This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie gdb / gdbserver question with x86-64 and -m32 g++ goodness



Michael Snyder-6 wrote:
> 
> Jerry 85032 wrote:
>> So I am new to using gdb and gdbserver.  And I'm trying to use it on a
>> pretty
>> complex program.  But that's okay, I can't get it to run on a simple
>> system,
>> so let's talk about that.
>> 
>> I created the usual c++ Hello World.  I have access to two identical
>> Centos
>> 5 development systems connected with tcp.
> ... 
>> If I compile my hello world with:
>> 
>> $ g++ -g hello.cpp -o hello
>> 
>> Then everything works pretty much as expected.  I can run it on either
>> system.  I can use gdb on one system, connect to gdbserver on the other
>> system, and everything seems to work fine.  I set a break at main on my
>> local system, gdbserver the program on the target, use gdb to tell it to
>> run, and Hello World prints out on the gdbserver system.
>> 
>> But if I compile it with -m32, and repeat the process, then the two
>> systems
>> seem to be fighting over architecture issues.  I receive messages like
>> register badly formatted.  Or "warning: Selected architecture i386 is not
>> compatible with reported target architecture i386:x86-64".  This seems to
>> happen regardless of how I tell gdb to set the architecture, either i386
>> or
>> i386:x86-64.
> 
> I believe you need to give the "set architecture" command
> before the "target remote" command.  This should work...
> 
> 

Thanks for the response.  But I tried to follow your suggestions, and still
I'm not seeing it work.  If you have any more suggestions, I am certainly
interested in hearing them.

Thanks,

Jerry

Here are three runs:
==============================

For each run, the remote gdbserver said:

$ gdbserver --multi rdev6:2010 hello
Process hello created; pid = 32603
Listening on port 2010
Remote debugging from host 134.51.26.149
readchar: Got EOF
Remote side has terminated connection.  GDBserver will reopen the
connection.
Listening on port 2010

And on our local:

==============================
Assuming it is i386, 32 bit setting archi to i386, then connecting
note: on the gdb side, the executable hasn't been specified or loaded

$ gdb
GNU gdb Fedora (6.8-37.el5)
his GDB was configured as "x86_64-redhat-linux-gnu".
(gdb) set archi i386
The target architecture is assumed to be i386
(gdb) target extended-remote rdev6:2010
Remote debugging using rdev6:2010
warning: Selected architecture i386 is not compatible with reported target
architecture i386:x86-64
Remote register badly formatted:
T0506:0000000000000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
here: 0000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
Try to load the executable by `file' first,
you may also check `set/show architecture'.
(gdb) 

==============================

Assuming it is i386 32 bit, setting archi to i386, then connecting
note: on the gdb side, the executable has been loaded with file

$ gdb
GNU gdb Fedora (6.8-37.el5)
his GDB was configured as "x86_64-redhat-linux-gnu".
(gdb) set archi i386
The target architecture is assumed to be i386
(gdb) file hello
Reading symbols from /home/j/hello...done.
(gdb) target extended-remote rdev6:2010
Remote debugging using rdev6:2010
warning: Selected architecture i386 is not compatible with reported target
architecture i386:x86-64
Remote register badly formatted:
T0506:0000000000000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
here: 0000000;07:b0dcdfff00000000;10:1018620000000000;thread:7f5b;
Try to load the executable by `file' first,
you may also check `set/show architecture'.
(gdb) sho archi
The target architecture is assumed to be i386
(gdb) 

==============================

Assuming it is i386:x86-64, setting archi to i386, then connecting
note: on the gdb side, the executable has been loaded with file

$ gdb 
GNU gdb Fedora (6.8-37.el5)
This GDB was configured as "x86_64-redhat-linux-gnu".
(gdb) set archi i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) file hello
Reading symbols from /home/j/hello...done.
(gdb) show archi
The target architecture is assumed to be i386:x86-64
(gdb) target extended-remote rdev6:2010
Remote debugging using rdev6:2010
[New Thread 32667]
Cannot access memory at address 0x800000008
(gdb) 



-- 
View this message in context: http://old.nabble.com/Newbie-gdb---gdbserver-question-with-x86-64-and--m32-g%2B%2B-goodness-tp28922383p28929351.html
Sent from the Sourceware - gdb list mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]