Setting a Break Point in GDB

This is a discussion on Setting a Break Point in GDB within the Tech Board forums, part of the Community Boards category; Can anybody tell me how to set a breakpoint in gdb on a function that returns a pointer? I know ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    35

    Setting a Break Point in GDB

    Can anybody tell me how to set a breakpoint in gdb on a function that returns a pointer? I know that for foo():

    break foo

    will take care of it, but what if I have

    void *foo()

    I tried:

    break foo
    break *foo
    break *(foo)
    break (*foo)

    None of these worked.

    Thanks.

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Then use the
    break <filename>:<linenumber>
    syntax.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    35
    Can't. I'm programming this, and the line number changes all the time.

  4. #4
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by joatmon View Post
    Can't. I'm programming this, and the line number changes all the time.
    That shouldn't matter unless you have written a script to automate the debugging (or parts of it).
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  5. #5
    Registered User
    Join Date
    Aug 2011
    Posts
    35
    I'm putting this in the gdbinit file. I appreciate your help, but I respectfully ask that you limit your response to answering my question, not spinning me around in circles like so many do on these boards. If you can't answer the question, please leave this post to somebody who can. Thank you.

  6. #6
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by joatmon View Post
    I'm putting this in the gdbinit file. I appreciate your help, but I respectfully ask that you limit your response to answering my question, not spinning me around in circles like so many do on these boards. If you can't answer the question, please leave this post to somebody who can. Thank you.
    Considering the fact that both there and here, you've posted claiming that you've been unable to do what is very much allowed in gdb...without any further clarification.... I wouldn't bother the next time.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  7. #7
    Registered User
    Join Date
    Aug 2011
    Posts
    35
    Is there anybody who can answer this question? I appreciate his help, but he did not really attempt to answer my question. All he did was tell me that it did'n't matter. I am quite sure that gdb can do this, that's why I am asking. The problem is that I don't know how to do accomplish it. Not trying to start a fight - just trying to get a focused answer to my question.

  8. #8
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Can gdb set a breakpoint on a function. Uh... Yes? If you have a function called foo(), then "break foo" should set a breakpoint there. If it does not, there is something about the situation you are leaving out.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-27-2011, 04:34 AM
  2. Is there something like break(2) (multiple break) ?
    By Phuzzillogic in forum C++ Programming
    Replies: 11
    Last Post: 05-11-2009, 04:05 AM
  3. Point to Point Protocol and Bluetooth DUN
    By PSLoh in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-03-2008, 08:44 AM
  4. MSVC 2003 break point problem
    By Bajanine in forum Windows Programming
    Replies: 6
    Last Post: 02-18-2008, 01:39 AM
  5. Floating point faster than fixed-point
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-08-2001, 10:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21