Fix for incorrect breakpoint set in case of clang compiled binary
authorKarthik Bhat <kvbhat@sourceware.org>
Tue, 4 Dec 2012 07:43:19 +0000 (07:43 +0000)
committerKarthik Bhat <kvbhat@sourceware.org>
Tue, 4 Dec 2012 07:43:19 +0000 (07:43 +0000)
gdb/ChangeLog
gdb/amd64-tdep.c
gdb/i386-tdep.c

index ae82862f5113be144bdb906efd9c8d77f32e0d32..41d9891ab3d783ec0c4ed50ec65973e55992d53a 100644 (file)
@@ -1,3 +1,10 @@
+2012-12-04  Karthik Bhat  <kv.bhat@samsung.com>
+
+       * i386-tdep.c (i386_skip_prologue): Using symbol table
+       to find the end of prologue for clang compiled binaries.
+       * amd64-tdep.c (amd64_skip_prologue): Using symbol table
+       to find the end of prologue for clang compiled binaries.
+
 2012-12-03  Doug Evans  <dje@google.com>
 
        * dwarf2read.c (struct dwarf2_per_objfile): Clarify comment.
index 2edaecf14271b2d31b9223e8ed64f41b9cbf7364..fec74d53f1b55637b432a79e4f43ae8b7f0f7675 100644 (file)
@@ -2252,6 +2252,22 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 {
   struct amd64_frame_cache cache;
   CORE_ADDR pc;
+  CORE_ADDR func_addr;
+
+  if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
+    {
+      CORE_ADDR post_prologue_pc
+       = skip_prologue_using_sal (gdbarch, func_addr);
+      struct symtab *s = find_pc_symtab (func_addr);
+
+      /* Clang always emits a line note before the prologue and another
+        one after.  We trust clang to emit usable line notes.  */
+      if (post_prologue_pc
+         && (s != NULL
+             && s->producer != NULL
+             && strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+        return max (start_pc, post_prologue_pc);
+    }
 
   amd64_init_frame_cache (&cache);
   pc = amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffLL,
index f0056bea56f7d9abc1b86d6aab255479a9542128..52b5c7004fffd0966e5a4e11f29e8d9b57cd440c 100644 (file)
@@ -1582,7 +1582,23 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
   CORE_ADDR pc;
   gdb_byte op;
   int i;
+  CORE_ADDR func_addr;
 
+  if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
+    {
+      CORE_ADDR post_prologue_pc
+       = skip_prologue_using_sal (gdbarch, func_addr);
+      struct symtab *s = find_pc_symtab (func_addr);
+
+      /* Clang always emits a line note before the prologue and another
+        one after.  We trust clang to emit usable line notes.  */
+      if (post_prologue_pc
+         && (s != NULL
+             && s->producer != NULL
+             && strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+        return max (start_pc, post_prologue_pc);
+    }
   cache.locals = -1;
   pc = i386_analyze_prologue (gdbarch, start_pc, 0xffffffff, &cache);
   if (cache.locals < 0)
This page took 0.03563 seconds and 4 git commands to generate.