Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Tea <teawater@gmail.com>,
	 "Michael Snyder" <msnyder@specifix.com>,
	 "Thiago Jung Bauermann" <bauerman@br.ibm.com>
Subject: Re: GDB record patch 0.1.3.1 for GDB-6.8 release
Date: Fri, 23 May 2008 21:10:00 -0000	[thread overview]
Message-ID: <200805231746.23570.pedro@codesourcery.com> (raw)
In-Reply-To: <daef60380805221954l45136acdra0189596eaec657b@mail.gmail.com>

A Friday 23 May 2008 03:54:06, Tea wrote:
> Hi Pedro,
> I am not very clear your meaning. Could you please write a example for me?

Sure, I'll try.

Think of the target stack roughly as polimorphism.  Each layer
of the stack overrides methods of the layer beneath.  A stratum
concept is used because there is a layering order on the stack, where
a given target implementation can sit at.  E.g., a thread_stratum layer
target always sits above a process_stratum layer target.  The
file_stratum is always below the process_stratum.  When core GDB wants
to wait for a debug event, it calls target_wait.  E.g, on linux native
debugging, that ends up calling linux_nat_wait on non multi-threaded
applications.  If your new target is the topmost on the stack, then 
record_wait would be called instead.

There's some description of it in the gdbint manual in
the "Target Vector Definition" node, but it isn't much complete.
There are more comments describing the struture in target.h.

As I said, if you make "record" sit on the target vector, then a
call to target_wait (), would really be calling record_wait (),
e.g., 

ptid_t
record_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
 if (record_list && (record_list->next || gdb_is_reverse)))
 {
    ... do whatever you were doing in record_wait ...
 }
 else
   return t->beneath->to_wait (ptid, outstatus);
}

Same for target_mourn_inferior, and target_close, at least.

See remote.c:init_remote_ops, and any struct target_ops
instance in GDB (like remote_ops in remote.c) for examples,
or perhaps a more staightforward one as win32-nat.c:win32_ops.

Issuing the "record" command would push the record target on
the stack, and stoprecord would pop it, and normally
target_mourn_inferior and target_detach do it too, although you
probably want to be able to shift to reverse after a
process death.  The new stratum suggestion was so it always sits
above all the others (see target.c:push_target)

record_ops.to_stratum = above_all_or_whatever_new_stratum;
record_ops.to_wait = record_wait;

/* record resume would be were you call record_message.  */
record_ops.to_resume = record_resume;

/* Calls record_close, and pops target record off the stack.  */
record_ops.to_mourn_inferior = record_mourn_inferior;

etc.

At a first glimpse it looks desirable to go this path.
You may get around to even abstract more things that you're doing
in infrun.c.  Take this only as an investigation suggestion.

-- 
Pedro Alves


  reply	other threads:[~2008-05-23 16:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23  8:55 Tea
2008-05-20  4:33 ` Thiago Jung Bauermann
2008-05-20  6:38   ` Daniel Jacobowitz
2008-05-20 15:32     ` Tea
2008-05-20 18:51       ` Michael Snyder
2008-05-21 17:26         ` Tea
2008-05-20 15:33   ` Tea
2008-05-21 17:14   ` Tea
2008-05-21 22:01     ` Michael Snyder
2008-05-21 22:16       ` Thiago Jung Bauermann
2008-05-21 22:40         ` Daniel Jacobowitz
2008-05-22 15:08           ` Thiago Jung Bauermann
2008-05-23  2:54             ` Tea
2008-05-23  4:33               ` Michael Snyder
2008-05-23 14:33                 ` Tea
2008-05-23 16:46                   ` Michael Snyder
2008-05-23 18:16                     ` Tea
2008-05-23  3:52 ` Pedro Alves
2008-05-23 14:31   ` Tea
2008-05-23 21:10     ` Pedro Alves [this message]
2008-06-08  6:53       ` teawater
2008-06-09  0:52         ` Pedro Alves
2008-06-09  3:00           ` Daniel Jacobowitz
2008-06-09 13:58             ` Thiago Jung Bauermann
2008-06-10  2:04               ` Michael Snyder
2008-06-09 22:56             ` Michael Snyder
2008-06-11 11:59           ` teawater
2008-06-11 20:03             ` Michael Snyder
2008-06-12 18:10               ` teawater
2008-06-13  6:08                 ` Michael Snyder
2008-06-14  6:24                   ` teawater
2008-06-14 10:31                     ` Michael Snyder
2008-06-15  3:27                       ` teawater

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=200805231746.23570.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=bauerman@br.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@specifix.com \
    --cc=teawater@gmail.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