From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30535 invoked by alias); 3 Jul 2008 18:04:45 -0000 Received: (qmail 30440 invoked by uid 22791); 3 Jul 2008 18:04:44 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 03 Jul 2008 18:04:19 +0000 Received: (qmail 30685 invoked from network); 3 Jul 2008 18:04:17 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Jul 2008 18:04:17 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Make remote-sim target always have a thread Date: Thu, 03 Jul 2008 18:04:00 -0000 User-Agent: KMail/1.9.9 References: <200807031623.29562.pedro@codesourcery.com> In-Reply-To: <200807031623.29562.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_kSRbIWgbgKwjarZ" Message-Id: <200807031904.20942.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00042.txt.bz2 --Boundary-00=_kSRbIWgbgKwjarZ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 3417 A Thursday 03 July 2008 16:23:29, Pedro Alves wrote: > This patch makes the monitor targets always register an execution control > task in GDB's thread list. Needed to clean up inferior control, and > get rid of context switching. > > I confirmed that it builds with x86_64-unknown-linux-gnu x h8300-elf cross, > and that it doesn't introduce any new warnings (this file is built without > -Werror). > > As I said in my previous email, I don't even know how to test this, > although I don't except to be any fallout. > > Does it look OK? Can anyone instruct me how to test this; or do a test > spin for me; or claim that it looks ok, and we'll fix problems as > they arise? :-) This patch does the same to remote-sim. (applies on top of the monitor patch) Managed to get myself an arm-elf toolchain and tested with a x86_64-unknow-linux-gnu x arm-elf, --target_board=arm-sim, without regressions. Does it look OK? Default results look much better than I was expecting without tweaking the boardfile. FAIL: gdb.base/args.exp: argc for one empty FAIL: gdb.base/args.exp: argv[2] for one empty FAIL: gdb.base/args.exp: argv[3] for one empty FAIL: gdb.base/args.exp: argc for two empty FAIL: gdb.base/args.exp: argv[2] for two empty FAIL: gdb.base/args.exp: argv[3] for two empty FAIL: gdb.base/args.exp: argv[4] for two empty FAIL: gdb.base/args.exp: argv[2] for one empty (with single quotes) FAIL: gdb.base/args.exp: argv[2] for two empty (with single quotes) FAIL: gdb.base/args.exp: argv[3] for two empty (with single quotes) FAIL: gdb.base/chng-syms.exp: running with invalidated bpt condition after executable changes FAIL: gdb.base/fileio.exp: Creating already existing file returns EEXIST FAIL: gdb.base/fileio.exp: Open directory for writing returns EISDIR FAIL: gdb.base/fileio.exp: Open for write but no write permission returns EACCES FAIL: gdb.base/fileio.exp: Writing to a file FAIL: gdb.base/fileio.exp: Write using invalid file descriptor returns EBADF FAIL: gdb.base/fileio.exp: Reading from a file FAIL: gdb.base/fileio.exp: Read using invalid file descriptor returns EBADF FAIL: gdb.base/fileio.exp: Lseeking END a file FAIL: gdb.base/fileio.exp: Closing an invalid file descriptor returns EBADF FAIL: gdb.base/fileio.exp: Stat a file FAIL: gdb.base/fileio.exp: Fstat an open file FAIL: gdb.base/fileio.exp: Fstat an invalid file descriptor returns EBADF FAIL: gdb.base/fileio.exp: Isatty (invalid fd) FAIL: gdb.base/fileio.exp: Isatty (open file) FAIL: gdb.base/fileio.exp: System says shell is available FAIL: gdb.base/fileio.exp: System(3) call FAIL: gdb.base/fileio.exp: System with invalid command returns 127 FAIL: gdb.base/fileio.exp: Rename a file FAIL: gdb.base/fileio.exp: Renaming a file to existing directory returns EISDIR FAIL: gdb.base/fileio.exp: Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST FAIL: gdb.base/fileio.exp: Renaming a directory to a subdir of itself returns EINVAL FAIL: gdb.base/fileio.exp: Renaming a nonexistant file returns ENOENT FAIL: gdb.base/fileio.exp: Unlinking a file in a directory w/o write access returns EACCES FAIL: gdb.base/fileio.exp: Unlinking a nonexistant file returns ENOENT # of expected passes 2493 # of unexpected failures 35 # of expected failures 3 # of untested testcases 3 # of unsupported tests 39 (only board tweakable failures, cool) -- Pedro Alves --Boundary-00=_kSRbIWgbgKwjarZ Content-Type: text/x-diff; charset="utf-8"; name="remote_sim_always_a_thread.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="remote_sim_always_a_thread.diff" Content-length: 5105 2008-07-03 Pedro Alves * remote-sim.c: Include gdbthread.h. (remote_sim_ptid): New global. (gdbsim_create_inferior): Silently add the main task to GDB's thread list. (gdbsim_close, gdbsim_mourn_inferior): Silently delete the main task from GDB's thread list. (gdbsim_resume): Adjust to use remote_sim_ptid. (gdbsim_thread_alive, gdbsim_pid_to_str): New. (init_gdbsim_ops): Register gdbsim_thread_alive and gdbsim_pid_to_str. (_initialize_remote_sim): Initialize remote_sim_ptid. * Makefile.in (remote-sim.o): Depend on $(gdbthread_h). --- gdb/Makefile.in | 2 +- gdb/remote-sim.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 4 deletions(-) Index: src/gdb/remote-sim.c =================================================================== --- src.orig/gdb/remote-sim.c 2008-07-03 18:21:37.000000000 +0100 +++ src/gdb/remote-sim.c 2008-07-03 18:47:41.000000000 +0100 @@ -41,6 +41,7 @@ #include "sim-regno.h" #include "arch-utils.h" #include "readline/readline.h" +#include "gdbthread.h" /* Prototypes */ @@ -115,6 +116,12 @@ static int program_loaded = 0; back to the other sim_foo routines. */ static SIM_DESC gdbsim_desc = 0; +/* This is the ptid we use while we're connected to the simulator. + It's value is arbitrary, as the simulator target don't have a + notion or processes or threads, but we need something non-null to + place in inferior_ptid. */ +static ptid_t remote_sim_ptid; + static void dump_mem (char *buf, int len) { @@ -452,7 +459,8 @@ gdbsim_create_inferior (char *exec_file, (exec_file ? exec_file : "(NULL)"), args); - gdbsim_kill (); + if (ptid_equal (inferior_ptid, remote_sim_ptid)) + gdbsim_kill (); remove_breakpoints (); init_wait_for_inferior (); @@ -471,7 +479,9 @@ gdbsim_create_inferior (char *exec_file, argv = NULL; sim_create_inferior (gdbsim_desc, exec_bfd, argv, env); - inferior_ptid = pid_to_ptid (42); + inferior_ptid = remote_sim_ptid; + add_thread_silent (inferior_ptid); + target_mark_running (&gdbsim_ops); insert_breakpoints (); /* Needed to get correct instruction in cache */ @@ -579,6 +589,8 @@ gdbsim_close (int quitting) } end_callbacks (); + if (!ptid_equal (inferior_ptid, null_ptid)) + delete_thread_silent (inferior_ptid); generic_mourn_inferior (); } @@ -612,7 +624,7 @@ static int resume_step; static void gdbsim_resume (ptid_t ptid, int step, enum target_signal siggnal) { - if (PIDGET (inferior_ptid) != 42) + if (!ptid_equal (inferior_ptid, remote_sim_ptid)) error (_("The program is not being run.")); if (remote_debug) @@ -815,6 +827,7 @@ gdbsim_mourn_inferior (void) if (remote_debug) printf_filtered ("gdbsim_mourn_inferior:\n"); + delete_thread_silent (inferior_ptid); remove_breakpoints (); target_mark_exited (&gdbsim_ops); generic_mourn_inferior (); @@ -849,6 +862,35 @@ simulator_command (char *args, int from_ registers_changed (); } +/* Check to see if a thread is still alive. */ + +static int +gdbsim_thread_alive (ptid_t ptid) +{ + if (ptid_equal (ptid, remote_sim_ptid)) + /* The simulators' task is always alive. */ + return 1; + + return 0; +} + +/* Convert a thread ID to a string. Returns the string in a static + buffer. */ + +static char * +gdbsim_pid_to_str (ptid_t ptid) +{ + static char buf[64]; + + if (ptid_equal (remote_sim_ptid, ptid)) + { + xsnprintf (buf, sizeof buf, "Thread
"); + return buf; + } + + return normal_pid_to_str (ptid); +} + /* Define the target subroutine names */ struct target_ops gdbsim_ops; @@ -876,6 +918,8 @@ init_gdbsim_ops (void) gdbsim_ops.to_create_inferior = gdbsim_create_inferior; gdbsim_ops.to_mourn_inferior = gdbsim_mourn_inferior; gdbsim_ops.to_stop = gdbsim_stop; + gdbsim_ops.to_thread_alive = gdbsim_thread_alive; + gdbsim_ops.to_pid_to_str = gdbsim_pid_to_str; gdbsim_ops.to_stratum = process_stratum; gdbsim_ops.to_has_all_memory = 1; gdbsim_ops.to_has_memory = 1; @@ -897,4 +941,8 @@ _initialize_remote_sim (void) add_com ("sim", class_obscure, simulator_command, _("Send a command to the simulator.")); + + /* Yes, 42000 is arbitrary. The only sense out of it, is that it + isn't 0. */ + remote_sim_ptid = ptid_build (42000, 0, 42000); } Index: src/gdb/Makefile.in =================================================================== --- src.orig/gdb/Makefile.in 2008-07-03 18:21:37.000000000 +0100 +++ src/gdb/Makefile.in 2008-07-03 18:24:21.000000000 +0100 @@ -2671,7 +2671,7 @@ remote-sim.o: remote-sim.c $(defs_h) $(i $(gdb_string_h) $(terminal_h) $(target_h) $(gdbcore_h) \ $(gdb_callback_h) $(gdb_remote_sim_h) $(command_h) \ $(regcache_h) $(gdb_assert_h) $(sim_regno_h) $(arch_utils_h) \ - $(readline_h) + $(readline_h) $(gdbthread_h) rs6000-nat.o: rs6000-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \ $(xcoffsolib_h) $(symfile_h) $(objfiles_h) $(libbfd_h) $(bfd_h) \ $(exceptions_h) $(gdb_stabs_h) $(regcache_h) $(arch_utils_h) \ --Boundary-00=_kSRbIWgbgKwjarZ--