public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Detect uninitialized memory in gdb
@ 2020-03-31  6:06 Andy Fan
  2020-03-31 18:48 ` Christian Biesinger
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Fan @ 2020-03-31  6:06 UTC (permalink / raw)
  To: gdb

Greetings.

Suppose I have the following codes:

struct X { ... };

void g(struct X *x_p);

void f()
{
   struct X x_var;
   g(&x_var);
}

In the function of g,  I want to check the data where x_p point to,
however it is possible that it is not initialized like above code. So
do we have a way to detect that the memory x_p point to is not
initialized or not in gdb?

Best Regards
Andy Fan

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

* Re: Detect uninitialized memory in gdb
  2020-03-31  6:06 Detect uninitialized memory in gdb Andy Fan
@ 2020-03-31 18:48 ` Christian Biesinger
  2020-03-31 23:53   ` Andy Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Biesinger @ 2020-03-31 18:48 UTC (permalink / raw)
  To: Andy Fan; +Cc: gdb

On Tue, Mar 31, 2020 at 1:08 AM Andy Fan via Gdb <gdb@sourceware.org> wrote:
>
> Greetings.
>
> Suppose I have the following codes:
>
> struct X { ... };
>
> void g(struct X *x_p);
>
> void f()
> {
>    struct X x_var;
>    g(&x_var);
> }
>
> In the function of g,  I want to check the data where x_p point to,
> however it is possible that it is not initialized like above code. So
> do we have a way to detect that the memory x_p point to is not
> initialized or not in gdb?

No, it's not really possible with GDB. You want a tool like Valgrind
or Address Sanitizer.

Christian

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

* Re: Detect uninitialized memory in gdb
  2020-03-31 18:48 ` Christian Biesinger
@ 2020-03-31 23:53   ` Andy Fan
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Fan @ 2020-03-31 23:53 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb

On Wed, Apr 1, 2020 at 2:48 AM Christian Biesinger <cbiesinger@google.com>
wrote:

> On Tue, Mar 31, 2020 at 1:08 AM Andy Fan via Gdb <gdb@sourceware.org>
> wrote:
> >
> > Greetings.
> >
> > Suppose I have the following codes:
> >
> > struct X { ... };
> >
> > void g(struct X *x_p);
> >
> > void f()
> > {
> >    struct X x_var;
> >    g(&x_var);
> > }
> >
> > In the function of g,  I want to check the data where x_p point to,
> > however it is possible that it is not initialized like above code. So
> > do we have a way to detect that the memory x_p point to is not
> > initialized or not in gdb?
>
> No, it's not really possible with GDB. You want a tool like Valgrind
> or Address Sanitizer.
>
> Thank you for your reply Christian.   Just because I want to call gdb
script after I know it is initialized,  so Valgrind is not my option now.

Best Regards
Andy Fan

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

end of thread, other threads:[~2020-03-31 23:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31  6:06 Detect uninitialized memory in gdb Andy Fan
2020-03-31 18:48 ` Christian Biesinger
2020-03-31 23:53   ` Andy Fan

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).