mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Bug fixes. Add actual generation.
Sat Mar 5 01:09:33 2005 Soeren Sandmann <sandmann@redhat.com> * sfile.c: Bug fixes. Add actual generation.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
a6db295462
commit
18ca5ed131
@ -1,3 +1,7 @@
|
|||||||
|
Sat Mar 5 01:09:33 2005 Soeren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* sfile.c: Bug fixes. Add actual generation.
|
||||||
|
|
||||||
Fri Mar 4 13:47:13 2005 Søren Sandmann <sandmann@redhat.com>
|
Fri Mar 4 13:47:13 2005 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* sysprof.c: Remove include of non-existing tracing.h
|
* sysprof.c: Remove include of non-existing tracing.h
|
||||||
|
|||||||
4
Makefile
4
Makefile
@ -20,7 +20,7 @@ MODULE := sysprof-module
|
|||||||
all: $(BINARY) $(MODULE).o
|
all: $(BINARY) $(MODULE).o
|
||||||
|
|
||||||
$(BINARY): $(OBJS) depend
|
$(BINARY): $(OBJS) depend
|
||||||
gcc $(OBJS) $(LIBS) -o$(BINARY)
|
$(CC) $(OBJS) $(LIBS) -o$(BINARY)
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(BINARY) $(MODULE).o *~ core* depend.mk
|
rm -f $(OBJS) $(BINARY) $(MODULE).o *~ core* depend.mk
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ else
|
|||||||
MODCFLAGS += -DKERNEL24
|
MODCFLAGS += -DKERNEL24
|
||||||
|
|
||||||
$(MODULE).o: $(MODULE).c
|
$(MODULE).o: $(MODULE).c
|
||||||
gcc $(MODCFLAGS) $(MODULE).c -c -o$(MODULE).o
|
$(CC) $(MODCFLAGS) $(MODULE).c -c -o$(MODULE).o
|
||||||
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -60,7 +60,7 @@ create_format (void)
|
|||||||
|
|
||||||
return sformat_new (
|
return sformat_new (
|
||||||
sformat_new_record (
|
sformat_new_record (
|
||||||
"profile",
|
"profile", NULL,
|
||||||
sformat_new_integer ("size"),
|
sformat_new_integer ("size"),
|
||||||
sformat_new_list (
|
sformat_new_list (
|
||||||
"objects", NULL,
|
"objects", NULL,
|
||||||
|
|||||||
130
sfile.c
130
sfile.c
@ -121,7 +121,10 @@ transition_new (const char *element,
|
|||||||
{
|
{
|
||||||
Transition *t = g_new (Transition, 1);
|
Transition *t = g_new (Transition, 1);
|
||||||
|
|
||||||
|
g_assert (element || kind == VALUE);
|
||||||
|
|
||||||
t->element = element? g_strdup (element) : NULL;
|
t->element = element? g_strdup (element) : NULL;
|
||||||
|
t->kind = kind;
|
||||||
t->type = type;
|
t->type = type;
|
||||||
t->to = to;
|
t->to = to;
|
||||||
|
|
||||||
@ -155,18 +158,19 @@ sformat_free (SFormat *format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GQueue *
|
static GQueue *
|
||||||
fragment_queue (va_list args)
|
fragment_queue (Fragment *fragment1, va_list args)
|
||||||
{
|
{
|
||||||
GQueue *fragments = g_queue_new ();
|
GQueue *fragments = g_queue_new ();
|
||||||
Fragment *fragment;
|
Fragment *fragment;
|
||||||
|
|
||||||
|
g_queue_push_tail (fragments, fragment1);
|
||||||
|
|
||||||
fragment = va_arg (args, Fragment *);
|
fragment = va_arg (args, Fragment *);
|
||||||
while (fragment)
|
while (fragment)
|
||||||
{
|
{
|
||||||
g_queue_push_tail (fragments, fragment);
|
g_queue_push_tail (fragments, fragment);
|
||||||
fragment = va_arg (args, Fragment *);
|
fragment = va_arg (args, Fragment *);
|
||||||
}
|
}
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
return fragments;
|
return fragments;
|
||||||
}
|
}
|
||||||
@ -289,7 +293,7 @@ sformat_new_record (const char * name,
|
|||||||
/* Build queue of fragments */
|
/* Build queue of fragments */
|
||||||
va_start (args, content1);
|
va_start (args, content1);
|
||||||
|
|
||||||
fragments = fragment_queue (args);
|
fragments = fragment_queue (content1, args);
|
||||||
|
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
@ -402,7 +406,7 @@ state_transition_check (const State *state,
|
|||||||
|
|
||||||
for (list = state->transitions->head; list; list = list->next)
|
for (list = state->transitions->head; list; list = list->next)
|
||||||
{
|
{
|
||||||
Transition *transition;
|
Transition *transition = list->data;
|
||||||
|
|
||||||
if (transition->kind == kind &&
|
if (transition->kind == kind &&
|
||||||
strcmp (element, transition->element) == 0)
|
strcmp (element, transition->element) == 0)
|
||||||
@ -546,7 +550,7 @@ static gboolean
|
|||||||
is_list_type (SType type)
|
is_list_type (SType type)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -915,13 +919,6 @@ build_instructions (const char *contents, SFormat *format, int *n_instructions,
|
|||||||
build.instructions = g_array_new (TRUE, TRUE, sizeof (Instruction));
|
build.instructions = g_array_new (TRUE, TRUE, sizeof (Instruction));
|
||||||
|
|
||||||
parse_context = g_markup_parse_context_new (&parser, 0, &build, NULL);
|
parse_context = g_markup_parse_context_new (&parser, 0, &build, NULL);
|
||||||
if (!sformat_is_end_state (format, build.state))
|
|
||||||
{
|
|
||||||
set_invalid_content_error (err, "Unexpected end of file\n");
|
|
||||||
|
|
||||||
free_instructions ((Instruction *)build.instructions->data, build.instructions->len);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_markup_parse_context_parse (parse_context, contents, -1, err))
|
if (!g_markup_parse_context_parse (parse_context, contents, -1, err))
|
||||||
{
|
{
|
||||||
@ -929,6 +926,14 @@ build_instructions (const char *contents, SFormat *format, int *n_instructions,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sformat_is_end_state (format, build.state))
|
||||||
|
{
|
||||||
|
set_invalid_content_error (err, "Premature end of file\n");
|
||||||
|
|
||||||
|
free_instructions ((Instruction *)build.instructions->data, build.instructions->len);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!post_process_read_instructions ((Instruction *)build.instructions->data, build.instructions->len, err))
|
if (!post_process_read_instructions ((Instruction *)build.instructions->data, build.instructions->len, err))
|
||||||
{
|
{
|
||||||
free_instructions ((Instruction *)build.instructions->data, build.instructions->len);
|
free_instructions ((Instruction *)build.instructions->data, build.instructions->len);
|
||||||
@ -1034,7 +1039,7 @@ sfile_end_add (SFileOutput *file,
|
|||||||
file->state = state_transition_end (
|
file->state = state_transition_end (
|
||||||
file->state, name, &instruction.type, NULL);
|
file->state, name, &instruction.type, NULL);
|
||||||
|
|
||||||
g_return_if_fail (file->state && instruction.kind == END);
|
g_return_if_fail (file->state);
|
||||||
|
|
||||||
instruction.kind = END;
|
instruction.kind = END;
|
||||||
instruction.name = g_strdup (name);
|
instruction.name = g_strdup (name);
|
||||||
@ -1073,6 +1078,7 @@ sfile_add_string (SFileOutput *file,
|
|||||||
|
|
||||||
instruction.kind = VALUE;
|
instruction.kind = VALUE;
|
||||||
instruction.type = TYPE_STRING;
|
instruction.type = TYPE_STRING;
|
||||||
|
instruction.name = g_strdup (name);
|
||||||
instruction.u.string.value = g_strdup (string);
|
instruction.u.string.value = g_strdup (string);
|
||||||
|
|
||||||
g_array_append_val (file->instructions, instruction);
|
g_array_append_val (file->instructions, instruction);
|
||||||
@ -1112,13 +1118,109 @@ sfile_add_pointer (SFileOutput *file,
|
|||||||
g_array_append_val (file->instructions, instruction);
|
g_array_append_val (file->instructions, instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_indent (GString *output, int indent)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < indent; ++i)
|
||||||
|
g_string_append_c (output, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_integer (GString *output, int value)
|
||||||
|
{
|
||||||
|
g_string_append_printf (output, "%d", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_string (GString *output, const char *str)
|
||||||
|
{
|
||||||
|
g_string_append_printf (output, "%s", str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_begin_tag (GString *output, int indent, const char *name)
|
||||||
|
{
|
||||||
|
add_indent (output, indent);
|
||||||
|
g_string_append_printf (output, "<%s>", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_end_tag (GString *output, int indent, const char *name)
|
||||||
|
{
|
||||||
|
add_indent (output, indent);
|
||||||
|
g_string_append_printf (output, "</%s>", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_nl (GString *output)
|
||||||
|
{
|
||||||
|
g_string_append_c (output, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
sfile_output_save (SFileOutput *sfile,
|
sfile_output_save (SFileOutput *sfile,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
GError **err)
|
GError **err)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
Instruction *instructions;
|
||||||
|
GString *output;
|
||||||
|
int indent;
|
||||||
|
|
||||||
return FALSE; /* FIXME */
|
g_return_val_if_fail (sfile != NULL, FALSE);
|
||||||
|
|
||||||
|
instructions = (Instruction *)sfile->instructions->data;
|
||||||
|
|
||||||
|
indent = 0;
|
||||||
|
output = g_string_new ("");
|
||||||
|
for (i = 0; i < sfile->instructions->len; ++i)
|
||||||
|
{
|
||||||
|
Instruction *instruction = &(instructions[i]);
|
||||||
|
|
||||||
|
switch (instruction->kind)
|
||||||
|
{
|
||||||
|
case BEGIN:
|
||||||
|
add_begin_tag (output, indent, instruction->name);
|
||||||
|
add_nl (output);
|
||||||
|
indent += 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case END:
|
||||||
|
indent -= 4;
|
||||||
|
add_end_tag (output, indent, instruction->name);
|
||||||
|
add_nl (output);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VALUE:
|
||||||
|
add_begin_tag (output, indent, instruction->name);
|
||||||
|
switch (instruction->type)
|
||||||
|
{
|
||||||
|
case TYPE_INTEGER:
|
||||||
|
add_integer (output, instruction->u.integer.value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_POINTER:
|
||||||
|
add_integer (output, instruction->u.pointer.target_id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_STRING:
|
||||||
|
add_string (output, instruction->u.string.value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
add_end_tag (output, 0, instruction->name);
|
||||||
|
add_nl (output);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: write to disk */
|
||||||
|
g_print (output->str);
|
||||||
|
|
||||||
|
g_string_free (output, TRUE);
|
||||||
|
|
||||||
|
return TRUE; /* FIXME */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user