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]

[PATCH] skip_prologue_using_sal: early exit if assembler


Hi.

This patch is part of the discussion I started here:
https://sourceware.org/ml/gdb-patches/2014-08/msg00539.html

The prologue parsing aspect of that discussion is submitted
as a patch here:
https://sourceware.org/ml/gdb-patches/2014-09/msg00079.html

This patch fixes a few failures when tested with clang,
e.g. amd64-disp-step.exp.  There's no point in trying to
use source line info to parse prologues in assembler code.

Regression tested on amd64, i386, aarch64, ppc64 [all linux].

Note: Most of the patch is due to re-indentation.

2014-09-02  Doug Evans  <dje@google.com>

	* symtab.c (skip_prologue_using_sal): Return zero if called for
	assembler code.

diff --git a/gdb/symtab.c b/gdb/symtab.c
index c530d50..a2b051b 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3139,27 +3139,33 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
   prologue_sal = find_pc_line (start_pc, 0);
   if (prologue_sal.line != 0)
     {
+      struct linetable *linetable = LINETABLE (prologue_sal.symtab);
+      int idx = 0;
+
+      /* If this is assembler just punt.
+	 While the assembler code could be implementing a higher level
+	 language and thus could have a logical prologue, we can't really
+	 know what is prologue and what is not using sals (short of using
+	 something like DWARF's DW_LNS_set_prologue_end).  */
+      if (prologue_sal.symtab->language == language_asm)
+	return 0;
+
       /* For languages other than assembly, treat two consecutive line
 	 entries at the same address as a zero-instruction prologue.
 	 The GNU assembler emits separate line notes for each instruction
 	 in a multi-instruction macro, but compilers generally will not
 	 do this.  */
-      if (prologue_sal.symtab->language != language_asm)
-	{
-	  struct linetable *linetable = LINETABLE (prologue_sal.symtab);
-	  int idx = 0;
-
-	  /* Skip any earlier lines, and any end-of-sequence marker
-	     from a previous function.  */
-	  while (linetable->item[idx].pc != prologue_sal.pc
-		 || linetable->item[idx].line == 0)
-	    idx++;
-
-	  if (idx+1 < linetable->nitems
-	      && linetable->item[idx+1].line != 0
-	      && linetable->item[idx+1].pc == start_pc)
-	    return start_pc;
-	}
+
+      /* Skip any earlier lines, and any end-of-sequence marker
+	 from a previous function.  */
+      while (linetable->item[idx].pc != prologue_sal.pc
+	     || linetable->item[idx].line == 0)
+	idx++;
+
+      if (idx+1 < linetable->nitems
+	  && linetable->item[idx+1].line != 0
+	  && linetable->item[idx+1].pc == start_pc)
+	return start_pc;
 
       /* If there is only one sal that covers the entire function,
 	 then it is probably a single line function, like


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