This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] avoid GDB crash on inspection of pascal arrays
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 8 Mar 2010 22:54:50 +0400
- Subject: Re: [PATCH] avoid GDB crash on inspection of pascal arrays
- References: <001801cabee0$31499ca0$93dcd5e0$@muller@ics-cnrs.unistra.fr>
Hi Pierre,
> 2020-03-08 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * p-lang.c (is_pascal_string_type): Check that TYPE arg is non NULL.
Seems odd that you'd call a function whose job is to inspect a type with
a NULL type, but it's not hard to add a check indeed - and that would not.
be the first time ;-). Please do not consider this an objection, just
"speaking" aloud...
Just one nit:
> - if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
> + if ((type != NULL) && (TYPE_CODE (type) == TYPE_CODE_STRUCT))
Would you mind removing the extra parenthesis around each block?
I'd like for the code to be as consistent as possible, to help
readability. It's a question of taste, and I don't agree with all
our rules, but I'd like for things to stay as consistent as possible...
While I'm sending you an email, I started looking at the call sites
for your function, to see if I could see why the function is called
with a NULL pointer, in case there was something obvious to be found.
Nothing obvious, but I noticed that some code in p-valprint might need
a little reformatting?
> elttype = check_typedef (TYPE_TARGET_TYPE (type));
> {
> addr = unpack_pointer (type, valaddr + embedded_offset);
> print_unpacked_pointer:
> elttype = check_typedef (TYPE_TARGET_TYPE (type));
>
> if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
(this is around line 153).
Something else that caught my attention, as well, is the following
statement is repeated twice:
elttype = check_typedef (TYPE_TARGET_TYPE (type));
It looks like the first instance is really unnecessary now?
(I am guessing there was a "if" before the mis-indented curly
brace before, and that this "if" got removed, but not its body,
to keep the patch readable - although there is always the diff -w
option). How about the curly brace themselves - since the block
does not introduce new local variables, it looks like it can go too.
--
Joel