From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 2 15:42:19 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6273E106566C for ; Mon, 2 Nov 2009 15:42:19 +0000 (UTC) (envelope-from shuvaev@physik.uni-wuerzburg.de) Received: from mailrelay.rz.uni-wuerzburg.de (mailrelay.rz.uni-wuerzburg.de [132.187.3.28]) by mx1.freebsd.org (Postfix) with ESMTP id 170A38FC1C for ; Mon, 2 Nov 2009 15:42:18 +0000 (UTC) Received: from virusscan.mail (localhost [127.0.0.1]) by mailrelay.mail (Postfix) with ESMTP id 4B3385B028; Mon, 2 Nov 2009 16:42:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by virusscan.mail (Postfix) with ESMTP id 47CE45AFFD; Mon, 2 Nov 2009 16:42:14 +0100 (CET) X-Virus-Scanned: by amavisd-new at uni-wuerzburg.de Received: from mail.physik.uni-wuerzburg.de (wthp192.physik.uni-wuerzburg.de [132.187.40.192]) by mailmaster.uni-wuerzburg.de (Postfix) with ESMTP id 1FD0F5CCA1; Mon, 2 Nov 2009 16:42:14 +0100 (CET) Received: from wep4035 ([132.187.37.35]) by mail.physik.uni-wuerzburg.de (Lotus Domino Release 8.0.2FP1HF244) with ESMTP id 2009110216421269-245767 ; Mon, 2 Nov 2009 16:42:12 +0100 Received: by wep4035 (sSMTP sendmail emulation); Mon, 2 Nov 2009 16:42:12 +0100 Date: Mon, 2 Nov 2009 16:42:12 +0100 From: Alexey Shuvaev To: Max Boyarov Message-ID: <20091102154212.GA30365@wep4035.physik.uni-wuerzburg.de> Mail-Followup-To: Max Boyarov , freebsd-hackers@freebsd.org References: <87c7bb540911020552x4a602732pd2caecb17c8c4535@mail.gmail.com> Mime-Version: 1.0 In-Reply-To: <87c7bb540911020552x4a602732pd2caecb17c8c4535@mail.gmail.com> User-Agent: Mutt/1.4.2.3i Organization: Universitaet Wuerzburg X-MIMETrack: Itemize by SMTP Server on domino1/uni-wuerzburg(Release 8.0.2FP1HF244 | April 7, 2009) at 11/02/2009 04:42:12 PM, Serialize by Router on domino1/uni-wuerzburg(Release 8.0.2FP1HF244 | April 7, 2009) at 11/02/2009 04:42:13 PM, Serialize complete at 11/02/2009 04:42:13 PM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Cc: freebsd-hackers@freebsd.org Subject: Re: strange gdb behavior X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Nov 2009 15:42:19 -0000 On Mon, Nov 02, 2009 at 03:52:33PM +0200, Max Boyarov wrote: > Hi, > > Who could help understand this: > > `--> cat 1.c > int > main(int argc, char **argv) > { > return 0; > } > > [snip] > > (gdb) set args test > (gdb) b main > Breakpoint 1 at 0x80483d0: file 1.c, line 3. > (gdb) r > Starting program: /tmp/1 test > > Breakpoint 1, main () at 1.c:3 > 3 { > (gdb) print argc > Error accessing memory address 0x0: Bad address. > (gdb) list > 1 int > 2 main(int argc, char **argv) > 3 { > 4 return 0; > 5 } > > checked on 9.0-CURRENT, 8.0-BETA3 > On FreeBSD wep4035 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r198671: Fri Oct 30 16:12:10 CET 2009 root@wep4035:/usr/obj/usr/src/sys/GENERIC amd64 I have the following: (gdb) set args test (gdb) b main Breakpoint 1 at 0x40052b: file 1.c, line 4. (gdb) r Starting program: /home/lexx/1 test Breakpoint 1, main (argc=2, argv=0x7fffffffe790) at 1.c:4 4 return 0; (gdb) list 1 int 2 main(int argc, char **argv) 3 { 4 return 0; 5 } (gdb) print argc $1 = 2 (gdb) Note that the breakpoint is set to line 4, not line 3 as in your case. There was a series of changes to the linker recently. Update to the latest CURRENT might help. HTH, Alexey.