This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: [PATCH] Fix for incorect breakpoint set in case of clang compiled binary


Hi Tom
I had missed out to paste the changeLog in  the mail. Please find the patch with changelog -

Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.14836
diff -u -p -r1.14836 ChangeLog
--- ChangeLog	15 Nov 2012 16:12:11 -0000	1.14836
+++ ChangeLog	20 Nov 2012 04:39:46 -0000
@@ -1,3 +1,9 @@
+2012-11-20  Karthik Bhat  <kv.bhat@samsung.com>
+
+	* i386-tdep.c (i386_skip_prologue): See if we
+              can determine the end of the prologue via the symbol table.
+	If so use the same instead of going through prologue instructions.
+
 2012-11-15  Pierre Muller  <muller@sourceware.org>
 
 	ARI fixes: move gdb_wait and gdb_stat headers to common subdirectory.
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.362
diff -u -p -r1.362 i386-tdep.c
--- i386-tdep.c	12 Nov 2012 21:59:06 -0000	1.362
+++ i386-tdep.c	20 Nov 2012 04:39:47 -0000
@@ -1582,8 +1582,30 @@ i386_skip_prologue (struct gdbarch *gdba
   CORE_ADDR pc;
   gdb_byte op;
   int i;
+  cache.locals = -1; 
+  CORE_ADDR func_addr;
+  struct symtab *s = find_pc_symtab (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);
+    
+    /* GCC always emits a line note before the prologue and another
+	 one after, even if the two are at the same address or on the
+	 same line.  Take advantage of this so that we do not need to
+	 know every instruction that might appear in the prologue.  We
+	 will have producer information for most binaries; if it is
+	 missing (e.g. for -gstabs), assuming the GNU tools.  */
+    if (post_prologue_pc
+	  && (s == NULL
+	      || s->producer == NULL
+	      || strncmp (s->producer, "GNU ", sizeof ("GNU ") - 1) == 0
+	      || strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+	  return  max (start_pc, post_prologue_pc);
+  }
+

Many of the current gcc test cases test this feature. We can reproduce this failure in clang with existing testcases such as break-always.exp,step-test.exp etc when tested with clang compiled binary. 
Hence i'm using the existing test cases.

Tom> +  Is there any other way?

Currently i could come up with this fix. Similar fix is used in case of ARM architecture.

Regards
Karthik

------- Original Message -------
Sender : Tom Tromey<tromey@redhat.com>
Date : Nov 20, 2012 00:49 (GMT+09:00)
Title : Re: [PATCH] Fix for incorect breakpoint set in case of clang compiled binary

>>>>> "Karthik" == KARTHIKVENKATESH BHAT writes:

Karthik> I wanted to add a patch in i386-tdep.c .  Similar to what is done in
Karthik> other architectures such as ARM,
Karthik> instead of actually going through the complete prologue if we can use
Karthik> the symbol table information to resolve prologue end.

I'm not the person to review this patch, but I did notice that it is
missing a ChangeLog entry and also a test case.

Karthik> +       || strncmp (s->producer, "GNU ", sizeof ("GNU ") - 1) == 0
Karthik> +       || strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))

Is there any other way?

Tom

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]