From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3367 invoked by alias); 18 Jun 2010 16:36:30 -0000 Received: (qmail 3351 invoked by uid 22791); 18 Jun 2010 16:36:29 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Jun 2010 16:36:24 +0000 Received: from mailhost3.vmware.com (mailhost3.vmware.com [10.16.27.45]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id BA97F23007; Fri, 18 Jun 2010 09:36:21 -0700 (PDT) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost3.vmware.com (Postfix) with ESMTP id AF59ACD903; Fri, 18 Jun 2010 09:36:21 -0700 (PDT) Message-ID: <4C1BA085.2010607@vmware.com> Date: Fri, 18 Jun 2010 16:36:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.22 (X11/20090609) MIME-Version: 1.0 To: Jerry 85032 CC: "gdb@sourceware.org" Subject: Re: Newbie gdb / gdbserver question with x86-64 and -m32 g++ goodness References: <28922383.post@talk.nabble.com> In-Reply-To: <28922383.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00072.txt.bz2 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. > > #include <iostream> > int main(int argc, char *argv[]) > { > std::cout << "Hello World." << std::endl; > return -1; > > } > > > 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... > > g++ -g -m32 hello.cpp -o hello > > So I gather much of my problem is because I'm ignorant. And I don't really > understand what -m32 does, although I know our hideously complex system IS > compiled that way. > > Apart from that, I am using: > > $ g++ --version > g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46) > > $ gdbserver --version > GNU gdbserver Fedora (6.8-37.el5) > This gdbserver was configured as "x86_64-redhat-linux-gnu" > > $ cat /etc/redhat-release > CentOS release 5.4 (Final) > > Can someone help clue me in? > > Thank you