This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Re: [patch 4/6] Prepare linux_find_memory_regions_full & co. for move


On 13-03-28 04:28 PM, Jan Kratochvil wrote:
On Wed, 27 Mar 2013 21:17:08 +0100, Aleksandar Ristovski wrote:
--- a/gdb/target.c
+++ b/gdb/target.c
[...]
@@ -3540,15 +3580,16 @@ target_fileio_read_alloc (const char *filename, gdb_byte **buf_p)
     are returned as allocated but empty strings.  A warning is issued
     if the result contains any embedded NUL bytes.  */

-char *
-target_fileio_read_stralloc (const char *filename)
+typedef LONGEST (read_stralloc_func_ftype) (const char *filename,
+					    gdb_byte **buf_p, int padding);
+
+static char *
+read_stralloc (const char *filename, read_stralloc_func_ftype *func)
  {
-  gdb_byte *buffer;
-  char *bufstr;
+  char *buffer;

Why you make this change?  That is unrelated to this patchset, it is a recent
modification by Pedro.


[AR] I apologize to Pedro - the code as I put it seems more natural, a few less lines and such. But I can remove it, it is not essential.




fad14e531       (Pedro Alves    2013-03-11 12:22:16 +0000       3546)  gdb_byte *buffer;
fad14e531       (Pedro Alves    2013-03-11 12:22:16 +0000       3547)  char *bufstr;



    LONGEST i, transferred;

-  transferred = target_fileio_read_alloc_1 (filename, &buffer, 1);

-  bufstr = (char *) buffer;

Likewise.  I already replied to this change in:
	http://sourceware.org/ml/gdb-patches/2013-03/msg00965.html
	Message-ID: <20130326165242.GA12291@host2.jankratochvil.net>


+  transferred = func (filename, (gdb_byte **) &buffer, 1);

Likewise - the (gdb_byte **) cast.



    if (transferred < 0)
      return NULL;
@@ -3556,11 +3597,11 @@ target_fileio_read_stralloc (const char *filename)
    if (transferred == 0)
      return xstrdup ("");

-  bufstr[transferred] = 0;
+  buffer[transferred] = 0;

    /* Check for embedded NUL bytes; but allow trailing NULs.  */
-  for (i = strlen (bufstr); i < transferred; i++)
-    if (bufstr[i] != 0)
+  for (i = strlen (buffer); i < transferred; i++)
+    if (buffer[i] != 0)
        {
  	warning (_("target file %s "
  		   "contained unexpected null characters"),
@@ -3568,9 +3609,14 @@ target_fileio_read_stralloc (const char *filename)
  	break;
        }

-  return bufstr;
+  return buffer;
  }

+char *
+target_fileio_read_stralloc (const char *filename)
+{
+  return read_stralloc (filename, target_fileio_read_alloc_1);
+}

  static int
  default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
--
1.7.10.4



Otherwise OK for this part but it needs a new post, thanks for catching the
xrealloc.

[AR] Thanks. I will repost the patch.




Thanks,
Jan



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