[Crash-utility] display function parameters for call stack
Dave Anderson
anderson at redhat.com
Tue Sep 25 13:54:31 UTC 2012
----- Original Message -----
>
> I find print_frame_args in gdb/stack.c seems to be the function to print out
> the argument's name. Its working mechanism is exacting out all symbols
> in the specified function with ALL_BLOCK_SYMBOLS. Then discard those symbol
> not as argument by SYMBOL_IS_ARGUMENT. At last it would get the argument
> name by SYMBOL_PRINT_NAME.
I think the problem you'll have there is the frame_info structure that
gets passed in to print_frame_args(). But maybe you can pull out a
subset of that function to just access the argument names from the
text symbol?
>
> So how could I reach this print_frame_args by crash, need modify gdb side
> to create such helper function?
> I am not familiar with the gdb modification...
> Is there any example to show me how to do this change?
> It is better that the example itself contains how to connect the
> change with crash. :)
For examples, check out any of the current users of gdb_interface().
They all set up a gnu_request structure with a command and any other
information required, and pass it into the gdb module.
To test your code, you can borrow the GNU_DEBUG_COMMAND command.
For example, you could create a function like this, which passes
the text symbol's name into the gdb module:
your_function(char *text_symbol)
{
struct gnu_request request, *req = &request;
req->command = GNU_DEBUG_COMMAND;
req->flags |= GNU_RETURN_ON_ERROR;
req->name = text_symbol;
/*
* fill in any other fields in the gnu_request struct
*/
gdb_interface(req);
if (req->flags & GNU_COMMAND_FAILED) {
goto error_out;
}
...
}
The gnu_request structure has several other general-purpose members
that you can use if more than the symbol name string is required.
Then, the gdb_interface() call above will end up here in
gdb-7.3.1/gdb/symtab.c:
void
gdb_command_funnel(struct gnu_request *req)
{
struct symbol *sym;
if (req->command != GNU_VERSION) {
replace_ui_file_FILE(gdb_stdout, req->fp);
replace_ui_file_FILE(gdb_stderr, req->fp);
do_cleanups((struct cleanup *)0);
}
switch (req->command)
{
...[ cut ] ...
case GNU_DEBUG_COMMAND:
gdb_debug_command(req);
break;
... [ cut ] ...
}
And you can do whatever you want in gdb_debug_command(), which is
also located in gdb-7.3.1/gdb/symtab.c:
static void
gdb_debug_command(struct gnu_request *req)
{
}
If you can get something working, we can add a new gdb
GNU_XXXX command that does what you want.
Dave
More information about the Crash-utility
mailing list