Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-section-script.c
CommitLineData
8a1ea21f
DE
1/* This testcase is part of GDB, the GNU debugger.
2
88b9d363 3 Copyright 2010-2022 Free Software Foundation, Inc.
8a1ea21f
DE
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
9f050062
DE
18#include "symcat.h"
19#include "gdb/section-scripts.h"
20
8a1ea21f 21/* Put the path to the pretty-printer script in .debug_gdb_scripts so
9f050062
DE
22 gdb will automagically loaded it.
23 Normally "MS" would appear here, as in
b2789696 24 .pushsection ".debug_gdb_scripts", "MS",%progbits,1
9f050062 25 but we remove it to test files appearing twice in the section. */
8a1ea21f 26
9f050062 27#define DEFINE_GDB_SCRIPT_FILE(script_name) \
8a1ea21f 28 asm("\
b2789696 29.pushsection \".debug_gdb_scripts\", \"S\",%progbits\n\
9f050062 30.byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_FILE) "\n\
8a1ea21f 31.asciz \"" script_name "\"\n\
9f050062 32.popsection\n\
8a1ea21f
DE
33");
34
9f050062
DE
35#ifndef SCRIPT_FILE
36#error "SCRIPT_FILE not defined"
37#endif
38
39/* Specify it twice to verify the file is only loaded once. */
40DEFINE_GDB_SCRIPT_FILE (SCRIPT_FILE)
41DEFINE_GDB_SCRIPT_FILE (SCRIPT_FILE)
42
43/* Inlined scripts are harder to create in the same way as
44 DEFINE_GDB_SCRIPT_FILE. Keep things simple and just define it here.
45 Normally "MS" would appear here, as in
b2789696 46 .pushsection ".debug_gdb_scripts", "MS",%progbits,1
9f050062
DE
47 but we remove it to test scripts appearing twice in the section. */
48
49#define DEFINE_GDB_SCRIPT_TEXT \
50asm( \
b2789696 51".pushsection \".debug_gdb_scripts\", \"S\",%progbits\n" \
9f050062
DE
52".byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_TEXT) "\n" \
53".ascii \"gdb.inlined-script\\n\"\n" \
54".ascii \"class test_cmd (gdb.Command):\\n\"\n" \
55".ascii \" def __init__ (self):\\n\"\n" \
56".ascii \" super (test_cmd, self).__init__ (\\\"test-cmd\\\", gdb.COMMAND_OBSCURE)\\n\"\n" \
57".ascii \" def invoke (self, arg, from_tty):\\n\"\n" \
58".ascii \" print (\\\"test-cmd output, arg = %s\\\" % arg)\\n\"\n" \
59".ascii \"test_cmd ()\\n\"\n" \
60".byte 0\n" \
61".popsection\n" \
62);
63
64/* Specify it twice to verify the script is only executed once. */
65DEFINE_GDB_SCRIPT_TEXT
66DEFINE_GDB_SCRIPT_TEXT
8a1ea21f
DE
67
68struct ss
69{
70 int a;
71 int b;
72};
73
74void
75init_ss (struct ss *s, int a, int b)
76{
77 s->a = a;
78 s->b = b;
79}
80
81int
82main ()
83{
84 struct ss ss;
85
86 init_ss (&ss, 1, 2);
87
88 return 0; /* break to inspect struct and union */
89}
This page took 2.489762 seconds and 4 git commands to generate.