Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Can i set a breakpoint when a member of a C struct is being assigned?
@ 2007-07-30  5:37 ying lcs
  2007-07-30  9:32 ` Bernhard Walle
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ying lcs @ 2007-07-30  5:37 UTC (permalink / raw)
  To: gdb

Hi,

Can i set a breakpoint when a member of a C struct is being assigned?

For example, i have a C struct in my code:
struct myStruct{
   int type;
};

How can I break my debugging program when I have code like this:

myStruct*  p;

p->type = 10;

Thank you.


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

* Re: Can i set a breakpoint when a member of a C struct is being  assigned?
  2007-07-30  5:37 Can i set a breakpoint when a member of a C struct is being assigned? ying lcs
@ 2007-07-30  9:32 ` Bernhard Walle
  2007-07-30 21:16 ` Eli Zaretskii
  2007-07-30 21:17 ` Jim Blandy
  2 siblings, 0 replies; 4+ messages in thread
From: Bernhard Walle @ 2007-07-30  9:32 UTC (permalink / raw)
  To: gdb

* ying lcs <yinglcs@gmail.com> [2007-07-30 05:20]:
> Hi,
> 
> Can i set a breakpoint when a member of a C struct is being assigned?
> 
> For example, i have a C struct in my code:
> struct myStruct{
>    int type;
> };
> 
> How can I break my debugging program when I have code like this:
> 
> myStruct*  p;

Set a breakpoint here. And add a watchpoint.

> p->type = 10;

Then GDB stops here.


       Bernhard
-- 
lp1 on fire
        -- One of the more obfuscated kernel messages


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

* Re: Can i set a breakpoint when a member of a C struct is being assigned?
  2007-07-30  5:37 Can i set a breakpoint when a member of a C struct is being assigned? ying lcs
  2007-07-30  9:32 ` Bernhard Walle
@ 2007-07-30 21:16 ` Eli Zaretskii
  2007-07-30 21:17 ` Jim Blandy
  2 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2007-07-30 21:16 UTC (permalink / raw)
  To: ying lcs; +Cc: gdb

> Date: Sun, 29 Jul 2007 22:20:58 -0500
> From: "ying lcs" <yinglcs@gmail.com>
> 
> Can i set a breakpoint when a member of a C struct is being assigned?
> 
> For example, i have a C struct in my code:
> struct myStruct{
>    int type;
> };
> 
> How can I break my debugging program when I have code like this:
> 
> myStruct*  p;
> 
> p->type = 10;

Like this:

 (gdb) watch p->type

(If `p' is a local (as opposed to static) variable, you need to do
this when `p' is in scope.


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

* Re: Can i set a breakpoint when a member of a C struct is being assigned?
  2007-07-30  5:37 Can i set a breakpoint when a member of a C struct is being assigned? ying lcs
  2007-07-30  9:32 ` Bernhard Walle
  2007-07-30 21:16 ` Eli Zaretskii
@ 2007-07-30 21:17 ` Jim Blandy
  2 siblings, 0 replies; 4+ messages in thread
From: Jim Blandy @ 2007-07-30 21:17 UTC (permalink / raw)
  To: ying lcs; +Cc: gdb


"ying lcs" <yinglcs@gmail.com> writes:
> Can i set a breakpoint when a member of a C struct is being assigned?
>
> For example, i have a C struct in my code:
> struct myStruct{
>    int type;
> };

There isn't any way to set a breakpoint on all assignments to a chosen
member of a chosen structure type, regardless of which actual object
of that type is being modified.

You can set a watchpoint on a particular member of a particular
object; see the GDB manual on 'watchpoints'.

You can, of course, set a breakpoint on a particular assignment
statement.


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

end of thread, other threads:[~2007-07-30 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-30  5:37 Can i set a breakpoint when a member of a C struct is being assigned? ying lcs
2007-07-30  9:32 ` Bernhard Walle
2007-07-30 21:16 ` Eli Zaretskii
2007-07-30 21:17 ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox