This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
patch: disassembly look
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: patch: disassembly look
- From: David Whedon <davidw at gordian dot com>
- Date: Tue, 15 Feb 2000 21:19:22 -0800 (PST)
A patch to allow source display in the disassemble command. Gives me the
one feature I like most about DDD/insight without all the overhead. I
haven't tested it with any GUIs, and I don't know how well they tolerate
the output changing, maybe this isn't a good idea. . .
-David
output looks something like this:
(gdb) disass _main
Dump of assembler code for function _main:
Source file : _main.c:
0x20a38 <_main>: linkw %fp,#0
0x20a3c <_main+4>: movel %a3,%sp@-
0x20a3e <_main+6>: movel %a2,%sp@-
156 new_FILE (n);
0x20a40 <_main+8>: movel %fp@(8),%sp@-
0x20a44 <_main+12>: jsr 0x2526e <new_FILE>
157 fopen (Console, "r"); /* stdin */
0x20a4a <_main+18>: pea 0x20a34 <_init+112>
0x20a50 <_main+24>: movel 0x6f2dc <Console>,%sp@-
0x20a56 <_main+30>: lea 0x69a18 <fopen>,%a3
0x20a5c <_main+36>: jsr %a3@
Index: gdb/printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.1.1.8
diff -c -3 -p -r1.1.1.8 printcmd.c
*** printcmd.c 2000/02/05 07:29:47 1.1.1.8
--- printcmd.c 2000/02/16 04:59:26
*************** static struct display *display_chain;
*** 119,124 ****
--- 119,129 ----
static int display_number;
+
+ /* print source file lines mixed with assembly lines when
+ told to disassemble if set */
+ static unsigned int mixed_disassembly = 1;
+
/* Prototypes for exported functions. */
void output_command PARAMS ((char *, int));
*************** disassemble_command (arg, from_tty)
*** 2374,2379 ****
--- 2379,2388 ----
char *name;
CORE_ADDR pc, pc_masked;
char *space_index;
+
+ struct symtab *symtab=NULL;
+ struct symtab_and_line sal;
+
#if 0
asection *section;
#endif
*************** disassemble_command (arg, from_tty)
*** 2458,2501 ****
#else
pc_masked = pc;
#endif
!
while (pc_masked < high)
! {
! QUIT;
! print_address (pc_masked, gdb_stdout);
! printf_filtered (":\t");
! /* We often wrap here if there are long symbolic names. */
! wrap_here (" ");
! pc += print_insn (pc, gdb_stdout);
! printf_filtered ("\n");
!
#ifdef GDB_TARGET_MASK_DISAS_PC
! pc_masked = GDB_TARGET_MASK_DISAS_PC (pc);
#else
! pc_masked = pc;
#endif
! }
printf_filtered ("End of assembler dump.\n");
gdb_flush (gdb_stdout);
}
#if defined(TUI)
! else
! {
! tuiDo ((TuiOpaqueFuncPtr) tui_vAddWinToLayout, DISASSEM_WIN);
! tuiDo ((TuiOpaqueFuncPtr) tui_vUpdateSourceWindowsWithAddr, low);
! }
#endif
}
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns length of the instruction, in bytes. */
!
static int
print_insn (memaddr, stream)
! CORE_ADDR memaddr;
! struct ui_file *stream;
{
! if (TARGET_BYTE_ORDER == BIG_ENDIAN)
TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG;
else
TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE;
--- 2467,2529 ----
#else
pc_masked = pc;
#endif
! if(mixed_disassembly){
! symtab = find_pc_symtab(pc);
! if(symtab != NULL){
! sal = find_pc_line(pc, 0);
! printf_filtered ("Source file : %s:\n",
symtab->filename);
! }
! else
! printf_filtered ("No source file found.\n");
! }
!
while (pc_masked < high)
! {
! if((sal.end <= pc) && mixed_disassembly && (symtab != NULL ))
{
! symtab = find_pc_symtab(pc);
! if(symtab != NULL){
! sal = find_pc_line(pc, 0);
! print_source_lines(symtab, sal.line, sal.line+1, 0);
! }
! }
! QUIT;
! print_address (pc_masked, gdb_stdout);
! printf_filtered (":\t");
! /* We often wrap here if there are long symbolic names. */
! wrap_here (" ");
! pc += print_insn (pc, gdb_stdout);
! printf_filtered ("\n");
!
#ifdef GDB_TARGET_MASK_DISAS_PC
! pc_masked = GDB_TARGET_MASK_DISAS_PC (pc);
#else
! pc_masked = pc;
#endif
!
!
!
! }
printf_filtered ("End of assembler dump.\n");
gdb_flush (gdb_stdout);
}
#if defined(TUI)
! else
! {
! tuiDo ((TuiOpaqueFuncPtr) tui_vAddWinToLayout, DISASSEM_WIN);
! tuiDo ((TuiOpaqueFuncPtr) tui_vUpdateSourceWindowsWithAddr,
low);
! }
#endif
}
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns length of the instruction, in bytes. */
!
static int
print_insn (memaddr, stream)
! CORE_ADDR memaddr;
! struct ui_file *stream;
{
! if (TARGET_BYTE_ORDER == BIG_ENDIAN)
TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_BIG;
else
TARGET_PRINT_INSN_INFO->endian = BFD_ENDIAN_LITTLE;
*************** print_insn (memaddr, stream)
*** 2511,2517 ****
void
_initialize_printcmd ()
{
! current_display_number = -1;
add_info ("address", address_info,
"Describe where symbol SYM is stored.");
--- 2539,2545 ----
void
_initialize_printcmd ()
{
! current_display_number = -1;
add_info ("address", address_info,
"Describe where symbol SYM is stored.");
*************** environment, the value is printed in its
*** 2664,2669 ****
--- 2692,2707 ----
"Set the largest offset that will be printed in <symbol+1234>
form.",
&setprintlist),
&showprintlist);
+
+ add_show_from_set (
+ add_set_cmd ("mixed-disassembly", no_class, var_zinteger,
+ (char *) &mixed_disassembly,
+ "Set source/assembler mixed disassemble. \n\
+ When enabled, disassemble command prints source lines (if available)\n\
+ in addition to assembly instructions.",
+ &setlist),
+ &showlist);
+
add_show_from_set (
add_set_cmd ("symbol-filename", no_class,
var_boolean,
(char *) &print_symbol_filename,
*************** environment, the value is printed in its
*** 2682,2684 ****
--- 2720,2739 ----
examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type",
NULL);
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+