* [PATCH, master + 11][gdb/cli] Don't assert on empty string for core-file
@ 2021-08-30 10:32 Tom de Vries via Gdb-patches
2021-08-30 11:05 ` Andrew Burgess
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries via Gdb-patches @ 2021-08-30 10:32 UTC (permalink / raw)
To: gdb-patches
Hi,
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.
Any comments?
Thanks,
- Tom
[gdb/cli] Don't assert on empty string for core-file
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/corelow.c | 3 ++-
gdb/testsuite/gdb.base/batch-exit-status.exp | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/corelow.c b/gdb/corelow.c
index eb785a08633..711e86c4cd4 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -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;
diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp
index 085dfc6ad56..9a080196bd6 100644
--- a/gdb/testsuite/gdb.base/batch-exit-status.exp
+++ b/gdb/testsuite/gdb.base/batch-exit-status.exp
@@ -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]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, master + 11][gdb/cli] Don't assert on empty string for core-file
2021-08-30 10:32 [PATCH, master + 11][gdb/cli] Don't assert on empty string for core-file Tom de Vries via Gdb-patches
@ 2021-08-30 11:05 ` Andrew Burgess
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2021-08-30 11:05 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
* Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> [2021-08-30 12:32:25 +0200]:
> Hi,
>
> 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.
>
> Any comments?
The error messages aren't massively helpful, but I'm not convinced its
worth putting too much effort into making them more hopeful, so LGTM.
Thanks,
Andrew
>
> Thanks,
> - Tom
>
> [gdb/cli] Don't assert on empty string for core-file
>
> 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/corelow.c | 3 ++-
> gdb/testsuite/gdb.base/batch-exit-status.exp | 4 ++++
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/corelow.c b/gdb/corelow.c
> index eb785a08633..711e86c4cd4 100644
> --- a/gdb/corelow.c
> +++ b/gdb/corelow.c
> @@ -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;
> diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp
> index 085dfc6ad56..9a080196bd6 100644
> --- a/gdb/testsuite/gdb.base/batch-exit-status.exp
> +++ b/gdb/testsuite/gdb.base/batch-exit-status.exp
> @@ -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]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-30 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 10:32 [PATCH, master + 11][gdb/cli] Don't assert on empty string for core-file Tom de Vries via Gdb-patches
2021-08-30 11:05 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox