public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Insight crashing when debugging invalid pointers
@ 2005-11-18 10:52 elmer.elmer
  2005-11-18 22:36 ` Keith Seitz
  0 siblings, 1 reply; 7+ messages in thread
From: elmer.elmer @ 2005-11-18 10:52 UTC (permalink / raw)
  To: insight


Hi,

I'm using a cross insight built from recent CVS snapshot (10242005)
[host=cygwin, target=arm-linux]

Insight is running quite fine, but I experience some troubles when insight tries
to display variables with invalid memory references...

For example :

typedef struct {
    int a;
    int b;
} TEST_STRUCT;

TEST_STRUCT pt;
int         sum;

pt = NULL;
sum = pt->a + pt->b;

This code will obviously fail (if memory address 0 is not accessible on target)
!!!
But it is only an example ...

If you stop execution at line 'sum = pt->a + pt->b'
Using the GDB console :
p pt
gives -> $1 (TEST_STRUCT *) 0x0
p pt->a
gives -> Error: Cannot access Memory at address 0x0

But if insight is trying to display the same things (either using tooltips or
watch), the entire Insight is crashing !!!

I thing it is related variable evaluation like {$val value}
I checked the Insight scripts, all calls to {$val value} are secured with
'catch'.
Is "catch {$val value} result" supposed to catch GDB exceptions ???

I wonder if this behavior is specific to my built/target or more generic ...

This is very annoying, because when stepping, your mouse can go over over an
expression where pointers are not yet initialized. Insight then tries to
display variable value in tooltips and this leads to frequent Insight
crashes...

Thanks,
Elmer.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Insight crashing when debugging invalid pointers
  2005-11-18 10:52 Insight crashing when debugging invalid pointers elmer.elmer
@ 2005-11-18 22:36 ` Keith Seitz
  2005-11-21 11:53   ` elmer
  2006-01-23  0:23   ` Insight won't let me use the source any more Bruce Korb
  0 siblings, 2 replies; 7+ messages in thread
From: Keith Seitz @ 2005-11-18 22:36 UTC (permalink / raw)
  To: elmer.elmer; +Cc: insight

elmer.elmer@free.fr wrote:

> But if insight is trying to display the same things (either using tooltips or
> watch), the entire Insight is crashing !!!
> 
> I thing it is related variable evaluation like {$val value}
> I checked the Insight scripts, all calls to {$val value} are secured with
> 'catch'.
> Is "catch {$val value} result" supposed to catch GDB exceptions ???
> 
> I wonder if this behavior is specific to my built/target or more generic ...

Good guess. It's probably a problem in varobj (which is part of gdb). 
Can you run insight on gdb and get a backtrace of where it dies?

Keith

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Insight crashing when debugging invalid pointers
  2005-11-18 22:36 ` Keith Seitz
@ 2005-11-21 11:53   ` elmer
  2006-01-23  0:23   ` Insight won't let me use the source any more Bruce Korb
  1 sibling, 0 replies; 7+ messages in thread
From: elmer @ 2005-11-21 11:53 UTC (permalink / raw)
  To: Keith Seitz; +Cc: insight


>> But if insight is trying to display the same things (either using 
>> tooltips or
>> watch), the entire Insight is crashing !!!
>>
>> I thing it is related variable evaluation like {$val value}
>> I checked the Insight scripts, all calls to {$val value} are secured 
>> with
>> 'catch'.
>> Is "catch {$val value} result" supposed to catch GDB exceptions ???
>>
>> I wonder if this behavior is specific to my built/target or more 
>> generic ...
>
>
> Good guess. It's probably a problem in varobj (which is part of gdb). 
> Can you run insight on gdb and get a backtrace of where it dies?
>
> Keith

Unfortunately, it is not very easy for me to have a native gdb to debug 
insight ....

But I think I have found the problem (you're right in varobj.c) :
- When gdb tries to evaluate a value, it calls many functions and 
subfunctions. One of these is "value_of_child"
When value_of_child cannot acces memory to evaluate a value, it simply 
return NULL (deletes the value context) instead of reporting the error.
I changed :
      if (!gdb_value_fetch_lazy (value))
         value = NULL;
to:
      if (!gdb_value_fetch_lazy (value))
         parent->error = 1;
All functions calling this one are testing the "->error" flag or NULL 
return value. So it works !

But this patch does not delete the value context as it was done 
previously....
So further use of the value (for types, names,...) are still possible.
Previously, Insight was crashing when trying to get the 'type' of this 
variable.

I made another patch in function "my_value_equal" (it assumes that 
variable can be accessed) :
I changed :
  gdb_assert (!value_lazy (val1));
to:
  if (value_lazy (val1))
    {
      *error2 = 1;
      return 0;
    }


With both these patches, Insight is able to display invalid pointers 
location with an error message set by gdbtk-varobj.c:variable_value
By the way, in case of error reported by varobj_get_value, 
variable_value sets an error messages and returns TCL_ERROR to the caller.

But it seems that "catch {$val value} result" does not catch the error ...
How to catch it ?

Thanks,
Elmer.






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Insight won't let me use the source any more
  2005-11-18 22:36 ` Keith Seitz
  2005-11-21 11:53   ` elmer
@ 2006-01-23  0:23   ` Bruce Korb
  2006-01-23  0:27     ` Bruce Korb
  2006-01-23  2:43     ` Vale Group
  1 sibling, 2 replies; 7+ messages in thread
From: Bruce Korb @ 2006-01-23  0:23 UTC (permalink / raw)
  To: Keith Seitz; +Cc: insight


Hi,

Some strange thing has happened and now I cannot get Insight to
let me do source level debugging any more.  I saved aside a version
of ~/.gdbtkinit, but rewriting it with the saved version and (also)
deleting it completely accomplishes nothing.  Nothing I do brings
back source level debugging.  What's the secret?  :)  Thanks. - Bruce

$ insight --version
GNU gdb 6.4.0.20051202-cvs
<<blah, blah, blah>>
This GDB was configured as "i686-pc-linux-gnu"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Insight won't let me use the source any more
  2006-01-23  0:23   ` Insight won't let me use the source any more Bruce Korb
@ 2006-01-23  0:27     ` Bruce Korb
  2006-01-23  2:43     ` Vale Group
  1 sibling, 0 replies; 7+ messages in thread
From: Bruce Korb @ 2006-01-23  0:27 UTC (permalink / raw)
  Cc: Keith Seitz, insight

Bruce Korb wrote:

>
> Hi,
>
> Some strange thing has happened and now I cannot get Insight to
> let me do source level debugging any more.  I saved aside a version
> of ~/.gdbtkinit, but rewriting it with the saved version and (also)
> deleting it completely accomplishes nothing.  Nothing I do brings
> back source level debugging.  What's the secret?  :)  Thanks. - Bruce
>
> $ insight --version
> GNU gdb 6.4.0.20051202-cvs
> <<blah, blah, blah>>
> This GDB was configured as "i686-pc-linux-gnu"
>
/home/bkorb/ag/ag/agen5/autogen.c:2: Error in sourced command file:
Undefined command: "".  Try "help".

    while executing
"gdb_cmd "source $file_name""
    (procedure "source_file" line 4)
    invoked from within
"source_file"
    invoked from within
".srcwin0.#srcwin0#srcwin#container#pane0#childsite#con#menubar#m.#srcwin0#srcwin#container#pane0#childsite#con#menubar#m#file 
invoke active"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list $w invoke active]"
    (procedure "tk::MenuInvoke" line 47)
    invoked from within
"tk::MenuInvoke 
.srcwin0.#srcwin0#srcwin#container#pane0#childsite#con#menubar#m.#srcwin0#srcwin#container#pane0#childsite#con#menubar#m#file 
1
"
    (command bound to event)errorCode is NONE

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Insight won't let me use the source any more
  2006-01-23  0:23   ` Insight won't let me use the source any more Bruce Korb
  2006-01-23  0:27     ` Bruce Korb
@ 2006-01-23  2:43     ` Vale Group
  2006-01-23  7:27       ` Bruce Korb
  1 sibling, 1 reply; 7+ messages in thread
From: Vale Group @ 2006-01-23  2:43 UTC (permalink / raw)
  To: insight

Bruce Korb wrote:
> ...I cannot get Insight to let me do source level debugging...
> What's the secret?

The first question that pops to mind is, did you switch the compilation to your
program-under-study to MinGW from Cygwin, for instance?

--
Chuck

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Insight won't let me use the source any more
  2006-01-23  2:43     ` Vale Group
@ 2006-01-23  7:27       ` Bruce Korb
  0 siblings, 0 replies; 7+ messages in thread
From: Bruce Korb @ 2006-01-23  7:27 UTC (permalink / raw)
  To: Vale Group; +Cc: insight

Vale Group wrote:

>Bruce Korb wrote:
>  
>
>>...I cannot get Insight to let me do source level debugging...
>>What's the secret?
>>    
>>
>
>The first question that pops to mind is, did you switch the compilation to your
>program-under-study to MinGW from Cygwin, for instance?
>
No, but I did retype, "make" from the affected directory instead of
the top and it was a "VPATH" build.  I could see the sources again
once I linked the sources into the build directory, so the glitch is
more likely to do with some compile option or another.  So, I do
not know the cause, but my best guess at the moment is some funny
compiler option.  Thanks.  Regards, Bruce

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-01-23  7:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-18 10:52 Insight crashing when debugging invalid pointers elmer.elmer
2005-11-18 22:36 ` Keith Seitz
2005-11-21 11:53   ` elmer
2006-01-23  0:23   ` Insight won't let me use the source any more Bruce Korb
2006-01-23  0:27     ` Bruce Korb
2006-01-23  2:43     ` Vale Group
2006-01-23  7:27       ` Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).