diff options
author | Joel Brobecker <brobecker@gnat.com> | 2012-02-03 07:32:40 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2012-02-03 07:32:40 +0000 |
commit | f7e44f6574a59496a4635c91080d635d095f81c8 (patch) | |
tree | c0a6984200aad946f75d8b27b5b4d06a9af8cd27 /gdb/mi/mi-cmd-stack.c | |
parent | 16bbd316adcf5dc1b16a8797da0a5fe2a397b66b (diff) | |
download | gdb-f7e44f6574a59496a4635c91080d635d095f81c8.zip gdb-f7e44f6574a59496a4635c91080d635d095f81c8.tar.gz gdb-f7e44f6574a59496a4635c91080d635d095f81c8.tar.bz2 |
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
Diffstat (limited to 'gdb/mi/mi-cmd-stack.c')
-rw-r--r-- | gdb/mi/mi-cmd-stack.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index c0c17bc..4ad9f7c 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -389,11 +389,12 @@ list_args_or_locals (enum what_to_list what, enum print_values values, struct frame_arg arg, entryarg; if (SYMBOL_IS_ARGUMENT (sym)) - sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym), + sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), block, VAR_DOMAIN, (int *) NULL); else sym2 = sym; + gdb_assert (sym2 != NULL); memset (&arg, 0, sizeof (arg)); arg.sym = sym2; |