diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-04-26 11:27:07 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-04-26 11:27:07 -0400 |
commit | bea3329b76cf131ad4ac27acb6728b38984998b9 (patch) | |
tree | 5c8d8482d6ec1da893061e2e263a55a2fff28a71 /gdb/testsuite/gdb.base | |
parent | 21f91785752b59d03117f7803b7e1c9a58e62dbe (diff) | |
download | gdb-bea3329b76cf131ad4ac27acb6728b38984998b9.zip gdb-bea3329b76cf131ad4ac27acb6728b38984998b9.tar.gz gdb-bea3329b76cf131ad4ac27acb6728b38984998b9.tar.bz2 |
gdb: check result of gdb_fopen_cloexec in dump_binary_file
Bug 27773 shows that passing a filename in a non-existent directory to
the "dump binary" command leads to a gdb crash. This is because the
gdb_fopen_cloexec in dump_binary_file fails (returns nullptr) and the
return value is not checked. Fix that by erroring out if
gdb_fopen_cloexec fails.
gdb/ChangeLog:
PR gdb/27773
* cli/cli-dump.c (dump_binary_file): Check result of
gdb_fopen_cloexec.
gdb/testsuite/ChangeLog:
PR gdb/27773
* gdb.base/dump.exp: Test dump to non-existent dir.
Change-Id: Iea89a3bf9e6b9dcc31142faa5ae17bc855759328
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/dump.exp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index 2b79237..52c6983 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -24,6 +24,8 @@ set options {debug} set is64bitonly "no" set endian "auto" +set formats {binary ihex srec tekhex verilog} + if [istarget "alpha*-*-*"] then { # SREC etc cannot handle 64-bit addresses. Force the test # program into the low 31 bits of the address space. @@ -467,6 +469,14 @@ if ![string compare $is64bitonly "no"] then { } +# Test writing a file of each format to a directory that does not exist. + +foreach_with_prefix format $formats { + gdb_test "dump $format memory /tmp/non/existent/directory/file $array_start $array_end" \ + "/tmp/non/existent/directory/file: No such file or directory." \ + "dump to non-existent directory" +} + # Now start a fresh gdb session, and reload the saved value files. gdb_exit |