Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Fix TUI build failure on AiX 4.3.2
@ 2004-02-23 23:05 Joel Brobecker
  2004-02-24 23:18 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2004-02-23 23:05 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

Hello,

I couldn't believe my eyes... On AiX, /usr/include/term.h defines
the following macros:

    #define lines                           CUR _c3
    #define label_width                     CURN _labl_width

That has a rather unfortunate consequence during the build of
tui-disasm.c and tui-regs.c, where we have variables using
these names. The variable names get expanded and kaboom!

So I suggest the following change, where I appended "tui_" to
the variable names to avoid the macro expansion (short of finding
a better replacement name).

2004-02-23  J. Brobecker  <brobecker@gnat.com>

        * tui-disasm.c: %s/lines/tui_lines/g to avoid a collision
        with the lines macro defined in term.h on AiX.
        * tui-regs.c: %s/label_width/tui_label_width/g, to avoid
        a collision with the label_width macro defined in term.h on AiX.
        
Tested on ppc-aix 4.3.2.0.
OK to apply?

Thanks,
-- 
Joel

[-- Attachment #2: tui.diff --]
[-- Type: text/plain, Size: 9462 bytes --]

Index: tui-disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-disasm.c,v
retrieving revision 1.13
diff -u -p -r1.13 tui-disasm.c
--- tui-disasm.c	10 Feb 2004 19:08:15 -0000	1.13
+++ tui-disasm.c	23 Feb 2004 22:55:20 -0000
@@ -51,7 +51,7 @@ struct tui_asm_line 
    Disassemble count lines starting at pc.
    Return address of the count'th instruction after pc.  */
 static CORE_ADDR
-tui_disassemble (struct tui_asm_line* lines, CORE_ADDR pc, int count)
+tui_disassemble (struct tui_asm_line* tui_lines, CORE_ADDR pc, int count)
 {
   struct ui_file *gdb_dis_out;
 
@@ -59,22 +59,22 @@ tui_disassemble (struct tui_asm_line* li
   gdb_dis_out = tui_sfileopen (256);
 
   /* Now construct each line */
-  for (; count > 0; count--, lines++)
+  for (; count > 0; count--, tui_lines++)
     {
-      if (lines->addr_string)
-        xfree (lines->addr_string);
-      if (lines->insn)
-        xfree (lines->insn);
+      if (tui_lines->addr_string)
+        xfree (tui_lines->addr_string);
+      if (tui_lines->insn)
+        xfree (tui_lines->insn);
       
       print_address (pc, gdb_dis_out);
-      lines->addr = pc;
-      lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
+      tui_lines->addr = pc;
+      tui_lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
 
       ui_file_rewind (gdb_dis_out);
 
       pc = pc + gdb_print_insn (pc, gdb_dis_out);
 
-      lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
+      tui_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
 
       /* reset the buffer to empty */
       ui_file_rewind (gdb_dis_out);
@@ -92,21 +92,21 @@ tui_find_disassembly_address (CORE_ADDR 
   CORE_ADDR new_low;
   int max_lines;
   int i;
-  struct tui_asm_line* lines;
+  struct tui_asm_line* tui_lines;
 
   max_lines = (from > 0) ? from : - from;
   if (max_lines <= 1)
      return pc;
 
-  lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
+  tui_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
                                          * max_lines);
-  memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
+  memset (tui_lines, 0, sizeof (struct tui_asm_line) * max_lines);
 
   new_low = pc;
   if (from > 0)
     {
-      tui_disassemble (lines, pc, max_lines);
-      new_low = lines[max_lines - 1].addr;
+      tui_disassemble (tui_lines, pc, max_lines);
+      new_low = tui_lines[max_lines - 1].addr;
     }
   else
     {
@@ -127,8 +127,8 @@ tui_find_disassembly_address (CORE_ADDR 
          else
             new_low += 1 * max_lines;
 
-         tui_disassemble (lines, new_low, max_lines);
-         last_addr = lines[pos].addr;
+         tui_disassemble (tui_lines, new_low, max_lines);
+         last_addr = tui_lines[pos].addr;
       } while (last_addr > pc && msymbol);
 
       /* Scan forward disassembling one instruction at a time
@@ -145,7 +145,7 @@ tui_find_disassembly_address (CORE_ADDR 
             if (pos >= max_lines)
               pos = 0;
 
-            next_addr = tui_disassemble (&lines[pos], last_addr, 1);
+            next_addr = tui_disassemble (&tui_lines[pos], last_addr, 1);
 
             /* If there are some problems while disassembling exit.  */
             if (next_addr <= last_addr)
@@ -155,12 +155,12 @@ tui_find_disassembly_address (CORE_ADDR 
       pos++;
       if (pos >= max_lines)
          pos = 0;
-      new_low = lines[pos].addr;
+      new_low = tui_lines[pos].addr;
     }
   for (i = 0; i < max_lines; i++)
     {
-      xfree (lines[i].addr_string);
-      xfree (lines[i].insn);
+      xfree (tui_lines[i].addr_string);
+      xfree (tui_lines[i].insn);
     }
   return new_low;
 }
@@ -176,7 +176,7 @@ tui_set_disassem_content (CORE_ADDR pc)
   CORE_ADDR cur_pc;
   struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
   int tab_len = tui_default_tab_len ();
-  struct tui_asm_line* lines;
+  struct tui_asm_line* tui_lines;
   int insn_pos;
   int addr_size, max_size;
   char* line;
@@ -195,24 +195,24 @@ tui_set_disassem_content (CORE_ADDR pc)
   max_lines = TUI_DISASM_WIN->generic.height - 2;	/* account for hilite */
 
   /* Get temporary table that will hold all strings (addr & insn).  */
-  lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
+  tui_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
                                          * max_lines);
-  memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
+  memset (tui_lines, 0, sizeof (struct tui_asm_line) * max_lines);
 
   line_width = TUI_DISASM_WIN->generic.width - 1;
 
-  tui_disassemble (lines, pc, max_lines);
+  tui_disassemble (tui_lines, pc, max_lines);
 
   /* See what is the maximum length of an address and of a line.  */
   addr_size = 0;
   max_size = 0;
   for (i = 0; i < max_lines; i++)
     {
-      size_t len = strlen (lines[i].addr_string);
+      size_t len = strlen (tui_lines[i].addr_string);
       if (len > addr_size)
         addr_size = len;
 
-      len = strlen (lines[i].insn) + tab_len;
+      len = strlen (tui_lines[i].insn) + tab_len;
       if (len > max_size)
         max_size = len;
     }
@@ -231,7 +231,7 @@ tui_set_disassem_content (CORE_ADDR pc)
 
       element = (struct tui_win_element *) TUI_DISASM_WIN->generic.content[i];
       src = &element->which_element.source;
-      strcpy (line, lines[i].addr_string);
+      strcpy (line, tui_lines[i].addr_string);
       cur_len = strlen (line);
 
       /* Add spaces to make the instructions start on the same column */
@@ -241,7 +241,7 @@ tui_set_disassem_content (CORE_ADDR pc)
           cur_len++;
         }
 
-      strcat (line, lines[i].insn);
+      strcat (line, tui_lines[i].insn);
 
       /* Now copy the line taking the offset into account */
       if (strlen (line) > offset)
@@ -249,15 +249,15 @@ tui_set_disassem_content (CORE_ADDR pc)
       else
         src->line[0] = '\0';
 
-      src->line_or_addr.addr = lines[i].addr;
-      src->is_exec_point = lines[i].addr == cur_pc;
+      src->line_or_addr.addr = tui_lines[i].addr;
+      src->is_exec_point = tui_lines[i].addr == cur_pc;
 
       /* See whether there is a breakpoint installed.  */
       src->has_break = (!src->is_exec_point
                        && breakpoint_here_p (pc) != no_breakpoint_here);
 
-      xfree (lines[i].addr_string);
-      xfree (lines[i].insn);
+      xfree (tui_lines[i].addr_string);
+      xfree (tui_lines[i].insn);
     }
   TUI_DISASM_WIN->generic.content_size = i;
   return TUI_SUCCESS;
Index: tui-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-regs.c,v
retrieving revision 1.11
diff -u -p -r1.11 tui-regs.c
--- tui-regs.c	10 Feb 2004 19:08:16 -0000	1.11
+++ tui-regs.c	23 Feb 2004 22:55:21 -0000
@@ -277,7 +277,7 @@ tui_display_registers_from (int start_el
       TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
     {
       int i = start_element_no;
-      int j, value_chars_wide, item_win_width, cur_y, label_width;
+      int j, value_chars_wide, item_win_width, cur_y, tui_label_width;
       enum precision_type precision;
 
       precision = (TUI_DATA_WIN->detail.data_display_info.regs_display_type
@@ -287,7 +287,7 @@ tui_display_registers_from (int start_el
 	  TUI_DATA_WIN->detail.data_display_info.regs_display_type == TUI_DFLOAT_REGS)
 	{
 	  value_chars_wide = DOUBLE_FLOAT_VALUE_WIDTH;
-	  label_width = DOUBLE_FLOAT_LABEL_WIDTH;
+	  tui_label_width = DOUBLE_FLOAT_LABEL_WIDTH;
 	}
       else
 	{
@@ -295,15 +295,15 @@ tui_display_registers_from (int start_el
 	      TUI_SFLOAT_REGS)
 	    {
 	      value_chars_wide = SINGLE_FLOAT_VALUE_WIDTH;
-	      label_width = SINGLE_FLOAT_LABEL_WIDTH;
+	      tui_label_width = SINGLE_FLOAT_LABEL_WIDTH;
 	    }
 	  else
 	    {
 	      value_chars_wide = SINGLE_VALUE_WIDTH;
-	      label_width = SINGLE_LABEL_WIDTH;
+	      tui_label_width = SINGLE_LABEL_WIDTH;
 	    }
 	}
-      item_win_width = value_chars_wide + label_width;
+      item_win_width = value_chars_wide + tui_label_width;
       /*
          ** Now create each data "sub" window, and write the display into it.
        */
@@ -859,7 +859,7 @@ tui_display_register (int reg_num,
     {
       int i;
       char buf[40];
-      int value_chars_wide, label_width;
+      int value_chars_wide, tui_label_width;
       struct tui_data_element * data_element_ptr = &((tui_win_content)
 				    win_info->content)[0]->which_element.data;
 
@@ -867,7 +867,7 @@ tui_display_register (int reg_num,
 	  TUI_DATA_WIN->detail.data_display_info.regs_display_type == TUI_DFLOAT_REGS)
 	{
 	  value_chars_wide = DOUBLE_FLOAT_VALUE_WIDTH;
-	  label_width = DOUBLE_FLOAT_LABEL_WIDTH;
+	  tui_label_width = DOUBLE_FLOAT_LABEL_WIDTH;
 	}
       else
 	{
@@ -875,18 +875,18 @@ tui_display_register (int reg_num,
 	      TUI_SFLOAT_REGS)
 	    {
 	      value_chars_wide = SINGLE_FLOAT_VALUE_WIDTH;
-	      label_width = SINGLE_FLOAT_LABEL_WIDTH;
+	      tui_label_width = SINGLE_FLOAT_LABEL_WIDTH;
 	    }
 	  else
 	    {
 	      value_chars_wide = SINGLE_VALUE_WIDTH;
-	      label_width = SINGLE_LABEL_WIDTH;
+	      tui_label_width = SINGLE_LABEL_WIDTH;
 	    }
 	}
 
       buf[0] = (char) 0;
       tui_register_format (buf,
-			  value_chars_wide + label_width,
+			  value_chars_wide + tui_label_width,
 			  reg_num,
 			  data_element_ptr,
 			  precision);

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

* Re: [RFA] Fix TUI build failure on AiX 4.3.2
  2004-02-23 23:05 [RFA] Fix TUI build failure on AiX 4.3.2 Joel Brobecker
@ 2004-02-24 23:18 ` Andrew Cagney
  2004-02-25  1:11   ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2004-02-24 23:18 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Hello,
> 
> I couldn't believe my eyes... On AiX, /usr/include/term.h defines
> the following macros:
> 
>     #define lines                           CUR _c3
>     #define label_width                     CURN _labl_width

> That has a rather unfortunate consequence during the build of
> tui-disasm.c and tui-regs.c, where we have variables using
> these names. The variable names get expanded and kaboom!

Mutter something rude ...

> So I suggest the following change, where I appended "tui_" to
> the variable names to avoid the macro expansion (short of finding
> a better replacement name).
> 
> 2004-02-23  J. Brobecker  <brobecker@gnat.com>
> 
>         * tui-disasm.c: %s/lines/tui_lines/g to avoid a collision
>         with the lines macro defined in term.h on AiX.

For this one I think "asm_lines" reads better.

>         * tui-regs.c: %s/label_width/tui_label_width/g, to avoid
>         a collision with the label_width macro defined in term.h on AiX.

For this one, yes, I can't think of anything better.  Suggest adding a 
comment so that someone doesn't change it back.

Either way, obishly approved,
Andrew

> Tested on ppc-aix 4.3.2.0.
> OK to apply?
> 
> Thanks,
> -- Joel
> 
> 
> 
> Index: tui-disasm.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/tui/tui-disasm.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 tui-disasm.c
> --- tui-disasm.c	10 Feb 2004 19:08:15 -0000	1.13
> +++ tui-disasm.c	23 Feb 2004 22:55:20 -0000
> @@ -51,7 +51,7 @@ struct tui_asm_line 
>     Disassemble count lines starting at pc.
>     Return address of the count'th instruction after pc.  */
>  static CORE_ADDR
> -tui_disassemble (struct tui_asm_line* lines, CORE_ADDR pc, int count)
> +tui_disassemble (struct tui_asm_line* tui_lines, CORE_ADDR pc, int count)
>  {
>    struct ui_file *gdb_dis_out;
>  
> @@ -59,22 +59,22 @@ tui_disassemble (struct tui_asm_line* li
>    gdb_dis_out = tui_sfileopen (256);
>  
>    /* Now construct each line */
> -  for (; count > 0; count--, lines++)
> +  for (; count > 0; count--, tui_lines++)
>      {
> -      if (lines->addr_string)
> -        xfree (lines->addr_string);
> -      if (lines->insn)
> -        xfree (lines->insn);
> +      if (tui_lines->addr_string)
> +        xfree (tui_lines->addr_string);
> +      if (tui_lines->insn)
> +        xfree (tui_lines->insn);
>        
>        print_address (pc, gdb_dis_out);
> -      lines->addr = pc;
> -      lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
> +      tui_lines->addr = pc;
> +      tui_lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
>  
>        ui_file_rewind (gdb_dis_out);
>  
>        pc = pc + gdb_print_insn (pc, gdb_dis_out);
>  
> -      lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
> +      tui_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
>  
>        /* reset the buffer to empty */
>        ui_file_rewind (gdb_dis_out);
> @@ -92,21 +92,21 @@ tui_find_disassembly_address (CORE_ADDR 
>    CORE_ADDR new_low;
>    int max_lines;
>    int i;
> -  struct tui_asm_line* lines;
> +  struct tui_asm_line* tui_lines;
>  
>    max_lines = (from > 0) ? from : - from;
>    if (max_lines <= 1)
>       return pc;
>  
> -  lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
> +  tui_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
>                                           * max_lines);
> -  memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
> +  memset (tui_lines, 0, sizeof (struct tui_asm_line) * max_lines);
>  
>    new_low = pc;
>    if (from > 0)
>      {
> -      tui_disassemble (lines, pc, max_lines);
> -      new_low = lines[max_lines - 1].addr;
> +      tui_disassemble (tui_lines, pc, max_lines);
> +      new_low = tui_lines[max_lines - 1].addr;
>      }
>    else
>      {
> @@ -127,8 +127,8 @@ tui_find_disassembly_address (CORE_ADDR 
>           else
>              new_low += 1 * max_lines;
>  
> -         tui_disassemble (lines, new_low, max_lines);
> -         last_addr = lines[pos].addr;
> +         tui_disassemble (tui_lines, new_low, max_lines);
> +         last_addr = tui_lines[pos].addr;
>        } while (last_addr > pc && msymbol);
>  
>        /* Scan forward disassembling one instruction at a time
> @@ -145,7 +145,7 @@ tui_find_disassembly_address (CORE_ADDR 
>              if (pos >= max_lines)
>                pos = 0;
>  
> -            next_addr = tui_disassemble (&lines[pos], last_addr, 1);
> +            next_addr = tui_disassemble (&tui_lines[pos], last_addr, 1);
>  
>              /* If there are some problems while disassembling exit.  */
>              if (next_addr <= last_addr)
> @@ -155,12 +155,12 @@ tui_find_disassembly_address (CORE_ADDR 
>        pos++;
>        if (pos >= max_lines)
>           pos = 0;
> -      new_low = lines[pos].addr;
> +      new_low = tui_lines[pos].addr;
>      }
>    for (i = 0; i < max_lines; i++)
>      {
> -      xfree (lines[i].addr_string);
> -      xfree (lines[i].insn);
> +      xfree (tui_lines[i].addr_string);
> +      xfree (tui_lines[i].insn);
>      }
>    return new_low;
>  }
> @@ -176,7 +176,7 @@ tui_set_disassem_content (CORE_ADDR pc)
>    CORE_ADDR cur_pc;
>    struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
>    int tab_len = tui_default_tab_len ();
> -  struct tui_asm_line* lines;
> +  struct tui_asm_line* tui_lines;
>    int insn_pos;
>    int addr_size, max_size;
>    char* line;
> @@ -195,24 +195,24 @@ tui_set_disassem_content (CORE_ADDR pc)
>    max_lines = TUI_DISASM_WIN->generic.height - 2;	/* account for hilite */
>  
>    /* Get temporary table that will hold all strings (addr & insn).  */
> -  lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
> +  tui_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
>                                           * max_lines);
> -  memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
> +  memset (tui_lines, 0, sizeof (struct tui_asm_line) * max_lines);
>  
>    line_width = TUI_DISASM_WIN->generic.width - 1;
>  
> -  tui_disassemble (lines, pc, max_lines);
> +  tui_disassemble (tui_lines, pc, max_lines);
>  
>    /* See what is the maximum length of an address and of a line.  */
>    addr_size = 0;
>    max_size = 0;
>    for (i = 0; i < max_lines; i++)
>      {
> -      size_t len = strlen (lines[i].addr_string);
> +      size_t len = strlen (tui_lines[i].addr_string);
>        if (len > addr_size)
>          addr_size = len;
>  
> -      len = strlen (lines[i].insn) + tab_len;
> +      len = strlen (tui_lines[i].insn) + tab_len;
>        if (len > max_size)
>          max_size = len;
>      }
> @@ -231,7 +231,7 @@ tui_set_disassem_content (CORE_ADDR pc)
>  
>        element = (struct tui_win_element *) TUI_DISASM_WIN->generic.content[i];
>        src = &element->which_element.source;
> -      strcpy (line, lines[i].addr_string);
> +      strcpy (line, tui_lines[i].addr_string);
>        cur_len = strlen (line);
>  
>        /* Add spaces to make the instructions start on the same column */
> @@ -241,7 +241,7 @@ tui_set_disassem_content (CORE_ADDR pc)
>            cur_len++;
>          }
>  
> -      strcat (line, lines[i].insn);
> +      strcat (line, tui_lines[i].insn);
>  
>        /* Now copy the line taking the offset into account */
>        if (strlen (line) > offset)
> @@ -249,15 +249,15 @@ tui_set_disassem_content (CORE_ADDR pc)
>        else
>          src->line[0] = '\0';
>  
> -      src->line_or_addr.addr = lines[i].addr;
> -      src->is_exec_point = lines[i].addr == cur_pc;
> +      src->line_or_addr.addr = tui_lines[i].addr;
> +      src->is_exec_point = tui_lines[i].addr == cur_pc;
>  
>        /* See whether there is a breakpoint installed.  */
>        src->has_break = (!src->is_exec_point
>                         && breakpoint_here_p (pc) != no_breakpoint_here);
>  
> -      xfree (lines[i].addr_string);
> -      xfree (lines[i].insn);
> +      xfree (tui_lines[i].addr_string);
> +      xfree (tui_lines[i].insn);
>      }
>    TUI_DISASM_WIN->generic.content_size = i;
>    return TUI_SUCCESS;
> Index: tui-regs.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/tui/tui-regs.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 tui-regs.c
> --- tui-regs.c	10 Feb 2004 19:08:16 -0000	1.11
> +++ tui-regs.c	23 Feb 2004 22:55:21 -0000
> @@ -277,7 +277,7 @@ tui_display_registers_from (int start_el
>        TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
>      {
>        int i = start_element_no;
> -      int j, value_chars_wide, item_win_width, cur_y, label_width;
> +      int j, value_chars_wide, item_win_width, cur_y, tui_label_width;
>        enum precision_type precision;
>  
>        precision = (TUI_DATA_WIN->detail.data_display_info.regs_display_type
> @@ -287,7 +287,7 @@ tui_display_registers_from (int start_el
>  	  TUI_DATA_WIN->detail.data_display_info.regs_display_type == TUI_DFLOAT_REGS)
>  	{
>  	  value_chars_wide = DOUBLE_FLOAT_VALUE_WIDTH;
> -	  label_width = DOUBLE_FLOAT_LABEL_WIDTH;
> +	  tui_label_width = DOUBLE_FLOAT_LABEL_WIDTH;
>  	}
>        else
>  	{
> @@ -295,15 +295,15 @@ tui_display_registers_from (int start_el
>  	      TUI_SFLOAT_REGS)
>  	    {
>  	      value_chars_wide = SINGLE_FLOAT_VALUE_WIDTH;
> -	      label_width = SINGLE_FLOAT_LABEL_WIDTH;
> +	      tui_label_width = SINGLE_FLOAT_LABEL_WIDTH;
>  	    }
>  	  else
>  	    {
>  	      value_chars_wide = SINGLE_VALUE_WIDTH;
> -	      label_width = SINGLE_LABEL_WIDTH;
> +	      tui_label_width = SINGLE_LABEL_WIDTH;
>  	    }
>  	}
> -      item_win_width = value_chars_wide + label_width;
> +      item_win_width = value_chars_wide + tui_label_width;
>        /*
>           ** Now create each data "sub" window, and write the display into it.
>         */
> @@ -859,7 +859,7 @@ tui_display_register (int reg_num,
>      {
>        int i;
>        char buf[40];
> -      int value_chars_wide, label_width;
> +      int value_chars_wide, tui_label_width;
>        struct tui_data_element * data_element_ptr = &((tui_win_content)
>  				    win_info->content)[0]->which_element.data;
>  
> @@ -867,7 +867,7 @@ tui_display_register (int reg_num,
>  	  TUI_DATA_WIN->detail.data_display_info.regs_display_type == TUI_DFLOAT_REGS)
>  	{
>  	  value_chars_wide = DOUBLE_FLOAT_VALUE_WIDTH;
> -	  label_width = DOUBLE_FLOAT_LABEL_WIDTH;
> +	  tui_label_width = DOUBLE_FLOAT_LABEL_WIDTH;
>  	}
>        else
>  	{
> @@ -875,18 +875,18 @@ tui_display_register (int reg_num,
>  	      TUI_SFLOAT_REGS)
>  	    {
>  	      value_chars_wide = SINGLE_FLOAT_VALUE_WIDTH;
> -	      label_width = SINGLE_FLOAT_LABEL_WIDTH;
> +	      tui_label_width = SINGLE_FLOAT_LABEL_WIDTH;
>  	    }
>  	  else
>  	    {
>  	      value_chars_wide = SINGLE_VALUE_WIDTH;
> -	      label_width = SINGLE_LABEL_WIDTH;
> +	      tui_label_width = SINGLE_LABEL_WIDTH;
>  	    }
>  	}
>  
>        buf[0] = (char) 0;
>        tui_register_format (buf,
> -			  value_chars_wide + label_width,
> +			  value_chars_wide + tui_label_width,
>  			  reg_num,
>  			  data_element_ptr,
>  			  precision);


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

* Re: [RFA] Fix TUI build failure on AiX 4.3.2
  2004-02-24 23:18 ` Andrew Cagney
@ 2004-02-25  1:11   ` Joel Brobecker
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2004-02-25  1:11 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

> >So I suggest the following change, where I appended "tui_" to
> >the variable names to avoid the macro expansion (short of finding
> >a better replacement name).
> >
> >2004-02-23  J. Brobecker  <brobecker@gnat.com>
> >
> >        * tui-disasm.c: %s/lines/tui_lines/g to avoid a collision
> >        with the lines macro defined in term.h on AiX.
> 
> For this one I think "asm_lines" reads better.

Agreed.

> >        * tui-regs.c: %s/label_width/tui_label_width/g, to avoid
> >        a collision with the label_width macro defined in term.h on AiX.
> 
> For this one, yes, I can't think of anything better.  Suggest adding a 
> comment so that someone doesn't change it back.
> 
> Either way, obishly approved,
> Andrew

Thank you. Here is what I ended up checking in.

2004-02-24  J. Brobecker  <brobecker@gnat.com>

        * tui/tui-disasm.c: %s/lines/asm_lines/g to avoid a collision
        with the lines macro defined in term.h on AiX.
        * tui/tui-regs.c: %s/label_width/tui_label_width/g, to avoid
        a collision with the label_width macro defined in term.h on AiX.

-- 
Joel

[-- Attachment #2: tui-aix.diff --]
[-- Type: text/plain, Size: 10023 bytes --]

Index: tui-disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-disasm.c,v
retrieving revision 1.13
diff -u -p -r1.13 tui-disasm.c
--- tui-disasm.c	10 Feb 2004 19:08:15 -0000	1.13
+++ tui-disasm.c	25 Feb 2004 01:05:14 -0000
@@ -51,7 +51,7 @@ struct tui_asm_line 
    Disassemble count lines starting at pc.
    Return address of the count'th instruction after pc.  */
 static CORE_ADDR
-tui_disassemble (struct tui_asm_line* lines, CORE_ADDR pc, int count)
+tui_disassemble (struct tui_asm_line* asm_lines, CORE_ADDR pc, int count)
 {
   struct ui_file *gdb_dis_out;
 
@@ -59,22 +59,22 @@ tui_disassemble (struct tui_asm_line* li
   gdb_dis_out = tui_sfileopen (256);
 
   /* Now construct each line */
-  for (; count > 0; count--, lines++)
+  for (; count > 0; count--, asm_lines++)
     {
-      if (lines->addr_string)
-        xfree (lines->addr_string);
-      if (lines->insn)
-        xfree (lines->insn);
+      if (asm_lines->addr_string)
+        xfree (asm_lines->addr_string);
+      if (asm_lines->insn)
+        xfree (asm_lines->insn);
       
       print_address (pc, gdb_dis_out);
-      lines->addr = pc;
-      lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
+      asm_lines->addr = pc;
+      asm_lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
 
       ui_file_rewind (gdb_dis_out);
 
       pc = pc + gdb_print_insn (pc, gdb_dis_out);
 
-      lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
+      asm_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
 
       /* reset the buffer to empty */
       ui_file_rewind (gdb_dis_out);
@@ -92,21 +92,21 @@ tui_find_disassembly_address (CORE_ADDR 
   CORE_ADDR new_low;
   int max_lines;
   int i;
-  struct tui_asm_line* lines;
+  struct tui_asm_line* asm_lines;
 
   max_lines = (from > 0) ? from : - from;
   if (max_lines <= 1)
      return pc;
 
-  lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
+  asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
                                          * max_lines);
-  memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
+  memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
 
   new_low = pc;
   if (from > 0)
     {
-      tui_disassemble (lines, pc, max_lines);
-      new_low = lines[max_lines - 1].addr;
+      tui_disassemble (asm_lines, pc, max_lines);
+      new_low = asm_lines[max_lines - 1].addr;
     }
   else
     {
@@ -127,8 +127,8 @@ tui_find_disassembly_address (CORE_ADDR 
          else
             new_low += 1 * max_lines;
 
-         tui_disassemble (lines, new_low, max_lines);
-         last_addr = lines[pos].addr;
+         tui_disassemble (asm_lines, new_low, max_lines);
+         last_addr = asm_lines[pos].addr;
       } while (last_addr > pc && msymbol);
 
       /* Scan forward disassembling one instruction at a time
@@ -145,7 +145,7 @@ tui_find_disassembly_address (CORE_ADDR 
             if (pos >= max_lines)
               pos = 0;
 
-            next_addr = tui_disassemble (&lines[pos], last_addr, 1);
+            next_addr = tui_disassemble (&asm_lines[pos], last_addr, 1);
 
             /* If there are some problems while disassembling exit.  */
             if (next_addr <= last_addr)
@@ -155,12 +155,12 @@ tui_find_disassembly_address (CORE_ADDR 
       pos++;
       if (pos >= max_lines)
          pos = 0;
-      new_low = lines[pos].addr;
+      new_low = asm_lines[pos].addr;
     }
   for (i = 0; i < max_lines; i++)
     {
-      xfree (lines[i].addr_string);
-      xfree (lines[i].insn);
+      xfree (asm_lines[i].addr_string);
+      xfree (asm_lines[i].insn);
     }
   return new_low;
 }
@@ -176,7 +176,7 @@ tui_set_disassem_content (CORE_ADDR pc)
   CORE_ADDR cur_pc;
   struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
   int tab_len = tui_default_tab_len ();
-  struct tui_asm_line* lines;
+  struct tui_asm_line* asm_lines;
   int insn_pos;
   int addr_size, max_size;
   char* line;
@@ -195,24 +195,24 @@ tui_set_disassem_content (CORE_ADDR pc)
   max_lines = TUI_DISASM_WIN->generic.height - 2;	/* account for hilite */
 
   /* Get temporary table that will hold all strings (addr & insn).  */
-  lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
+  asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
                                          * max_lines);
-  memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
+  memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
 
   line_width = TUI_DISASM_WIN->generic.width - 1;
 
-  tui_disassemble (lines, pc, max_lines);
+  tui_disassemble (asm_lines, pc, max_lines);
 
   /* See what is the maximum length of an address and of a line.  */
   addr_size = 0;
   max_size = 0;
   for (i = 0; i < max_lines; i++)
     {
-      size_t len = strlen (lines[i].addr_string);
+      size_t len = strlen (asm_lines[i].addr_string);
       if (len > addr_size)
         addr_size = len;
 
-      len = strlen (lines[i].insn) + tab_len;
+      len = strlen (asm_lines[i].insn) + tab_len;
       if (len > max_size)
         max_size = len;
     }
@@ -231,7 +231,7 @@ tui_set_disassem_content (CORE_ADDR pc)
 
       element = (struct tui_win_element *) TUI_DISASM_WIN->generic.content[i];
       src = &element->which_element.source;
-      strcpy (line, lines[i].addr_string);
+      strcpy (line, asm_lines[i].addr_string);
       cur_len = strlen (line);
 
       /* Add spaces to make the instructions start on the same column */
@@ -241,7 +241,7 @@ tui_set_disassem_content (CORE_ADDR pc)
           cur_len++;
         }
 
-      strcat (line, lines[i].insn);
+      strcat (line, asm_lines[i].insn);
 
       /* Now copy the line taking the offset into account */
       if (strlen (line) > offset)
@@ -249,15 +249,15 @@ tui_set_disassem_content (CORE_ADDR pc)
       else
         src->line[0] = '\0';
 
-      src->line_or_addr.addr = lines[i].addr;
-      src->is_exec_point = lines[i].addr == cur_pc;
+      src->line_or_addr.addr = asm_lines[i].addr;
+      src->is_exec_point = asm_lines[i].addr == cur_pc;
 
       /* See whether there is a breakpoint installed.  */
       src->has_break = (!src->is_exec_point
                        && breakpoint_here_p (pc) != no_breakpoint_here);
 
-      xfree (lines[i].addr_string);
-      xfree (lines[i].insn);
+      xfree (asm_lines[i].addr_string);
+      xfree (asm_lines[i].insn);
     }
   TUI_DISASM_WIN->generic.content_size = i;
   return TUI_SUCCESS;
Index: tui-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-regs.c,v
retrieving revision 1.11
diff -u -p -r1.11 tui-regs.c
--- tui-regs.c	10 Feb 2004 19:08:16 -0000	1.11
+++ tui-regs.c	25 Feb 2004 01:05:14 -0000
@@ -277,9 +277,15 @@ tui_display_registers_from (int start_el
       TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0)
     {
       int i = start_element_no;
-      int j, value_chars_wide, item_win_width, cur_y, label_width;
+      int j, value_chars_wide, item_win_width, cur_y;
       enum precision_type precision;
 
+      /* Do not rename the following variable into "label_width".
+         Unfortunately, term.h on AiX systems defines a macro with
+         the same name, which causes a build failure if we use the
+         same name for this variable.  */
+      int tui_label_width;
+
       precision = (TUI_DATA_WIN->detail.data_display_info.regs_display_type
 		   == TUI_DFLOAT_REGS) ?
 	double_precision : unspecified_precision;
@@ -287,7 +293,7 @@ tui_display_registers_from (int start_el
 	  TUI_DATA_WIN->detail.data_display_info.regs_display_type == TUI_DFLOAT_REGS)
 	{
 	  value_chars_wide = DOUBLE_FLOAT_VALUE_WIDTH;
-	  label_width = DOUBLE_FLOAT_LABEL_WIDTH;
+	  tui_label_width = DOUBLE_FLOAT_LABEL_WIDTH;
 	}
       else
 	{
@@ -295,15 +301,15 @@ tui_display_registers_from (int start_el
 	      TUI_SFLOAT_REGS)
 	    {
 	      value_chars_wide = SINGLE_FLOAT_VALUE_WIDTH;
-	      label_width = SINGLE_FLOAT_LABEL_WIDTH;
+	      tui_label_width = SINGLE_FLOAT_LABEL_WIDTH;
 	    }
 	  else
 	    {
 	      value_chars_wide = SINGLE_VALUE_WIDTH;
-	      label_width = SINGLE_LABEL_WIDTH;
+	      tui_label_width = SINGLE_LABEL_WIDTH;
 	    }
 	}
-      item_win_width = value_chars_wide + label_width;
+      item_win_width = value_chars_wide + tui_label_width;
       /*
          ** Now create each data "sub" window, and write the display into it.
        */
@@ -859,15 +865,21 @@ tui_display_register (int reg_num,
     {
       int i;
       char buf[40];
-      int value_chars_wide, label_width;
+      int value_chars_wide;
       struct tui_data_element * data_element_ptr = &((tui_win_content)
 				    win_info->content)[0]->which_element.data;
 
+      /* Do not rename the following variable into "label_width".
+         Unfortunately, term.h on AiX systems defines a macro with
+         the same name, which causes a build failure if we use the
+         same name for this variable.  */
+      int tui_label_width;
+
       if (IS_64BIT ||
 	  TUI_DATA_WIN->detail.data_display_info.regs_display_type == TUI_DFLOAT_REGS)
 	{
 	  value_chars_wide = DOUBLE_FLOAT_VALUE_WIDTH;
-	  label_width = DOUBLE_FLOAT_LABEL_WIDTH;
+	  tui_label_width = DOUBLE_FLOAT_LABEL_WIDTH;
 	}
       else
 	{
@@ -875,18 +887,18 @@ tui_display_register (int reg_num,
 	      TUI_SFLOAT_REGS)
 	    {
 	      value_chars_wide = SINGLE_FLOAT_VALUE_WIDTH;
-	      label_width = SINGLE_FLOAT_LABEL_WIDTH;
+	      tui_label_width = SINGLE_FLOAT_LABEL_WIDTH;
 	    }
 	  else
 	    {
 	      value_chars_wide = SINGLE_VALUE_WIDTH;
-	      label_width = SINGLE_LABEL_WIDTH;
+	      tui_label_width = SINGLE_LABEL_WIDTH;
 	    }
 	}
 
       buf[0] = (char) 0;
       tui_register_format (buf,
-			  value_chars_wide + label_width,
+			  value_chars_wide + tui_label_width,
 			  reg_num,
 			  data_element_ptr,
 			  precision);

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

end of thread, other threads:[~2004-02-25  1:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-23 23:05 [RFA] Fix TUI build failure on AiX 4.3.2 Joel Brobecker
2004-02-24 23:18 ` Andrew Cagney
2004-02-25  1:11   ` Joel Brobecker

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