Thread: @mingw users: gdb makes me clueless

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    519

    @mingw users: gdb makes me clueless

    Hi,

    I'm playing around a few hours with mingw under windows xp (version 5.1.3). I'm trying to debug the app I'm porting to win32 with mingw's gdb. So I can load the app with it and even run it. Also I can set a breakpoint, e.g.
    Code:
    break MainFrame.cpp:MainFrame::MainFrame()
    to break in the ctor of the wxWidget main frame. But if I run it, the app just runs ignoring my breakpoint (always, I tried it with line numbers too). The executables are build and linked with -O0 -g3. I also tried with -ggdb, -gstabs, -gdwarf-2 and so on, but most time gdbs behavior was even worse. I alos tried the insight-gdb-version (6.6). Same thing.
    Linux gdb + same app works just fine.
    What I'm doing wrong?

    Thank you for any hints!

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Can you break at main()? Does that at least work?

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    There's a few issues with GDB breakpoints in constructors. Your solution to break at function call is one of the ways to handle it. But it is useless if your constructor is inlined. Is it? If so, defined it in the implementation file instead.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Mario F. View Post
    There's a few issues with GDB breakpoints in constructors. Your solution to break at function call is one of the ways to handle it. But it is useless if your constructor is inlined. Is it? If so, defined it in the implementation file instead.
    I'd just use the -fno-inline flag. I've never had the problems you mention.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Yup. That flag handles it just fine too. However gdb does have an issue regarding constructors (googling for it will give you some material). Basically it has to do with the fact gdb creates several copies of the constructor... and affects mostly breakpoints placed inside the constructor.

    Regardless, just noticed too... break function_name doesn't take the "()". You may want to remove them, pheres. I'm unsure if this will help though.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Hi again,

    you are right, I did a google search and read about the problem with breaking in a c/dtor.
    I suffered from two problems at once: I tried to brak in the ctor and if I tried to break in another function I used the wrong debugging symbol format (-ggdb). Compiling and linking with -g3 and breaking in main works now.

    About adding the parameter signature to the break command when breaking in a C++ function I read in some gdb-tutorial. The reason given for it was the polymorphic character of C++ (same function name with different signature are possible). So the signature is needed to specify the break point. That sounded logical to me and it worked at least on my setup. I looked through the gdb help messages but there wasn't that mentioned. So I'm not sure about the final truth

    Thanks to both of you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 08:18 AM
  2. gdb drive me crazy!!!!
    By gandalf_bar in forum Linux Programming
    Replies: 5
    Last Post: 04-07-2004, 06:38 AM
  3. Could someone explain this code, string
    By sjalesho in forum C Programming
    Replies: 7
    Last Post: 11-26-2003, 02:54 PM
  4. Windows ntfs perms
    By wp_x in forum Tech Board
    Replies: 3
    Last Post: 03-04-2003, 06:38 AM