public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Print addresses of all local variables
@ 2015-06-17  8:55 Suryansh Kumar
  2015-06-17  9:14 ` Andreas Schwab
  2015-06-23 15:14 ` Doug Evans
  0 siblings, 2 replies; 4+ messages in thread
From: Suryansh Kumar @ 2015-06-17  8:55 UTC (permalink / raw)
  To: gdb; +Cc: Vini Kanvar

Print addresses
----------------
I want to print the addresses of all the local and global variables
which are being used in the current frame and store them in a file.
"info local" prints the values of all local variables. I need something
to print the addresses in a similar way. Is there any built in
command for it?

GDB macro coding language tutorial
-----------------------------------
I tried writing a gdb script for the same using the gdb macro coding
language, but I am not able to find sufficient material for it. Any
handbook or tutorial on the gdb scripting language which covers its
usage and syntax in detail is urgently needed. I need to know if we can
declare arrays and strings, and perform comparisons on them.

"step" into non-library functions
----------------------------------
I need to store the data at the end of every function when it is
executed using a gdb script. I am not able to use the 'step' command
in the script as it also steps into the library functions, which I
don't need. Need a way to run step conditionally on user functions
only.

-- 
Regards,
Suryansh D Kumar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Print addresses of all local variables
  2015-06-17  8:55 Print addresses of all local variables Suryansh Kumar
@ 2015-06-17  9:14 ` Andreas Schwab
       [not found]   ` <CADA370tyjyMojvqJvtNkWexQKmwWzqGgA+vaDBGCS1fy2vXBfw@mail.gmail.com>
  2015-06-23 15:14 ` Doug Evans
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2015-06-17  9:14 UTC (permalink / raw)
  To: Suryansh Kumar; +Cc: gdb, Vini Kanvar

Suryansh Kumar <suryansh.1234@gmail.com> writes:

> "step" into non-library functions
> ----------------------------------
> I need to store the data at the end of every function when it is
> executed using a gdb script. I am not able to use the 'step' command
> in the script as it also steps into the library functions, which I
> don't need. Need a way to run step conditionally on user functions
> only.

How do you define "user function"?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Fwd: Print addresses of all local variables
       [not found]   ` <CADA370tyjyMojvqJvtNkWexQKmwWzqGgA+vaDBGCS1fy2vXBfw@mail.gmail.com>
@ 2015-06-23 10:52     ` Suryansh Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Suryansh Kumar @ 2015-06-23 10:52 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gdb, Vini Kanvar

---------- Forwarded message ----------
From: Suryansh Kumar <suryansh.1234@gmail.com>
Date: Wed, Jun 17, 2015 at 2:46 PM
Subject: Re: Print addresses of all local variables
To: Andreas Schwab <schwab@suse.de>


By user functions I mean those written by the programmer, the non
library functions.

On Wed, Jun 17, 2015 at 2:44 PM, Andreas Schwab <schwab@suse.de> wrote:
> Suryansh Kumar <suryansh.1234@gmail.com> writes:
>
>> "step" into non-library functions
>> ----------------------------------
>> I need to store the data at the end of every function when it is
>> executed using a gdb script. I am not able to use the 'step' command
>> in the script as it also steps into the library functions, which I
>> don't need. Need a way to run step conditionally on user functions
>> only.
>
> How do you define "user function"?
>
> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."



--
Regards,
Suryansh D Kumar



-- 
Regards,
Suryansh D Kumar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Print addresses of all local variables
  2015-06-17  8:55 Print addresses of all local variables Suryansh Kumar
  2015-06-17  9:14 ` Andreas Schwab
@ 2015-06-23 15:14 ` Doug Evans
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Evans @ 2015-06-23 15:14 UTC (permalink / raw)
  To: Suryansh Kumar; +Cc: gdb, Vini Kanvar

On Wed, Jun 17, 2015 at 3:55 AM, Suryansh Kumar <suryansh.1234@gmail.com> wrote:
> Print addresses
> ----------------
> I want to print the addresses of all the local and global variables
> which are being used in the current frame and store them in a file.
> "info local" prints the values of all local variables. I need something
> to print the addresses in a similar way. Is there any built in
> command for it?

No, but one might be able to do something in python.

https://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html

> GDB macro coding language tutorial
> -----------------------------------
> I tried writing a gdb script for the same using the gdb macro coding
> language, but I am not able to find sufficient material for it. Any
> handbook or tutorial on the gdb scripting language which covers its
> usage and syntax in detail is urgently needed. I need to know if we can
> declare arrays and strings, and perform comparisons on them.

gdb's own scripting language is really limited.
Use Python.

There's also Guile support, but the Python support is more complete.
https://sourceware.org/gdb/current/onlinedocs/gdb/Guile.html

> "step" into non-library functions
> ----------------------------------
> I need to store the data at the end of every function when it is
> executed using a gdb script. I am not able to use the 'step' command
> in the script as it also steps into the library functions, which I
> don't need. Need a way to run step conditionally on user functions
> only.

There's no real way to distinguish user from non-user functions.
There are ways to achieve what you want though.

1) The "skip" set of commands.
https://sourceware.org/gdb/current/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html

2) gdb won't step into functions that are missing debug info.
You *could*, though I'm not recommending this as a great approach,
remove the debug info for functions you don't want gdb to step into.
E.g., if you have debug info installed for glibc, temporarily remove it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-23 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17  8:55 Print addresses of all local variables Suryansh Kumar
2015-06-17  9:14 ` Andreas Schwab
     [not found]   ` <CADA370tyjyMojvqJvtNkWexQKmwWzqGgA+vaDBGCS1fy2vXBfw@mail.gmail.com>
2015-06-23 10:52     ` Fwd: " Suryansh Kumar
2015-06-23 15:14 ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).