SF.net SVN: geany-plugins:[2125] trunk/geany-plugins/debugger/src
cesspit at users.sourceforge.net
cesspit at xxxxx
Sat Aug 6 20:44:04 UTC 2011
Revision: 2125
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2125&view=rev
Author: cesspit
Date: 2011-08-06 20:44:03 +0000 (Sat, 06 Aug 2011)
Log Message:
-----------
debugger plugin:
- distinct markers for conditional/with hitscount breakpoints
- stack frames markers for frames other than top
Modified Paths:
--------------
trunk/geany-plugins/debugger/src/breakpoints.c
trunk/geany-plugins/debugger/src/debug.c
trunk/geany-plugins/debugger/src/markers.c
trunk/geany-plugins/debugger/src/markers.h
trunk/geany-plugins/debugger/src/stree.c
Modified: trunk/geany-plugins/debugger/src/breakpoints.c
===================================================================
--- trunk/geany-plugins/debugger/src/breakpoints.c 2011-08-06 13:30:45 UTC (rev 2124)
+++ trunk/geany-plugins/debugger/src/breakpoints.c 2011-08-06 20:44:03 UTC (rev 2125)
@@ -183,7 +183,11 @@
void handle_hitscount_set(breakpoint* bp, gboolean success)
{
if (success)
+ {
bptree_set_hitscount(bp->iter, bp->hitscount);
+ markers_remove_breakpoint(bp);
+ markers_add_breakpoint(bp);
+ }
else
dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
}
@@ -200,6 +204,8 @@
{
/* set condition in breaks tree */
bptree_set_condition(bp->iter, bp->condition);
+ markers_remove_breakpoint(bp);
+ markers_add_breakpoint(bp);
}
else
{
@@ -221,16 +227,9 @@
void handle_switch(breakpoint* bp, gboolean success)
{
/* remove old and set new marker */
- if (bp->enabled)
- {
- markers_remove_breakpoint_disabled(bp->file, bp->line);
- markers_add_breakpoint(bp);
- }
- else
- {
- markers_remove_breakpoint(bp);
- markers_add_breakpoint_disabled(bp->file, bp->line);
- }
+ markers_remove_breakpoint(bp);
+ markers_add_breakpoint(bp);
+
/* set checkbox in breaks tree */
bptree_set_enabled(bp->iter, bp->enabled);
}
Modified: trunk/geany-plugins/debugger/src/debug.c
===================================================================
--- trunk/geany-plugins/debugger/src/debug.c 2011-08-06 13:30:45 UTC (rev 2124)
+++ trunk/geany-plugins/debugger/src/debug.c 2011-08-06 20:44:03 UTC (rev 2125)
@@ -124,13 +124,10 @@
static GtkWidget **sensitive_widget[] = {&stree, &wtree, <ree, NULL};
/*
- * information about current instruction
- * used to remove markers when stepping forward
+ * current stack for holding
+ * position of ffreames markers
*/
-struct ci {
- char file[FILENAME_MAX + 1];
- int line;
-} current_instruction;
+static GList* stack = NULL;
/*
* pages which are loaded in debugger and therefore, are set readonly
@@ -149,6 +146,44 @@
static GHashTable *calltips = NULL;
/*
+ * removes stack margin markers
+ */
+ void remove_stack_markers()
+{
+ frame *current = (frame*)stack->data;
+ if (current->have_source)
+ {
+ markers_remove_current_instruction(current->file, current->line);
+ }
+ GList *iter = stack->next;
+ while (iter)
+ {
+ frame *next = (frame*)iter->data;
+ markers_remove_frame(next->file, next->line);
+ iter = iter->next;
+ }
+}
+
+/*
+ * removes stack margin markers
+ */
+ void add_stack_markers()
+{
+ frame *current = (frame*)stack->data;
+ if (current->have_source)
+ {
+ markers_add_current_instruction(current->file, current->line);
+ }
+ GList *iter = stack->next;
+ while (iter)
+ {
+ frame *next = (frame*)iter->data;
+ markers_add_frame(next->file, next->line);
+ iter = iter->next;
+ }
+}
+
+/*
* Handlers for GUI maked changes in watches
*/
@@ -532,16 +567,18 @@
debug_state = DBS_RUNNING;
/* if curren instruction marker was set previously - remove it */
- if (strlen(current_instruction.file))
+ if (stack)
{
- markers_remove_current_instruction(current_instruction.file, current_instruction.line);
- strcpy(current_instruction.file, "");
+ remove_stack_markers();
+ g_list_free(stack);
+ stack = NULL;
}
/* disable widgets */
enable_sensitive_widgets(FALSE);
}
+
/*
* called from debug module when debugger is being stopped
*/
@@ -574,19 +611,8 @@
stree_clear();
/* get current stack trace and put in the tree view */
- GList* stack = active_module->get_stack();
-
- /* if upper frame has source file - remember the file and the line for
- the current instruction marker */
- frame *f = (frame*)stack->data;
- if (f->have_source)
- {
- strcpy(current_instruction.file, f->file);
- current_instruction.line = (int)f->line;
- }
+ stack = active_module->get_stack();
- stack = g_list_reverse(stack);
-
GList *iter = stack;
while (iter)
{
@@ -594,8 +620,6 @@
stree_add(f);
iter = g_list_next(iter);
}
- g_list_foreach(stack, (GFunc)g_free, NULL);
- g_list_free(stack);
stree_select_first();
/* files */
@@ -654,14 +678,19 @@
GList *watches = active_module->get_watches();
update_variables(GTK_TREE_VIEW(wtree), NULL, watches);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW(wtree));
-
- if (strlen(current_instruction.file))
+
+ if (stack)
{
- /* open current instruction position */
- editor_open_position(current_instruction.file, current_instruction.line);
+ frame *current = (frame*)stack->data;
+ if (current->have_source)
+ {
+ /* open current instruction position */
+ editor_open_position(current->file, current->line);
+ }
+
/* add current instruction marker */
- markers_add_current_instruction(current_instruction.file, current_instruction.line);
+ add_stack_markers();
}
/* enable widgets */
@@ -678,10 +707,11 @@
static void on_debugger_exited (int code)
{
/* remove marker for current instruction if was set */
- if (strlen(current_instruction.file))
+ if (stack)
{
- markers_remove_current_instruction(current_instruction.file, current_instruction.line);
- strcpy(current_instruction.file, "");
+ remove_stack_markers();
+ g_list_free(stack);
+ stack = NULL;
}
/* clear watch page */
@@ -903,9 +933,13 @@
close(pty_master);
close(pty_slave);
- /* remove current instruction marker if present */
- if (strlen(current_instruction.file))
- markers_remove_current_instruction(current_instruction.file, current_instruction.line);
+ /* remove stack markers if present */
+ if (stack)
+ {
+ remove_stack_markers();
+ g_list_free(stack);
+ stack = NULL;
+ }
}
/*
@@ -1224,7 +1258,8 @@
*/
gboolean debug_current_instruction_have_sources()
{
- return strlen(current_instruction.file);
+ frame *current = (frame*)stack->data;
+ return current->have_source ? strlen(current->file) : 0;
}
/*
@@ -1232,7 +1267,8 @@
*/
void debug_jump_to_current_instruction()
{
- editor_open_position(current_instruction.file, current_instruction.line);
+ frame *current = (frame*)stack->data;
+ editor_open_position(current->file, current->line);
}
/*
Modified: trunk/geany-plugins/debugger/src/markers.c
===================================================================
--- trunk/geany-plugins/debugger/src/markers.c 2011-08-06 13:30:45 UTC (rev 2124)
+++ trunk/geany-plugins/debugger/src/markers.c 2011-08-06 20:44:03 UTC (rev 2125)
@@ -31,21 +31,30 @@
#include "breakpoints.h"
/* markers identifiers */
-#define MARKER_FIRST 12
-#define MARKER_BREAKPOINT_ENABLED MARKER_FIRST
-#define MARKER_BREAKPOINT_DISABLED (MARKER_FIRST + 1)
-#define MARKER_CURRENT_INSTRUCTION_BACKGROUND (MARKER_FIRST + 2)
-#define MARKER_CURRENT_INSTRUCTION_ARROW (MARKER_FIRST + 3)
-#define MARKER_FRAME (MARKER_FIRST + 4)
+#define M_FIRST 12
+#define M_BP_ENABLED M_FIRST
+#define M_BP_DISABLED (M_FIRST + 1)
+#define M_CI_BACKGROUND (M_FIRST + 2)
+#define M_BP_ENABLED_CONDITIONAL (M_FIRST + 3)
+#define M_BP_ENABLED_HITS (M_FIRST + 4)
+#define M_BP_ENABLED_HITS_CONDITIONAL (M_FIRST + 5)
+#define M_BP_DISABLED_CONDITIONAL (M_FIRST + 6)
+#define M_BP_DISABLED_HITS (M_FIRST + 7)
+#define M_BP_DISABLED_HITS_CONDITIONAL (M_FIRST + 8)
+#define M_CI_ARROW (M_FIRST + 9)
+#define M_FRAME (M_FIRST + 10)
+#define MARKER_PRESENT(mask, marker) (mask && (0x01 << marker))
+
/* markers colors */
#define RGB(R,G,B) (R | (G << 8) | (B << 16))
-#define RED RGB(255,0,0)
+#define RED RGB(255,0,0)
#define GREEN RGB(0,255,0)
-#define BLUE RGB(0,0,255)
+#define BLUE RGB(0,0,255)
#define YELLOW RGB(255,255,0)
#define BLACK RGB(0,0,0)
#define WHITE RGB(255,255,255)
+#define PINK RGB(255,192,203)
#define LIGHT_YELLOW RGB(200,200,0)
@@ -55,30 +64,57 @@
void markers_set_for_document(ScintillaObject *sci)
{
/* enabled breakpoint */
- scintilla_send_message(sci, SCI_MARKERDEFINE, MARKER_BREAKPOINT_ENABLED, SC_MARK_SMALLRECT);
- scintilla_send_message(sci, SCI_MARKERSETBACK, MARKER_BREAKPOINT_ENABLED, RED);
- scintilla_send_message(sci, SCI_MARKERSETFORE, MARKER_BREAKPOINT_ENABLED, RED);
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_ENABLED, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_BP_ENABLED, RED);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_ENABLED, RED);
+
+ /* enabled breakpoint - condition */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_ENABLED_CONDITIONAL, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_BP_ENABLED_CONDITIONAL, BLUE);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_ENABLED_CONDITIONAL, BLUE);
+ /* enabled breakpoint - hits */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_ENABLED_HITS, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_BP_ENABLED_HITS, YELLOW);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_ENABLED_HITS, YELLOW);
+
+ /* enabled breakpoint - hits, condition */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_ENABLED_HITS_CONDITIONAL, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_BP_ENABLED_HITS_CONDITIONAL, GREEN);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_ENABLED_HITS_CONDITIONAL, GREEN);
+
/* disabled breakpoint */
- scintilla_send_message(sci, SCI_MARKERDEFINE, MARKER_BREAKPOINT_DISABLED, SC_MARK_SMALLRECT);
- scintilla_send_message(sci, SCI_MARKERSETFORE, MARKER_BREAKPOINT_DISABLED, RED);
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_DISABLED, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_DISABLED, RED);
+ /* disabled breakpoint - condition */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_DISABLED_CONDITIONAL, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_DISABLED_CONDITIONAL, BLUE);
+
+ /* disabled breakpoint - hits */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_DISABLED_HITS, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_DISABLED_HITS, YELLOW);
+
+ /* disabled breakpoint - hits, condition */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_BP_DISABLED_HITS_CONDITIONAL, SC_MARK_ROUNDRECT);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_BP_DISABLED_HITS_CONDITIONAL, GREEN);
+
/* currect instruction background */
- scintilla_send_message(sci, SCI_MARKERDEFINE, MARKER_CURRENT_INSTRUCTION_BACKGROUND, SC_MARK_BACKGROUND);
- scintilla_send_message(sci, SCI_MARKERSETBACK, MARKER_CURRENT_INSTRUCTION_BACKGROUND, YELLOW);
- scintilla_send_message(sci, SCI_MARKERSETFORE, MARKER_CURRENT_INSTRUCTION_BACKGROUND, YELLOW);
- scintilla_send_message(sci, SCI_MARKERSETALPHA, MARKER_CURRENT_INSTRUCTION_BACKGROUND, 75);
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_CI_BACKGROUND, SC_MARK_BACKGROUND);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_CI_BACKGROUND, YELLOW);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_CI_BACKGROUND, YELLOW);
+ scintilla_send_message(sci, SCI_MARKERSETALPHA, M_CI_BACKGROUND, 75);
/* currect instruction arrow */
- scintilla_send_message(sci, SCI_MARKERDEFINE, MARKER_CURRENT_INSTRUCTION_ARROW, SC_MARK_SHORTARROW);
- scintilla_send_message(sci, SCI_MARKERSETBACK, MARKER_CURRENT_INSTRUCTION_ARROW, YELLOW);
- scintilla_send_message(sci, SCI_MARKERSETFORE, MARKER_CURRENT_INSTRUCTION_ARROW, BLACK);
- scintilla_send_message(sci, SCI_MARKERSETALPHA, MARKER_CURRENT_INSTRUCTION_ARROW, 75);
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_CI_ARROW, SC_MARK_SHORTARROW);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_CI_ARROW, YELLOW);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_CI_ARROW, BLACK);
+ scintilla_send_message(sci, SCI_MARKERSETALPHA, M_CI_ARROW, 75);
- /* frame marker */
- scintilla_send_message(sci, SCI_MARKERDEFINE, MARKER_FRAME, SC_MARK_SHORTARROW);
- scintilla_send_message(sci, SCI_MARKERSETBACK, MARKER_FRAME, LIGHT_YELLOW);
- scintilla_send_message(sci, SCI_MARKERSETFORE, MARKER_FRAME, LIGHT_YELLOW);
+ /* frame marker current */
+ scintilla_send_message(sci, SCI_MARKERDEFINE, M_FRAME, SC_MARK_SHORTARROW);
+ scintilla_send_message(sci, SCI_MARKERSETBACK, M_FRAME, WHITE);
+ scintilla_send_message(sci, SCI_MARKERSETFORE, M_FRAME, BLACK);
}
/*
@@ -103,62 +139,110 @@
GeanyDocument *doc = document_find_by_filename(bp->file);
if (doc)
{
- sci_set_marker_at_line(doc->editor->sci, bp->line - 1,
- bp->enabled ? MARKER_BREAKPOINT_ENABLED : MARKER_BREAKPOINT_DISABLED);
+ int marker;
+ if (bp->enabled)
+ {
+ if (strlen(bp->condition))
+ {
+ marker = bp->hitscount ? M_BP_ENABLED_HITS_CONDITIONAL : M_BP_ENABLED_CONDITIONAL;
+ }
+ else if (bp->hitscount)
+ {
+ marker = M_BP_ENABLED_HITS;
+ }
+ else
+ {
+ marker = M_BP_ENABLED;
+ }
+ }
+ else
+ {
+ if (strlen(bp->condition))
+ {
+ marker = bp->hitscount ? M_BP_DISABLED_HITS_CONDITIONAL : M_BP_DISABLED_CONDITIONAL;
+ }
+ else if (bp->hitscount)
+ {
+ marker = M_BP_DISABLED_HITS;
+ }
+ else
+ {
+ marker = M_BP_DISABLED;
+ }
+ }
+ sci_set_marker_at_line(doc->editor->sci, bp->line - 1, marker);
}
}
/*
* removes breakpoints marker
*/
-void markers_remove_breakpoint(breakpoint* bp)
+void markers_remove_breakpoint(breakpoint *bp)
{
+ static int breakpoint_markers[] = {
+ M_BP_ENABLED,
+ M_BP_ENABLED_CONDITIONAL,
+ M_BP_ENABLED_HITS,
+ M_BP_ENABLED_HITS_CONDITIONAL,
+ M_BP_DISABLED,
+ M_BP_DISABLED_CONDITIONAL,
+ M_BP_DISABLED_HITS,
+ M_BP_DISABLED_HITS_CONDITIONAL
+ };
+
GeanyDocument *doc = document_find_by_filename(bp->file);
if (doc)
{
- /* delete enabled marker */
- sci_delete_marker_at_line(doc->editor->sci, bp->line - 1, MARKER_BREAKPOINT_ENABLED);
- /* delete disabled marker */
- sci_delete_marker_at_line(doc->editor->sci, bp->line - 1, MARKER_BREAKPOINT_DISABLED);
+ int markers = scintilla_send_message(doc->editor->sci, SCI_MARKERGET, bp->line - 1, (long)NULL);
+ int markers_count = sizeof(breakpoint_markers) / sizeof(breakpoint_markers[0]);
+ int i = 0;
+ for (; i < markers_count; i++)
+ {
+ int marker = breakpoint_markers[i];
+ if (markers & (0x01 << marker))
+ {
+ sci_delete_marker_at_line(doc->editor->sci, bp->line - 1, marker);
+ }
+ }
}
}
/*
- * adds disabled breakpoint marker
+ * adds current instruction marker
*/
-void markers_add_breakpoint_disabled(char* file, int line)
+void markers_add_current_instruction(char* file, int line)
{
GeanyDocument *doc = document_find_by_filename(file);
- sci_set_marker_at_line(doc->editor->sci, line - 1, MARKER_BREAKPOINT_DISABLED);
+ sci_set_marker_at_line(doc->editor->sci, line - 1, M_CI_ARROW);
+ sci_set_marker_at_line(doc->editor->sci, line - 1, M_CI_BACKGROUND);
}
/*
- * removes disabled breakpoint marker
+ * removes current instruction marker
*/
-void markers_remove_breakpoint_disabled(char* file, int line)
+void markers_remove_current_instruction(char* file, int line)
{
GeanyDocument *doc = document_find_by_filename(file);
- sci_delete_marker_at_line(doc->editor->sci, line - 1, MARKER_BREAKPOINT_DISABLED);
+ sci_delete_marker_at_line(doc->editor->sci, line - 1, M_CI_ARROW);
+ sci_delete_marker_at_line(doc->editor->sci, line - 1, M_CI_BACKGROUND);
+ scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
}
/*
- * adds current instruction marker
+ * adds frame marker
*/
-void markers_add_current_instruction(char* file, int line)
+void markers_add_frame(char* file, int line)
{
GeanyDocument *doc = document_find_by_filename(file);
- sci_set_marker_at_line(doc->editor->sci, line - 1, MARKER_CURRENT_INSTRUCTION_ARROW);
- sci_set_marker_at_line(doc->editor->sci, line - 1, MARKER_CURRENT_INSTRUCTION_BACKGROUND);
+ sci_set_marker_at_line(doc->editor->sci, line - 1, M_FRAME);
}
/*
- * removes current instruction marker
+ * removes frame marker
*/
-void markers_remove_current_instruction(char* file, int line)
+void markers_remove_frame(char* file, int line)
{
GeanyDocument *doc = document_find_by_filename(file);
- sci_delete_marker_at_line(doc->editor->sci, line - 1, MARKER_CURRENT_INSTRUCTION_ARROW);
- sci_delete_marker_at_line(doc->editor->sci, line - 1, MARKER_CURRENT_INSTRUCTION_BACKGROUND);
+ sci_delete_marker_at_line(doc->editor->sci, line - 1, M_FRAME);
scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
}
-
Modified: trunk/geany-plugins/debugger/src/markers.h
===================================================================
--- trunk/geany-plugins/debugger/src/markers.h 2011-08-06 13:30:45 UTC (rev 2124)
+++ trunk/geany-plugins/debugger/src/markers.h 2011-08-06 20:44:03 UTC (rev 2125)
@@ -25,5 +25,7 @@
void markers_remove_breakpoint(breakpoint* bp);
void markers_add_current_instruction(char* file, int line);
void markers_remove_current_instruction(char* file, int line);
+void markers_add_frame(char* file, int line);
+void markers_remove_frame(char* file, int line);
Modified: trunk/geany-plugins/debugger/src/stree.c
===================================================================
--- trunk/geany-plugins/debugger/src/stree.c 2011-08-06 13:30:45 UTC (rev 2124)
+++ trunk/geany-plugins/debugger/src/stree.c 2011-08-06 20:44:03 UTC (rev 2125)
@@ -194,7 +194,7 @@
void stree_add(frame *f)
{
GtkTreeIter iter;
- gtk_list_store_prepend (store, &iter);
+ gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
S_ADRESS, f->address,
S_FUNCTION, f->function,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Plugins-Commits
mailing list