1 /* Output VMS debug format symbol table information from the GNU C compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 Contributed by Douglas B. Rupp (rupp@gnat.com).
6 This file is part of GNU CC.
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 2, 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 COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #ifdef VMS_DEBUGGING_INFO
33 #include "langhooks.h"
35 /* Difference in seconds between the VMS Epoch and the Unix Epoch */
36 static const long long vms_epoch_offset
= 3506716800ll;
38 /* NOTE: In the comments in this file, many references are made to "Debug
39 Symbol Table". This term is abbreviated as `DST' throughout the remainder
42 typedef struct dst_line_info_struct
*dst_line_info_ref
;
44 /* Each entry in the line_info_table maintains the file and
45 line number associated with the label generated for that
46 entry. The label gives the PC value associated with
47 the line number entry. */
48 typedef struct dst_line_info_struct
50 unsigned long dst_file_num
;
51 unsigned long dst_line_num
;
55 typedef struct dst_file_info_struct
*dst_file_info_ref
;
57 typedef struct dst_file_info_struct
60 unsigned int max_line
;
61 unsigned int listing_line_start
;
70 /* How to start an assembler comment. */
71 #ifndef ASM_COMMENT_START
72 #define ASM_COMMENT_START ";#"
75 /* Maximum size (in bytes) of an artificially generated label. */
76 #define MAX_ARTIFICIAL_LABEL_BYTES 30
78 /* Make sure we know the sizes of the various types debug can describe. These
79 are only defaults. If the sizes are different for your target, you should
80 override these values by defining the appropriate symbols in your tm.h
83 #define PTR_SIZE 4 /* Must be 32 bits for VMS debug info */
86 /* Pointer to an structure of filenames referenced by this compilation unit. */
87 static dst_file_info_ref file_info_table
;
89 /* Total number of entries in the table (i.e. array) pointed to by
90 `file_info_table'. This is the *total* and includes both used and unused
92 static unsigned int file_info_table_allocated
;
94 /* Number of entries in the file_info_table which are actually in use. */
95 static unsigned int file_info_table_in_use
;
97 /* Size (in elements) of increments by which we may expand the filename
99 #define FILE_TABLE_INCREMENT 64
101 static char **func_table
;
102 static unsigned int func_table_allocated
;
103 static unsigned int func_table_in_use
;
104 #define FUNC_TABLE_INCREMENT 256
106 /* Local pointer to the name of the main input file. Initialized in
108 static const char *primary_filename
;
110 static char *module_producer
;
111 static unsigned int module_language
;
113 /* A pointer to the base of a table that contains line information
114 for each source code line in .text in the compilation unit. */
115 static dst_line_info_ref line_info_table
;
117 /* Number of elements currently allocated for line_info_table. */
118 static unsigned int line_info_table_allocated
;
120 /* Number of elements in line_info_table currently in use. */
121 static unsigned int line_info_table_in_use
;
123 /* Size (in elements) of increments by which we may expand line_info_table. */
124 #define LINE_INFO_TABLE_INCREMENT 1024
126 /* Forward declarations for functions defined in this file. */
127 static char *full_name
PARAMS ((const char *));
128 static unsigned int lookup_filename
PARAMS ((const char *));
129 static void addr_const_to_string
PARAMS ((char *, rtx
));
130 static int write_debug_header
PARAMS ((DST_HEADER
*, const char *, int));
131 static int write_debug_addr
PARAMS ((char *, const char *, int));
132 static int write_debug_data1
PARAMS ((unsigned int, const char *, int));
133 static int write_debug_data2
PARAMS ((unsigned int, const char *, int));
134 static int write_debug_data4
PARAMS ((unsigned long, const char *, int));
135 static int write_debug_data8
PARAMS ((unsigned long long, const char *,
137 static int write_debug_delta4
PARAMS ((char *, char *, const char *, int));
138 static int write_debug_string
PARAMS ((char *, const char *, int));
139 static int write_modbeg
PARAMS ((int));
140 static int write_modend
PARAMS ((int));
141 static int write_rtnbeg
PARAMS ((int, int));
142 static int write_rtnend
PARAMS ((int, int));
143 static int write_pclines
PARAMS ((int));
144 static int write_srccorr
PARAMS ((int, dst_file_info_entry
, int));
145 static int write_srccorrs
PARAMS ((int));
147 static void vmsdbgout_init
PARAMS ((const char *));
148 static void vmsdbgout_finish
PARAMS ((const char *));
149 static void vmsdbgout_define
PARAMS ((unsigned int, const char *));
150 static void vmsdbgout_undef
PARAMS ((unsigned int, const char *));
151 static void vmsdbgout_start_source_file
PARAMS ((unsigned int, const char *));
152 static void vmsdbgout_end_source_file
PARAMS ((unsigned int));
153 static void vmsdbgout_begin_block
PARAMS ((unsigned int, unsigned int));
154 static void vmsdbgout_end_block
PARAMS ((unsigned int, unsigned int));
155 static bool vmsdbgout_ignore_block
PARAMS ((tree
));
156 static void vmsdbgout_source_line
PARAMS ((unsigned int, const char *));
157 static void vmsdbgout_begin_prologue
PARAMS ((unsigned int, const char *));
158 static void vmsdbgout_end_epilogue
PARAMS ((void));
159 static void vmsdbgout_begin_function
PARAMS ((tree
));
160 static void vmsdbgout_decl
PARAMS ((tree
));
161 static void vmsdbgout_global_decl
PARAMS ((tree
));
162 static void vmsdbgout_abstract_function
PARAMS ((tree
));
164 /* The debug hooks structure. */
166 const struct gcc_debug_hooks vmsdbg_debug_hooks
171 vmsdbgout_start_source_file
,
172 vmsdbgout_end_source_file
,
173 vmsdbgout_begin_block
,
175 vmsdbgout_ignore_block
,
176 vmsdbgout_source_line
,
177 vmsdbgout_begin_prologue
,
178 debug_nothing_int
, /* end_prologue */
179 vmsdbgout_end_epilogue
, /* end_epilogue */
180 vmsdbgout_begin_function
, /* begin_function */
181 debug_nothing_int
, /* end_function */
183 vmsdbgout_global_decl
,
184 debug_nothing_tree
, /* deferred_inline_function */
185 vmsdbgout_abstract_function
,
186 debug_nothing_rtx
/* label */
189 /* Definitions of defaults for assembler-dependent names of various
190 pseudo-ops and section names.
191 Theses may be overridden in the tm.h file (if necessary) for a particular
193 #ifdef UNALIGNED_SHORT_ASM_OP
194 #undef UNALIGNED_SHORT_ASM_OP
196 #define UNALIGNED_SHORT_ASM_OP ".word"
198 #ifdef UNALIGNED_INT_ASM_OP
199 #undef UNALIGNED_INT_ASM_OP
201 #define UNALIGNED_INT_ASM_OP ".long"
203 #ifdef UNALIGNED_LONG_ASM_OP
204 #undef UNALIGNED_LONG_ASM_OP
206 #define UNALIGNED_LONG_ASM_OP ".long"
208 #ifdef UNALIGNED_DOUBLE_INT_ASM_OP
209 #undef UNALIGNED_DOUBLE_INT_ASM_OP
211 #define UNALIGNED_DOUBLE_INT_ASM_OP ".quad"
216 #define ASM_BYTE_OP ".byte"
218 #define NUMBYTES(I) ((I) < 256 ? 1 : (I) < 65536 ? 2 : 4)
220 #define NUMBYTES0(I) ((I) < 128 ? 0 : (I) < 65536 ? 2 : 4)
222 #ifndef UNALIGNED_PTR_ASM_OP
223 #define UNALIGNED_PTR_ASM_OP \
224 (PTR_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
227 #ifndef UNALIGNED_OFFSET_ASM_OP
228 #define UNALIGNED_OFFSET_ASM_OP(OFFSET) \
229 (NUMBYTES(OFFSET) == 4 \
230 ? UNALIGNED_LONG_ASM_OP \
231 : (NUMBYTES(OFFSET) == 2 ? UNALIGNED_SHORT_ASM_OP : ASM_BYTE_OP))
234 /* Definitions of defaults for formats and names of various special
235 (artificial) labels which may be generated within this file (when the -g
236 options is used and VMS_DEBUGGING_INFO is in effect. If necessary, these
237 may be overridden from within the tm.h file, but typically, overriding these
238 defaults is unnecessary. */
240 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
242 #ifndef TEXT_END_LABEL
243 #define TEXT_END_LABEL "Lvetext"
245 #ifndef FUNC_BEGIN_LABEL
246 #define FUNC_BEGIN_LABEL "LVFB"
248 #ifndef FUNC_PROLOG_LABEL
249 #define FUNC_PROLOG_LABEL "LVFP"
251 #ifndef FUNC_END_LABEL
252 #define FUNC_END_LABEL "LVFE"
254 #ifndef BLOCK_BEGIN_LABEL
255 #define BLOCK_BEGIN_LABEL "LVBB"
257 #ifndef BLOCK_END_LABEL
258 #define BLOCK_END_LABEL "LVBE"
260 #ifndef LINE_CODE_LABEL
261 #define LINE_CODE_LABEL "LVM"
264 #ifndef ASM_OUTPUT_DEBUG_DELTA2
265 #define ASM_OUTPUT_DEBUG_DELTA2(FILE,LABEL1,LABEL2) \
268 fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
269 assemble_name (FILE, LABEL1); \
270 fprintf (FILE, "-"); \
271 assemble_name (FILE, LABEL2); \
276 #ifndef ASM_OUTPUT_DEBUG_DELTA4
277 #define ASM_OUTPUT_DEBUG_DELTA4(FILE,LABEL1,LABEL2) \
280 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
281 assemble_name (FILE, LABEL1); \
282 fprintf (FILE, "-"); \
283 assemble_name (FILE, LABEL2); \
288 #ifndef ASM_OUTPUT_DEBUG_ADDR_DELTA
289 #define ASM_OUTPUT_DEBUG_ADDR_DELTA(FILE,LABEL1,LABEL2) \
292 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
293 assemble_name (FILE, LABEL1); \
294 fprintf (FILE, "-"); \
295 assemble_name (FILE, LABEL2); \
300 #ifndef ASM_OUTPUT_DEBUG_ADDR
301 #define ASM_OUTPUT_DEBUG_ADDR(FILE,LABEL) \
304 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
305 assemble_name (FILE, LABEL); \
310 #ifndef ASM_OUTPUT_DEBUG_ADDR_CONST
311 #define ASM_OUTPUT_DEBUG_ADDR_CONST(FILE,ADDR) \
312 fprintf ((FILE), "\t%s\t%s", UNALIGNED_PTR_ASM_OP, (ADDR))
315 #ifndef ASM_OUTPUT_DEBUG_DATA1
316 #define ASM_OUTPUT_DEBUG_DATA1(FILE,VALUE) \
317 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned char) VALUE)
320 #ifndef ASM_OUTPUT_DEBUG_DATA2
321 #define ASM_OUTPUT_DEBUG_DATA2(FILE,VALUE) \
322 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, \
323 (unsigned short) VALUE)
326 #ifndef ASM_OUTPUT_DEBUG_DATA4
327 #define ASM_OUTPUT_DEBUG_DATA4(FILE,VALUE) \
328 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_INT_ASM_OP, (unsigned long) VALUE)
331 #ifndef ASM_OUTPUT_DEBUG_DATA
332 #define ASM_OUTPUT_DEBUG_DATA(FILE,VALUE) \
333 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP(VALUE), VALUE)
336 #ifndef ASM_OUTPUT_DEBUG_ADDR_DATA
337 #define ASM_OUTPUT_DEBUG_ADDR_DATA(FILE,VALUE) \
338 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_PTR_ASM_OP, \
339 (unsigned long) VALUE)
342 #ifndef ASM_OUTPUT_DEBUG_DATA8
343 #define ASM_OUTPUT_DEBUG_DATA8(FILE,VALUE) \
344 fprintf ((FILE), "\t%s\t0x%llx", UNALIGNED_DOUBLE_INT_ASM_OP, \
345 (unsigned long long) VALUE)
348 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
349 newline is produced. When flag_verbose_asm is asserted, we add commnetary
350 at the end of the line, so we must avoid output of a newline here. */
351 #ifndef ASM_OUTPUT_DEBUG_STRING
352 #define ASM_OUTPUT_DEBUG_STRING(FILE,P) \
355 register int slen = strlen(P); \
356 register char *p = (P); \
358 fprintf (FILE, "\t.ascii \""); \
359 for (i = 0; i < slen; i++) \
361 register int c = p[i]; \
362 if (c == '\"' || c == '\\') \
364 if (c >= ' ' && c < 0177) \
367 fprintf (FILE, "\\%o", c); \
369 fprintf (FILE, "\""); \
374 /* Convert a reference to the assembler name of a C-level name. This
375 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
376 a string rather than writing to a file. */
377 #ifndef ASM_NAME_TO_STRING
378 #define ASM_NAME_TO_STRING(STR, NAME) \
381 if ((NAME)[0] == '*') \
382 strcpy (STR, NAME+1); \
384 strcpy (STR, NAME); \
390 /* General utility functions. */
392 /* Convert an integer constant expression into assembler syntax. Addition and
393 subtraction are the only arithmetic that may appear in these expressions.
394 This is an adaptation of output_addr_const in final.c. Here, the target
395 of the conversion is a string buffer. We can't use output_addr_const
396 directly, because it writes to a file. */
399 addr_const_to_string (str
, x
)
408 switch (GET_CODE (x
))
418 ASM_NAME_TO_STRING (buf1
, XSTR (x
, 0));
423 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (XEXP (x
, 0)));
424 ASM_NAME_TO_STRING (buf2
, buf1
);
429 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (x
));
430 ASM_NAME_TO_STRING (buf2
, buf1
);
435 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
440 /* This used to output parentheses around the expression, but that does
441 not work on the 386 (either ATT or BSD assembler). */
442 addr_const_to_string (buf1
, XEXP (x
, 0));
447 if (GET_MODE (x
) == VOIDmode
)
449 /* We can use %d if the number is one word and positive. */
450 if (CONST_DOUBLE_HIGH (x
))
451 sprintf (buf1
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
452 CONST_DOUBLE_HIGH (x
), CONST_DOUBLE_LOW (x
));
453 else if (CONST_DOUBLE_LOW (x
) < 0)
454 sprintf (buf1
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
456 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
,
457 CONST_DOUBLE_LOW (x
));
461 /* We can't handle floating point constants; PRINT_OPERAND must
463 output_operand_lossage ("floating constant misused");
467 /* Some assemblers need integer constants to appear last (eg masm). */
468 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
470 addr_const_to_string (buf1
, XEXP (x
, 1));
472 if (INTVAL (XEXP (x
, 0)) >= 0)
474 addr_const_to_string (buf1
, XEXP (x
, 0));
479 addr_const_to_string (buf1
, XEXP (x
, 0));
481 if (INTVAL (XEXP (x
, 1)) >= 0)
483 addr_const_to_string (buf1
, XEXP (x
, 1));
489 /* Avoid outputting things like x-x or x+5-x, since some assemblers
490 can't handle that. */
491 x
= simplify_subtraction (x
);
492 if (GET_CODE (x
) != MINUS
)
495 addr_const_to_string (buf1
, XEXP (x
, 0));
498 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
499 && INTVAL (XEXP (x
, 1)) < 0)
502 addr_const_to_string (buf1
, XEXP (x
, 1));
508 addr_const_to_string (buf1
, XEXP (x
, 1));
515 addr_const_to_string (buf1
, XEXP (x
, 0));
520 output_operand_lossage ("invalid expression as operand");
524 /* Output the debug header HEADER. Also output COMMENT if flag_verbose_asm is
525 set. Return the header size. Just return the size if DOSIZEONLY is
529 write_debug_header (header
, comment
, dosizeonly
)
536 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
,
537 header
->dst__header_length
.dst_w_length
);
539 if (flag_verbose_asm
)
540 fprintf (asm_out_file
, "\t%s record length", ASM_COMMENT_START
);
541 fputc ('\n', asm_out_file
);
543 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
,
544 header
->dst__header_type
.dst_w_type
);
546 if (flag_verbose_asm
)
547 fprintf (asm_out_file
, "\t%s record type (%s)", ASM_COMMENT_START
,
550 fputc ('\n', asm_out_file
);
556 /* Output the address of SYMBOL. Also output COMMENT if flag_verbose_asm is
557 set. Return the address size. Just return the size if DOSIZEONLY is
561 write_debug_addr (symbol
, comment
, dosizeonly
)
568 ASM_OUTPUT_DEBUG_ADDR (asm_out_file
, symbol
);
569 if (flag_verbose_asm
)
570 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
571 fputc ('\n', asm_out_file
);
577 /* Output the single byte DATA1. Also output COMMENT if flag_verbose_asm is
578 set. Return the data size. Just return the size if DOSIZEONLY is
582 write_debug_data1 (data1
, comment
, dosizeonly
)
589 ASM_OUTPUT_DEBUG_DATA1 (asm_out_file
, data1
);
590 if (flag_verbose_asm
)
591 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
592 fputc ('\n', asm_out_file
);
598 /* Output the single word DATA2. Also output COMMENT if flag_verbose_asm is
599 set. Return the data size. Just return the size if DOSIZEONLY is
603 write_debug_data2 (data2
, comment
, dosizeonly
)
610 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file
, data2
);
611 if (flag_verbose_asm
)
612 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
613 fputc ('\n', asm_out_file
);
619 /* Output double word DATA4. Also output COMMENT if flag_verbose_asm is set.
620 Return the data size. Just return the size if DOSIZEONLY is non-zero. */
623 write_debug_data4 (data4
, comment
, dosizeonly
)
630 ASM_OUTPUT_DEBUG_DATA4 (asm_out_file
, data4
);
631 if (flag_verbose_asm
)
632 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
633 fputc ('\n', asm_out_file
);
639 /* Output quad word DATA8. Also output COMMENT if flag_verbose_asm is set.
640 Return the data size. Just return the size if DOSIZEONLY is non-zero. */
643 write_debug_data8 (data8
, comment
, dosizeonly
)
644 unsigned long long data8
;
650 ASM_OUTPUT_DEBUG_DATA8 (asm_out_file
, data8
);
651 if (flag_verbose_asm
)
652 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
653 fputc ('\n', asm_out_file
);
659 /* Output the difference between LABEL1 and LABEL2. Also output COMMENT if
660 flag_verbose_asm is set. Return the data size. Just return the size if
661 DOSIZEONLY is non-zero. */
664 write_debug_delta4 (label1
, label2
, comment
, dosizeonly
)
672 ASM_OUTPUT_DEBUG_DELTA4 (asm_out_file
, label1
, label2
);
673 if (flag_verbose_asm
)
674 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
675 fputc ('\n', asm_out_file
);
681 /* Output a character string STRING. Also write COMMENT if flag_verbose_asm is
682 set. Return the string length. Just return the length if DOSIZEONLY is
686 write_debug_string (string
, comment
, dosizeonly
)
693 ASM_OUTPUT_DEBUG_STRING (asm_out_file
, string
);
694 if (flag_verbose_asm
)
695 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
, comment
);
696 fputc ('\n', asm_out_file
);
699 return strlen (string
);
702 /* Output a module begin header and return the header size. Just return the
703 size if DOSIZEONLY is non-zero. */
706 write_modbeg (dosizeonly
)
709 DST_MODULE_BEGIN modbeg
;
712 char *module_name
, *m
;
717 /* Assumes primary filename has Unix syntax file spec. */
718 module_name
= xstrdup (basename ((char *) primary_filename
));
720 m
= strrchr (module_name
, '.');
724 modnamelen
= strlen (module_name
);
725 for (i
= 0; i
< modnamelen
; i
++)
726 module_name
[i
] = TOUPPER (module_name
[i
]);
728 prodnamelen
= strlen (module_producer
);
730 modbeg
.dst_a_modbeg_header
.dst__header_length
.dst_w_length
731 = DST_K_MODBEG_SIZE
+ modnamelen
+ DST_K_MB_TRLR_SIZE
+ prodnamelen
- 1;
732 modbeg
.dst_a_modbeg_header
.dst__header_type
.dst_w_type
= DST_K_MODBEG
;
733 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_hide
= 0;
734 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_version
= 1;
735 modbeg
.dst_b_modbeg_flags
.dst_v_modbeg_unused
= 0;
736 modbeg
.dst_b_modbeg_unused
= 0;
737 modbeg
.dst_l_modbeg_language
= module_language
;
738 modbeg
.dst_w_version_major
= DST_K_VERSION_MAJOR
;
739 modbeg
.dst_w_version_minor
= DST_K_VERSION_MINOR
;
740 modbeg
.dst_b_modbeg_name
= strlen (module_name
);
742 mb_trlr
.dst_b_compiler
= strlen (module_producer
);
744 totsize
+= write_debug_header (&modbeg
.dst_a_modbeg_header
,
745 "modbeg", dosizeonly
);
746 totsize
+= write_debug_data1 (*((char *) &modbeg
.dst_b_modbeg_flags
),
747 "flags", dosizeonly
);
748 totsize
+= write_debug_data1 (modbeg
.dst_b_modbeg_unused
,
749 "unused", dosizeonly
);
750 totsize
+= write_debug_data4 (modbeg
.dst_l_modbeg_language
,
751 "language", dosizeonly
);
752 totsize
+= write_debug_data2 (modbeg
.dst_w_version_major
,
753 "DST major version", dosizeonly
);
754 totsize
+= write_debug_data2 (modbeg
.dst_w_version_minor
,
755 "DST minor version", dosizeonly
);
756 totsize
+= write_debug_data1 (modbeg
.dst_b_modbeg_name
,
757 "length of module name", dosizeonly
);
758 totsize
+= write_debug_string (module_name
, "module name", dosizeonly
);
759 totsize
+= write_debug_data1 (mb_trlr
.dst_b_compiler
,
760 "length of compiler name", dosizeonly
);
761 totsize
+= write_debug_string (module_producer
, "compiler name", dosizeonly
);
766 /* Output a module end trailer and return the trailer size. Just return
767 the size if DOSIZEONLY is non-zero. */
770 write_modend (dosizeonly
)
773 DST_MODULE_END modend
;
776 modend
.dst_a_modend_header
.dst__header_length
.dst_w_length
777 = DST_K_MODEND_SIZE
- 1;
778 modend
.dst_a_modend_header
.dst__header_type
.dst_w_type
= DST_K_MODEND
;
780 totsize
+= write_debug_header (&modend
.dst_a_modend_header
, "modend",
786 /* Output a routine begin header routine RTNNUM and return the header size.
787 Just return the size if DOSIZEONLY is non-zero. */
790 write_rtnbeg (rtnnum
, dosizeonly
)
795 int rtnnamelen
, rtnentrynamelen
;
798 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
799 DST_ROUTINE_BEGIN rtnbeg
;
802 rtnname
= func_table
[rtnnum
];
803 rtnnamelen
= strlen (rtnname
);
804 rtnentrynamelen
= rtnnamelen
+ 4; /* "..en" */
805 rtnentryname
= (char *) xmalloc (rtnentrynamelen
+ 1);
806 strcpy (rtnentryname
, rtnname
);
807 strcat (rtnentryname
, "..en");
809 if (!strcmp (rtnname
, "main"))
812 const char *go
= "TRANSFER$BREAK$GO";
814 /* This command isn't documented in DSTRECORDS, so it's made to
815 look like what DEC C does */
817 /* header size - 1st byte + flag byte + STO_LW size
818 + string count byte + string length */
819 header
.dst__header_length
.dst_w_length
820 = DST_K_DST_HEADER_SIZE
- 1 + 1 + 4 + 1 + strlen (go
);
821 header
.dst__header_type
.dst_w_type
= 0x17;
823 totsize
+= write_debug_header (&header
, "transfer", dosizeonly
);
825 /* I think this is a flag byte, but I don't know what this flag means */
826 totsize
+= write_debug_data1 (0x1, "flags ???", dosizeonly
);
828 /* Routine Begin PD Address */
829 totsize
+= write_debug_addr (rtnname
, "main procedure descriptor",
831 totsize
+= write_debug_data1 (strlen (go
), "length of main_name",
833 totsize
+= write_debug_string ((char *) go
, "main name", dosizeonly
);
836 /* The header length never includes the length byte */
837 rtnbeg
.dst_a_rtnbeg_header
.dst__header_length
.dst_w_length
838 = DST_K_RTNBEG_SIZE
+ rtnnamelen
- 1;
839 rtnbeg
.dst_a_rtnbeg_header
.dst__header_type
.dst_w_type
= DST_K_RTNBEG
;
840 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_unused
= 0;
841 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_unalloc
= 0;
842 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_prototype
= 0;
843 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_inlined
= 0;
844 rtnbeg
.dst_b_rtnbeg_flags
.dst_v_rtnbeg_no_call
= 1;
845 rtnbeg
.dst_b_rtnbeg_name
= rtnnamelen
;
847 totsize
+= write_debug_header (&rtnbeg
.dst_a_rtnbeg_header
, "rtnbeg",
849 totsize
+= write_debug_data1 (*((char *) &rtnbeg
.dst_b_rtnbeg_flags
),
850 "flags", dosizeonly
);
852 /* Routine Begin Address */
853 totsize
+= write_debug_addr (rtnentryname
, "routine entry name", dosizeonly
);
855 /* Routine Begin PD Address */
856 totsize
+= write_debug_addr (rtnname
, "routine procedure descriptor",
859 /* Routine Begin Name */
860 totsize
+= write_debug_data1 (rtnbeg
.dst_b_rtnbeg_name
,
861 "length of routine name", dosizeonly
);
863 totsize
+= write_debug_string (rtnname
, "routine name", dosizeonly
);
867 if (debug_info_level
> DINFO_LEVEL_TERSE
)
869 prolog
.dst_a_prolog_header
.dst__header_length
.dst_w_length
870 = DST_K_PROLOG_SIZE
- 1;
871 prolog
.dst_a_prolog_header
.dst__header_type
.dst_w_type
= DST_K_PROLOG
;
873 totsize
+= write_debug_header (&prolog
.dst_a_prolog_header
, "prolog",
876 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_PROLOG_LABEL
, rtnnum
);
877 totsize
+= write_debug_addr (label
, "prolog breakpoint addr",
884 /* Output a routine end trailer for routine RTNNUM and return the header size.
885 Just return the size if DOSIZEONLY is non-zero. */
888 write_rtnend (rtnnum
, dosizeonly
)
892 DST_ROUTINE_END rtnend
;
893 char label1
[MAX_ARTIFICIAL_LABEL_BYTES
];
894 char label2
[MAX_ARTIFICIAL_LABEL_BYTES
];
899 rtnend
.dst_a_rtnend_header
.dst__header_length
.dst_w_length
900 = DST_K_RTNEND_SIZE
- 1;
901 rtnend
.dst_a_rtnend_header
.dst__header_type
.dst_w_type
= DST_K_RTNEND
;
902 rtnend
.dst_b_rtnend_unused
= 0;
903 rtnend
.dst_l_rtnend_size
= 0; /* Calculated below. */
905 totsize
+= write_debug_header (&rtnend
.dst_a_rtnend_header
, "rtnend",
907 totsize
+= write_debug_data1 (rtnend
.dst_b_rtnend_unused
, "unused",
910 ASM_GENERATE_INTERNAL_LABEL (label1
, FUNC_BEGIN_LABEL
, rtnnum
);
911 ASM_GENERATE_INTERNAL_LABEL (label2
, FUNC_END_LABEL
, rtnnum
);
912 totsize
+= write_debug_delta4 (label2
, label1
, "routine size", dosizeonly
);
917 #define K_DELTA_PC(I) \
918 ((I) < 128 ? -(I) : (I) < 65536 ? DST_K_DELTA_PC_W : DST_K_DELTA_PC_L)
920 #define K_SET_LINUM(I) \
921 ((I) < 256 ? DST_K_SET_LINUM_B \
922 : (I) < 65536 ? DST_K_SET_LINUM : DST_K_SET_LINUM_L)
924 #define K_INCR_LINUM(I) \
925 ((I) < 256 ? DST_K_INCR_LINUM \
926 : (I) < 65536 ? DST_K_INCR_LINUM_W : DST_K_INCR_LINUM_L)
928 /* Output the PC to line number correlations and return the size. Just return
929 the size if DOSIZEONLY is non-zero */
932 write_pclines (dosizeonly
)
940 DST_LINE_NUM_HEADER line_num
;
941 DST_PCLINE_COMMANDS pcline
;
942 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
943 char lastlabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
947 max_line
= file_info_table
[1].max_line
;
948 file_info_table
[1].listing_line_start
= linestart
;
949 linestart
= linestart
+ ((max_line
/ 100000) + 1) * 100000;
951 for (i
= 2; i
< file_info_table_in_use
; i
++)
953 max_line
= file_info_table
[i
].max_line
;
954 file_info_table
[i
].listing_line_start
= linestart
;
955 linestart
= linestart
+ ((max_line
/ 10000) + 1) * 10000;
958 /* Set starting address to beginning of text section */
959 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
= 8;
960 line_num
.dst_a_line_num_header
.dst__header_type
.dst_w_type
= DST_K_LINE_NUM
;
961 pcline
.dst_b_pcline_command
= DST_K_SET_ABS_PC
;
963 totsize
+= write_debug_header (&line_num
.dst_a_line_num_header
,
964 "line_num", dosizeonly
);
965 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
966 "line_num (SET ABS PC)", dosizeonly
);
972 ASM_OUTPUT_DEBUG_ADDR (asm_out_file
, TEXT_SECTION_ASM_OP
);
973 if (flag_verbose_asm
)
974 fprintf (asm_out_file
, "\t%s line_num", ASM_COMMENT_START
);
975 fputc ('\n', asm_out_file
);
978 fn
= line_info_table
[1].dst_file_num
;
979 ln
= (file_info_table
[fn
].listing_line_start
980 + line_info_table
[1].dst_line_num
);
981 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
= 4 + 4;
982 pcline
.dst_b_pcline_command
= DST_K_SET_LINUM_L
;
984 totsize
+= write_debug_header (&line_num
.dst_a_line_num_header
,
985 "line_num", dosizeonly
);
986 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
987 "line_num (SET LINUM LONG)", dosizeonly
);
989 sprintf (buff
, "line_num (%d)", ln
- 1);
990 totsize
+= write_debug_data4 (ln
- 1, buff
, dosizeonly
);
993 strcpy (lastlabel
, TEXT_SECTION_ASM_OP
);
994 for (i
= 1; i
< line_info_table_in_use
; i
++)
998 fn
= line_info_table
[i
].dst_file_num
;
999 ln
= (file_info_table
[fn
].listing_line_start
1000 + line_info_table
[i
].dst_line_num
);
1002 if (ln
- lastln
> 1)
1003 extrabytes
= 5; /* NUMBYTES (ln - lastln - 1) + 1; */
1004 else if (ln
<= lastln
)
1005 extrabytes
= 5; /* NUMBYTES (ln - 1) + 1; */
1009 line_num
.dst_a_line_num_header
.dst__header_length
.dst_w_length
1012 totsize
+= write_debug_header
1013 (&line_num
.dst_a_line_num_header
, "line_num", dosizeonly
);
1015 if (ln
- lastln
> 1)
1017 int lndif
= ln
- lastln
- 1;
1019 /* K_INCR_LINUM (lndif); */
1020 pcline
.dst_b_pcline_command
= DST_K_INCR_LINUM_L
;
1022 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
1023 "line_num (INCR LINUM LONG)",
1026 sprintf (buff
, "line_num (%d)", lndif
);
1027 totsize
+= write_debug_data4 (lndif
, buff
, dosizeonly
);
1029 else if (ln
<= lastln
)
1031 /* K_SET_LINUM (ln-1); */
1032 pcline
.dst_b_pcline_command
= DST_K_SET_LINUM_L
;
1034 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
1035 "line_num (SET LINUM LONG)",
1038 sprintf (buff
, "line_num (%d)", ln
- 1);
1039 totsize
+= write_debug_data4 (ln
- 1, buff
, dosizeonly
);
1042 pcline
.dst_b_pcline_command
= DST_K_DELTA_PC_L
;
1044 totsize
+= write_debug_data1 (pcline
.dst_b_pcline_command
,
1045 "line_num (DELTA PC LONG)", dosizeonly
);
1047 ASM_GENERATE_INTERNAL_LABEL (label
, LINE_CODE_LABEL
, i
);
1048 totsize
+= write_debug_delta4 (label
, lastlabel
, "increment line_num",
1052 strcpy (lastlabel
, label
);
1058 /* Output a source correlation for file FILEID using information saved in
1059 FILE_INFO_ENTRY and return the size. Just return the size if DOSIZEONLY is
1063 write_srccorr (fileid
, file_info_entry
, dosizeonly
)
1065 dst_file_info_entry file_info_entry
;
1068 int src_command_size
;
1069 int linesleft
= file_info_entry
.max_line
;
1070 int linestart
= file_info_entry
.listing_line_start
;
1071 int flen
= file_info_entry
.flen
;
1073 DST_SOURCE_CORR src_header
;
1074 DST_SRC_COMMAND src_command
;
1075 DST_SRC_COMMAND src_command_sf
;
1076 DST_SRC_COMMAND src_command_sl
;
1077 DST_SRC_COMMAND src_command_sr
;
1078 DST_SRC_COMMAND src_command_dl
;
1079 DST_SRC_CMDTRLR src_cmdtrlr
;
1085 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1086 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 1 - 1;
1087 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1089 src_command
.dst_b_src_command
= DST_K_SRC_FORMFEED
;
1091 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1092 "source corr", dosizeonly
);
1094 totsize
+= write_debug_data1 (src_command
.dst_b_src_command
,
1095 "source_corr (SRC FORMFEED)",
1100 = DST_K_SRC_COMMAND_SIZE
+ flen
+ DST_K_SRC_CMDTRLR_SIZE
;
1101 src_command
.dst_b_src_command
= DST_K_SRC_DECLFILE
;
1102 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_length
1103 = src_command_size
- 2;
1104 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_flags
= 0;
1105 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_fileid
1107 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_q_src_df_rms_cdt
1108 = file_info_entry
.cdt
;
1109 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_l_src_df_rms_ebk
1110 = file_info_entry
.ebk
;
1111 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_rms_ffb
1112 = file_info_entry
.ffb
;
1113 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_rms_rfo
1114 = file_info_entry
.rfo
;
1115 src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_filename
1116 = file_info_entry
.flen
;
1118 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1119 = DST_K_SOURCE_CORR_HEADER_SIZE
+ src_command_size
- 1;
1120 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1123 src_cmdtrlr
.dst_b_src_df_libmodname
= 0;
1125 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1126 "source corr", dosizeonly
);
1127 totsize
+= write_debug_data1 (src_command
.dst_b_src_command
,
1128 "source_corr (DECL SRC FILE)", dosizeonly
);
1129 totsize
+= write_debug_data1
1130 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_length
,
1131 "source_corr (length)", dosizeonly
);
1133 totsize
+= write_debug_data1
1134 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_flags
,
1135 "source_corr (flags)", dosizeonly
);
1137 totsize
+= write_debug_data2
1138 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_fileid
,
1139 "source_corr (fileid)", dosizeonly
);
1141 totsize
+= write_debug_data8
1142 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_q_src_df_rms_cdt
,
1143 "source_corr (creation date)", dosizeonly
);
1145 totsize
+= write_debug_data4
1146 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_l_src_df_rms_ebk
,
1147 "source_corr (EOF block number)", dosizeonly
);
1149 totsize
+= write_debug_data2
1150 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_w_src_df_rms_ffb
,
1151 "source_corr (first free byte)", dosizeonly
);
1153 totsize
+= write_debug_data1
1154 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_rms_rfo
,
1155 "source_corr (record and file organization)", dosizeonly
);
1157 totsize
+= write_debug_data1
1158 (src_command
.dst_a_src_cmd_fields
.dst_a_src_decl_src
.dst_b_src_df_filename
,
1159 "source_corr (filename length)", dosizeonly
);
1161 totsize
+= write_debug_string (file_info_entry
.file_name
,
1162 "source file name", dosizeonly
);
1163 totsize
+= write_debug_data1 (src_cmdtrlr
.dst_b_src_df_libmodname
,
1164 "source_corr (libmodname)", dosizeonly
);
1166 src_command_sf
.dst_b_src_command
= DST_K_SRC_SETFILE
;
1167 src_command_sf
.dst_a_src_cmd_fields
.dst_w_src_unsword
= fileid
;
1169 src_command_sr
.dst_b_src_command
= DST_K_SRC_SETREC_W
;
1170 src_command_sr
.dst_a_src_cmd_fields
.dst_w_src_unsword
= 1;
1172 src_command_sl
.dst_b_src_command
= DST_K_SRC_SETLNUM_L
;
1173 src_command_sl
.dst_a_src_cmd_fields
.dst_l_src_unslong
= linestart
+ 1;
1175 src_command_dl
.dst_b_src_command
= DST_K_SRC_DEFLINES_W
;
1177 if (linesleft
> 65534)
1178 linesleft
= linesleft
- 65534, linestodo
= 65534;
1180 linestodo
= linesleft
, linesleft
= 0;
1182 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
= linestodo
;
1184 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1185 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 3 + 3 + 5 + 3 - 1;
1186 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1189 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1190 "source corr", dosizeonly
);
1192 totsize
+= write_debug_data1 (src_command_sf
.dst_b_src_command
,
1193 "source_corr (src setfile)", dosizeonly
);
1195 totsize
+= write_debug_data2
1196 (src_command_sf
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1197 "source_corr (fileid)", dosizeonly
);
1199 totsize
+= write_debug_data1 (src_command_sr
.dst_b_src_command
,
1200 "source_corr (setrec)", dosizeonly
);
1202 totsize
+= write_debug_data2
1203 (src_command_sr
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1204 "source_corr (recnum)", dosizeonly
);
1206 totsize
+= write_debug_data1 (src_command_sl
.dst_b_src_command
,
1207 "source_corr (setlnum)", dosizeonly
);
1209 totsize
+= write_debug_data4
1210 (src_command_sl
.dst_a_src_cmd_fields
.dst_l_src_unslong
,
1211 "source_corr (linenum)", dosizeonly
);
1213 totsize
+= write_debug_data1 (src_command_dl
.dst_b_src_command
,
1214 "source_corr (deflines)", dosizeonly
);
1216 sprintf (buff
, "source_corr (%d)",
1217 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
);
1218 totsize
+= write_debug_data2
1219 (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
, buff
, dosizeonly
);
1221 while (linesleft
> 0)
1223 src_header
.dst_a_source_corr_header
.dst__header_length
.dst_w_length
1224 = DST_K_SOURCE_CORR_HEADER_SIZE
+ 3 - 1;
1225 src_header
.dst_a_source_corr_header
.dst__header_type
.dst_w_type
1227 src_command_dl
.dst_b_src_command
= DST_K_SRC_DEFLINES_W
;
1229 if (linesleft
> 65534)
1230 linesleft
= linesleft
- 65534, linestodo
= 65534;
1232 linestodo
= linesleft
, linesleft
= 0;
1234 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
= linestodo
;
1236 totsize
+= write_debug_header (&src_header
.dst_a_source_corr_header
,
1237 "source corr", dosizeonly
);
1238 totsize
+= write_debug_data1 (src_command_dl
.dst_b_src_command
,
1239 "source_corr (deflines)", dosizeonly
);
1240 sprintf (buff
, "source_corr (%d)",
1241 src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
);
1242 totsize
+= write_debug_data2
1243 (src_command_dl
.dst_a_src_cmd_fields
.dst_w_src_unsword
,
1250 /* Output all the source correlation entries and return the size. Just return
1251 the size if DOSIZEONLY is non-zero. */
1254 write_srccorrs (dosizeonly
)
1260 for (i
= 1; i
< file_info_table_in_use
; i
++)
1261 totsize
+= write_srccorr (i
, file_info_table
[i
], dosizeonly
);
1266 /* Output a marker (i.e. a label) for the beginning of a function, before
1270 vmsdbgout_begin_prologue (line
, file
)
1274 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1276 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1277 (*dwarf2_debug_hooks
.begin_prologue
) (line
, file
);
1279 if (debug_info_level
> DINFO_LEVEL_NONE
)
1281 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
1282 current_function_funcdef_no
);
1283 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1287 /* Output a marker (i.e. a label) for the beginning of a function, after
1291 vmsdbgout_after_prologue ()
1293 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1295 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1297 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_PROLOG_LABEL
,
1298 current_function_funcdef_no
);
1299 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1303 /* Output a marker (i.e. a label) for the absolute end of the generated code
1304 for a function definition. This gets called *after* the epilogue code has
1308 vmsdbgout_end_epilogue ()
1310 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1312 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1313 (*dwarf2_debug_hooks
.end_epilogue
) ();
1315 if (debug_info_level
> DINFO_LEVEL_NONE
)
1317 /* Output a label to mark the endpoint of the code generated for this
1319 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
,
1320 current_function_funcdef_no
);
1321 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1325 /* Output a marker (i.e. a label) for the beginning of the generated code for
1329 vmsdbgout_begin_block (line
, blocknum
)
1330 register unsigned line
;
1331 register unsigned blocknum
;
1333 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1334 (*dwarf2_debug_hooks
.begin_block
) (line
, blocknum
);
1336 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1337 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
1340 /* Output a marker (i.e. a label) for the end of the generated code for a
1344 vmsdbgout_end_block (line
, blocknum
)
1345 register unsigned line
;
1346 register unsigned blocknum
;
1348 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1349 (*dwarf2_debug_hooks
.end_block
) (line
, blocknum
);
1351 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1352 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
1355 /* Not implemented in VMS Debug. */
1358 vmsdbgout_ignore_block (block
)
1363 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1364 retval
= (*dwarf2_debug_hooks
.ignore_block
) (block
);
1369 /* Add an entry for function DECL into the func_table. */
1372 vmsdbgout_begin_function (decl
)
1375 const char *name
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
1377 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1378 (*dwarf2_debug_hooks
.begin_function
) (decl
);
1380 if (func_table_in_use
== func_table_allocated
)
1382 func_table_allocated
+= FUNC_TABLE_INCREMENT
;
1383 func_table
= (char **) xrealloc (func_table
,
1384 func_table_allocated
* sizeof (char *));
1387 /* Add the new entry to the end of the function name table. */
1388 func_table
[func_table_in_use
++] = xstrdup (name
);
1391 static char fullname_buff
[4096];
1393 /* Return the full file specification for FILENAME. The specification must be
1394 in VMS syntax in order to be processed by VMS Debug. */
1397 full_name (filename
)
1398 const char *filename
;
1401 FILE *fp
= fopen (filename
, "r");
1403 fgetname (fp
, fullname_buff
, 1);
1406 getcwd (fullname_buff
, sizeof (fullname_buff
));
1408 strcat (fullname_buff
, "/");
1409 strcat (fullname_buff
, filename
);
1411 /* ??? Insert hairy code here to translate Unix style file specification
1415 return fullname_buff
;
1418 /* Lookup a filename (in the list of filenames that we know about here in
1419 vmsdbgout.c) and return its "index". The index of each (known) filename is
1420 just a unique number which is associated with only that one filename. We
1421 need such numbers for the sake of generating labels and references
1422 to those files numbers. If the filename given as an argument is not
1423 found in our current list, add it to the list and assign it the next
1424 available unique index number. In order to speed up searches, we remember
1425 the index of the filename was looked up last. This handles the majority of
1429 lookup_filename (file_name
)
1430 const char *file_name
;
1432 static unsigned int last_file_lookup_index
= 0;
1434 register unsigned i
;
1441 struct stat statbuf
;
1443 if (stat (file_name
, &statbuf
) == 0)
1449 /* Adjust for GMT */
1450 ts
= (struct tm
*) localtime (&statbuf
.st_ctime
);
1451 gmtoff
= ts
->tm_gmtoff
;
1453 /* VMS has multiple file format types */
1454 rfo
= statbuf
.st_fab_rfm
;
1456 /* Is GMT adjustment an issue with a cross-compiler? */
1459 /* Assume stream LF type file */
1462 cdt
= 10000000 * (statbuf
.st_ctime
+ gmtoff
+ vms_epoch_offset
);
1463 ebk
= statbuf
.st_size
/ 512 + 1;
1464 ffb
= statbuf
.st_size
- ((statbuf
.st_size
/ 512) * 512);
1465 fnam
= full_name (file_name
);
1466 flen
= strlen (fnam
);
1478 /* Check to see if the file name that was searched on the previous call
1479 matches this file name. If so, return the index. */
1480 if (last_file_lookup_index
!= 0)
1482 fn
= file_info_table
[last_file_lookup_index
].file_name
;
1483 if (strcmp (fnam
, fn
) == 0)
1484 return last_file_lookup_index
;
1487 /* Didn't match the previous lookup, search the table */
1488 for (i
= 1; i
< file_info_table_in_use
; ++i
)
1490 fn
= file_info_table
[i
].file_name
;
1491 if (strcmp (fnam
, fn
) == 0)
1493 last_file_lookup_index
= i
;
1498 /* Prepare to add a new table entry by making sure there is enough space in
1499 the table to do so. If not, expand the current table. */
1500 if (file_info_table_in_use
== file_info_table_allocated
)
1503 file_info_table_allocated
+= FILE_TABLE_INCREMENT
;
1505 = (dst_file_info_ref
) xrealloc (file_info_table
,
1506 (file_info_table_allocated
1507 * sizeof (dst_file_info_entry
)));
1510 /* Add the new entry to the end of the filename table. */
1511 file_info_table
[file_info_table_in_use
].file_name
= xstrdup (fnam
);
1512 file_info_table
[file_info_table_in_use
].max_line
= 0;
1513 file_info_table
[file_info_table_in_use
].cdt
= cdt
;
1514 file_info_table
[file_info_table_in_use
].ebk
= ebk
;
1515 file_info_table
[file_info_table_in_use
].ffb
= ffb
;
1516 file_info_table
[file_info_table_in_use
].rfo
= rfo
;
1517 file_info_table
[file_info_table_in_use
].flen
= flen
;
1519 last_file_lookup_index
= file_info_table_in_use
++;
1520 return last_file_lookup_index
;
1523 /* Output a label to mark the beginning of a source code line entry
1524 and record information relating to this source line, in
1525 'line_info_table' for later output of the .debug_line section. */
1528 vmsdbgout_source_line (line
, filename
)
1529 register unsigned line
;
1530 register const char *filename
;
1532 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1533 (*dwarf2_debug_hooks
.source_line
) (line
, filename
);
1535 if (debug_info_level
>= DINFO_LEVEL_TERSE
)
1537 dst_line_info_ref line_info
;
1539 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, LINE_CODE_LABEL
,
1540 line_info_table_in_use
);
1542 /* Expand the line info table if necessary. */
1543 if (line_info_table_in_use
== line_info_table_allocated
)
1545 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
1547 = (dst_line_info_ref
) xrealloc (line_info_table
,
1548 (line_info_table_allocated
1549 * sizeof (dst_line_info_entry
)));
1552 /* Add the new entry at the end of the line_info_table. */
1553 line_info
= &line_info_table
[line_info_table_in_use
++];
1554 line_info
->dst_file_num
= lookup_filename (filename
);
1555 line_info
->dst_line_num
= line
;
1556 if (line
> file_info_table
[line_info
->dst_file_num
].max_line
)
1557 file_info_table
[line_info
->dst_file_num
].max_line
= line
;
1561 /* Record the beginning of a new source file, for later output.
1562 At present, unimplemented. */
1565 vmsdbgout_start_source_file (lineno
, filename
)
1566 unsigned int lineno
;
1567 const char *filename
;
1569 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1570 (*dwarf2_debug_hooks
.start_source_file
) (lineno
, filename
);
1573 /* Record the end of a source file, for later output.
1574 At present, unimplemented. */
1577 vmsdbgout_end_source_file (lineno
)
1578 unsigned int lineno ATTRIBUTE_UNUSED
;
1580 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1581 (*dwarf2_debug_hooks
.end_source_file
) (lineno
);
1584 /* Set up for Debug output at the start of compilation. */
1587 vmsdbgout_init (main_input_filename
)
1588 const char *main_input_filename
;
1590 const char *language_string
= lang_hooks
.name
;
1592 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1593 (*dwarf2_debug_hooks
.init
) (main_input_filename
);
1595 if (debug_info_level
== DINFO_LEVEL_NONE
)
1598 /* Remember the name of the primary input file. */
1599 primary_filename
= main_input_filename
;
1601 /* Allocate the initial hunk of the file_info_table. */
1603 = (dst_file_info_ref
) xcalloc (FILE_TABLE_INCREMENT
,
1604 sizeof (dst_file_info_entry
));
1605 file_info_table_allocated
= FILE_TABLE_INCREMENT
;
1607 /* Skip the first entry - file numbers begin at 1 */
1608 file_info_table_in_use
= 1;
1610 func_table
= (char **) xcalloc (FUNC_TABLE_INCREMENT
, sizeof (char *));
1611 func_table_allocated
= FUNC_TABLE_INCREMENT
;
1612 func_table_in_use
= 1;
1614 /* Allocate the initial hunk of the line_info_table. */
1616 = (dst_line_info_ref
) xcalloc (LINE_INFO_TABLE_INCREMENT
,
1617 sizeof (dst_line_info_entry
));
1618 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
1619 /* zero-th entry is allocated, but unused */
1620 line_info_table_in_use
= 1;
1622 lookup_filename (primary_filename
);
1624 if (!strcmp (language_string
, "GNU C"))
1625 module_language
= DST_K_C
;
1626 else if (!strcmp (language_string
, "GNU C++"))
1627 module_language
= DST_K_CXX
;
1628 else if (!strcmp (language_string
, "GNU Ada"))
1629 module_language
= DST_K_ADA
;
1630 else if (!strcmp (language_string
, "GNU F77"))
1631 module_language
= DST_K_FORTRAN
;
1633 module_language
= DST_K_UNKNOWN
;
1636 = (char *) xmalloc (strlen (language_string
) + 1
1637 + strlen (version_string
) + 1);
1638 sprintf (module_producer
, "%s %s", language_string
, version_string
);
1640 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
1644 /* Not implemented in VMS Debug. */
1647 vmsdbgout_define (lineno
, buffer
)
1648 unsigned int lineno
;
1651 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1652 (*dwarf2_debug_hooks
.define
) (lineno
, buffer
);
1655 /* Not implemented in VMS Debug. */
1658 vmsdbgout_undef (lineno
, buffer
)
1659 unsigned int lineno
;
1662 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1663 (*dwarf2_debug_hooks
.undef
) (lineno
, buffer
);
1666 /* Not implemented in VMS Debug. */
1669 vmsdbgout_decl (decl
)
1672 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1673 (*dwarf2_debug_hooks
.function_decl
) (decl
);
1676 /* Not implemented in VMS Debug. */
1679 vmsdbgout_global_decl (decl
)
1682 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1683 (*dwarf2_debug_hooks
.global_decl
) (decl
);
1686 /* Not implemented in VMS Debug. */
1689 vmsdbgout_abstract_function (decl
)
1692 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1693 (*dwarf2_debug_hooks
.outlining_inline_function
) (decl
);
1696 /* Output stuff that Debug requires at the end of every file and generate the
1697 VMS Debug debugging info. */
1700 vmsdbgout_finish (input_filename
)
1701 const char *input_filename ATTRIBUTE_UNUSED
;
1706 if (write_symbols
== VMS_AND_DWARF2_DEBUG
)
1707 (*dwarf2_debug_hooks
.finish
) (input_filename
);
1709 if (debug_info_level
== DINFO_LEVEL_NONE
)
1712 /* Output a terminator label for the .text section. */
1714 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, TEXT_END_LABEL
, 0);
1716 /* Output debugging information.
1717 Warning! Do not change the name of the .vmsdebug section without
1718 changing it in the assembler also. */
1719 named_section (NULL_TREE
, ".vmsdebug", 0);
1720 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
1722 totsize
= write_modbeg (1);
1723 for (i
= 1; i
< func_table_in_use
; i
++)
1725 totsize
+= write_rtnbeg (i
, 1);
1726 totsize
+= write_rtnend (i
, 1);
1728 totsize
+= write_pclines (1);
1731 for (i
= 1; i
< func_table_in_use
; i
++)
1733 write_rtnbeg (i
, 0);
1734 write_rtnend (i
, 0);
1738 if (debug_info_level
> DINFO_LEVEL_TERSE
)
1740 totsize
= write_srccorrs (1);
1744 totsize
= write_modend (1);
1747 #endif /* VMS_DEBUGGING_INFO */