Opened 14 years ago

Closed 9 years ago

#26450 closed defect (fixed)

gdb does not work for debugging gcc45 C++ programs

Reported by: bumens@… Owned by: stuartwesterman (Stuart Westerman)
Priority: Normal Milestone:
Component: ports Version: 1.9.1
Keywords: Cc: tvb377@…, michaelld (Michael Dickens), manphiz@…, macports@…, geekosaur, ClintO (Clint O), alexeiz@…, cooljeanius (Eric Gallager)
Port: gdb

Description

Neither fsf-gdb nor fsf-gdbtui work for debugging C++ programs. They're finding errors where no errors are, it's even not possible to try out because it's not possible to debug until the main() entry (with gdb command "start").

In contrast, MacPorts' cgdb works, as well as Apple's gdb (both don't work very well because of the too old release of GNU's gdb they're made of).

Attachments (1)

Portfile-gdb.diff (802 bytes) - added by tvb377@… 14 years ago.
patch to get gdb to 7.2, but does not help for this problem.

Download all attachments as: .zip

Change History (21)

comment:1 Changed 14 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to dweber@…

comment:2 Changed 14 years ago by tvb377@…

Cc: tvb377@… added

Cc Me!

comment:3 Changed 14 years ago by tvb377@…

Some tests with gcc45+gdb72: With a helloworld-like test

#include <iostream>
#include <string>

int	main(int argc, char ** argv)
{
	std::cout << "Wie gehts denn so?" << std::endl;
	std::string	bla = "Ganz gut!";
	std::cout << bla << std::endl;
	return 0;
}

I notice:

b main
r
-->Program received signal SIGSEGV, Segmentation fault.
0x0000000100045d73 in std::basic_ostream<char, std::char_traits<char> >::sentry::sentry(std::basic_ostream<char, std::char_traits<char> >&)
    () from /opt/local/lib/gcc45/libstdc++.6.dylib

There can be more failures produced like

b 7
r

Breakpoint 1, main (argc=1, argv=0x1000002d8) at tst.cpp:7
7		std::string	bla = "Ganz gut!";
(gdb) n
0x00007fff5fc0d500 in ?? ()
(gdb) n
Cannot find bounds of current function

or with a different program I also get

Breakpoint 3, main (argc=Could not find the frame base for "main(int, char**)".

Changed 14 years ago by tvb377@…

Attachment: Portfile-gdb.diff added

patch to get gdb to 7.2, but does not help for this problem.

comment:4 Changed 14 years ago by michaelld (Michael Dickens)

Cc: michaelld@… added

Cc Me!

comment:5 Changed 14 years ago by manphiz@…

Any news on this bug? Has it been reported to upstream?

comment:6 Changed 14 years ago by manphiz@…

Cc: manphiz@… added

Cc Me!

comment:7 Changed 13 years ago by jmroot (Joshua Root)

Any improvement with 7.3?

comment:8 Changed 13 years ago by tvb377@…

I think that this ticket really describes 2 things.

First is that you cannot really use mp-g++-4.5. See http://lists.macosforge.org/pipermail/macports-dev/2011-June/014877.html

That accounts at least for one of the errors I experienced during my first tests.

Second is that mainline GNU gdb apparently does not work for OSX as a target.

Using gdb 7.3 to trace through a hello world in C++ gives for me:

(gdb) b main

Breakpoint 1 at 0x1000009c9: file ostringstream.cpp, line 6.

(gdb) r

Starting program: a.out

BFD: unable to read unknown load command 0x24

BFD: unable to read unknown load command 0x26

Error in re-setting breakpoint 1: Cannot access memory at address 0x1000009bd

I get similar results when trying a C program, also of "hello world" complexity.

As far as I can see gdb is dead for OSX as a target. Since lldb works quite well for OSX targets that's not too bad.

Maybe the port should be marked as "broken".

comment:9 in reply to:  7 Changed 13 years ago by manphiz@…

Replying to jmr@…:

Any improvement with 7.3?

Following instruction on http://sourceware.org/gdb/wiki/BuildingOnDarwin I am able to debug program built using a hand built gcc 4.6 and trunk (4.7), even though there are lots of warning about missing debugging symbol. Not sure about gcc 4.5 from macports.

comment:10 Changed 12 years ago by macports@…

Cc: macports@… added

Cc Me!

comment:11 Changed 12 years ago by geekosaur

Cc: allbery.b@… added

Cc Me!

comment:12 Changed 12 years ago by nkatzakis@…

macports gdb 7.3 does not work for debugging macports gcc-mp-4.6.2 programs either.

comment:13 Changed 12 years ago by ClintO (Clint O)

Cc: clint.olsen@… added

Cc Me!

comment:14 Changed 12 years ago by alexeiz@…

Cc: alexeiz@… added

Cc Me!

comment:15 Changed 10 years ago by cooljeanius (Eric Gallager)

gdb is now 7.6, does it work now?

comment:16 Changed 10 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:17 Changed 10 years ago by mf2k (Frank Schima)

Owner: changed from dweber@… to macports-tickets@…

dweber has retired. See #43834.

comment:18 Changed 10 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to stuartwesterman@…

comment:19 Changed 9 years ago by stuartwesterman (Stuart Westerman)

This problem is overcome by new gdb (7.7.1). Please close this ticket.

comment:20 Changed 9 years ago by larryv (Lawrence Velázquez)

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.