> >>morden writes:
> >>> UI_WINDOW_OBJECT *uObject = (UI_WINDOW_OBJECT *)object;
> >>>I want to set a watchpoint on the contents of uObject after
> >>>initialization.
> >>Why? The value (contents) of the uObject pointer does not change
> >>within this function, so your watchpoint will never trigger.
> >It does. Something corrupts the stack and uObject pointer becomes
> >garbage (0x1c3, that's 467) while uObjectDup does not:
> >#1 0x82b4808 in GeneralXEventHandler__FP10_WidgetRecPvP7_XEventPc (
> > __0__A226=0x879918c, __0object=0x80456ac, __0xEvent=0x4,
> >__0__A227=0x2 "")
> > at m_win2.c:704 (that's the last line of the function: call to Event
> > where program SIGSEGVs)
> >(gdb) print __1uObjectDup
> >$4 = (struct UI_WINDOW_OBJECT *) 0x8689fb0
> >(gdb) print __1uObject
> >$5 = (struct UI_WINDOW_OBJECT *) 0x1c3
> >>Perhaps you want to describe what your *real* problem is?
> >Stack corruption.
> >The code again is:
> >I have the following code in a third party library:
> >// GeneralXEventHandler gets called for each event of the types we
> requested
> >// in RegisterObject(). We send the event to the Event() routine of the
> >// object the event belongs to.
> >void GeneralXEventHandler(Widget, XtPointer object, XEvent *xEvent,
> >Boolean *)
> >{
> > UI_WINDOW_OBJECT *uObject = (UI_WINDOW_OBJECT *)object;
> > // for debug
> >^^^^^^^^^^^^^^ need a watchpoint right after assignment.
> > UI_WINDOW_OBJECT *uObjectDup = (UI_WINDOW_OBJECT *)object;
> > if (!uObject->screenID)
> > return;
> > UI_EVENT event(E_MOTIF, *xEvent);
> > if (xEvent->type == KeyPress && event.rawCode == XK_Tab)
> > _lastFocusEvent = KeyPress;
> > else if (xEvent->type == ButtonPress)
> > _lastFocusEvent = ButtonPress;
> > if(uObject != uObjectDup) {
> > l_fatal("object %p objectdup %p !!!!", uObject, uObjectDup);
> > }
> > uObject->Event(event);
> >}
> >I want to set a watchpoint on the contents of uObject after
> >initialization. The function is called quite a bit and I don't want to
> >(I can't) do it manually on every call.
> >Is there a gcc directive to automate the setup of watchpoints?
> Do you know what the corrupt value is when it happens?
> If so do something like:
> if(object = 0xDEADBEEF) {
> object = object;
> }
> Set a break on the object = object line.
This won't be useful, because I need to know which function down the
line is corrupting uObject. I could just as well set a breakpoint on
l_fatal line. I need a watchpoint to track down the errant code
and because there are dozens of calls/per second to GeneralXEventHandler
I could not set watchpoints by hand.
Note that I'm not likely to run out of watchpoints because they will go
out of scope as rapidly as they will get set.
In general terms: I need to communicate to gdb from my C++ applications.