]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Kill init_sal
authorPedro Alves <palves@redhat.com>
Mon, 4 Sep 2017 16:10:13 +0000 (17:10 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 4 Sep 2017 16:11:45 +0000 (17:11 +0100)
Instead, make symtab_and_line initialize its members itself.  Many
symtab_and_line declarations are moved to where the object is
initialized at the same time both for clarity and to avoid double
initialization.  A few functions, like e.g., find_frame_sal are
adjusted to return the sal using normal function return instead of an
output parameter likewise to avoid having to default-construct a sal
and then immediately have the object overwritten.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

* ada-lang.c (is_known_support_routine): Move sal declaration to
where it is initialized.
* breakpoint.c (create_internal_breakpoint, init_catchpoint)
(parse_breakpoint_sals, decode_static_tracepoint_spec)
(clear_command, update_static_tracepoint): Remove init_sal
references.  Move declarations closer to initializations.
* cli/cli-cmds.c (list_command): Move sal declarations closer to
initializations.
* elfread.c (elf_gnu_ifunc_resolver_stop): Remove init_sal
references.  Move sal declarations closer to initializations.
* frame.c (find_frame_sal): Return a symtab_and_line via function
return instead of output parameter.  Remove init_sal references.
* frame.h (find_frame_sal): Return a symtab_and_line via function
return instead of output parameter.
* guile/scm-frame.c (gdbscm_frame_sal): Adjust.
* guile/scm-symtab.c (stscm_make_sal_smob): Use in-place new
instead of memset.
(gdbscm_find_pc_line): Remove init_sal reference.
* infcall.c (call_function_by_hand_dummy): Remove init_sal
references.  Move declarations closer to initializations.
* infcmd.c (set_step_frame): Update.  Move declarations closer to
initializations.
(finish_backward): Remove init_sal references.  Move declarations
closer to initializations.
* infrun.c (process_event_stop_test, handle_step_into_function)
(insert_hp_step_resume_breakpoint_at_frame)
(insert_step_resume_breakpoint_at_caller): Likewise.
* linespec.c (create_sals_line_offset, decode_digits_ordinary)
(symbol_to_sal): Likewise.
* probe.c (parse_probes_in_pspace): Remove init_sal reference.
* python/py-frame.c (frapy_find_sal): Move sal declaration closer
to its initialization.
* reverse.c (save_bookmark_command): Use new/delete.  Remove
init_sal references.  Move declarations closer to initializations.
* source.c (get_current_source_symtab_and_line): Remove brace
initialization.
(set_current_source_symtab_and_line): Now takes the sal by const
reference.  Remove brace initialization.
(line_info): Remove init_sal reference.
* source.h (set_current_source_symtab_and_line): Now takes a
symtab_and_line via const reference.
* stack.c (set_current_sal_from_frame): Adjust.
(print_frame_info): Adjust.
(get_last_displayed_sal): Return the sal via function return
instead of via output parameter.  Simplify.
(frame_info): Adjust.
* stack.h (get_last_displayed_sal): Return the sal via function
return instead of via output parameter.
* symtab.c (init_sal): Delete.
(find_pc_sect_line): Remove init_sal references.  Move
declarations closer to initializations.
(find_function_start_sal): Remove init_sal references.  Move
declarations closer to initializations.
* symtab.h (struct symtab_and_line): In-class initialize all
fields.
* tracepoint.c (set_traceframe_context)
(print_one_static_tracepoint_marker): Remove init_sal references.
Move declarations closer to initializations.
* tui/tui-disasm.c (tui_show_disassem_and_update_source): Adjust.
* tui/tui-stack.c (tui_show_frame_info): Adjust.  Move
declarations closer to initializations.
* tui/tui-winsource.c (tui_update_source_window_as_is): Remove
init_sal references.  Adjust.

26 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/breakpoint.c
gdb/cli/cli-cmds.c
gdb/elfread.c
gdb/frame.c
gdb/frame.h
gdb/guile/scm-frame.c
gdb/guile/scm-symtab.c
gdb/infcall.c
gdb/infcmd.c
gdb/infrun.c
gdb/linespec.c
gdb/probe.c
gdb/python/py-frame.c
gdb/reverse.c
gdb/source.c
gdb/source.h
gdb/stack.c
gdb/stack.h
gdb/symtab.c
gdb/symtab.h
gdb/tracepoint.c
gdb/tui/tui-disasm.c
gdb/tui/tui-stack.c
gdb/tui/tui-winsource.c

index 1fbceff98ead27bdf462bc4a2c46026bb23b7910..6b4000b044a26118f9ca2d4d6cab5fd97328085d 100644 (file)
@@ -1,3 +1,69 @@
+2017-09-04  Pedro Alves  <palves@redhat.com>
+
+       * ada-lang.c (is_known_support_routine): Move sal declaration to
+       where it is initialized.
+       * breakpoint.c (create_internal_breakpoint, init_catchpoint)
+       (parse_breakpoint_sals, decode_static_tracepoint_spec)
+       (clear_command, update_static_tracepoint): Remove init_sal
+       references.  Move declarations closer to initializations.
+       * cli/cli-cmds.c (list_command): Move sal declarations closer to
+       initializations.
+       * elfread.c (elf_gnu_ifunc_resolver_stop): Remove init_sal
+       references.  Move sal declarations closer to initializations.
+       * frame.c (find_frame_sal): Return a symtab_and_line via function
+       return instead of output parameter.  Remove init_sal references.
+       * frame.h (find_frame_sal): Return a symtab_and_line via function
+       return instead of output parameter.
+       * guile/scm-frame.c (gdbscm_frame_sal): Adjust.
+       * guile/scm-symtab.c (stscm_make_sal_smob): Use in-place new
+       instead of memset.
+       (gdbscm_find_pc_line): Remove init_sal reference.
+       * infcall.c (call_function_by_hand_dummy): Remove init_sal
+       references.  Move declarations closer to initializations.
+       * infcmd.c (set_step_frame): Update.  Move declarations closer to
+       initializations.
+       (finish_backward): Remove init_sal references.  Move declarations
+       closer to initializations.
+       * infrun.c (process_event_stop_test, handle_step_into_function)
+       (insert_hp_step_resume_breakpoint_at_frame)
+       (insert_step_resume_breakpoint_at_caller): Likewise.
+       * linespec.c (create_sals_line_offset, decode_digits_ordinary)
+       (symbol_to_sal): Likewise.
+       * probe.c (parse_probes_in_pspace): Remove init_sal reference.
+       * python/py-frame.c (frapy_find_sal): Move sal declaration closer
+       to its initialization.
+       * reverse.c (save_bookmark_command): Use new/delete.  Remove
+       init_sal references.  Move declarations closer to initializations.
+       * source.c (get_current_source_symtab_and_line): Remove brace
+       initialization.
+       (set_current_source_symtab_and_line): Now takes the sal by const
+       reference.  Remove brace initialization.
+       (line_info): Remove init_sal reference.
+       * source.h (set_current_source_symtab_and_line): Now takes a
+       symtab_and_line via const reference.
+       * stack.c (set_current_sal_from_frame): Adjust.
+       (print_frame_info): Adjust.
+       (get_last_displayed_sal): Return the sal via function return
+       instead of via output parameter.  Simplify.
+       (frame_info): Adjust.
+       * stack.h (get_last_displayed_sal): Return the sal via function
+       return instead of via output parameter.
+       * symtab.c (init_sal): Delete.
+       (find_pc_sect_line): Remove init_sal references.  Move
+       declarations closer to initializations.
+       (find_function_start_sal): Remove init_sal references.  Move
+       declarations closer to initializations.
+       * symtab.h (struct symtab_and_line): In-class initialize all
+       fields.
+       * tracepoint.c (set_traceframe_context)
+       (print_one_static_tracepoint_marker): Remove init_sal references.
+       Move declarations closer to initializations.
+       * tui/tui-disasm.c (tui_show_disassem_and_update_source): Adjust.
+       * tui/tui-stack.c (tui_show_frame_info): Adjust.  Move
+       declarations closer to initializations.
+       * tui/tui-winsource.c (tui_update_source_window_as_is): Remove
+       init_sal references.  Adjust.
+
 2017-09-04  Pedro Alves  <palves@redhat.com>
 
        * ax-gdb.c (agent_command_1): Use range-for.
index cbb846c9e59c45cbc23c286398aebf3612b090a7..b4e193ca80214927237f7aeca8711e0abcba5eca 100644 (file)
@@ -11980,7 +11980,6 @@ ada_exception_support_info_sniffer (void)
 static int
 is_known_support_routine (struct frame_info *frame)
 {
-  struct symtab_and_line sal;
   char *func_name;
   enum language func_lang;
   int i;
@@ -11989,7 +11988,7 @@ is_known_support_routine (struct frame_info *frame)
   /* If this code does not have any debugging information (no symtab),
      This cannot be any user code.  */
 
-  find_frame_sal (frame, &sal);
+  symtab_and_line sal = find_frame_sal (frame);
   if (sal.symtab == NULL)
     return 1;
 
index eeaf02716a2d2ca398d45eb685557fd701b49018..778a011161f035a324efc9180d378488052249cf 100644 (file)
@@ -3358,16 +3358,12 @@ create_internal_breakpoint (struct gdbarch *gdbarch,
                            CORE_ADDR address, enum bptype type,
                            const struct breakpoint_ops *ops)
 {
-  struct symtab_and_line sal;
-  struct breakpoint *b;
-
-  init_sal (&sal);             /* Initialize to zeroes.  */
-
+  symtab_and_line sal;
   sal.pc = address;
   sal.section = find_pc_overlay (sal.pc);
   sal.pspace = current_program_space;
 
-  b = set_raw_breakpoint (gdbarch, sal, type, ops);
+  breakpoint *b = set_raw_breakpoint (gdbarch, sal, type, ops);
   b->number = internal_breakpoint_number--;
   b->disposition = disp_donttouch;
 
@@ -8525,9 +8521,7 @@ init_catchpoint (struct breakpoint *b,
                 const char *cond_string,
                 const struct breakpoint_ops *ops)
 {
-  struct symtab_and_line sal;
-
-  init_sal (&sal);
+  symtab_and_line sal;
   sal.pspace = current_program_space;
 
   init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops);
@@ -9379,18 +9373,14 @@ parse_breakpoint_sals (const struct event_location *location,
             breakpoint address.  */
          if (last_displayed_sal_is_valid ())
            {
-             struct symtab_and_line sal;
-             CORE_ADDR pc;
-
-             init_sal (&sal);          /* Initialize to zeroes.  */
-
              /* Set sal's pspace, pc, symtab, and line to the values
                 corresponding to the last call to print_frame_info.
                 Be sure to reinitialize LINE with NOTCURRENT == 0
                 as the breakpoint line number is inappropriate otherwise.
                 find_pc_line would adjust PC, re-set it back.  */
-             get_last_displayed_sal (&sal);
-             pc = sal.pc;
+             symtab_and_line sal = get_last_displayed_sal ();
+             CORE_ADDR pc = sal.pc;
+
              sal = find_pc_line (pc, 0);
 
              /* "break" without arguments is equivalent to "break *PC"
@@ -9600,10 +9590,7 @@ decode_static_tracepoint_spec (const char **arg_p)
 
       marker = VEC_index (static_tracepoint_marker_p, markers, i);
 
-      symtab_and_line sal;
-      init_sal (&sal);
-
-      sal = find_pc_line (marker->address, 0);
+      symtab_and_line sal = find_pc_line (marker->address, 0);
       sal.pc = marker->address;
       sals.push_back (sal);
 
@@ -11799,12 +11786,10 @@ clear_command (char *arg, int from_tty)
     }
   else
     {
-      init_sal (&last_sal);            /* Initialize to zeroes.  */
-
       /* Set sal's line, symtab, pc, and pspace to the values
         corresponding to the last call to print_frame_info.  If the
         codepoint is not valid, this will set all the fields to 0.  */
-      get_last_displayed_sal (&last_sal);
+      last_sal = get_last_displayed_sal ();
       if (last_sal.symtab == 0)
        error (_("No source file specified."));
 
@@ -13883,7 +13868,6 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
 
       if (!VEC_empty(static_tracepoint_marker_p, markers))
        {
-         struct symtab_and_line sal2;
          struct symbol *sym;
          struct static_tracepoint_marker *tpmarker;
          struct ui_out *uiout = current_uiout;
@@ -13898,11 +13882,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
                     "found at previous line number"),
                   b->number, tp->static_trace_marker_id);
 
-         init_sal (&sal2);
-
-         sal2.pc = tpmarker->address;
-
-         sal2 = find_pc_line (tpmarker->address, 0);
+         symtab_and_line sal2 = find_pc_line (tpmarker->address, 0);
          sym = find_pc_sect_function (tpmarker->address, NULL);
          uiout->text ("Now in ");
          if (sym)
index dfff87c537a08a0ab1daf335bec259f03a979070..7d7e16a64a8fe7a214ae088615e7e8a390fb1031 100644 (file)
@@ -886,9 +886,6 @@ edit_command (char *arg, int from_tty)
 static void
 list_command (char *arg, int from_tty)
 {
-  struct symtab_and_line sal = { 0 };
-  struct symtab_and_line sal_end = { 0 };
-  struct symtab_and_line cursal = { 0 };
   struct symbol *sym;
   char *arg1;
   int no_end = 1;
@@ -901,7 +898,7 @@ list_command (char *arg, int from_tty)
   if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0'))
     {
       set_default_source_symtab_and_line ();
-      cursal = get_current_source_symtab_and_line ();
+      symtab_and_line cursal = get_current_source_symtab_and_line ();
 
       /* If this is the first "list" since we've set the current
         source line, center the listing around that line.  */
@@ -954,6 +951,7 @@ list_command (char *arg, int from_tty)
     error (_("No symbol table is loaded.  Use the \"file\" command."));
 
   std::vector<symtab_and_line> sals;
+  symtab_and_line sal, sal_end;
 
   arg1 = arg;
   if (*arg1 == ',')
index ddff16b5ef3b79c88221a4e0cb00ccd84abe8eff..cad7aa8647fff3a481ef22308eb8586a71326fbc 100644 (file)
@@ -917,12 +917,10 @@ elf_gnu_ifunc_resolver_stop (struct breakpoint *b)
 
   if (b_return == b)
     {
-      struct symtab_and_line sal;
-
       /* No need to call find_pc_line for symbols resolving as this is only
         a helper breakpointer never shown to the user.  */
 
-      init_sal (&sal);
+      symtab_and_line sal;
       sal.pspace = current_inferior ()->pspace;
       sal.pc = prev_pc;
       sal.section = find_pc_overlay (sal.pc);
index 30e4aeab7e2901074c289ac4d96ebda885805a29..55d4ddb396fa589644bace319dab5f4b6451043a 100644 (file)
@@ -2506,8 +2506,8 @@ get_frame_address_in_block_if_available (struct frame_info *this_frame,
   return 1;
 }
 
-void
-find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal)
+symtab_and_line
+find_frame_sal (frame_info *frame)
 {
   struct frame_info *next_frame;
   int notcurrent;
@@ -2528,21 +2528,21 @@ find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal)
 
       /* If frame is inline, it certainly has symbols.  */
       gdb_assert (sym);
-      init_sal (sal);
+
+      symtab_and_line sal;
       if (SYMBOL_LINE (sym) != 0)
        {
-         sal->symtab = symbol_symtab (sym);
-         sal->line = SYMBOL_LINE (sym);
+         sal.symtab = symbol_symtab (sym);
+         sal.line = SYMBOL_LINE (sym);
        }
       else
        /* If the symbol does not have a location, we don't know where
           the call site is.  Do not pretend to.  This is jarring, but
           we can't do much better.  */
-       sal->pc = get_frame_pc (frame);
+       sal.pc = get_frame_pc (frame);
 
-      sal->pspace = get_frame_program_space (frame);
-
-      return;
+      sal.pspace = get_frame_program_space (frame);
+      return sal;
     }
 
   /* If FRAME is not the innermost frame, that normally means that
@@ -2555,13 +2555,10 @@ find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal)
      instruction/line, consequently, for such cases, want to get the
      line containing fi->pc.  */
   if (!get_frame_pc_if_available (frame, &pc))
-    {
-      init_sal (sal);
-      return;
-    }
+    return {};
 
   notcurrent = (pc != get_frame_address_in_block (frame));
-  (*sal) = find_pc_line (pc, notcurrent);
+  return find_pc_line (pc, notcurrent);
 }
 
 /* Per "frame.h", return the ``address'' of the frame.  Code should
index f3485af925a475acb65eb32088348cb93317291b..3b00d362d979ee4147eb6ca547f826b010567235 100644 (file)
@@ -408,8 +408,7 @@ extern int get_frame_func_if_available (struct frame_info *fi, CORE_ADDR *);
    find_frame_symtab(), find_frame_function().  Each will need to be
    carefully considered to determine if the real intent was for it to
    apply to the PC or the adjusted PC.  */
-extern void find_frame_sal (struct frame_info *frame,
-                           struct symtab_and_line *sal);
+extern symtab_and_line find_frame_sal (frame_info *frame);
 
 /* Set the current source and line to the location given by frame
    FRAME, if possible.  */
index 994f92d41c8eef80aa7795379c1f9b2b2b6c3c38..b2af7432a6308655e9d0b9769344292bc73e5e0e 100644 (file)
@@ -761,7 +761,7 @@ gdbscm_frame_sal (SCM self)
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
-       find_frame_sal (frame, &sal);
+       sal = find_frame_sal (frame);
     }
   CATCH (except, RETURN_MASK_ALL)
     {
index 925ab39573ed2ca29b7892a51c9998f3b2bf6094..755ea672472ba19ecdff4a5669b585972bc9b5b8 100644 (file)
@@ -419,7 +419,7 @@ stscm_make_sal_smob (void)
   SCM s_scm;
 
   s_smob->symtab_scm = SCM_BOOL_F;
-  memset (&s_smob->sal, 0, sizeof (s_smob->sal));
+  new (&s_smob->sal) symtab_and_line ();
   s_scm = scm_new_smob (sal_smob_tag, (scm_t_bits) s_smob);
   gdbscm_init_gsmob (&s_smob->base);
 
@@ -589,9 +589,7 @@ static SCM
 gdbscm_find_pc_line (SCM pc_scm)
 {
   ULONGEST pc_ull;
-  struct symtab_and_line sal;
-
-  init_sal (&sal); /* -Wall */
+  symtab_and_line sal;
 
   gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc_ull);
 
index 38335a799627c491826c41f3191cead06a223243..9e434a9df41e6b299456000a601097d835731cdf 100644 (file)
@@ -1051,17 +1051,16 @@ call_function_by_hand_dummy (struct value *function,
      inferior.  That way it breaks when it returns.  */
 
   {
-    struct breakpoint *bpt, *longjmp_b;
-    struct symtab_and_line sal;
-
-    init_sal (&sal);           /* initialize to zeroes */
+    symtab_and_line sal;
     sal.pspace = current_program_space;
     sal.pc = bp_addr;
     sal.section = find_pc_overlay (sal.pc);
+
     /* Sanity.  The exact same SP value is returned by
        PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
        dummy_id to form the frame ID's stack address.  */
-    bpt = set_momentary_breakpoint (gdbarch, sal, dummy_id, bp_call_dummy);
+    breakpoint *bpt = set_momentary_breakpoint (gdbarch, sal,
+                                               dummy_id, bp_call_dummy);
 
     /* set_momentary_breakpoint invalidates FRAME.  */
     frame = NULL;
@@ -1069,7 +1068,7 @@ call_function_by_hand_dummy (struct value *function,
     bpt->disposition = disp_del;
     gdb_assert (bpt->related_breakpoint == bpt);
 
-    longjmp_b = set_longjmp_breakpoint_for_call_dummy ();
+    breakpoint *longjmp_b = set_longjmp_breakpoint_for_call_dummy ();
     if (longjmp_b)
       {
        /* Link BPT into the chain of LONGJMP_B.  */
index cab9d496cca067a1c24585abae5ac9c3a03876b8..3b7178c4d8e936e8c8ab1a468f02022ebd7b06c9 100644 (file)
@@ -865,14 +865,13 @@ continue_command (char *args, int from_tty)
 static void
 set_step_frame (void)
 {
-  struct symtab_and_line sal;
-  CORE_ADDR pc;
-  struct frame_info *frame = get_current_frame ();
-  struct thread_info *tp = inferior_thread ();
+  frame_info *frame = get_current_frame ();
 
-  find_frame_sal (frame, &sal);
+  symtab_and_line sal = find_frame_sal (frame);
   set_step_info (frame, sal);
-  pc = get_frame_pc (frame);
+
+  CORE_ADDR pc = get_frame_pc (frame);
+  thread_info *tp = inferior_thread ();
   tp->control.step_start_function = find_pc_function (pc);
 }
 
@@ -1873,11 +1872,10 @@ finish_backward (struct finish_command_fsm *sm)
     {
       struct frame_info *frame = get_selected_frame (NULL);
       struct gdbarch *gdbarch = get_frame_arch (frame);
-      struct symtab_and_line sr_sal;
 
       /* Set a step-resume at the function's entry point.  Once that's
         hit, we'll do one more step backwards.  */
-      init_sal (&sr_sal);
+      symtab_and_line sr_sal;
       sr_sal.pc = sal.pc;
       sr_sal.pspace = get_frame_program_space (frame);
       insert_step_resume_breakpoint_at_sal (gdbarch,
@@ -1998,10 +1996,7 @@ finish_command (char *arg, int from_tty)
         called by that frame.  We don't use the magic "1" value for
         step_range_end, because then infrun will think this is nexti,
         and not step over the rest of this inlined function call.  */
-      struct symtab_and_line empty_sal;
-
-      init_sal (&empty_sal);
-      set_step_info (frame, empty_sal);
+      set_step_info (frame, {});
       tp->control.step_range_start = get_frame_pc (frame);
       tp->control.step_range_end = tp->control.step_range_start;
       tp->control.step_over_calls = STEP_OVER_ALL;
index 06b45b44ed6365366e5dc1c64032de7f262ea0af..7568a5ef478df3ef168827ffe959a31d7bec3396 100644 (file)
@@ -6558,9 +6558,7 @@ process_event_stop_test (struct execution_control_state *ecs)
        {
          /* Set up a step-resume breakpoint at the address
             indicated by SKIP_SOLIB_RESOLVER.  */
-         struct symtab_and_line sr_sal;
-
-         init_sal (&sr_sal);
+         symtab_and_line sr_sal;
          sr_sal.pc = pc_after_resolver;
          sr_sal.pspace = get_frame_program_space (frame);
 
@@ -6611,9 +6609,7 @@ process_event_stop_test (struct execution_control_state *ecs)
       if (real_stop_pc)
        {
          /* And put the step-breakpoint there and go until there.  */
-         struct symtab_and_line sr_sal;
-
-         init_sal (&sr_sal);   /* initialize to zeroes */
+         symtab_and_line sr_sal;
          sr_sal.pc = real_stop_pc;
          sr_sal.section = find_pc_overlay (sr_sal.pc);
          sr_sal.pspace = get_frame_program_space (frame);
@@ -6711,10 +6707,8 @@ process_event_stop_test (struct execution_control_state *ecs)
                 to the caller.  */
              if (ecs->stop_func_start != stop_pc && ecs->stop_func_start != 0)
                {
-                 struct symtab_and_line sr_sal;
-
                  /* Normal function call return (static or dynamic).  */
-                 init_sal (&sr_sal);
+                 symtab_and_line sr_sal;
                  sr_sal.pc = ecs->stop_func_start;
                  sr_sal.pspace = get_frame_program_space (frame);
                  insert_step_resume_breakpoint_at_sal (gdbarch,
@@ -6741,9 +6735,7 @@ process_event_stop_test (struct execution_control_state *ecs)
 
       if (real_stop_pc != 0 && in_solib_dynsym_resolve_code (real_stop_pc))
        {
-         struct symtab_and_line sr_sal;
-
-         init_sal (&sr_sal);
+         symtab_and_line sr_sal;
          sr_sal.pc = ecs->stop_func_start;
          sr_sal.pspace = get_frame_program_space (frame);
 
@@ -6797,9 +6789,7 @@ process_event_stop_test (struct execution_control_state *ecs)
            {
              /* Set a breakpoint at callee's start address.
                 From there we can step once and be back in the caller.  */
-             struct symtab_and_line sr_sal;
-
-             init_sal (&sr_sal);
+             symtab_and_line sr_sal;
              sr_sal.pc = ecs->stop_func_start;
              sr_sal.pspace = get_frame_program_space (frame);
              insert_step_resume_breakpoint_at_sal (gdbarch,
@@ -6837,9 +6827,7 @@ process_event_stop_test (struct execution_control_state *ecs)
          /* Stepped backward into the solib dynsym resolver.
             Set a breakpoint at its start and continue, then
             one more step will take us out.  */
-         struct symtab_and_line sr_sal;
-
-         init_sal (&sr_sal);
+         symtab_and_line sr_sal;
          sr_sal.pc = ecs->stop_func_start;
          sr_sal.pspace = get_frame_program_space (frame);
          insert_step_resume_breakpoint_at_sal (gdbarch, 
@@ -6919,13 +6907,11 @@ process_event_stop_test (struct execution_control_state *ecs)
                   ecs->event_thread->control.step_frame_id)
       && inline_skipped_frames (ecs->ptid))
     {
-      struct symtab_and_line call_sal;
-
       if (debug_infrun)
        fprintf_unfiltered (gdb_stdlog,
                            "infrun: stepped into inlined function\n");
 
-      find_frame_sal (get_current_frame (), &call_sal);
+      symtab_and_line call_sal = find_frame_sal (get_current_frame ());
 
       if (ecs->event_thread->control.step_over_calls != STEP_OVER_ALL)
        {
@@ -7289,17 +7275,14 @@ static void
 handle_step_into_function (struct gdbarch *gdbarch,
                           struct execution_control_state *ecs)
 {
-  struct compunit_symtab *cust;
-  struct symtab_and_line stop_func_sal, sr_sal;
-
   fill_in_stop_func (gdbarch, ecs);
 
-  cust = find_pc_compunit_symtab (stop_pc);
+  compunit_symtab *cust = find_pc_compunit_symtab (stop_pc);
   if (cust != NULL && compunit_language (cust) != language_asm)
     ecs->stop_func_start
       = gdbarch_skip_prologue_noexcept (gdbarch, ecs->stop_func_start);
 
-  stop_func_sal = find_pc_line (ecs->stop_func_start, 0);
+  symtab_and_line stop_func_sal = find_pc_line (ecs->stop_func_start, 0);
   /* Use the step_resume_break to step until the end of the prologue,
      even if that involves jumps (as it seems to on the vax under
      4.2).  */
@@ -7343,7 +7326,7 @@ handle_step_into_function (struct gdbarch *gdbarch,
   else
     {
       /* Put the step-breakpoint there and go until there.  */
-      init_sal (&sr_sal);      /* initialize to zeroes */
+      symtab_and_line sr_sal;
       sr_sal.pc = ecs->stop_func_start;
       sr_sal.section = find_pc_overlay (ecs->stop_func_start);
       sr_sal.pspace = get_frame_program_space (get_current_frame ());
@@ -7442,13 +7425,11 @@ insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch,
 static void
 insert_hp_step_resume_breakpoint_at_frame (struct frame_info *return_frame)
 {
-  struct symtab_and_line sr_sal;
-  struct gdbarch *gdbarch;
-
   gdb_assert (return_frame != NULL);
-  init_sal (&sr_sal);          /* initialize to zeros */
 
-  gdbarch = get_frame_arch (return_frame);
+  struct gdbarch *gdbarch = get_frame_arch (return_frame);
+
+  symtab_and_line sr_sal;
   sr_sal.pc = gdbarch_addr_bits_remove (gdbarch, get_frame_pc (return_frame));
   sr_sal.section = find_pc_overlay (sr_sal.pc);
   sr_sal.pspace = get_frame_program_space (return_frame);
@@ -7475,16 +7456,13 @@ insert_hp_step_resume_breakpoint_at_frame (struct frame_info *return_frame)
 static void
 insert_step_resume_breakpoint_at_caller (struct frame_info *next_frame)
 {
-  struct symtab_and_line sr_sal;
-  struct gdbarch *gdbarch;
-
   /* We shouldn't have gotten here if we don't know where the call site
      is.  */
   gdb_assert (frame_id_p (frame_unwind_caller_id (next_frame)));
 
-  init_sal (&sr_sal);          /* initialize to zeros */
+  struct gdbarch *gdbarch = frame_unwind_caller_arch (next_frame);
 
-  gdbarch = frame_unwind_caller_arch (next_frame);
+  symtab_and_line sr_sal;
   sr_sal.pc = gdbarch_addr_bits_remove (gdbarch,
                                        frame_unwind_caller_pc (next_frame));
   sr_sal.section = find_pc_overlay (sr_sal.pc);
index 5396ebab929d2f74293579430587be365f900958..480180869fa4fe126f150ae51b868302415844d7 100644 (file)
@@ -2126,11 +2126,8 @@ static std::vector<symtab_and_line>
 create_sals_line_offset (struct linespec_state *self,
                         linespec_p ls)
 {
-  struct symtab_and_line val;
   int use_default = 0;
 
-  init_sal (&val);
-
   /* This is where we need to make sure we have good defaults.
      We must guarantee that this section of code is never executed
      when we are called with just a function name, since
@@ -2155,6 +2152,7 @@ create_sals_line_offset (struct linespec_state *self,
       use_default = 1;
     }
 
+  symtab_and_line val;
   val.line = ls->explicit_loc.line_offset.offset;
   switch (ls->explicit_loc.line_offset.sign)
     {
@@ -4235,9 +4233,7 @@ decode_digits_ordinary (struct linespec_state *self,
       pcs = find_pcs_for_symtab_line (elt, line, best_entry);
       for (CORE_ADDR pc : pcs)
        {
-         struct symtab_and_line sal;
-
-         init_sal (&sal);
+         symtab_and_line sal;
          sal.pspace = SYMTAB_PSPACE (elt);
          sal.symtab = elt;
          sal.line = line;
@@ -4619,7 +4615,7 @@ symbol_to_sal (struct symtab_and_line *result,
     {
       if (SYMBOL_CLASS (sym) == LOC_LABEL && SYMBOL_VALUE_ADDRESS (sym) != 0)
        {
-         init_sal (result);
+         *result = {};
          result->symtab = symbol_symtab (sym);
          result->line = SYMBOL_LINE (sym);
          result->pc = SYMBOL_VALUE_ADDRESS (sym);
@@ -4634,7 +4630,7 @@ symbol_to_sal (struct symtab_and_line *result,
       else if (SYMBOL_LINE (sym) != 0)
        {
          /* We know its line number.  */
-         init_sal (result);
+         *result = {};
          result->symtab = symbol_symtab (sym);
          result->line = SYMBOL_LINE (sym);
          result->pspace = SYMTAB_PSPACE (result->symtab);
index 5b5e6f0febba641a61af68032afacd4e1dcc6aa5..ce2836193b7e51f55e97def68df32dc3f4ef9bb6 100644 (file)
@@ -85,9 +85,6 @@ parse_probes_in_pspace (const struct probe_ops *probe_ops,
            continue;
 
          symtab_and_line sal;
-
-         init_sal (&sal);
-
          sal.pc = get_probe_address (probe, objfile);
          sal.explicit_pc = 1;
          sal.section = find_pc_overlay (sal.pc);
index 891f44e708fd7a4d9ba82325da7f7c8e38f27f07..c5ae391ef544aff151c9f755c5ef5136bd87f273 100644 (file)
@@ -468,14 +468,13 @@ static PyObject *
 frapy_find_sal (PyObject *self, PyObject *args)
 {
   struct frame_info *frame;
-  struct symtab_and_line sal;
   PyObject *sal_obj = NULL;   /* Initialize to appease gcc warning.  */
 
   TRY
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
-      find_frame_sal (frame, &sal);
+      symtab_and_line sal = find_frame_sal (frame);
       sal_obj = symtab_and_line_to_sal_object (sal);
     }
   CATCH (except, RETURN_MASK_ALL)
index 61f31e547304dd3385e0dbf18c804f1bd03fbcee..c3c20fb28277b52438f1587841d1e86773777bfb 100644 (file)
@@ -121,7 +121,6 @@ save_bookmark_command (char *args, int from_tty)
 {
   /* Get target's idea of a bookmark.  */
   gdb_byte *bookmark_id = target_get_bookmark (args, from_tty);
-  struct bookmark *b, *b1;
   struct gdbarch *gdbarch = get_regcache_arch (get_current_regcache ());
 
   /* CR should not cause another identical bookmark.  */
@@ -131,9 +130,8 @@ save_bookmark_command (char *args, int from_tty)
     error (_("target_get_bookmark failed."));
 
   /* Set up a bookmark struct.  */
-  b = XCNEW (struct bookmark);
+  bookmark *b = new bookmark ();
   b->number = ++bookmark_count;
-  init_sal (&b->sal);
   b->pc = regcache_read_pc (get_current_regcache ());
   b->sal = find_pc_line (b->pc, 0);
   b->sal.pspace = get_frame_program_space (get_current_frame ());
@@ -143,7 +141,7 @@ save_bookmark_command (char *args, int from_tty)
   /* Add this bookmark to the end of the chain, so that a list
      of bookmarks will come out in order of increasing numbers.  */
 
-  b1 = bookmark_chain;
+  bookmark *b1 = bookmark_chain;
   if (b1 == 0)
     bookmark_chain = b;
   else
@@ -183,7 +181,7 @@ delete_one_bookmark (int num)
            break;
          }
       xfree (b->opaque_data);
-      xfree (b);
+      delete b;
       return 1;                /* success */
     }
   return 0;            /* failure */
index b63db8a725e80cb3e1a22d6f92f7393979c5459a..bac404530c0607b65f9860541a968ee60e6107a1 100644 (file)
@@ -182,7 +182,7 @@ get_lines_to_list (void)
 struct symtab_and_line
 get_current_source_symtab_and_line (void)
 {
-  struct symtab_and_line cursal = { 0 };
+  symtab_and_line cursal;
 
   cursal.pspace = current_source_pspace;
   cursal.symtab = current_source_symtab;
@@ -218,9 +218,9 @@ set_default_source_symtab_and_line (void)
    NOTE: The returned sal pc and end fields are not valid.  */
    
 struct symtab_and_line
-set_current_source_symtab_and_line (const struct symtab_and_line *sal)
+set_current_source_symtab_and_line (const symtab_and_line &sal)
 {
-  struct symtab_and_line cursal = { 0 };
+  symtab_and_line cursal;
 
   cursal.pspace = current_source_pspace;
   cursal.symtab = current_source_symtab;
@@ -228,9 +228,9 @@ set_current_source_symtab_and_line (const struct symtab_and_line *sal)
   cursal.pc = 0;
   cursal.end = 0;
 
-  current_source_pspace = sal->pspace;
-  current_source_symtab = sal->symtab;
-  current_source_line = sal->line;
+  current_source_pspace = sal.pspace;
+  current_source_symtab = sal.symtab;
+  current_source_line = sal.line;
 
   /* Force the next "list" to center around the current line.  */
   clear_lines_listed_range ();
@@ -1498,7 +1498,6 @@ info_line_command (char *arg, int from_tty)
 
   if (arg == 0)
     {
-      init_sal (&curr_sal);            /* initialize to zeroes */
       curr_sal.symtab = current_source_symtab;
       curr_sal.pspace = current_program_space;
       if (last_line_listed != 0)
index 263715aeddb49b35c8fb990a65a452c1ceecf8e6..41e1d8691abb3b15631a285da2cbcc0ce3b7734c 100644 (file)
@@ -91,7 +91,8 @@ extern void set_default_source_symtab_and_line (void);
    (the returned sal pc and end fields are not valid.)
    and set the current default to whatever is in SAL.
    NOTE: The returned sal pc and end fields are not valid.  */
-extern struct symtab_and_line set_current_source_symtab_and_line (const struct symtab_and_line *);
+extern symtab_and_line set_current_source_symtab_and_line
+  (const symtab_and_line &sal);
 
 /* Reset any information stored about a default file and line to print.  */
 extern void clear_current_source_symtab_and_line (void);
index 9c15b9f841e8328e52e797e4d6395370266360c0..8a066b2b69118899701a7bcbda0c6d0339a8ba6a 100644 (file)
@@ -723,11 +723,9 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 void
 set_current_sal_from_frame (struct frame_info *frame)
 {
-  struct symtab_and_line sal;
-
-  find_frame_sal (frame, &sal);
+  symtab_and_line sal = find_frame_sal (frame);
   if (sal.symtab != NULL)
-    set_current_source_symtab_and_line (&sal);
+    set_current_source_symtab_and_line (sal);
 }
 
 /* If ON, GDB will display disassembly of the next source line when
@@ -789,7 +787,6 @@ print_frame_info (struct frame_info *frame, int print_level,
                  int set_current_sal)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  struct symtab_and_line sal;
   int source_print;
   int location_print;
   struct ui_out *uiout = current_uiout;
@@ -852,7 +849,7 @@ print_frame_info (struct frame_info *frame, int print_level,
      the next frame is a SIGTRAMP_FRAME or a DUMMY_FRAME, then the
      next frame was not entered as the result of a call, and we want
      to get the line containing FRAME->pc.  */
-  find_frame_sal (frame, &sal);
+  symtab_and_line sal = find_frame_sal (frame);
 
   location_print = (print_what == LOCATION 
                    || print_what == LOC_AND_ADDRESS
@@ -1017,23 +1014,20 @@ get_last_displayed_line (void)
 
 /* Get the last sal we displayed, if it's valid.  */
 
-void
-get_last_displayed_sal (struct symtab_and_line *sal)
+symtab_and_line
+get_last_displayed_sal ()
 {
+  symtab_and_line sal;
+
   if (last_displayed_sal_valid)
     {
-      sal->pspace = last_displayed_pspace;
-      sal->pc = last_displayed_addr;
-      sal->symtab = last_displayed_symtab;
-      sal->line = last_displayed_line;
-    }
-  else
-    {
-      sal->pspace = 0;
-      sal->pc = 0;
-      sal->symtab = 0;
-      sal->line = 0;
+      sal.pspace = last_displayed_pspace;
+      sal.pc = last_displayed_addr;
+      sal.symtab = last_displayed_symtab;
+      sal.line = last_displayed_line;
     }
+
+  return sal;
 }
 
 
@@ -1399,7 +1393,6 @@ static void
 info_frame_command (char *addr_exp, int from_tty)
 {
   struct frame_info *fi;
-  struct symtab_and_line sal;
   struct symbol *func;
   struct symtab *s;
   struct frame_info *calling_frame_info;
@@ -1434,8 +1427,8 @@ info_frame_command (char *addr_exp, int from_tty)
     pc_regname = "pc";
 
   frame_pc_p = get_frame_pc_if_available (fi, &frame_pc);
-  find_frame_sal (fi, &sal);
   func = get_frame_function (fi);
+  symtab_and_line sal = find_frame_sal (fi);
   s = sal.symtab;
   if (func)
     {
index 1583200cb2930339c9f1b65e3b7554cf74059161..f41d21ef61ef4d7e565f068d7c83c33bb346c629 100644 (file)
@@ -45,6 +45,6 @@ struct program_space* get_last_displayed_pspace (void);
 CORE_ADDR get_last_displayed_addr (void);
 struct symtab* get_last_displayed_symtab (void);
 int get_last_displayed_line (void);
-void get_last_displayed_sal (struct symtab_and_line *sal);
+symtab_and_line get_last_displayed_sal ();
 
 #endif /* #ifndef STACK_H */
index 7ea03d4499be01c68431964bb8d2f87b6ac39fe6..84923153059dd06f82cd0149a187b721c259f5dd 100644 (file)
@@ -947,14 +947,6 @@ symbol_search_name (const struct general_symbol_info *gsymbol)
   else
     return symbol_natural_name (gsymbol);
 }
-
-/* Initialize the structure fields to zero values.  */
-
-void
-init_sal (struct symtab_and_line *sal)
-{
-  memset (sal, 0, sizeof (*sal));
-}
 \f
 
 /* Return 1 if the two sections are the same, or if they could
@@ -2938,7 +2930,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
   int len;
   int i;
   struct linetable_entry *item;
-  struct symtab_and_line val;
   const struct blockvector *bv;
   struct bound_minimal_symbol msymbol;
 
@@ -2965,10 +2956,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
      But what we want is the statement containing the instruction.
      Fudge the pc to make sure we get that.  */
 
-  init_sal (&val);             /* initialize to zeroes */
-
-  val.pspace = current_program_space;
-
   /* It's tempting to assume that, if we can't find debugging info for
      any function enclosing PC, that we shouldn't search for line
      number info, either.  However, GAS can emit line number info for
@@ -3057,6 +3044,8 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
          return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0);
       }
 
+  symtab_and_line val;
+  val.pspace = current_program_space;
 
   cust = find_pc_sect_compunit_symtab (pc, section);
   if (cust == NULL)
@@ -3469,12 +3458,11 @@ find_pc_line_pc_range (CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endptr)
 struct symtab_and_line
 find_function_start_sal (struct symbol *sym, int funfirstline)
 {
-  struct symtab_and_line sal;
-  struct obj_section *section;
-
   fixup_symbol_section (sym, NULL);
-  section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym);
-  sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0);
+
+  obj_section *section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym);
+  symtab_and_line sal
+    = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0);
 
   if (funfirstline && sal.symtab != NULL
       && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))
@@ -3494,7 +3482,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline)
      can find a line number for after the prologue.  */
   if (sal.pc < BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))
     {
-      init_sal (&sal);
+      sal = {};
       sal.pspace = current_program_space;
       sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
       sal.section = section;
index a2ca8fcea75e29bca6f84ee798e55735819ee9cb..1bf77c199ba2d51027788d4813da157ddab2a6ee 100644 (file)
@@ -1418,29 +1418,27 @@ extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR);
 struct symtab_and_line
 {
   /* The program space of this sal.  */
-  struct program_space *pspace;
+  struct program_space *pspace = NULL;
 
-  struct symtab *symtab;
-  struct obj_section *section;
+  struct symtab *symtab = NULL;
+  struct obj_section *section = NULL;
   /* Line number.  Line numbers start at 1 and proceed through symtab->nlines.
      0 is never a valid line number; it is used to indicate that line number
      information is not available.  */
-  int line;
+  int line = 0;
 
-  CORE_ADDR pc;
-  CORE_ADDR end;
-  int explicit_pc;
-  int explicit_line;
+  CORE_ADDR pc = 0;
+  CORE_ADDR end = 0;
+  bool explicit_pc = false;
+  bool explicit_line = false;
 
   /* The probe associated with this symtab_and_line.  */
-  struct probe *probe;
+  struct probe *probe = NULL;
   /* If PROBE is not NULL, then this is the objfile in which the probe
      originated.  */
-  struct objfile *objfile;
+  struct objfile *objfile = NULL;
 };
 
-extern void init_sal (struct symtab_and_line *sal);
-
 \f
 
 /* Given a pc value, return line number it is in.  Second arg nonzero means
index 566d06bb050ecc1a313f7357b8d56a83ecace5fa..f8aa3297b3c1531d4c7b65bd926d968f04edd2b5 100644 (file)
@@ -253,7 +253,7 @@ set_traceframe_context (struct frame_info *trace_frame)
 {
   CORE_ADDR trace_pc;
   struct symbol *traceframe_fun;
-  struct symtab_and_line traceframe_sal;
+  symtab_and_line traceframe_sal;
 
   /* Save as globals for internal use.  */
   if (trace_frame != NULL
@@ -269,7 +269,6 @@ set_traceframe_context (struct frame_info *trace_frame)
     }
   else
     {
-      init_sal (&traceframe_sal);
       traceframe_fun = NULL;
       set_internalvar_integer (lookup_internalvar ("trace_line"), -1);
     }
@@ -3818,10 +3817,7 @@ print_one_static_tracepoint_marker (int count,
   struct ui_out *uiout = current_uiout;
   VEC(breakpoint_p) *tracepoints;
 
-  struct symtab_and_line sal;
-
-  init_sal (&sal);
-
+  symtab_and_line sal;
   sal.pc = marker->address;
 
   tracepoints = static_tracepoints_here (marker->address);
index 123a9068f2c39d1fe17f2b6ef5eb1fdc532d1a95..a76383255eddac29ec8d578b25c667c2ba249121 100644 (file)
@@ -305,7 +305,7 @@ tui_show_disassem_and_update_source (struct gdbarch *gdbarch,
       tui_update_source_window (TUI_SRC_WIN, gdbarch, sal.symtab, val, TRUE);
       if (sal.symtab)
        {
-         set_current_source_symtab_and_line (&sal);
+         set_current_source_symtab_and_line (sal);
          tui_update_locator_fullname (symtab_to_fullname (sal.symtab));
        }
       else
index 21a8bacebace1997e86915fc61de7a925acc836e..c075bef4e4d693861b0eb72ba681321125b9a807 100644 (file)
@@ -366,10 +366,9 @@ tui_show_frame_info (struct frame_info *fi)
       CORE_ADDR low;
       struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
       int source_already_displayed;
-      struct symtab_and_line sal;
       CORE_ADDR pc;
 
-      find_frame_sal (fi, &sal);
+      symtab_and_line sal = find_frame_sal (fi);
 
       source_already_displayed = sal.symtab != 0
         && tui_source_is_displayed (symtab_to_fullname (sal.symtab));
index 3ae9c7122992619b6767d1ba91956b90d707cfc6..103b1e6658e6fa61b57c4d6776392c45619fbd7f 100644 (file)
@@ -109,14 +109,13 @@ tui_update_source_window_as_is (struct tui_win_info *win_info,
       tui_update_exec_info (win_info);
       if (win_info->generic.type == SRC_WIN)
        {
-         struct symtab_and_line sal;
-         
-         init_sal (&sal);
+         symtab_and_line sal;
+
          sal.line = line_or_addr.u.line_no +
            (win_info->generic.content_size - 2);
          sal.symtab = s;
          sal.pspace = SYMTAB_PSPACE (s);
-         set_current_source_symtab_and_line (&sal);
+         set_current_source_symtab_and_line (sal);
          /* If the focus was in the asm win, put it in the src win if
             we don't have a split layout.  */
          if (tui_win_with_focus () == TUI_DISASM_WIN