Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: David Smith <dsmith@redhat.com>
To: GDB Patches <gdb-patches@sources.redhat.com>
Subject: [RFC, RFA] multi-arch PREPARE_TO_PROCEED()
Date: Thu, 29 Mar 2001 18:25:00 -0000	[thread overview]
Message-ID: <3AC39D32.8090709@redhat.com> (raw)

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  <dsmith@redhat.com>

	* 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 <deephan@erols.com>
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=<args> to gdb.
It assumes that <args> is one argument (i.e., is in quotes, or has the
spaces escaped).
--args acts just like calling 'set args <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  <david@llamedos.org>

	* 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 <windows.h>		/* for MAX_PATH */
  #include <sys/cygwin.h>		/* 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);


             reply	other threads:[~2001-03-29 18:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-29 18:25 David Smith [this message]
2001-03-30 12:16 ` Andrew Cagney
2001-04-02  7:28   ` David Smith
2001-04-04 14:54     ` Andrew Cagney
2001-04-06 10:55       ` David Smith

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=3AC39D32.8090709@redhat.com \
    --to=dsmith@redhat.com \
    --cc=gdb-patches@sources.redhat.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