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 25c2d01adc513606ecde719dfca22360bb3a89a2..e7395da56eda0799f3e21513745b12ca50fa251b 100644 (file)
@@ -1,3 +1,12 @@
+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)
index a40e6c5206b075b9c95dcea21574a556257c3dcf..c8fd267f3625375a8f7791a8382c1fe0adeed78b 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 254c7e00dcb3392c87db89af53d06c725385fbfd..1ec9cecdc9c9dac475fe5b87b71f0ccc7a15b8f4 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 ada3964ad1a7c658f7d31002e28cb7bc23759350..6f2dc3533f77e42914b432b06b773f811b67d4b1 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);