GDB (xrefs)
Loading...
Searching...
No Matches
frame_info_ptr-selftests.c
Go to the documentation of this file.
1/* Self tests for frame_info_ptr.
2
3 Copyright (C) 2022-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21
22#include "frame.h"
23#include "gdbsupport/selftest.h"
24#include "scoped-mock-context.h"
25#include "test-target.h"
26
27namespace selftests {
28
29static void
31{
32 SELF_CHECK (id.stack_status == FID_STACK_VALID);
33 SELF_CHECK (id.stack_addr == 0x1234);
34 SELF_CHECK (id.code_addr_p);
35 SELF_CHECK (id.code_addr == 0x5678);
36}
37
38static frame_info_ptr
49
50static void
52{
53 scoped_mock_context<test_target_ops> mock_context
55 frame_info_ptr frame = create_new_frame (0x1234, 0x5678);
56
58
59 /* Pass the frame to a callee, which calls reinit_frame_cache. This lets us
60 validate that the reinflation in both the callee and caller restore the
61 same frame_info object. */
62 frame_info_ptr callees_frame_info = user_created_frame_callee (frame);
63
65 SELF_CHECK (frame.get () == callees_frame_info.get ());
66}
67
68} /* namespace selftests */
69
71void
73{
74 selftests::register_test ("frame_info_ptr_user",
76}
frame_info * get() const
Definition frame.h:294
@ FID_STACK_VALID
Definition frame-id.h:31
void reinit_frame_cache(void)
Definition frame.c:2107
static frame_info_ptr create_new_frame(frame_id id)
Definition frame.c:2007
struct frame_id get_frame_id(frame_info_ptr fi)
Definition frame.c:631
void _initialize_frame_info_ptr_selftests()
struct inferior * current_inferior(void)
Definition inferior.c:55
static frame_info_ptr user_created_frame_callee(frame_info_ptr frame)
static void validate_user_created_frame(frame_id id)
static void test_user_created_frame()