Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Crash Utility (http://www.linux-archive.org/crash-utility/)
-   -   display function parameters for call stack (http://www.linux-archive.org/crash-utility/706042-display-function-parameters-call-stack.html)

Lei Wen 09-21-2012 08:56 AM

display function parameters for call stack
 
Hi Dave,
I notice there was some discussion around on enablingthe*display function parameters feature for crash tool.Like this one:*http://www.redhat.com/archives/crash-utility/2009-May/msg00016.html

Although the answer seems to be quite clear, it should be hard tosupport such feature. But does this feature cannot be done anyway?I think this feature would be great in assisting kernel debug.

The main feature I require, first should be know each param's value in the call stack.Then it is better to know each call stack's param's name.
Like for do_vfs_ioctl function, it is better to display as:
do_vfs_ioctl(filp=xxx, fd=xxx, cmd=xxx, arg=xxx)
Do you have any idea on how this could be implemented?
Thanks,Lei
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 09-21-2012 01:44 PM

display function parameters for call stack
 
----- Original Message -----
>
> Hi Dave,
>
>
> I notice there was some discussion around on enabling
> the display function parameters feature for crash tool.
> Like this one:
> http://www.redhat.com/archives/crash-utility/2009-May/msg00016.html

Yes, it seems to come up every few years. People have tried, but it
has never come to fruition.

>
> Although the answer seems to be quite clear, it should be hard to
> support such feature. But does this feature cannot be done anyway?
> I think this feature would be great in assisting kernel debug.
>
> The main feature I require, first should be know each param's value
> in the call stack.
> Then it is better to know each call stack's param's name.
>
> Like for do_vfs_ioctl function, it is better to display as:
> do_vfs_ioctl(filp=xxx, fd=xxx, cmd=xxx, arg=xxx)
>
> Do you have any idea on how this could be implemented?

No I don't.

Good luck,
Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Lei Wen 09-24-2012 09:49 AM

display function parameters for call stack
 
Dave,

On Fri, Sep 21, 2012 at 9:44 PM, Dave Anderson <anderson@redhat.com> wrote:





----- Original Message -----

>

> Hi Dave,

>

>

> I notice there was some discussion around on enabling

> the display function parameters feature for crash tool.

> Like this one:

> http://www.redhat.com/archives/crash-utility/2009-May/msg00016.html



Yes, it seems to come up every few years. *People have tried, but it

has never come to fruition.



>

> Although the answer seems to be quite clear, it should be hard to

> support such feature. But does this feature cannot be done anyway?

> I think this feature would be great in assisting kernel debug.

>

> The main feature I require, first should be know each param's value

> in the call stack.

> Then it is better to know each call stack's param's name.

>

> Like for do_vfs_ioctl function, it is better to display as:

> do_vfs_ioctl(filp=xxx, fd=xxx, cmd=xxx, arg=xxx)

>

> Do you have any idea on how this could be implemented?



No I don't.

Sorry for asking the stupid question, but*I notice that we couldget the structure member in crash by "struct" command:crash> struct stackframe
struct stackframe {* * long unsigned int fp;* * long unsigned int sp;* * long unsigned int lr;* * long unsigned int pc;}SIZE: 16

I check the crash code, and find cmd_struct use gdb interface to parse it out.
And the gdb itself seems already could parse out function argument[1], so couldwe still use similar mechanism as the "struct" command to implement a "func"
command, which could shows the function declaration?

Reference:[1]*http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_7.html
GDB could shows the function param string and corresponding value#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) at builtin.c:993
#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
at macro.c:71
(More stack frames follow...)
Thanks,Lei
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 09-24-2012 01:30 PM

display function parameters for call stack
 
----- Original Message -----
>
> Dave,
>
>
> On Fri, Sep 21, 2012 at 9:44 PM, Dave Anderson < anderson@redhat.com
> > wrote:
>
>
>
>
>
> ----- Original Message -----
> >
> > Hi Dave,
> >
> >
> > I notice there was some discussion around on enabling
> > the display function parameters feature for crash tool.
> > Like this one:
> > http://www.redhat.com/archives/crash-utility/2009-May/msg00016.html
>
> Yes, it seems to come up every few years. People have tried, but it
> has never come to fruition.
>
>
> >
> > Although the answer seems to be quite clear, it should be hard to
> > support such feature. But does this feature cannot be done anyway?
> > I think this feature would be great in assisting kernel debug.
> >
> > The main feature I require, first should be know each param's value in the call stack.
> > Then it is better to know each call stack's param's name.
> >
> > Like for do_vfs_ioctl function, it is better to display as:
> > do_vfs_ioctl(filp=xxx, fd=xxx, cmd=xxx, arg=xxx)
> >
> > Do you have any idea on how this could be implemented?
>
> No I don't.
>
>
>
> Sorry for asking the stupid question, but I notice that we could
> get the structure member in crash by "struct" command:
>
> crash> struct stackframe
> struct stackframe {
> long unsigned int fp;
> long unsigned int sp;
> long unsigned int lr;
> long unsigned int pc;
> }
> SIZE: 16
>
>
> I check the crash code, and find cmd_struct use gdb interface to
> parse it out.
>
>
> And the gdb itself seems already could parse out function argument[1], so could
> we still use similar mechanism as the "struct" command to implement a "func"
> command, which could shows the function declaration?

You can either use the "whatis" command to get the function declaration:

crash> help whatis

NAME
whatis - search symbol table for data or type information

SYNOPSIS
whatis [struct | union | typedef | symbol]

DESCRIPTION
This command displays the definition of structures, unions, typedefs or
text/data symbols.
...


crash> whatis do_vfs_ioctl
int do_vfs_ioctl(struct file *, unsigned int, unsigned int, long unsigned int);
crash>

Or print it with "p", which gives you both the declaration and its virtual address:

crash> p do_vfs_ioctl
do_vfs_ioctl = $14 =
{int (struct file *, unsigned int, unsigned int, long unsigned int)} 0xffffffff811247ec <do_vfs_ioctl>
crash>

Dave





--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Lei Wen 09-24-2012 01:44 PM

display function parameters for call stack
 
On Mon, Sep 24, 2012 at 9:30 PM, Dave Anderson <anderson@redhat.com> wrote:





----- Original Message -----

>

> Dave,

>

>

> On Fri, Sep 21, 2012 at 9:44 PM, Dave Anderson < anderson@redhat.com

> > wrote:

>

>

>

>

>

> ----- Original Message -----

> >

> > Hi Dave,

> >

> >

> > I notice there was some discussion around on enabling

> > the display function parameters feature for crash tool.

> > Like this one:

> > http://www.redhat.com/archives/crash-utility/2009-May/msg00016.html

>

> Yes, it seems to come up every few years. People have tried, but it

> has never come to fruition.

>

>

> >

> > Although the answer seems to be quite clear, it should be hard to

> > support such feature. But does this feature cannot be done anyway?

> > I think this feature would be great in assisting kernel debug.

> >

> > The main feature I require, first should be know each param's value in the call stack.

> > Then it is better to know each call stack's param's name.

> >

> > Like for do_vfs_ioctl function, it is better to display as:

> > do_vfs_ioctl(filp=xxx, fd=xxx, cmd=xxx, arg=xxx)

> >

> > Do you have any idea on how this could be implemented?

>

> No I don't.

>

>

>

> Sorry for asking the stupid question, but I notice that we could

> get the structure member in crash by "struct" command:

>

> crash> struct stackframe

> struct stackframe {

> long unsigned int fp;

> long unsigned int sp;

> long unsigned int lr;

> long unsigned int pc;

> }

> SIZE: 16

>

>

> I check the crash code, and find cmd_struct use gdb interface to

> parse it out.

>

>

> And the gdb itself seems already could parse out function argument[1], so could

> we still use similar mechanism as the "struct" command to implement a "func"

> command, which could shows the function declaration?



You can either use the "whatis" command to get the function declaration:



*crash> help whatis



*NAME

* *whatis - search symbol table for data or type information



*SYNOPSIS

* *whatis [struct | union | typedef | symbol]



*DESCRIPTION

* *This command displays the definition of structures, unions, typedefs or

* *text/data symbols.

*...





*crash> whatis do_vfs_ioctl

*int do_vfs_ioctl(struct file *, unsigned int, unsigned int, long unsigned int);

*crash>



Or print it with "p", which gives you both the declaration and its virtual address:



*crash> p do_vfs_ioctl

*do_vfs_ioctl = $14 =

* {int (struct file *, unsigned int, unsigned int, long unsigned int)} 0xffffffff811247ec <do_vfs_ioctl>

*crash>



That works. :)However could it be possible to show the argument without only display its type?The kernel is defining the do_vfs_ioctl as:
int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,* * * * * * *unsigned long arg);Could the "filp, fd, cmd, arg" be showed out?*

Dave



Thanks,Lei*
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 09-24-2012 01:55 PM

display function parameters for call stack
 
----- Original Message -----


> You can either use the "whatis" command to get the function
> declaration:
>
> crash> help whatis
>
> NAME
> whatis - search symbol table for data or type information
>
> SYNOPSIS
> whatis [struct | union | typedef | symbol]
>
> DESCRIPTION
> This command displays the definition of structures, unions, typedefs
> or
> text/data symbols.
> ...
>
> crash> whatis do_vfs_ioctl
> int do_vfs_ioctl(struct file *, unsigned int, unsigned int, long unsigned int);
> crash>
>
> Or print it with "p", which gives you both the declaration and its
> virtual address:
>
> crash> p do_vfs_ioctl
> do_vfs_ioctl = $14 =
> {int (struct file *, unsigned int, unsigned int, long unsigned int)} 0xffffffff811247ec <do_vfs_ioctl>
> crash>
>
> That works. :)
> However could it be possible to show the argument without only display its type?
> The kernel is defining the do_vfs_ioctl as:
>
> int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned long arg);
> Could the "filp, fd, cmd, arg" be showed out?

Anything from the output line could be selectively shown if you parse
the gdb output with open_tmpfile() or open_tmpfile2() if necessary.

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Lei Wen 09-24-2012 02:17 PM

display function parameters for call stack
 
Dave,

On Mon, Sep 24, 2012 at 9:55 PM, Dave Anderson <anderson@redhat.com> wrote:





----- Original Message -----





> You can either use the "whatis" command to get the function

> declaration:

>

> crash> help whatis

>

> NAME

> whatis - search symbol table for data or type information

>

> SYNOPSIS

> whatis [struct | union | typedef | symbol]

>

> DESCRIPTION

> This command displays the definition of structures, unions, typedefs

> or

> text/data symbols.

> ...

>

> crash> whatis do_vfs_ioctl

> int do_vfs_ioctl(struct file *, unsigned int, unsigned int, long unsigned int);

> crash>

>

> Or print it with "p", which gives you both the declaration and its

> virtual address:

>

> crash> p do_vfs_ioctl

> do_vfs_ioctl = $14 =

> {int (struct file *, unsigned int, unsigned int, long unsigned int)} *0xffffffff811247ec <do_vfs_ioctl>

> crash>

>

> That works. :)

> However could it be possible to show the argument without only display its type?

> The kernel is defining the do_vfs_ioctl as:

>

> int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned long arg);

> Could the "filp, fd, cmd, arg" be showed out?



Anything from the output line could be selectively shown if you parse

the gdb output with open_tmpfile() or open_tmpfile2() if necessary.



Do you mean if I want to display out something like:int do_vfs_ioctl(struct file **filp, unsigned int*fd, unsigned int*cmd, long unsigned int*arg);
I need to use the tmpfile to pass*"filp, fd, cmd, arg" to "whatis"?
But the reality is that I don't know how to let crash extract the four parameter name,then how could I pass this info to the tmpfile?

Also the interest of me is get the output as:*do_vfs_ioctl(filp, *fd, *cmd, *arg);The parameter's type may not need to be displayed as the whatis case.
Thanks,Lei



--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 09-24-2012 03:00 PM

display function parameters for call stack
 
----- Original Message -----

> >
> Do you mean if I want to display out something like:
> int do_vfs_ioctl(struct file * filp, unsigned int fd, unsigned int cmd, long unsigned int arg);
> I need to use the tmpfile to pass "filp, fd, cmd, arg" to "whatis"?
>
> But the reality is that I don't know how to let crash extract the four parameter name,
> then how could I pass this info to the tmpfile?
>
> Also the interest of me is get the output as:
> do_vfs_ioctl(filp, fd, cmd, arg);
> The parameter's type may not need to be displayed as the whatis case.
>
> Thanks,
> Lei


Ah OK, I misunderstood your first question.

As far as getting the parameter names themselves, there is no helper
function that does that. There are two ways of accessing gdb
functionality -- either:

(1) a gdb command string can be issued unmodified via the
gdb_pass_through() function, or
(2) a specific pre-existing gdb helper function may be accessed
via gdb_interface(), which ends up in the gdb_command_funnel()
function in gdb-7.3-1/gdb/symtab.c.

with respect to (1), ideally there would be some other gdb command
string that you could pass unmodified to gdb to get what you want,
but I don't know of any.

With respect to (2), the gdb_command_funnel() function has a switch
statement for a list of several pre-existing "req->command" definitions,
but none of them pull out the actual names of text function arguments.
I would guess that the argument name strings could be pulled out with
a new gdb helper function, but you'd have to write it yourself.

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Lei Wen 09-25-2012 09:58 AM

display function parameters for call stack
 
On Mon, Sep 24, 2012 at 11:00 PM, Dave Anderson <anderson@redhat.com> wrote:





----- Original Message -----



> >

> Do you mean if I want to display out something like:

> int do_vfs_ioctl(struct file * filp, unsigned int fd, unsigned int cmd, long unsigned int arg);

> I need to use the tmpfile to pass "filp, fd, cmd, arg" to "whatis"?

>

> But the reality is that I don't know how to let crash extract the four parameter name,

> then how could I pass this info to the tmpfile?

>

> Also the interest of me is get the output as:

> *do_vfs_ioctl(filp, *fd, *cmd, *arg);

> The parameter's type may not need to be displayed as the whatis case.

>

> Thanks,

> Lei





Ah OK, I misunderstood your first question.



As far as getting the parameter names themselves, there is no helper

function that does that. *There are two ways of accessing gdb

functionality -- either:



(1) a gdb command string can be issued unmodified via the

* * gdb_pass_through() function, or

(2) a specific pre-existing gdb helper function may be accessed

* * via gdb_interface(), which ends up in the gdb_command_funnel()

* * function in gdb-7.3-1/gdb/symtab.c.



with respect to (1), ideally there would be some other gdb command

string that you could pass unmodified to gdb to get what you want,

but I don't know of any.



With respect to (2), the gdb_command_funnel() function has a switch

statement for a list of several pre-existing "req->command" definitions,

but none of them pull out the actual names of text function arguments.

I would guess that the argument name strings could be pulled out with

a new gdb helper function, but you'd have to write it yourself.



I find print_frame_args in gdb/stack.c seems to be the function to print outthe argument's name. Its working mechanism is exacting out all symbols
in the specified function with*ALL_BLOCK_SYMBOLS. Then discardthose symbol not as argument by*SYMBOL_IS_ARGUMENT.At last it would get the argument name by*SYMBOL_PRINT_NAME.

So how could I reach this print_frame_args by crash, need modify gdb sideto 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. :)
Thanks,Lei
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility


All times are GMT. The time now is 07:34 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.