From 00b2bad465eaa08f94998de03f578885a98706ec Mon Sep 17 00:00:00 2001 From: Stephane Carrez Date: Fri, 30 Aug 2002 20:07:05 +0000 Subject: * tuiSourceWin.h (tui_update_all_breakpoint_info): Declare. (tui_update_breakpoint_info): Declare. (tuiSetHasBreakAt, tuiAllSetHasBreakAt): Remove. * tuiSourceWin.c (tuiUpdateSourceWindowAsIs): Update breakpoint information using tui_update_breakpoint_info. (tui_update_all_breakpoint_info): New function to refresh all execution windows. (tui_update_breakpoint_info): New function to recompute the status of exec info window from breakpoints. (tuiSetHasBreakAt, tuiAllSetHasBreakAt): Remove. (tuiSetExecInfoContent): Use the exec info flags computed by tui_update_breakpoint_info to display a short status about breakpoints. * tuiData.h (TuiExecInfoContent): New for exec info string. (TuiWhichElement): Use it. (TUI_BP_ENABLED, TUI_BP_DISABLED, TUI_BP_HIT): New defines. (TUI_BP_CONDITIONAL, TUI_BP_HARDWARE): New defines. (TUI_BP_HIT_POS, TUI_BP_BREAK_POS, TUI_EXEC_POS): Likewise. (TUI_EXECINFO_SIZE): Likewise. * tuiData.c (initContentElement): Clear exec info string. * tui-hooks.c (get_breakpoint): Remove. (tui_event_create_breakpoint): Call tui_update_all_breakpoint_info. (tui_event_delete_breakpoint): Likewise. (tui_event_modify_breakpoint): Likewise. --- gdb/tui/ChangeLog | 29 ++++++++ gdb/tui/tui-hooks.c | 60 +--------------- gdb/tui/tuiData.c | 3 +- gdb/tui/tuiData.h | 16 ++++- gdb/tui/tuiSourceWin.c | 185 ++++++++++++++++++++++++------------------------- gdb/tui/tuiSourceWin.h | 13 +++- 6 files changed, 152 insertions(+), 154 deletions(-) (limited to 'gdb') diff --git a/gdb/tui/ChangeLog b/gdb/tui/ChangeLog index 0e19a12..ed31bfd 100644 --- a/gdb/tui/ChangeLog +++ b/gdb/tui/ChangeLog @@ -1,3 +1,32 @@ +2002-08-30 Stephane Carrez + + * tuiSourceWin.h (tui_update_all_breakpoint_info): Declare. + (tui_update_breakpoint_info): Declare. + (tuiSetHasBreakAt, tuiAllSetHasBreakAt): Remove. + + * tuiSourceWin.c (tuiUpdateSourceWindowAsIs): Update breakpoint + information using tui_update_breakpoint_info. + (tui_update_all_breakpoint_info): New function to refresh all + execution windows. + (tui_update_breakpoint_info): New function to recompute the status + of exec info window from breakpoints. + (tuiSetHasBreakAt, tuiAllSetHasBreakAt): Remove. + (tuiSetExecInfoContent): Use the exec info flags computed by + tui_update_breakpoint_info to display a short status about breakpoints. + + * tuiData.h (TuiExecInfoContent): New for exec info string. + (TuiWhichElement): Use it. + (TUI_BP_ENABLED, TUI_BP_DISABLED, TUI_BP_HIT): New defines. + (TUI_BP_CONDITIONAL, TUI_BP_HARDWARE): New defines. + (TUI_BP_HIT_POS, TUI_BP_BREAK_POS, TUI_EXEC_POS): Likewise. + (TUI_EXECINFO_SIZE): Likewise. + * tuiData.c (initContentElement): Clear exec info string. + + * tui-hooks.c (get_breakpoint): Remove. + (tui_event_create_breakpoint): Call tui_update_all_breakpoint_info. + (tui_event_delete_breakpoint): Likewise. + (tui_event_modify_breakpoint): Likewise. + 2002-08-29 Stephane Carrez * tui.c (tuiGetLowDisassemblyAddress): Moved from here. diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index d605194..fe144a3 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -167,44 +167,12 @@ tui_register_changed_hook (int regno) } } -extern struct breakpoint *breakpoint_chain; - -/* Find a breakpoint given its number. Returns null if not found. */ -static struct breakpoint * -get_breakpoint (int number) -{ - struct breakpoint *bp; - - for (bp = breakpoint_chain; bp; bp = bp->next) - { - if (bp->number == number) - return bp; - } - return 0; -} - /* Breakpoint creation hook. Update the screen to show the new breakpoint. */ static void tui_event_create_breakpoint (int number) { - struct breakpoint *bp; - - bp = get_breakpoint (number); - if (bp) - { - switch (bp->type) - { - case bp_breakpoint: - case bp_hardware_breakpoint: - tuiAllSetHasBreakAt (bp, 1); - tuiUpdateAllExecInfos (); - break; - - default: - break; - } - } + tui_update_all_breakpoint_info (); } /* Breakpoint deletion hook. @@ -212,35 +180,13 @@ tui_event_create_breakpoint (int number) static void tui_event_delete_breakpoint (int number) { - struct breakpoint *bp; - struct breakpoint *b; - int clearIt; - - bp = get_breakpoint (number); - if (bp == 0) - return; - - /* Before turning off the visuals for the bp, check to see that - there are no other bps at the same address. */ - clearIt = 0; - for (b = breakpoint_chain; b; b = b->next) - { - clearIt = (b == bp || b->address != bp->address); - if (!clearIt) - break; - } - - if (clearIt) - { - tuiAllSetHasBreakAt (bp, 0); - tuiUpdateAllExecInfos (); - } + tui_update_all_breakpoint_info (); } static void tui_event_modify_breakpoint (int number) { - ; + tui_update_all_breakpoint_info (); } static void diff --git a/gdb/tui/tuiData.c b/gdb/tui/tuiData.c index 45508e0..29ed9b0 100644 --- a/gdb/tui/tuiData.c +++ b/gdb/tui/tuiData.c @@ -888,7 +888,8 @@ initContentElement (TuiWinElementPtr element, TuiWinType type) element->whichElement.locator.addr = 0; break; case EXEC_INFO_WIN: - element->whichElement.simpleString = blankStr (); + memset(element->whichElement.simpleString, ' ', + sizeof(element->whichElement.simpleString)); break; default: break; diff --git a/gdb/tui/tuiData.h b/gdb/tui/tuiData.h index 36d7853..9de5c6f 100644 --- a/gdb/tui/tuiData.h +++ b/gdb/tui/tuiData.h @@ -200,6 +200,20 @@ typedef struct _TuiLocatorElement } TuiLocatorElement, *TuiLocatorElementPtr; +/* Flags to tell what kind of breakpoint is at current line. */ +#define TUI_BP_ENABLED 0x01 +#define TUI_BP_DISABLED 0x02 +#define TUI_BP_HIT 0x04 +#define TUI_BP_CONDITIONAL 0x08 +#define TUI_BP_HARDWARE 0x10 + +/* Position of breakpoint markers in the exec info string. */ +#define TUI_BP_HIT_POS 0 +#define TUI_BP_BREAK_POS 1 +#define TUI_EXEC_POS 2 +#define TUI_EXECINFO_SIZE 4 + +typedef char TuiExecInfoContent[TUI_EXECINFO_SIZE]; /* An content element in a window */ typedef union @@ -209,7 +223,7 @@ typedef union TuiDataElement data; /* elements of dataWindow */ TuiCommandElement command; /* command elements */ TuiLocatorElement locator; /* locator elements */ - char *simpleString; /* simple char based elements */ + TuiExecInfoContent simpleString; /* simple char based elements */ } TuiWhichElement, *TuiWhichElementPtr; diff --git a/gdb/tui/tuiSourceWin.c b/gdb/tui/tuiSourceWin.c index b2ce594..04f778c 100644 --- a/gdb/tui/tuiSourceWin.c +++ b/gdb/tui/tuiSourceWin.c @@ -120,7 +120,7 @@ tuiUpdateSourceWindowAsIs (TuiWinInfoPtr winInfo, struct symtab *s, } else { - tuiEraseSourceContent (winInfo, NO_EMPTY_SOURCE_PROMPT); + tui_update_breakpoint_info (winInfo, 0); tuiShowSourceContent (winInfo); tuiUpdateExecInfo (winInfo); if (winInfo->generic.type == SRC_WIN) @@ -398,67 +398,85 @@ tuiSetIsExecPointAt (TuiLineOrAddress l, TuiWinInfoPtr winInfo) return; } /* tuiSetIsExecPointAt */ -/* - ** tuiSetHasBreakAt(). - ** Set or clear the hasBreak flag in the line whose line is lineNo. - */ +/* Update the execution windows to show the active breakpoints. + This is called whenever a breakpoint is inserted, removed or + has its state changed. */ void -tuiSetHasBreakAt (struct breakpoint *bp, TuiWinInfoPtr winInfo, int hasBreak) +tui_update_all_breakpoint_info () { + TuiList* list = sourceWindows (); int i; - TuiWinContent content = (TuiWinContent) winInfo->generic.content; - i = 0; - while (i < winInfo->generic.contentSize) + for (i = 0; i < list->count; i++) { - int gotIt; - TuiGenWinInfoPtr locator = locatorWinInfoPtr (); - - if (winInfo == srcWin) - { - TuiSourceInfoPtr src = &winInfo->detail.sourceInfo; + TuiWinInfoPtr win = (TuiWinInfoPtr) list->list[i]; - gotIt = (src->filename != (char *) NULL && - bp->source_file != NULL && - (strcmp (bp->source_file, src->filename) == 0) && - content[i]->whichElement.source.lineOrAddr.lineNo == - bp->line_number); - } - else - gotIt = (content[i]->whichElement.source.lineOrAddr.addr - == bp->address); - if (gotIt) - { - content[i]->whichElement.source.hasBreak = hasBreak; - break; - } - i++; + if (tui_update_breakpoint_info (win, FALSE)) + { + tuiUpdateExecInfo (win); + } } - - return; -} /* tuiSetHasBreakAt */ +} -/* - ** tuiAllSetHasBreakAt(). - ** Set or clear the hasBreak flag in all displayed source windows. - */ -void -tuiAllSetHasBreakAt (struct breakpoint *bp, int hasBreak) +/* Scan the source window and the breakpoints to update the + hasBreak information for each line. + Returns 1 if something changed and the execution window + must be refreshed. */ +int +tui_update_breakpoint_info (TuiWinInfoPtr win, int current_only) { int i; + int need_refresh = 0; + TuiSourceInfoPtr src = &win->detail.sourceInfo; - for (i = 0; i < (sourceWindows ())->count; i++) - tuiSetHasBreakAt (bp, - (TuiWinInfoPtr) (sourceWindows ())->list[i], hasBreak); - - return; -} /* tuiAllSetHasBreakAt */ - + for (i = 0; i < win->generic.contentSize; i++) + { + struct breakpoint *bp; + extern struct breakpoint *breakpoint_chain; + int mode; + TuiSourceElement* line; + + line = &((TuiWinElementPtr) win->generic.content[i])->whichElement.source; + if (current_only && !line->isExecPoint) + continue; + + /* Scan each breakpoint to see if the current line has something to + do with it. Identify enable/disabled breakpoints as well as + those that we already hit. */ + mode = 0; + for (bp = breakpoint_chain; + bp != (struct breakpoint *) NULL; + bp = bp->next) + { + if ((win == srcWin + && bp->source_file + && (strcmp (src->filename, bp->source_file) == 0) + && bp->line_number == line->lineOrAddr.lineNo) + || (win == disassemWin + && bp->address == line->lineOrAddr.addr)) + { + if (bp->enable_state == bp_disabled) + mode |= TUI_BP_DISABLED; + else + mode |= TUI_BP_ENABLED; + if (bp->hit_count) + mode |= TUI_BP_HIT; + if (bp->cond) + mode |= TUI_BP_CONDITIONAL; + if (bp->type == bp_hardware_breakpoint) + mode |= TUI_BP_HARDWARE; + } + } + if (line->hasBreak != mode) + { + line->hasBreak = mode; + need_refresh = 1; + } + } + return need_refresh; +} -/********************************* -** EXECUTION INFO FUNCTIONS ** -*********************************/ /* ** tuiSetExecInfoContent(). @@ -483,56 +501,37 @@ tuiSetExecInfoContent (TuiWinInfoPtr winInfo) { int i; + tui_update_breakpoint_info (winInfo, 1); for (i = 0; i < winInfo->generic.contentSize; i++) { TuiWinElementPtr element; TuiWinElementPtr srcElement; + int mode; element = (TuiWinElementPtr) execInfoPtr->content[i]; srcElement = (TuiWinElementPtr) winInfo->generic.content[i]; - /* - ** First check to see if we have a breakpoint that is - ** temporary. If so, and this is our current execution point, - ** then clear the break indicator. - */ - if (srcElement->whichElement.source.hasBreak && - srcElement->whichElement.source.isExecPoint) - { - struct breakpoint *bp; - int found = FALSE; - extern struct breakpoint *breakpoint_chain; - - for (bp = breakpoint_chain; - (bp != (struct breakpoint *) NULL && !found); - bp = bp->next) - { - found = - (winInfo == srcWin && - bp->line_number == - srcElement->whichElement.source.lineOrAddr.lineNo) || - (winInfo == disassemWin && - bp->address == (CORE_ADDR) - srcElement->whichElement.source.lineOrAddr.addr); - if (found) - srcElement->whichElement.source.hasBreak = - (bp->disposition != disp_del || bp->hit_count <= 0); - } - if (!found) - srcElement->whichElement.source.hasBreak = FALSE; - } - /* - ** Now update the exec info content based upon the state - ** of each line as indicated by the source content. - */ - if (srcElement->whichElement.source.hasBreak && - srcElement->whichElement.source.isExecPoint) - element->whichElement.simpleString = breakLocationStr (); - else if (srcElement->whichElement.source.hasBreak) - element->whichElement.simpleString = breakStr (); - else if (srcElement->whichElement.source.isExecPoint) - element->whichElement.simpleString = locationStr (); - else - element->whichElement.simpleString = blankStr (); + + memset(element->whichElement.simpleString, ' ', + sizeof(element->whichElement.simpleString)); + element->whichElement.simpleString[TUI_EXECINFO_SIZE - 1] = 0; + + /* Now update the exec info content based upon the state + of each line as indicated by the source content. */ + mode = srcElement->whichElement.source.hasBreak; + if (mode & TUI_BP_HIT) + element->whichElement.simpleString[TUI_BP_HIT_POS] = + (mode & TUI_BP_HARDWARE) ? 'H' : 'B'; + else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED)) + element->whichElement.simpleString[TUI_BP_HIT_POS] = + (mode & TUI_BP_HARDWARE) ? 'h' : 'b'; + + if (mode & TUI_BP_ENABLED) + element->whichElement.simpleString[TUI_BP_BREAK_POS] = '+'; + else if (mode & TUI_BP_DISABLED) + element->whichElement.simpleString[TUI_BP_BREAK_POS] = '-'; + + if (srcElement->whichElement.source.isExecPoint) + element->whichElement.simpleString[TUI_EXEC_POS] = '>'; } execInfoPtr->contentSize = winInfo->generic.contentSize; } @@ -541,7 +540,7 @@ tuiSetExecInfoContent (TuiWinInfoPtr winInfo) } return ret; -} /* tuiSetExecInfoContent */ +} /* diff --git a/gdb/tui/tuiSourceWin.h b/gdb/tui/tuiSourceWin.h index 803cb90..1d554af 100644 --- a/gdb/tui/tuiSourceWin.h +++ b/gdb/tui/tuiSourceWin.h @@ -22,6 +22,17 @@ #ifndef _TUI_SOURCEWIN_H #define _TUI_SOURCEWIN_H +/* Update the execution windows to show the active breakpoints. + This is called whenever a breakpoint is inserted, removed or + has its state changed. */ +extern void tui_update_all_breakpoint_info (void); + +/* Scan the source window and the breakpoints to update the + hasBreak information for each line. + Returns 1 if something changed and the execution window + must be refreshed. */ +extern int tui_update_breakpoint_info (TuiWinInfoPtr win, int current_only); + /* Function to display the "main" routine. */ extern void tui_display_main (void); extern void tuiUpdateSourceWindow (TuiWinInfoPtr, struct symtab *, TuiLineOrAddress, @@ -47,8 +58,6 @@ extern void tuiUpdateExecInfo (TuiWinInfoPtr); extern void tuiUpdateAllExecInfos (void); extern void tuiSetIsExecPointAt (TuiLineOrAddress, TuiWinInfoPtr); -extern void tuiSetHasBreakAt (struct breakpoint *, TuiWinInfoPtr, int); -extern void tuiAllSetHasBreakAt (struct breakpoint *, int); extern TuiStatus tuiAllocSourceBuffer (TuiWinInfoPtr); extern int tuiLineIsDisplayed (int, TuiWinInfoPtr, int); extern int tuiAddrIsDisplayed (CORE_ADDR, TuiWinInfoPtr, int); -- cgit v1.1