From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18135 invoked by alias); 2 May 2011 16:13:11 -0000 Received: (qmail 18124 invoked by uid 22791); 2 May 2011 16:13:10 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_OV,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 May 2011 16:12:56 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p42GCsoA016563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 May 2011 12:12:55 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p42GCrn6020024; Mon, 2 May 2011 12:12:54 -0400 From: Phil Muldoon To: Francois Cc: gdb@sourceware.org Subject: Re: better assembly level debugging References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Mon, 02 May 2011 16:13:00 -0000 In-Reply-To: (Francois's message of "Mon, 2 May 2011 17:34:37 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2011-05/txt/msg00009.txt.bz2 Francois writes: > - defining labels > reverse engineering is very difficult without debugging symbols. It > would be very handy if I could (like on IDA or OllyDbg) define my own > labels. That would be for example user-defined symbols, which could be > used to get a nicer output. > For example > set label 0x402000 log_error > would define a new symbol "log_error". Further disassembly of "call > 0x402000" instruction, or stepping near this address would give a > cleaner output. I like the utility of this. I think you could probably write a large amount of this in Python. If a label is just a location, that could easily be stored in a Python list. You would have to teach the GDB linespec code about parsing these utility labels though; that is an internal GDB task. OTOH, I think there is a way to assign locations to GDB vars from the command-line right now. I'm not sure. > - pretty printer for instructions > GDB could pretty print what it disassembles so that values of operands > are introspected (looking for strings or functions especially) > > Let's take an example : > > #include > #include > int main() { > int (*printIt) (const wchar_t*, ...) = wprintf; > const wchar_t* foo = L"foo 42"; > printIt(foo); > } > > > compiled with g++ -o wide wide.cpp, I see: > => 0x0000000000400690 <+4>: sub $0x10,%rsp > 0x0000000000400694 <+8>: movq $0x400578,-0x10(%rbp) > 0x000000000040069c <+16>: movq $0x4007ac,-0x8(%rbp) > ... > > which contains zero indication for reading. > I would expect > 0x400578 to be commented as # and > 0x4007ac to be commented as # L"foo 42" > I think you probably write a Python based pretty-printer for this. I'm not sure if 0x400... in the assembly output is a value or just some text GDB prints. If not, you could probably add some hooks in the disassembler to call the Python pretty-printer code before printing the address? > > Do you think these features could be integrated in GDB? If yes I could > send some code for review. My 2 cents, I think these would be great features, regardless of whether you choose to implement them in pure C or a Python hook/C approach. I am not a maintainer though, wait for thoughts from them first! Cheers, Phil