From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Smith To: GDB Patches Subject: [RFC, RFA] multi-arch PREPARE_TO_PROCEED() Date: Thu, 29 Mar 2001 18:25:00 -0000 Message-id: <3AC39D32.8090709@redhat.com> X-SW-Source: 2001-03/msg00541.html This patch multi-arch's the PREPARE_TO_PROCEED macro. PREPARE_TO_PROCEED gets called in proceed() (infrun.c:1028). Here's where it gets called (which also explains its use): #ifdef PREPARE_TO_PROCEED /* In a multi-threaded task we may select another thread and then continue or step. But if the old thread was stopped at a breakpoint, it will immediately cause another breakpoint stop without any execution (i.e. it will report a breakpoint hit incorrectly). So we must step over it first. PREPARE_TO_PROCEED checks the current thread against the thread that reported the most recent event. If a step-over is required it returns TRUE and sets the current thread to the old thread. */ if (PREPARE_TO_PROCEED (1) && breakpoint_here_p (read_pc ())) { oneproc = 1; thread_step_needed = 1; } #endif /* PREPARE_TO_PROCEED */ The real problem with this change is that to know whether or not the user has switched threads since the breakpoint was hit, we have to cache the return values of target_wait()/target_wait_hook(). So, I modified handle_inferior_event() to cache the needed information (and I added a function to returned the cached information). The existing implementations (hppa-tdep.c, lin-lwp.c, linux-thread.c, m3-nat.c) cheat a bit by defining their own wait functions. Here's the ChangeLog entry: 2001-03-29 David Smith * arch-utils.c (default_prepare_to_proceed) (generic_prepare_to_proceed): Added new functions. * arch-utils.h: New function declarations for default_prepare_to_proceed() and generic_prepare_to_proceed(). * gdbarch.sh: Added PREPARE_TO_PROCEED. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * inferior.h: Added get_last_target_status() declaration. * infrun.c (get_last_target_status): Added new function. (handle_inferior_event): Saves last pid and waitstatus, which will get returned by get_last_target_status(). -- David Smith dsmith@redhat.com Red Hat, Inc. http://www.redhat.com 256.704.9222 (direct) 256.837.3839 (fax) >From deephan@erols.com Thu Mar 29 21:47:00 2001 From: David Deephanphongs To: gdb-patches@sources.redhat.com Subject: [PATCH] specify arguments to debugee from commandline Date: Thu, 29 Mar 2001 21:47:00 -0000 Message-id: <20010330005457.A21793@llamedos.org> X-SW-Source: 2001-03/msg00542.html Content-length: 4638 This patch will add the option --args= to gdb. It assumes that is one argument (i.e., is in quotes, or has the spaces escaped). --args acts just like calling 'set args ' does from the gdb prompt: gdb --args '--color=never -l gdb' /bin/ls is equivalent to: gdb /bin/ls gdb> set args --color=never -l gdb It also adds a description of --args when 'gdb -h' is run, and adds a description of --args to the manpage. The patch is against the 20010327 snapshot. ======= Changelog ========= 2001-03-30 David Deephanphongs * main.c: (set_inferior_args): Added extern prototype of set_inferior_args. (captured_main): Add --args option to gdb. * infcmd.c: (inferior_args): initialize to zero. (_initialize_infcmd): only call set_inferior_args (xtrdup ("")) if inferior_args is set to zero. * gdb.1, main.c (print_gdb_help): Document --args option ====== Patch ======= diff -c3p gdb-orig/gdb.1 gdb/gdb.1 *** gdb-orig/gdb.1 Tue Mar 6 03:21:07 2001 --- gdb/gdb.1 Fri Mar 30 00:22:00 2001 *************** gdb \- The GNU Debugger *** 38,43 **** --- 38,46 ---- .RB "[\|" "\-d "\c .I dir\c \&\|] + .RB "[\|" "\-args "\c + .I args\c + \&\|] .RB "[\|" \c .I prog\c .RB "[\|" \c *************** Execute GDB commands from file \c *** 264,269 **** --- 267,280 ---- Add \c .I directory\c \& to the path to search for source files. + + + .TP + .BI "\-args=" "args"\c + \& + Set \c + .I args\c + \& as the default arguments for the program to be debugged. .PP .TP diff -c3p gdb-orig/infcmd.c gdb/infcmd.c *** gdb-orig/infcmd.c Wed Mar 21 11:42:38 2001 --- gdb/infcmd.c Thu Mar 29 23:27:07 2001 *************** static void breakpoint_auto_delete_conte *** 121,127 **** /* String containing arguments to give to the program, separated by spaces. Empty string (pointer to '\0') means no args. */ ! static char *inferior_args; /* File name for default use for standard in/out in the inferior. */ --- 121,127 ---- /* String containing arguments to give to the program, separated by spaces. Empty string (pointer to '\0') means no args. */ ! static char *inferior_args = 0; /* File name for default use for standard in/out in the inferior. */ *************** Register name as argument means describe *** 1967,1973 **** add_info ("float", float_info, "Print the status of the floating point unit\n"); ! set_inferior_args (xstrdup ("")); /* Initially no args */ inferior_environ = make_environ (); init_environ (inferior_environ); } --- 1967,1974 ---- add_info ("float", float_info, "Print the status of the floating point unit\n"); ! if (inferior_args == 0) ! set_inferior_args (xstrdup ("")); /* Initially no args */ inferior_environ = make_environ (); init_environ (inferior_environ); } diff -c3p gdb-orig/main.c gdb/main.c *** gdb-orig/main.c Tue Mar 6 03:21:10 2001 --- gdb/main.c Fri Mar 30 00:14:39 2001 *************** static void print_gdb_help (struct ui_fi *** 89,94 **** --- 89,98 ---- extern int enable_external_editor; extern char *external_editor_command; + /* Used to set the arguments to the inferior program (i.e., the program that + is being debugged.) */ + extern char *set_inferior_args (char *newargs); + #ifdef __CYGWIN__ #include /* for MAX_PATH */ #include /* for cygwin32_conv_to_posix_path */ *************** captured_main (void *data) *** 284,289 **** --- 288,294 ---- {"windows", no_argument, &use_windows, 1}, {"statistics", no_argument, 0, 13}, {"write", no_argument, &write_files, 1}, + {"args", required_argument, 0, 14}, /* Allow machine descriptions to add more options... */ #ifdef ADDITIONAL_OPTIONS ADDITIONAL_OPTIONS *************** captured_main (void *data) *** 325,330 **** --- 330,339 ---- display_time = 1; display_space = 1; break; + case 14: + /* Set the arguments for the inferior program. */ + set_inferior_args ( xstrdup (optarg) ); + break; case 'f': annotation_level = 1; /* We have probably been invoked from emacs. Disable window interface. */ *************** Options:\n\n\ *** 824,829 **** --- 833,841 ---- -w Use a window interface.\n\ --write Set writing into executable and core files.\n\ --xdb XDB compatibility mode.\n\ + ", stream); + fputs_unfiltered ("\ + --args=args Set arguments to give debugged program when it is run.\n\ ", stream); #ifdef ADDITIONAL_OPTION_HELP fputs_unfiltered (ADDITIONAL_OPTION_HELP, stream);