arm, objdump: print obsolote warning when 26-bit set in instructions
[binutils-gdb.git] / gdb / unittests / frame_info_ptr-selftests.c
blobec83024cc3d1ba69ecf7736dd45ab697da2f57f0
1 /* Self tests for frame_info_ptr.
3 Copyright (C) 2022-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
21 #include "frame.h"
22 #include "gdbsupport/selftest.h"
23 #include "scoped-mock-context.h"
24 #include "test-target.h"
26 namespace selftests {
28 static void
29 validate_user_created_frame (frame_id id)
31 SELF_CHECK (id.stack_status == FID_STACK_VALID);
32 SELF_CHECK (id.stack_addr == 0x1234);
33 SELF_CHECK (id.code_addr_p);
34 SELF_CHECK (id.code_addr == 0x5678);
37 static frame_info_ptr
38 user_created_frame_callee (const frame_info_ptr &frame)
40 validate_user_created_frame (get_frame_id (frame));
42 reinit_frame_cache ();
44 validate_user_created_frame (get_frame_id (frame));
46 return frame;
49 static void
50 test_user_created_frame ()
52 scoped_mock_context<test_target_ops> mock_context
53 (current_inferior ()->arch ());
54 frame_info_ptr frame = create_new_frame (0x1234, 0x5678);
56 validate_user_created_frame (get_frame_id (frame));
58 /* Pass the frame to a callee, which calls reinit_frame_cache. This lets us
59 validate that the reinflation in both the callee and caller restore the
60 same frame_info object. */
61 frame_info_ptr callees_frame_info = user_created_frame_callee (frame);
63 validate_user_created_frame (get_frame_id (frame));
64 SELF_CHECK (frame.get () == callees_frame_info.get ());
67 } /* namespace selftests */
69 void _initialize_frame_info_ptr_selftests ();
70 void
71 _initialize_frame_info_ptr_selftests ()
73 selftests::register_test ("frame_info_ptr_user",
74 selftests::test_user_created_frame);