Blame SOURCES/gdb-rhbz1225569-oom-killer-aarch64-frame-same-id-5of8.patch

7b26da
commit 2d6f0de676f46ebd8bb7d98a0093aa081e17e94b
7b26da
Author: Yao Qi <yao@codesourcery.com>
7b26da
Date:   Mon Jun 30 11:47:51 2014 +0800
7b26da
7b26da
    Tweak gdb.trace/tfile.c for thumb mode
7b26da
    
7b26da
    We see the fail below happens on thumb related multi-libs
7b26da
    (-mthumb -march={armv4t,armv7-a}),
7b26da
    
7b26da
    target tfile tfile-basic.tf ^M
7b26da
    warning: Uploaded tracepoint 1 has no source location, using raw address^M
7b26da
    warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
7b26da
    Tracepoint 3 at 0x8958: file /scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.trace/tfile.c, line 91.^M
7b26da
    Created tracepoint 3 for target's tracepoint 1 at 0x8959.^M
7b26da
    warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
7b26da
    warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
7b26da
    warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
7b26da
    (gdb) FAIL: gdb.trace/tfile.exp: complete-command 'target tfile'
7b26da
    
7b26da
    The address of write_basic_trace_file is two-bytes aligned,
7b26da
    
7b26da
    (gdb) p write_basic_trace_file
7b26da
    $1 = {void (void)} 0x8958 <write_basic_trace_file>
7b26da
    
7b26da
    but the ld sets the LSB of every reference to the function address
7b26da
    (indicating the address is in thumb mode), so "&write_basic_trace_file"
7b26da
    in the program becomes 0x8959, which is saved in the trace file.  That
7b26da
    is why the warnnings are emitted.
7b26da
    
7b26da
    This patch is to clear the LSB of the function address written to trace
7b26da
    file in thumb and thumb2 mode.  This patch fixes the fail above.
7b26da
    
7b26da
    gdb/testsuite:
7b26da
    
7b26da
    2014-07-10  Yao Qi  <yao@codesourcery.com>
7b26da
    
7b26da
    	* gdb.trace/tfile.c (write_basic_trace_file)
7b26da
    	[__thumb__||__thumb2__]: Clear the Thumb bit of the function
7b26da
    	address written to trace file.
7b26da
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.trace/tfile.c
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/testsuite/gdb.trace/tfile.c
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.trace/tfile.c
7b26da
@@ -68,6 +68,7 @@ write_basic_trace_file (void)
7b26da
 {
7b26da
   int fd, int_x;
7b26da
   short short_x;
7b26da
+  long func_addr;
7b26da
 
7b26da
   fd = start_trace_file ("basic.tf");
7b26da
 
7b26da
@@ -86,8 +87,14 @@ write_basic_trace_file (void)
7b26da
   /* Dump tracepoint definitions, in syntax similar to that used
7b26da
      for reconnection uploads.  */
7b26da
   /* FIXME need a portable way to print function address in hex */
7b26da
-  snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n",
7b26da
-	    (long) &write_basic_trace_file);
7b26da
+  func_addr = (long) &write_basic_trace_file;
7b26da
+#if defined(__thumb__) || defined(__thumb2__)
7b26da
+  /* Although Thumb functions are two-byte aligned, function
7b26da
+     pointers have the Thumb bit set.  Clear it.  */
7b26da
+  func_addr &= ~1;
7b26da
+#endif
7b26da
+
7b26da
+  snprintf (spbuf, sizeof spbuf, "tp T1:%lx:E:0:0\n", func_addr);
7b26da
   write (fd, spbuf, strlen (spbuf));
7b26da
   /* (Note that we would only need actions defined if we wanted to
7b26da
      test tdump.) */