1 /* This testcase is part of GDB, the GNU debugger. 2 3 Copyright 2010-2019 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(script_name) \ 28 asm("\ 29 .pushsection \".debug_gdb_scripts\", \"S\",%progbits\n\ 30 .byte " XSTRING (SECTION_SCRIPT_ID_SCHEME_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 (SCRIPT_FILE) 41 DEFINE_GDB_SCRIPT (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_SCHEME_TEXT) "\n" \ 53 ".ascii \"gdb.inlined-script\\n\"\n" \ 54 ".ascii \"(define test-cmd\\n\"\n" \ 55 ".ascii \" (make-command \\\"test-cmd\\\"\\n\"\n" \ 56 ".ascii \" #:command-class COMMAND_OBSCURE\\n\"\n" \ 57 ".ascii \" #:invoke (lambda (self arg from-tty)\\n\"\n" \ 58 ".ascii \" (display (format #f \\\"test-cmd output, arg = ~a\\n\\\" arg)))))\\n\"\n" \ 59 ".ascii \"(register-command! 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 } 90