Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: KARTHIKVENKATESH BHAT <kv.bhat@samsung.com>
To: Tom Tromey <tromey@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: Re: [PATCH] Fix for incorect breakpoint set in case of clang compiled binary
Date: Tue, 20 Nov 2012 04:58:00 -0000	[thread overview]
Message-ID: <12011231.483671353387478250.JavaMail.weblogic@epml02> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 3377 bytes --]

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\x16º&Öéj×!zÊÞ¶êç÷­<öX¬µªÜ†\a[¥«\…ë

             reply	other threads:[~2012-11-20  4:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20  4:58 KARTHIKVENKATESH BHAT [this message]
2012-11-21 13:11 ` Pedro Alves
2012-11-21 13:20   ` Mark Kettenis
2012-11-21 14:11     ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2012-12-04  6:09 KARTHIKVENKATESH BHAT
2012-11-28  5:14 KARTHIKVENKATESH BHAT
2012-11-27 13:47 KARTHIKVENKATESH BHAT
2012-11-21 15:39 KARTHIKVENKATESH BHAT
2012-11-19 15:19 KARTHIKVENKATESH BHAT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12011231.483671353387478250.JavaMail.weblogic@epml02 \
    --to=kv.bhat@samsung.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox