|
| 1 | +# Enable execution recording |
| 2 | +#target record |
| 3 | + |
| 4 | +set record stop-at-limit off |
| 5 | +set record insn-number-max 1000 |
| 6 | + |
| 7 | +# Shared libraries |
| 8 | +set auto-solib-add on |
| 9 | +set debug-file-directory /usr/lib/debug/:/usr/local/lib/debug/ |
| 10 | +set stop-on-solib-events 0 |
| 11 | + |
| 12 | +# Don't stop when a signal is recieved |
| 13 | +handle all pass print nostop |
| 14 | +handle SIGSEGV pass print stop |
| 15 | + |
| 16 | +# Environment info |
| 17 | +#set verbose on |
| 18 | +#set trace-commands on |
| 19 | +#set schedule-multiple on |
| 20 | +#set debug observer 1 |
| 21 | + |
| 22 | +# Stringer type constants |
| 23 | +set $gdb_constant_t = 1 |
| 24 | +set $gdb_placer_t = 2 |
| 25 | +set $gdb_nuller_t = 4 |
| 26 | +set $gdb_block_t = 8 |
| 27 | +set $gdb_managed_t = 16 |
| 28 | +set $gdb_mapped_t = 32 |
| 29 | + |
| 30 | +# Stringer print helpers |
| 31 | +define pstr_len |
| 32 | + |
| 33 | + set $opts = *((uint32_t *)$arg0) |
| 34 | + |
| 35 | + if ($opts & $gdb_constant_t) == $gdb_constant_t |
| 36 | + printf "Length = NULL\n" |
| 37 | + end |
| 38 | + if ($opts & $gdb_placer_t) == $gdb_placer_t |
| 39 | + printf "Length = %u\n", ((placer_t *)$arg0)->length |
| 40 | + end |
| 41 | + if ($opts & $gdb_nuller_t) == $gdb_nuller_t |
| 42 | + printf "Length = NULL\n" |
| 43 | + end |
| 44 | + if ($opts & $gdb_block_t) == $gdb_block_t |
| 45 | + printf "Length = %u\n", ((block_t *)$arg0)->length |
| 46 | + end |
| 47 | + if ($opts & $gdb_managed_t) == $gdb_managed_t |
| 48 | + printf "Length = %u\n", ((managed_t *)$arg0)->length |
| 49 | + end |
| 50 | + if ($opts & $gdb_mapped_t) == $gdb_mapped_t |
| 51 | + printf "Length = %u\n", ((mapped_t *)$arg0)->length |
| 52 | + end |
| 53 | + |
| 54 | +end |
| 55 | +document pstr_len |
| 56 | + Print the data length of a stringer buffer. |
| 57 | +end |
| 58 | + |
| 59 | +define pstr_avail |
| 60 | + |
| 61 | + set $opts = *((uint32_t *)$arg0) |
| 62 | + |
| 63 | + if ($opts & $gdb_constant_t) == $gdb_constant_t |
| 64 | + printf "Available = NULL\n" |
| 65 | + end |
| 66 | + if ($opts & $gdb_placer_t) == $gdb_placer_t |
| 67 | + printf "Available = NULL\n" |
| 68 | + end |
| 69 | + if ($opts & $gdb_nuller_t) == $gdb_nuller_t |
| 70 | + printf "Available = NULL\n" |
| 71 | + end |
| 72 | + if ($opts & $gdb_block_t) == $gdb_block_t |
| 73 | + printf "Available = NULL\n" |
| 74 | + end |
| 75 | + if ($opts & $gdb_managed_t) == $gdb_managed_t |
| 76 | + printf "Available = %u\n", ((managed_t *)$arg0)->avail |
| 77 | + end |
| 78 | + if ($opts & $gdb_mapped_t) == $gdb_mapped_t |
| 79 | + printf "Available = %u\n", ((mapped_t *)$arg0)->avail |
| 80 | + end |
| 81 | + |
| 82 | +end |
| 83 | +document pstr_avail |
| 84 | + Print the allocated length of a stringer buffer. |
| 85 | +end |
| 86 | + |
| 87 | +define pstr_data |
| 88 | + |
| 89 | + set $opts = *((uint32_t *)$arg0) |
| 90 | + |
| 91 | + if ($opts & $gdb_constant_t) == $gdb_constant_t |
| 92 | + output *((char *)((constant_t *)$arg0)->data) |
| 93 | + end |
| 94 | + if ($opts & $gdb_placer_t) == $gdb_placer_t |
| 95 | + output *((char *)((placer_t *)$arg0)->data)@((placer_t *)$arg0)->length |
| 96 | + end |
| 97 | + if ($opts & $gdb_nuller_t) == $gdb_nuller_t |
| 98 | + output *((char *)((nuller_t *)$arg0)->data) |
| 99 | + end |
| 100 | + if ($opts & $gdb_block_t) == $gdb_block_t |
| 101 | + output *((char *)((block_t *)$arg0)->data)@((block_t *)$arg0)->length |
| 102 | + end |
| 103 | + if ($opts & $gdb_managed_t) == $gdb_managed_t |
| 104 | + output *((char *)((managed_t *)$arg0)->data)@((managed_t *)$arg0)->length |
| 105 | + end |
| 106 | + if ($opts & $gdb_mapped_t) == $gdb_mapped_t |
| 107 | + output *((char *)((mapped_t *)$arg0)->data)@((mapped_t *)$arg0)->length |
| 108 | + end |
| 109 | + |
| 110 | +end |
| 111 | +document pstr_data |
| 112 | + Print the data stored in a stringer buffer. |
| 113 | +end |
0 commit comments