public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@codesourcery.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org, rearnsha@arm.com,
	matthew.gretton-dann@arm.com
Subject: Re: [rfc/rfa] Use ARM exception tables as GDB unwinder
Date: Fri, 11 Mar 2011 22:35:00 -0000	[thread overview]
Message-ID: <20110311221709.GZ25422@caradoc.them.org> (raw)
In-Reply-To: <201103091843.p29Ih4l9002682@d06av02.portsmouth.uk.ibm.com>

On Wed, Mar 09, 2011 at 07:43:04PM +0100, Ulrich Weigand wrote:
> Daniel Jacobowitz wrote:
> > On Wed, Dec 01, 2010 at 05:45:31PM +0100, Ulrich Weigand wrote:
> > > Hmm, looking at DO_CALL a bit more I think this can actually be handled
> > > inline just fine:
> > > 
> > > #define DO_CALL(syscall_name, args)             \
> > >     DOARGS_##args;                              \
> > >     mov ip, r7;                                 \
> > >     cfi_register (r7, ip);                      \
> > >     ldr r7, =SYS_ify (syscall_name);            \
> > >     swi 0x0;                                    \
> > >     mov r7, ip;                                 \
> > >     cfi_restore (r7);                           \
> > >     UNDOARGS_##args
> > > 
> > > Note the calls to DOARGS_... / UNDOARGS_..., which actually save and
> > > restore registers on the stack anyway (just not r7).  Why not simply
> > > have (a variant) of [UN]DOARGS_... save r7 to the stack, and then
> > > provide both correct CFI and ARM unwind records for it?  [ Saving
> > > to IP would then be no longer necessary. ]
> > > 
> > > Am I missing something here?
> > 
> > I don't think you are missing anything, except a couple of cycles.
> > 
> > We save r7 in ip because it ought to be faster loading and storing it
> > on the stack.  But we already take the position that the system call
> > overhead is substantial compared to DO_CALL... so the extra two memory
> > ops do not seem like a huge loss to me, especially if we can save on
> > code size.
> 
> I finally got around to continue working on this.  The patch below
> implements this approach.  However, this uncovered one rather fundamental
> problem:  when implementing the vfork system call, the syscall stub
> must *not* put anything on the stack or else things will break due to
> the peculiar semantics of vfork:
> 
> The system will return to execute solely the child at first, until such
> time as the child calls exec; and in the meantime, the child will share
> the parent's address space.  Now if vfork pushed something on the stack,
> the child will pop that value, and go on to overwrite that stack location
> with other stuff.  Once the parent later gets to run as well, it will
> restore a corrupted value into r7 ...
> 
> I'm not quite sure if there is a way around this ... Any suggestions
> would be appreciated.

Hmm, I wonder if that's why I did it this way before.

Can we use a different technique to implement vfork than for other
system calls?  I don't see a reason they all need to be the same.

> As Andreas notes, DOARGS is called with a 0 argument.  However, I'm
> wondering if there isn't a bug anyway:
> 
>   __##syscall_name##_nocancel:                                          \
>     .cfi_sections .debug_frame;                                         \
>     cfi_startproc;                                                      \
>     DO_CALL (syscall_name, args);                                       \
>     PSEUDO_RET;                                                         \
>     cfi_endproc;                                                        \
>   .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;      \
> 
> Shouldn't there be a 
>     cmn r0, $4096;
> in between the DO_CALL and the PSEUDO_RET?

It does look that way.

> Also, some of the code in the linuxthreads/ directories seems to be broken,
> but I'm wondering why those are still there in the first place; linuxthreads
> support has been removed from glibc a long time ago, hasn't it?

Yes.  Those files should just be removed.

-- 
Daniel Jacobowitz
Mentor Graphics

  reply	other threads:[~2011-03-11 22:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20  0:01 Ulrich Weigand
2010-10-20 11:14 ` Matthew Gretton-Dann
2010-10-21 15:39   ` Ulrich Weigand
2010-10-20 13:27 ` Daniel Jacobowitz
2010-10-21 15:51   ` Ulrich Weigand
2010-10-21 16:02     ` Daniel Jacobowitz
2010-10-21 18:26       ` Ulrich Weigand
2010-10-21 18:42         ` Daniel Jacobowitz
2010-10-21 20:29           ` Ulrich Weigand
2010-10-21 20:43             ` Daniel Jacobowitz
2010-12-01 16:45               ` Ulrich Weigand
2010-12-12  4:21                 ` Daniel Jacobowitz
2010-12-12 12:24                   ` Andreas Schwab
2011-03-09 19:11                   ` Ulrich Weigand
2011-03-11 22:35                     ` Daniel Jacobowitz [this message]
2011-03-19  4:25                       ` Ulrich Weigand
2011-03-21 14:51                         ` Daniel Jacobowitz
2011-03-21 20:06                           ` Ulrich Weigand
2010-10-21 22:26       ` Ulrich Weigand
2010-10-26 13:43         ` Daniel Jacobowitz

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=20110311221709.GZ25422@caradoc.them.org \
    --to=dan@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=matthew.gretton-dann@arm.com \
    --cc=rearnsha@arm.com \
    --cc=uweigand@de.ibm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).