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.
This commit is contained in:
Eli Zaretskii 2011-10-29 15:35:23 +02:00
parent aa4dfba7fd
commit 8b058d4474
3 changed files with 80 additions and 6 deletions

View file

@ -1245,20 +1245,36 @@ document xbacktrace
an error was signaled.
end
define which
set debug_print (which_symbols ($arg0))
define xprintbytestr
set $data = (char *) $arg0->data
printf "Bytecode: "
output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
end
document which
document xprintbytestr
Print a string of byte code.
end
define xwhichsymbols
set $output_debug = print_output_debug_flag
set print_output_debug_flag = 0
set safe_debug_print (which_symbols ($arg0, $arg1))
set print_output_debug_flag = $output_debug
end
document xwhichsymbols
Print symbols which references a given lisp object
either as its symbol value or symbol function.
Call with two arguments: the lisp object and the
maximum number of symbols referencing it to produce.
end
define xbytecode
set $bt = byte_stack_list
while $bt
xgettype ($bt->byte_string)
printf "0x%x => ", $bt->byte_string
which $bt->byte_string
xgetptr $bt->byte_string
set $ptr = (struct Lisp_String *) $ptr
xprintbytestr $ptr
printf "\n0x%x => ", $bt->byte_string
xwhichsymbols $bt->byte_string 5
set $bt = $bt->next
end
end

View file

@ -1,3 +1,12 @@
2011-10-29 Eli Zaretskii <eliz@gnu.org>
Fix the `xbytecode' command.
* .gdbinit (xprintbytestr): New command.
(xwhichsymbols): Renamed from `which'; all callers changed.
(xbytecode): Print the byte-code string as well.
* alloc.c (which_symbols): New function.
2011-10-29 Andreas Schwab <schwab@linux-m68k.org>
* minibuf.c (read_minibuf_noninteractive): Allow reading empty

View file

@ -6250,6 +6250,55 @@ Frames, windows, buffers, and subprocesses count as vectors
return Flist (8, consed);
}
/* Find at most FIND_MAX symbols which have OBJ as their value or
function. This is used in gdbinit's `xwhichsymbols' command. */
Lisp_Object
which_symbols (Lisp_Object obj, int find_max)
{
struct symbol_block *sblk;
int gc_count = inhibit_garbage_collection ();
Lisp_Object found = Qnil;
if (!EQ (obj, Vdead))
{
for (sblk = symbol_block; sblk; sblk = sblk->next)
{
struct Lisp_Symbol *sym = sblk->symbols;
int bn;
for (bn = 0; bn < SYMBOL_BLOCK_SIZE; bn++, sym++)
{
Lisp_Object val;
Lisp_Object tem;
if (sblk == symbol_block && bn >= symbol_block_index)
break;
XSETSYMBOL (tem, sym);
val = find_symbol_value (tem);
if (EQ (val, obj)
|| EQ (sym->function, obj)
|| (!NILP (sym->function)
&& COMPILEDP (sym->function)
&& EQ (AREF (sym->function, COMPILED_BYTECODE), obj))
|| (!NILP (val)
&& COMPILEDP (val)
&& EQ (AREF (val, COMPILED_BYTECODE), obj)))
{
found = Fcons (tem, found);
if (--find_max == 0)
goto out;
}
}
}
}
out:
unbind_to (gc_count, Qnil);
return found;
}
#ifdef ENABLE_CHECKING
int suppress_checking;