diff options
author | Keith Seitz <keiths@redhat.com> | 2001-04-19 22:51:02 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2001-04-19 22:51:02 +0000 |
commit | a477eed2dc636a5d081dd98f0c35210461a1039a (patch) | |
tree | dab63ebf854fa120b901866d913741b6d2cbf7bd /gdb/gdbtk | |
parent | 3fda809efb8d347decbd9c0836fa48019ea9a030 (diff) | |
download | gdb-a477eed2dc636a5d081dd98f0c35210461a1039a.tar.gz |
Breakpoint/tracepoint event notification using new event model...
* generic/gdbtk-cmds.c (gdb_set_bp): Use create_breakpoint_hook
to notify gui of changes.
(gdb_set_bp_addr): Ditto.
(gdb_get_breakpoint_info): Update comments to match reality.
* generic/gdbtk-hooks.c (breakpoint_notify): Only pass the
breakpoint number which generated the event.
(tracepoint_notify): Ditto for tracepoints.
* library/interface.tcl (gdb_breakpoint_change_hook): Mark
as deprecated and comment out definition.
(gdbtk_tcl_breakpoint): Use new GDBEvent event "breakpoint"
to notify rest of UI about breakpoint event.
(gdbtk_tcl_tracepoint): Ditto for "tracepoint" event.
* library/bpwin.ith (update): Renamed to "breakpoint".
(breakpoint): New public method.
(tracepoint): New public method.
(bp_add): Take event as argument instead of number.
(bp_modify): Ditto.
(bp_delete): Ditto.
* library/bpwin.itb (constructor): Remove
gdb_breakpoint_changed_hook.
(destructor): Ditto.
(build_win): Insert any existing breakpoints by
making BreakpointEvents for them.
(breakpoint): Renamed from "update" to handle
breakpoint events.
Remove code to deal with tracepoints.
(tracepoint): New method to handle tracepoint
events.
(bp_add): Deal with breakpoint events, not breakpoint
numbers.
(bp_modify): Ditto.
(bp_delete): Ditto.
* library/srctextwin.ith: Inherit from GDBWin.
(breakpoint): New public method.
(tracepoint): New public method.
* library/srctextwin.itb (constructor): Remove
gdb_breakpoint_changed_hook.
(destructor): Ditto.
(breakpoint): New method to handle breakpoint event.
(tracepoint): New method to handle tracepoint event.
(do_bp): Handle duplicate breakpoints for asm, too.
(remove_bp_at_line): Delete breakpoints by number, not
linespec. clear_command removes breakpoints from the
breakpoint_chain BEFORE deleting the breakpoint. delete_command
does this afterward (so we can call gdb_get_breakpoint_info on
an about-to-be-deleted breakpoint).
Diffstat (limited to 'gdb/gdbtk')
-rw-r--r-- | gdb/gdbtk/ChangeLog | 47 | ||||
-rw-r--r-- | gdb/gdbtk/generic/gdbtk-cmds.c | 71 | ||||
-rw-r--r-- | gdb/gdbtk/generic/gdbtk-hooks.c | 23 | ||||
-rw-r--r-- | gdb/gdbtk/library/bpwin.itb | 121 | ||||
-rw-r--r-- | gdb/gdbtk/library/bpwin.ith | 14 | ||||
-rw-r--r-- | gdb/gdbtk/library/interface.tcl | 21 | ||||
-rw-r--r-- | gdb/gdbtk/library/srctextwin.itb | 63 | ||||
-rw-r--r-- | gdb/gdbtk/library/srctextwin.ith | 10 |
8 files changed, 200 insertions, 170 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index 85992bee9a2..202c131d467 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -11,6 +11,53 @@ (_state): Delete unused variable. * library/tclIndex: Regenerated. + * generic/gdbtk-cmds.c (gdb_set_bp): Use create_breakpoint_hook + to notify gui of changes. + (gdb_set_bp_addr): Ditto. + (gdb_get_breakpoint_info): Update comments to match reality. + * generic/gdbtk-hooks.c (breakpoint_notify): Only pass the + breakpoint number which generated the event. + (tracepoint_notify): Ditto for tracepoints. + * library/interface.tcl (gdb_breakpoint_change_hook): Mark + as deprecated and comment out definition. + (gdbtk_tcl_breakpoint): Use new GDBEvent event "breakpoint" + to notify rest of UI about breakpoint event. + (gdbtk_tcl_tracepoint): Ditto for "tracepoint" event. + * library/bpwin.ith (update): Renamed to "breakpoint". + (breakpoint): New public method. + (tracepoint): New public method. + (bp_add): Take event as argument instead of number. + (bp_modify): Ditto. + (bp_delete): Ditto. + * library/bpwin.itb (constructor): Remove + gdb_breakpoint_changed_hook. + (destructor): Ditto. + (build_win): Insert any existing breakpoints by + making BreakpointEvents for them. + (breakpoint): Renamed from "update" to handle + breakpoint events. + Remove code to deal with tracepoints. + (tracepoint): New method to handle tracepoint + events. + (bp_add): Deal with breakpoint events, not breakpoint + numbers. + (bp_modify): Ditto. + (bp_delete): Ditto. + * library/srctextwin.ith: Inherit from GDBWin. + (breakpoint): New public method. + (tracepoint): New public method. + * library/srctextwin.itb (constructor): Remove + gdb_breakpoint_changed_hook. + (destructor): Ditto. + (breakpoint): New method to handle breakpoint event. + (tracepoint): New method to handle tracepoint event. + (do_bp): Handle duplicate breakpoints for asm, too. + (remove_bp_at_line): Delete breakpoints by number, not + linespec. clear_command removes breakpoints from the + breakpoint_chain BEFORE deleting the breakpoint. delete_command + does this afterward (so we can call gdb_get_breakpoint_info on + an about-to-be-deleted breakpoint). + 2001-04-18 Martin M. Hunt <hunt@redhat.com> * generic/gdbtk.c (gdbtk_init): Initialize uiout. diff --git a/gdb/gdbtk/generic/gdbtk-cmds.c b/gdb/gdbtk/generic/gdbtk-cmds.c index e97cc2b5904..31167c4fa57 100644 --- a/gdb/gdbtk/generic/gdbtk-cmds.c +++ b/gdb/gdbtk/generic/gdbtk-cmds.c @@ -3766,9 +3766,7 @@ gdb_loadfile (ClientData clientData, Tcl_Interp *interp, int objc, */ /* This implements the tcl command "gdb_set_bp" - * It sets breakpoints, and runs the Tcl command - * gdbtk_tcl_breakpoint create - * to register the new breakpoint with the GUI. + * It sets breakpoints, and notifies the GUI. * * Tcl Arguments: * filename: the file in which to set the breakpoint @@ -3787,7 +3785,7 @@ gdb_set_bp (clientData, interp, objc, objv) Tcl_Obj *CONST objv[]; { struct symtab_and_line sal; - int line, ret, thread = -1; + int line, thread = -1; struct breakpoint *b; char *buf, *typestr; Tcl_DString cmd; @@ -3854,35 +3852,12 @@ gdb_set_bp (clientData, interp, objc, objv) free(buf); /* now send notification command back to GUI */ - - Tcl_DStringInit (&cmd); - - Tcl_DStringAppend (&cmd, "gdbtk_tcl_breakpoint create ", -1); - xasprintf (&buf, "%d", b->number); - Tcl_DStringAppendElement (&cmd, buf); - free(buf); - xasprintf (&buf, "0x%lx", (long) sal.pc); - Tcl_DStringAppendElement (&cmd, buf); - Tcl_DStringAppendElement (&cmd, Tcl_GetStringFromObj (objv[2], NULL)); - Tcl_DStringAppendElement (&cmd, Tcl_GetStringFromObj (objv[1], NULL)); - Tcl_DStringAppendElement (&cmd, bpdisp[b->disposition]); - free(buf); - xasprintf (&buf, "%d", b->enable); - Tcl_DStringAppendElement (&cmd, buf); - free(buf); - xasprintf (&buf, "%d", b->thread); - Tcl_DStringAppendElement (&cmd, buf); - free(buf); - - ret = Tcl_Eval (interp, Tcl_DStringValue (&cmd)); - Tcl_DStringFree (&cmd); - return ret; + create_breakpoint_hook (b); + return TCL_OK; } /* This implements the tcl command "gdb_set_bp_addr" - * It sets breakpoints, and runs the Tcl command - * gdbtk_tcl_breakpoint create - * to register the new breakpoint with the GUI. + * It sets breakpoints, and notifies the GUI. * * Tcl Arguments: * addr: the address at which to set the breakpoint @@ -3898,7 +3873,7 @@ gdb_set_bp_addr (ClientData clientData, Tcl_Interp *interp, int objc, { struct symtab_and_line sal; - int ret, thread = -1; + int thread = -1; long addr; struct breakpoint *b; char *filename, *typestr, *buf; @@ -3956,36 +3931,8 @@ gdb_set_bp_addr (ClientData clientData, Tcl_Interp *interp, int objc, b->addr_string = xstrdup (buf); /* now send notification command back to GUI */ - - Tcl_DStringInit (&cmd); - - Tcl_DStringAppend (&cmd, "gdbtk_tcl_breakpoint create ", -1); - free(buf); - xasprintf (&buf, "%d", b->number); - Tcl_DStringAppendElement (&cmd, buf); - free(buf); - xasprintf (&buf, "0x%lx", addr); - Tcl_DStringAppendElement (&cmd, buf); - free(buf); - xasprintf (&buf, "%d", b->line_number); - Tcl_DStringAppendElement (&cmd, buf); - - filename = symtab_to_filename (sal.symtab); - if (filename == NULL) - filename = ""; - Tcl_DStringAppendElement (&cmd, filename); - Tcl_DStringAppendElement (&cmd, bpdisp[b->disposition]); - free(buf); - xasprintf (&buf, "%d", b->enable); - Tcl_DStringAppendElement (&cmd, buf); - free(buf); - xasprintf (&buf, "%d", b->thread); - Tcl_DStringAppendElement (&cmd, buf); - - ret = Tcl_Eval (interp, Tcl_DStringValue (&cmd)); - Tcl_DStringFree (&cmd); - free(buf); - return ret; + create_breakpoint_hook (b); + return TCL_OK; } /* This implements the tcl command "gdb_find_bp_at_line" @@ -4085,7 +4032,7 @@ gdb_find_bp_at_addr (clientData, interp, objc, objv) * Tcl Result: * A list with {file, function, line_number, address, type, enabled?, * disposition, ignore_count, {list_of_commands}, - * thread, hit_count} + * condition, thread, hit_count} */ static int diff --git a/gdb/gdbtk/generic/gdbtk-hooks.c b/gdb/gdbtk/generic/gdbtk-hooks.c index 528e08d044a..bb6515c05b6 100644 --- a/gdb/gdbtk/generic/gdbtk-hooks.c +++ b/gdb/gdbtk/generic/gdbtk-hooks.c @@ -661,23 +661,13 @@ breakpoint_notify (b, action) const char *action; { char *buf; - int v; - struct symtab_and_line sal; - char *filename; if (b->type != bp_breakpoint) return; /* We ensure that ACTION contains no special Tcl characters, so we can do this. */ - sal = find_pc_line (b->address, 0); - filename = symtab_to_filename (sal.symtab); - if (filename == NULL) - filename = ""; - - xasprintf (&buf, "gdbtk_tcl_breakpoint %s %d 0x%lx %d {%s} {%s} %d %d", - action, b->number, (long) b->address, b->line_number, filename, - bpdisp[b->disposition], b->enable, b->thread); + xasprintf (&buf, "gdbtk_tcl_breakpoint %s %d", action, b->number); if (Tcl_Eval (gdbtk_interp, buf) != TCL_OK) report_error (); @@ -794,19 +784,10 @@ tracepoint_notify (tp, action) const char *action; { char *buf; - int v; - struct symtab_and_line sal; - char *filename; /* We ensure that ACTION contains no special Tcl characters, so we can do this. */ - sal = find_pc_line (tp->address, 0); - - filename = symtab_to_filename (sal.symtab); - if (filename == NULL) - filename = "N/A"; - xasprintf (&buf, "gdbtk_tcl_tracepoint %s %d 0x%lx %d {%s} %d", action, tp->number, - (long) tp->address, sal.line, filename, tp->pass_count); + xasprintf (&buf, "gdbtk_tcl_tracepoint %s %d", action, tp->number); if (Tcl_Eval (gdbtk_interp, buf) != TCL_OK) report_error (); diff --git a/gdb/gdbtk/library/bpwin.itb b/gdb/gdbtk/library/bpwin.itb index ee895a9472a..0ea50d1b837 100644 --- a/gdb/gdbtk/library/bpwin.itb +++ b/gdb/gdbtk/library/bpwin.itb @@ -1,5 +1,5 @@ # Breakpoint window for GDBtk. -# Copyright 1997, 1998, 1999 Cygnus Solutions +# Copyright 1997, 1998, 1999, 2001 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) as published by @@ -18,7 +18,6 @@ body BpWin::constructor {args} { window_name "Breakpoints" "BPs" - add_hook gdb_breakpoint_change_hook "$this update" if {[pref getd gdb/bp/menu] != ""} { set mbar 0 } @@ -32,9 +31,7 @@ body BpWin::constructor {args} { # ------------------------------------------------------------------ # DESTRUCTOR: destroy the breakpoint window # ------------------------------------------------------------------ -body BpWin::destructor {} { - remove_hook gdb_breakpoint_change_hook "$this update" -} +body BpWin::destructor {} {} # ------------------------------------------------------------------ @@ -168,12 +165,16 @@ body BpWin::build_win {} { if { $tracepoints == 0 } { # insert all breakpoints foreach i [gdb_get_breakpoint_list] { - bp_add $i + set e [BreakpointEvent \#auto -action create -number $i] + bp_add $e + delete object $e } } else { # insert all tracepoints foreach i [gdb_get_tracepoint_list] { - bp_add $i 1 + set e [TracepointEvent \#auto -action create -number $i] + bp_add $e 1 + delete object $e } } @@ -185,25 +186,24 @@ body BpWin::build_win {} { # ------------------------------------------------------------------ # METHOD: bp_add - add a breakpoint entry # ------------------------------------------------------------------ -body BpWin::bp_add { bpnum {tracepoint 0}} { +body BpWin::bp_add {bp_event {tracepoint 0}} { global _bp_en _bp_disp tcl_platform _files - + + set number [$bp_event get number] + set thread [$bp_event get thread] + set disposition [$bp_event get disposition] + set file [$bp_event get file] + if {$tracepoint} { - set bpinfo [gdb_get_tracepoint_info $bpnum] - lassign $bpinfo file func line pc enabled pass_count \ - step_count thread hit_count actions - set disposition tracepoint + set diposition tracepoint set bptype tracepoint } else { - set bpinfo [gdb_get_breakpoint_info $bpnum] - lassign $bpinfo file func line pc type enabled disposition \ - ignore_count commands cond thread hit_count set bptype breakpoint } - debug "bp_add bpnum=$bpnum thread=$thread show=$show_threads" + debug "bp_add bpnum=$number thread=$thread show=$show_threads" set i $next_row - set _bp_en($i) $enabled + set _bp_en($i) [$bp_event get enabled] set _bp_disp($i) $disposition set temp($i) "" switch $disposition { @@ -229,9 +229,9 @@ body BpWin::bp_add { bpnum {tracepoint 0}} { } if {$tracepoints} { - label $twin.num$i -text "$bpnum " -relief flat -anchor e -font src-font -bg $bg1 + label $twin.num$i -text "$number " -relief flat -anchor e -font src-font -bg $bg1 } - label $twin.addr$i -text "$pc " -relief flat -anchor e -font src-font -bg $bg1 + label $twin.addr$i -text "[$bp_event get address] " -relief flat -anchor e -font src-font -bg $bg1 if {[info exists _files(short,$file)]} { set file $_files(short,$file) } else { @@ -243,11 +243,10 @@ body BpWin::bp_add { bpnum {tracepoint 0}} { label $twin.thread$i -text "$thread " -relief flat -anchor e -font src-font -bg $bg1 } label $twin.file$i -text "$file " -relief flat -anchor e -font src-font -bg $bg1 - label $twin.line$i -text "$line " -relief flat -anchor e -font src-font -bg $bg1 - label $twin.func$i -text "$func " -relief flat -anchor e -font src-font -bg $bg1 - + label $twin.line$i -text "[$bp_event get line] " -relief flat -anchor e -font src-font -bg $bg1 + label $twin.func$i -text "[$bp_event get function] " -relief flat -anchor e -font src-font -bg $bg1 if {$tracepoints} { - label $twin.pass$i -text "$pass_count " -relief flat -anchor e -font src-font -bg $bg1 + label $twin.pass$i -text "[$bp_event get pass_count] " -relief flat -anchor e -font src-font -bg $bg1 } if {$mbar} { @@ -276,7 +275,7 @@ body BpWin::bp_add { bpnum {tracepoint 0}} { # This used to be the last row. Fix it vertically again. grid rowconfigure $twin $i -weight 0 - set index_to_bpnum($i) $bpnum + set index_to_bpnum($i) $number set Index_to_bptype($i) $bptype incr i set next_row $i @@ -417,25 +416,24 @@ body BpWin::bp_select { r } { # ------------------------------------------------------------------ # METHOD: bp_modify - modify a breakpoint entry # ------------------------------------------------------------------ -body BpWin::bp_modify { bpnum {tracepoint 0} } { +body BpWin::bp_modify {bp_event {tracepoint 0}} { global _bp_en _bp_disp tcl_platform _files + set number [$bp_event get number] + set thread [$bp_event get thread] + set disposition [$bp_event get disposition] + set file [$bp_event get file] + if {$tracepoint} { - set bpinfo [gdb_get_tracepoint_info $bpnum] - lassign $bpinfo file func line pc enabled pass_count \ - step_count thread hit_count actions set disposition tracepoint set bptype tracepoint } else { - set bpinfo [gdb_get_breakpoint_info $bpnum] - lassign $bpinfo file func line pc type enabled disposition \ - ignore_count commands cond thread hit_count set bptype breakpoint } set found 0 for {set i 1} {$i < $next_row} {incr i} { - if { $bpnum == $index_to_bpnum($i) + if { $number == $index_to_bpnum($i) && "$Index_to_bptype($i)" == "$bptype"} { incr found break @@ -443,12 +441,12 @@ body BpWin::bp_modify { bpnum {tracepoint 0} } { } if {!$found} { - debug "ERROR: breakpoint number $bpnum not found!" + debug "ERROR: breakpoint number $number not found!" return } - if {$_bp_en($i) != $enabled} { - set _bp_en($i) $enabled + if {$_bp_en($i) != [$bp_event get enabled]} { + set _bp_en($i) [$bp_event get enabled] } if {$_bp_disp($i) != $disposition} { @@ -472,9 +470,9 @@ body BpWin::bp_modify { bpnum {tracepoint 0} } { $twin.en$i configure -selectcolor $color } if {$tracepoints} { - $twin.num$i configure -text "$bpnum " + $twin.num$i configure -text "$number " } - $twin.addr$i configure -text "$pc " + $twin.addr$i configure -text "[$bp_event get address] " if {[info exists _files(short,$file)]} { set file $_files(short,$file) } else { @@ -486,10 +484,10 @@ body BpWin::bp_modify { bpnum {tracepoint 0} } { $twin.thread$i configure -text "$thread " } $twin.file$i configure -text "$file " - $twin.line$i configure -text "$line " - $twin.func$i configure -text "$func " + $twin.line$i configure -text "[$bp_event get line] " + $twin.func$i configure -text "[$bp_event get function] " if {$tracepoints} { - $twin.pass$i configure -text "$pass_count " + $twin.pass$i configure -text "[$bp_event get pass_count] " } } @@ -562,9 +560,10 @@ body BpWin::bp_type { i } { # ------------------------------------------------------------------ # METHOD: bp_delete - delete a breakpoint # ------------------------------------------------------------------ -body BpWin::bp_delete { bpnum } { +body BpWin::bp_delete {bp_event} { + set number [$bp_event get number] for {set i 1} {$i < $next_row} {incr i} { - if { $bpnum == $index_to_bpnum($i) } { + if { $number == $index_to_bpnum($i) } { if {$tracepoints} { grid forget $twin.en$i $twin.num$i $twin.addr$i $twin.file$i \ $twin.line$i $twin.func$i $twin.pass$i @@ -587,22 +586,36 @@ body BpWin::bp_delete { bpnum } { } # ------------------------------------------------------------------ -# METHOD: update - update widget when a breakpoint changes +# PUBLIC METHOD: breakpoint - Update widget when a breakpoint +# event is received from the backend. # ------------------------------------------------------------------ -body BpWin::update {action bpnum addr {linenum {}} {file {}} {type 0} args} { - #debug "bp update $action $bpnum $type" +body BpWin::breakpoint {bp_event} { - if {$type == "tracepoint"} { - set tp 1 - } else { - set tp 0 + set action [$bp_event get action] + #debug "bp update $action [$bp_event get number] [$bp_event get type]" + + switch $action { + modify { bp_modify $bp_event 0 } + create { bp_add $bp_event 0 } + delete { bp_delete $bp_event } + default { dbug E "Unknown breakpoint action: $action" } } +} + +# ------------------------------------------------------------------ +# METHOD: tracepoint - Update widget when a tracepoint event +# is received from the backend. +# ------------------------------------------------------------------ +body BpWin::tracepoint {tp_event} { + + set action [$tp_event get action] + #debug "tp update $action [$tp_event get number]" switch $action { - modify { bp_modify $bpnum $tp} - create { bp_add $bpnum $tp} - delete { bp_delete $bpnum } - default { debug "Unknown breakpoint action: $action" } + modify { bp_modify $tp_event 1 } + create { bp_add $tp_event 1 } + delete { bp_delete $tp_event } + default { dbug E "Unknown tracepoint action: $action" } } } diff --git a/gdb/gdbtk/library/bpwin.ith b/gdb/gdbtk/library/bpwin.ith index d3b56f893ab..9c6740a95fa 100644 --- a/gdb/gdbtk/library/bpwin.ith +++ b/gdb/gdbtk/library/bpwin.ith @@ -1,5 +1,5 @@ -# Breakpoint window class definition for GDBtk. -# Copyright 1997, 1998, 1999 Cygnus Solutions +# Breakpoint window class definition for Insight +# Copyright 1997, 1998, 1999, 2001 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) as published by @@ -26,13 +26,15 @@ class BpWin { method bp_restore {} method bp_store {} method bp_type { i } - method update {action bpnum addr {linenum {}} {file {}} {type 0} args} method bp_all { command } method get_actions {bpnum} method toggle_threads {} method reconfig {} method goto_bp {r} + # GDB Events + method breakpoint {event} + method tracepoint {event} } private { @@ -48,9 +50,9 @@ class BpWin { variable show_threads ;#cached copy of [pref get gdb/bp/show_threads] method build_win {} - method bp_add { bpnum {tracepoint 0}} - method bp_modify { bpnum {tracepoint 0} } - method bp_delete { bpnum } + method bp_add {bp_event {tracepoint 0}} + method bp_modify {bp_event {tracepoint 0}} + method bp_delete {bp_event} } } diff --git a/gdb/gdbtk/library/interface.tcl b/gdb/gdbtk/library/interface.tcl index b95f57e5b32..9e44a878899 100644 --- a/gdb/gdbtk/library/interface.tcl +++ b/gdb/gdbtk/library/interface.tcl @@ -1,5 +1,5 @@ # Interface between GDB and Insight. -# Copyright 1997, 1998, 1999 Cygnus Solutions +# Copyright 1997, 1998, 1999, 2001 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) as published by @@ -16,9 +16,10 @@ global gdbtk_state set gdbtk_state(busyCount) 0 +# *** DEPRECATED: Use GDBEventHandler::breakpoint instead. # This is run when a breakpoint changes. The arguments are the # action, the breakpoint number, and the breakpoint info. -define_hook gdb_breakpoint_change_hook +#define_hook gdb_breakpoint_change_hook # This is run when a `set' command successfully completes in gdb. The # first argument is the gdb variable name (as a Tcl list). The second @@ -443,17 +444,21 @@ proc gdbtk_tcl_end_variable_annotation {} { # ------------------------------------------------------------------ # PROC: gdbtk_tcl_breakpoint - # ------------------------------------------------------------------ -proc gdbtk_tcl_breakpoint {action bpnum addr line file bp_type enabled thread} { -# debug "BREAKPOINT: $action $bpnum $addr $line $file $bp_type $enabled $thread " - run_hooks gdb_breakpoint_change_hook $action $bpnum $addr $line $file $bp_type $enabled $thread +proc gdbtk_tcl_breakpoint {action bpnum} { +# debug "BREAKPOINT: $action $bpnum" + set e [BreakpointEvent \#auto -action $action -number $bpnum] + GDBEventHandler::dispatch $e + delete object $e } # ------------------------------------------------------------------ # PROC: gdbtk_tcl_tracepoint - # ------------------------------------------------------------------ -proc gdbtk_tcl_tracepoint {action tpnum addr line file pass_count} { -# debug "TRACEPOINT: $action $tpnum $addr $line $file $pass_count" - run_hooks gdb_breakpoint_change_hook $action $tpnum $addr $line $file tracepoint +proc gdbtk_tcl_tracepoint {action tpnum} { +# debug "TRACEPOINT: $action $tpnum" + set e [TracepointEvent \#auto -action $action -number $tpnum] + GDBEventHandler::dispatch $e + delete object $e } # ------------------------------------------------------------------ diff --git a/gdb/gdbtk/library/srctextwin.itb b/gdb/gdbtk/library/srctextwin.itb index 518b09d57ca..35e12ba6a69 100644 --- a/gdb/gdbtk/library/srctextwin.itb +++ b/gdb/gdbtk/library/srctextwin.itb @@ -1,5 +1,5 @@ - # Paned text widget for source code, for GDBtk. -# Copyright 1997, 1998, 1999 Cygnus Solutions +# Paned text widget for source code, for Insight +# Copyright 1997, 1998, 1999, 2001 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) as published by @@ -60,8 +60,6 @@ body SrcTextWin::constructor {args} { build_win # add hooks - add_hook gdb_breakpoint_change_hook "$this bp" - if {$Tracing} { add_hook control_mode_hook "$this set_control_mode" add_hook gdb_trace_find_hook "$this trace_find_hook" @@ -83,7 +81,6 @@ body SrcTextWin::constructor {args} { # DESTRUCTOR - destroy window containing widget # ------------------------------------------------------------------ body SrcTextWin::destructor {} { - remove_hook gdb_breakpoint_change_hook "$this bp" if {$Tracing} { remove_hook control_mode_hook "$this set_control_mode" } @@ -1454,6 +1451,28 @@ body SrcTextWin::removeBreakTag {win linenum tag } { } # ------------------------------------------------------------------ +# PUBLIC METHOD: breakpoint - Handle a breakpoint create, delete, +# or modify event from the backend. +# ------------------------------------------------------------------ +body SrcTextWin::breakpoint {bp_event} { + + bp [$bp_event get action] [$bp_event get number] [$bp_event get address] \ + [$bp_event get line] [$bp_event get file] [$bp_event get disposition] \ + [$bp_event get enabled] [$bp_event get thread] +} + +# ------------------------------------------------------------------ +# PUBLIC METHOD: tracepoint - Handle a tracepoint create, delete, +# modify event from the backend. +# ------------------------------------------------------------------ +body SrcTextWin::tracepoint {tp_event} { + + bp [$tp_event get action] [$tp_event get number] [$tp_event get address] \ + [$tp_event get line] [$tp_event get file] tracepoint \ + [$tp_event get pass_count] +} + +# ------------------------------------------------------------------ # METHOD: bp - set and remove breakpoints # # if $addr is valid, the breakpoint will be set in the assembly or @@ -1462,7 +1481,7 @@ body SrcTextWin::removeBreakTag {win linenum tag } { # ------------------------------------------------------------------ body SrcTextWin::bp {action bpnum addr {linenum {}} {file {}} {type 0} {enabled 0} {thread -1}} { # debug "$action addr=$addr line=$linenum file=$file type=$type current(filename)=$current(filename)" - + switch $current(mode) { SOURCE { if {[string compare $file $current(filename)] == 0 && $linenum != {}} { @@ -1501,15 +1520,23 @@ body SrcTextWin::bp {action bpnum addr {linenum {}} {file {}} {type 0} {enabled # ------------------------------------------------------------------ body SrcTextWin::do_bp { win action linenum type bpnum enabled thread asm} { # debug "$action line=$linenum type=$type bpnum=$bpnum enabled=$enabled thread=$thread" - + if {$dont_change_appearance} { return } - if {!$asm && $action == "delete" && [string compare $type tracepoint] != 0} { + if {$action == "delete" && [string compare $type tracepoint] != 0} { # make sure there are no more breakpoints on # this line. - set bps [gdb_find_bp_at_line $current(filename) $linenum] + if {!$asm} { + set bps [gdb_find_bp_at_line $current(filename) $linenum] + } else { + if {[info exists _map($Cname,line=$linenum)]} { + set bps [gdb_find_bp_at_addr $_map($Cname,line=$linenum)] + } else { + set bps {} + } + } if {[llength $bps] > 0} { foreach b $bps { if {$b != $bpnum} { @@ -1568,7 +1595,7 @@ body SrcTextWin::do_bp { win action linenum type bpnum enabled thread asm} { set tag_type thread_bp_tag } default { - dbug E "UNKNOWN BP TYPE $action $type" + dbug E "UNKNOWN BP TYPE action=\"$action\" type=\"$type\"" $win insert $linenum.0 "X" bp_tag set tag_type bp_tag } @@ -1903,16 +1930,20 @@ body SrcTextWin::remove_bp_at_line {{win {}} {y -1}} { if {$Running} {return} # Look up the line... This foreach is an lassign... - + foreach {name line addr type} [lookup_line $win $y] { break } - - if {[string compare $type src] == 0} { - gdb_cmd "clear $name:$addr" - } else { - gdb_cmd "clear *$addr" + + # FIXME: if there are multiple bp/tp at a single line, + # we will (right now) always take the first one we find... + switch $type { + src { set bps [gdb_find_bp_at_line $name $addr] } + asm { set bps [gdb_find_bp_at_addr $addr] } } + + set number [lindex $bps 0] + gdb_cmd "delete $number" } diff --git a/gdb/gdbtk/library/srctextwin.ith b/gdb/gdbtk/library/srctextwin.ith index 345cffbb546..5e5c0e0a23d 100644 --- a/gdb/gdbtk/library/srctextwin.ith +++ b/gdb/gdbtk/library/srctextwin.ith @@ -1,5 +1,5 @@ -# SrcTextWin class definition, for GDBtk. -# Copyright 1997, 1998, 1999 Cygnus Solutions +# SrcTextWin class definition, for Insight +# Copyright 1997, 1998, 1999, 2001 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) as published by @@ -13,7 +13,7 @@ class SrcTextWin { - inherit itk::Widget + inherit itk::Widget GDBWin public { variable Tracing ;# 1 if we are running in trace mode @@ -89,6 +89,10 @@ class SrcTextWin { method clear_file {} method get_file {} method set_tag_to_stack {} + + # GDB Events + method breakpoint {event} + method tracepoint {event} } protected { |