From: "Sérgio Durigan Júnior" <sergiodj@linux.vnet.ibm.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/4] 'catch syscall' feature -- Architecture-independent part
Date: Fri, 07 Nov 2008 03:30:00 -0000 [thread overview]
Message-ID: <1226028565.32321.86.camel@miki> (raw)
In-Reply-To: <200811041617.10621.pedro@codesourcery.com>
Hi Pedro,
On Tue, 2008-11-04 at 16:17 +0000, Pedro Alves wrote:
> On Tuesday 04 November 2008 04:31:19, Sérgio Durigan Júnior wrote:
> > +static enum print_stop_action
> > +print_it_catch_syscall (struct breakpoint *b)
> > +{
> > + /* This is needed because we want to know in which state a
> > + syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY
> > + or TARGET_WAITKIND_SYSCALL_RETURN, and depending on it we
> > + must print "called syscall" or "returned from syscall". */
> > + struct thread_info *th_info = find_thread_pid (inferior_ptid);
> > + const char *syscall_name =
> > + gdbarch_syscall_name_from_number (current_gdbarch, b->syscall_number);
> > +
> > + annotate_catchpoint (b->number);
> > + printf_filtered (_("\nCatchpoint %d ("), b->number);
> > +
> > + if (th_info->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY)
> > + printf_filtered (_("calling "));
> > + else
> > + printf_filtered (_("returned from "));
>
> This bit left me wondering about the below. Take these with a
> grain of salt, please :-)
Of course :-). And I'm sorry for taking so long to respond.
> syscall_state has been placed in struct thread_info, and linux-nat.c
> toggles it between entry/exit, but that's mainly because on linux, the
> same trap is sent in both cases. In the ttrace case (inf-ttrace.c), for
> example, you have distinct TTEVT_SYSCALL_ENTRY and TTEVT_SYSCALL_RETURN
> events at the target level. Shouldn't we be doing the same on linux? That
> is, move 'syscall_state' to 'struct lwp_info', thus making it
> private to the linux-nat.c implementation, and have the core side
> always distinguish them from the TARGET_WAITKIND_SYSCALL_* type
> returned from target_wait? It looks weird for the target side to
> be writing to a thread_info directly. I always tend to ponder how I'd
> do these things in gdbserver to validate target_ops designs --- I guess
> I wouldn't be able to tweak gdb's common code from there. :-)
>
> Was it because you need to access it in print_it_catch_syscall? You
> could get it from the last target event like you do in
> breakpoint_hit_catch_syscall, I guess.
Ok, I'll try to put the syscall_state in 'struct lwp_info'. Honestly, I
don't remember now why I've chosen to put this variable inside
thread_info, but of course you're way more capable of telling me how to
make my design be more clever (and look more like GDB) :-).
> Also, I'm not 100% sure, but I think you can crash in
> linux-nat.c:linux_handle_extended_wait if an lwp happens to hit a syscall
> you're catching before it's corresponding thread has been added to the
> thread list in linux-thread-db.c.
I'm not sure I'm able to answer this, but that's a problem that I wasn't
considering. Thanks for the hint.
> Also, while we're on to speaking of these matters, would it make sense
> to be able to catch only syscall entry or syscall return events
> at the UI level? That is, separate "catch syscall entry",
> "catch syscall return" or some such?
IMHO, we could postpone this for now. Honestly I'm pretty satisfied with
the feature right now, but of course my opinion shouldn't count that
much ;-).
Thanks for your comments, I'll fix my code as soon as I can.
Regards,
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
next prev parent reply other threads:[~2008-11-07 3:30 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 4:32 Sérgio Durigan Júnior
2008-11-04 16:17 ` Pedro Alves
2008-11-07 3:30 ` Sérgio Durigan Júnior [this message]
2008-11-07 12:12 ` Pedro Alves
2008-11-07 13:30 ` Daniel Jacobowitz
2008-11-08 15:35 ` Sérgio Durigan Júnior
2008-11-04 17:57 ` Tom Tromey
2008-11-04 21:55 ` Thiago Jung Bauermann
2008-11-04 22:33 ` Tom Tromey
2008-11-05 19:05 ` Tom Tromey
2008-11-05 19:13 ` Sérgio Durigan Júnior
2008-11-07 3:41 ` Sérgio Durigan Júnior
2008-11-07 3:39 ` Sérgio Durigan Júnior
2008-11-07 18:21 ` Tom Tromey
2008-11-04 21:13 ` Eli Zaretskii
2008-11-04 22:12 ` Thiago Jung Bauermann
2008-11-04 22:22 ` Eli Zaretskii
2008-11-04 22:35 ` Daniel Jacobowitz
2008-11-05 4:19 ` Eli Zaretskii
2008-11-05 13:34 ` Sérgio Durigan Júnior
2008-11-05 18:42 ` Eli Zaretskii
2008-11-08 19:31 ` Mark Kettenis
2008-11-05 14:55 ` Daniel Jacobowitz
2008-11-05 18:43 ` Eli Zaretskii
2008-11-05 18:59 ` Daniel Jacobowitz
2008-11-05 19:11 ` Eli Zaretskii
2008-11-06 23:03 ` Mark Kettenis
2008-11-04 22:31 ` Pedro Alves
2008-11-05 4:10 ` Eli Zaretskii
2008-11-05 12:29 ` Pedro Alves
2008-11-05 18:38 ` Eli Zaretskii
2008-11-05 18:57 ` Pedro Alves
2008-11-05 19:10 ` Eli Zaretskii
2008-11-05 19:34 ` Pedro Alves
2008-11-05 20:36 ` Eli Zaretskii
2008-11-05 21:10 ` Pedro Alves
2008-11-06 4:27 ` Eli Zaretskii
2008-11-06 14:32 ` Pedro Alves
2008-11-07 9:59 ` Eli Zaretskii
2008-11-07 10:10 ` Pedro Alves
2008-11-05 13:32 ` Mark Kettenis
-- strict thread matches above, loose matches on Subject: below --
2008-09-30 18:12 Sérgio Durigan Júnior
2008-10-02 21:13 ` Joel Brobecker
2008-10-03 2:33 ` Sérgio Durigan Júnior
2008-10-03 6:07 ` Joel Brobecker
2008-10-03 17:52 ` Daniel Jacobowitz
2008-10-04 23:07 ` Sérgio Durigan Júnior
2008-10-04 23:04 ` Sérgio Durigan Júnior
2008-10-06 17:22 ` Joel Brobecker
2008-10-10 13:12 ` Daniel Jacobowitz
2008-10-10 15:28 ` Sérgio Durigan Júnior
2008-10-12 2:26 ` Sérgio Durigan Júnior
2008-10-15 5:40 ` Joel Brobecker
2008-10-16 3:35 ` Sérgio Durigan Júnior
2008-10-16 12:37 ` Daniel Jacobowitz
2008-10-16 15:17 ` Daniel Jacobowitz
2008-10-16 16:28 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1226028565.32321.86.camel@miki \
--to=sergiodj@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox