From owner-freebsd-chat Sat Jul 7 20:19:26 2001 Delivered-To: freebsd-chat@freebsd.org Received: from wantadilla.lemis.com (wantadilla.lemis.com [192.109.197.80]) by hub.freebsd.org (Postfix) with ESMTP id BC45137B408 for ; Sat, 7 Jul 2001 20:19:21 -0700 (PDT) (envelope-from grog@lemis.com) Received: by wantadilla.lemis.com (Postfix, from userid 1004) id 0E6366ACBC; Sun, 8 Jul 2001 12:49:20 +0930 (CST) Date: Sun, 8 Jul 2001 12:49:19 +0930 From: Greg Lehey To: Steve Price Cc: chat@freebsd.org Subject: Re: gdb debugging tips Message-ID: <20010708124919.G80862@wantadilla.lemis.com> References: <20010706175625.J65832@bsd.havk.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010706175625.J65832@bsd.havk.org>; from steve@havk.org on Fri, Jul 06, 2001 at 05:56:25PM -0500 Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Friday, 6 July 2001 at 17:56:25 -0500, Steve Price wrote: > I've been having problems with a software package for which I > only have a binary with no debugging symbols. In talking to > the folks that wrote the software I know what arguments the > routine takes I just need to be able to see them in the debugger. Hmm. I suppose chat@ is a catchall, but I would have thought you could find a better mailing list for this question. I can't think of one at the moment, though, so I'll reply here. > Here's what I've done: > > Fire up the program. Attach to the pid of the running process > with 'gdb lsv 10336'. Hmm. I don't know this syntax. Is that really what you typed to the shell? > I've set the breakpoint at the routine that I'm interested in 'break > LH2P' and I've coerced the program to run to the breakpoint. > > Here's where I'm lost. I'm back in gdb and it is waiting for me to > tell it what to do. I know the function LH2P takes one argument a > 'char *'. How do I view a function's arguments? With debugging > symbols this is as easy as 'where'. I figured 'info args' would be > the ticket but all it says is 'No symbol table info avialable'. Now > I'm betting the information from 'info frame' is the key but how to > decipher it. I have some macros which handle this. You'll find them in /usr/src/sys/modules/vinum/.gdbinit.kernel. I must move them somewhere else, since this file isn't Vinum-specific. The commands you need are: f0 -- Select stack frame 0 and show assembler-level details f1 -- Select stack frame 1 and show assembler-level details f2 -- Select stack frame 2 and show assembler-level details f3 -- Select stack frame 3 and show assembler-level details f4 -- Select stack frame 4 and show assembler-level details f5 -- Select stack frame 5 and show assembler-level details xb -- Show 12 words starting at current BP value in hex xi -- List the next 10 instructions from the current IP value xp -- Show the register contents and the first four parameter xp0 -- Show the first parameter of current stack frame in various formats xp1 -- Show the second parameter of current stack frame in various formats xp2 -- Show the third parameter of current stack frame in various formats xp3 -- Show the fourth parameter of current stack frame in various formats xp4 -- Show the fifth parameter of current stack frame in various formats xs -- Show the last 12 words on stack in hex xxp -- Show the register contents and the first ten parameter y -- User-defined z -- Single step 1 instruction (over calls) and show next instruction zs -- Single step 1 instruction (through calls) and show next instruction You can get a complete list with 'help user'. Let me know if you have any questions. Greg -- See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message