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]

RFA: remove target_memory_bfdsection and assorted cruft.


I submit the enclosed changes for approval.  

This removes the global variable target_memory_bfd_section which was
set in target_xfer_memory() but never used (except in long dead #if'd
out code).  This allowed me to remove the section argument to target_
xfer_memory(), which allowed me to remove target_read_memory_section,
which allowed me to remove even more stuff.

This was discussed in on the gdb mailing list in a thread starting:
  http://sourceware.cygnus.com/ml/gdb/2000-q1/msg00749.html

In that thread, I got approval in principal for these changes.  Now I'm
seeking approval for the changes themselves.

        --jtc

2000-05-18  J.T. Conklin  <jtc@redback.com>
  
	* target.h (target_memory_bfd_section): Removed declaration.
	* target.c (target_memory_bfd_section): Removed.
	* exec.c (xfer_memory): Removed #if'ed-out code which referenced
 	target_memory_bfd_section.
	
	* target.h (target_read_memory_section): Removed declaration.
	* target.c (target_read_memory_section): Removed.
	(target_xfer_memory): Update, removed bfd_section argument.
	(target_read_string, target_read_memory, target_write_memory):
	Update for above change.

	* gdbcore.h (read_memory_section): Removed declaration.
	* corefile.c (read_memory_section): Removed.
	* jv-lang.c (get_java_utf8_name): Changed calls to
 	read_memory_section to read_memory.
	* printcmd.c (printf_command): Likewise.
	* valops.c (value_at, value_fetch_lazy): Likewise.
	


Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gdb/corefile.c,v
retrieving revision 1.2
diff -c -r1.2 corefile.c
*** corefile.c	2000/02/23 02:42:40	1.2
--- corefile.c	2000/05/19 02:02:47
***************
*** 270,290 ****
      memory_error (status, memaddr);
  }
  
- void
- read_memory_section (memaddr, myaddr, len, bfd_section)
-      CORE_ADDR memaddr;
-      char *myaddr;
-      int len;
-      asection *bfd_section;
- {
-   int status;
-   status = target_read_memory_section (memaddr, myaddr, len, bfd_section);
-   if (status != 0)
-     memory_error (status, memaddr);
- }
- 
  /* Like target_read_memory, but slightly different parameters.  */
- 
  int
  dis_asm_read_memory (memaddr, myaddr, len, info)
       bfd_vma memaddr;
--- 270,276 ----
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.1.1.8
diff -c -r1.1.1.8 exec.c
*** exec.c	1999/12/07 03:56:00	1.1.1.8
--- exec.c	2000/05/19 02:02:49
***************
*** 490,538 ****
    xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents;
    nextsectaddr = memend;
  
- #if 0				/* Stu's implementation */
- /* If a section has been specified, try to use it.  Note that we cannot use the
-    specified section directly.  This is because it usually comes from the
-    symbol file, which may be different from the exec or core file.  Instead, we
-    have to lookup the specified section by name in the bfd associated with
-    to_sections.  */
- 
-   if (target_memory_bfd_section)
-     {
-       asection *s;
-       bfd *abfd;
-       asection *target_section;
-       bfd *target_bfd;
- 
-       s = target_memory_bfd_section;
-       abfd = s->owner;
- 
-       target_bfd = target->to_sections->bfd;
-       target_section = bfd_get_section_by_name (target_bfd, bfd_section_name (abfd, s));
- 
-       if (target_section)
- 	{
- 	  bfd_vma sec_addr;
- 	  bfd_size_type sec_size;
- 
- 	  sec_addr = bfd_section_vma (target_bfd, target_section);
- 	  sec_size = target_section->_raw_size;
- 
- 	  /* Make sure the requested memory starts inside the section.  */
- 
- 	  if (memaddr >= sec_addr
- 	      && memaddr < sec_addr + sec_size)
- 	    {
- 	      /* Cut back length in case request overflows the end of the section. */
- 	      len = min (len, sec_addr + sec_size - memaddr);
- 
- 	      res = xfer_fn (target_bfd, target_section, myaddr, memaddr - sec_addr, len);
- 
- 	      return res ? len : 0;
- 	    }
- 	}
-     }
- #endif /* 0, Stu's implementation */
    for (p = target->to_sections; p < target->to_sections_end; p++)
      {
        if (overlay_debugging && section && p->the_bfd_section &&
--- 490,495 ----
Index: gdbcore.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbcore.h,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 gdbcore.h
*** gdbcore.h	1999/12/08 02:50:38	1.1.1.4
--- gdbcore.h	2000/05/19 02:02:50
***************
*** 51,59 ****
  
  extern void read_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
  
- extern void read_memory_section PARAMS ((CORE_ADDR memaddr, char *myaddr,
- 					 int len, asection * bfd_section));
- 
  /* Read an integer from debugged memory, given address and number of
     bytes.  */
  
--- 51,56 ----
Index: jv-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-lang.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 jv-lang.c
*** jv-lang.c	2000/02/02 00:21:08	1.1.1.5
--- jv-lang.c	2000/05/19 02:02:57
***************
*** 224,230 ****
      + TYPE_LENGTH (VALUE_TYPE (temp));
    chrs = obstack_alloc (obstack, name_length + 1);
    chrs[name_length] = '\0';
!   read_memory_section (data_addr, chrs, name_length, NULL);
    return chrs;
  }
  
--- 224,230 ----
      + TYPE_LENGTH (VALUE_TYPE (temp));
    chrs = obstack_alloc (obstack, name_length + 1);
    chrs[name_length] = '\0';
!   read_memory (data_addr, chrs, name_length);
    return chrs;
  }
  
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.7
diff -c -r1.7 printcmd.c
*** printcmd.c	2000/05/15 03:16:15	1.7
--- printcmd.c	2000/05/19 02:03:16
***************
*** 2319,2333 ****
  		{
  		  char c;
  		  QUIT;
! 		  read_memory_section (tem + j, &c, 1,
! 				       VALUE_BFD_SECTION (val_args[i]));
  		  if (c == 0)
  		    break;
  		}
  
  	      /* Copy the string contents into a string inside GDB.  */
  	      str = (char *) alloca (j + 1);
! 	      read_memory_section (tem, str, j, VALUE_BFD_SECTION (val_args[i]));
  	      str[j] = 0;
  
  	      printf_filtered (current_substring, str);
--- 2319,2332 ----
  		{
  		  char c;
  		  QUIT;
! 		  read_memory (tem + j, &c, 1);
  		  if (c == 0)
  		    break;
  		}
  
  	      /* Copy the string contents into a string inside GDB.  */
  	      str = (char *) alloca (j + 1);
! 	      read_memory (tem, str, j);
  	      str[j] = 0;
  
  	      printf_filtered (current_substring, str);
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.6
diff -c -r1.6 target.c
*** target.c	2000/04/28 03:10:43	1.6
--- target.c	2000/05/19 02:03:30
***************
*** 95,101 ****
  
  static int
  target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
! 			    int write, asection * bfd_section));
  
  static void init_dummy_target PARAMS ((void));
  
--- 95,101 ----
  
  static int
  target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
! 			    int write));
  
  static void init_dummy_target PARAMS ((void));
  
***************
*** 836,842 ****
        tlen = MIN (len, 4 - (memaddr & 3));
        offset = memaddr & 3;
  
!       errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0, NULL);
        if (errcode != 0)
  	{
  	  /* The transfer request might have crossed the boundary to an
--- 836,842 ----
        tlen = MIN (len, 4 - (memaddr & 3));
        offset = memaddr & 3;
  
!       errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
        if (errcode != 0)
  	{
  	  /* The transfer request might have crossed the boundary to an
***************
*** 844,850 ****
  	     a single byte.  */
  	  tlen = 1;
  	  offset = 0;
! 	  errcode = target_xfer_memory (memaddr, buf, 1, 0, NULL);
  	  if (errcode != 0)
  	    goto done;
  	}
--- 844,850 ----
  	     a single byte.  */
  	  tlen = 1;
  	  offset = 0;
! 	  errcode = target_xfer_memory (memaddr, buf, 1, 0);
  	  if (errcode != 0)
  	    goto done;
  	}
***************
*** 896,929 ****
       char *myaddr;
       int len;
  {
!   return target_xfer_memory (memaddr, myaddr, len, 0, NULL);
  }
  
  int
- target_read_memory_section (memaddr, myaddr, len, bfd_section)
-      CORE_ADDR memaddr;
-      char *myaddr;
-      int len;
-      asection *bfd_section;
- {
-   return target_xfer_memory (memaddr, myaddr, len, 0, bfd_section);
- }
- 
- int
  target_write_memory (memaddr, myaddr, len)
       CORE_ADDR memaddr;
       char *myaddr;
       int len;
  {
!   return target_xfer_memory (memaddr, myaddr, len, 1, NULL);
  }
  
- /* This variable is used to pass section information down to targets.  This
-    *should* be done by adding an argument to the target_xfer_memory function
-    of all the targets, but I didn't feel like changing 50+ files.  */
- 
- asection *target_memory_bfd_section = NULL;
- 
  /* Move memory to or from the targets.  Iterate until all of it has
     been moved, if necessary.  The top target gets priority; anything
     it doesn't want, is offered to the next one down, etc.  Note the
--- 896,913 ----
       char *myaddr;
       int len;
  {
!   return target_xfer_memory (memaddr, myaddr, len, 0);
  }
  
  int
  target_write_memory (memaddr, myaddr, len)
       CORE_ADDR memaddr;
       char *myaddr;
       int len;
  {
!   return target_xfer_memory (memaddr, myaddr, len, 1);
  }
  
  /* Move memory to or from the targets.  Iterate until all of it has
     been moved, if necessary.  The top target gets priority; anything
     it doesn't want, is offered to the next one down, etc.  Note the
***************
*** 935,946 ****
     Result is 0 or errno value.  */
  
  static int
! target_xfer_memory (memaddr, myaddr, len, write, bfd_section)
       CORE_ADDR memaddr;
       char *myaddr;
       int len;
       int write;
-      asection *bfd_section;
  {
    int curlen;
    int res;
--- 919,929 ----
     Result is 0 or errno value.  */
  
  static int
! target_xfer_memory (memaddr, myaddr, len, write)
       CORE_ADDR memaddr;
       char *myaddr;
       int len;
       int write;
  {
    int curlen;
    int res;
***************
*** 950,957 ****
    /* Zero length requests are ok and require no work.  */
    if (len == 0)
      return 0;
- 
-   target_memory_bfd_section = bfd_section;
  
    /* to_xfer_memory is not guaranteed to set errno, even when it returns
       0.  */
--- 933,938 ----
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.3
diff -c -r1.3 target.h
*** target.h	2000/04/17 02:27:37	1.3
--- target.h	2000/05/19 02:03:34
***************
*** 615,624 ****
  target_read_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
  
  extern int
- target_read_memory_section PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
- 				    asection * bfd_section));
- 
- extern int
  target_write_memory PARAMS ((CORE_ADDR, char *, int));
  
  extern int
--- 615,620 ----
***************
*** 1388,1394 ****
  /* Timeout limit for response from target. */
  extern int remote_timeout;
  
- extern asection *target_memory_bfd_section;
  
  /* Functions for helping to write a native target.  */
  
--- 1384,1389 ----
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.13
diff -c -r1.13 valops.c
*** valops.c	2000/05/15 06:27:18	1.13
--- valops.c	2000/05/19 02:03:41
***************
*** 465,471 ****
        store_address (VALUE_CONTENTS_RAW (val), 4, num);
      }
    else
!     read_memory_section (addr, VALUE_CONTENTS_ALL_RAW (val), TYPE_LENGTH (type), sect);
  
    VALUE_LVAL (val) = lval_memory;
    VALUE_ADDRESS (val) = addr;
--- 465,471 ----
        store_address (VALUE_CONTENTS_RAW (val), 4, num);
      }
    else
!     read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), TYPE_LENGTH (type));
  
    VALUE_LVAL (val) = lval_memory;
    VALUE_ADDRESS (val) = addr;
***************
*** 540,547 ****
        store_address (VALUE_CONTENTS_RAW (val), 4, num);
      }
    else if (length)
!     read_memory_section (addr, VALUE_CONTENTS_ALL_RAW (val), length,
! 			 VALUE_BFD_SECTION (val));
    VALUE_LAZY (val) = 0;
    return 0;
  }
--- 540,547 ----
        store_address (VALUE_CONTENTS_RAW (val), 4, num);
      }
    else if (length)
!     read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), length);
!   
    VALUE_LAZY (val) = 0;
    return 0;
  }

-- 
J.T. Conklin
RedBack Networks

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