gdb can not debug “hello world” in mac os x

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

gdb can not debug “hello world” in mac os x

hefeweizen
Hi, I have the following smal C++ program

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    puts("!!!Hello World!!!");
    return EXIT_SUCCESS;
}

I compile in Mac OS X Leopard last release using:

g++ -g hello.cpp -o hello.exe

being g++:

host:bin macbook$ g++ --ver
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5493~1/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5493)

then I try to debug this program using fsf-gdb 7.1:

fsf-gdb hello.exe

put a breakpoint in main:

(gdb) b main
Breakpoint 1 at 0x1f8f: file hello.cpp, line 5.

run the program:

(gdb) r
Starting program: /Users/horacio/work/software/gdb/gdb-7.2-inst/bin/hello.exe

Breakpoint 1, main () at hello.cpp:5
5       puts("!!!Hello World!!!");

and try to step, and this happens:

(gdb) n
0x00003045 in ?? ()

This is the output if I do the same under Ubuntu Linux:

(gdb) n
!!!Hello World!!!
6       return EXIT_SUCCESS;

where gcc=7.1 and gcc 4.3.4

What is the problem ???? I honestly do not understand why this does not work in mac os x.

Maybe the problem is the gdb version used in mac or the gcc version in mac. Which other alternatives exist for gdb in mac?

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: gdb can not debug “hello world” in mac os x

Tristan Gingold-2

On Mar 8, 2011, at 4:54 PM, hefeweizen wrote:

>
> Hi, I have the following smal C++ program

[...]

> What is the problem ???? I honestly do not understand why this does not work
> in mac os x.

This could be investigated.  I never tried to debug C++ applications with fsf gdb.
Also, you could try with a more recent version of gdb (7.2)

>
> Maybe the problem is the gdb version used in mac or the gcc version in mac.
> Which other alternatives exist for gdb in mac?

You can use the gdb provided by Apple.

Tristan.

Reply | Threaded
Open this post in threaded view
|

Re: gdb can not debug “hello world” in mac os x

hefeweizen
the main problem is the following;

gdb provided by apple does not produce this problem. But I want to use Eclipse CDT Helios in Mac. When Eclipse calls Apple gdb (6.3) there is a lot of problems for debugging. With gdb 7.1 or 7.2 I only get this mentioned problem.


Tristan Gingold-2 wrote
On Mar 8, 2011, at 4:54 PM, hefeweizen wrote:

>
> Hi, I have the following smal C++ program

[...]

> What is the problem ???? I honestly do not understand why this does not work
> in mac os x.

This could be investigated.  I never tried to debug C++ applications with fsf gdb.
Also, you could try with a more recent version of gdb (7.2)

>
> Maybe the problem is the gdb version used in mac or the gcc version in mac.
> Which other alternatives exist for gdb in mac?

You can use the gdb provided by Apple.

Tristan.
Reply | Threaded
Open this post in threaded view
|

Re: gdb can not debug “hello world” in mac os x

André Pönitz-3
On Tuesday 08 March 2011 17:12:13 ext hefeweizen wrote:
>
> the main problem is the following;
>
> gdb provided by apple does not produce this problem. But I want to use
> Eclipse CDT Helios in Mac. When Eclipse calls Apple gdb (6.3) there is a lot
> of problems for debugging. With gdb 7.1 or 7.2 I only get this mentioned
> problem.

There is also  http://sourceware.org/bugzilla/show_bug.cgi?id=11488

I would be glad if I could use a Python enabled gdb on Mac for Qt Creator,
too, but right now the only option is indeed Apple's 6.3, and that probably
will never get Python scripting ;-|

Andre'
Reply | Threaded
Open this post in threaded view
|

Re: gdb can not debug “hello world” in mac os x

Peter Watkins-6
In reply to this post by hefeweizen
Hi Horacio,


On 03/08/2011 07:54 AM, [hidden email] wrote:

>
> Hi, I have the following smal C++ program
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int main(void) {
>      puts("!!!Hello World!!!");
>      return EXIT_SUCCESS;
> }
>
> I compile in Mac OS X Leopard last release using:
>
> g++ -g hello.cpp -o hello.exe
>
> being g++:
>
> host:bin macbook$ g++ --ver
> Using built-in specs.
> Target: i686-apple-darwin9
> Configured with: /var/tmp/gcc/gcc-5493~1/src/configure --disable-checking
> -enable-werror --prefix=/usr --mandir=/share/man
> --enable-languages=c,objc,c++,obj-c++
> --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/
> --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib
> --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic
> --host=i686-apple-darwin9 --target=i686-apple-darwin9
> Thread model: posix
> gcc version 4.0.1 (Apple Inc. build 5493)
Did you get your GCC version from the Apple Developer Tools?


> then I try to debug this program using fsf-gdb 7.1:
>
> fsf-gdb hello.exe
What happens when you use Apple's version of GDB that comes with the
Developer Tools?

-Peter
Reply | Threaded
Open this post in threaded view
|

Re: gdb can not debug “hello world” in mac os x

hefeweizen
Apple Leopard's gdb does not produce this error. But I want to use Eclipse CDT, and it can not work with Apple's gdb, that is why I am trying to use a non-Apple gdb version.

Peter Watkins-6 wrote
Hi Horacio,


On 03/08/2011 07:54 AM, horacio.sanchez@kit.edu wrote:
>
> Hi, I have the following smal C++ program
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int main(void) {
>      puts("!!!Hello World!!!");
>      return EXIT_SUCCESS;
> }
>
> I compile in Mac OS X Leopard last release using:
>
> g++ -g hello.cpp -o hello.exe
>
> being g++:
>
> host:bin macbook$ g++ --ver
> Using built-in specs.
> Target: i686-apple-darwin9
> Configured with: /var/tmp/gcc/gcc-5493~1/src/configure --disable-checking
> -enable-werror --prefix=/usr --mandir=/share/man
> --enable-languages=c,objc,c++,obj-c++
> --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/
> --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib
> --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic
> --host=i686-apple-darwin9 --target=i686-apple-darwin9
> Thread model: posix
> gcc version 4.0.1 (Apple Inc. build 5493)
Did you get your GCC version from the Apple Developer Tools?


> then I try to debug this program using fsf-gdb 7.1:
>
> fsf-gdb hello.exe
What happens when you use Apple's version of GDB that comes with the
Developer Tools?

-Peter
Reply | Threaded
Open this post in threaded view
|

Re: gdb can not debug “hello world” in mac os x

Paul Pluzhnikov-4
In reply to this post by hefeweizen
On Tue, Mar 8, 2011 at 7:54 AM, hefeweizen <[hidden email]> wrote:

> (gdb) b main
> Breakpoint 1 at 0x1f8f: file hello.cpp, line 5.
>
> run the program:
>
> (gdb) r
> Starting program:
> /Users/horacio/work/software/gdb/gdb-7.2-inst/bin/hello.exe
>
> Breakpoint 1, main () at hello.cpp:5
> 5       puts("!!!Hello World!!!");
>
> and try to step, and this happens:
>
> (gdb) n
> 0x00003045 in ?? ()

FWIW, I did not reproduce this with current CVS build of GDB:

gdb/gdb ./a.out
GNU gdb (GDB) 7.3.50.20110508-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10.7.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/ppluzhnikov/gdb-cvs/build/a.out...Reading
symbols from /Users/ppluzhnikov/gdb-cvs/build/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) b main
Breakpoint 1 at 0x100000ef8: file t.cc, line 5.
(gdb) r
Starting program: /Users/ppluzhnikov/gdb-cvs/build/a.out

Breakpoint 1, main () at t.cc:5
5   puts("!!!Hello World!!!");
(gdb) n
!!!Hello World!!!
6   return EXIT_SUCCESS;
(gdb) n
7 }
(gdb) n
0x0000000100000eec in start ()
(gdb) c
Continuing.
[Inferior 1 (process 41135) exited normally]
(gdb) q


--
Paul Pluzhnikov