Permalink
Browse files

Merge pull request #1 from cesspit/master

fixing fixed length address bug
  • Loading branch information...
2 parents 137c00c + 4d7dd61 commit 2383726b8b52e0bfdb58469a3fec83d5c2a7bd49 @cesspit cesspit committed Dec 16, 2011
Showing with 47 additions and 13 deletions.
  1. +7 −7 debugger/src/dbm_gdb.c
  2. +4 −1 debugger/src/debug.c
  3. +29 −0 debugger/src/debug_module.c
  4. +7 −5 debugger/src/debug_module.h
@@ -879,18 +879,18 @@ GList* get_stack()
gchar **next = frames + 1;
while (*next)
{
- frame *f = malloc(sizeof(frame));
+ frame *f = frame_new();
/* adresss */
gchar* pos = strstr(*next, "addr=\"") + strlen("addr=\"");
*strchr(pos, '\"') = '\0';
- strcpy(f->address, pos);
+ f->address = g_strdup(pos);
pos += strlen(pos) + 1;
/* function */
pos = strstr(pos, "func=\"") + strlen("func=\"");
*strchr(pos, '\"') = '\0';
- strcpy(f->function, pos);
+ f->function = g_strdup(pos);
pos += strlen(pos) + 1;
/* file: fullname | file | from */
@@ -903,27 +903,27 @@ GList* get_stack()
fullname += strlen("fullname=\"");
pos = fullname;
*strchr(pos, '\"') = '\0';
- strcpy(f->file, pos);
+ f->file = g_strdup(pos);
pos += strlen(pos) + 1;
}
else if (file)
{
file += strlen("file=\"");
pos = file;
*strchr(pos, '\"') = '\0';
- strcpy(f->file, pos);
+ f->file = g_strdup(pos);
pos += strlen(pos) + 1;
}
else if (from)
{
from += strlen("from=\"");
pos = from;
*strchr(pos, '\"') = '\0';
- strcpy(f->file, pos);
+ f->file = g_strdup(pos);
pos += strlen(pos) + 1;
}
else
- strcpy(f->file, "");
+ f->file = g_strdup("");
/* whether source is available */
f->have_source = fullname ? TRUE : FALSE;
@@ -174,7 +174,7 @@ static GHashTable *calltips = NULL;
}
/*
- * removes stack margin markers
+ * add stack margin markers
*/
void add_stack_markers()
{
@@ -591,6 +591,7 @@ static void on_debugger_run ()
if (stack)
{
remove_stack_markers();
+ g_list_foreach(stack, (GFunc)frame_free, NULL);
g_list_free(stack);
stack = NULL;
}
@@ -741,6 +742,7 @@ static void on_debugger_exited (int code)
if (stack)
{
remove_stack_markers();
+ g_list_foreach(stack, (GFunc)frame_free, NULL);
g_list_free(stack);
stack = NULL;
}
@@ -963,6 +965,7 @@ void debug_destroy()
if (stack)
{
remove_stack_markers();
+ g_list_foreach(stack, (GFunc)frame_free, NULL);
g_list_free(stack);
stack = NULL;
}
@@ -23,6 +23,8 @@
* Contains variable structure constructors and destructors.
*/
+#include <stdlib.h>
+#include <memory.h>
#include <gtk/gtk.h>
@@ -73,3 +75,30 @@ void variable_reset(variable *var)
g_string_assign(var->value, "");
var->has_children = var->evaluated = FALSE;
}
+
+/* creates new frame */
+frame* frame_new()
+{
+ frame *f = (frame*)malloc(sizeof(frame));
+ memset((void*)f, 0, sizeof(frame));
+ return f;
+}
+
+/* frees a frame */
+void frame_free(frame* f)
+{
+ if (f->address)
+ {
+ g_free(f->address);
+ }
+ if (f->function)
+ {
+ g_free(f->function);
+ }
+ if (f->file)
+ {
+ g_free(f->file);
+ }
+
+ g_free(f);
+}
@@ -70,9 +70,9 @@ typedef struct _variable {
/* type to hold information about a stack frame */
typedef struct _frame {
- gchar address[11];
- gchar function[128];
- gchar file[FILENAME_MAX];
+ gchar *address;
+ gchar *function;
+ gchar *file;
gint line;
gboolean have_source;
} frame;
@@ -154,8 +154,10 @@ typedef struct _dbg_module {
error_message, \
MODULE_FEATURES }
-void variable_free(variable *var);
+void variable_free(variable *var);
variable* variable_new(gchar *name, variable_type vt);
variable* variable_new2(gchar *name, gchar *internal, variable_type vt);
-void variable_reset(variable *var);
+void variable_reset(variable *var);
+frame* frame_new();
+void frame_free(frame* f);

0 comments on commit 2383726

Please sign in to comment.