[gdb/cli] Don't assert on empty string for core-file
authorTom de Vries <tdevries@suse.de>
Mon, 30 Aug 2021 14:03:15 +0000 (16:03 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 30 Aug 2021 14:03:15 +0000 (16:03 +0200)
With current gdb we run into:
...
$ gdb -batch '' ''
: No such file or directory.
pathstuff.cc:132: internal-error: \
  gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): \
  Assertion `path != NULL && path[0] != '\0'' failed.
...

Fix this by skipping the call to gdb_abspath in core_target_open in the
empty-string case, such that we have instead:
...
$ gdb -batch '' ''
: No such file or directory.
: No such file or directory.
$
...

Tested on x86_64-linux.

gdb/ChangeLog:

2021-08-30  Tom de Vries  <tdevries@suse.de>

PR cli/28290
* gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the
empty-string case.

gdb/testsuite/ChangeLog:

2021-08-30  Tom de Vries  <tdevries@suse.de>

PR cli/28290
* gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.

gdb/ChangeLog
gdb/corelow.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/batch-exit-status.exp

index 477b17762c5e3ac5fca0bb19249c09ada2504905..fd4a9d11b92259c2f2b9f4f6216f417947ec6cd3 100644 (file)
@@ -1,3 +1,9 @@
+2021-08-30  Tom de Vries  <tdevries@suse.de>
+
+       PR cli/28290
+       * gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the
+       empty-string case.
+
 2021-08-23  Tom de Vries  <tdevries@suse.de>
 
        PR gdb/26880
index eb785a08633ac1659711a8c30e38aa90067ea333..711e86c4cd4b5fc07670140baf8aea186e69657c 100644 (file)
@@ -428,7 +428,8 @@ core_target_open (const char *arg, int from_tty)
     }
 
   gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
-  if (!IS_ABSOLUTE_PATH (filename.get ()))
+  if (strlen (filename.get ()) != 0
+      && !IS_ABSOLUTE_PATH (filename.get ()))
     filename = gdb_abspath (filename.get ());
 
   flags = O_BINARY | O_LARGEFILE;
index e5efec5b3d164aeb06ee7192c86c4b32680c4f7e..436bcb4080b613a00f9a499ee60e2c02de9fe278 100644 (file)
@@ -1,3 +1,8 @@
+2021-08-30  Tom de Vries  <tdevries@suse.de>
+
+       PR cli/28290
+       * gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.
+
 2021-08-23  Tom de Vries  <tdevries@suse.de>
 
        PR gdb/26880
index 085dfc6ad56d842d97e4afc71910070cf54ad3e6..9a080196bd61e5c4f3d49f2d8b19908617f42ea5 100644 (file)
@@ -76,3 +76,7 @@ test_exit_status 1 "-batch -x $good_commands -x $bad_commands" \
     "-batch -x good-commands -x bad-commands"
 test_exit_status 1 "-batch -x $good_commands -ex \"set not-a-thing 4\"" \
     "-batch -x good-commands -ex \"set not-a-thing 4\""
+
+set no_such_re ": No such file or directory\\."
+test_exit_status 1 "-batch \"\"" $no_such_re
+test_exit_status 1 "-batch \"\" \"\"" [multi_line $no_such_re $no_such_re]
This page took 0.034734 seconds and 4 git commands to generate.