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: [RFA] Patch for PR gdb/2477


On Mon, Jul 14, 2008 at 10:31:49AM -0700, Paul Pluzhnikov wrote:
> Greetings,
> 
> Attached patch fixes error in printing NULL pointers when "set print object on".
>  http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view&database=gdb&pr=2477
> and adds a test case for it.
> 
> Ok to commit?

Thanks for fixing this.  The patch isn't OK, but it points to the
right solution so we can get it fixed up in no time.  The test is OK.

> @@ -89,7 +89,8 @@ value_virtual_fn_field (struct value **a
>  struct type *
>  value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
>  {
> -  if ((current_cp_abi.rtti_type) == NULL)
> +  if ((current_cp_abi.rtti_type) == NULL
> +      || VALUE_ADDRESS (v) == 0)
>      return NULL;
>    return (*current_cp_abi.rtti_type) (v, full, top, using_enc);
>  }

There's nothing special about zero.  It's just an unreadable memory
address; the same problem will reappear with any other invalid
pointer.  So what we need is to catch memory errors.  There's no way
at present to separate them from other errors, but that's not a big
problem.

So if we use TRY_CATCH and RETURN_MASK_ERROR around the call to
current_cp_abi.rtti_type, we can return NULL in the error case.

-- 
Daniel Jacobowitz
CodeSourcery


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