diff options
| author | Eli Zaretskii | 2011-10-29 15:35:23 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2011-10-29 15:35:23 +0200 |
| commit | 8b058d447425857f933c119edbac3c1e2da3e1f3 (patch) | |
| tree | 61907528bf161ea6783014135d6924d173cb22f7 /src | |
| parent | aa4dfba7fd52e598b29e3a13efe8743837a2e53b (diff) | |
| download | emacs-8b058d447425857f933c119edbac3c1e2da3e1f3.tar.gz emacs-8b058d447425857f933c119edbac3c1e2da3e1f3.zip | |
Fix the `xbytecode' user-defined command in .gdbinit.
src/.gdbinit (xprintbytestr): New command.
(xwhichsymbols): Renamed from `which'; all callers changed.
(xbytecode): Print the byte-code string as well.
src/alloc.c (which_symbols): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 28 | ||||
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/alloc.c | 49 |
3 files changed, 80 insertions, 6 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index b908ef005d6..80415abe40d 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -1245,20 +1245,36 @@ document xbacktrace | |||
| 1245 | an error was signaled. | 1245 | an error was signaled. |
| 1246 | end | 1246 | end |
| 1247 | 1247 | ||
| 1248 | define which | 1248 | define xprintbytestr |
| 1249 | set debug_print (which_symbols ($arg0)) | 1249 | set $data = (char *) $arg0->data |
| 1250 | printf "Bytecode: " | ||
| 1251 | output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) | ||
| 1252 | end | ||
| 1253 | document xprintbytestr | ||
| 1254 | Print a string of byte code. | ||
| 1255 | end | ||
| 1256 | |||
| 1257 | define xwhichsymbols | ||
| 1258 | set $output_debug = print_output_debug_flag | ||
| 1259 | set print_output_debug_flag = 0 | ||
| 1260 | set safe_debug_print (which_symbols ($arg0, $arg1)) | ||
| 1261 | set print_output_debug_flag = $output_debug | ||
| 1250 | end | 1262 | end |
| 1251 | document which | 1263 | document xwhichsymbols |
| 1252 | Print symbols which references a given lisp object | 1264 | Print symbols which references a given lisp object |
| 1253 | either as its symbol value or symbol function. | 1265 | either as its symbol value or symbol function. |
| 1266 | Call with two arguments: the lisp object and the | ||
| 1267 | maximum number of symbols referencing it to produce. | ||
| 1254 | end | 1268 | end |
| 1255 | 1269 | ||
| 1256 | define xbytecode | 1270 | define xbytecode |
| 1257 | set $bt = byte_stack_list | 1271 | set $bt = byte_stack_list |
| 1258 | while $bt | 1272 | while $bt |
| 1259 | xgettype ($bt->byte_string) | 1273 | xgetptr $bt->byte_string |
| 1260 | printf "0x%x => ", $bt->byte_string | 1274 | set $ptr = (struct Lisp_String *) $ptr |
| 1261 | which $bt->byte_string | 1275 | xprintbytestr $ptr |
| 1276 | printf "\n0x%x => ", $bt->byte_string | ||
| 1277 | xwhichsymbols $bt->byte_string 5 | ||
| 1262 | set $bt = $bt->next | 1278 | set $bt = $bt->next |
| 1263 | end | 1279 | end |
| 1264 | end | 1280 | end |
diff --git a/src/ChangeLog b/src/ChangeLog index 5a7d66ceb17..98c050c2379 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2011-10-29 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | Fix the `xbytecode' command. | ||
| 4 | * .gdbinit (xprintbytestr): New command. | ||
| 5 | (xwhichsymbols): Renamed from `which'; all callers changed. | ||
| 6 | (xbytecode): Print the byte-code string as well. | ||
| 7 | |||
| 8 | * alloc.c (which_symbols): New function. | ||
| 9 | |||
| 1 | 2011-10-29 Andreas Schwab <schwab@linux-m68k.org> | 10 | 2011-10-29 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 11 | ||
| 3 | * minibuf.c (read_minibuf_noninteractive): Allow reading empty | 12 | * minibuf.c (read_minibuf_noninteractive): Allow reading empty |
diff --git a/src/alloc.c b/src/alloc.c index 6e999a0ba6d..ac5da1c2fa1 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6250,6 +6250,55 @@ Frames, windows, buffers, and subprocesses count as vectors | |||
| 6250 | return Flist (8, consed); | 6250 | return Flist (8, consed); |
| 6251 | } | 6251 | } |
| 6252 | 6252 | ||
| 6253 | /* Find at most FIND_MAX symbols which have OBJ as their value or | ||
| 6254 | function. This is used in gdbinit's `xwhichsymbols' command. */ | ||
| 6255 | |||
| 6256 | Lisp_Object | ||
| 6257 | which_symbols (Lisp_Object obj, int find_max) | ||
| 6258 | { | ||
| 6259 | struct symbol_block *sblk; | ||
| 6260 | int gc_count = inhibit_garbage_collection (); | ||
| 6261 | Lisp_Object found = Qnil; | ||
| 6262 | |||
| 6263 | if (!EQ (obj, Vdead)) | ||
| 6264 | { | ||
| 6265 | for (sblk = symbol_block; sblk; sblk = sblk->next) | ||
| 6266 | { | ||
| 6267 | struct Lisp_Symbol *sym = sblk->symbols; | ||
| 6268 | int bn; | ||
| 6269 | |||
| 6270 | for (bn = 0; bn < SYMBOL_BLOCK_SIZE; bn++, sym++) | ||
| 6271 | { | ||
| 6272 | Lisp_Object val; | ||
| 6273 | Lisp_Object tem; | ||
| 6274 | |||
| 6275 | if (sblk == symbol_block && bn >= symbol_block_index) | ||
| 6276 | break; | ||
| 6277 | |||
| 6278 | XSETSYMBOL (tem, sym); | ||
| 6279 | val = find_symbol_value (tem); | ||
| 6280 | if (EQ (val, obj) | ||
| 6281 | || EQ (sym->function, obj) | ||
| 6282 | || (!NILP (sym->function) | ||
| 6283 | && COMPILEDP (sym->function) | ||
| 6284 | && EQ (AREF (sym->function, COMPILED_BYTECODE), obj)) | ||
| 6285 | || (!NILP (val) | ||
| 6286 | && COMPILEDP (val) | ||
| 6287 | && EQ (AREF (val, COMPILED_BYTECODE), obj))) | ||
| 6288 | { | ||
| 6289 | found = Fcons (tem, found); | ||
| 6290 | if (--find_max == 0) | ||
| 6291 | goto out; | ||
| 6292 | } | ||
| 6293 | } | ||
| 6294 | } | ||
| 6295 | } | ||
| 6296 | |||
| 6297 | out: | ||
| 6298 | unbind_to (gc_count, Qnil); | ||
| 6299 | return found; | ||
| 6300 | } | ||
| 6301 | |||
| 6253 | #ifdef ENABLE_CHECKING | 6302 | #ifdef ENABLE_CHECKING |
| 6254 | int suppress_checking; | 6303 | int suppress_checking; |
| 6255 | 6304 | ||