This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(patch) hpjyg15b, was Re: (patch) hpjyg15: hppah-nat.c & related


This is hpjyg15b.  And with diff -w, which should suppress a lot of
diffs ... does patch ignore whitespace differences (in case the context
surrounding the non-whitespace diffs contain whitespace diffs)?

1999-11-08	Jimmy Guo	<guo@cup.hp.com>

        * hppah-nat.c (child_xfer_memory): when reading, also try the
          other way.
          (child_has_execd): cache pathname info, used for the 2nd exec
          event reported by ptrace.
          (child_pid_to_exec_file): make sure ptrace request for
          pathname is made after an exec.

Index: gdb/hppah-nat.c
/opt/gnu/bin/diff -r -w -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/hppah-nat.c gdb/hppah-nat.c
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/hppah-nat.c	Thu Nov 11 16:49:30 1999
--- gdb/hppah-nat.c	Thu Nov 11 15:58:15 1999
***************
*** 363,371 ****
--- 363,380 ----
  				   inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
  	  if (errno)
  	    {
+ 	      /* As above, we may have guessed wrong about code vs. data, so
+               	 try it the other way. */
+ 	      errno = 0;
+ 	      buffer[i] = call_ptrace (addr >= text_end ?
+ 				       PT_RIUSER : PT_RDUSER, 
+ 				       inferior_pid,
+ 				       (PTRACE_ARG3_TYPE) addr, 0);
+ 	      if (errno) {
  		free(buffer);
  		return 0;
  	      }
+ 	    }
  	  QUIT;
  	}
  
***************
*** 697,705 ****
  {
  #if defined(PT_SET_EVENT_MASK)
    int pt_status;
-   ptrace_event_t ptrace_events;
    int nsigs;
    int signum;
  
    /* Instruct the kernel as to the set of events we wish to be
       informed of.  (This support does not exist before HPUX 10.0.
--- 706,714 ----
  {
  #if defined(PT_SET_EVENT_MASK)
    int pt_status;
    int nsigs;
    int signum;
+   ptrace_event_t ptrace_events;
  
    /* Instruct the kernel as to the set of events we wish to be
       informed of.  (This support does not exist before HPUX 10.0.
***************
*** 730,736 ****
  	  (signal_print_state (signum)) ||
  	  (!signal_pass_state (signum)))
  	{
! 	  if (target_signal_p (signum))
  	    sigdelset (&ptrace_events.pe_signals,
  		       target_signal_to_host (signum));
  	}
--- 739,745 ----
  	  (signal_print_state (signum)) ||
  	  (!signal_pass_state (signum)))
  	{
! 	  if (target_signal_exists (signum))
  	    sigdelset (&ptrace_events.pe_signals,
  		       target_signal_to_host (signum));
  	}
***************
*** 1033,1038 ****
--- 1042,1049 ----
       int pid;
       char **execd_pathname;
  {
+   static char saved_pathname[1024];
+ 
    /* This request is only available on HPUX 10.0 and later.  */
  #if !defined(PT_GET_PROCESS_STATE)
    *execd_pathname = NULL;
***************
*** 1054,1061 ****
  
    if (ptrace_state.pe_report_event & PTRACE_EXEC)
      {
!       char *exec_file = target_pid_to_exec_file (pid);
        *execd_pathname = savestring (exec_file, strlen (exec_file));
        return 1;
      }
  
--- 1065,1083 ----
  
    if (ptrace_state.pe_report_event & PTRACE_EXEC)
      {
!       char *exec_file;
! 
!       if (ptrace_state.pe_path_len > 0)
! 	{
! 	  /* RM: ptrace reports 2 exec events per exec. Only the first one
! 	     allows us to get a valid pathname. For the second one simply
! 	     return the previously cached pathname */
! 	  exec_file = target_pid_to_exec_file (pid);
  	  *execd_pathname = savestring (exec_file, strlen (exec_file));
+ 	  strncpy (saved_pathname, exec_file, sizeof (saved_pathname) - 1);
+ 	}
+       else
+ 	*execd_pathname = saved_pathname;
        return 1;
      }
  
***************
*** 1089,1094 ****
--- 1111,1117 ----
  {
    static char exec_file_buffer[1024];
    int pt_status;
+   ptrace_state_t ptrace_state;
    CORE_ADDR top_of_stack;
    char four_chars[4];
    int name_index;
***************
*** 1098,1109 ****
  
  #ifdef PT_GET_PROCESS_PATHNAME
    /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
    pt_status = call_ptrace (PT_GET_PROCESS_PATHNAME,
  			   pid,
  			   (PTRACE_ARG3_TYPE) exec_file_buffer,
  			   sizeof (exec_file_buffer) - 1);
!   if (pt_status == 0)
      return exec_file_buffer;
  #endif
  
    /* It appears that this request is broken prior to 10.30.
--- 1121,1146 ----
  
  #ifdef PT_GET_PROCESS_PATHNAME
    /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
+   /* RM: According to the documentation, this request only works right
+    * after an exec */
+   errno = 0;
+   pt_status = call_ptrace (PT_GET_PROCESS_STATE,
+ 			   pid,
+ 			   (PTRACE_ARG3_TYPE) &ptrace_state,
+ 			   sizeof (ptrace_state));
+   if (errno)
+     perror_with_name ("ptrace");
+ 
+   if (ptrace_state.pe_report_event & PTRACE_EXEC)
+     {
        pt_status = call_ptrace (PT_GET_PROCESS_PATHNAME,
  			       pid,
  			       (PTRACE_ARG3_TYPE) exec_file_buffer,
  			       sizeof (exec_file_buffer) - 1);
!       /* RM: ??? pt_status < 0 indicates failure, I think */
!       if (pt_status >= 0)
  	return exec_file_buffer;
+     }
  #endif
  
    /* It appears that this request is broken prior to 10.30.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]