]> Git Repo - binutils.git/blob - gdb/testsuite/gdb.python/py-section-script.c
Update copyright year range in all GDB files.
[binutils.git] / gdb / testsuite / gdb.python / py-section-script.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3    Copyright 2010-2020 Free Software Foundation, Inc.
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
18 #include "symcat.h"
19 #include "gdb/section-scripts.h"
20
21 /* Put the path to the pretty-printer script in .debug_gdb_scripts so
22    gdb will automagically loaded it.
23    Normally "MS" would appear here, as in
24    .pushsection ".debug_gdb_scripts", "MS",%progbits,1
25    but we remove it to test files appearing twice in the section.  */
26
27 #define DEFINE_GDB_SCRIPT_FILE(script_name) \
28   asm("\
29 .pushsection \".debug_gdb_scripts\", \"S\",%progbits\n\
30 .byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_FILE) "\n\
31 .asciz \"" script_name "\"\n\
32 .popsection\n\
33 ");
34
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.  */
40 DEFINE_GDB_SCRIPT_FILE (SCRIPT_FILE)
41 DEFINE_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
46    .pushsection ".debug_gdb_scripts", "MS",%progbits,1
47    but we remove it to test scripts appearing twice in the section.  */
48
49 #define DEFINE_GDB_SCRIPT_TEXT \
50 asm( \
51 ".pushsection \".debug_gdb_scripts\", \"S\",%progbits\n" \
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.  */
65 DEFINE_GDB_SCRIPT_TEXT
66 DEFINE_GDB_SCRIPT_TEXT
67
68 struct ss
69 {
70   int a;
71   int b;
72 };
73
74 void
75 init_ss (struct ss *s, int a, int b)
76 {
77   s->a = a;
78   s->b = b;
79 }
80
81 int
82 main ()
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 0.044048 seconds and 4 git commands to generate.