[binutils-gdb] Change tui_data_item_window::content to be a unique_xmalloc_ptr

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[binutils-gdb] Change tui_data_item_window::content to be a unique_xmalloc_ptr

gdb-buildbot
*** TEST RESULTS FOR COMMIT b9ad36868f46d5270347ef50fd62fde94d68328b ***

commit b9ad36868f46d5270347ef50fd62fde94d68328b
Author:     Tom Tromey <[hidden email]>
AuthorDate: Sat Jul 13 16:01:34 2019 -0600
Commit:     Tom Tromey <[hidden email]>
CommitDate: Tue Aug 20 16:45:50 2019 -0600

    Change tui_data_item_window::content to be a unique_xmalloc_ptr
   
    This changes tui_data_item_window::content to be a unique_xmalloc_ptr
    and fixes up the fallout.  It also removes a parameter from
    tui_expand_tabs, as it was only ever given one value.
   
    This also removes some tab-handling code from
    tui_data_window::display_registers_from.  Because the content can only
    be set by tui_register_format, and because that calls tui_expand_tabs,
    it's not possible to see a tab here.
   
    gdb/ChangeLog
    2019-08-20  Tom Tromey  <[hidden email]>
   
            * tui/tui-regs.h (struct tui_data_item_window)
            <~tui_data_item_window>: Remove.
            <content>: Now a unique_xmalloc_ptr.
            * tui/tui-regs.c (tui_register_format): Return a
            unique_xmalloc_ptr.
            (tui_get_register): Update.
            (~tui_data_item_window): Remove.
            (tui_data_window::display_registers_from, tui_display_register):
            Update.
            * tui/tui-io.h (tui_expand_tabs): Update.
            * tui/tui-io.c (tui_expand_tabs): Return a unique_xmalloc_ptr.
            Remove "col" parameter.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b4108d90d2..fd3c8489a8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,18 @@
+2019-08-20  Tom Tromey  <[hidden email]>
+
+ * tui/tui-regs.h (struct tui_data_item_window)
+ <~tui_data_item_window>: Remove.
+ <content>: Now a unique_xmalloc_ptr.
+ * tui/tui-regs.c (tui_register_format): Return a
+ unique_xmalloc_ptr.
+ (tui_get_register): Update.
+ (~tui_data_item_window): Remove.
+ (tui_data_window::display_registers_from, tui_display_register):
+ Update.
+ * tui/tui-io.h (tui_expand_tabs): Update.
+ * tui/tui-io.c (tui_expand_tabs): Return a unique_xmalloc_ptr.
+ Remove "col" parameter.
+
 2019-08-20  Tom Tromey  <[hidden email]>
 
  * tui/tui-regs.h (struct tui_data_item_window) <value>: Remove
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 7bdba3f64f..ac7f098275 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -1050,19 +1050,17 @@ tui_getc (FILE *fp)
   return ch;
 }
 
-/* Utility function to expand TABs in a STRING into spaces.  STRING
-   will be displayed starting at column COL, and is assumed to include
-   no newlines.  The returned expanded string is malloc'ed.  */
+/* See tui-io.h.  */
 
-char *
-tui_expand_tabs (const char *string, int col)
+gdb::unique_xmalloc_ptr<char>
+tui_expand_tabs (const char *string)
 {
   int n_adjust, ncol;
   const char *s;
   char *ret, *q;
 
   /* 1. How many additional characters do we need?  */
-  for (ncol = col, n_adjust = 0, s = string; s; )
+  for (ncol = 0, n_adjust = 0, s = string; s; )
     {
       s = strpbrk (s, "\t");
       if (s)
@@ -1079,7 +1077,7 @@ tui_expand_tabs (const char *string, int col)
   ret = q = (char *) xmalloc (strlen (string) + n_adjust + 1);
 
   /* 2. Copy the original string while replacing TABs with spaces.  */
-  for (ncol = col, s = string; s; )
+  for (ncol = 0, s = string; s; )
     {
       const char *s1 = strpbrk (s, "\t");
       if (s1)
@@ -1101,5 +1099,5 @@ tui_expand_tabs (const char *string, int col)
       s = s1;
     }
 
-  return ret;
+  return gdb::unique_xmalloc_ptr<char> (ret);
 }
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index 34a24da292..ec2378759a 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -46,7 +46,7 @@ extern void tui_initialize_io (void);
 extern void tui_redisplay_readline (void);
 
 /* Expand TABs into spaces.  */
-extern char *tui_expand_tabs (const char *, int);
+extern gdb::unique_xmalloc_ptr<char> tui_expand_tabs (const char *);
 
 /* Enter/leave reverse video mode.  */
 extern void tui_set_reverse_mode (WINDOW *w, bool reverse);
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index aebea49eff..a899b1df69 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -52,7 +52,7 @@ static void tui_show_register_group (tui_data_window *win_info,
 /* Get the register from the frame and return a printable
    representation of it.  */
 
-static char *
+static gdb::unique_xmalloc_ptr<char>
 tui_register_format (struct frame_info *frame, int regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
@@ -72,7 +72,7 @@ tui_register_format (struct frame_info *frame, int regnum)
     str.resize (str.size () - 1);
 
   /* Expand tabs into spaces, since ncurses on MS-Windows doesn't.  */
-  return tui_expand_tabs (str.c_str (), 0);
+  return tui_expand_tabs (str.c_str ());
 }
 
 /* Get the register value from the given frame and format it for the
@@ -87,27 +87,19 @@ tui_get_register (struct frame_info *frame,
     *changedp = false;
   if (target_has_registers)
     {
-      char *prev_content = data->content;
-
-      data->content = tui_register_format (frame, regnum);
+      gdb::unique_xmalloc_ptr<char> new_content
+ = tui_register_format (frame, regnum);
 
       if (changedp != NULL
-  && strcmp (prev_content, data->content) != 0)
+  && strcmp (data->content.get (), new_content.get ()) != 0)
  *changedp = true;
 
-      xfree (prev_content);
+      data->content = std::move (new_content);
     }
 }
 
 /* See tui-regs.h.  */
 
-tui_data_item_window::~tui_data_item_window ()
-{
-  xfree (content);
-}
-
-/* See tui-regs.h.  */
-
 int
 tui_data_window::last_regs_line_no () const
 {
@@ -309,19 +301,13 @@ tui_data_window::display_registers_from (int start_element_no)
       int max_len = 0;
       for (auto &&data_item_win : regs_content)
         {
-          char *p;
+          const char *p;
           int len;
 
           len = 0;
-          p = data_item_win->content;
+          p = data_item_win->content.get ();
           if (p != 0)
-            while (*p)
-              {
-                if (*p++ == '\t')
-                  len = 8 * ((len / 8) + 1);
-                else
-                  len++;
-              }
+    len = strlen (p);
 
           if (len > max_len)
             max_len = len;
@@ -641,7 +627,7 @@ tui_display_register (struct tui_data_item_window *data)
         waddch (data->handle, ' ');
       wmove (data->handle, 0, 0);
       if (data->content)
-        waddstr (data->handle, data->content);
+        waddstr (data->handle, data->content.get ());
 
       if (data->highlight)
  /* We ignore the return value, casting it to void in order to avoid
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index d54b556148..b70d8df362 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -33,13 +33,11 @@ struct tui_data_item_window : public tui_gen_win_info
   {
   }
 
-  ~tui_data_item_window () override;
-
   const char *name = nullptr;
   /* The register number, or data display number.  */
   int item_no = -1;
   bool highlight = false;
-  char *content = nullptr;
+  gdb::unique_xmalloc_ptr<char> content;
 };
 
 /* The TUI registers window.  */
Reply | Threaded
Open this post in threaded view
|

Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master

gdb-buildbot
Buildername:
        Ubuntu-Aarch64-native-extended-gdbserver-m64

Worker:
        ubuntu-aarch64

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/5/builds/556

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Ubuntu-Aarch64-native-extended-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
new UNRESOLVED: gdb.trace/trace-condition.exp: delete all breakpoints in delete_breakpoints
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Ubuntu-Aarch64-native-extended-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Ubuntu-Aarch64-native-extended-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-i686, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-i686

Worker:
        fedora-x86-64-3

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/18/builds/625

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-i686/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> KFAIL: gdb.threads/non-ldr-exit.exp: program exits normally
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=0: inferior 1 exited
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=on: cond_bp_target=0: inferior 1 exited
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-i686/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-i686/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-x86_64-m32, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-x86_64-m32

Worker:
        fedora-x86-64-4

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/17/builds/623

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-x86_64-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> KFAIL: gdb.threads/non-ldr-exit.exp: program exits normally
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=0: inferior 1 exited
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=on: cond_bp_target=0: inferior 1 exited
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=on: cond_bp_target=1: inferior 1 exited
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-x86_64-m64, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-x86_64-m64

Worker:
        fedora-x86-64-2

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/3/builds/647

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-x86_64-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> KFAIL: gdb.threads/non-ldr-exit.exp: program exits normally
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=1: inferior 1 exited
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=on: cond_bp_target=1: inferior 1 exited
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-x86_64-native-extended-gdbserver-m32, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-x86_64-native-extended-gdbserver-m32

Worker:
        fedora-x86-64-3

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/4/builds/622

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-extended-gdbserver-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=0: inferior 1 exited
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-extended-gdbserver-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-extended-gdbserver-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-x86_64-native-gdbserver-m32, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-x86_64-native-gdbserver-m32

Worker:
        fedora-x86-64-1

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/24/builds/622

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-gdbserver-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=1: inferior 1 exited
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-gdbserver-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-gdbserver-m32/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-x86_64-native-extended-gdbserver-m64, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-x86_64-native-extended-gdbserver-m64

Worker:
        fedora-x86-64-4

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/2/builds/623

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-extended-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> UNRESOLVED: gdb.threads/attach-into-signal.exp: threaded: attach
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-extended-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-extended-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>

Reply | Threaded
Open this post in threaded view
|

Failures on Fedora-x86_64-native-gdbserver-m64, branch master

gdb-buildbot
In reply to this post by gdb-buildbot
Buildername:
        Fedora-x86_64-native-gdbserver-m64

Worker:
        fedora-x86-64-2

Full Build URL:
        https://gdb-buildbot.osci.io/#builders/22/builds/622

Author:
        Tom Tromey <[hidden email]>

Commit tested:
        b9ad36868f46d5270347ef50fd62fde94d68328b

Subject of commit:
        Change tui_data_item_window::content to be a unique_xmalloc_ptr

Testsuite logs (gdb.sum, gdb.log and others):
        https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b/

*** Diff to previous build ***
==============================================
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=0: inferior 1 exited
PASS -> KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=off: cond_bp_target=1: inferior 1 exited
==============================================

*** Complete list of XFAILs for this builder ***

To obtain the list of XFAIL tests for this builder, go to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.gz>

You can also see a pretty-printed version of the list, with more information
about each XFAIL, by going to:

        <https://gdb-buildbot.osci.io/results/Fedora-x86_64-native-gdbserver-m64/b9/b9ad36868f46d5270347ef50fd62fde94d68328b//xfail.table.gz>