Change tui_update_source_window for better type safety
authorTom Tromey <tom@tromey.com>
Sun, 16 Jun 2019 22:31:37 +0000 (16:31 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 25 Jun 2019 13:48:38 +0000 (07:48 -0600)
tui_update_source_window can only be called for source and disassembly
windows, so change the argument type to enforce this at compile time.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.h (tui_update_source_window)
(tui_update_source_window_as_is): Change parameter type.
* tui/tui-winsource.c (tui_update_source_window): Change win_info
to be a tui_source_window_base.
(tui_update_source_window_as_is): Likewise.
* tui/tui-win.c (make_visible_with_new_height): Update.

gdb/ChangeLog
gdb/tui/tui-win.c
gdb/tui/tui-winsource.c
gdb/tui/tui-winsource.h

index 25c2d01..e7395da 100644 (file)
@@ -1,5 +1,14 @@
 2019-06-25  Tom Tromey  <tom@tromey.com>
 
+       * tui/tui-winsource.h (tui_update_source_window)
+       (tui_update_source_window_as_is): Change parameter type.
+       * tui/tui-winsource.c (tui_update_source_window): Change win_info
+       to be a tui_source_window_base.
+       (tui_update_source_window_as_is): Likewise.
+       * tui/tui-win.c (make_visible_with_new_height): Update.
+
+2019-06-25  Tom Tromey  <tom@tromey.com>
+
        * tui/tui-winsource.c (tui_erase_source_content)
        (tui_show_source_content, tui_show_exec_info_content)
        (tui_erase_exec_info_content): Use refresh_window method.
index a40e6c5..c8fd267 100644 (file)
@@ -1327,7 +1327,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
 
          line_or_addr = base->start_line_or_addr;
          tui_free_win_content (win_info);
-         tui_update_source_window (win_info, gdbarch,
+         tui_update_source_window (base, gdbarch,
                                    cursal.symtab, line_or_addr, TRUE);
        }
       else if (deprecated_safe_get_selected_frame () != NULL)
@@ -1349,7 +1349,7 @@ make_visible_with_new_height (struct tui_win_info *win_info)
              line.loa = LOA_ADDRESS;
              find_line_pc (s, cursal.line, &line.u.addr);
            }
-         tui_update_source_window (win_info, gdbarch, s, line, TRUE);
+         tui_update_source_window (base, gdbarch, s, line, TRUE);
        }
       if (win_info->has_locator ())
        {
index 254c7e0..1ec9cec 100644 (file)
@@ -69,14 +69,13 @@ tui_display_main ()
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
-tui_update_source_window (struct tui_win_info *win_info,
+tui_update_source_window (struct tui_source_window_base *win_info,
                          struct gdbarch *gdbarch,
                          struct symtab *s,
                          struct tui_line_or_address line_or_addr,
                          int noerror)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  base->horizontal_offset = 0;
+  win_info->horizontal_offset = 0;
   tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
 
   return;
@@ -86,7 +85,7 @@ tui_update_source_window (struct tui_win_info *win_info,
 /* Function to display source in the source/asm window.  This function
    shows the source as specified by the horizontal offset.  */
 void
-tui_update_source_window_as_is (struct tui_win_info *win_info, 
+tui_update_source_window_as_is (struct tui_source_window_base *win_info, 
                                struct gdbarch *gdbarch,
                                struct symtab *s,
                                struct tui_line_or_address line_or_addr, 
index ada3964..6f2dc35 100644 (file)
@@ -39,11 +39,11 @@ extern int tui_update_breakpoint_info (struct tui_win_info *win,
 
 /* Function to display the "main" routine.  */
 extern void tui_display_main (void);
-extern void tui_update_source_window (struct tui_win_info *, 
+extern void tui_update_source_window (struct tui_source_window_base *, 
                                      struct gdbarch *, struct symtab *,
                                      struct tui_line_or_address, 
                                      int);
-extern void tui_update_source_window_as_is (struct tui_win_info *,
+extern void tui_update_source_window_as_is (struct tui_source_window_base *,
                                            struct gdbarch *, struct symtab *,
                                            struct tui_line_or_address, 
                                            int);