From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11524 invoked by alias); 6 Jun 2008 07:08:19 -0000 Received: (qmail 11181 invoked by uid 22791); 6 Jun 2008 07:08:17 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 06 Jun 2008 07:07:50 +0000 Received: from spaceape11.eur.corp.google.com (spaceape11.eur.corp.google.com [172.28.16.145]) by smtp-out.google.com with ESMTP id m5677hgA024936 for ; Fri, 6 Jun 2008 08:07:43 +0100 Received: from rv-out-0708.google.com (rvbf25.prod.google.com [10.140.82.25]) by spaceape11.eur.corp.google.com with ESMTP id m5677gUH024415 for ; Fri, 6 Jun 2008 08:07:42 +0100 Received: by rv-out-0708.google.com with SMTP id f25so908626rvb.32 for ; Fri, 06 Jun 2008 00:07:41 -0700 (PDT) Received: by 10.142.214.5 with SMTP id m5mr946090wfg.342.1212736061803; Fri, 06 Jun 2008 00:07:41 -0700 (PDT) Received: by 10.142.102.9 with HTTP; Fri, 6 Jun 2008 00:07:41 -0700 (PDT) Message-ID: <2e7be40c0806060007n1a237cbfya34c58208a57add1@mail.gmail.com> Date: Fri, 06 Jun 2008 07:08:00 -0000 From: "Chris Demetriou" To: "Masao Uebayashi" Subject: Re: mips sim syscall Cc: gdb@sourceware.org In-Reply-To: <20080606.152013.212798583.uebayasi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080606.152013.212798583.uebayasi@gmail.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-06/txt/msg00039.txt.bz2 Oooh, for once a question I can help answer! Let me warn you, my knowledge of this subject is pretty old, but looking at the code it looks good enough. On Thu, Jun 5, 2008 at 23:20, Masao Uebayashi wrote: > Does GDB MIPS simulator support system call emulation? If I read code > (sim/mips/interp.c) correctly, if SystemCall or Trap is triggered, it > just looks at the exception vector and execute (emulate) that code. > This won't work for *nix like environment, right? The MIPS sim does have syscall emulation, yes. As you note, it typically vectors exceptions as described by the MIPS architecture. One glaring exception is the handling of "RSVD_INSTRUCTION", a reserved opcode (really, family of opcodes) used by the simulator to provide system call emulation. (In the MIPS sim, this is *not* done using the MIPS syscall instruction.) For this path, look for RSVD_INSTRUCTION in signal_exception. That code sends the requested operation off to sim_monitor, which provides emulation for the appropriate syscall. This is the mechanism used by to run the compiler tests on the MIPS simulator, e.g., runtest using the mips-sim target. For more information, see http://gcc.gnu.org/simtest-howto.html. Under the covers, how this work is that libgloss code is configured to use one of several standard-ish MIPS firmware monitors, and jumps to known service addresses that they provide. sim/mips provides stubs at those locations which use RSVD_INSTRUCTION to emulate the requested operations. (This enables, e.g., code compiled for the IDT mips monitor to run on both the hardware and on the simulator.) IMO, being able to emulate any particular OS environmnent (without booting the OS itself 8-) just wasn't worth the effort. It's a pain to emulate enough syscalls and enough of the operating environment to be useful. The only time i *really* wanted this IIRC was when I was trying to debug dynamic loader issues, and to do that you'd have to emulate a *bunch* of stuff. I don't quite recall the status of what got integrated, but the exception handling, architecture emulation, and device emulation we developed at SiByte/Broadcom was sufficient to enable a real OS kernel to be run on the board. E.g., we could boot a MIPS Linux or NetBSD kernel on our simulator. Programs running in userland on that run syscalls, of course. 8-) (You could even boot all the way to multi-user, getting your root fs, etc., from NFS... IIRC we contributed all that code to GDB, but I never got around to integrating all of it.) We contributed all the code back, but I don't recall how much of it I integrated before I moved on. (IIRC, the contributed-back bits were supposed to be put up in the contrib area on the FTP site, don't know if they ever made it there.) If you're interested in pursuing any of that work, let me know. I have ... little interest in actually working on that code anymore, but could probably answer questions about it. good luck, chris