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]

PATCH: Problem union comparision in TUI


Hi,

I have observed this problem in the sh-elf configuration of GDB. It is not visible in the i686-linux configuration because it uses the following union in a different way.

/* Structure describing source line or line address */
union tui_line_or_address
{
  int line_no;
  CORE_ADDR addr;
};


The problem is that the union is always compared using 'addr'. In the case where it was set using 'line_no', as it is in sh-elf, half the union contains garbage. This appears to be killing the comparison in tui_set_is_exec_point_at() in tui-winsource.c.


The result is that the current line is never highlighted as it should be. I assume the reason it works on i686-linux is that that host/target uses the addr field rather than the line_no field.

The attached patch provides one way to fix the problem. I could not think of any way to fix the comparison because there is no way I can see to know which mode it is using, so I have changed the type of line_no in the union to match the type of addr. This does not seem to be the Right Thing to do with a union (because it might as well be one variable), but I can't see any other down side.

Andrew Stubbs
Index: src/gdb/tui/tui-data.h
===================================================================
--- src.orig/gdb/tui/tui-data.h	2004-03-13 14:14:01.000000000 +0000
+++ src/gdb/tui/tui-data.h	2005-10-17 14:21:23.000000000 +0100
@@ -149,7 +149,7 @@ enum tui_register_display_type
 /* Structure describing source line or line address */
 union tui_line_or_address
 {
-  int line_no;
+  CORE_ADDR line_no;
   CORE_ADDR addr;
 };
 

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