public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* auto-solib-add when attaching to inferior
@ 2003-04-16 18:59 Kris Warkentin
  2003-04-16 19:04 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Kris Warkentin @ 2003-04-16 18:59 UTC (permalink / raw)
  To: gdb

When I run a remote process using our QNX remote protocol, I get a solib
breakpoint set properly and from then on, if solibs are loaded, their
symbols automatically get added (auto-solib-add is on by default).  If,
however, I attach to the process, even if auto-solib-add is on, I still have
to go 'shared' to get them to load.  If I 'maint info breakpoints' on the
attached process, I see that there isn't a shlib-events breakpoint set on
the attached process so I assume either enable_break() isn't getting called
or is failing.

I'm still building my debug gdb to test but I'm hoping someone will tell me,
"Oh, when you attach you should always call such-and-such function" and I
can just add it to our back end code.

cheers,

Kris

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

* Re: auto-solib-add when attaching to inferior
  2003-04-16 18:59 auto-solib-add when attaching to inferior Kris Warkentin
@ 2003-04-16 19:04 ` Daniel Jacobowitz
  2003-04-16 22:05   ` Kris Warkentin
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-04-16 19:04 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: gdb

On Wed, Apr 16, 2003 at 03:05:46PM -0400, Kris Warkentin wrote:
> When I run a remote process using our QNX remote protocol, I get a solib
> breakpoint set properly and from then on, if solibs are loaded, their
> symbols automatically get added (auto-solib-add is on by default).  If,
> however, I attach to the process, even if auto-solib-add is on, I still have
> to go 'shared' to get them to load.  If I 'maint info breakpoints' on the
> attached process, I see that there isn't a shlib-events breakpoint set on
> the attached process so I assume either enable_break() isn't getting called
> or is failing.
> 
> I'm still building my debug gdb to test but I'm hoping someone will tell me,
> "Oh, when you attach you should always call such-and-such function" and I
> can just add it to our back end code.

Search for SOLIB in remote.c and see if that helps.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: auto-solib-add when attaching to inferior
  2003-04-16 19:04 ` Daniel Jacobowitz
@ 2003-04-16 22:05   ` Kris Warkentin
  2003-04-16 22:14     ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Kris Warkentin @ 2003-04-16 22:05 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

> > When I run a remote process using our QNX remote protocol, I get a solib
> > breakpoint set properly and from then on, if solibs are loaded, their
> > symbols automatically get added (auto-solib-add is on by default).  If,
> > however, I attach to the process, even if auto-solib-add is on, I still
have
> > to go 'shared' to get them to load.  If I 'maint info breakpoints' on
the
> > attached process, I see that there isn't a shlib-events breakpoint set
on
> > the attached process so I assume either enable_break() isn't getting
called
> > or is failing.
> >
> > I'm still building my debug gdb to test but I'm hoping someone will tell
me,
> > "Oh, when you attach you should always call such-and-such function" and
I
> > can just add it to our back end code.
>
> Search for SOLIB in remote.c and see if that helps.

I didn't see an explicit "remote_ops.to_attach" in remote.c function but I
notice that you're doing SOLIB_CREATE_INFERIOR_HOOK.  We also do that when
we create a process.  Just for chuckles, I tried to do that in our to_attach
function but it didn't work.  If I call it before I set inferior_ptid to the
child process, I get a solib_event_bkpt that is relocated incorrectly.  If I
do it after, then for some reason the target_wait() function spins blocks
forever trying to read from the inferior.  On the bright side, the
relocation of the solib breakpoint is done correctly (I printed the
breakpoint_chain) but the lockup is a real puzzle.  I'm wondering if somehow
my host and target are getting out of sync.  Fun, fun, fun.  I think I'm
going to have to attach to our remote agent and see what the heck it thinks
its doing.

cheers,

Kris

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

* Re: auto-solib-add when attaching to inferior
  2003-04-16 22:05   ` Kris Warkentin
@ 2003-04-16 22:14     ` Daniel Jacobowitz
  2003-04-17 14:12       ` Kris Warkentin
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-04-16 22:14 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: gdb

On Wed, Apr 16, 2003 at 06:11:56PM -0400, Kris Warkentin wrote:
> > > When I run a remote process using our QNX remote protocol, I get a solib
> > > breakpoint set properly and from then on, if solibs are loaded, their
> > > symbols automatically get added (auto-solib-add is on by default).  If,
> > > however, I attach to the process, even if auto-solib-add is on, I still
> have
> > > to go 'shared' to get them to load.  If I 'maint info breakpoints' on
> the
> > > attached process, I see that there isn't a shlib-events breakpoint set
> on
> > > the attached process so I assume either enable_break() isn't getting
> called
> > > or is failing.
> > >
> > > I'm still building my debug gdb to test but I'm hoping someone will tell
> me,
> > > "Oh, when you attach you should always call such-and-such function" and
> I
> > > can just add it to our back end code.
> >
> > Search for SOLIB in remote.c and see if that helps.
> 
> I didn't see an explicit "remote_ops.to_attach" in remote.c function but I
> notice that you're doing SOLIB_CREATE_INFERIOR_HOOK.  We also do that when
> we create a process.  Just for chuckles, I tried to do that in our to_attach
> function but it didn't work.  If I call it before I set inferior_ptid to the
> child process, I get a solib_event_bkpt that is relocated incorrectly.  If I
> do it after, then for some reason the target_wait() function spins blocks
> forever trying to read from the inferior.  On the bright side, the
> relocation of the solib breakpoint is done correctly (I printed the
> breakpoint_chain) but the lockup is a real puzzle.  I'm wondering if somehow
> my host and target are getting out of sync.  Fun, fun, fun.  I think I'm
> going to have to attach to our remote agent and see what the heck it thinks
> its doing.

Remember that you don't use attach with the normal remote protocol. 
When you to_open the target has already started.  For your agent it
sounds like you need to do it at to_attach time; but why isn't the one
in infcmd.c:attach_command working?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: auto-solib-add when attaching to inferior
  2003-04-16 22:14     ` Daniel Jacobowitz
@ 2003-04-17 14:12       ` Kris Warkentin
  2003-04-17 18:14         ` Kris Warkentin
  0 siblings, 1 reply; 6+ messages in thread
From: Kris Warkentin @ 2003-04-17 14:12 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

> Remember that you don't use attach with the normal remote protocol.
> When you to_open the target has already started.  For your agent it
> sounds like you need to do it at to_attach time; but why isn't the one
> in infcmd.c:attach_command working?

Good question.  For some reason locate_base() seems to be failing.  Maybe
that's the answer to the puzzle.  It looks like the SOLIB_ADD() in
attach_command() should do the right thing.  I'll chase it deeper from that
end.

Thanks,

Kris

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

* Re: auto-solib-add when attaching to inferior
  2003-04-17 14:12       ` Kris Warkentin
@ 2003-04-17 18:14         ` Kris Warkentin
  0 siblings, 0 replies; 6+ messages in thread
From: Kris Warkentin @ 2003-04-17 18:14 UTC (permalink / raw)
  To: Kris Warkentin, Daniel Jacobowitz; +Cc: gdb

> > Remember that you don't use attach with the normal remote protocol.
> > When you to_open the target has already started.  For your agent it
> > sounds like you need to do it at to_attach time; but why isn't the one
> > in infcmd.c:attach_command working?
>
> Good question.  For some reason locate_base() seems to be failing.  Maybe
> that's the answer to the puzzle.  It looks like the SOLIB_ADD() in
> attach_command() should do the right thing.  I'll chase it deeper from
that
> end.

Well, I think I've found the cause but only part of the solution.  When
solib-svr4.c:elf_locate_base() is called, the dynamic pointer stored in the
DT_DEBUG section is zero.  This is because QNX has a util called 'on' which
can spawn a process in a 'held' state where it's stopped on the very first
instruction.  This is handy if you want to attach to a process before it
gets going but in this case, the loader hasn't been run yet so the DT_DEBUG
section isn't filled in.  If I attach to a process that is running properly,
I get my solibs loaded up and everything is fine.

This, however, presents the next problem: the shlib_event breakpoint not
being set.  On our native gdb, if I just add a SOLIB_CREATE_INFERIOR_HOOK
call to the attach function, it works properly.  The remote is another case.
I'm still thinking it's a sync issue with the debug agent though.

Thanks for the help.  You definitely got me barking up the right tree.

cheers,

Kris

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

end of thread, other threads:[~2003-04-17 18:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-16 18:59 auto-solib-add when attaching to inferior Kris Warkentin
2003-04-16 19:04 ` Daniel Jacobowitz
2003-04-16 22:05   ` Kris Warkentin
2003-04-16 22:14     ` Daniel Jacobowitz
2003-04-17 14:12       ` Kris Warkentin
2003-04-17 18:14         ` Kris Warkentin

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