OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtcl/] [bpwin.itb] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Breakpoint window for GDBtk.
2
# Copyright 1997, 1998, 1999, 2001 Red Hat, Inc.
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License (GPL) as published by
6
# the Free Software Foundation; either version 2 of the License, or (at
7
# your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
 
14
 
15
# ------------------------------------------------------------------
16
#  CONSTRUCTOR:  create the main breakpoint window
17
# ------------------------------------------------------------------
18
body BpWin::constructor {args} {
19
  window_name "Breakpoints" "BPs"
20
 
21
  if {[pref getd gdb/bp/menu] != ""} {
22
    set mbar 0
23
  }
24
  set show_threads [pref get gdb/bp/show_threads]
25
  debug "Ready to build"
26
  build_win
27
  eval itk_initialize $args
28
  debug "done building"
29
}
30
 
31
# ------------------------------------------------------------------
32
#  DESTRUCTOR:  destroy the breakpoint window
33
# ------------------------------------------------------------------
34
body BpWin::destructor {} {}
35
 
36
 
37
# ------------------------------------------------------------------
38
#  METHOD:  build_win - build the main breakpoint window
39
# ------------------------------------------------------------------
40
body BpWin::build_win {} {
41
  global _bp_en _bp_disp tixOption tcl_platform
42
  set bg1 $tixOption(input1_bg)
43
 
44
  frame $itk_interior.f -bg $bg1
45
  if {$tcl_platform(platform) == "windows"} {
46
    tixScrolledWindow $itk_interior.f.sw -scrollbar both -sizebox 1
47
  } else {
48
    tixScrolledWindow $itk_interior.f.sw -scrollbar auto
49
  }
50
  set twin [$itk_interior.f.sw subwidget window]
51
  $twin configure -bg $bg1
52
 
53
  # write header
54
  if {$tracepoints} {
55
    label $twin.num0 -text "Num" -relief raised -bd 2 -anchor center \
56
      -font src-font
57
  }
58
  label $twin.thread0 -text "Thread" -relief raised -bd 2 -anchor center \
59
    -font src-font
60
  label $twin.addr0 -text "Address" -relief raised -bd 2 -anchor center \
61
    -font src-font
62
  label $twin.file0 -text "File" -relief raised -bd 2 -anchor center \
63
    -font src-font
64
  label $twin.line0 -text "Line" -relief raised -bd 2 -anchor center \
65
    -font src-font
66
  label $twin.func0 -text "Function" -relief raised -bd 2 -anchor center \
67
    -font src-font
68
 
69
  if {$tracepoints} {
70
    label $twin.pass0 -text "PassCount" -relief raised -borderwidth 2 \
71
      -anchor center -font src-font
72
    grid x $twin.num0 $twin.addr0 $twin.file0 $twin.line0 $twin.func0 $twin.pass0 \
73
      -sticky new
74
  } else {
75
    if {$show_threads} {
76
      grid x $twin.thread0 $twin.addr0 $twin.file0 $twin.line0 $twin.func0 -sticky new
77
      # Let the File and Function columns expand; no others.
78
      grid columnconfigure $twin 3 -weight 1
79
      grid columnconfigure $twin 5 -weight 1
80
    } else {
81
      grid x $twin.addr0 $twin.file0 $twin.line0 $twin.func0 -sticky new
82
      # Let the File and Function columns expand; no others.
83
      grid columnconfigure $twin 2 -weight 1
84
      grid columnconfigure $twin 4 -weight 1
85
    }
86
  }
87
 
88
 
89
  # The last row must always suck up all the leftover vertical
90
  # space.
91
  set next_row 1
92
  grid rowconfigure $twin $next_row -weight 1
93
 
94
  if { $mbar } {
95
    menu $itk_interior.m -tearoff 0
96
    [winfo toplevel $itk_interior] configure -menu $itk_interior.m
97
    if { $tracepoints == 0 } {
98
      $itk_interior.m add cascade -menu $itk_interior.m.bp -label "Breakpoint" -underline 0
99
    } else {
100
      $itk_interior.m add cascade -menu $itk_interior.m.bp -label "Tracepoint" -underline 0
101
    }
102
    set m [menu $itk_interior.m.bp]
103
    if { $tracepoints == 0 } {
104
      $m add radio -label "Normal" -variable _bp_disp($selected) \
105
        -value donttouch -underline 0 -state disabled
106
      $m add radio -label "Temporary" -variable _bp_disp($selected) \
107
        -value delete -underline 0 -state disabled
108
    } else {
109
      $m add command -label "Actions" -underline 0 -state disabled
110
    }
111
 
112
    $m add separator
113
    $m add radio -label "Enabled" -variable _bp_en($selected) -value 1 \
114
      -underline 0 -state disabled
115
    $m add radio -label "Disabled" -variable _bp_en($selected) -value 0 \
116
      -underline 0 -state disabled
117
    $m add separator
118
    $m add command -label "Remove" -underline 0 -state disabled
119
    $itk_interior.m add cascade -menu $itk_interior.m.all -label "Global" \
120
      -underline 0
121
    set m [menu $itk_interior.m.all]
122
    $m add check -label " Show Threads" \
123
      -variable [pref varname gdb/bp/show_threads] \
124
      -underline 1 -command "$this toggle_threads"
125
    $m add separator
126
    $m add command -label "Disable All" -underline 0 \
127
      -command "$this bp_all disable"
128
    $m add command -label "Enable All" -underline 0 \
129
      -command "$this bp_all enable"
130
    $m add separator
131
    $m add command -label "Remove All" -underline 0 \
132
      -command "$this bp_all delete"
133
    $m add separator
134
    $m add command -label "Store Breakpoints..." -underline 0 \
135
      -command [code $this bp_store]
136
    $m add command -label "Restore Breakpoints..." -underline 3 \
137
      -command [code $this bp_restore]
138
  }
139
 
140
  set Menu [menu $itk_interior.pop -tearoff 0]
141
 
142
  if { $tracepoints == 0 } {
143
    $Menu add radio -label "Normal" -variable _bp_disp($selected) \
144
      -value donttouch -underline 0
145
    $Menu add radio -label "Temporary" -variable _bp_disp($selected) \
146
      -value delete -underline 0
147
  } else {
148
    $Menu add command -label "Actions" -underline 0
149
  }
150
  $Menu add separator
151
  $Menu add radio -label "Enabled" -variable _bp_en($selected) -value 1 -underline 0
152
  $Menu add radio -label "Disabled" -variable _bp_en($selected) -value 0 -underline 0
153
  $Menu add separator
154
  $Menu add command -label "Remove" -underline 0
155
  $Menu add cascade -menu $Menu.all -label "Global" -underline 0
156
  set m [menu $Menu.all]
157
  $m add check -label " Show Threads" -variable [pref varname gdb/bp/show_threads] \
158
    -underline 1 -command "$this toggle_threads"
159
  $m add separator
160
  $m add command -label "Disable All" -underline 0 -command "$this bp_all disable"
161
  $m add command -label "Enable All" -underline 0 -command "$this bp_all enable"
162
  $m add separator
163
  $m add command -label "Remove All" -underline 0 -command "$this bp_all delete"
164
 
165
  if { $tracepoints == 0 } {
166
    # insert all breakpoints
167
    foreach i [gdb_get_breakpoint_list] {
168
      set e [BreakpointEvent \#auto -action create -number $i]
169
      bp_add $e
170
      delete object $e
171
    }
172
  } else {
173
    # insert all tracepoints
174
    foreach i [gdb_get_tracepoint_list] {
175
      set e [TracepointEvent \#auto -action create -number $i]
176
      bp_add $e 1
177
      delete object $e
178
    }
179
  }
180
 
181
  pack $itk_interior.f.sw -side left -expand true -fill both
182
  pack $itk_interior.f -side top -expand true -fill both
183
 
184
}
185
 
186
# ------------------------------------------------------------------
187
#  METHOD:  bp_add - add a breakpoint entry
188
# ------------------------------------------------------------------
189
body BpWin::bp_add {bp_event {tracepoint 0}} {
190
  global _bp_en _bp_disp tcl_platform _files
191
 
192
  set number [$bp_event get number]
193
  set thread [$bp_event get thread]
194
  set disposition [$bp_event get disposition]
195
  set file [$bp_event get file]
196
 
197
  if {$tracepoint} {
198
    set diposition tracepoint
199
    set bptype tracepoint
200
  } else {
201
    set bptype breakpoint
202
  }
203
 
204
  debug "bp_add bpnum=$number thread=$thread show=$show_threads"
205
  set i $next_row
206
  set _bp_en($i) [$bp_event get enabled]
207
  set _bp_disp($i) $disposition
208
  set temp($i) ""
209
  switch $disposition {
210
    donttouch { set color [pref get gdb/src/bp_fg] }
211
    delete {
212
      set color [pref get gdb/src/temp_bp_fg]
213
      set temp($i) delete
214
    }
215
    tracepoint {
216
      set color [pref get gdb/src/trace_fg]
217
    }
218
    default { set color yellow }
219
  }
220
 
221
  if {$thread != "-1"} {set color [pref get gdb/src/thread_fg]}
222
 
223
  if {$tcl_platform(platform) == "windows"} {
224
    checkbutton $twin.en$i -relief flat -variable _bp_en($i) -bg $bg1 \
225
      -activebackground $bg1 -command "$this bp_able $i" -fg $color
226
  } else {
227
    checkbutton $twin.en$i -relief flat -variable _bp_en($i) -selectcolor $color \
228
      -command "$this bp_able $i" -bg $bg1 -activebackground $bg1
229
  }
230
 
231
  if {$tracepoints} {
232
    label $twin.num$i -text "$number " -relief flat -anchor e -font src-font -bg $bg1
233
  }
234
  label $twin.addr$i -text "[$bp_event get address] " -relief flat -anchor e -font src-font -bg $bg1
235
  if {[info exists _files(short,$file)]} {
236
    set file $_files(short,$file)
237
  } else {
238
    # FIXME.  Really need to do better than this.
239
    set file [::file tail $file]
240
  }
241
  if {$show_threads} {
242
    if {$thread == "-1"} {set thread "ALL"}
243
    label $twin.thread$i -text "$thread " -relief flat -anchor e -font src-font -bg $bg1
244
  }
245
  label $twin.file$i -text "$file " -relief flat -anchor e -font src-font -bg $bg1
246
  label $twin.line$i -text "[$bp_event get line] " -relief flat -anchor e -font src-font -bg $bg1
247
  label $twin.func$i -text "[$bp_event get function] " -relief flat -anchor e -font src-font -bg $bg1
248
  if {$tracepoints} {
249
    label $twin.pass$i -text "[$bp_event get pass_count] " -relief flat -anchor e -font src-font -bg $bg1
250
  }
251
 
252
  if {$mbar} {
253
    set zz [list addr file func line]
254
    if {$tracepoints} {lappend zz num pass}
255
    if {$show_threads} {lappend zz thread}
256
    foreach thing $zz {
257
      bind $twin.${thing}${i} <1> "$this bp_select $i"
258
      bind $twin.${thing}${i}  "$this goto_bp $i"
259
    }
260
  }
261
 
262
  if {$tracepoints} {
263
    grid $twin.en$i $twin.num$i $twin.addr$i $twin.file$i $twin.line$i \
264
      $twin.func$i $twin.pass$i -sticky new -ipadx 4 -ipady 2
265
  } else {
266
    if {$show_threads} {
267
      grid $twin.en$i $twin.thread$i $twin.addr$i $twin.file$i $twin.line$i \
268
        $twin.func$i -sticky new -ipadx 4 -ipady 2
269
    } else {
270
      grid $twin.en$i $twin.addr$i $twin.file$i $twin.line$i \
271
        $twin.func$i -sticky new -ipadx 4 -ipady 2
272
    }
273
  }
274
 
275
  # This used to be the last row.  Fix it vertically again.
276
  grid rowconfigure $twin $i -weight 0
277
 
278
  set index_to_bpnum($i) $number
279
  set Index_to_bptype($i) $bptype
280
  incr i
281
  set next_row $i
282
  grid rowconfigure $twin $i -weight 1
283
}
284
 
285
# ------------------------------------------------------------------
286
#  METHOD:  bp_store - stores away the breakpoints in a file of gdb
287
#                      commands
288
# ------------------------------------------------------------------
289
body BpWin::bp_store {} {
290
  set out_file [tk_getSaveFile]
291
  if {$out_file == ""} {
292
    return
293
  }
294
  if {[catch {::open $out_file w} outH]} {
295
    tk_messageBox -message "Could not open $out_file: $outH"
296
    return
297
  }
298
  foreach breakpoint [gdb_get_breakpoint_list] {
299
    # This is an lassign
300
    foreach {file function line_no address type \
301
               enable_p disp ignore cmds thread hit_count user_spec} \
302
      [gdb_get_breakpoint_info $breakpoint] {
303
        break
304
      }
305
 
306
    if {$user_spec != ""} {
307
      set bp_specifier $user_spec
308
    } elseif {$file != ""} {
309
      set filename [file tail $file]
310
      set bp_specifier $filename:$line_no
311
    } else {
312
      set bp_specifier *$address
313
    }
314
 
315
    # FIXME: doesn't handle watchpoints.
316
    if {[string compare $disp "delete"] == 0} {
317
      puts $outH "tbreak $bp_specifier"
318
    } else {
319
      puts $outH "break $bp_specifier"
320
    }
321
 
322
    if {!$enable_p} {
323
      puts $outH "disable \$bpnum"
324
    }
325
    if {$ignore > 0} {
326
      puts $outH "ignore \$bpnum $ignore"
327
    }
328
  }
329
  close $outH
330
}
331
 
332
# ------------------------------------------------------------------
333
#  METHOD:  bp_restore - restore the breakpoints from a file of gdb
334
#                      commands
335
# ------------------------------------------------------------------
336
body BpWin::bp_restore {} {
337
  set inH [tk_getOpenFile]
338
  if {$inH == ""} {
339
    return
340
  }
341
  bp_all delete
342
  if {[catch {gdb_cmd "source $inH"} err]} {
343
    tk_messageBox -message "Error sourcing in BP file $inH: \"$err\""
344
  }
345
}
346
 
347
# ------------------------------------------------------------------
348
#  METHOD:  bp_select - select a row in the grid
349
# ------------------------------------------------------------------
350
body BpWin::bp_select { r } {
351
  global tixOption _bp_en _bp_disp
352
 
353
  set zz [list addr file func line]
354
  if {$tracepoints} {lappend zz num pass}
355
  if {$show_threads} {lappend zz thread}
356
 
357
  if {$selected} {
358
    set i $selected
359
 
360
    foreach thing $zz {
361
      $twin.${thing}${i}  configure -fg $tixOption(fg) -bg $bg1
362
      bind $twin.${thing}${i} <3> break
363
    }
364
  }
365
 
366
  # if we click on the same line, unselect it and return
367
  if {$selected == $r} {
368
    set selected 0
369
 
370
    if {$tracepoints == 0} {
371
      $itk_interior.m.bp entryconfigure "Normal" -state disabled
372
      $itk_interior.m.bp entryconfigure "Temporary" -state disabled
373
    } else {
374
      $itk_interior.m.bp entryconfigure "Actions" -state disabled
375
    }
376
    $itk_interior.m.bp entryconfigure "Enabled" -state disabled
377
    $itk_interior.m.bp entryconfigure "Disabled" -state disabled
378
    $itk_interior.m.bp entryconfigure "Remove" -state disabled
379
 
380
    foreach thing $zz {
381
      bind $twin.${thing}${r} <3> break
382
    }
383
 
384
    return
385
  }
386
 
387
  foreach thing $zz {
388
    $twin.${thing}${r}  configure -fg $tixOption(select_fg) -bg $tixOption(select_bg)
389
    bind $twin.${thing}${r}  <3> "tk_popup $Menu %X %Y"
390
  }
391
 
392
  if {$tracepoints == 0} {
393
    $itk_interior.m.bp entryconfigure "Normal" -variable _bp_disp($r) \
394
      -command "$this bp_type $r" -state normal
395
    $itk_interior.m.bp entryconfigure "Temporary" -variable _bp_disp($r) \
396
      -command "$this bp_type $r" -state normal
397
    $Menu entryconfigure "Normal" -variable _bp_disp($r)      \
398
      -command "$this bp_type $r" -state normal
399
    $Menu entryconfigure "Temporary" -variable _bp_disp($r)      \
400
      -command "$this bp_type $r" -state normal
401
  } else {
402
    $itk_interior.m.bp entryconfigure "Actions" -command "$this get_actions $r" -state normal
403
    $Menu entryconfigure "Actions" -command "$this get_actions $r" -state normal
404
  }
405
  $itk_interior.m.bp entryconfigure "Enabled" -variable _bp_en($r)   \
406
    -command "$this bp_able $r" -state normal
407
  $itk_interior.m.bp entryconfigure "Disabled" -variable _bp_en($r)   \
408
    -command "$this bp_able $r" -state normal
409
  $itk_interior.m.bp entryconfigure "Remove" -command "$this bp_remove $r" -state normal
410
  $Menu entryconfigure "Enabled" -variable _bp_en($r)        \
411
    -command "$this bp_able $r" -state normal
412
  $Menu entryconfigure "Disabled" -variable _bp_en($r)        \
413
    -command "$this bp_able $r" -state normal
414
  $Menu entryconfigure "Remove" -command "$this bp_remove $r" -state normal
415
 
416
  set selected $r
417
}
418
 
419
# ------------------------------------------------------------------
420
#  METHOD:  bp_modify - modify a breakpoint entry
421
# ------------------------------------------------------------------
422
body BpWin::bp_modify {bp_event {tracepoint 0}} {
423
  global _bp_en _bp_disp tcl_platform _files
424
 
425
  set number [$bp_event get number]
426
  set thread [$bp_event get thread]
427
  set disposition [$bp_event get disposition]
428
  set file [$bp_event get file]
429
 
430
  if {$tracepoint} {
431
    set disposition tracepoint
432
    set bptype tracepoint
433
  } else {
434
    set bptype breakpoint
435
  }
436
 
437
  set found 0
438
  for {set i 1} {$i < $next_row} {incr i} {
439
    if { $number == $index_to_bpnum($i)
440
         && "$Index_to_bptype($i)" == "$bptype"} {
441
      incr found
442
      break
443
    }
444
  }
445
 
446
  if {!$found} {
447
    debug "ERROR: breakpoint number $number not found!"
448
    return
449
  }
450
 
451
  if {$_bp_en($i) != [$bp_event get enabled]} {
452
    set _bp_en($i) [$bp_event get enabled]
453
  }
454
 
455
  if {$_bp_disp($i) != $disposition} {
456
    set _bp_disp($i) $disposition
457
  }
458
 
459
  switch $disposition {
460
    donttouch { set color [pref get gdb/src/bp_fg] }
461
    delete {
462
      set color [pref get gdb/src/temp_bp_fg]
463
    }
464
    tracepoint { set color [pref get gdb/src/trace_fg] }
465
    default { set color yellow}
466
  }
467
 
468
  if {$thread != "-1"} {set color [pref get gdb/src/thread_fg]}
469
 
470
  if {$tcl_platform(platform) == "windows"} then {
471
    $twin.en$i configure -fg $color
472
  } else {
473
    $twin.en$i configure -selectcolor $color
474
  }
475
  if {$tracepoints} {
476
    $twin.num$i configure  -text "$number "
477
  }
478
  $twin.addr$i configure -text "[$bp_event get address] "
479
  if {[info exists _files(short,$file)]} {
480
    set file $_files(short,$file)
481
  } else {
482
    # FIXME.  Really need to do better than this.
483
    set file [::file tail $file]
484
  }
485
  if {$show_threads} {
486
    if {$thread == "-1"} {set thread "ALL"}
487
    $twin.thread$i configure -text "$thread "
488
  }
489
  $twin.file$i configure -text "$file "
490
  $twin.line$i configure  -text "[$bp_event get line] "
491
  $twin.func$i configure  -text "[$bp_event get function] "
492
  if {$tracepoints} {
493
    $twin.pass$i configure  -text "[$bp_event get pass_count] "
494
  }
495
}
496
 
497
# ------------------------------------------------------------------
498
#  METHOD:  bp_able - enable/disable a breakpoint
499
# ------------------------------------------------------------------
500
body BpWin::bp_able { i } {
501
  global _bp_en
502
 
503
  bp_select $i
504
 
505
  switch $Index_to_bptype($i) {
506
    breakpoint {set type {}}
507
    tracepoint {set type "tracepoint"}
508
  }
509
 
510
  if {$_bp_en($i) == "1"} {
511
    set command "enable $type $temp($i) "
512
  } else {
513
    set command "disable $type "
514
  }
515
 
516
  append command  "$index_to_bpnum($i)"
517
  gdb_cmd "$command"
518
}
519
 
520
# ------------------------------------------------------------------
521
#  METHOD:  bp_remove - remove a breakpoint
522
# ------------------------------------------------------------------
523
body BpWin::bp_remove { i } {
524
 
525
  bp_select $i
526
 
527
  switch $Index_to_bptype($i) {
528
    breakpoint { set type {} }
529
    tracepoint { set type "tracepoint" }
530
  }
531
 
532
  gdb_cmd "delete $type $index_to_bpnum($i)"
533
}
534
 
535
# ------------------------------------------------------------------
536
#  METHOD:  bp_type - change the breakpoint type (disposition)
537
# ------------------------------------------------------------------
538
body BpWin::bp_type { i } {
539
 
540
  if {$Index_to_bptype($i) != "breakpoint"} {
541
    return
542
  }
543
 
544
  set bpnum $index_to_bpnum($i)
545
  #debug "bp_type $i $bpnum"
546
  set bpinfo [gdb_get_breakpoint_info $bpnum]
547
  lassign $bpinfo file func line pc type enabled disposition \
548
    ignore_count commands cond thread hit_count user_spec
549
  bp_select $i
550
  switch $disposition {
551
    delete {
552
      gdb_cmd "delete $bpnum"
553
      gdb_cmd "break *$pc"
554
    }
555
    donttouch {
556
      gdb_cmd "delete $bpnum"
557
      gdb_cmd "tbreak *$pc"
558
    }
559
    default { debug "Unknown breakpoint disposition: $disposition" }
560
  }
561
}
562
 
563
# ------------------------------------------------------------------
564
#  METHOD:  bp_delete - delete a breakpoint
565
# ------------------------------------------------------------------
566
body BpWin::bp_delete {bp_event} {
567
  set number [$bp_event get number]
568
  for {set i 1} {$i < $next_row} {incr i} {
569
    if { $number == $index_to_bpnum($i) } {
570
      if {$tracepoints} {
571
        grid forget $twin.en$i $twin.num$i $twin.addr$i $twin.file$i \
572
          $twin.line$i $twin.func$i $twin.pass$i
573
        destroy $twin.en$i $twin.num$i $twin.addr$i $twin.file$i \
574
          $twin.line$i $twin.func$i $twin.pass$i
575
      } else {
576
        if {$show_threads} {
577
          grid forget $twin.thread$i
578
          destroy $twin.thread$i
579
        }
580
        grid forget $twin.en$i $twin.addr$i $twin.file$i $twin.line$i $twin.func$i
581
        destroy $twin.en$i $twin.addr$i $twin.file$i $twin.line$i $twin.func$i
582
      }
583
      if {$selected == $i} {
584
        set selected 0
585
      }
586
      return
587
    }
588
  }
589
}
590
 
591
# ------------------------------------------------------------------
592
#  PUBLIC METHOD:  breakpoint - Update widget when a breakpoint
593
#                   event is received from the backend.
594
# ------------------------------------------------------------------
595
body BpWin::breakpoint {bp_event} {
596
 
597
  set action [$bp_event get action]
598
  #debug "bp update $action [$bp_event get number] [$bp_event get type]"
599
 
600
  switch $action {
601
    modify  { bp_modify $bp_event 0 }
602
    create  { bp_add $bp_event 0 }
603
    delete  { bp_delete $bp_event }
604
    default { dbug E "Unknown breakpoint action: $action" }
605
  }
606
}
607
 
608
# ------------------------------------------------------------------
609
#  METHOD:  tracepoint - Update widget when a tracepoint event
610
#            is received from the backend.
611
# ------------------------------------------------------------------
612
body BpWin::tracepoint {tp_event} {
613
 
614
  set action [$tp_event get action]
615
  #debug "tp update $action [$tp_event get number]"
616
 
617
  switch $action {
618
    modify  { bp_modify $tp_event 1 }
619
    create  { bp_add $tp_event 1 }
620
    delete  { bp_delete $tp_event }
621
    default { dbug E "Unknown tracepoint action: $action" }
622
  }
623
}
624
 
625
# ------------------------------------------------------------------
626
#  METHOD:  bp_all - perform a command on all breakpoints
627
# ------------------------------------------------------------------
628
body BpWin::bp_all { command } {
629
 
630
  if {!$tracepoints} {
631
    # Do all breakpoints
632
    foreach bpnum [gdb_get_breakpoint_list] {
633
      if { $command == "enable"} {
634
        for {set i 1} {$i < $next_row} {incr i} {
635
          if { $bpnum == $index_to_bpnum($i)
636
               && "$Index_to_bptype($i)" == "breakpoint"} {
637
            gdb_cmd "enable $temp($i) $bpnum"
638
            break
639
          }
640
        }
641
      } else {
642
        gdb_cmd "$command $bpnum"
643
      }
644
    }
645
  } else {
646
    # Do all tracepoints
647
    foreach bpnum [gdb_get_tracepoint_list] {
648
      if { $command == "enable"} {
649
        for {set i 1} {$i < $next_row} {incr i} {
650
          if { $bpnum == $index_to_bpnum($i)
651
               && "$Index_to_bptype($i)" == "tracepoint"} {
652
            gdb_cmd "enable tracepoint $bpnum"
653
            break
654
          }
655
        }
656
      } else {
657
        gdb_cmd "$command tracepoint $bpnum"
658
      }
659
    }
660
  }
661
}
662
 
663
# ------------------------------------------------------------------
664
#  METHOD:  get_actions - pops up the add trace dialog on a selected
665
#                         tracepoint
666
# ------------------------------------------------------------------
667
body BpWin::get_actions {bpnum} {
668
  set bpnum $index_to_bpnum($bpnum)
669
  set bpinfo [gdb_get_tracepoint_info $bpnum]
670
  lassign $bpinfo file func line pc enabled pass_count \
671
    step_count thread hit_count actions
672
 
673
  set filename [::file tail $file]
674
  ManagedWin::open TraceDlg -File $filename -Lines $line
675
}
676
 
677
# ------------------------------------------------------------------
678
#  METHOD:  toggle_threads - callback when show_threads is toggled
679
# ------------------------------------------------------------------
680
body BpWin::toggle_threads {} {
681
  set show_threads [pref get gdb/bp/show_threads]
682
  reconfig
683
}
684
 
685
# ------------------------------------------------------------------
686
#  METHOD:  reconfig - used when preferences change
687
# ------------------------------------------------------------------
688
body BpWin::reconfig {} {
689
  if {[winfo exists $itk_interior.f]} { destroy $itk_interior.f }
690
  if {[winfo exists $itk_interior.m]} { destroy $itk_interior.m }
691
  if {[winfo exists $itk_interior.pop]} { destroy $itk_interior.pop }
692
  build_win
693
}
694
 
695
# ------------------------------------------------------------------
696
#  METHOD:  goto_bp - show bp in source window
697
# ------------------------------------------------------------------
698
body BpWin::goto_bp {r} {
699
  set bpnum $index_to_bpnum($r)
700
  if {$tracepoints} {
701
    set bpinfo [gdb_get_tracepoint_info $bpnum]
702
  } else {
703
    set bpinfo [gdb_get_breakpoint_info $bpnum]
704
  }
705
  set pc [lindex $bpinfo 3]
706
 
707
  SrcWin::choose_and_display BROWSE_TAG [gdb_loc *$pc]
708
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.