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

Re: [RFA] Fix TUI build failure on AiX 4.3.2


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);


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