diff options
author | Andrew Stubbs <andrew.stubbs@st.com> | 2008-09-19 18:12:17 +0000 |
---|---|---|
committer | Andrew Stubbs <andrew.stubbs@st.com> | 2008-09-19 18:12:17 +0000 |
commit | 3f27f2a479adae58f900b42305bbddd6487a50a5 (patch) | |
tree | b3d320e5be1817c2310704d31524f5b0283729cc /gdb/frame.c | |
parent | 5db484ff3d77b5241c7cbef02788962fa6aeedd8 (diff) | |
download | gdb-3f27f2a479adae58f900b42305bbddd6487a50a5.zip gdb-3f27f2a479adae58f900b42305bbddd6487a50a5.tar.gz gdb-3f27f2a479adae58f900b42305bbddd6487a50a5.tar.bz2 |
2008-09-19 Andrew Stubbs <ams@codesourcery.com>
* frame.c (get_frame_register_bytes): Detect bad debug info.
Diffstat (limited to 'gdb/frame.c')
-rw-r--r-- | gdb/frame.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gdb/frame.c b/gdb/frame.c index 55ded7168..88d51f7 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -796,6 +796,8 @@ get_frame_register_bytes (struct frame_info *frame, int regnum, CORE_ADDR offset, int len, gdb_byte *myaddr) { struct gdbarch *gdbarch = get_frame_arch (frame); + int i; + int maxsize; /* Skip registers wholly inside of OFFSET. */ while (offset >= register_size (gdbarch, regnum)) @@ -804,6 +806,22 @@ get_frame_register_bytes (struct frame_info *frame, int regnum, regnum++; } + /* Detect bad debug info. */ + maxsize = -offset; + for (i = regnum; i < gdbarch_num_regs (gdbarch); i++) + { + int thissize = register_size (gdbarch, i); + if (thissize == 0) + break; + maxsize += thissize; + } + if (len > maxsize) + { + warning (_("Bad debug information detected: " + "Attempt to read %d bytes from registers."), len); + return 0; + } + /* Copy the data. */ while (len > 0) { |