This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
MI mixed disassembly address range issue
- From: Frederic RISS <frederic dot riss at st dot com>
- To: gdb at sources dot redhat dot com
- Date: Thu, 01 Sep 2005 13:28:00 +0200
- Subject: MI mixed disassembly address range issue
Hello,
when using the -data-disassemble MI command with the -s and -e options
to specify the address range to disassemble, it's quit easy to break the
following assumption in disasm.c :
/* Assume symtab is valid for whole PC range */
symtab = find_pc_symtab (low);
If the low and high address' aren't recorded in the same symtab, we hit
this code in do_mixed_source_and_assembly :
/* If we're on the last line, and it's part of the function,
then we need to get the end pc in a special way. */
if (i == nlines - 1 && le[i].pc < high)
{
mle[newlines].line = le[i].line;
mle[newlines].start_pc = le[i].pc;
sal = find_pc_line (le[i].pc, 0);
mle[newlines].end_pc = sal.end;
newlines++;
}
I tested this with the Dwarf2 debug format which introduces
'end-of-function' markers (ie lineentries with 0 as line number). When
reaching the end of the table, the above code introduces an entry with 0
line number in the 'lines to be dumped' array.
The result is like that :
-data-disassemble -s 0x804859e -e 0x8048600 -- 1
^done,asm_insns=[src_and_asm_line={line="0",file="main.c",line_asm_insn=[]},
src_and_asm_line={line="1",file="main.c",line_asm_insn=[]},
<src_and_asm_line={line="x",file="main.c",line_asm_insn=[]},> [repeated for 0 <= x <= 109]
src_and_asm_line={line="108",file="main.c",line_asm_insn=[]},
src_and_asm_line={line="109",file="main.c",line_asm_insn=[{address="0x0804859e",
func-name="main",offset="375",inst="movl $0x4,0xfffffff4(%ebp)"},
[ ... stripped correct output ]
As you see the lines 0-<line of start address> are output empty, which
seems like a bug. One obvious fix for this is to patch
do_mixed_source_and_assembly along the lines of :
--- disasm.c.old 2005-08-31 15:16:13.000000000 +0200
+++ disasm.c 2005-08-31 15:32:40.000000000 +0200
@@ -200,7 +200,7 @@
/* If we're on the last line, and it's part of the function,
then we need to get the end pc in a special way. */
- if (i == nlines - 1 && le[i].pc < high)
+ if (i == nlines - 1 && le[i].pc < high && le[i].line != 0)
{
mle[newlines].line = le[i].line;
mle[newlines].start_pc = le[i].pc;
I don't know if all debug formats (or even Dwarf in all cases) will
output an end-marker at the end of the linetable, but if it's the case,
the offending code could be totally removed as we'll always have
le[nlines-1].line == 0.
Kind regards,
Fred.