This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] avoid GDB crash on inspection of pascal arrays



> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Joel Brobecker
> Envoyé?: Monday, March 08, 2010 7:55 PM
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [PATCH] avoid GDB crash on inspection of pascal arrays
> 
> 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...

  No, you are perfectly right that it doesn't
seem logical to call this function with a NULL type.

  I fact, that happen probably only because of the p-exp.y 
code, but I tought that adding this test was the safest anyhow.
 
> 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?

  Sorry, I am always confused about operator precedence here
(pascal 'AND' binary operator has a higher precedence than
comparison operators, which means that similar pascal code
means those extra parentheses...)

> 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.

  Formatting with the tab/spaces conversion is still a nightmare
for me...

  I really don't know vi enough to reformat correctly
an almost 100 lines long block... Is there a neat way to do this just with
vi
or do I need something more powerful?

  Could someone tell me the best way?

Pierre



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]