[gdb/testsuite] Add untested case in gdb.gdb/complaints.exp
[deliverable/binutils-gdb.git] / gdb / inline-frame.c
index 5840e3ee3198e6869a0cfc508e56890d8cb5ba95..c98af1842a6caab36898e38b791fbec043ed7217 100644 (file)
@@ -1,6 +1,6 @@
 /* Inline frame unwinder for GDB.
 
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
+   Copyright (C) 2008-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -37,9 +37,9 @@
 struct inline_state
 {
   inline_state (thread_info *thread_, int skipped_frames_, CORE_ADDR saved_pc_,
-               symbol *skipped_symbol_)
+               std::vector<symbol *> &&skipped_symbols_)
     : thread (thread_), skipped_frames (skipped_frames_), saved_pc (saved_pc_),
-      skipped_symbol (skipped_symbol_)
+      skipped_symbols (std::move (skipped_symbols_))
   {}
 
   /* The thread this data relates to.  It should be a currently
@@ -56,10 +56,10 @@ struct inline_state
      any skipped frames.  */
   CORE_ADDR saved_pc;
 
-  /* Only valid if SKIPPED_FRAMES is non-zero.  This is the symbol
-     of the outermost skipped inline function.  It's used to find the
-     call site of the current frame.  */
-  struct symbol *skipped_symbol;
+  /* Only valid if SKIPPED_FRAMES is non-zero.  This is the list of all
+     function symbols that have been skipped, from inner most to outer
+     most.  It is used to find the call site of the current frame.  */
+  std::vector<struct symbol *> skipped_symbols;
 };
 
 static std::vector<inline_state> inline_states;
@@ -95,37 +95,54 @@ find_inline_frame_state (thread_info *thread)
   return &state;
 }
 
-/* Forget about any hidden inlined functions in PTID, which is new or
-   about to be resumed.  PTID may be minus_one_ptid (all processes)
-   or a PID (all threads in this process).  */
+/* See inline-frame.h.  */
 
 void
-clear_inline_frame_state (ptid_t ptid)
+clear_inline_frame_state (process_stratum_target *target, ptid_t filter_ptid)
 {
-  if (ptid == minus_one_ptid)
-    {
-      inline_states.clear ();
-      return;
-    }
+  gdb_assert (target != NULL);
 
-  if (ptid.is_pid ())
+  if (filter_ptid == minus_one_ptid || filter_ptid.is_pid ())
     {
-      int pid = ptid.pid ();
+      auto matcher = [target, &filter_ptid] (const inline_state &state)
+       {
+         thread_info *t = state.thread;
+         return (t->inf->process_target () == target
+                 && t->ptid.matches (filter_ptid));
+       };
+
       auto it = std::remove_if (inline_states.begin (), inline_states.end (),
-                               [pid] (const inline_state &state)
-                                 {
-                                   return pid == state.thread->inf->pid;
-                                 });
+                               matcher);
 
       inline_states.erase (it, inline_states.end ());
 
       return;
     }
 
+
+  auto matcher = [target, &filter_ptid] (const inline_state &state)
+    {
+      thread_info *t = state.thread;
+      return (t->inf->process_target () == target
+             && filter_ptid == t->ptid);
+    };
+
+  auto it = std::find_if (inline_states.begin (), inline_states.end (),
+                         matcher);
+
+  if (it != inline_states.end ())
+    unordered_remove (inline_states, it);
+}
+
+/* See inline-frame.h.  */
+
+void
+clear_inline_frame_state (thread_info *thread)
+{
   auto it = std::find_if (inline_states.begin (), inline_states.end (),
-                         [&ptid] (const inline_state &state)
+                         [thread] (const inline_state &state)
                            {
-                             return ptid == state.thread->ptid;
+                             return thread == state.thread;
                            });
 
   if (it != inline_states.end ())
@@ -144,7 +161,8 @@ inline_frame_this_id (struct frame_info *this_frame,
      real frame's this_id method.  So we must call
      get_prev_frame_always.  Because we are inlined into some
      function, there must be previous frames, so this is safe - as
-     long as we're careful not to create any cycles.  */
+     long as we're careful not to create any cycles.  See related
+     comments in get_prev_frame_always_1.  */
   *this_id = get_frame_id (get_prev_frame_always (this_frame));
 
   /* We need a valid frame ID, so we need to be based on a valid
@@ -154,10 +172,6 @@ inline_frame_this_id (struct frame_info *this_frame,
      frame").  This will take work.  */
   gdb_assert (frame_id_p (*this_id));
 
-  /* For now, require we don't match outer_frame_id either (see
-     comment above).  */
-  gdb_assert (!frame_id_eq (*this_id, outer_frame_id));
-
   /* Future work NOTE: Alexandre Oliva applied a patch to GCC 4.3
      which generates DW_AT_entry_pc for inlined functions when
      possible.  If this attribute is available, we should use it
@@ -249,6 +263,7 @@ inline_frame_sniffer (const struct frame_unwind *self,
 }
 
 const struct frame_unwind inline_frame_unwind = {
+  "inline",
   INLINE_FRAME,
   default_frame_unwind_stop_reason,
   inline_frame_this_id,
@@ -286,7 +301,8 @@ block_starting_point_at (CORE_ADDR pc, const struct block *block)
 }
 
 /* Loop over the stop chain and determine if execution stopped in an
-   inlined frame because of a user breakpoint set at FRAME_BLOCK.  */
+   inlined frame because of a breakpoint with a user-specified location
+   set at FRAME_BLOCK.  */
 
 static bool
 stopped_by_user_bp_inline_frame (const block *frame_block, bpstat stop_chain)
@@ -295,9 +311,10 @@ stopped_by_user_bp_inline_frame (const block *frame_block, bpstat stop_chain)
     {
       struct breakpoint *bpt = s->breakpoint_at;
 
-      if (bpt != NULL && user_breakpoint_p (bpt))
+      if (bpt != NULL
+         && (user_breakpoint_p (bpt) || bpt->type == bp_until))
        {
-         bp_location *loc = s->bp_location_at;
+         bp_location *loc = s->bp_location_at.get ();
          enum bp_loc_type t = loc->loc_type;
 
          if (t == bp_loc_software_breakpoint
@@ -324,7 +341,7 @@ void
 skip_inline_frames (thread_info *thread, bpstat stop_chain)
 {
   const struct block *frame_block, *cur_block;
-  struct symbol *last_sym = NULL;
+  std::vector<struct symbol *> skipped_syms;
   int skip_count = 0;
 
   /* This function is called right after reinitializing the frame
@@ -352,7 +369,7 @@ skip_inline_frames (thread_info *thread, bpstat stop_chain)
                    break;
 
                  skip_count++;
-                 last_sym = BLOCK_FUNCTION (cur_block);
+                 skipped_syms.push_back (BLOCK_FUNCTION (cur_block));
                }
              else
                break;
@@ -365,7 +382,8 @@ skip_inline_frames (thread_info *thread, bpstat stop_chain)
     }
 
   gdb_assert (find_inline_frame_state (thread) == NULL);
-  inline_states.emplace_back (thread, skip_count, this_pc, last_sym);
+  inline_states.emplace_back (thread, skip_count, this_pc,
+                             std::move (skipped_syms));
 
   if (skip_count != 0)
     reinit_frame_cache ();
@@ -404,9 +422,16 @@ struct symbol *
 inline_skipped_symbol (thread_info *thread)
 {
   inline_state *state = find_inline_frame_state (thread);
-
   gdb_assert (state != NULL);
-  return state->skipped_symbol;
+
+  /* This should only be called when we are skipping at least one frame,
+     hence SKIPPED_FRAMES will be greater than zero when we get here.
+     We initialise SKIPPED_FRAMES at the same time as we build
+     SKIPPED_SYMBOLS, hence it should be true that SKIPPED_FRAMES never
+     indexes outside of the SKIPPED_SYMBOLS vector.  */
+  gdb_assert (state->skipped_frames > 0);
+  gdb_assert (state->skipped_frames <= state->skipped_symbols.size ());
+  return state->skipped_symbols[state->skipped_frames - 1];
 }
 
 /* Return the number of functions inlined into THIS_FRAME.  Some of
This page took 0.030404 seconds and 4 git commands to generate.