| 1 |
namespace eval showdebuggable { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
set_help_text showdebuggable \ |
| 7 |
{Prints content of debuggable nicely formatted |
| 8 |
|
| 9 |
Usage: |
| 10 |
showdebuggable <debuggable> <address> [<linecount>] [<columns>] |
| 11 |
} |
| 12 |
|
| 13 |
set_tabcompletion_proc showdebuggable [namespace code tab_showdebuggable] |
| 14 |
proc tab_showdebuggable {args} { |
| 15 |
if {[llength $args] == 2} { |
| 16 |
return [debug list] |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
proc showdebuggable_line {debuggable address {columns 16}} { |
| 21 |
set size [debug size $debuggable] |
| 22 |
set num [expr {(($address + $columns) <= $size) ? $columns : ($size - $address)}] |
| 23 |
set mem "[debug read_block $debuggable $address $num]" |
| 24 |
binary scan $mem c* values |
| 25 |
set hex "" |
| 26 |
foreach val $values { |
| 27 |
append hex [format "%02x " [expr {$val & 0xff}]] |
| 28 |
} |
| 29 |
set pad [string repeat " " [expr {$columns - $num}]] |
| 30 |
set asc [regsub -all {[^ !-~]} $mem {.}] |
| 31 |
return [format "%04x: %s%s %s\n" $address $hex $pad $asc] |
| 32 |
} |
| 33 |
|
| 34 |
proc showdebuggable {debuggable {address 0} {lines 8} {columns 16}} { |
| 35 |
set result "" |
| 36 |
for {set i 0} {$i < $lines} {incr i} { |
| 37 |
if {$address >= [debug size $debuggable]} break |
| 38 |
append result [showdebuggable_line $debuggable $address $columns] |
| 39 |
incr address $columns |
| 40 |
} |
| 41 |
return $result |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
set_help_text showmem \ |
| 47 |
{Prints the content of the CPU visible memory nicely formatted |
| 48 |
This is a shortcut for 'showdebuggable memory <address> <linecount> <columns>'. |
| 49 |
|
| 50 |
Usage: |
| 51 |
showmem <address> [<linecount>] [<columns>] |
| 52 |
} |
| 53 |
|
| 54 |
proc showmem {{address 0} {lines 8} {columns 16}} { |
| 55 |
showdebuggable memory $address $lines $columns |
| 56 |
} |
| 57 |
|
| 58 |
namespace export showdebuggable |
| 59 |
namespace export showmem |
| 60 |
|
| 61 |
} ; |
| 62 |
|
| 63 |
namespace import showdebuggable::* |