[3/3,gdb/testsuite] Add missing includes in gdb.trace/collection.c

Message ID 20240327143038.20021-3-tdevries@suse.de
State Committed
Headers
Series [1/3,gdb/tetsuite] Add missing include in gdb.base/ctf-ptype.c |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom de Vries March 27, 2024, 2:30 p.m. UTC
  On fedora rawhide, with test-case gdb.trace/collection.exp, I get:
...
gdb compile failed, collection.c: In function 'strings_test_func':
collection.c:227:13: error: implicit declaration of function 'malloc' \
  [-Wimplicit-function-declaration]
  227 |   longloc = malloc(500);
      |             ^~~~~~
collection.c:1:1: note: \
  include '<stdlib.h>' or provide a declaration of 'malloc'
  +++ |+#include <stdlib.h>
    1 | /* This testcase is part of GDB, the GNU debugger.

collection.c:228:3: error: implicit declaration of function 'strcpy' \
  [-Wimplicit-function-declaration]
  228 |   strcpy(longloc, ... );
      |   ^~~~~~
collection.c:1:1: note: include '<string.h>' or provide a declaration of \
  'strcpy'
  +++ |+#include <string.h>
    1 | /* This testcase is part of GDB, the GNU debugger.
collection.c:230:8: error: implicit declaration of function 'strlen' \
  [-Wimplicit-function-declaration]
  230 |   i += strlen (locstr);
      |        ^~~~~~
collection.c:230:8: note: include '<string.h>' or provide a declaration of \
  'strlen'
...

Fix this by adding the missing includes.

Tested on aarch64-linux.
---
 gdb/testsuite/gdb.trace/collection.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/gdb/testsuite/gdb.trace/collection.c b/gdb/testsuite/gdb.trace/collection.c
index efcc2e389da..8379b7d7eaf 100644
--- a/gdb/testsuite/gdb.trace/collection.c
+++ b/gdb/testsuite/gdb.trace/collection.c
@@ -19,6 +19,9 @@ 
  * Test program for trace collection
  */
 
+#include <string.h>
+#include <stdlib.h>
+
 /*
  * Typedefs
  */