From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37345 invoked by alias); 20 Jul 2015 05:38:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 37334 invoked by uid 89); 20 Jul 2015 05:38:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f195.google.com Received: from mail-yk0-f195.google.com (HELO mail-yk0-f195.google.com) (209.85.160.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 20 Jul 2015 05:38:55 +0000 Received: by ykfw194 with SMTP id w194so8421518ykf.2 for ; Sun, 19 Jul 2015 22:38:53 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.170.88.212 with SMTP id f203mr26819820yka.34.1437370733635; Sun, 19 Jul 2015 22:38:53 -0700 (PDT) Received: by 10.13.233.198 with HTTP; Sun, 19 Jul 2015 22:38:53 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Jul 2015 05:38:00 -0000 Message-ID: Subject: Re: [PATCH] Rewrite mixed source/assembler disassembly From: Doug Evans To: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00547.txt.bz2 On Sun, Jul 19, 2015 at 10:19 PM, Doug Evans wrote: > Hi. > > This is a patch I've wanted to write for a very long time. > The current mixed source/assembler disassembly is not very usable. > In the presence of multiple source files (inlined functions, etc.) > it doesn't print usable output. > In the presence of optimized code, trying to be source centric > just doesn't work IMO. And with no optimization the before/after > should be identical. > > One change I've made here is that I'm printing the source file > in the output. This is critical when displaying inlined functions > from another source file. If there's only one source file it's > more a matter of taste. To keep things simple, this patch displays > the source file name even if there's only one file. > > The other change I've made is to remove the blank line between > assembly and the next source line. I'm ambivalent, what do you think? > > E.g., > > (gdb) disas /m main > Dump of assembler code for function main: > hello.c: <<<--- this is new > 5 { > 0x08048330 <+0>: push %ebp > 0x08048331 <+1>: mov %esp,%ebp > 0x08048333 <+3>: sub $0x8,%esp > 0x08048336 <+6>: and $0xfffffff0,%esp > 0x08048339 <+9>: sub $0x10,%esp > 6 printf ("Hello.\n"); > => 0x0804833c <+12>: movl $0x8048440,(%esp) > 0x08048343 <+19>: call 0x8048284 > 7 return 0; > 0x08048348 <+24>: mov $0x0,%eax > 8 } > 0x0804834d <+29>: leave > 0x0804834e <+30>: ret > > I still need to test this with an MI frontend. > > 2015-07-19 Doug Evans > > * NEWS: Document change is mixed source/assembly output. > * disasm.c: #include "source.h". > (dis_line_entry) : New member. > (dis_line_entry) : Delete members. > (hash_dis_line_entry, eq_dis_line_entry): New functions. > (allocate_dis_line_table): New functions. > (maybe_add_dis_line_entry, line_has_code_p): New functions. > (compare_lines): Delete. > (dump_insns): New arg end_pc. All callers updated. > (do_mixed_source_and_assembly): Rewrite. Delete arg nlines, le. > Rename arg symtab to main_symtab. All callers updated. > > doc/ > * gdb.texinfo (Machine Code): Update docs for mixed source/assembly > disassembly. > > testsuite/ > * gdb.mi/basics.c (main): Add comment. > * gdb.mi/mi-cli.exp: Update. > * gdb.mi/mi-disassemble.exp: Update. Hmmm, looks like I need to do a bit of testing with TUI too. TUI doesn't have a mixed source+assembly in one window AFAICT. That would be cool, but that's a separate project. For now I'm just going to make sure things work at least as well as before (I'm seeing some problems I need to investigate).