1 /* Output VMS debug format symbol table information from GCC.
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 Contributed by Douglas B. Rupp (rupp@gnat.com).
4 Updated by Bernard W. Giroud (bgiroud@users.sourceforge.net).
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
27 #ifdef VMS_DEBUGGING_INFO
37 #include "langhooks.h"
41 /* Difference in seconds between the VMS Epoch and the Unix Epoch */
42 static const long long vms_epoch_offset
= 3506716800ll;
44 int vms_file_stats_name (const char *, long long *, long *, char *, int *);
46 /* NOTE: In the comments in this file, many references are made to "Debug
47 Symbol Table". This term is abbreviated as `DST' throughout the remainder
50 typedef struct dst_line_info_struct
*dst_line_info_ref
;
52 /* Each entry in the line_info_table maintains the file and
53 line number associated with the label generated for that
54 entry. The label gives the PC value associated with
55 the line number entry. */
56 typedef struct dst_line_info_struct
58 unsigned long dst_file_num
;
59 unsigned long dst_line_num
;
63 typedef struct dst_file_info_struct
*dst_file_info_ref
;
65 typedef struct dst_file_info_struct
68 unsigned int max_line
;
69 unsigned int listing_line_start
;
77 /* Maximum size (in bytes) of an artificially generated label. */
78 #define MAX_ARTIFICIAL_LABEL_BYTES 30
80 /* Make sure we know the sizes of the various types debug can describe. These
81 are only defaults. If the sizes are different for your target, you should
82 override these values by defining the appropriate symbols in your tm.h
85 #define PTR_SIZE 4 /* Must be 32 bits for VMS debug info */
88 /* Pointer to a structure of filenames referenced by this compilation unit. */
89 static dst_file_info_ref file_info_table
;
91 /* Total number of entries in the table (i.e. array) pointed to by
92 `file_info_table'. This is the *total* and includes both used and unused
94 static unsigned int file_info_table_allocated
;
96 /* Number of entries in the file_info_table which are actually in use. */
97 static unsigned int file_info_table_in_use
;
99 /* Size (in elements) of increments by which we may expand the filename
101 #define FILE_TABLE_INCREMENT 64
103 typedef char *char_p
;
105 static vec
<char_p
> funcnam_table
;
106 static vec
<unsigned> funcnum_table
;
107 #define FUNC_TABLE_INITIAL 256
109 /* Local pointer to the name of the main input file. Initialized in
111 static const char *primary_filename
;
113 static char *module_producer
;
114 static unsigned int module_language
;
116 /* A pointer to the base of a table that contains line information
117 for each source code line in .text in the compilation unit. */
118 static dst_line_info_ref line_info_table
;
120 /* Number of elements currently allocated for line_info_table. */
121 static unsigned int line_info_table_allocated
;
123 /* Number of elements in line_info_table currently in use. */
124 static unsigned int line_info_table_in_use
;
126 /* Size (in elements) of increments by which we may expand line_info_table. */
127 #define LINE_INFO_TABLE_INCREMENT 1024
129 /* Forward declarations for functions defined in this file. */
130 static char *full_name (const char *);
131 static unsigned int lookup_filename (const char *);
132 static int write_debug_header (DST_HEADER
*, const char *, int);
133 static int write_debug_addr (const char *, const char *, int);
134 static int write_debug_data1 (unsigned int, const char *, int);
135 static int write_debug_data2 (unsigned int, const char *, int);
136 static int write_debug_data4 (unsigned long, const char *, int);
137 static int write_debug_data8 (unsigned long long, const char *, int);
138 static int write_debug_delta4 (const char *, const char *, const char *, int);
139 static int write_debug_string (const char *, const char *, int);
140 static int write_modbeg (int);
141 static int write_modend (int);
142 static int write_rtnbeg (int, int);
143 static int write_rtnend (int, int);
144 static int write_pclines (int);
145 static int write_srccorr (int, dst_file_info_entry
, int);
146 static int write_srccorrs (int);
148 static void vmsdbgout_init (const char *);
149 static void vmsdbgout_finish (const char *);
150 static void vmsdbgout_assembly_start (void);
151 static void vmsdbgout_define (unsigned int, const char *);
152 static void vmsdbgout_undef (unsigned int, const char *);
153 static void vmsdbgout_start_source_file (unsigned int, const char *);
154 static void vmsdbgout_end_source_file (unsigned int);
155 static void vmsdbgout_begin_block (unsigned int, unsigned int);
156 static void vmsdbgout_end_block (unsigned int, unsigned int);
157 static bool vmsdbgout_ignore_block (const_tree
);
158 static void vmsdbgout_source_line (unsigned int, unsigned int, const char *,
160 static void vmsdbgout_write_source_line (unsigned, const char *, int , bool);
161 static void vmsdbgout_begin_prologue (unsigned int, unsigned int,
163 static void vmsdbgout_end_prologue (unsigned int, const char *);
164 static void vmsdbgout_end_function (unsigned int);
165 static void vmsdbgout_begin_epilogue (unsigned int, const char *);
166 static void vmsdbgout_end_epilogue (unsigned int, const char *);
167 static void vmsdbgout_begin_function (tree
);
168 static void vmsdbgout_function_decl (tree
);
169 static void vmsdbgout_early_global_decl (tree
);
170 static void vmsdbgout_late_global_decl (tree
);
171 static void vmsdbgout_type_decl (tree
, int);
172 static void vmsdbgout_abstract_function (tree
);
174 /* The debug hooks structure. */
176 const struct gcc_debug_hooks vmsdbg_debug_hooks
179 debug_nothing_charstar
,
180 vmsdbgout_assembly_start
,
183 vmsdbgout_start_source_file
,
184 vmsdbgout_end_source_file
,
185 vmsdbgout_begin_block
,
187 vmsdbgout_ignore_block
,
188 vmsdbgout_source_line
,
189 vmsdbgout_begin_prologue
,
190 vmsdbgout_end_prologue
,
191 vmsdbgout_begin_epilogue
,
192 vmsdbgout_end_epilogue
,
193 vmsdbgout_begin_function
,
194 vmsdbgout_end_function
,
195 debug_nothing_tree
, /* register_main_translation_unit */
196 vmsdbgout_function_decl
,
197 vmsdbgout_early_global_decl
,
198 vmsdbgout_late_global_decl
,
199 vmsdbgout_type_decl
, /* type_decl */
200 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
201 debug_nothing_tree
, /* deferred_inline_function */
202 vmsdbgout_abstract_function
,
203 debug_nothing_rtx_code_label
, /* label */
204 debug_nothing_int
, /* handle_pch */
205 debug_nothing_rtx_insn
, /* var_location */
206 debug_nothing_tree
, /* size_function */
207 debug_nothing_void
, /* switch_text_section */
208 debug_nothing_tree_tree
, /* set_name */
209 0, /* start_end_main_source_file */
210 TYPE_SYMTAB_IS_ADDRESS
/* tree_type_symtab_field */
213 /* Definitions of defaults for assembler-dependent names of various
214 pseudo-ops and section names. */
215 #define VMS_UNALIGNED_SHORT_ASM_OP ".word"
216 #define VMS_UNALIGNED_INT_ASM_OP ".long"
217 #define VMS_UNALIGNED_LONG_ASM_OP ".long"
218 #define VMS_UNALIGNED_DOUBLE_INT_ASM_OP ".quad"
220 #define VMS_ASM_BYTE_OP ".byte"
222 #define NUMBYTES(I) ((I) < 256 ? 1 : (I) < 65536 ? 2 : 4)
224 #define NUMBYTES0(I) ((I) < 128 ? 0 : (I) < 65536 ? 2 : 4)
226 #ifndef UNALIGNED_PTR_ASM_OP
227 #define UNALIGNED_PTR_ASM_OP \
228 (PTR_SIZE == 8 ? VMS_UNALIGNED_DOUBLE_INT_ASM_OP : VMS_UNALIGNED_INT_ASM_OP)
231 #ifndef UNALIGNED_OFFSET_ASM_OP
232 #define UNALIGNED_OFFSET_ASM_OP(OFFSET) \
233 (NUMBYTES (OFFSET) == 4 \
234 ? VMS_UNALIGNED_LONG_ASM_OP \
235 : (NUMBYTES (OFFSET) == 2 ? VMS_UNALIGNED_SHORT_ASM_OP : VMS_ASM_BYTE_OP))
238 /* Definitions of defaults for formats and names of various special
239 (artificial) labels which may be generated within this file (when the -g
240 options is used and VMS_DEBUGGING_INFO is in effect. If necessary, these
241 may be overridden from within the tm.h file, but typically, overriding these
242 defaults is unnecessary. */
244 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
246 #ifndef TEXT_END_LABEL
247 #define TEXT_END_LABEL "Lvetext"
249 #ifndef FUNC_BEGIN_LABEL
250 #define FUNC_BEGIN_LABEL "LVFB"
252 #ifndef FUNC_PROLOG_LABEL
253 #define FUNC_PROLOG_LABEL "LVFP"
255 #ifndef FUNC_EPILOG_LABEL
256 #define FUNC_EPILOG_LABEL "LVEB"
258 #ifndef FUNC_END_LABEL
259 #define FUNC_END_LABEL "LVFE"
261 #ifndef BLOCK_BEGIN_LABEL
262 #define BLOCK_BEGIN_LABEL "LVBB"
264 #ifndef BLOCK_END_LABEL
265 #define BLOCK_END_LABEL "LVBE"
267 #ifndef LINE_CODE_LABEL
268 #define LINE_CODE_LABEL "LVM"
271 #ifndef ASM_OUTPUT_DEBUG_DELTA2
272 #define ASM_OUTPUT_DEBUG_DELTA2(FILE,LABEL1,LABEL2) \
275 fprintf ((FILE), "\t%s\t", VMS_UNALIGNED_SHORT_ASM_OP); \
276 assemble_name (FILE, LABEL1); \
277 fprintf (FILE, "-"); \
278 assemble_name (FILE, LABEL2); \
283 #ifndef ASM_OUTPUT_DEBUG_DELTA4
284 #define ASM_OUTPUT_DEBUG_DELTA4(FILE,LABEL1,LABEL2) \
287 fprintf ((FILE), "\t%s\t", VMS_UNALIGNED_INT_ASM_OP); \
288 assemble_name (FILE, LABEL1); \
289 fprintf (FILE, "-"); \
290 assemble_name (FILE, LABEL2); \
295 #ifndef ASM_OUTPUT_DEBUG_ADDR_DELTA
296 #define ASM_OUTPUT_DEBUG_ADDR_DELTA(FILE,LABEL1,LABEL2) \
299 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
300 assemble_name (FILE, LABEL1); \
301 fprintf (FILE, "-"); \
302 assemble_name (FILE, LABEL2); \
307 #ifndef ASM_OUTPUT_DEBUG_ADDR
308 #define ASM_OUTPUT_DEBUG_ADDR(FILE,LABEL) \
311 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
312 assemble_name (FILE, LABEL); \
317 #ifndef ASM_OUTPUT_DEBUG_ADDR_CONST
318 #define ASM_OUTPUT_DEBUG_ADDR_CONST(FILE,ADDR) \
319 fprintf ((FILE), "\t%s\t%s", UNALIGNED_PTR_ASM_OP, (ADDR))
322 #ifndef ASM_OUTPUT_DEBUG_DATA1
323 #define ASM_OUTPUT_DEBUG_DATA1(FILE,VALUE) \
324 fprintf ((FILE), "\t%s\t%#x", VMS_ASM_BYTE_OP, (unsigned char) VALUE)
327 #ifndef ASM_OUTPUT_DEBUG_DATA2
328 #define ASM_OUTPUT_DEBUG_DATA2(FILE,VALUE) \
329 fprintf ((FILE), "\t%s\t%#x", VMS_UNALIGNED_SHORT_ASM_OP, \
330 (unsigned short) VALUE)
333 #ifndef ASM_OUTPUT_DEBUG_DATA4
334 #define ASM_OUTPUT_DEBUG_DATA4(FILE,VALUE) \
335 fprintf ((FILE), "\t%s\t%#lx", VMS_UNALIGNED_INT_ASM_OP, \
336 (unsigned long) VALUE)
339 #ifndef ASM_OUTPUT_DEBUG_DATA
340 #define ASM_OUTPUT_DEBUG_DATA(FILE,VALUE) \
341 fprintf ((FILE), "\t%s\t%#lx", UNALIGNED_OFFSET_ASM_OP (VALUE), VALUE)
344 #ifndef ASM_OUTPUT_DEBUG_ADDR_DATA
345 #define ASM_OUTPUT_DEBUG_ADDR_DATA(FILE,VALUE) \
346 fprintf ((FILE), "\t%s\t%#lx", UNALIGNED_PTR_ASM_OP, \
347 (unsigned long) VALUE)
350 #ifndef ASM_OUTPUT_DEBUG_DATA8
351 #define ASM_OUTPUT_DEBUG_DATA8(FILE,VALUE) \
352 fprintf ((FILE), "\t%s\t%#llx", VMS_UNALIGNED_DOUBLE_INT_ASM_OP, \
353 (unsigned long long) VALUE)
356 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
357 newline is produced. When flag_verbose_asm is asserted, we add commentary
358 at the end of the line, so we must avoid output of a newline here. */
359 #ifndef ASM_OUTPUT_DEBUG_STRING
360 #define ASM_OUTPUT_DEBUG_STRING(FILE,P) \
363 register int slen = strlen (P); \
364 register const char *p = (P); \
366 fprintf (FILE, "\t.ascii \""); \
367 for (i = 0; i < slen; i++) \
369 register int c = p[i]; \
370 if (c == '\"' || c == '\\') \
372 if (c >= ' ' && c < 0177) \
375 fprintf (FILE, "\\%o", c); \
377 fprintf (FILE, "\""); \
382 /* Convert a reference to the assembler name of a C-level name. This
383 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
384 a string rather than writing to a file. */
385 #ifndef ASM_NAME_TO_STRING
386 #define ASM_NAME_TO_STRING(STR, NAME) \
389 if ((NAME)[0] == '*') \
390 strcpy (STR, NAME+1); \
392 strcpy (STR, NAME); \
398 /* Output the debug header HEADER. Also output COMMENT if flag_verbose_asm is
399 set. Return the header size. Just return the size if DOSIZEONLY is
403 write_debug_header (DST_HEADER
*header
, const char *comment
, int dosizeonly
)
407 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
,
408 header
->dst__header_length
.dst_w_length
);
410 if (flag_verbose_asm
)
411 fprintf (asm_out_file
, "\t%s record length", ASM_COMMENT_START
);
412 fputc ('\n', asm_out_file
);
414 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
,
415 header
->dst__header_type
.dst_w_type
);
417 if (flag_verbose_asm
)
418 fprintf (asm_out_file
, "\t%s record type (%s)", ASM_COMMENT_START
,
421 fputc ('\n', asm_out_file
);
427 /* Output the address of SYMBOL. Also output COMMENT if flag_verbose_asm is
428 set. Return the address size. Just return the size if DOSIZEONLY is
432 write_debug_addr (const char *symbol
, const char *comment
, int dosizeonly
)
436 ASM_OUTPUT_DEBUG_ADDR (asm_out_file
, symbol
);
437 if (flag_verbose_asm
)
438 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
439 fputc ('\n', asm_out_file
);
445 /* Output the single byte DATA1. Also output COMMENT if flag_verbose_asm is
446 set. Return the data size. Just return the size if DOSIZEONLY is
450 write_debug_data1 (unsigned int data1
, const char *comment
, int dosizeonly
)
454 ASM_OUTPUT_DEBUG_DATA1 (asm_out_file
, data1
);
455 if (flag_verbose_asm
)
456 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
457 fputc ('\n', asm_out_file
);
463 /* Output the single word DATA2. Also output COMMENT if flag_verbose_asm is
464 set. Return the data size. Just return the size if DOSIZEONLY is
468 write_debug_data2 (unsigned int data2
, const char *comment
, int dosizeonly
)
472 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
, data2
);
473 if (flag_verbose_asm
)
474 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
475 fputc ('\n', asm_out_file
);
481 /* Output double word DATA4. Also output COMMENT if flag_verbose_asm is set.
482 Return the data size. Just return the size if DOSIZEONLY is nonzero. */
485 write_debug_data4 (unsigned long data4
, const char *comment
, int dosizeonly
)
489 ASM_OUTPUT_DEBUG_DATA4 (asm_out_file
, data4
);
490 if (flag_verbose_asm
)
491 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
492 fputc ('\n', asm_out_file
);
498 /* Output quad word DATA8. Also output COMMENT if flag_verbose_asm is set.
499 Return the data size. Just return the size if DOSIZEONLY is nonzero. */
502 write_debug_data8 (unsigned long long data8
, const char *comment
,
507 ASM_OUTPUT_DEBUG_DATA8 (asm_out_file
, data8
);
508 if (flag_verbose_asm
)
509 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
510 fputc ('\n', asm_out_file
);
516 /* Output the difference between LABEL1 and LABEL2. Also output COMMENT if
517 flag_verbose_asm is set. Return the data size. Just return the size if
518 DOSIZEONLY is nonzero. */
521 write_debug_delta4 (const char *label1
, const char *label2
,
522 const char *comment
, int dosizeonly
)
526 ASM_OUTPUT_DEBUG_DELTA4 (asm_out_file
, label1
, label2
);
527 if (flag_verbose_asm
)
528 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
529 fputc ('\n', asm_out_file
);
535 /* Output a character string STRING. Also write COMMENT if flag_verbose_asm is
536 set. Return the string length. Just return the length if DOSIZEONLY is
540 write_debug_string (const char *string
, const char *comment
, int dosizeonly
)
544 ASM_OUTPUT_DEBUG_STRING (asm_out_file
, string
);
545 if (flag_verbose_asm
)
546 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
547 fputc ('\n', asm_out_file
);
550 return strlen (string
);
553 /* Output a module begin header and return the header size. Just return the
554 size if DOSIZEONLY is nonzero. */
557 write_modbeg (int dosizeonly
)
559 DST_MODULE_BEGIN modbeg
;
562 char *module_name
, *m
;
567 /* Assumes primary filename has Unix syntax file spec. */
568 module_name
= xstrdup (lbasename (primary_filename
));
570 m
= strrchr (module_name
, '.');
574 modnamelen
= strlen (module_name
);
575 for (i
= 0; i
< modnamelen
; i
++)
576 module_name
[i
] = TOUPPER (module_name
[i
]);
578 prodnamelen
= strlen (module_producer
);
580 modbeg
.dst_a_modbeg_header
.dst__header_length
.dst_w_length
581 = DST_K_MODBEG_SIZE
+ modnamelen
+ DST_K_MB_TRLR_SIZE
+ prodnamelen
- 1;
582 modbeg
.dst_a_modbeg_header
.dst__header_type
.dst_w_type
= DST_K_MODBEG
;
583 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_hide
= 0;
584 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_version
= 1;
585 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_unused
= 0;
586 modbeg
.dst_b_modbeg_unused
= 0;
587 modbeg
.dst_l_modbeg_language
= (DST_LANGUAGE
) module_language
;
588 modbeg
.dst_w_version_major
= DST_K_VERSION_MAJOR
;
589 modbeg
.dst_w_version_minor
= DST_K_VERSION_MINOR
;
590 modbeg
.dst_b_modbeg_name
= strlen (module_name
);
592 mb_trlr
.dst_b_compiler
= strlen (module_producer
);
594 totsize
+= write_debug_header (&modbeg
.dst_a_modbeg_header
,
595 "modbeg", dosizeonly
);
596 totsize
+= write_debug_data1 (*((char *) &modbeg
.dst_b_modbeg_flags
),
597 "flags", dosizeonly
);
598 totsize
+= write_debug_data1 (modbeg
.dst_b_modbeg_unused
,
599 "unused", dosizeonly
);
600 totsize
+= write_debug_data4 (modbeg
.dst_l_modbeg_language
,
601 "language", dosizeonly
);
602 totsize
+= write_debug_data2 (modbeg
.dst_w_version_major
,
603 "DST major version", dosizeonly
);
604 totsize
+= write_debug_data2 (modbeg
.dst_w_version_minor
,
605 "DST minor version", dosizeonly
);
606 totsize
+= write_debug_data1 (modbeg
.dst_b_modbeg_name
,
607 "length of module name", dosizeonly
);
608 totsize
+= write_debug_string (module_name
, "module name", dosizeonly
);
609 totsize
+= write_debug_data1 (mb_trlr
.dst_b_compiler
,
610 "length of compiler name", dosizeonly
);
611 totsize
+= write_debug_string (module_producer
, "compiler name", dosizeonly
);
616 /* Output a module end trailer and return the trailer size. Just return
617 the size if DOSIZEONLY is nonzero. */
620 write_modend (int dosizeonly
)
622 DST_MODULE_END modend
;
625 modend
.dst_a_modend_header
.dst__header_length
.dst_w_length
626 = DST_K_MODEND_SIZE
- 1;
627 modend
.dst_a_modend_header
.dst__header_type
.dst_w_type
= DST_K_MODEND
;
629 totsize
+= write_debug_header (&modend
.dst_a_modend_header
, "modend",
635 /* Output a routine begin header routine RTNNUM and return the header size.
636 Just return the size if DOSIZEONLY is nonzero. */
639 write_rtnbeg (int rtnnum
, int dosizeonly
)
645 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
646 DST_ROUTINE_BEGIN rtnbeg
;
649 rtnname
= funcnam_table
[rtnnum
];
650 rtnnamelen
= strlen (rtnname
);
651 rtnentryname
= concat (rtnname
, "..en", NULL
);
653 if (!strcmp (rtnname
, "main"))
656 const char *go
= "TRANSFER$BREAK$GO";
658 /* This command isn't documented in DSTRECORDS, so it's made to
659 look like what DEC C does */
661 /* header size - 1st byte + flag byte + STO_LW size
662 + string count byte + string length */
663 header
.dst__header_length
.dst_w_length
664 = DST_K_DST_HEADER_SIZE
- 1 + 1 + 4 + 1 + strlen (go
);
665 header
.dst__header_type
.dst_w_type
= DST_K_TBG
;
667 totsize
+= write_debug_header (&header
, "transfer", dosizeonly
);
669 /* I think this is a flag byte, but I don't know what this flag means */
670 totsize
+= write_debug_data1 (0x1, "flags ???", dosizeonly
);
672 /* Routine Begin PD Address */
673 totsize
+= write_debug_addr (rtnname
, "main procedure descriptor",
675 totsize
+= write_debug_data1 (strlen (go
), "length of main_name",
677 totsize
+= write_debug_string (go
, "main name", dosizeonly
);
680 /* The header length never includes the length byte. */
681 rtnbeg
.dst_a_rtnbeg_header
.dst__header_length
.dst_w_length
682 = DST_K_RTNBEG_SIZE
+ rtnnamelen
- 1;
683 rtnbeg
.dst_a_rtnbeg_header
.dst__header_type
.dst_w_type
= DST_K_RTNBEG
;
684 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_unused
= 0;
685 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_unalloc
= 0;
686 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_prototype
= 0;
687 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_inlined
= 0;
688 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_no_call
= 1;
689 rtnbeg
.dst_b_rtnbeg_name
= rtnnamelen
;
691 totsize
+= write_debug_header (&rtnbeg
.dst_a_rtnbeg_header
, "rtnbeg",
693 totsize
+= write_debug_data1 (*((char *) &rtnbeg
.dst_b_rtnbeg_flags
),
694 "flags", dosizeonly
);
696 /* Routine Begin Address */
697 totsize
+= write_debug_addr (rtnentryname
, "routine entry name", dosizeonly
);
699 /* Routine Begin PD Address */
700 totsize
+= write_debug_addr (rtnname
, "routine procedure descriptor",
703 /* Routine Begin Name */
704 totsize
+= write_debug_data1 (rtnbeg
.dst_b_rtnbeg_name
,
705 "length of routine name", dosizeonly
);
707 totsize
+= write_debug_string (rtnname
, "routine name", dosizeonly
);
711 if (debug_info_level
> DINFO_LEVEL_TERSE
)
713 prolog
.dst_a_prolog_header
.dst__header_length
.dst_w_length
714 = DST_K_PROLOG_SIZE
- 1;
715 prolog
.dst_a_prolog_header
.dst__header_type
.dst_w_type
= DST_K_PROLOG
;
717 totsize
+= write_debug_header (&prolog
.dst_a_prolog_header
, "prolog",
720 ASM_GENERATE_INTERNAL_LABEL
721 (label
, FUNC_PROLOG_LABEL
,
722 funcnum_table
[rtnnum
]);
723 totsize
+= write_debug_addr (label
, "prolog breakpoint addr",
730 /* Output a routine end trailer for routine RTNNUM and return the header size.
731 Just return the size if DOSIZEONLY is nonzero. */
734 write_rtnend (int rtnnum
, int dosizeonly
)
736 DST_ROUTINE_END rtnend
;
737 char label1
[MAX_ARTIFICIAL_LABEL_BYTES
];
738 char label2
[MAX_ARTIFICIAL_LABEL_BYTES
];
743 rtnend
.dst_a_rtnend_header
.dst__header_length
.dst_w_length
744 = DST_K_RTNEND_SIZE
- 1;
745 rtnend
.dst_a_rtnend_header
.dst__header_type
.dst_w_type
= DST_K_RTNEND
;
746 rtnend
.dst_b_rtnend_unused
= 0;
747 rtnend
.dst_l_rtnend_size
= 0; /* Calculated below. */
749 totsize
+= write_debug_header (&rtnend
.dst_a_rtnend_header
, "rtnend",
751 totsize
+= write_debug_data1 (rtnend
.dst_b_rtnend_unused
, "unused",
754 ASM_GENERATE_INTERNAL_LABEL
755 (label1
, FUNC_BEGIN_LABEL
,
756 funcnum_table
[rtnnum
]);
757 ASM_GENERATE_INTERNAL_LABEL
758 (label2
, FUNC_END_LABEL
,
759 funcnum_table
[rtnnum
]);
760 totsize
+= write_debug_delta4 (label2
, label1
, "routine size", dosizeonly
);
765 #define K_DELTA_PC(I) \
766 ((I) < 128 ? -(I) : (I) < 65536 ? DST_K_DELTA_PC_W : DST_K_DELTA_PC_L)
768 #define K_SET_LINUM(I) \
769 ((I) < 256 ? DST_K_SET_LINUM_B \
770 : (I) < 65536 ? DST_K_SET_LINUM : DST_K_SET_LINUM_L)
772 #define K_INCR_LINUM(I) \
773 ((I) < 256 ? DST_K_INCR_LINUM \
774 : (I) < 65536 ? DST_K_INCR_LINUM_W : DST_K_INCR_LINUM_L)
776 /* Output the PC to line number correlations and return the size. Just return
777 the size if DOSIZEONLY is nonzero */
780 write_pclines (int dosizeonly
)
787 DST_LINE_NUM_HEADER line_num
;
788 DST_PCLINE_COMMANDS pcline
;
789 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
790 char lastlabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
794 max_line
= file_info_table
[1].max_line
;
795 file_info_table
[1].listing_line_start
= linestart
;
796 linestart
= linestart
+ ((max_line
/ 100000) + 1) * 100000;
798 for (i
= 2; i
< file_info_table_in_use
; i
++)
800 max_line
= file_info_table
[i
].max_line
;
801 file_info_table
[i
].listing_line_start
= linestart
;
802 linestart
= linestart
+ ((max_line
/ 10000) + 1) * 10000;
805 /* Set starting address to beginning of text section. */
806 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
= 8;
807 line_num
.dst_a_line_num_header
.dst__header_type
.dst_w_type
= DST_K_LINE_NUM
;
808 pcline
.dst_b_pcline_command
= DST_K_SET_ABS_PC
;
810 totsize
+= write_debug_header (&line_num
.dst_a_line_num_header
,
811 "line_num", dosizeonly
);
812 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
813 "line_num (SET ABS PC)", dosizeonly
);
819 ASM_OUTPUT_DEBUG_ADDR (asm_out_file
, TEXT_SECTION_ASM_OP
);
820 if (flag_verbose_asm
)
821 fprintf (asm_out_file
, "\t%s line_num", ASM_COMMENT_START
);
822 fputc ('\n', asm_out_file
);
825 fn
= line_info_table
[1].dst_file_num
;
826 ln
= (file_info_table
[fn
].listing_line_start
827 + line_info_table
[1].dst_line_num
);
828 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
= 4 + 4;
829 pcline
.dst_b_pcline_command
= DST_K_SET_LINUM_L
;
831 totsize
+= write_debug_header (&line_num
.dst_a_line_num_header
,
832 "line_num", dosizeonly
);
833 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
834 "line_num (SET LINUM LONG)", dosizeonly
);
836 sprintf (buff
, "line_num (%d)", ln
? ln
- 1 : 0);
837 totsize
+= write_debug_data4 (ln
? ln
- 1 : 0, buff
, dosizeonly
);
840 strcpy (lastlabel
, TEXT_SECTION_ASM_OP
);
841 for (i
= 1; i
< line_info_table_in_use
; i
++)
845 fn
= line_info_table
[i
].dst_file_num
;
846 ln
= (file_info_table
[fn
].listing_line_start
847 + line_info_table
[i
].dst_line_num
);
850 extrabytes
= 5; /* NUMBYTES (ln - lastln - 1) + 1; */
851 else if (ln
<= lastln
)
852 extrabytes
= 5; /* NUMBYTES (ln - 1) + 1; */
856 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
859 totsize
+= write_debug_header
860 (&line_num
.dst_a_line_num_header
, "line_num", dosizeonly
);
864 int lndif
= ln
- lastln
- 1;
866 /* K_INCR_LINUM (lndif); */
867 pcline
.dst_b_pcline_command
= DST_K_INCR_LINUM_L
;
869 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
870 "line_num (INCR LINUM LONG)",
873 sprintf (buff
, "line_num (%d)", lndif
);
874 totsize
+= write_debug_data4 (lndif
, buff
, dosizeonly
);
876 else if (ln
<= lastln
)
878 /* K_SET_LINUM (ln-1); */
879 pcline
.dst_b_pcline_command
= DST_K_SET_LINUM_L
;
881 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
882 "line_num (SET LINUM LONG)",
885 sprintf (buff
, "line_num (%d)", ln
- 1);
886 totsize
+= write_debug_data4 (ln
- 1, buff
, dosizeonly
);
889 pcline
.dst_b_pcline_command
= DST_K_DELTA_PC_L
;
891 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
892 "line_num (DELTA PC LONG)", dosizeonly
);
894 ASM_GENERATE_INTERNAL_LABEL (label
, LINE_CODE_LABEL
, i
);
895 totsize
+= write_debug_delta4 (label
, lastlabel
, "increment line_num",
899 strcpy (lastlabel
, label
);
905 /* Output a source correlation for file FILEID using information saved in
906 FILE_INFO_ENTRY and return the size. Just return the size if DOSIZEONLY is
910 write_srccorr (int fileid
, dst_file_info_entry file_info_entry
,
913 int src_command_size
;
914 int linesleft
= file_info_entry
.max_line
;
915 int linestart
= file_info_entry
.listing_line_start
;
916 int flen
= strlen (file_info_entry
.file_name
);
918 DST_SOURCE_CORR src_header
;
919 DST_SRC_COMMAND src_command
;
920 DST_SRC_COMMAND src_command_sf
;
921 DST_SRC_COMMAND src_command_sl
;
922 DST_SRC_COMMAND src_command_sr
;
923 DST_SRC_COMMAND src_command_dl
;
924 DST_SRC_CMDTRLR src_cmdtrlr
;
930 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
931 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 1 - 1;
932 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
934 src_command
.dst_b_src_command
= DST_K_SRC_FORMFEED
;
936 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
937 "source corr", dosizeonly
);
939 totsize
+= write_debug_data1 (src_command
.dst_b_src_command
,
940 "source_corr (SRC FORMFEED)",
945 = DST_K_SRC_COMMAND_SIZE
+ flen
+ DST_K_SRC_CMDTRLR_SIZE
;
946 src_command
.dst_b_src_command
= DST_K_SRC_DECLFILE
;
947 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_length
948 = src_command_size
- 2;
949 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_flags
= 0;
950 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_fileid
952 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_q_src_df_rms_cdt
953 = file_info_entry
.cdt
;
954 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_l_src_df_rms_ebk
955 = file_info_entry
.ebk
;
956 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_rms_ffb
957 = file_info_entry
.ffb
;
958 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_rms_rfo
959 = file_info_entry
.rfo
;
960 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_filename
963 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
964 = DST_K_SOURCE_CORR_HEADER_SIZE
+ src_command_size
- 1;
965 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
968 src_cmdtrlr
.dst_b_src_df_libmodname
= 0;
970 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
971 "source corr", dosizeonly
);
972 totsize
+= write_debug_data1 (src_command
.dst_b_src_command
,
973 "source_corr (DECL SRC FILE)", dosizeonly
);
974 totsize
+= write_debug_data1
975 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_length
,
976 "source_corr (length)", dosizeonly
);
978 totsize
+= write_debug_data1
979 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_flags
,
980 "source_corr (flags)", dosizeonly
);
982 totsize
+= write_debug_data2
983 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_fileid
,
984 "source_corr (fileid)", dosizeonly
);
986 totsize
+= write_debug_data8
987 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_q_src_df_rms_cdt
,
988 "source_corr (creation date)", dosizeonly
);
990 totsize
+= write_debug_data4
991 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_l_src_df_rms_ebk
,
992 "source_corr (EOF block number)", dosizeonly
);
994 totsize
+= write_debug_data2
995 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_rms_ffb
,
996 "source_corr (first free byte)", dosizeonly
);
998 totsize
+= write_debug_data1
999 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_rms_rfo
,
1000 "source_corr (record and file organization)", dosizeonly
);
1002 totsize
+= write_debug_data1
1003 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_filename
,
1004 "source_corr (filename length)", dosizeonly
);
1006 totsize
+= write_debug_string (remap_debug_filename (
1007 file_info_entry
.file_name
),
1008 "source file name", dosizeonly
);
1009 totsize
+= write_debug_data1 (src_cmdtrlr
.dst_b_src_df_libmodname
,
1010 "source_corr (libmodname)", dosizeonly
);
1012 src_command_sf
.dst_b_src_command
= DST_K_SRC_SETFILE
;
1013 src_command_sf
.dst_a_src_cmd_fields
.dst_w_src_unsword
= fileid
;
1015 src_command_sr
.dst_b_src_command
= DST_K_SRC_SETREC_W
;
1016 src_command_sr
.dst_a_src_cmd_fields
.dst_w_src_unsword
= 1;
1018 src_command_sl
.dst_b_src_command
= DST_K_SRC_SETLNUM_L
;
1019 src_command_sl
.dst_a_src_cmd_fields
.dst_l_src_unslong
= linestart
+ 1;
1021 src_command_dl
.dst_b_src_command
= DST_K_SRC_DEFLINES_W
;
1023 if (linesleft
> 65534)
1024 linesleft
= linesleft
- 65534, linestodo
= 65534;
1026 linestodo
= linesleft
, linesleft
= 0;
1028 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
= linestodo
;
1030 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1031 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 3 + 3 + 5 + 3 - 1;
1032 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1035 if (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
)
1037 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1038 "source corr", dosizeonly
);
1040 totsize
+= write_debug_data1 (src_command_sf
.dst_b_src_command
,
1041 "source_corr (src setfile)", dosizeonly
);
1043 totsize
+= write_debug_data2
1044 (src_command_sf
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1045 "source_corr (fileid)", dosizeonly
);
1047 totsize
+= write_debug_data1 (src_command_sr
.dst_b_src_command
,
1048 "source_corr (setrec)", dosizeonly
);
1050 totsize
+= write_debug_data2
1051 (src_command_sr
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1052 "source_corr (recnum)", dosizeonly
);
1054 totsize
+= write_debug_data1 (src_command_sl
.dst_b_src_command
,
1055 "source_corr (setlnum)", dosizeonly
);
1057 totsize
+= write_debug_data4
1058 (src_command_sl
.dst_a_src_cmd_fields
.dst_l_src_unslong
,
1059 "source_corr (linenum)", dosizeonly
);
1061 totsize
+= write_debug_data1 (src_command_dl
.dst_b_src_command
,
1062 "source_corr (deflines)", dosizeonly
);
1064 sprintf (buff
, "source_corr (%d)",
1065 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
);
1066 totsize
+= write_debug_data2
1067 (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1070 while (linesleft
> 0)
1072 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1073 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 3 - 1;
1074 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1076 src_command_dl
.dst_b_src_command
= DST_K_SRC_DEFLINES_W
;
1078 if (linesleft
> 65534)
1079 linesleft
= linesleft
- 65534, linestodo
= 65534;
1081 linestodo
= linesleft
, linesleft
= 0;
1083 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
= linestodo
;
1085 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1086 "source corr", dosizeonly
);
1087 totsize
+= write_debug_data1 (src_command_dl
.dst_b_src_command
,
1088 "source_corr (deflines)", dosizeonly
);
1089 sprintf (buff
, "source_corr (%d)",
1090 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
);
1091 totsize
+= write_debug_data2
1092 (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1100 /* Output all the source correlation entries and return the size. Just return
1101 the size if DOSIZEONLY is nonzero. */
1104 write_srccorrs (int dosizeonly
)
1109 for (i
= 1; i
< file_info_table_in_use
; i
++)
1110 totsize
+= write_srccorr (i
, file_info_table
[i
], dosizeonly
);
1115 /* Output a marker (i.e. a label) for the beginning of a function, before
1119 vmsdbgout_begin_prologue (unsigned int line
, unsigned int column
,
1122 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1124 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1125 (*dwarf2_debug_hooks
.begin_prologue
) (line
, column
, file
);
1127 if (debug_info_level
> DINFO_LEVEL_NONE
)
1129 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
1130 current_function_funcdef_no
);
1131 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1135 /* Output a marker (i.e. a label) for the beginning of a function, after
1139 vmsdbgout_end_prologue (unsigned int line
, const char *file
)
1141 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1143 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1144 (*dwarf2_debug_hooks
.end_prologue
) (line
, file
);
1146 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1148 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_PROLOG_LABEL
,
1149 current_function_funcdef_no
);
1150 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1152 /* VMS PCA expects every PC range to correlate to some line and file. */
1153 vmsdbgout_write_source_line (line
, file
, 0, true);
1157 /* No output for VMS debug, but make obligatory call to Dwarf2 debug */
1160 vmsdbgout_end_function (unsigned int line
)
1162 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1163 (*dwarf2_debug_hooks
.end_function
) (line
);
1166 /* Output a marker (i.e. a label) for the beginning of the epilogue.
1167 This gets called *before* the epilogue code has been generated. */
1170 vmsdbgout_begin_epilogue (unsigned int line
, const char *file
)
1172 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1173 static int save_current_function_funcdef_no
= -1;
1175 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1176 (*dwarf2_debug_hooks
.begin_epilogue
) (line
, file
);
1178 if (debug_info_level
> DINFO_LEVEL_NONE
)
1180 if (save_current_function_funcdef_no
!= current_function_funcdef_no
)
1182 /* Output a label to mark the endpoint of the code generated for this
1184 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_EPILOG_LABEL
,
1185 current_function_funcdef_no
);
1187 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1189 save_current_function_funcdef_no
= current_function_funcdef_no
;
1191 /* VMS PCA expects every PC range to correlate to some line and
1193 vmsdbgout_write_source_line (line
, file
, 0, true);
1198 /* Output a marker (i.e. a label) for the absolute end of the generated code
1199 for a function definition. This gets called *after* the epilogue code has
1203 vmsdbgout_end_epilogue (unsigned int line
, const char *file
)
1205 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1207 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1208 (*dwarf2_debug_hooks
.end_epilogue
) (line
, file
);
1210 if (debug_info_level
> DINFO_LEVEL_NONE
)
1212 /* Output a label to mark the endpoint of the code generated for this
1214 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
,
1215 current_function_funcdef_no
);
1216 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1218 /* VMS PCA expects every PC range to correlate to some line and file. */
1219 vmsdbgout_write_source_line (line
, file
, 0, true);
1223 /* Output a marker (i.e. a label) for the beginning of the generated code for
1227 vmsdbgout_begin_block (register unsigned line
, register unsigned blocknum
)
1229 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1230 (*dwarf2_debug_hooks
.begin_block
) (line
, blocknum
);
1232 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1233 targetm
.asm_out
.internal_label (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
1236 /* Output a marker (i.e. a label) for the end of the generated code for a
1240 vmsdbgout_end_block (register unsigned line
, register unsigned blocknum
)
1242 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1243 (*dwarf2_debug_hooks
.end_block
) (line
, blocknum
);
1245 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1246 targetm
.asm_out
.internal_label (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
1249 /* Not implemented in VMS Debug. */
1252 vmsdbgout_ignore_block (const_tree block
)
1256 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1257 retval
= (*dwarf2_debug_hooks
.ignore_block
) (block
);
1262 /* Add an entry for function DECL into the funcnam_table. */
1265 vmsdbgout_begin_function (tree decl
)
1267 const char *name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1269 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1270 (*dwarf2_debug_hooks
.begin_function
) (decl
);
1272 /* Add the new entry to the end of the function name table. */
1273 funcnam_table
.safe_push (xstrdup (name
));
1274 funcnum_table
.safe_push (current_function_funcdef_no
);
1277 static char fullname_buff
[4096];
1279 /* Return the full file specification for FILENAME. The specification must be
1280 in VMS syntax in order to be processed by VMS Debug. */
1283 full_name (const char *filename
)
1286 FILE *fp
= fopen (filename
, "r");
1288 fgetname (fp
, fullname_buff
, 1);
1291 /* Unix paths really mess up VMS debug. Better to just output the
1293 strcpy (fullname_buff
, filename
);
1296 return fullname_buff
;
1299 /* Lookup a filename (in the list of filenames that we know about here in
1300 vmsdbgout.c) and return its "index". The index of each (known) filename is
1301 just a unique number which is associated with only that one filename. We
1302 need such numbers for the sake of generating labels and references
1303 to those files numbers. If the filename given as an argument is not
1304 found in our current list, add it to the list and assign it the next
1305 available unique index number. In order to speed up searches, we remember
1306 the index of the filename was looked up last. This handles the majority of
1310 lookup_filename (const char *file_name
)
1312 static unsigned int last_file_lookup_index
= 0;
1314 register unsigned i
;
1323 fnam
= full_name (file_name
);
1325 /* Check to see if the file name that was searched on the previous call
1326 matches this file name. If so, return the index. */
1327 if (last_file_lookup_index
!= 0)
1329 fn
= file_info_table
[last_file_lookup_index
].file_name
;
1330 if (strcmp (fnam
, fn
) == 0)
1331 return last_file_lookup_index
;
1334 /* Didn't match the previous lookup, search the table */
1335 for (i
= 1; i
< file_info_table_in_use
; ++i
)
1337 fn
= file_info_table
[i
].file_name
;
1338 if (strcmp (fnam
, fn
) == 0)
1340 last_file_lookup_index
= i
;
1345 /* Prepare to add a new table entry by making sure there is enough space in
1346 the table to do so. If not, expand the current table. */
1347 if (file_info_table_in_use
== file_info_table_allocated
)
1350 file_info_table_allocated
+= FILE_TABLE_INCREMENT
;
1351 file_info_table
= XRESIZEVEC (dst_file_info_entry
, file_info_table
,
1352 file_info_table_allocated
);
1355 if (vms_file_stats_name (file_name
, &cdt
, &siz
, &rfo
, &ver
) == 0)
1357 ebk
= siz
/ 512 + 1;
1358 ffb
= siz
- ((siz
/ 512) * 512);
1361 /* Add the new entry to the end of the filename table. */
1362 file_info_table
[file_info_table_in_use
].file_name
= xstrdup (fnam
);
1363 file_info_table
[file_info_table_in_use
].max_line
= 0;
1364 file_info_table
[file_info_table_in_use
].cdt
= cdt
;
1365 file_info_table
[file_info_table_in_use
].ebk
= ebk
;
1366 file_info_table
[file_info_table_in_use
].ffb
= ffb
;
1367 file_info_table
[file_info_table_in_use
].rfo
= rfo
;
1369 last_file_lookup_index
= file_info_table_in_use
++;
1370 return last_file_lookup_index
;
1373 /* Output a label to mark the beginning of a source code line entry
1374 and record information relating to this source line, in
1375 'line_info_table' for later output of the .debug_line section. */
1378 vmsdbgout_write_source_line (unsigned line
, const char *filename
,
1379 int /* discriminator */, bool /* is_stmt */)
1381 dst_line_info_ref line_info
;
1383 targetm
.asm_out
.internal_label (asm_out_file
, LINE_CODE_LABEL
,
1384 line_info_table_in_use
);
1386 /* Expand the line info table if necessary. */
1387 if (line_info_table_in_use
== line_info_table_allocated
)
1389 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
1390 line_info_table
= XRESIZEVEC (dst_line_info_entry
, line_info_table
,
1391 line_info_table_allocated
);
1394 /* Add the new entry at the end of the line_info_table. */
1395 line_info
= &line_info_table
[line_info_table_in_use
++];
1396 line_info
->dst_file_num
= lookup_filename (filename
);
1397 line_info
->dst_line_num
= line
;
1398 if (line
> file_info_table
[line_info
->dst_file_num
].max_line
)
1399 file_info_table
[line_info
->dst_file_num
].max_line
= line
;
1403 vmsdbgout_source_line (register unsigned line
, unsigned int column
,
1404 register const char *filename
,
1405 int discriminator
, bool is_stmt
)
1407 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1408 (*dwarf2_debug_hooks
.source_line
) (line
, column
, filename
, discriminator
,
1411 if (debug_info_level
>= DINFO_LEVEL_TERSE
)
1412 vmsdbgout_write_source_line (line
, filename
, discriminator
, is_stmt
);
1415 /* Record the beginning of a new source file, for later output.
1416 At present, unimplemented. */
1419 vmsdbgout_start_source_file (unsigned int lineno
, const char *filename
)
1421 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1422 (*dwarf2_debug_hooks
.start_source_file
) (lineno
, filename
);
1425 /* Record the end of a source file, for later output.
1426 At present, unimplemented. */
1429 vmsdbgout_end_source_file (unsigned int lineno ATTRIBUTE_UNUSED
)
1431 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1432 (*dwarf2_debug_hooks
.end_source_file
) (lineno
);
1435 /* Set up for Debug output at the start of compilation. */
1438 vmsdbgout_init (const char *filename
)
1440 const char *language_string
= lang_hooks
.name
;
1442 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1443 (*dwarf2_debug_hooks
.init
) (filename
);
1445 if (debug_info_level
== DINFO_LEVEL_NONE
)
1448 /* Remember the name of the primary input file. */
1449 primary_filename
= filename
;
1451 /* Allocate the initial hunk of the file_info_table. */
1452 file_info_table
= XCNEWVEC (dst_file_info_entry
, FILE_TABLE_INCREMENT
);
1453 file_info_table_allocated
= FILE_TABLE_INCREMENT
;
1454 /* Skip the first entry - file numbers begin at 1. */
1455 file_info_table_in_use
= 1;
1457 funcnam_table
.create (FUNC_TABLE_INITIAL
);
1458 funcnum_table
.create (FUNC_TABLE_INITIAL
);
1460 /* Allocate the initial hunk of the line_info_table. */
1461 line_info_table
= XCNEWVEC (dst_line_info_entry
, LINE_INFO_TABLE_INCREMENT
);
1462 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
1463 /* zero-th entry is allocated, but unused */
1464 line_info_table_in_use
= 1;
1466 lookup_filename (primary_filename
);
1469 module_language
= DST_K_C
;
1470 else if (lang_GNU_CXX ())
1471 module_language
= DST_K_CXX
;
1472 else if (!strcmp (language_string
, "GNU Ada"))
1473 module_language
= DST_K_ADA
;
1474 else if (!strcmp (language_string
, "GNU F77"))
1475 module_language
= DST_K_FORTRAN
;
1477 module_language
= DST_K_UNKNOWN
;
1479 module_producer
= concat (language_string
, " ", version_string
, NULL
);
1481 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
1485 /* Not implemented in VMS Debug. */
1488 vmsdbgout_assembly_start (void)
1490 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1491 (*dwarf2_debug_hooks
.assembly_start
) ();
1494 /* Not implemented in VMS Debug. */
1497 vmsdbgout_define (unsigned int lineno
, const char *buffer
)
1499 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1500 (*dwarf2_debug_hooks
.define
) (lineno
, buffer
);
1503 /* Not implemented in VMS Debug. */
1506 vmsdbgout_undef (unsigned int lineno
, const char *buffer
)
1508 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1509 (*dwarf2_debug_hooks
.undef
) (lineno
, buffer
);
1512 /* Not implemented in VMS Debug. */
1515 vmsdbgout_function_decl (tree decl
)
1517 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1518 (*dwarf2_debug_hooks
.function_decl
) (decl
);
1521 /* Not implemented in VMS Debug. */
1524 vmsdbgout_early_global_decl (tree decl
)
1526 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1527 (*dwarf2_debug_hooks
.early_global_decl
) (decl
);
1530 /* Not implemented in VMS Debug. */
1533 vmsdbgout_late_global_decl (tree decl
)
1535 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1536 (*dwarf2_debug_hooks
.late_global_decl
) (decl
);
1539 /* Not implemented in VMS Debug. */
1542 vmsdbgout_type_decl (tree decl
, int local
)
1544 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1545 (*dwarf2_debug_hooks
.type_decl
) (decl
, local
);
1548 /* Not implemented in VMS Debug. */
1551 vmsdbgout_abstract_function (tree decl
)
1553 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1554 (*dwarf2_debug_hooks
.outlining_inline_function
) (decl
);
1557 /* Output stuff that Debug requires at the end of every file and generate the
1558 VMS Debug debugging info. */
1561 vmsdbgout_finish (const char *filename ATTRIBUTE_UNUSED
)
1563 unsigned int i
, ifunc
;
1566 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1567 (*dwarf2_debug_hooks
.finish
) (filename
);
1569 if (debug_info_level
== DINFO_LEVEL_NONE
)
1572 /* Output a terminator label for the .text section. */
1573 switch_to_section (text_section
);
1574 targetm
.asm_out
.internal_label (asm_out_file
, TEXT_END_LABEL
, 0);
1576 /* Output debugging information.
1577 Warning! Do not change the name of the .vmsdebug section without
1578 changing it in the assembler also. */
1579 switch_to_section (get_named_section (NULL
, ".vmsdebug", 0));
1580 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
1582 totsize
= write_modbeg (1);
1583 FOR_EACH_VEC_ELT (funcnum_table
, i
, ifunc
)
1585 totsize
+= write_rtnbeg (i
, 1);
1586 totsize
+= write_rtnend (i
, 1);
1588 totsize
+= write_pclines (1);
1591 FOR_EACH_VEC_ELT (funcnum_table
, i
, ifunc
)
1593 write_rtnbeg (i
, 0);
1594 write_rtnend (i
, 0);
1598 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1600 totsize
= write_srccorrs (1);
1604 totsize
= write_modend (1);
1608 /* Need for both Dwarf2 on IVMS and VMS Debug on AVMS */
1611 #define __NEW_STARLET 1
1612 #include <vms/rms.h>
1613 #include <vms/atrdef.h>
1614 #include <vms/fibdef.h>
1615 #include <vms/stsdef.h>
1616 #include <vms/iodef.h>
1617 #include <vms/fatdef.h>
1618 #include <vms/descrip.h>
1619 #include <unixlib.h>
1623 /* descrip.h doesn't have everything ... */
1624 typedef struct fibdef
* __fibdef_ptr32
__attribute__ (( mode (SI
) ));
1625 struct dsc$descriptor_fib
1627 unsigned int fib$l_len
;
1628 __fibdef_ptr32 fib$l_addr
;
1631 /* I/O Status Block. */
1634 unsigned short status
, count
;
1635 unsigned int devdep
;
1638 static char *tryfile
;
1640 /* Variable length string. */
1644 char string
[NAM$C_MAXRSS
+1];
1647 static char filename_buff
[MAXPATH
];
1648 static char vms_filespec
[MAXPATH
];
1650 /* Callback function for filespec style conversion. */
1653 translate_unix (char *name
, int type ATTRIBUTE_UNUSED
)
1655 strncpy (filename_buff
, name
, MAXPATH
);
1656 filename_buff
[MAXPATH
- 1] = (char) 0;
1660 /* Wrapper for DECC function that converts a Unix filespec
1661 to VMS style filespec. */
1664 to_vms_file_spec (char *filespec
)
1666 strncpy (vms_filespec
, "", MAXPATH
);
1667 decc$
to_vms (filespec
, translate_unix
, 1, 1);
1668 strncpy (vms_filespec
, filename_buff
, MAXPATH
);
1670 vms_filespec
[MAXPATH
- 1] = (char) 0;
1672 return vms_filespec
;
1676 #define VMS_EPOCH_OFFSET 35067168000000000LL
1677 #define VMS_GRANULARITY_FACTOR 10000000
1680 /* Return VMS file date, size, format, version given a name. */
1683 vms_file_stats_name (const char *filename
, long long *cdt
, long *siz
, char *rfo
,
1690 unsigned long long create
;
1692 char ascnamebuff
[256];
1696 { ATR$S_CREDATE
, ATR$C_CREDATE
, &create
},
1697 { ATR$S_RECATTR
, ATR$C_RECATTR
, &recattr
},
1698 { ATR$S_ASCNAME
, ATR$C_ASCNAME
, &ascnamebuff
},
1703 struct dsc$descriptor_fib fibdsc
= {sizeof (fib
), (void *) &fib
};
1708 unsigned short chan
;
1710 struct vstring file
;
1711 struct dsc$descriptor_s filedsc
1712 = {NAM$C_MAXRSS
, DSC$K_DTYPE_T
, DSC$K_CLASS_S
, (void *) file
.string
};
1713 struct vstring device
;
1714 struct dsc$descriptor_s devicedsc
1715 = {NAM$C_MAXRSS
, DSC$K_DTYPE_T
, DSC$K_CLASS_S
, (void *) device
.string
};
1716 struct vstring result
;
1717 struct dsc$descriptor_s resultdsc
1718 = {NAM$C_MAXRSS
, DSC$K_DTYPE_VT
, DSC$K_CLASS_VS
, (void *) result
.string
};
1720 if (strcmp (filename
, "<internal>") == 0
1721 || strcmp (filename
, "<built-in>") == 0)
1738 tryfile
= to_vms_file_spec (filename
);
1740 /* Allocate and initialize a FAB and NAM structures. */
1744 nam
.nam$l_esa
= file
.string
;
1745 nam
.nam$b_ess
= NAM$C_MAXRSS
;
1746 nam
.nam$l_rsa
= result
.string
;
1747 nam
.nam$b_rss
= NAM$C_MAXRSS
;
1748 fab
.fab$l_fna
= tryfile
;
1749 fab
.fab$b_fns
= strlen (tryfile
);
1750 fab
.fab$l_nam
= &nam
;
1752 /* Validate filespec syntax and device existence. */
1753 status
= SYS$
PARSE (&fab
, 0, 0);
1754 if ((status
& 1) != 1)
1757 file
.string
[nam
.nam$b_esl
] = 0;
1759 /* Find matching filespec. */
1760 status
= SYS$
SEARCH (&fab
, 0, 0);
1761 if ((status
& 1) != 1)
1764 file
.string
[nam
.nam$b_esl
] = 0;
1765 result
.string
[result
.length
=nam
.nam$b_rsl
] = 0;
1767 /* Get the device name and assign an IO channel. */
1768 strncpy (device
.string
, nam
.nam$l_dev
, nam
.nam$b_dev
);
1769 devicedsc
.dsc$w_length
= nam
.nam$b_dev
;
1771 status
= SYS$
ASSIGN (&devicedsc
, &chan
, 0, 0, 0);
1772 if ((status
& 1) != 1)
1775 /* Initialize the FIB and fill in the directory id field. */
1776 memset (&fib
, 0, sizeof (fib
));
1777 fib
.fib$w_did
[0] = nam
.nam$w_did
[0];
1778 fib
.fib$w_did
[1] = nam
.nam$w_did
[1];
1779 fib
.fib$w_did
[2] = nam
.nam$w_did
[2];
1780 fib
.fib$l_acctl
= 0;
1782 strcpy (file
.string
, (strrchr (result
.string
, ']') + 1));
1783 filedsc
.dsc$w_length
= strlen (file
.string
);
1784 result
.string
[result
.length
= 0] = 0;
1786 /* Open and close the file to fill in the attributes. */
1788 = SYS$
QIOW (0, chan
, IO$_ACCESS
|IO$M_ACCESS
, &iosb
, 0, 0,
1789 &fibdsc
, &filedsc
, &result
.length
, &resultdsc
, &atrlst
, 0);
1790 if ((status
& 1) != 1)
1792 if ((iosb
.status
& 1) != 1)
1795 result
.string
[result
.length
] = 0;
1796 status
= SYS$
QIOW (0, chan
, IO$_DEACCESS
, &iosb
, 0, 0, &fibdsc
, 0, 0, 0,
1798 if ((status
& 1) != 1)
1800 if ((iosb
.status
& 1) != 1)
1803 /* Deassign the channel and exit. */
1804 status
= SYS$
DASSGN (chan
);
1805 if ((status
& 1) != 1)
1808 if (cdt
) *cdt
= create
;
1809 if (siz
) *siz
= (512 * 65536 * recattr
.fat$w_efblkh
) +
1810 (512 * (recattr
.fat$w_efblkl
- 1)) +
1811 recattr
.fat$w_ffbyte
;
1812 if (rfo
) *rfo
= recattr
.fat$v_rtype
;
1813 if (ver
) *ver
= strtol (strrchr (ascnamebuff
, ';')+1, 0, 10);
1819 if ((stat (filename
, &buff
)) != 0)
1823 *cdt
= (long long) (buff
.st_mtime
* VMS_GRANULARITY_FACTOR
)
1827 *siz
= buff
.st_size
;
1830 *rfo
= 2; /* Stream LF format */