aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-07-31 07:42:56 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-08-28 10:30:31 +0100
commit56260065c80caf67b57ec612b85bb978e06dad2d (patch)
treea99e8d6be7dbb3c994fea5ccbc239f97c9e7bd57
parent3e9907d8496edb66086dcdebd3a9cb2b3c918e77 (diff)
downloadgdb-56260065c80caf67b57ec612b85bb978e06dad2d.zip
gdb-56260065c80caf67b57ec612b85bb978e06dad2d.tar.gz
gdb-56260065c80caf67b57ec612b85bb978e06dad2d.tar.bz2
gdb: Add 'maint info inline-frames' command
While reviewing a patch I wanted to view GDB's inline frame state. I don't believe there's currently a maintenance command to view this information, so in this commit I've added one. The new command is: maintenance info inline-frames maintenance info inline-frames ADDRESS The command lists the inline frames that start at ADDRESS, or at the current $pc if no ADDRESS is given. The command also displays the "outer" function in which the inline functions are present. An example of the command output: (gdb) maintenance info inline-frames Cached inline state information for thread 1. program counter = 0x401137 skipped frames = 1 bar > foo main (gdb) This tells us that function 'main' called 'foo' which called 'bar'. The functions 'foo' and 'bar' are both inline and both start at the address 0x401137. Currently GDB considers the inferior to be stopped in frame 'foo' (note the '>' marker), this means that there is 1 skipped frame (function 'bar'). The function 'main' is the outer function. The outer function might not start at 0x401137, it is simply the function that contains the inline functions. If the user does a 'step' then GDB will not actually move the inferior forward, but will instead simply tell the user that the inferior entered 'bar'. The output of 'maint info inline-frames' will change like this: (gdb) step bar () at inline.c:6 6 ++global_counter; (gdb) maintenance info inline-frames Cached inline state information for thread 1. program counter = 0x401137 skipped frames = 0 > bar foo main (gdb) Now GDB is in function 'bar' and there are no skipped frames. I have renamed skipped_symbols to function symbols within the inline_state class. We are now going to carry the "outer" function (the function that contains all the inlined functions) within this list (as the last entry), so the old name didn't really make sense. As a consequence of this rename I've updated some comments. I've changed stopped_by_user_bp_inline_frame to take a symbol rather than a block. Previously we just used the block to access the associated function symbol. After this commit we can just pass in the function symbol directly, so lets do that. New function gather_inline_frames contains some of the logic pulled from skip_inline_frames. This new function builds the list of all symbols of inlined functions that start at a given $pc value and also the "outer" function that contains all of the inlined functions. In skip_inline_frames I've split the loop logic into two. The loop to build the function symbol list has moved to gather_inline_frames. The loop to figure out how many of the inlined functions we are skipping remains in skip_inline_frames and uses the result of calling gather_inline_frames. In inline_skipped_symbol there are some minor updates to the comment, and I've tweaked one of the asserts now that the function symbols list also contains the "outer" function (a <= becomes <). The maintenance_info_inline_frames function is now and implements the new maintenance command. And _initialize_inline_frame is updated to register the new command. I've added a basic test for the new command. Please excuse the file name for the new test, in the next commit I'll be adding additional tests and at that point the file name will make sense. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r--gdb/NEWS7
-rw-r--r--gdb/doc/gdb.texinfo111
-rw-r--r--gdb/inline-frame.c266
-rw-r--r--gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c57
-rw-r--r--gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp151
5 files changed, 534 insertions, 58 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 6bded31..a65c557 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -40,6 +40,13 @@
history has been reached. It also specifies that the forward execution can
continue, and the recording will also continue.
+* New commands
+
+maintenance info inline-frames [ADDRESS]
+ New command which displays GDB's inline-frame information for the
+ current address, or for ADDRESS if specified. The output identifies
+ inlined frames which start at the specified address.
+
*** Changes in GDB 15
* The MPX commands "show/set mpx bound" have been deprecated, as Intel
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7938b07..e85099f 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41858,6 +41858,117 @@ frame-id for frame #0: @{stack=0x7fffffffac70,code=0x0000000000401106,!special@}
frame-id for frame #2: @{stack=0x7fffffffac90,code=0x000000000040111c,!special@}
@end smallexample
+@item maint info inline-frames
+@itemx maint info inline-frames @var{address}
+@cindex frames of inlined functions
+@kindex maint info inline-frames
+Print information about inlined frames which start at the current
+address, or @var{address} if specified.
+
+In order to allow the user to correctly step into inlined functions,
+@value{GDBN} needs to identify which inlined functions start at a
+particular address, and @value{GDBN} also needs to track which of
+these functions was last displayed to the user as the current frame.
+
+Imagine a situation where function @code{main} calls @code{foo}, which
+then calls @code{bar}, something like this:
+
+@smallexample
+@group
+int
+main ()
+@{
+ /* Some interesting code here... */
+
+ foo ();
+
+ /* More interesting code here... */
+@}
+
+void
+foo ()
+@{
+ bar ();
+@}
+
+void
+bar ()
+@{
+ /* Some interesting code here... */
+@}
+@end group
+@end smallexample
+
+As both @code{foo} and @code{bar} are inlined within @code{main} then
+there could be one address within @code{main} which is also the start
+of @code{foo} and also the start of @code{bar}. When the user stops
+at this address they will initially be told the inferior is in
+@code{main}, if the user does a @kbd{step} then @value{GDBN} doesn't
+actually step the inferior, instead the user is told the inferior
+entered @code{foo}. After the next @kbd{step} the user is told the
+inferior entered @code{bar}. The @kbd{maint info inline-frames}
+command can be used to view this internal @value{GDBN} state, like
+this:
+
+@smallexample
+@group
+(@value{GDBP}) step
+24 foo ();
+(@value{GDBP}) maintenance info inline-frames
+Cached inline state information for thread 1.
+program counter = 0x401137
+skipped frames = 2
+ bar
+ foo
+> main
+@end group
+@end smallexample
+
+Here the user is stopped in @code{main} at the call to @code{foo}. The
+inline-frames information shows that at this address @value{GDBN} has
+found the start of inlined functions @code{bar} and @code{foo}, but
+currently @value{GDBN} has skipped 2 frames and considers @code{main}
+to be the current frame, this is indicated with the @samp{>}.
+
+If the user performs a @kbd{step} to enter @code{foo} then the
+situation is updated:
+
+@smallexample
+@group
+(@value{GDBP}) step
+foo () at inline.c:14
+14 bar ();
+(@value{GDBP}) maintenance info inline-frames
+Cached inline state information for thread 1.
+program counter = 0x401137
+skipped frames = 1
+ bar
+> foo
+ main
+@end group
+@end smallexample
+
+Notice that the program counter value @code{0x401137} hasn't change,
+but now @value{GDBN} considers @code{foo} to be the current frame, and
+it is marked as such with the @samp{>}.
+
+Finally, the user performs another @kbd{step} to enter @code{bar}:
+
+@smallexample
+@group
+(@value{GDBP}) step
+bar () at inline.c:6
+6 ++global_counter;
+(@value{GDBP}) maintenance info inline-frames
+Cached inline state information for thread 1.
+program counter = 0x401137
+skipped frames = 0
+> bar
+ foo
+ main
+@end group
+@end smallexample
+
@kindex maint print registers
@kindex maint print raw-registers
@kindex maint print cooked-registers
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index 56b2955..8ba886c 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -27,6 +27,8 @@
#include "regcache.h"
#include "symtab.h"
#include "frame.h"
+#include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
#include <algorithm>
/* We need to save a few variables for every thread stopped at the
@@ -36,9 +38,9 @@
struct inline_state
{
inline_state (thread_info *thread_, int skipped_frames_, CORE_ADDR saved_pc_,
- std::vector<const symbol *> &&skipped_symbols_)
+ std::vector<const symbol *> &&function_symbols_)
: thread (thread_), skipped_frames (skipped_frames_), saved_pc (saved_pc_),
- skipped_symbols (std::move (skipped_symbols_))
+ function_symbols (std::move (function_symbols_))
{}
/* The thread this data relates to. It should be a currently
@@ -49,16 +51,19 @@ struct inline_state
functions can be stepped in to. */
int skipped_frames;
- /* Only valid if SKIPPED_FRAMES is non-zero. This is the PC used
- when calculating SKIPPED_FRAMES; used to check whether we have
- moved to a new location by user request. If so, we invalidate
- any skipped frames. */
+ /* This is the PC used when calculating FUNCTION_SYMBOLS; used to check
+ whether we have moved to a new location by user request. If so, we
+ invalidate any skipped frames. */
CORE_ADDR saved_pc;
- /* 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<const symbol *> skipped_symbols;
+ /* The list of all inline functions that start at SAVED_PC, except for
+ the last entry which will either be a non-inline function, or an
+ inline function that doesn't start at SAVED_PC. This last entry is
+ the function that "contains" all of the earlier functions.
+
+ This list can be empty if SAVED_PC is for a code region which is not
+ covered by any function (inline or non-inline). */
+ std::vector<const symbol *> function_symbols;
};
static std::vector<inline_state> inline_states;
@@ -303,10 +308,11 @@ 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 breakpoint with a user-specified location
- set at FRAME_BLOCK. */
+ set at FRAME_SYMBOL. */
static bool
-stopped_by_user_bp_inline_frame (const block *frame_block, bpstat *stop_chain)
+stopped_by_user_bp_inline_frame (const symbol *frame_symbol,
+ bpstat *stop_chain)
{
for (bpstat *s = stop_chain; s != nullptr; s = s->next)
{
@@ -327,7 +333,7 @@ stopped_by_user_bp_inline_frame (const block *frame_block, bpstat *stop_chain)
to presenting the stop at the innermost inline
function. */
if (loc->symbol == nullptr
- || frame_block == loc->symbol->value_block ())
+ || frame_symbol == loc->symbol)
return true;
}
}
@@ -336,58 +342,109 @@ stopped_by_user_bp_inline_frame (const block *frame_block, bpstat *stop_chain)
return false;
}
+/* Return a list of all the inline function symbols that start at THIS_PC
+ and the symbol for the function which contains all of the inline
+ functions.
+
+ The function symbols are ordered such that the most inner function is
+ first.
+
+ The returned list can be empty if there are no function at THIS_PC. Or
+ the returned list may have only a single entry if there are no inline
+ functions starting at THIS_PC. */
+
+static std::vector<const symbol *>
+gather_inline_frames (CORE_ADDR this_pc)
+{
+ /* Build the list of inline frames starting at THIS_PC. After the loop,
+ CUR_BLOCK is expected to point at the first function symbol (inlined or
+ not) "containing" the inline frames starting at THIS_PC. */
+ const block *cur_block = block_for_pc (this_pc);
+ if (cur_block == nullptr)
+ return {};
+
+ std::vector<const symbol *> function_symbols;
+ while (cur_block != nullptr)
+ {
+ if (cur_block->inlined_p ())
+ {
+ gdb_assert (cur_block->function () != nullptr);
+
+ /* See comments in inline_frame_this_id about this use
+ of BLOCK_ENTRY_PC. */
+ if (cur_block->entry_pc () == this_pc
+ || block_starting_point_at (this_pc, cur_block))
+ function_symbols.push_back (cur_block->function ());
+ else
+ break;
+ }
+ else if (cur_block->function () != nullptr)
+ break;
+
+ cur_block = cur_block->superblock ();
+ }
+
+ /* If we have a code region for which we have no function blocks,
+ possibly due to bad debug, or possibly just when some debug
+ information has been stripped, then we can end up in a situation where
+ there are global and static blocks for an address, but no function
+ blocks. In this case the early return above will not trigger as we
+ will find the static block for THIS_PC, but in the loop above we will
+ fail to find any function blocks (inline or non-inline) and so
+ CUR_BLOCK will eventually become NULL. If this happens then
+ FUNCTION_SYMBOLS must be empty (as we found no function blocks).
+
+ Otherwise, if we did find a function block, then we should only leave
+ the above loop when CUR_BLOCK is pointing to a non-inline function
+ that possibly contains some inline functions, or CUR_BLOCK should
+ point to an inline function that doesn't start at THIS_PC. */
+ if (cur_block != nullptr)
+ {
+ gdb_assert (cur_block->function () != nullptr);
+ function_symbols.push_back (cur_block->function ());
+ }
+ else
+ gdb_assert (function_symbols.empty ());
+
+ return function_symbols;
+}
+
/* See inline-frame.h. */
void
skip_inline_frames (thread_info *thread, bpstat *stop_chain)
{
- const struct block *frame_block, *cur_block;
- std::vector<const symbol *> skipped_syms;
- int skip_count = 0;
+ gdb_assert (find_inline_frame_state (thread) == nullptr);
- /* This function is called right after reinitializing the frame
- cache. We try not to do more unwinding than absolutely
- necessary, for performance. */
CORE_ADDR this_pc = get_frame_pc (get_current_frame ());
- frame_block = block_for_pc (this_pc);
- if (frame_block != NULL)
+ std::vector<const symbol *> function_symbols
+ = gather_inline_frames (this_pc);
+
+ /* Figure out how many of the inlined frames to skip. Do not skip an
+ inlined frame (and its callers) if execution stopped because of a user
+ breakpoint for this specific function.
+
+ By default, skip all the found inlined frames.
+
+ The last entry in FUNCTION_SYMBOLS is special, this is the function
+ which contains all of the inlined functions, we never skip this. */
+ int skipped_frames = 0;
+
+ for (const auto sym : function_symbols)
{
- cur_block = frame_block;
- while (cur_block->superblock ())
- {
- if (cur_block->inlined_p ())
- {
- /* See comments in inline_frame_this_id about this use
- of BLOCK_ENTRY_PC. */
- if (cur_block->entry_pc () == this_pc
- || block_starting_point_at (this_pc, cur_block))
- {
- /* Do not skip the inlined frame if execution
- stopped in an inlined frame because of a user
- breakpoint for this inline function. */
- if (stopped_by_user_bp_inline_frame (cur_block, stop_chain))
- break;
-
- skip_count++;
- skipped_syms.push_back (cur_block->function ());
- }
- else
- break;
- }
- else if (cur_block->function () != NULL)
- break;
+ if (stopped_by_user_bp_inline_frame (sym, stop_chain)
+ || sym == function_symbols.back ())
+ break;
- cur_block = cur_block->superblock ();
- }
+ ++skipped_frames;
}
- gdb_assert (find_inline_frame_state (thread) == NULL);
- inline_states.emplace_back (thread, skip_count, this_pc,
- std::move (skipped_syms));
-
- if (skip_count != 0)
+ if (skipped_frames > 0)
reinit_frame_cache ();
+
+ inline_states.emplace_back (thread, skipped_frames, this_pc,
+ std::move (function_symbols));
}
/* Step into an inlined function by unhiding it. */
@@ -426,13 +483,16 @@ inline_skipped_symbol (thread_info *thread)
gdb_assert (state != NULL);
/* 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. */
+ hence FUNCTION_SYMBOLS will contain more than one entry (the last
+ entry is the "outer" containing function).
+
+ As we initialise SKIPPED_FRAMES at the same time as we build
+ FUNCTION_SYMBOLS it should be true that SKIPPED_FRAMES never indexes
+ outside of the FUNCTION_SYMBOLS vector. */
+ gdb_assert (state->function_symbols.size () > 1);
gdb_assert (state->skipped_frames > 0);
- gdb_assert (state->skipped_frames <= state->skipped_symbols.size ());
- return state->skipped_symbols[state->skipped_frames - 1];
+ gdb_assert (state->skipped_frames < state->function_symbols.size ());
+ return state->function_symbols[state->skipped_frames - 1];
}
/* Return the number of functions inlined into THIS_FRAME. Some of
@@ -460,3 +520,93 @@ frame_inlined_callees (const frame_info_ptr &this_frame)
return inline_count;
}
+
+/* The 'maint info inline-frames' command. Takes an optional address
+ expression and displays inline frames that start at the given address,
+ or at the address of the current thread if no address is given. */
+
+static void
+maintenance_info_inline_frames (const char *arg, int from_tty)
+{
+ std::optional<std::vector<const symbol *>> local_function_symbols;
+ std::vector<const symbol *> *function_symbols;
+ int skipped_frames;
+ CORE_ADDR addr;
+
+ if (arg == nullptr)
+ {
+ /* With no argument then the user wants to know about the current
+ inline frame information. This information is cached per-thread
+ and can be updated as the user steps between inline functions at
+ the current address. */
+
+ if (inferior_ptid == null_ptid)
+ error (_("no inferior thread"));
+
+ thread_info *thread = inferior_thread ();
+ auto it = std::find_if (inline_states.begin (), inline_states.end (),
+ [thread] (const inline_state &istate)
+ {
+ return thread == istate.thread;
+ });
+
+ /* Stopped threads always have cached inline_state information. */
+ gdb_assert (it != inline_states.end ());
+
+ gdb_printf (_("Cached inline state information for thread %s.\n"),
+ print_thread_id (thread));
+
+ function_symbols = &it->function_symbols;
+ skipped_frames = it->skipped_frames;
+ addr = it->saved_pc;
+ }
+ else
+ {
+ /* If there is an argument then parse it as an address, the user is
+ asking about inline functions that start at the given address. */
+
+ addr = parse_and_eval_address (arg);
+ local_function_symbols.emplace (gather_inline_frames (addr));
+
+ function_symbols = &(local_function_symbols.value ());
+ skipped_frames = function_symbols->size () - 1;
+ }
+
+ /* The address we're analysing. */
+ gdb_printf (_("program counter = %ps\n"),
+ styled_string (address_style.style (),
+ core_addr_to_string_nz (addr)));
+
+ gdb_printf (_("skipped frames = %d\n"), skipped_frames);
+
+ /* Print the full list of function symbols in STATE. Highlight the
+ current function as indicated by the skipped frames counter. */
+ for (size_t i = 0; i < function_symbols->size (); ++i)
+ gdb_printf (_("%c %ps\n"),
+ (i == skipped_frames ? '>' : ' '),
+ styled_string (function_name_style.style (),
+ (*function_symbols)[i]->print_name ()));
+}
+
+
+
+void _initialize_inline_frame ();
+void
+_initialize_inline_frame ()
+{
+ add_cmd ("inline-frames", class_maintenance, maintenance_info_inline_frames,
+ _("\
+Display inline frame information for current thread.\n\
+\n\
+Usage:\n\
+\n\
+ maintenance info inline-frames [ADDRESS]\n\
+\n\
+With no ADDRESS show all inline frames starting at the current program\n\
+counter address. When ADDRESS is given, list all inline frames starting\n\
+at ADDRESS.\n\
+\n\
+The last frame listed might not start at ADDRESS, this is the frame that\n\
+contains the other inline frames."),
+ &maintenanceinfolist);
+}
diff --git a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c
new file mode 100644
index 0000000..35b2064
--- /dev/null
+++ b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.c
@@ -0,0 +1,57 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static void inline_func_a (void);
+static void inline_func_b (void);
+static void normal_func (void);
+
+volatile int global_var = 0;
+
+static void __attribute__((noinline))
+normal_func (void)
+{
+ /* Do some work. */
+ ++global_var;
+ ++global_var;
+
+ /* Now the inline function. */
+ inline_func_a ();
+
+ /* Do some work. */
+ ++global_var; /* After inline function. */
+ ++global_var;
+}
+
+static inline void __attribute__((__always_inline__))
+inline_func_a (void)
+{
+ inline_func_b ();
+}
+
+static inline void __attribute__((__always_inline__))
+inline_func_b (void)
+{
+ ++global_var;
+ ++global_var;
+}
+
+int
+main ()
+{
+ normal_func ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp
new file mode 100644
index 0000000..cbf090d
--- /dev/null
+++ b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp
@@ -0,0 +1,151 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check the 'maint info inline-frames' command.
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ {debug nopie}]} {
+ return -1
+}
+
+if {![runto normal_func]} {
+ return 0
+}
+
+# Next forward until we find the call to inline_func_a(). The hope is
+# that when we see the 'inline_func_a()' line this will be the start of
+# the inlined function. This might not be the case on all
+# architectures if the compiler needs to perform some preamble.
+gdb_test_multiple "next" "next forward to inline_func_a" {
+ -re "^$decimal\\s+inline_func_a \\(\\);\r\n" {
+ # Consume the next prompt.
+ gdb_expect {
+ -re "^$gdb_prompt $" {}
+ }
+ pass $gdb_test_name
+ }
+
+ -re "^$decimal\\s+\[^\r\n\]+After inline function\[^\r\n\]+\r\n" {
+ # We've gone too far!
+ fail $gdb_test_name
+ }
+
+ -re "^$decimal\\s+\[^\r\n\]+\r\n" {
+ send_gdb "next\n"
+ exp_continue
+ }
+
+ -re "^\[^\r\n\]+\r\n" {
+ exp_continue
+ }
+}
+
+# View the inline frame information. This should display that we are
+# at the start of inline_func_a() within normal_func().
+gdb_test "maint info inline-frames" \
+ [multi_line \
+ "^Cached inline state information for thread $decimal\\." \
+ "program counter = $hex" \
+ "skipped frames = 2" \
+ " inline_func_b" \
+ " inline_func_a" \
+ "> normal_func"] \
+ "check inline-frames state when in normal_func"
+
+# Step, we should now enter the inlined function.
+gdb_test "step" ".*" \
+ "step to enter inline_func"
+
+# And the inline-frames information should update.
+gdb_test "maint info inline-frames" \
+ [multi_line \
+ "^Cached inline state information for thread $decimal\\." \
+ "program counter = $hex" \
+ "skipped frames = 1" \
+ " inline_func_b" \
+ "> inline_func_a" \
+ " normal_func"] \
+ "check inline-frames state when just entered inline_func_a"
+
+# Record the current program counter.
+set pc [get_hexadecimal_valueof "\$pc" "UNKNOWN"]
+
+# Use the recorded $pc value to check inline frames.
+gdb_test "maint info inline-frames $pc" \
+ [multi_line \
+ "^program counter = $hex" \
+ "skipped frames = 2" \
+ " inline_func_b" \
+ " inline_func_a" \
+ "> normal_func"] \
+ "check inline-frames state at recorded \$pc while at the \$pc"
+
+# Step again, we should now enter inlined_func_b().
+gdb_test "step" ".*" \
+ "step into inline_func_b"
+
+gdb_test "maint info inline-frames" \
+ [multi_line \
+ "^Cached inline state information for thread $decimal\\." \
+ "program counter = $hex" \
+ "skipped frames = 0" \
+ "> inline_func_b" \
+ " inline_func_a" \
+ " normal_func"] \
+ "check inline-frames state when just entered inline_func_b"
+
+gdb_test "step" ".*" \
+ "step into the body of inline_func_b"
+
+# Now we are no longer at the start of the inlined function we should
+# no longer see normal_func() in the inline-frames information.
+gdb_test "maint info inline-frames" \
+ [multi_line \
+ "^Cached inline state information for thread $decimal\\." \
+ "program counter = $hex" \
+ "skipped frames = 0" \
+ "> inline_func_b"] \
+ "check inline-frames state when within inline_func_b"
+
+# Use the recorded $pc value to check inline frames.
+gdb_test "maint info inline-frames $pc" \
+ [multi_line \
+ "^program counter = $hex" \
+ "skipped frames = 2" \
+ " inline_func_b" \
+ " inline_func_a" \
+ "> normal_func"] \
+ "check inline-frames state at recorded \$pc"
+
+clean_restart $binfile
+
+# Use the recorded $pc value to check inline frames when the inferior
+# is not executing.
+gdb_test "maint info inline-frames $pc" \
+ [multi_line \
+ "^program counter = $hex" \
+ "skipped frames = 2" \
+ " inline_func_b" \
+ " inline_func_a" \
+ "> normal_func"] \
+ "check inline-frames state at recorded \$pc before execution starts"
+
+# Trying to read the $pc from the current thread should fail if the
+# inferior is not yet running.
+gdb_test "maint info inline-frames" \
+ "^no inferior thread" \
+ "check inline-frames state of current thread before execution starts"