1 /* Output VMS debug format symbol table information from GCC.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
5 Contributed by Douglas B. Rupp (rupp@gnat.com).
6 Updated by Bernard W. Giroud (bgiroud@users.sourceforge.net).
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 3, or (at your option) any later
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3. If not see
22 <http://www.gnu.org/licenses/>. */
26 #include "coretypes.h"
29 #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 DEF_VEC_ALLOC_P(char_p
,heap
);
107 static VEC(char_p
,heap
) *funcnam_table
;
108 static VEC(unsigned,heap
) *funcnum_table
;
109 #define FUNC_TABLE_INITIAL 256
111 /* Local pointer to the name of the main input file. Initialized in
113 static const char *primary_filename
;
115 static char *module_producer
;
116 static unsigned int module_language
;
118 /* A pointer to the base of a table that contains line information
119 for each source code line in .text in the compilation unit. */
120 static dst_line_info_ref line_info_table
;
122 /* Number of elements currently allocated for line_info_table. */
123 static unsigned int line_info_table_allocated
;
125 /* Number of elements in line_info_table currently in use. */
126 static unsigned int line_info_table_in_use
;
128 /* Size (in elements) of increments by which we may expand line_info_table. */
129 #define LINE_INFO_TABLE_INCREMENT 1024
131 /* Forward declarations for functions defined in this file. */
132 static char *full_name (const char *);
133 static unsigned int lookup_filename (const char *);
134 static int write_debug_header (DST_HEADER
*, const char *, int);
135 static int write_debug_addr (const char *, const char *, int);
136 static int write_debug_data1 (unsigned int, const char *, int);
137 static int write_debug_data2 (unsigned int, const char *, int);
138 static int write_debug_data4 (unsigned long, const char *, int);
139 static int write_debug_data8 (unsigned long long, const char *, int);
140 static int write_debug_delta4 (const char *, const char *, const char *, int);
141 static int write_debug_string (const char *, const char *, int);
142 static int write_modbeg (int);
143 static int write_modend (int);
144 static int write_rtnbeg (int, int);
145 static int write_rtnend (int, int);
146 static int write_pclines (int);
147 static int write_srccorr (int, dst_file_info_entry
, int);
148 static int write_srccorrs (int);
150 static void vmsdbgout_init (const char *);
151 static void vmsdbgout_finish (const char *);
152 static void vmsdbgout_assembly_start (void);
153 static void vmsdbgout_define (unsigned int, const char *);
154 static void vmsdbgout_undef (unsigned int, const char *);
155 static void vmsdbgout_start_source_file (unsigned int, const char *);
156 static void vmsdbgout_end_source_file (unsigned int);
157 static void vmsdbgout_begin_block (unsigned int, unsigned int);
158 static void vmsdbgout_end_block (unsigned int, unsigned int);
159 static bool vmsdbgout_ignore_block (const_tree
);
160 static void vmsdbgout_source_line (unsigned int, const char *, int, bool);
161 static void vmsdbgout_write_source_line (unsigned, const char *, int , bool);
162 static void vmsdbgout_begin_prologue (unsigned int, const char *);
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_decl (tree
);
169 static void vmsdbgout_global_decl (tree
);
170 static void vmsdbgout_type_decl (tree
, int);
171 static void vmsdbgout_abstract_function (tree
);
173 /* The debug hooks structure. */
175 const struct gcc_debug_hooks vmsdbg_debug_hooks
178 vmsdbgout_assembly_start
,
181 vmsdbgout_start_source_file
,
182 vmsdbgout_end_source_file
,
183 vmsdbgout_begin_block
,
185 vmsdbgout_ignore_block
,
186 vmsdbgout_source_line
,
187 vmsdbgout_begin_prologue
,
188 vmsdbgout_end_prologue
,
189 vmsdbgout_begin_epilogue
,
190 vmsdbgout_end_epilogue
,
191 vmsdbgout_begin_function
,
192 vmsdbgout_end_function
,
194 vmsdbgout_global_decl
,
195 vmsdbgout_type_decl
, /* type_decl */
196 debug_nothing_tree_tree_tree_bool
, /* imported_module_or_decl */
197 debug_nothing_tree
, /* deferred_inline_function */
198 vmsdbgout_abstract_function
,
199 debug_nothing_rtx
, /* label */
200 debug_nothing_int
, /* handle_pch */
201 debug_nothing_rtx
, /* var_location */
202 debug_nothing_void
, /* switch_text_section */
203 debug_nothing_tree_tree
, /* set_name */
204 0, /* start_end_main_source_file */
205 TYPE_SYMTAB_IS_ADDRESS
/* tree_type_symtab_field */
208 /* Definitions of defaults for assembler-dependent names of various
209 pseudo-ops and section names. */
210 #define VMS_UNALIGNED_SHORT_ASM_OP ".word"
211 #define VMS_UNALIGNED_INT_ASM_OP ".long"
212 #define VMS_UNALIGNED_LONG_ASM_OP ".long"
213 #define VMS_UNALIGNED_DOUBLE_INT_ASM_OP ".quad"
215 #define VMS_ASM_BYTE_OP ".byte"
217 #define NUMBYTES(I) ((I) < 256 ? 1 : (I) < 65536 ? 2 : 4)
219 #define NUMBYTES0(I) ((I) < 128 ? 0 : (I) < 65536 ? 2 : 4)
221 #ifndef UNALIGNED_PTR_ASM_OP
222 #define UNALIGNED_PTR_ASM_OP \
223 (PTR_SIZE == 8 ? VMS_UNALIGNED_DOUBLE_INT_ASM_OP : VMS_UNALIGNED_INT_ASM_OP)
226 #ifndef UNALIGNED_OFFSET_ASM_OP
227 #define UNALIGNED_OFFSET_ASM_OP(OFFSET) \
228 (NUMBYTES(OFFSET) == 4 \
229 ? VMS_UNALIGNED_LONG_ASM_OP \
230 : (NUMBYTES(OFFSET) == 2 ? VMS_UNALIGNED_SHORT_ASM_OP : VMS_ASM_BYTE_OP))
233 /* Definitions of defaults for formats and names of various special
234 (artificial) labels which may be generated within this file (when the -g
235 options is used and VMS_DEBUGGING_INFO is in effect. If necessary, these
236 may be overridden from within the tm.h file, but typically, overriding these
237 defaults is unnecessary. */
239 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
241 #ifndef TEXT_END_LABEL
242 #define TEXT_END_LABEL "Lvetext"
244 #ifndef FUNC_BEGIN_LABEL
245 #define FUNC_BEGIN_LABEL "LVFB"
247 #ifndef FUNC_PROLOG_LABEL
248 #define FUNC_PROLOG_LABEL "LVFP"
250 #ifndef FUNC_EPILOG_LABEL
251 #define FUNC_EPILOG_LABEL "LVEB"
253 #ifndef FUNC_END_LABEL
254 #define FUNC_END_LABEL "LVFE"
256 #ifndef BLOCK_BEGIN_LABEL
257 #define BLOCK_BEGIN_LABEL "LVBB"
259 #ifndef BLOCK_END_LABEL
260 #define BLOCK_END_LABEL "LVBE"
262 #ifndef LINE_CODE_LABEL
263 #define LINE_CODE_LABEL "LVM"
266 #ifndef ASM_OUTPUT_DEBUG_DELTA2
267 #define ASM_OUTPUT_DEBUG_DELTA2(FILE,LABEL1,LABEL2) \
270 fprintf ((FILE), "\t%s\t", VMS_UNALIGNED_SHORT_ASM_OP); \
271 assemble_name (FILE, LABEL1); \
272 fprintf (FILE, "-"); \
273 assemble_name (FILE, LABEL2); \
278 #ifndef ASM_OUTPUT_DEBUG_DELTA4
279 #define ASM_OUTPUT_DEBUG_DELTA4(FILE,LABEL1,LABEL2) \
282 fprintf ((FILE), "\t%s\t", VMS_UNALIGNED_INT_ASM_OP); \
283 assemble_name (FILE, LABEL1); \
284 fprintf (FILE, "-"); \
285 assemble_name (FILE, LABEL2); \
290 #ifndef ASM_OUTPUT_DEBUG_ADDR_DELTA
291 #define ASM_OUTPUT_DEBUG_ADDR_DELTA(FILE,LABEL1,LABEL2) \
294 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
295 assemble_name (FILE, LABEL1); \
296 fprintf (FILE, "-"); \
297 assemble_name (FILE, LABEL2); \
302 #ifndef ASM_OUTPUT_DEBUG_ADDR
303 #define ASM_OUTPUT_DEBUG_ADDR(FILE,LABEL) \
306 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
307 assemble_name (FILE, LABEL); \
312 #ifndef ASM_OUTPUT_DEBUG_ADDR_CONST
313 #define ASM_OUTPUT_DEBUG_ADDR_CONST(FILE,ADDR) \
314 fprintf ((FILE), "\t%s\t%s", UNALIGNED_PTR_ASM_OP, (ADDR))
317 #ifndef ASM_OUTPUT_DEBUG_DATA1
318 #define ASM_OUTPUT_DEBUG_DATA1(FILE,VALUE) \
319 fprintf ((FILE), "\t%s\t%#x", VMS_ASM_BYTE_OP, (unsigned char) VALUE)
322 #ifndef ASM_OUTPUT_DEBUG_DATA2
323 #define ASM_OUTPUT_DEBUG_DATA2(FILE,VALUE) \
324 fprintf ((FILE), "\t%s\t%#x", VMS_UNALIGNED_SHORT_ASM_OP, \
325 (unsigned short) VALUE)
328 #ifndef ASM_OUTPUT_DEBUG_DATA4
329 #define ASM_OUTPUT_DEBUG_DATA4(FILE,VALUE) \
330 fprintf ((FILE), "\t%s\t%#lx", VMS_UNALIGNED_INT_ASM_OP, \
331 (unsigned long) VALUE)
334 #ifndef ASM_OUTPUT_DEBUG_DATA
335 #define ASM_OUTPUT_DEBUG_DATA(FILE,VALUE) \
336 fprintf ((FILE), "\t%s\t%#lx", UNALIGNED_OFFSET_ASM_OP(VALUE), VALUE)
339 #ifndef ASM_OUTPUT_DEBUG_ADDR_DATA
340 #define ASM_OUTPUT_DEBUG_ADDR_DATA(FILE,VALUE) \
341 fprintf ((FILE), "\t%s\t%#lx", UNALIGNED_PTR_ASM_OP, \
342 (unsigned long) VALUE)
345 #ifndef ASM_OUTPUT_DEBUG_DATA8
346 #define ASM_OUTPUT_DEBUG_DATA8(FILE,VALUE) \
347 fprintf ((FILE), "\t%s\t%#llx", VMS_UNALIGNED_DOUBLE_INT_ASM_OP, \
348 (unsigned long long) VALUE)
351 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
352 newline is produced. When flag_verbose_asm is asserted, we add commentary
353 at the end of the line, so we must avoid output of a newline here. */
354 #ifndef ASM_OUTPUT_DEBUG_STRING
355 #define ASM_OUTPUT_DEBUG_STRING(FILE,P) \
358 register int slen = strlen(P); \
359 register const char *p = (P); \
361 fprintf (FILE, "\t.ascii \""); \
362 for (i = 0; i < slen; i++) \
364 register int c = p[i]; \
365 if (c == '\"' || c == '\\') \
367 if (c >= ' ' && c < 0177) \
370 fprintf (FILE, "\\%o", c); \
372 fprintf (FILE, "\""); \
377 /* Convert a reference to the assembler name of a C-level name. This
378 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
379 a string rather than writing to a file. */
380 #ifndef ASM_NAME_TO_STRING
381 #define ASM_NAME_TO_STRING(STR, NAME) \
384 if ((NAME)[0] == '*') \
385 strcpy (STR, NAME+1); \
387 strcpy (STR, NAME); \
393 /* Output the debug header HEADER. Also output COMMENT if flag_verbose_asm is
394 set. Return the header size. Just return the size if DOSIZEONLY is
398 write_debug_header (DST_HEADER
*header
, const char *comment
, int dosizeonly
)
402 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
,
403 header
->dst__header_length
.dst_w_length
);
405 if (flag_verbose_asm
)
406 fprintf (asm_out_file
, "\t%s record length", ASM_COMMENT_START
);
407 fputc ('\n', asm_out_file
);
409 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
,
410 header
->dst__header_type
.dst_w_type
);
412 if (flag_verbose_asm
)
413 fprintf (asm_out_file
, "\t%s record type (%s)", ASM_COMMENT_START
,
416 fputc ('\n', asm_out_file
);
422 /* Output the address of SYMBOL. Also output COMMENT if flag_verbose_asm is
423 set. Return the address size. Just return the size if DOSIZEONLY is
427 write_debug_addr (const char *symbol
, const char *comment
, int dosizeonly
)
431 ASM_OUTPUT_DEBUG_ADDR (asm_out_file
, symbol
);
432 if (flag_verbose_asm
)
433 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
434 fputc ('\n', asm_out_file
);
440 /* Output the single byte DATA1. Also output COMMENT if flag_verbose_asm is
441 set. Return the data size. Just return the size if DOSIZEONLY is
445 write_debug_data1 (unsigned int data1
, const char *comment
, int dosizeonly
)
449 ASM_OUTPUT_DEBUG_DATA1 (asm_out_file
, data1
);
450 if (flag_verbose_asm
)
451 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
452 fputc ('\n', asm_out_file
);
458 /* Output the single word DATA2. Also output COMMENT if flag_verbose_asm is
459 set. Return the data size. Just return the size if DOSIZEONLY is
463 write_debug_data2 (unsigned int data2
, const char *comment
, int dosizeonly
)
467 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
, data2
);
468 if (flag_verbose_asm
)
469 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
470 fputc ('\n', asm_out_file
);
476 /* Output double word DATA4. Also output COMMENT if flag_verbose_asm is set.
477 Return the data size. Just return the size if DOSIZEONLY is nonzero. */
480 write_debug_data4 (unsigned long data4
, const char *comment
, int dosizeonly
)
484 ASM_OUTPUT_DEBUG_DATA4 (asm_out_file
, data4
);
485 if (flag_verbose_asm
)
486 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
487 fputc ('\n', asm_out_file
);
493 /* Output quad word DATA8. Also output COMMENT if flag_verbose_asm is set.
494 Return the data size. Just return the size if DOSIZEONLY is nonzero. */
497 write_debug_data8 (unsigned long long data8
, const char *comment
,
502 ASM_OUTPUT_DEBUG_DATA8 (asm_out_file
, data8
);
503 if (flag_verbose_asm
)
504 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
505 fputc ('\n', asm_out_file
);
511 /* Output the difference between LABEL1 and LABEL2. Also output COMMENT if
512 flag_verbose_asm is set. Return the data size. Just return the size if
513 DOSIZEONLY is nonzero. */
516 write_debug_delta4 (const char *label1
, const char *label2
,
517 const char *comment
, int dosizeonly
)
521 ASM_OUTPUT_DEBUG_DELTA4 (asm_out_file
, label1
, label2
);
522 if (flag_verbose_asm
)
523 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
524 fputc ('\n', asm_out_file
);
530 /* Output a character string STRING. Also write COMMENT if flag_verbose_asm is
531 set. Return the string length. Just return the length if DOSIZEONLY is
535 write_debug_string (const char *string
, const char *comment
, int dosizeonly
)
539 ASM_OUTPUT_DEBUG_STRING (asm_out_file
, string
);
540 if (flag_verbose_asm
)
541 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
542 fputc ('\n', asm_out_file
);
545 return strlen (string
);
548 /* Output a module begin header and return the header size. Just return the
549 size if DOSIZEONLY is nonzero. */
552 write_modbeg (int dosizeonly
)
554 DST_MODULE_BEGIN modbeg
;
557 char *module_name
, *m
;
562 /* Assumes primary filename has Unix syntax file spec. */
563 module_name
= xstrdup (lbasename (primary_filename
));
565 m
= strrchr (module_name
, '.');
569 modnamelen
= strlen (module_name
);
570 for (i
= 0; i
< modnamelen
; i
++)
571 module_name
[i
] = TOUPPER (module_name
[i
]);
573 prodnamelen
= strlen (module_producer
);
575 modbeg
.dst_a_modbeg_header
.dst__header_length
.dst_w_length
576 = DST_K_MODBEG_SIZE
+ modnamelen
+ DST_K_MB_TRLR_SIZE
+ prodnamelen
- 1;
577 modbeg
.dst_a_modbeg_header
.dst__header_type
.dst_w_type
= DST_K_MODBEG
;
578 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_hide
= 0;
579 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_version
= 1;
580 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_unused
= 0;
581 modbeg
.dst_b_modbeg_unused
= 0;
582 modbeg
.dst_l_modbeg_language
= (DST_LANGUAGE
) module_language
;
583 modbeg
.dst_w_version_major
= DST_K_VERSION_MAJOR
;
584 modbeg
.dst_w_version_minor
= DST_K_VERSION_MINOR
;
585 modbeg
.dst_b_modbeg_name
= strlen (module_name
);
587 mb_trlr
.dst_b_compiler
= strlen (module_producer
);
589 totsize
+= write_debug_header (&modbeg
.dst_a_modbeg_header
,
590 "modbeg", dosizeonly
);
591 totsize
+= write_debug_data1 (*((char *) &modbeg
.dst_b_modbeg_flags
),
592 "flags", dosizeonly
);
593 totsize
+= write_debug_data1 (modbeg
.dst_b_modbeg_unused
,
594 "unused", dosizeonly
);
595 totsize
+= write_debug_data4 (modbeg
.dst_l_modbeg_language
,
596 "language", dosizeonly
);
597 totsize
+= write_debug_data2 (modbeg
.dst_w_version_major
,
598 "DST major version", dosizeonly
);
599 totsize
+= write_debug_data2 (modbeg
.dst_w_version_minor
,
600 "DST minor version", dosizeonly
);
601 totsize
+= write_debug_data1 (modbeg
.dst_b_modbeg_name
,
602 "length of module name", dosizeonly
);
603 totsize
+= write_debug_string (module_name
, "module name", dosizeonly
);
604 totsize
+= write_debug_data1 (mb_trlr
.dst_b_compiler
,
605 "length of compiler name", dosizeonly
);
606 totsize
+= write_debug_string (module_producer
, "compiler name", dosizeonly
);
611 /* Output a module end trailer and return the trailer size. Just return
612 the size if DOSIZEONLY is nonzero. */
615 write_modend (int dosizeonly
)
617 DST_MODULE_END modend
;
620 modend
.dst_a_modend_header
.dst__header_length
.dst_w_length
621 = DST_K_MODEND_SIZE
- 1;
622 modend
.dst_a_modend_header
.dst__header_type
.dst_w_type
= DST_K_MODEND
;
624 totsize
+= write_debug_header (&modend
.dst_a_modend_header
, "modend",
630 /* Output a routine begin header routine RTNNUM and return the header size.
631 Just return the size if DOSIZEONLY is nonzero. */
634 write_rtnbeg (int rtnnum
, int dosizeonly
)
640 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
641 DST_ROUTINE_BEGIN rtnbeg
;
644 rtnname
= VEC_index (char_p
, funcnam_table
, rtnnum
);
645 rtnnamelen
= strlen (rtnname
);
646 rtnentryname
= concat (rtnname
, "..en", NULL
);
648 if (!strcmp (rtnname
, "main"))
651 const char *go
= "TRANSFER$BREAK$GO";
653 /* This command isn't documented in DSTRECORDS, so it's made to
654 look like what DEC C does */
656 /* header size - 1st byte + flag byte + STO_LW size
657 + string count byte + string length */
658 header
.dst__header_length
.dst_w_length
659 = DST_K_DST_HEADER_SIZE
- 1 + 1 + 4 + 1 + strlen (go
);
660 header
.dst__header_type
.dst_w_type
= DST_K_TBG
;
662 totsize
+= write_debug_header (&header
, "transfer", dosizeonly
);
664 /* I think this is a flag byte, but I don't know what this flag means */
665 totsize
+= write_debug_data1 (0x1, "flags ???", dosizeonly
);
667 /* Routine Begin PD Address */
668 totsize
+= write_debug_addr (rtnname
, "main procedure descriptor",
670 totsize
+= write_debug_data1 (strlen (go
), "length of main_name",
672 totsize
+= write_debug_string (go
, "main name", dosizeonly
);
675 /* The header length never includes the length byte. */
676 rtnbeg
.dst_a_rtnbeg_header
.dst__header_length
.dst_w_length
677 = DST_K_RTNBEG_SIZE
+ rtnnamelen
- 1;
678 rtnbeg
.dst_a_rtnbeg_header
.dst__header_type
.dst_w_type
= DST_K_RTNBEG
;
679 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_unused
= 0;
680 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_unalloc
= 0;
681 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_prototype
= 0;
682 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_inlined
= 0;
683 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_no_call
= 1;
684 rtnbeg
.dst_b_rtnbeg_name
= rtnnamelen
;
686 totsize
+= write_debug_header (&rtnbeg
.dst_a_rtnbeg_header
, "rtnbeg",
688 totsize
+= write_debug_data1 (*((char *) &rtnbeg
.dst_b_rtnbeg_flags
),
689 "flags", dosizeonly
);
691 /* Routine Begin Address */
692 totsize
+= write_debug_addr (rtnentryname
, "routine entry name", dosizeonly
);
694 /* Routine Begin PD Address */
695 totsize
+= write_debug_addr (rtnname
, "routine procedure descriptor",
698 /* Routine Begin Name */
699 totsize
+= write_debug_data1 (rtnbeg
.dst_b_rtnbeg_name
,
700 "length of routine name", dosizeonly
);
702 totsize
+= write_debug_string (rtnname
, "routine name", dosizeonly
);
706 if (debug_info_level
> DINFO_LEVEL_TERSE
)
708 prolog
.dst_a_prolog_header
.dst__header_length
.dst_w_length
709 = DST_K_PROLOG_SIZE
- 1;
710 prolog
.dst_a_prolog_header
.dst__header_type
.dst_w_type
= DST_K_PROLOG
;
712 totsize
+= write_debug_header (&prolog
.dst_a_prolog_header
, "prolog",
715 ASM_GENERATE_INTERNAL_LABEL
716 (label
, FUNC_PROLOG_LABEL
,
717 VEC_index (unsigned, funcnum_table
, rtnnum
));
718 totsize
+= write_debug_addr (label
, "prolog breakpoint addr",
725 /* Output a routine end trailer for routine RTNNUM and return the header size.
726 Just return the size if DOSIZEONLY is nonzero. */
729 write_rtnend (int rtnnum
, int dosizeonly
)
731 DST_ROUTINE_END rtnend
;
732 char label1
[MAX_ARTIFICIAL_LABEL_BYTES
];
733 char label2
[MAX_ARTIFICIAL_LABEL_BYTES
];
738 rtnend
.dst_a_rtnend_header
.dst__header_length
.dst_w_length
739 = DST_K_RTNEND_SIZE
- 1;
740 rtnend
.dst_a_rtnend_header
.dst__header_type
.dst_w_type
= DST_K_RTNEND
;
741 rtnend
.dst_b_rtnend_unused
= 0;
742 rtnend
.dst_l_rtnend_size
= 0; /* Calculated below. */
744 totsize
+= write_debug_header (&rtnend
.dst_a_rtnend_header
, "rtnend",
746 totsize
+= write_debug_data1 (rtnend
.dst_b_rtnend_unused
, "unused",
749 ASM_GENERATE_INTERNAL_LABEL
750 (label1
, FUNC_BEGIN_LABEL
,
751 VEC_index (unsigned, funcnum_table
, rtnnum
));
752 ASM_GENERATE_INTERNAL_LABEL
753 (label2
, FUNC_END_LABEL
,
754 VEC_index (unsigned, funcnum_table
, rtnnum
));
755 totsize
+= write_debug_delta4 (label2
, label1
, "routine size", dosizeonly
);
760 #define K_DELTA_PC(I) \
761 ((I) < 128 ? -(I) : (I) < 65536 ? DST_K_DELTA_PC_W : DST_K_DELTA_PC_L)
763 #define K_SET_LINUM(I) \
764 ((I) < 256 ? DST_K_SET_LINUM_B \
765 : (I) < 65536 ? DST_K_SET_LINUM : DST_K_SET_LINUM_L)
767 #define K_INCR_LINUM(I) \
768 ((I) < 256 ? DST_K_INCR_LINUM \
769 : (I) < 65536 ? DST_K_INCR_LINUM_W : DST_K_INCR_LINUM_L)
771 /* Output the PC to line number correlations and return the size. Just return
772 the size if DOSIZEONLY is nonzero */
775 write_pclines (int dosizeonly
)
782 DST_LINE_NUM_HEADER line_num
;
783 DST_PCLINE_COMMANDS pcline
;
784 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
785 char lastlabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
789 max_line
= file_info_table
[1].max_line
;
790 file_info_table
[1].listing_line_start
= linestart
;
791 linestart
= linestart
+ ((max_line
/ 100000) + 1) * 100000;
793 for (i
= 2; i
< file_info_table_in_use
; i
++)
795 max_line
= file_info_table
[i
].max_line
;
796 file_info_table
[i
].listing_line_start
= linestart
;
797 linestart
= linestart
+ ((max_line
/ 10000) + 1) * 10000;
800 /* Set starting address to beginning of text section. */
801 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
= 8;
802 line_num
.dst_a_line_num_header
.dst__header_type
.dst_w_type
= DST_K_LINE_NUM
;
803 pcline
.dst_b_pcline_command
= DST_K_SET_ABS_PC
;
805 totsize
+= write_debug_header (&line_num
.dst_a_line_num_header
,
806 "line_num", dosizeonly
);
807 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
808 "line_num (SET ABS PC)", dosizeonly
);
814 ASM_OUTPUT_DEBUG_ADDR (asm_out_file
, TEXT_SECTION_ASM_OP
);
815 if (flag_verbose_asm
)
816 fprintf (asm_out_file
, "\t%s line_num", ASM_COMMENT_START
);
817 fputc ('\n', asm_out_file
);
820 fn
= line_info_table
[1].dst_file_num
;
821 ln
= (file_info_table
[fn
].listing_line_start
822 + line_info_table
[1].dst_line_num
);
823 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
= 4 + 4;
824 pcline
.dst_b_pcline_command
= DST_K_SET_LINUM_L
;
826 totsize
+= write_debug_header (&line_num
.dst_a_line_num_header
,
827 "line_num", dosizeonly
);
828 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
829 "line_num (SET LINUM LONG)", dosizeonly
);
831 sprintf (buff
, "line_num (%d)", ln
? ln
- 1 : 0);
832 totsize
+= write_debug_data4 (ln
? ln
- 1 : 0, buff
, dosizeonly
);
835 strcpy (lastlabel
, TEXT_SECTION_ASM_OP
);
836 for (i
= 1; i
< line_info_table_in_use
; i
++)
840 fn
= line_info_table
[i
].dst_file_num
;
841 ln
= (file_info_table
[fn
].listing_line_start
842 + line_info_table
[i
].dst_line_num
);
845 extrabytes
= 5; /* NUMBYTES (ln - lastln - 1) + 1; */
846 else if (ln
<= lastln
)
847 extrabytes
= 5; /* NUMBYTES (ln - 1) + 1; */
851 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
854 totsize
+= write_debug_header
855 (&line_num
.dst_a_line_num_header
, "line_num", dosizeonly
);
859 int lndif
= ln
- lastln
- 1;
861 /* K_INCR_LINUM (lndif); */
862 pcline
.dst_b_pcline_command
= DST_K_INCR_LINUM_L
;
864 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
865 "line_num (INCR LINUM LONG)",
868 sprintf (buff
, "line_num (%d)", lndif
);
869 totsize
+= write_debug_data4 (lndif
, buff
, dosizeonly
);
871 else if (ln
<= lastln
)
873 /* K_SET_LINUM (ln-1); */
874 pcline
.dst_b_pcline_command
= DST_K_SET_LINUM_L
;
876 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
877 "line_num (SET LINUM LONG)",
880 sprintf (buff
, "line_num (%d)", ln
- 1);
881 totsize
+= write_debug_data4 (ln
- 1, buff
, dosizeonly
);
884 pcline
.dst_b_pcline_command
= DST_K_DELTA_PC_L
;
886 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
887 "line_num (DELTA PC LONG)", dosizeonly
);
889 ASM_GENERATE_INTERNAL_LABEL (label
, LINE_CODE_LABEL
, i
);
890 totsize
+= write_debug_delta4 (label
, lastlabel
, "increment line_num",
894 strcpy (lastlabel
, label
);
900 /* Output a source correlation for file FILEID using information saved in
901 FILE_INFO_ENTRY and return the size. Just return the size if DOSIZEONLY is
905 write_srccorr (int fileid
, dst_file_info_entry file_info_entry
,
908 int src_command_size
;
909 int linesleft
= file_info_entry
.max_line
;
910 int linestart
= file_info_entry
.listing_line_start
;
911 int flen
= strlen (file_info_entry
.file_name
);
913 DST_SOURCE_CORR src_header
;
914 DST_SRC_COMMAND src_command
;
915 DST_SRC_COMMAND src_command_sf
;
916 DST_SRC_COMMAND src_command_sl
;
917 DST_SRC_COMMAND src_command_sr
;
918 DST_SRC_COMMAND src_command_dl
;
919 DST_SRC_CMDTRLR src_cmdtrlr
;
925 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
926 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 1 - 1;
927 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
929 src_command
.dst_b_src_command
= DST_K_SRC_FORMFEED
;
931 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
932 "source corr", dosizeonly
);
934 totsize
+= write_debug_data1 (src_command
.dst_b_src_command
,
935 "source_corr (SRC FORMFEED)",
940 = DST_K_SRC_COMMAND_SIZE
+ flen
+ DST_K_SRC_CMDTRLR_SIZE
;
941 src_command
.dst_b_src_command
= DST_K_SRC_DECLFILE
;
942 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_length
943 = src_command_size
- 2;
944 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_flags
= 0;
945 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_fileid
947 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_q_src_df_rms_cdt
948 = file_info_entry
.cdt
;
949 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_l_src_df_rms_ebk
950 = file_info_entry
.ebk
;
951 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_rms_ffb
952 = file_info_entry
.ffb
;
953 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_rms_rfo
954 = file_info_entry
.rfo
;
955 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_filename
958 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
959 = DST_K_SOURCE_CORR_HEADER_SIZE
+ src_command_size
- 1;
960 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
963 src_cmdtrlr
.dst_b_src_df_libmodname
= 0;
965 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
966 "source corr", dosizeonly
);
967 totsize
+= write_debug_data1 (src_command
.dst_b_src_command
,
968 "source_corr (DECL SRC FILE)", dosizeonly
);
969 totsize
+= write_debug_data1
970 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_length
,
971 "source_corr (length)", dosizeonly
);
973 totsize
+= write_debug_data1
974 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_flags
,
975 "source_corr (flags)", dosizeonly
);
977 totsize
+= write_debug_data2
978 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_fileid
,
979 "source_corr (fileid)", dosizeonly
);
981 totsize
+= write_debug_data8
982 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_q_src_df_rms_cdt
,
983 "source_corr (creation date)", dosizeonly
);
985 totsize
+= write_debug_data4
986 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_l_src_df_rms_ebk
,
987 "source_corr (EOF block number)", dosizeonly
);
989 totsize
+= write_debug_data2
990 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_rms_ffb
,
991 "source_corr (first free byte)", dosizeonly
);
993 totsize
+= write_debug_data1
994 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_rms_rfo
,
995 "source_corr (record and file organization)", dosizeonly
);
997 totsize
+= write_debug_data1
998 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_filename
,
999 "source_corr (filename length)", dosizeonly
);
1001 totsize
+= write_debug_string (remap_debug_filename (
1002 file_info_entry
.file_name
),
1003 "source file name", dosizeonly
);
1004 totsize
+= write_debug_data1 (src_cmdtrlr
.dst_b_src_df_libmodname
,
1005 "source_corr (libmodname)", dosizeonly
);
1007 src_command_sf
.dst_b_src_command
= DST_K_SRC_SETFILE
;
1008 src_command_sf
.dst_a_src_cmd_fields
.dst_w_src_unsword
= fileid
;
1010 src_command_sr
.dst_b_src_command
= DST_K_SRC_SETREC_W
;
1011 src_command_sr
.dst_a_src_cmd_fields
.dst_w_src_unsword
= 1;
1013 src_command_sl
.dst_b_src_command
= DST_K_SRC_SETLNUM_L
;
1014 src_command_sl
.dst_a_src_cmd_fields
.dst_l_src_unslong
= linestart
+ 1;
1016 src_command_dl
.dst_b_src_command
= DST_K_SRC_DEFLINES_W
;
1018 if (linesleft
> 65534)
1019 linesleft
= linesleft
- 65534, linestodo
= 65534;
1021 linestodo
= linesleft
, linesleft
= 0;
1023 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
= linestodo
;
1025 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1026 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 3 + 3 + 5 + 3 - 1;
1027 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1030 if (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
)
1032 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1033 "source corr", dosizeonly
);
1035 totsize
+= write_debug_data1 (src_command_sf
.dst_b_src_command
,
1036 "source_corr (src setfile)", dosizeonly
);
1038 totsize
+= write_debug_data2
1039 (src_command_sf
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1040 "source_corr (fileid)", dosizeonly
);
1042 totsize
+= write_debug_data1 (src_command_sr
.dst_b_src_command
,
1043 "source_corr (setrec)", dosizeonly
);
1045 totsize
+= write_debug_data2
1046 (src_command_sr
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1047 "source_corr (recnum)", dosizeonly
);
1049 totsize
+= write_debug_data1 (src_command_sl
.dst_b_src_command
,
1050 "source_corr (setlnum)", dosizeonly
);
1052 totsize
+= write_debug_data4
1053 (src_command_sl
.dst_a_src_cmd_fields
.dst_l_src_unslong
,
1054 "source_corr (linenum)", dosizeonly
);
1056 totsize
+= write_debug_data1 (src_command_dl
.dst_b_src_command
,
1057 "source_corr (deflines)", dosizeonly
);
1059 sprintf (buff
, "source_corr (%d)",
1060 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
);
1061 totsize
+= write_debug_data2
1062 (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1065 while (linesleft
> 0)
1067 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1068 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 3 - 1;
1069 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1071 src_command_dl
.dst_b_src_command
= DST_K_SRC_DEFLINES_W
;
1073 if (linesleft
> 65534)
1074 linesleft
= linesleft
- 65534, linestodo
= 65534;
1076 linestodo
= linesleft
, linesleft
= 0;
1078 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
= linestodo
;
1080 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1081 "source corr", dosizeonly
);
1082 totsize
+= write_debug_data1 (src_command_dl
.dst_b_src_command
,
1083 "source_corr (deflines)", dosizeonly
);
1084 sprintf (buff
, "source_corr (%d)",
1085 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
);
1086 totsize
+= write_debug_data2
1087 (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1095 /* Output all the source correlation entries and return the size. Just return
1096 the size if DOSIZEONLY is nonzero. */
1099 write_srccorrs (int dosizeonly
)
1104 for (i
= 1; i
< file_info_table_in_use
; i
++)
1105 totsize
+= write_srccorr (i
, file_info_table
[i
], dosizeonly
);
1110 /* Output a marker (i.e. a label) for the beginning of a function, before
1114 vmsdbgout_begin_prologue (unsigned int line
, const char *file
)
1116 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1118 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1119 (*dwarf2_debug_hooks
.begin_prologue
) (line
, file
);
1121 if (debug_info_level
> DINFO_LEVEL_NONE
)
1123 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
1124 current_function_funcdef_no
);
1125 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1129 /* Output a marker (i.e. a label) for the beginning of a function, after
1133 vmsdbgout_end_prologue (unsigned int line
, const char *file
)
1135 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1137 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1138 (*dwarf2_debug_hooks
.end_prologue
) (line
, file
);
1140 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1142 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_PROLOG_LABEL
,
1143 current_function_funcdef_no
);
1144 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1146 /* VMS PCA expects every PC range to correlate to some line and file. */
1147 vmsdbgout_write_source_line (line
, file
, 0, true);
1151 /* No output for VMS debug, but make obligatory call to Dwarf2 debug */
1154 vmsdbgout_end_function (unsigned int line
)
1156 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1157 (*dwarf2_debug_hooks
.end_function
) (line
);
1160 /* Output a marker (i.e. a label) for the beginning of the epilogue.
1161 This gets called *before* the epilogue code has been generated. */
1164 vmsdbgout_begin_epilogue (unsigned int line
, const char *file
)
1166 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1167 static int save_current_function_funcdef_no
= -1;
1169 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1170 (*dwarf2_debug_hooks
.begin_epilogue
) (line
, file
);
1172 if (debug_info_level
> DINFO_LEVEL_NONE
)
1174 if (save_current_function_funcdef_no
!= current_function_funcdef_no
)
1176 /* Output a label to mark the endpoint of the code generated for this
1178 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_EPILOG_LABEL
,
1179 current_function_funcdef_no
);
1181 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1183 save_current_function_funcdef_no
= current_function_funcdef_no
;
1185 /* VMS PCA expects every PC range to correlate to some line and
1187 vmsdbgout_write_source_line (line
, file
, 0, true);
1192 /* Output a marker (i.e. a label) for the absolute end of the generated code
1193 for a function definition. This gets called *after* the epilogue code has
1197 vmsdbgout_end_epilogue (unsigned int line
, const char *file
)
1199 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1201 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1202 (*dwarf2_debug_hooks
.end_epilogue
) (line
, file
);
1204 if (debug_info_level
> DINFO_LEVEL_NONE
)
1206 /* Output a label to mark the endpoint of the code generated for this
1208 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
,
1209 current_function_funcdef_no
);
1210 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1212 /* VMS PCA expects every PC range to correlate to some line and file. */
1213 vmsdbgout_write_source_line (line
, file
, 0, true);
1217 /* Output a marker (i.e. a label) for the beginning of the generated code for
1221 vmsdbgout_begin_block (register unsigned line
, register unsigned blocknum
)
1223 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1224 (*dwarf2_debug_hooks
.begin_block
) (line
, blocknum
);
1226 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1227 targetm
.asm_out
.internal_label (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
1230 /* Output a marker (i.e. a label) for the end of the generated code for a
1234 vmsdbgout_end_block (register unsigned line
, register unsigned blocknum
)
1236 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1237 (*dwarf2_debug_hooks
.end_block
) (line
, blocknum
);
1239 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1240 targetm
.asm_out
.internal_label (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
1243 /* Not implemented in VMS Debug. */
1246 vmsdbgout_ignore_block (const_tree block
)
1250 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1251 retval
= (*dwarf2_debug_hooks
.ignore_block
) (block
);
1256 /* Add an entry for function DECL into the funcnam_table. */
1259 vmsdbgout_begin_function (tree decl
)
1261 const char *name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1263 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1264 (*dwarf2_debug_hooks
.begin_function
) (decl
);
1266 /* Add the new entry to the end of the function name table. */
1267 VEC_safe_push (char_p
, heap
, funcnam_table
, xstrdup (name
));
1268 VEC_safe_push (unsigned, heap
, funcnum_table
,
1269 current_function_funcdef_no
);
1272 static char fullname_buff
[4096];
1274 /* Return the full file specification for FILENAME. The specification must be
1275 in VMS syntax in order to be processed by VMS Debug. */
1278 full_name (const char *filename
)
1281 FILE *fp
= fopen (filename
, "r");
1283 fgetname (fp
, fullname_buff
, 1);
1286 /* Unix paths really mess up VMS debug. Better to just output the
1288 strcpy (fullname_buff
, filename
);
1291 return fullname_buff
;
1294 /* Lookup a filename (in the list of filenames that we know about here in
1295 vmsdbgout.c) and return its "index". The index of each (known) filename is
1296 just a unique number which is associated with only that one filename. We
1297 need such numbers for the sake of generating labels and references
1298 to those files numbers. If the filename given as an argument is not
1299 found in our current list, add it to the list and assign it the next
1300 available unique index number. In order to speed up searches, we remember
1301 the index of the filename was looked up last. This handles the majority of
1305 lookup_filename (const char *file_name
)
1307 static unsigned int last_file_lookup_index
= 0;
1309 register unsigned i
;
1318 fnam
= full_name (file_name
);
1320 /* Check to see if the file name that was searched on the previous call
1321 matches this file name. If so, return the index. */
1322 if (last_file_lookup_index
!= 0)
1324 fn
= file_info_table
[last_file_lookup_index
].file_name
;
1325 if (strcmp (fnam
, fn
) == 0)
1326 return last_file_lookup_index
;
1329 /* Didn't match the previous lookup, search the table */
1330 for (i
= 1; i
< file_info_table_in_use
; ++i
)
1332 fn
= file_info_table
[i
].file_name
;
1333 if (strcmp (fnam
, fn
) == 0)
1335 last_file_lookup_index
= i
;
1340 /* Prepare to add a new table entry by making sure there is enough space in
1341 the table to do so. If not, expand the current table. */
1342 if (file_info_table_in_use
== file_info_table_allocated
)
1345 file_info_table_allocated
+= FILE_TABLE_INCREMENT
;
1346 file_info_table
= XRESIZEVEC (dst_file_info_entry
, file_info_table
,
1347 file_info_table_allocated
);
1350 if (vms_file_stats_name (file_name
, &cdt
, &siz
, &rfo
, &ver
) == 0)
1352 ebk
= siz
/ 512 + 1;
1353 ffb
= siz
- ((siz
/ 512) * 512);
1356 /* Add the new entry to the end of the filename table. */
1357 file_info_table
[file_info_table_in_use
].file_name
= xstrdup (fnam
);
1358 file_info_table
[file_info_table_in_use
].max_line
= 0;
1359 file_info_table
[file_info_table_in_use
].cdt
= cdt
;
1360 file_info_table
[file_info_table_in_use
].ebk
= ebk
;
1361 file_info_table
[file_info_table_in_use
].ffb
= ffb
;
1362 file_info_table
[file_info_table_in_use
].rfo
= rfo
;
1364 last_file_lookup_index
= file_info_table_in_use
++;
1365 return last_file_lookup_index
;
1368 /* Output a label to mark the beginning of a source code line entry
1369 and record information relating to this source line, in
1370 'line_info_table' for later output of the .debug_line section. */
1373 vmsdbgout_write_source_line (unsigned line
, const char *filename
,
1374 int discriminator
, bool is_stmt
)
1376 dst_line_info_ref line_info
;
1378 targetm
.asm_out
.internal_label (asm_out_file
, LINE_CODE_LABEL
,
1379 line_info_table_in_use
);
1381 /* Expand the line info table if necessary. */
1382 if (line_info_table_in_use
== line_info_table_allocated
)
1384 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
1385 line_info_table
= XRESIZEVEC (dst_line_info_entry
, line_info_table
,
1386 line_info_table_allocated
);
1389 /* Add the new entry at the end of the line_info_table. */
1390 line_info
= &line_info_table
[line_info_table_in_use
++];
1391 line_info
->dst_file_num
= lookup_filename (filename
);
1392 line_info
->dst_line_num
= line
;
1393 if (line
> file_info_table
[line_info
->dst_file_num
].max_line
)
1394 file_info_table
[line_info
->dst_file_num
].max_line
= line
;
1398 vmsdbgout_source_line (register unsigned line
, register const char *filename
,
1399 int discriminator
, bool is_stmt
)
1401 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1402 (*dwarf2_debug_hooks
.source_line
) (line
, filename
, discriminator
, is_stmt
);
1404 if (debug_info_level
>= DINFO_LEVEL_TERSE
)
1405 vmsdbgout_write_source_line (line
, filename
, discriminator
, is_stmt
);
1408 /* Record the beginning of a new source file, for later output.
1409 At present, unimplemented. */
1412 vmsdbgout_start_source_file (unsigned int lineno
, const char *filename
)
1414 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1415 (*dwarf2_debug_hooks
.start_source_file
) (lineno
, filename
);
1418 /* Record the end of a source file, for later output.
1419 At present, unimplemented. */
1422 vmsdbgout_end_source_file (unsigned int lineno ATTRIBUTE_UNUSED
)
1424 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1425 (*dwarf2_debug_hooks
.end_source_file
) (lineno
);
1428 /* Set up for Debug output at the start of compilation. */
1431 vmsdbgout_init (const char *filename
)
1433 const char *language_string
= lang_hooks
.name
;
1435 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1436 (*dwarf2_debug_hooks
.init
) (filename
);
1438 if (debug_info_level
== DINFO_LEVEL_NONE
)
1441 /* Remember the name of the primary input file. */
1442 primary_filename
= filename
;
1444 /* Allocate the initial hunk of the file_info_table. */
1445 file_info_table
= XCNEWVEC (dst_file_info_entry
, FILE_TABLE_INCREMENT
);
1446 file_info_table_allocated
= FILE_TABLE_INCREMENT
;
1447 /* Skip the first entry - file numbers begin at 1. */
1448 file_info_table_in_use
= 1;
1450 funcnam_table
= VEC_alloc (char_p
, heap
, FUNC_TABLE_INITIAL
);
1451 funcnum_table
= VEC_alloc (unsigned, heap
, FUNC_TABLE_INITIAL
);
1453 /* Allocate the initial hunk of the line_info_table. */
1454 line_info_table
= XCNEWVEC (dst_line_info_entry
, LINE_INFO_TABLE_INCREMENT
);
1455 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
1456 /* zero-th entry is allocated, but unused */
1457 line_info_table_in_use
= 1;
1459 lookup_filename (primary_filename
);
1461 if (!strcmp (language_string
, "GNU C"))
1462 module_language
= DST_K_C
;
1463 else if (!strcmp (language_string
, "GNU C++"))
1464 module_language
= DST_K_CXX
;
1465 else if (!strcmp (language_string
, "GNU Ada"))
1466 module_language
= DST_K_ADA
;
1467 else if (!strcmp (language_string
, "GNU F77"))
1468 module_language
= DST_K_FORTRAN
;
1470 module_language
= DST_K_UNKNOWN
;
1472 module_producer
= concat (language_string
, " ", version_string
, NULL
);
1474 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
1478 /* Not implemented in VMS Debug. */
1481 vmsdbgout_assembly_start (void)
1483 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1484 (*dwarf2_debug_hooks
.assembly_start
) ();
1487 /* Not implemented in VMS Debug. */
1490 vmsdbgout_define (unsigned int lineno
, const char *buffer
)
1492 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1493 (*dwarf2_debug_hooks
.define
) (lineno
, buffer
);
1496 /* Not implemented in VMS Debug. */
1499 vmsdbgout_undef (unsigned int lineno
, const char *buffer
)
1501 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1502 (*dwarf2_debug_hooks
.undef
) (lineno
, buffer
);
1505 /* Not implemented in VMS Debug. */
1508 vmsdbgout_decl (tree decl
)
1510 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1511 (*dwarf2_debug_hooks
.function_decl
) (decl
);
1514 /* Not implemented in VMS Debug. */
1517 vmsdbgout_global_decl (tree decl
)
1519 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1520 (*dwarf2_debug_hooks
.global_decl
) (decl
);
1523 /* Not implemented in VMS Debug. */
1526 vmsdbgout_type_decl (tree decl
, int local
)
1528 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1529 (*dwarf2_debug_hooks
.type_decl
) (decl
, local
);
1532 /* Not implemented in VMS Debug. */
1535 vmsdbgout_abstract_function (tree decl
)
1537 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1538 (*dwarf2_debug_hooks
.outlining_inline_function
) (decl
);
1541 /* Output stuff that Debug requires at the end of every file and generate the
1542 VMS Debug debugging info. */
1545 vmsdbgout_finish (const char *filename ATTRIBUTE_UNUSED
)
1547 unsigned int i
, ifunc
;
1550 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1551 (*dwarf2_debug_hooks
.finish
) (filename
);
1553 if (debug_info_level
== DINFO_LEVEL_NONE
)
1556 /* Output a terminator label for the .text section. */
1557 switch_to_section (text_section
);
1558 targetm
.asm_out
.internal_label (asm_out_file
, TEXT_END_LABEL
, 0);
1560 /* Output debugging information.
1561 Warning! Do not change the name of the .vmsdebug section without
1562 changing it in the assembler also. */
1563 switch_to_section (get_named_section (NULL
, ".vmsdebug", 0));
1564 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
1566 totsize
= write_modbeg (1);
1567 FOR_EACH_VEC_ELT (unsigned, funcnum_table
, i
, ifunc
)
1569 totsize
+= write_rtnbeg (i
, 1);
1570 totsize
+= write_rtnend (i
, 1);
1572 totsize
+= write_pclines (1);
1575 FOR_EACH_VEC_ELT (unsigned, funcnum_table
, i
, ifunc
)
1577 write_rtnbeg (i
, 0);
1578 write_rtnend (i
, 0);
1582 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1584 totsize
= write_srccorrs (1);
1588 totsize
= write_modend (1);
1592 /* Need for both Dwarf2 on IVMS and VMS Debug on AVMS */
1595 #define __NEW_STARLET 1
1596 #include <vms/rms.h>
1597 #include <vms/atrdef.h>
1598 #include <vms/fibdef.h>
1599 #include <vms/stsdef.h>
1600 #include <vms/iodef.h>
1601 #include <vms/fatdef.h>
1602 #include <vms/descrip.h>
1603 #include <unixlib.h>
1607 /* descrip.h doesn't have everything ... */
1608 typedef struct fibdef
* __fibdef_ptr32
__attribute__ (( mode (SI
) ));
1609 struct dsc$descriptor_fib
1611 unsigned int fib$l_len
;
1612 __fibdef_ptr32 fib$l_addr
;
1615 /* I/O Status Block. */
1618 unsigned short status
, count
;
1619 unsigned int devdep
;
1622 static char *tryfile
;
1624 /* Variable length string. */
1628 char string
[NAM$C_MAXRSS
+1];
1631 static char filename_buff
[MAXPATH
];
1632 static char vms_filespec
[MAXPATH
];
1634 /* Callback function for filespec style conversion. */
1637 translate_unix (char *name
, int type ATTRIBUTE_UNUSED
)
1639 strncpy (filename_buff
, name
, MAXPATH
);
1640 filename_buff
[MAXPATH
- 1] = (char) 0;
1644 /* Wrapper for DECC function that converts a Unix filespec
1645 to VMS style filespec. */
1648 to_vms_file_spec (char *filespec
)
1650 strncpy (vms_filespec
, "", MAXPATH
);
1651 decc$
to_vms (filespec
, translate_unix
, 1, 1);
1652 strncpy (vms_filespec
, filename_buff
, MAXPATH
);
1654 vms_filespec
[MAXPATH
- 1] = (char) 0;
1656 return vms_filespec
;
1660 #define VMS_EPOCH_OFFSET 35067168000000000LL
1661 #define VMS_GRANULARITY_FACTOR 10000000
1664 /* Return VMS file date, size, format, version given a name. */
1667 vms_file_stats_name (const char *filename
, long long *cdt
, long *siz
, char *rfo
,
1674 unsigned long long create
;
1676 char ascnamebuff
[256];
1680 { ATR$S_CREDATE
, ATR$C_CREDATE
, &create
},
1681 { ATR$S_RECATTR
, ATR$C_RECATTR
, &recattr
},
1682 { ATR$S_ASCNAME
, ATR$C_ASCNAME
, &ascnamebuff
},
1687 struct dsc$descriptor_fib fibdsc
= {sizeof (fib
), (void *) &fib
};
1692 unsigned short chan
;
1694 struct vstring file
;
1695 struct dsc$descriptor_s filedsc
1696 = {NAM$C_MAXRSS
, DSC$K_DTYPE_T
, DSC$K_CLASS_S
, (void *) file
.string
};
1697 struct vstring device
;
1698 struct dsc$descriptor_s devicedsc
1699 = {NAM$C_MAXRSS
, DSC$K_DTYPE_T
, DSC$K_CLASS_S
, (void *) device
.string
};
1700 struct vstring result
;
1701 struct dsc$descriptor_s resultdsc
1702 = {NAM$C_MAXRSS
, DSC$K_DTYPE_VT
, DSC$K_CLASS_VS
, (void *) result
.string
};
1704 if (strcmp (filename
, "<internal>") == 0
1705 || strcmp (filename
, "<built-in>") == 0)
1722 tryfile
= to_vms_file_spec (filename
);
1724 /* Allocate and initialize a FAB and NAM structures. */
1728 nam
.nam$l_esa
= file
.string
;
1729 nam
.nam$b_ess
= NAM$C_MAXRSS
;
1730 nam
.nam$l_rsa
= result
.string
;
1731 nam
.nam$b_rss
= NAM$C_MAXRSS
;
1732 fab
.fab$l_fna
= tryfile
;
1733 fab
.fab$b_fns
= strlen (tryfile
);
1734 fab
.fab$l_nam
= &nam
;
1736 /* Validate filespec syntax and device existence. */
1737 status
= SYS$
PARSE (&fab
, 0, 0);
1738 if ((status
& 1) != 1)
1741 file
.string
[nam
.nam$b_esl
] = 0;
1743 /* Find matching filespec. */
1744 status
= SYS$
SEARCH (&fab
, 0, 0);
1745 if ((status
& 1) != 1)
1748 file
.string
[nam
.nam$b_esl
] = 0;
1749 result
.string
[result
.length
=nam
.nam$b_rsl
] = 0;
1751 /* Get the device name and assign an IO channel. */
1752 strncpy (device
.string
, nam
.nam$l_dev
, nam
.nam$b_dev
);
1753 devicedsc
.dsc$w_length
= nam
.nam$b_dev
;
1755 status
= SYS$
ASSIGN (&devicedsc
, &chan
, 0, 0, 0);
1756 if ((status
& 1) != 1)
1759 /* Initialize the FIB and fill in the directory id field. */
1760 memset (&fib
, 0, sizeof (fib
));
1761 fib
.fib$w_did
[0] = nam
.nam$w_did
[0];
1762 fib
.fib$w_did
[1] = nam
.nam$w_did
[1];
1763 fib
.fib$w_did
[2] = nam
.nam$w_did
[2];
1764 fib
.fib$l_acctl
= 0;
1766 strcpy (file
.string
, (strrchr (result
.string
, ']') + 1));
1767 filedsc
.dsc$w_length
= strlen (file
.string
);
1768 result
.string
[result
.length
= 0] = 0;
1770 /* Open and close the file to fill in the attributes. */
1772 = SYS$
QIOW (0, chan
, IO$_ACCESS
|IO$M_ACCESS
, &iosb
, 0, 0,
1773 &fibdsc
, &filedsc
, &result
.length
, &resultdsc
, &atrlst
, 0);
1774 if ((status
& 1) != 1)
1776 if ((iosb
.status
& 1) != 1)
1779 result
.string
[result
.length
] = 0;
1780 status
= SYS$
QIOW (0, chan
, IO$_DEACCESS
, &iosb
, 0, 0, &fibdsc
, 0, 0, 0,
1782 if ((status
& 1) != 1)
1784 if ((iosb
.status
& 1) != 1)
1787 /* Deassign the channel and exit. */
1788 status
= SYS$
DASSGN (chan
);
1789 if ((status
& 1) != 1)
1792 if (cdt
) *cdt
= create
;
1793 if (siz
) *siz
= (512 * 65536 * recattr
.fat$w_efblkh
) +
1794 (512 * (recattr
.fat$w_efblkl
- 1)) +
1795 recattr
.fat$w_ffbyte
;
1796 if (rfo
) *rfo
= recattr
.fat$v_rtype
;
1797 if (ver
) *ver
= strtol (strrchr (ascnamebuff
, ';')+1, 0, 10);
1803 if ((stat (filename
, &buff
)) != 0)
1807 *cdt
= (long long) (buff
.st_mtime
* VMS_GRANULARITY_FACTOR
)
1811 *siz
= buff
.st_size
;
1814 *rfo
= 2; /* Stream LF format */