diff options
author | Yao Qi <yao.qi@linaro.org> | 2016-12-02 09:37:30 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2016-12-02 09:37:30 +0000 |
commit | 4d9a9006139d1ceea787cdda871dff8943e493f0 (patch) | |
tree | e52116c2358af3d557f2939ddac9cfdb7c6ac913 /gdb/trad-frame.c | |
parent | 018572b88885ae67d22612937fa1e4fd98d5f5ad (diff) | |
download | gdb-4d9a9006139d1ceea787cdda871dff8943e493f0.zip gdb-4d9a9006139d1ceea787cdda871dff8943e493f0.tar.gz gdb-4d9a9006139d1ceea787cdda871dff8943e493f0.tar.bz2 |
Add unit test to aarch64 prologue analyzer
We don't have an effective way to test prologue analyzer which is
highly dependent on instruction patterns in prologue generated by
compiler. GDB prologue analyzer may not handle the new sequences
generated by new compiler, or may still handle some sequences that
generated by very old compilers which are no longer used. The
former is a functionality issue, while the latter is a maintenance
issue.
The input and output of prologue analyzer is quite clear, so it
fits for unit test. The input is series of instructions, and the
output are 1) where prologue end, 2) where registers are saved.
In aarch64, they are represented in 'struct aarch64_prologue_cache'.
This patch refactors aarch64_analyze_prologue so it can read
instructions from either real target or test harness. In unit
test aarch64_analyze_prologue_test, aarch64_analyze_prologue gets
instructions we prepared in the test, as the input of prologue
analyzer. Then, we checked various fields in
'struct aarch64_prologue_cache'.
gdb:
2016-12-02 Yao Qi <yao.qi@linaro.org>
Pedro Alves <palves@redhat.com>
* aarch64-tdep.c: Include "selftest.h".
(abstract_instruction_reader): New class.
(instruction_reader): New class.
(aarch64_analyze_prologue): Add new parameter reader. Call
reader.read instead of read_memory_unsigned_integer.
[GDB_SELF_TEST] (instruction_reader_test): New class.
(aarch64_analyze_prologue_test): New function.
(_initialize_aarch64_tdep) [GDB_SELF_TEST]: Register
selftests::aarch64_analyze_prologue_test.
* trad-frame.c (trad_frame_cache_zalloc):
(trad_frame_alloc_saved_regs): Add a new function.
* trad-frame.h (trad_frame_alloc_saved_regs): Declare.
Diffstat (limited to 'gdb/trad-frame.c')
-rw-r--r-- | gdb/trad-frame.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index ebf19df..4430dd5 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -43,16 +43,10 @@ trad_frame_cache_zalloc (struct frame_info *this_frame) return this_trad_cache; } -/* A traditional frame is unwound by analysing the function prologue - and using the information gathered to track registers. For - non-optimized frames, the technique is reliable (just need to check - for all potential instruction sequences). */ - struct trad_frame_saved_reg * -trad_frame_alloc_saved_regs (struct frame_info *this_frame) +trad_frame_alloc_saved_regs (struct gdbarch *gdbarch) { int regnum; - struct gdbarch *gdbarch = get_frame_arch (this_frame); int numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); struct trad_frame_saved_reg *this_saved_regs = FRAME_OBSTACK_CALLOC (numregs, struct trad_frame_saved_reg); @@ -65,6 +59,19 @@ trad_frame_alloc_saved_regs (struct frame_info *this_frame) return this_saved_regs; } +/* A traditional frame is unwound by analysing the function prologue + and using the information gathered to track registers. For + non-optimized frames, the technique is reliable (just need to check + for all potential instruction sequences). */ + +struct trad_frame_saved_reg * +trad_frame_alloc_saved_regs (struct frame_info *this_frame) +{ + struct gdbarch *gdbarch = get_frame_arch (this_frame); + + return trad_frame_alloc_saved_regs (gdbarch); +} + enum { TF_REG_VALUE = -1, TF_REG_UNKNOWN = -2 }; int |