aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-value.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python/py-value.c')
-rw-r--r--gdb/testsuite/gdb.python/py-value.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.python/py-value.c b/gdb/testsuite/gdb.python/py-value.c
index 586a0fd..8a8ace6 100644
--- a/gdb/testsuite/gdb.python/py-value.c
+++ b/gdb/testsuite/gdb.python/py-value.c
@@ -82,7 +82,7 @@ char **save_argv;
int
main (int argc, char *argv[])
{
- char *cp = argv[0]; /* Prevent gcc from optimizing argv[] out. */
+ char *cp;
struct s s;
union u u;
PTR x = &s;
@@ -99,6 +99,14 @@ main (int argc, char *argv[])
const char *sn = 0;
struct str *xstr;
+ /* Prevent gcc from optimizing argv[] out. */
+
+ /* We also check for a NULL argv in case we are dealing with a target
+ executing in a freestanding environment, therefore there are no
+ guarantees about argc or argv. */
+ if (argv != NULL)
+ cp = argv[0];
+
s.a = 3;
s.b = 5;
u.a = 7;