Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]: Set nr_bytes in remote_write_bytes
@ 2001-05-14 11:38 Michael Snyder
  2001-05-14 13:22 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2001-05-14 11:38 UTC (permalink / raw)
  To: gdb-patches, cagney

Use the return value of bin2hex to set the number of converted bytes.
2001-05-14  Michael Snyder  <msnyder@redhat.com>

	* remote.c (remote_write_bytes): Set nr_bytes to return value of
	bin2hex.
	
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -c -3 -p -r1.50 -r1.51
*** remote.c	2001/05/14 16:48:01	1.50
--- remote.c	2001/05/14 18:31:35	1.51
*************** remote_write_bytes (CORE_ADDR memaddr, c
*** 3629,3636 ****
        /* Normal mode: Send target system values byte by byte, in
  	 increasing byte addresses.  Each byte is encoded as a two hex
  	 value.  */
!       bin2hex (myaddr, p, todo);
!       nr_bytes = todo;
        break;
      case PACKET_SUPPORT_UNKNOWN:
        internal_error (__FILE__, __LINE__,
--- 3629,3635 ----
        /* Normal mode: Send target system values byte by byte, in
  	 increasing byte addresses.  Each byte is encoded as a two hex
  	 value.  */
!       nr_bytes = bin2hex (myaddr, p, todo);
        break;
      case PACKET_SUPPORT_UNKNOWN:
        internal_error (__FILE__, __LINE__,
From msnyder@cygnus.com Mon May 14 11:46:00 2001
From: Michael Snyder <msnyder@cygnus.com>
To: Kevin Buettner <kevinb@cygnus.com>
Cc: Andrew Cagney <ac131313@cygnus.com>, GDB Patches <gdb-patches@sourceware.cygnus.com>
Subject: Re: [patch/but] Fix -Werror probs remote.c, fixes bug
Date: Mon, 14 May 2001 11:46:00 -0000
Message-id: <3B0027F2.C2417CF4@cygnus.com>
References: <3B000D0F.1080702@cygnus.com> <1010514181430.ZM6964@ocotillo.lan>
X-SW-Source: 2001-05/msg00302.html
Content-length: 1972

Kevin Buettner wrote:
> 
> On May 14, 12:51pm, Andrew Cagney wrote:
> 
> > For the extern I'm adding to solib.h, I'm kind of wondering if that is
> > the correct interface.  Kevin?  Feel free to clean up that exported
> > function.
> 
> I've fixed the prototype to match the definition in solib.c.
> 
> Michael S: Could I ask you to provide some comments regarding the
> purpose of no_shared_libraries()?

Done.  See attached.

  2001-05-14  Michael Snyder  <msnyder@redhat.com>
  
	* solib.c, solib.h: Add comment for function no_shared_libraries.
  	
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.39
diff -c -3 -p -r1.39 solib.c
*** solib.c	2001/04/17 23:22:52	1.39
--- solib.c	2001/05/14 18:45:01
*************** sharedlibrary_command (char *args, int f
*** 809,814 ****
--- 809,826 ----
    solib_add (args, from_tty, (struct target_ops *) 0);
  }
  
+ /* LOCAL FUNCTION
+ 
+    no_shared_libraries -- handle command to explicitly discard symbols
+    from shared libraries.
+ 
+    DESCRIPTION
+ 
+    Implements the command "nosharedlibrary", which discards symbols
+    that have been auto-loaded from shared libraries.  Symbols from
+    shared libraries that were added by explicit request of the user
+    are not discarded.  Also called from remote.c.  */
+ 
  void
  no_shared_libraries (char *ignored, int from_tty)
  {
Index: solib.h
===================================================================
RCS file: /cvs/src/src/gdb/solib.h,v
retrieving revision 1.6
diff -c -3 -p -r1.6 solib.h
*** solib.h	2001/05/14 18:09:05	1.6
--- solib.h	2001/05/14 18:45:01
*************** extern char *solib_address (CORE_ADDR);	
*** 194,197 ****
--- 194,199 ----
  
  extern int in_solib_dynsym_resolve_code (CORE_ADDR);	/* solib.c */
  
+ /* Discard symbols that were auto-loaded from shared libraries. */
+ 
  extern void no_shared_libraries (char *ignored, int from_tty);
From ac131313@cygnus.com Mon May 14 13:02:00 2001
From: Andrew Cagney <ac131313@cygnus.com>
To: Mark Kettenis <kettenis@wins.uva.nl>
Cc: gdb-patches@sources.redhat.com, jimb@cygnus.com, ezannoni@cygnus.com
Subject: Re: [PATCH, RFA] Fix basename bug in symtab.c
Date: Mon, 14 May 2001 13:02:00 -0000
Message-id: <3B0039B5.7060704@cygnus.com>
References: <200105132045.f4DKjpm03579@delius.kettenis.local>
X-SW-Source: 2001-05/msg00303.html
Content-length: 953

> [Jim, Elena, sorry I keep saying cygnus instead of redhat :-(]
> 
> Here is a patch that fixes the problems discussed on the discussion
> list.  Eli pretty much convinced me that this is the right approach.
> We can still discuss the other uses of basename() in GDB, but since
> this fixes a rather serious bug on FreeBSD (and I suppose other
> systems as well), I'd like to get this in ASAP.


Just to be clear on one thing, the bug occures on FreeBSD.  It isn't a 
FreeBSD bug :-).  To quote the opengroup standard:

> #include <libgen.h>
> char *basename(char *path);

...

> The basename() function may modify the string pointed to by path, and may return a pointer to static storage that may then be overwritten by a subsequent call to basename().
> 
> This interface need not be reentrant.


Any way, looking at libiberty/lbasename.c, it casts:

	(const char*) -> (char *)

so I'd not call that function safe either (actually grrrr).

	Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH]: Set nr_bytes in remote_write_bytes
  2001-05-14 11:38 [PATCH]: Set nr_bytes in remote_write_bytes Michael Snyder
@ 2001-05-14 13:22 ` Andrew Cagney
  2001-05-14 14:29   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2001-05-14 13:22 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches, cagney

2001-05-14  Michael Snyder  <msnyder@redhat.com>

* remote.c (remote_write_bytes): Set nr_bytes to return value of
	bin2hex.
	
as far as I can tell the code:

> !       bin2hex (myaddr, p, todo);
> !       nr_bytes = todo;
>         break;


is identical to:


> !       nr_bytes = bin2hex (myaddr, p, todo);


Although to be honest, I was having trouble figuring out what bin2hex() 
returned.

	Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH]: Set nr_bytes in remote_write_bytes
  2001-05-14 13:22 ` Andrew Cagney
@ 2001-05-14 14:29   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2001-05-14 14:29 UTC (permalink / raw)
  To: Andrew Cagney, gdb-patches

Andrew Cagney wrote:
> 
> 2001-05-14  Michael Snyder  <msnyder@redhat.com>
> 
> * remote.c (remote_write_bytes): Set nr_bytes to return value of
>         bin2hex.
> 
> as far as I can tell the code:
> 
> > !       bin2hex (myaddr, p, todo);
> > !       nr_bytes = todo;
> >         break;
> 
> is identical to:
> 
> > !       nr_bytes = bin2hex (myaddr, p, todo);

It is identical, assuming that you know the implementation details of bin2hex.
I think it's cleaner to not assume this.  Pragmatically it makes no difference,
but this is write_bytes, which implements xfer_memory.  In principal it could
return a number smaller than the requested number.  I was just coding to that
model.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-05-14 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-14 11:38 [PATCH]: Set nr_bytes in remote_write_bytes Michael Snyder
2001-05-14 13:22 ` Andrew Cagney
2001-05-14 14:29   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox