Thread: Setting a Break Point in GDB

  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
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Then use the
    break <filename>:<linenumber>
    syntax.

  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
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    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).

  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
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    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.

  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
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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, 09:44 AM
  4. MSVC 2003 break point problem
    By Bajanine in forum Windows Programming
    Replies: 6
    Last Post: 02-18-2008, 02: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, 11:34 PM