gdb break - Unix

This is a discussion on gdb break - Unix ; hi how to make gdb to break ,with the change in some memory location.i tried watchpoint but it's not working. is there anyother way thanks sinbad...

+ Reply to Thread
Results 1 to 4 of 4

Thread: gdb break

  1. gdb break

    hi
    how to make gdb to break ,with the change in some memory location.i
    tried watchpoint but it's not working.
    is there anyother way

    thanks
    sinbad

  2. Re: gdb break

    On Fri, 14 Mar 2008 23:16:23 -0700,sinbad wrote:

    > hi
    > how to make gdb to break ,with the change in some memory location.i
    > tried watchpoint but it's not working. is there anyother way
    >


    I think gnu.gcc.help is a more appropriate place to discuss this
    problem.

    I think 'watch' should work, what's wrong with it?

    --
    Hi, I'm a .signature virus, please copy/paste me to help me spread
    all over the world.

  3. Re: gdb break

    sinbad writes:

    > how to make gdb to break ,with the change in some memory location.


    You'll do well to read this:
    http://catb.org/esr/faqs/smart-questions.html
    and ask a smarter question next time.

    > i tried watchpoint but it's not working.


    Since you didn't tell us what exactly you did, we can't tell you
    what you did wrong. Gdb watchpoints work just fine. They are even
    fast on some platforms.

    > is there anyother way


    No.

    Here are precise instructions:
    Suppose you have a global variable "count" and you want gdb to stop
    every time it is updated.

    $ cat t.c
    #include
    int count;

    int incr()
    {
    return count++;
    }

    int main()
    {
    int i;
    while ((i = incr()) < 5)
    printf("%d\n", i);
    return 0;
    }
    $ gcc -g t.c && gdb -q ./a.out
    Using host libthread_db library "/lib/tls/libthread_db.so.1".
    (gdb) p &count
    $1 = (int *) 0x804959c
    (gdb) watch *$1
    Hardware watchpoint 1: *$1
    (gdb) r
    Hardware watchpoint 1: *$1
    Hardware watchpoint 1: *$1
    Hardware watchpoint 1: *$1

    Old value = 0
    New value = 1
    incr () at t.c:7
    7 }
    (gdb) bt
    #0 incr () at t.c:7
    #1 0x08048395 in main () at t.c:12
    (gdb) c
    0
    Hardware watchpoint 1: *$1

    Old value = 1
    New value = 2
    incr () at t.c:7
    7 }
    .... etc ...

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  4. Re: gdb break

    On Mar 15, 9:40 pm, Paul Pluzhnikov wrote:
    > sinbad writes:
    > > how to make gdb to break ,with the change in some memory location.

    >
    > You'll do well to read this:
    > http://catb.org/esr/faqs/smart-questions.html
    > and ask a smarter question next time.
    >
    > > i triedwatchpointbut it's not working.

    >
    > Since you didn't tell us what exactly you did, we can't tell you
    > what you did wrong. Gdb watchpoints work just fine. They are even
    > fast on some platforms.
    >
    > > is there anyother way

    >
    > No.
    >
    > Here are precise instructions:
    > Suppose you have a global variable "count" and you want gdb to stop
    > every time it is updated.
    >
    > $ cat t.c
    > #include
    > int count;
    >
    > int incr()
    > {
    > return count++;
    >
    > }
    >
    > int main()
    > {
    > int i;
    > while ((i = incr()) < 5)
    > printf("%d\n", i);
    > return 0;}
    >
    > $ gcc -g t.c && gdb -q ./a.out
    > Using host libthread_db library "/lib/tls/libthread_db.so.1".
    > (gdb) p &count
    > $1 = (int *) 0x804959c
    > (gdb) watch *$1
    > Hardwarewatchpoint1: *$1
    > (gdb) r
    > Hardwarewatchpoint1: *$1
    > Hardwarewatchpoint1: *$1
    > Hardwarewatchpoint1: *$1
    >
    > Old value = 0
    > New value = 1
    > incr () at t.c:7
    > 7 }
    > (gdb) bt
    > #0 incr () at t.c:7
    > #1 0x08048395 in main () at t.c:12
    > (gdb) c
    > 0
    > Hardwarewatchpoint1: *$1
    >
    > Old value = 1
    > New value = 2
    > incr () at t.c:7
    > 7 }
    > ... etc ...
    >
    > Cheers,
    > --
    > In order to understand recursion you must first understand recursion.
    > Remove /-nsp/ for email.


    hi ,
    I am getting the following error, while i tried to set watchpoint like
    above.

    "Can't clear hardware watchpoints without the 'Z2' (write-watchpoint)
    packet."

    btw i am doing remote debugging.

    thanks
    sinbad

+ Reply to Thread