diff options
author | Yao Qi <yao@codesourcery.com> | 2013-10-18 17:36:11 +0800 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2013-12-10 20:27:49 +0800 |
commit | 0865b04a4dec8a458bee54081b5598a6268b0724 (patch) | |
tree | 7b2cdde0ecfc6456086735083c6a8b1a7ebb08dc /gdb/corefile.c | |
parent | Invalidate target cache before starting to handle event. (diff) | |
download | binutils-gdb-0865b04a4dec8a458bee54081b5598a6268b0724.tar.gz binutils-gdb-0865b04a4dec8a458bee54081b5598a6268b0724.tar.bz2 binutils-gdb-0865b04a4dec8a458bee54081b5598a6268b0724.zip |
Use target_read_code in skip_prologue (i386)
GDB is able to cache memory accesses requested in target_read_code,
so target_read_code is more efficient than general target_read_memory.
This patch uses target_read_code and its variants to read target
memory in the functions related to i386_skip_prologue. It improves
the performance when doing 'b foo' (foo is a function) in remote
debugging.
Nowadays, when we set a breakpoint on function f1, GDB will fetch the
code in f1 to determine the start of the function body (say skip the
prologue), it requests read from target many times. With this patch
applied, the number of RSP 'm' packets are reduced.
gdb:
2013-12-10 Yao Qi <yao@codesourcery.com>
* corefile.c (read_code): New function.
(read_code_integer): New function.
(read_code_unsigned_integer): New function.
* gdbcore.h (read_code): Declare.
(read_code_integer): Declare.
(read_code_unsigned_integer): Declare.
* i386-tdep.c (i386_follow_jump): Call target_read_code instead
of target_read_memory. Call read_code_unsigned_integer instead
of read_memory_unsigned_integer.
(i386_analyze_struct_return): Likewise.
(i386_skip_probe): Likewise.
(i386_analyze_stack_align): Likewise.
(i386_match_pattern): Likewise.
(i386_skip_noop): Likewise.
(i386_analyze_frame_setup): Likewise.
(i386_analyze_register_saves): Likewise.
(i386_skip_prologue): Likewise.
(i386_skip_main_prologue): Likewise.
(i386_frame_cache_1): Likewise.
Diffstat (limited to 'gdb/corefile.c')
-rw-r--r-- | gdb/corefile.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/corefile.c b/gdb/corefile.c index 878ab3b3900..d821fdd8cb1 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -276,6 +276,18 @@ read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) memory_error (status, memaddr); } +/* Same as target_read_code, but report an error if can't read. */ + +void +read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) +{ + int status; + + status = target_read_code (memaddr, myaddr, len); + if (status != 0) + memory_error (status, memaddr); +} + /* Argument / return result struct for use with do_captured_read_memory_integer(). MEMADDR and LEN are filled in by gdb_read_memory_integer(). RESULT is the contents that were @@ -354,6 +366,26 @@ read_memory_unsigned_integer (CORE_ADDR memaddr, int len, return extract_unsigned_integer (buf, len, byte_order); } +LONGEST +read_code_integer (CORE_ADDR memaddr, int len, + enum bfd_endian byte_order) +{ + gdb_byte buf[sizeof (LONGEST)]; + + read_code (memaddr, buf, len); + return extract_signed_integer (buf, len, byte_order); +} + +ULONGEST +read_code_unsigned_integer (CORE_ADDR memaddr, int len, + enum bfd_endian byte_order) +{ + gdb_byte buf[sizeof (ULONGEST)]; + + read_code (memaddr, buf, len); + return extract_unsigned_integer (buf, len, byte_order); +} + void read_memory_string (CORE_ADDR memaddr, char *buffer, int max_len) { |