2009-10-21 Paul Pluzhnikov <ppluzhnikov@google.com>

* defs.h (pc_prefix): New prototype.
	* disasm.c (dump_insns): Mark current instruction.
	* printcmd.c (do_examine): Likewise.
	(pc_prefix): New function.
	* stack.c (print_frame_info): Disassemble entire current line.

doc/ChangeLog:

2009-10-21  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* gdb.texinfo (Machine Code): Mention current pc marker.
	(Memory): Likewise.

testsuite/ChangeLog:

2009-10-21  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* gdb.base/consecutive.exp: Adjust.
	* gdb.base/display.exp: Likewise.
	* gdb.base/pc-fp.exp: Likewise.
	* gdb.base/sigbpt.exp: Likewise.
This commit is contained in:
Paul Pluzhnikov 2009-10-21 18:02:27 +00:00
parent b54295a786
commit 2b28d20924
12 changed files with 89 additions and 30 deletions

View file

@ -1,3 +1,11 @@
2009-10-21 Paul Pluzhnikov <ppluzhnikov@google.com>
* defs.h (pc_prefix): New prototype.
* disasm.c (dump_insns): Mark current instruction.
* printcmd.c (do_examine): Likewise.
(pc_prefix): New function.
* stack.c (print_frame_info): Disassemble entire current line.
2009-10-21 Michael Snyder <msnyder@vmware.com> 2009-10-21 Michael Snyder <msnyder@vmware.com>
Elaborate "info record". Elaborate "info record".

View file

@ -608,6 +608,7 @@ extern int build_address_symbolic (CORE_ADDR addr,
int *unmapped); int *unmapped);
extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *); extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
extern const char *pc_prefix (CORE_ADDR);
/* From source.c */ /* From source.c */

View file

@ -113,6 +113,7 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
num_displayed++; num_displayed++;
} }
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_text (uiout, pc_prefix (pc));
ui_out_field_core_addr (uiout, "address", gdbarch, pc); ui_out_field_core_addr (uiout, "address", gdbarch, pc);
if (!build_address_symbolic (pc, 0, &name, &offset, &filename, if (!build_address_symbolic (pc, 0, &name, &offset, &filename,

View file

@ -1,3 +1,8 @@
2009-10-21 Paul Pluzhnikov <ppluzhnikov@google.com>
* gdb.texinfo (Machine Code): Mention current pc marker.
(Memory): Likewise.
2009-10-19 Pedro Alves <pedro@codesourcery.com> 2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs <stan@codesourcery.com> Stan Shebs <stan@codesourcery.com>

View file

@ -6525,6 +6525,9 @@ program counter of the selected frame. A single argument to this
command is a program counter value; @value{GDBN} dumps the function command is a program counter value; @value{GDBN} dumps the function
surrounding this value. Two arguments specify a range of addresses surrounding this value. Two arguments specify a range of addresses
(first inclusive, second exclusive) to dump. (first inclusive, second exclusive) to dump.
If the range of memory being disassembled contains current program counter,
the instruction at that location is shown with a @code{=>} marker.
@end table @end table
The following example shows the disassembly of a range of addresses of The following example shows the disassembly of a range of addresses of
@ -6533,38 +6536,39 @@ HP PA-RISC 2.0 code:
@smallexample @smallexample
(@value{GDBP}) disas 0x32c4 0x32e4 (@value{GDBP}) disas 0x32c4 0x32e4
Dump of assembler code from 0x32c4 to 0x32e4: Dump of assembler code from 0x32c4 to 0x32e4:
0x32c4 <main+204>: addil 0,dp 0x32c4 <main+204>: addil 0,dp
0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26 0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26
0x32cc <main+212>: ldil 0x3000,r31 0x32cc <main+212>: ldil 0x3000,r31
0x32d0 <main+216>: ble 0x3f8(sr4,r31) 0x32d0 <main+216>: ble 0x3f8(sr4,r31)
0x32d4 <main+220>: ldo 0(r31),rp 0x32d4 <main+220>: ldo 0(r31),rp
0x32d8 <main+224>: addil -0x800,dp 0x32d8 <main+224>: addil -0x800,dp
0x32dc <main+228>: ldo 0x588(r1),r26 0x32dc <main+228>: ldo 0x588(r1),r26
0x32e0 <main+232>: ldil 0x3000,r31 0x32e0 <main+232>: ldil 0x3000,r31
End of assembler dump. End of assembler dump.
@end smallexample @end smallexample
Here is an example showing mixed source+assembly for Intel x86: Here is an example showing mixed source+assembly for Intel x86, when the
program is stopped just after function prologue:
@smallexample @smallexample
(@value{GDBP}) disas /m main (@value{GDBP}) disas /m main
Dump of assembler code for function main: Dump of assembler code for function main:
5 @{ 5 @{
0x08048330 <main+0>: push %ebp 0x08048330 <main+0>: push %ebp
0x08048331 <main+1>: mov %esp,%ebp 0x08048331 <main+1>: mov %esp,%ebp
0x08048333 <main+3>: sub $0x8,%esp 0x08048333 <main+3>: sub $0x8,%esp
0x08048336 <main+6>: and $0xfffffff0,%esp 0x08048336 <main+6>: and $0xfffffff0,%esp
0x08048339 <main+9>: sub $0x10,%esp 0x08048339 <main+9>: sub $0x10,%esp
6 printf ("Hello.\n"); 6 printf ("Hello.\n");
0x0804833c <main+12>: movl $0x8048440,(%esp) => 0x0804833c <main+12>: movl $0x8048440,(%esp)
0x08048343 <main+19>: call 0x8048284 <puts@@plt> 0x08048343 <main+19>: call 0x8048284 <puts@@plt>
7 return 0; 7 return 0;
8 @} 8 @}
0x08048348 <main+24>: mov $0x0,%eax 0x08048348 <main+24>: mov $0x0,%eax
0x0804834d <main+29>: leave 0x0804834d <main+29>: leave
0x0804834e <main+30>: ret 0x0804834e <main+30>: ret
End of assembler dump. End of assembler dump.
@end smallexample @end smallexample
@ -7244,6 +7248,18 @@ with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command,
the repeat count @var{n} is used again; the other arguments default as the repeat count @var{n} is used again; the other arguments default as
for successive uses of @code{x}. for successive uses of @code{x}.
When examining machine instructions, the instruction at current program
counter is shown with a @code{=>} marker. For example:
@smallexample
(@value{GDBP}) x/5i $pc-6
0x804837f <main+11>: mov %esp,%ebp
0x8048381 <main+13>: push %ecx
0x8048382 <main+14>: sub $0x4,%esp
=> 0x8048385 <main+17>: movl $0x8048460,(%esp)
0x804838c <main+24>: call 0x80482d4 <puts@@plt>
@end smallexample
@cindex @code{$_}, @code{$__}, and value history @cindex @code{$_}, @code{$__}, and value history
The addresses and contents printed by the @code{x} command are not saved The addresses and contents printed by the @code{x} command are not saved
in the value history because there is often too much of them and they in the value history because there is often too much of them and they

View file

@ -725,6 +725,26 @@ print_address (struct gdbarch *gdbarch,
print_address_symbolic (addr, stream, asm_demangle, " "); print_address_symbolic (addr, stream, asm_demangle, " ");
} }
/* Return a prefix for instruction address:
"=> " for current instruction, else " ". */
const char *
pc_prefix (CORE_ADDR addr)
{
if (has_stack_frames ())
{
struct frame_info *frame;
CORE_ADDR pc;
frame = get_selected_frame (NULL);
pc = get_frame_pc (frame);
if (pc == addr)
return "=> ";
}
return " ";
}
/* Print address ADDR symbolically on STREAM. Parameter DEMANGLE /* Print address ADDR symbolically on STREAM. Parameter DEMANGLE
controls whether to print the symbolic name "raw" or demangled. controls whether to print the symbolic name "raw" or demangled.
Global setting "addressprint" controls whether to print hex address Global setting "addressprint" controls whether to print hex address
@ -817,6 +837,8 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
while (count > 0) while (count > 0)
{ {
QUIT; QUIT;
if (format == 'i')
fputs_filtered (pc_prefix (next_address), gdb_stdout);
print_address (next_gdbarch, next_address, gdb_stdout); print_address (next_gdbarch, next_address, gdb_stdout);
printf_filtered (":"); printf_filtered (":");
for (i = maxelts; for (i = maxelts;

View file

@ -643,8 +643,7 @@ print_frame_info (struct frame_info *frame, int print_level,
/* If disassemble-next-line is set to on and there is line debug /* If disassemble-next-line is set to on and there is line debug
messages, output assembly codes for next line. */ messages, output assembly codes for next line. */
if (disassemble_next_line == AUTO_BOOLEAN_TRUE) if (disassemble_next_line == AUTO_BOOLEAN_TRUE)
do_gdb_disassembly (get_frame_arch (frame), -1, do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end);
get_frame_pc (frame), sal.end);
} }
if (print_what != LOCATION) if (print_what != LOCATION)

View file

@ -1,3 +1,10 @@
2009-10-21 Paul Pluzhnikov <ppluzhnikov@google.com>
* gdb.base/consecutive.exp: Adjust.
* gdb.base/display.exp: Likewise.
* gdb.base/pc-fp.exp: Likewise.
* gdb.base/sigbpt.exp: Likewise.
2009-10-19 Michael Snyder <msnyder@vmware.com> 2009-10-19 Michael Snyder <msnyder@vmware.com>
* gdb.reverse/consecutive-reverse.c: Add comment at end of main. * gdb.reverse/consecutive-reverse.c: Add comment at end of main.

View file

@ -64,7 +64,7 @@ set stop_addr 0
send_gdb "x /2i \$pc\n" send_gdb "x /2i \$pc\n"
gdb_expect { gdb_expect {
-re "$hex.*${nl}($hex).*$gdb_prompt $" { -re "=> $hex.*${nl} ($hex).*$gdb_prompt $" {
set bp_addr $expect_out(1,string) set bp_addr $expect_out(1,string)
pass "get breakpoint address for foo" pass "get breakpoint address for foo"
} }

View file

@ -91,7 +91,7 @@ gdb_test "break 19" ".*Breakpoint 4.*" "break 19"
gdb_test "info disp" ".*There are no auto-display expressions now..*" "inf disp" gdb_test "info disp" ".*There are no auto-display expressions now..*" "inf disp"
gdb_test "disp i" ".*1: i = 0.*" "display i" gdb_test "disp i" ".*1: i = 0.*" "display i"
gdb_test "disp/x j" ".*2: /x j = 0x0.*" "display j" gdb_test "disp/x j" ".*2: /x j = 0x0.*" "display j"
gdb_test "disp/i &k" ".*3: x/i &k(\r\n| )$hex:.*" "display &k" gdb_test "disp/i &k" ".*3: x/i &k(\r\n| ) $hex:.*" "display &k"
gdb_test "disp/f f" ".*4: /f f = 3.1415*" "display/f f" gdb_test "disp/f f" ".*4: /f f = 3.1415*" "display/f f"
gdb_test "disp/s &sum" ".*5: x/s &sum $hex.*sum.:.*" "display/s &sum" gdb_test "disp/s &sum" ".*5: x/s &sum $hex.*sum.:.*" "display/s &sum"

View file

@ -63,7 +63,7 @@ set valueof_fp [get_hexadecimal_valueof "\$fp" "0"]
# display since that encodes and then decodes the expression parameter # display since that encodes and then decodes the expression parameter
# (and hence uses the mechanisms we're trying to test). # (and hence uses the mechanisms we're trying to test).
gdb_test "display/i \$pc" "1: x/i +\\\$pc( +|\r\n)${valueof_pc}.*" gdb_test "display/i \$pc" "1: x/i +\\\$pc( +|\r\n)=> ${valueof_pc}.*"
gdb_test "display/w \$fp" "2: x/xw +\\\$fp +${valueof_fp}.*" gdb_test "display/w \$fp" "2: x/xw +\\\$fp +${valueof_fp}.*"
# FIXME: cagney/2002-09-04: Should also check that ``info registers # FIXME: cagney/2002-09-04: Should also check that ``info registers

View file

@ -93,12 +93,12 @@ gdb_test "advance *bowler" "bowler.*" "advance to the bowler"
set test "stepping to fault" set test "stepping to fault"
set signame "SIGSEGV" set signame "SIGSEGV"
gdb_test_multiple "stepi" "$test" { gdb_test_multiple "stepi" "$test" {
-re "Program received signal (SIGBUS|SIGSEGV).*pc(\r\n| *) *(0x\[0-9a-f\]*).*$gdb_prompt $" { -re "Program received signal (SIGBUS|SIGSEGV).*pc(\r\n| *) *=> (0x\[0-9a-f\]*).*$gdb_prompt $" {
set signame $expect_out(1,string) set signame $expect_out(1,string)
set segv_addr $expect_out(3,string) set segv_addr $expect_out(3,string)
pass "$test" pass "$test"
} }
-re " .*pc(\r\n| *)(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" { -re " .*pc(\r\n| *)=> (0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
set bowler_addrs [concat $expect_out(2,string) $bowler_addrs] set bowler_addrs [concat $expect_out(2,string) $bowler_addrs]
send_gdb "stepi\n" send_gdb "stepi\n"
exp_continue exp_continue
@ -110,7 +110,7 @@ gdb_test_multiple "stepi" "$test" {
set test "get insn after fault" set test "get insn after fault"
gdb_test_multiple {x/2i $pc} "$test" { gdb_test_multiple {x/2i $pc} "$test" {
-re "(0x\[0-9a-f\]*).*bowler.*(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" { -re "=> (0x\[0-9a-f\]*).*bowler.*(0x\[0-9a-f\]*).*bowler.*$gdb_prompt $" {
set bowler_addrs [concat $expect_out(2,string) $bowler_addrs] set bowler_addrs [concat $expect_out(2,string) $bowler_addrs]
pass "$test" pass "$test"
} }
@ -199,7 +199,7 @@ proc stepi_out { name args } {
-re "pc(\r\n| *)[after_segv] .*bowler.*$gdb_prompt $" { -re "pc(\r\n| *)[after_segv] .*bowler.*$gdb_prompt $" {
kfail gdb/1702 "$test (skipped fault insn)" kfail gdb/1702 "$test (skipped fault insn)"
} }
-re "pc(\r\n| *)0x\[a-z0-9\]* .*bowler.*$gdb_prompt $" { -re "pc(\r\n| *)=> 0x\[a-z0-9\]* .*bowler.*$gdb_prompt $" {
kfail gdb/1702 "$test (corrupt pc)" kfail gdb/1702 "$test (corrupt pc)"
} }
} }
@ -244,12 +244,12 @@ proc cont_out { name args } {
# inserted at the faulting instruction. Note that the breakpoint # inserted at the faulting instruction. Note that the breakpoint
# instruction wasn't executed, rather the inferior was SIGTRAPed # instruction wasn't executed, rather the inferior was SIGTRAPed
# with the PC at the breakpoint. # with the PC at the breakpoint.
gdb_test "continue" "Breakpoint.*pc(\r\n| *)[at_segv] .*" \ gdb_test "continue" "Breakpoint.*pc(\r\n| *)=> [at_segv] .*" \
"${name}; continue to breakpoint at fault" "${name}; continue to breakpoint at fault"
# Now single step the faulted instrction at that breakpoint. # Now single step the faulted instrction at that breakpoint.
gdb_test "stepi" \ gdb_test "stepi" \
"Program received signal ${signame}.*pc(\r\n| *)[at_segv] .*" \ "Program received signal ${signame}.*pc(\r\n| *)=> [at_segv] .*" \
"${name}; stepi fault" "${name}; stepi fault"
# Clear any breakpoints # Clear any breakpoints