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] [ppc64] L* funcs addresses to infcalled funcs


Hi,

currently on ppc64 GDB cannot find the function descriptor for any static
function starting with letter L.  That is convert_code_addr_to_desc_addr will
fail on these, passing the code address instead of the function descriptor,
jumping to a garbage address.

(gdb) print callfunc (Lcallfunc, 5)

Program received signal SIGSEGV, Segmentation fault.
?? ()
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(callfunc) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) FAIL: gdb.base/callfuncs.exp: print callfunc (Lcallfunc, 5)
->
(gdb) print callfunc (Lcallfunc, 5)
$84 = 12
(gdb) PASS: gdb.base/callfuncs.exp: print callfunc (Lcallfunc, 5)


Not regression tested, ppc* regression test is welcome but I will do it before
a check in.


Thanks,
Jan


gdb/
2011-03-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* elfread.c (elf_symtab_read): Do not ignore .L symbols if they are
	BSF_SYNTHETIC.

gdb/testsuite/
2011-03-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/callfuncs.c (Lcallfunc, callfunc): New functions.
	* gdb.base/callfuncs.exp (print callfunc (Lcallfunc, 5)): New test.

--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -395,7 +395,11 @@ elf_symtab_read (struct objfile *objfile, int type,
 		{
 		  ms_type = mst_text;
 		}
-	      else if ((sym->name[0] == '.' && sym->name[1] == 'L')
+	      /* The BSF_SYNTHETIC check is there to omit ppc64 function
+		 descriptors mistaken for static functions starting with 'L'.
+		 */
+	      else if ((sym->name[0] == '.' && sym->name[1] == 'L'
+			&& (sym->flags & BSF_SYNTHETIC) == 0)
 		       || ((sym->flags & BSF_LOCAL)
 			   && sym->name[0] == '$'
 			   && sym->name[1] == 'L'))
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -510,3 +510,15 @@ int main ()
   t_structs_c(struct_val1);
   return 0 ;
 }
+
+static int
+Lcallfunc (int arg)
+{
+  return arg + 1;
+}
+
+int
+callfunc (int (*func) (int value), int value)
+{
+  return Lcallfunc (0) * 0 + func (value) * 2;
+}
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -458,3 +458,8 @@ if {![target_info exists gdb,nosignals] && ![istarget "*-*-uclinux*"]} {
 
     gdb_test {set $sp = $old_sp}
 }
+
+# Test function descriptor resolution - the separate debug info .opd section
+# handling vs. local labels `.L'... as `Lcallfunc' starts with `L'.
+
+gdb_test "print callfunc (Lcallfunc, 5)" " = 12"


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