From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6030 invoked by alias); 2 May 2011 15:34:55 -0000 Received: (qmail 5923 invoked by uid 22791); 2 May 2011 15:34:54 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,TW_OV,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pw0-f41.google.com (HELO mail-pw0-f41.google.com) (209.85.160.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 May 2011 15:34:38 +0000 Received: by pwi10 with SMTP id 10so3812969pwi.0 for ; Mon, 02 May 2011 08:34:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.191.5 with SMTP id o5mr3285730wff.28.1304350477991; Mon, 02 May 2011 08:34:37 -0700 (PDT) Received: by 10.142.87.7 with HTTP; Mon, 2 May 2011 08:34:37 -0700 (PDT) Date: Mon, 02 May 2011 15:34:00 -0000 Message-ID: Subject: better assembly level debugging From: Francois To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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/msg00006.txt.bz2 Hello I'm trying to do some machine code-level debugging using GDB. Basically, I'm debugging a C application that provides no debugging symbol. GDB works greatly, and I think a few customization could make it as nice as the other popular debugging alternatives for this task (like OllyDbg for Win32). - 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. - 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" moreover, if compiled with g++ -o wide wide.cpp -fPIC, the first lines above change to => 0x400680 : sub $0x10,%rsp 0x400684 : mov 0x1003fd(%rip),%rax # 0x500a88 0x40068b : mov %rax,-0x10(%rbp) 0x40068f : lea 0x106(%rip),%rax # 0x40079c once again, we need to run x/a 0x500a88 x/ws 0x40079c to get an understandable disassembly. Do you think these features could be integrated in GDB? If yes I could send some code for review. Francois