From 028cafa74fe2601ebf13e9a64e6de90e891cbed8 Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Thu, 6 Dec 2012 12:15:32 +0800 Subject: [PATCH 2/5] * tilegx-tdep.c (tilegx_analyze_prologue): fix prologue analysis overflow bug when setting breakpoint by function name, if that function is in .so and that .so is not loaded yet, then gdb will do partial name match, which will match the corresponding plt stub entry. We should take this situation into account when doing prologue analysis. --- gdb/tilegx-tdep.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 2f7f253..93969c9 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -432,8 +432,22 @@ tilegx_analyze_prologue (struct gdbarch* gdbarch, status = safe_frame_unwind_memory (next_frame, instbuf_start, instbuf, instbuf_size); - if (status == 0) - memory_error (status, next_addr); + if (status == 0) { + /* fix gdb.base/gdb1250 + * breakpoint is set before dynamic library loaded, thus gdb + * does a partial symbol name finding and sets the breakpoint + * in the plt stub. our 32-bundle prefetch window is too large + * for this situation to cause a memory access error. + * For plt stub, we just need to return directly. + * + * x86 does not have this problem, because the first instruction + * in their plt stub is jump, which ends the analysis also. + */ + if (strcmp(find_pc_section(instbuf_start)->the_bfd_section->name, + ".plt") == 0) + return instbuf_start; + memory_error (status, next_addr); + } } reverse_frame_valid = 0; -- 1.7.10.4