Re: [PATCH v2][RFC] Fix crash in AIX when current working directory is NULL

Tom Tromey <[email protected]> Tue, 21 Jul 2026 11:49:36 -0600
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
>>>>> Aditya Vidyadhar Kamath <[email protected]> writes:

>    desc = openp (search_path, flags, file_name, O_RDONLY | O_BINARY,
> -		&absolute_name, per_bfd->captured_cwd.c_str ());
> +		&absolute_name, per_bfd->captured_cwd.has_value () ?
> +		per_bfd->captured_cwd->c_str () : nullptr);

gdb style is to put operators at the start of a new line.
For "?:" in particular I would also move the condition to a new line.

> diff --git a/gdb/testsuite/gdb.base/getcwd-fail-helper.c b/gdb/testsuite/gdb.base/getcwd-fail-helper.c
> new file mode 100644
> index 00000000000..a5e8fe80cbf
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/getcwd-fail-helper.c
> @@ -0,0 +1,67 @@
> +/* Helper to reproduce getcwd failure by deleting cwd via child process.  */
> +#include <stdio.h>

New files should have a copyright header.

This applies to the other files as well.

> +catch {file delete -force $temp_dir}

Deleting this is probably undesirable.  It's normally good if running a
test leaves the test environment around.

Tom