Results 1 to 3 of 3

Thread: gdb option to see from a memory address onwards?

  1. #1
    Join Date
    Aug 2012
    Beans
    623

    gdb option to see from a memory address onwards?

    Hello,
    I was wondering if there is an option in gdb to see from a particular memory address onwards. I normally print out the values using
    Code:
    (gdb) p *A1
    (gdb) p *(A1+1)
    (gdb) p *(A1+2)
    (gdb) p *(A1+3)
    Is there something where I can see the contents of the next n memory locations starting from A1?

    Use Case :
    I define my arrays using pointers.
    So I would have something like
    Code:
    int* A1;
    A1= malloc(10 * sizeof(int));
    
    for(i=0;i<10;i++)
     *(A1 + i) = i+1;
    Now I want to see the array contents using gdb.

    Please advise.
    Thanks.

  2. #2
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: gdb option to see from a memory address onwards?

    Code:
    (gdb) p *A1@10
    $2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    See http://ftp.gnu.org/old-gnu/Manuals/g...b_9.html#SEC54

  3. #3
    Join Date
    Aug 2012
    Beans
    623

    Re: gdb option to see from a memory address onwards?

    Quote Originally Posted by spjackson View Post
    Code:
    (gdb) p *A1@10
    $2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    See http://ftp.gnu.org/old-gnu/Manuals/g...b_9.html#SEC54
    spjackson, haha, this is insane

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •