old-cross-binutils/gdb/testsuite/gdb.trace
Pedro Alves 1b5d0ab34c gdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup
I noticed that the existing code casts a function's address to 'long',
but that doesn't work correctly on some ABIs, like Win64, where long
is 32-bit and while pointers are 64-bit:

  func_addr = (long) &write_basic_trace_file;

Fixing that showed there's actually another place in the file that
writes a function address to file, and therefore should clear the
Thumb bit.  This commit adds a macro+function pair to centralize the
Thumb bit handling, and uses it in both places.

The rest is just enough changes to make the file build without
warnings with "-Wall -Wextra" with x86_64-w64-mingw32-gcc and
i686-w64-mingw32-gcc cross compilers, and with -m32/-m64 on x86_64
GNU/Linux.  Currently with x86_64-w64-mingw32-gcc we get:

  $ x86_64-w64-mingw32-gcc tfile.c  -Wall -DTFILE_DIR=\"\"
  tfile.c: In function 'start_trace_file':
  tfile.c:51:23: error: 'S_IRGRP' undeclared (first use in this function)
	 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
			 ^
  tfile.c:51:23: note: each undeclared identifier is reported only once for each function it appears in
  tfile.c:51:31: error: 'S_IROTH' undeclared (first use in this function)
	 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
				 ^
  tfile.c: In function 'add_memory_block':
  tfile.c:79:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     ll_x = (unsigned long) addr;
	    ^
  tfile.c: In function 'write_basic_trace_file':
  tfile.c:113:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     func_addr = (long) &write_basic_trace_file;
		 ^
  tfile.c:137:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob, sizeof (testglob));
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c:139:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob2, 1);
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c: In function 'write_error_trace_file':
  tfile.c:185:3: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
     char *hex = alloca (len * 2 + 1);
     ^
  tfile.c:185:15: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by default]
     char *hex = alloca (len * 2 + 1);
		 ^
  tfile.c:211:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
	(long) &write_basic_trace_file);
      ^

Tested on x86_64 Fedora 20, -m64 and -m32.
Tested by Yao on arm targets.

gdb/testsuite/
2014-07-16  Pedro Alves  <palves@redhat.com>

	* gdb.trace/tfile.c: Include unistd.h and stdint.h.
	(start_trace_file): Guard S_IRGRP and S_IROTH uses behind #ifdef.
	(tfile_write_64, tfile_write_16, tfile_write_8, tfile_write_addr)
	(tfile_write_buf): New functions.
	(add_memory_block): Rewrite using the above.
	(adjust_function_address): New function.
	(FUNCTION_ADDRESS): New macro.
	(write_basic_trace_file): Remove short_x local, and use
	tfile_write_16. Change type of func_addr local to unsigned long
	long.  Use FUNCTION_ADDRESS instead of handling the Thumb bit
	here.  Cast argument of add_memory_block to char pointer.
	(write_error_trace_file): Avoid alloca.  Use FUNCTION_ADDRESS.
	(main): Remove parameters.
	* gdb.trace/tfile.exp: Remove nowarnings.
2014-07-16 19:25:41 +01:00
..
actions-changed.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
actions-changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
actions.c Ensure unreferenced static symbols aren't omitted by clang (either marking them __attribute__((used)) or making them non-static) 2014-04-24 22:33:46 -07:00
actions.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ax.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
backtrace.exp testsuite: Introduce gdb_assert 2014-07-14 20:30:41 +01:00
change-loc-1.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
change-loc-2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
change-loc.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
change-loc.exp Fix several "set remote foo-packet on/off" commands. 2014-04-25 18:07:02 +01:00
change-loc.h Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
circ.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
circ.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
collection.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
collection.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
deltrace.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
disconnected-tracing.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
disconnected-tracing.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
entry-values.c Fix gdb.trace/entry-values.exp for thumb mode 2014-07-08 16:48:22 +08:00
entry-values.exp Fix gdb.trace/entry-values.exp for thumb mode 2014-07-08 16:48:22 +08:00
ftrace.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ftrace.exp Fix several "set remote foo-packet on/off" commands. 2014-04-25 18:07:02 +01:00
infotrace.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Makefile.in
mi-trace-frame-collected.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-trace-unavailable.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-traceframe-changed.exp Check tracefile is generated by binary execution 2014-04-22 09:57:44 +08:00
mi-tracepoint-changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
mi-tsv-changed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
packetlen.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
passc-dyn.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
passcount.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pending.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pending.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pendshr1.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pendshr2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pr16508.exp Fix PR16508 2014-03-06 11:33:06 +08:00
qtro.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
qtro.exp Don't suppress errors inserting/removing hardware breakpoints in shared 2014-04-23 15:06:47 +01:00
range-stepping.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
range-stepping.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
read-memory.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
read-memory.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
report.exp Create inferior for ctf target. 2014-02-05 19:37:25 +08:00
save-trace.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
stap-trace.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
stap-trace.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
status-stop.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
status-stop.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
strace.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
strace.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tfile.c gdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup 2014-07-16 19:25:41 +01:00
tfile.exp gdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup 2014-07-16 19:25:41 +01:00
tfind.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-break.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-break.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-buffer-size.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-buffer-size.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-mt.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-mt.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
trace-unavailable.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tracecmd.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tspeed.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tspeed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tstatus.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tsv.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
unavailable-dwarf-piece.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
unavailable-dwarf-piece.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
unavailable.cc Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
unavailable.exp Partially available/unavailable data in requested range 2014-05-05 11:51:59 +08:00
while-dyn.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
while-stepping.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00