From: Mike Frysinger <vapier@gentoo.org>
To: gdb@sourceware.org
Cc: "Steve Ellcey " <sellcey@mips.com>
Subject: Re: Simulator question about argc/argv
Date: Fri, 31 May 2013 23:55:00 -0000 [thread overview]
Message-ID: <201305311955.29482.vapier@gentoo.org> (raw)
In-Reply-To: <201305311453.05333.vapier@gentoo.org>
[-- Attachment #1: Type: Text/Plain, Size: 3143 bytes --]
On Friday 31 May 2013 14:53:04 Mike Frysinger wrote:
> On Friday 31 May 2013 12:47:54 Steve Ellcey wrote:
> > Some new tests have been added to the GCC testsuite (cilk tests) that
> > check the value of argc and they expect it to be 1 if there are no
> > arguments to the test program (and there are none) but I am getting 0
> > when I run the tests under the gnu simulator. Does anyone know why
> > this is? I don't know if this is specific to my target (mips-mti-elf)
> > or a general simulator problem. Perhaps it is related to my linker
> > script? The mips-mti-elf target is built with newlib. Could someone
> > else who uses the gnu simulator and newlib try this. It works fine for
> > me under the qemu simulator.
>
> unfortunately, the argc/argv handling tends to be target specific and
> spread across newlib, libgloss, and the sim (target specific pieces). you
> might even see different behavior if the env is gdb rather than the run
> frontend :).
>
> i'd have to dig into the specific mips lower startup code to see how it
> transfers things, but this does work for Blackfin targets:
ok, there's a bit of history here :). you can start here:
http://sourceware.org/ml/newlib/2012/msg00134.html
for the Blackfin overview:
on the libgloss side of things:
* _start in the crt0 used by the sim calls a Blackfin-libgloss func named
__setup_argv_and_call_main
* __setup_argv_and_call_main uses the syscalls SYS_argc, SYS_argn, and
SYS_argnlen to request info from the sim and copies the contents to storage it
has allocated locally
* the code then calls the real main() with the populated argc/argv values
* profit!
on the sim side of things:
* at startup (see sim_open()), save a copy of the argc/argv into the active
sim state (see sim_analyze_program() and STATE_PROG_ARGV())
* also in semi-startup (see sim_create_inferior()), we have to handle an edge
case where the sim is being started up by `gdb` rather than `run`
* the code that responds to syscalls looks for these SYS_arg* and returns
values from STATE_PROG_ARGV()
a quick survey of libgloss/newlib shows:
* SYS_arg{c, n, nlen}: implemented by Blackfin and SuperH
* SYS_arg{v, vlen}: implemented by d10v (and defined by arm & i960, although i
don't see implementation for it)
while a survey of the sim shows:
* common code has implementations of SYS_arg{v, vlen}, but they're disabled
* Blackfin & SuperH implement SYS_arg{c, n, nlen}
* a few random sims mark out SYS_arg{v, vlen} as in "syscall #13 is SYS_argv",
but don't actually implement any handling for it
this of course doesn't include random ports/patches that people like to carry
but not post upstream
however, considering Jie's findings in the referenced thread, and no one has
spoken up since, and it seems everyone's sim (except for Blackfin & SuperH)
have been broken, then i guess it's time to call it. let's recommend people
implement SYS_arg{c, n, nlen}, and document the process. hell, i really need
to bite my tongue and write *any* sim documentation as i don't believe anyone
has ever written any :(.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-05-31 23:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 16:48 Steve Ellcey
2013-05-31 16:50 ` Andrew Pinski
2013-05-31 18:53 ` Mike Frysinger
2013-05-31 18:54 ` Mike Frysinger
2013-05-31 23:55 ` Mike Frysinger [this message]
2013-06-01 2:25 ` Andrew Pinski
2013-06-01 6:21 ` Mike Frysinger
2013-06-03 11:20 ` nick clifton
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=201305311955.29482.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb@sourceware.org \
--cc=sellcey@mips.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