decl.c (value_annotation_hasher::handle_cache_entry): Delete.
[gcc.git] / gcc / vmsdbgout.c
1 /* Output VMS debug format symbol table information from GCC.
2 Copyright (C) 1987-2015 Free Software Foundation, Inc.
3 Contributed by Douglas B. Rupp (rupp@gnat.com).
4 Updated by Bernard W. Giroud (bgiroud@users.sourceforge.net).
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
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
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26
27 #ifdef VMS_DEBUGGING_INFO
28 #include "alias.h"
29 #include "symtab.h"
30 #include "tree.h"
31 #include "varasm.h"
32 #include "version.h"
33 #include "flags.h"
34 #include "rtl.h"
35 #include "output.h"
36 #include "vmsdbg.h"
37 #include "debug.h"
38 #include "langhooks.h"
39 #include "hard-reg-set.h"
40 #include "function.h"
41 #include "target.h"
42
43 /* Difference in seconds between the VMS Epoch and the Unix Epoch */
44 static const long long vms_epoch_offset = 3506716800ll;
45
46 int vms_file_stats_name (const char *, long long *, long *, char *, int *);
47
48 /* NOTE: In the comments in this file, many references are made to "Debug
49 Symbol Table". This term is abbreviated as `DST' throughout the remainder
50 of this file. */
51
52 typedef struct dst_line_info_struct *dst_line_info_ref;
53
54 /* Each entry in the line_info_table maintains the file and
55 line number associated with the label generated for that
56 entry. The label gives the PC value associated with
57 the line number entry. */
58 typedef struct dst_line_info_struct
59 {
60 unsigned long dst_file_num;
61 unsigned long dst_line_num;
62 }
63 dst_line_info_entry;
64
65 typedef struct dst_file_info_struct *dst_file_info_ref;
66
67 typedef struct dst_file_info_struct
68 {
69 char *file_name;
70 unsigned int max_line;
71 unsigned int listing_line_start;
72 long long cdt;
73 long ebk;
74 short ffb;
75 char rfo;
76 }
77 dst_file_info_entry;
78
79 /* Maximum size (in bytes) of an artificially generated label. */
80 #define MAX_ARTIFICIAL_LABEL_BYTES 30
81
82 /* Make sure we know the sizes of the various types debug can describe. These
83 are only defaults. If the sizes are different for your target, you should
84 override these values by defining the appropriate symbols in your tm.h
85 file. */
86 #ifndef PTR_SIZE
87 #define PTR_SIZE 4 /* Must be 32 bits for VMS debug info */
88 #endif
89
90 /* Pointer to a structure of filenames referenced by this compilation unit. */
91 static dst_file_info_ref file_info_table;
92
93 /* Total number of entries in the table (i.e. array) pointed to by
94 `file_info_table'. This is the *total* and includes both used and unused
95 slots. */
96 static unsigned int file_info_table_allocated;
97
98 /* Number of entries in the file_info_table which are actually in use. */
99 static unsigned int file_info_table_in_use;
100
101 /* Size (in elements) of increments by which we may expand the filename
102 table. */
103 #define FILE_TABLE_INCREMENT 64
104
105 typedef char *char_p;
106
107 static vec<char_p> funcnam_table;
108 static vec<unsigned> funcnum_table;
109 #define FUNC_TABLE_INITIAL 256
110
111 /* Local pointer to the name of the main input file. Initialized in
112 vmsdbgout_init. */
113 static const char *primary_filename;
114
115 static char *module_producer;
116 static unsigned int module_language;
117
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;
121
122 /* Number of elements currently allocated for line_info_table. */
123 static unsigned int line_info_table_allocated;
124
125 /* Number of elements in line_info_table currently in use. */
126 static unsigned int line_info_table_in_use;
127
128 /* Size (in elements) of increments by which we may expand line_info_table. */
129 #define LINE_INFO_TABLE_INCREMENT 1024
130
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);
149
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_early_global_decl (tree);
170 static void vmsdbgout_late_global_decl (tree);
171 static void vmsdbgout_type_decl (tree, int);
172 static void vmsdbgout_abstract_function (tree);
173
174 /* The debug hooks structure. */
175
176 const struct gcc_debug_hooks vmsdbg_debug_hooks
177 = {vmsdbgout_init,
178 vmsdbgout_finish,
179 debug_nothing_void,
180 vmsdbgout_assembly_start,
181 vmsdbgout_define,
182 vmsdbgout_undef,
183 vmsdbgout_start_source_file,
184 vmsdbgout_end_source_file,
185 vmsdbgout_begin_block,
186 vmsdbgout_end_block,
187 vmsdbgout_ignore_block,
188 vmsdbgout_source_line,
189 vmsdbgout_begin_prologue,
190 vmsdbgout_end_prologue,
191 vmsdbgout_begin_epilogue,
192 vmsdbgout_end_epilogue,
193 vmsdbgout_begin_function,
194 vmsdbgout_end_function,
195 debug_nothing_tree, /* register_main_translation_unit */
196 vmsdbgout_function_decl,
197 vmsdbgout_early_global_decl,
198 vmsdbgout_late_global_decl,
199 vmsdbgout_type_decl, /* type_decl */
200 debug_nothing_tree_tree_tree_bool, /* imported_module_or_decl */
201 debug_nothing_tree, /* deferred_inline_function */
202 vmsdbgout_abstract_function,
203 debug_nothing_rtx_code_label, /* label */
204 debug_nothing_int, /* handle_pch */
205 debug_nothing_rtx_insn, /* var_location */
206 debug_nothing_void, /* switch_text_section */
207 debug_nothing_tree_tree, /* set_name */
208 0, /* start_end_main_source_file */
209 TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */
210 };
211
212 /* Definitions of defaults for assembler-dependent names of various
213 pseudo-ops and section names. */
214 #define VMS_UNALIGNED_SHORT_ASM_OP ".word"
215 #define VMS_UNALIGNED_INT_ASM_OP ".long"
216 #define VMS_UNALIGNED_LONG_ASM_OP ".long"
217 #define VMS_UNALIGNED_DOUBLE_INT_ASM_OP ".quad"
218
219 #define VMS_ASM_BYTE_OP ".byte"
220
221 #define NUMBYTES(I) ((I) < 256 ? 1 : (I) < 65536 ? 2 : 4)
222
223 #define NUMBYTES0(I) ((I) < 128 ? 0 : (I) < 65536 ? 2 : 4)
224
225 #ifndef UNALIGNED_PTR_ASM_OP
226 #define UNALIGNED_PTR_ASM_OP \
227 (PTR_SIZE == 8 ? VMS_UNALIGNED_DOUBLE_INT_ASM_OP : VMS_UNALIGNED_INT_ASM_OP)
228 #endif
229
230 #ifndef UNALIGNED_OFFSET_ASM_OP
231 #define UNALIGNED_OFFSET_ASM_OP(OFFSET) \
232 (NUMBYTES (OFFSET) == 4 \
233 ? VMS_UNALIGNED_LONG_ASM_OP \
234 : (NUMBYTES (OFFSET) == 2 ? VMS_UNALIGNED_SHORT_ASM_OP : VMS_ASM_BYTE_OP))
235 #endif
236
237 /* Definitions of defaults for formats and names of various special
238 (artificial) labels which may be generated within this file (when the -g
239 options is used and VMS_DEBUGGING_INFO is in effect. If necessary, these
240 may be overridden from within the tm.h file, but typically, overriding these
241 defaults is unnecessary. */
242
243 static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
244
245 #ifndef TEXT_END_LABEL
246 #define TEXT_END_LABEL "Lvetext"
247 #endif
248 #ifndef FUNC_BEGIN_LABEL
249 #define FUNC_BEGIN_LABEL "LVFB"
250 #endif
251 #ifndef FUNC_PROLOG_LABEL
252 #define FUNC_PROLOG_LABEL "LVFP"
253 #endif
254 #ifndef FUNC_EPILOG_LABEL
255 #define FUNC_EPILOG_LABEL "LVEB"
256 #endif
257 #ifndef FUNC_END_LABEL
258 #define FUNC_END_LABEL "LVFE"
259 #endif
260 #ifndef BLOCK_BEGIN_LABEL
261 #define BLOCK_BEGIN_LABEL "LVBB"
262 #endif
263 #ifndef BLOCK_END_LABEL
264 #define BLOCK_END_LABEL "LVBE"
265 #endif
266 #ifndef LINE_CODE_LABEL
267 #define LINE_CODE_LABEL "LVM"
268 #endif
269
270 #ifndef ASM_OUTPUT_DEBUG_DELTA2
271 #define ASM_OUTPUT_DEBUG_DELTA2(FILE,LABEL1,LABEL2) \
272 do \
273 { \
274 fprintf ((FILE), "\t%s\t", VMS_UNALIGNED_SHORT_ASM_OP); \
275 assemble_name (FILE, LABEL1); \
276 fprintf (FILE, "-"); \
277 assemble_name (FILE, LABEL2); \
278 } \
279 while (0)
280 #endif
281
282 #ifndef ASM_OUTPUT_DEBUG_DELTA4
283 #define ASM_OUTPUT_DEBUG_DELTA4(FILE,LABEL1,LABEL2) \
284 do \
285 { \
286 fprintf ((FILE), "\t%s\t", VMS_UNALIGNED_INT_ASM_OP); \
287 assemble_name (FILE, LABEL1); \
288 fprintf (FILE, "-"); \
289 assemble_name (FILE, LABEL2); \
290 } \
291 while (0)
292 #endif
293
294 #ifndef ASM_OUTPUT_DEBUG_ADDR_DELTA
295 #define ASM_OUTPUT_DEBUG_ADDR_DELTA(FILE,LABEL1,LABEL2) \
296 do \
297 { \
298 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
299 assemble_name (FILE, LABEL1); \
300 fprintf (FILE, "-"); \
301 assemble_name (FILE, LABEL2); \
302 } \
303 while (0)
304 #endif
305
306 #ifndef ASM_OUTPUT_DEBUG_ADDR
307 #define ASM_OUTPUT_DEBUG_ADDR(FILE,LABEL) \
308 do \
309 { \
310 fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP); \
311 assemble_name (FILE, LABEL); \
312 } \
313 while (0)
314 #endif
315
316 #ifndef ASM_OUTPUT_DEBUG_ADDR_CONST
317 #define ASM_OUTPUT_DEBUG_ADDR_CONST(FILE,ADDR) \
318 fprintf ((FILE), "\t%s\t%s", UNALIGNED_PTR_ASM_OP, (ADDR))
319 #endif
320
321 #ifndef ASM_OUTPUT_DEBUG_DATA1
322 #define ASM_OUTPUT_DEBUG_DATA1(FILE,VALUE) \
323 fprintf ((FILE), "\t%s\t%#x", VMS_ASM_BYTE_OP, (unsigned char) VALUE)
324 #endif
325
326 #ifndef ASM_OUTPUT_DEBUG_DATA2
327 #define ASM_OUTPUT_DEBUG_DATA2(FILE,VALUE) \
328 fprintf ((FILE), "\t%s\t%#x", VMS_UNALIGNED_SHORT_ASM_OP, \
329 (unsigned short) VALUE)
330 #endif
331
332 #ifndef ASM_OUTPUT_DEBUG_DATA4
333 #define ASM_OUTPUT_DEBUG_DATA4(FILE,VALUE) \
334 fprintf ((FILE), "\t%s\t%#lx", VMS_UNALIGNED_INT_ASM_OP, \
335 (unsigned long) VALUE)
336 #endif
337
338 #ifndef ASM_OUTPUT_DEBUG_DATA
339 #define ASM_OUTPUT_DEBUG_DATA(FILE,VALUE) \
340 fprintf ((FILE), "\t%s\t%#lx", UNALIGNED_OFFSET_ASM_OP (VALUE), VALUE)
341 #endif
342
343 #ifndef ASM_OUTPUT_DEBUG_ADDR_DATA
344 #define ASM_OUTPUT_DEBUG_ADDR_DATA(FILE,VALUE) \
345 fprintf ((FILE), "\t%s\t%#lx", UNALIGNED_PTR_ASM_OP, \
346 (unsigned long) VALUE)
347 #endif
348
349 #ifndef ASM_OUTPUT_DEBUG_DATA8
350 #define ASM_OUTPUT_DEBUG_DATA8(FILE,VALUE) \
351 fprintf ((FILE), "\t%s\t%#llx", VMS_UNALIGNED_DOUBLE_INT_ASM_OP, \
352 (unsigned long long) VALUE)
353 #endif
354
355 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
356 newline is produced. When flag_verbose_asm is asserted, we add commentary
357 at the end of the line, so we must avoid output of a newline here. */
358 #ifndef ASM_OUTPUT_DEBUG_STRING
359 #define ASM_OUTPUT_DEBUG_STRING(FILE,P) \
360 do \
361 { \
362 register int slen = strlen (P); \
363 register const char *p = (P); \
364 register int i; \
365 fprintf (FILE, "\t.ascii \""); \
366 for (i = 0; i < slen; i++) \
367 { \
368 register int c = p[i]; \
369 if (c == '\"' || c == '\\') \
370 putc ('\\', FILE); \
371 if (c >= ' ' && c < 0177) \
372 putc (c, FILE); \
373 else \
374 fprintf (FILE, "\\%o", c); \
375 } \
376 fprintf (FILE, "\""); \
377 } \
378 while (0)
379 #endif
380
381 /* Convert a reference to the assembler name of a C-level name. This
382 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
383 a string rather than writing to a file. */
384 #ifndef ASM_NAME_TO_STRING
385 #define ASM_NAME_TO_STRING(STR, NAME) \
386 do \
387 { \
388 if ((NAME)[0] == '*') \
389 strcpy (STR, NAME+1); \
390 else \
391 strcpy (STR, NAME); \
392 } \
393 while (0)
394 #endif
395
396 \f
397 /* Output the debug header HEADER. Also output COMMENT if flag_verbose_asm is
398 set. Return the header size. Just return the size if DOSIZEONLY is
399 nonzero. */
400
401 static int
402 write_debug_header (DST_HEADER *header, const char *comment, int dosizeonly)
403 {
404 if (!dosizeonly)
405 {
406 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file,
407 header->dst__header_length.dst_w_length);
408
409 if (flag_verbose_asm)
410 fprintf (asm_out_file, "\t%s record length", ASM_COMMENT_START);
411 fputc ('\n', asm_out_file);
412
413 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file,
414 header->dst__header_type.dst_w_type);
415
416 if (flag_verbose_asm)
417 fprintf (asm_out_file, "\t%s record type (%s)", ASM_COMMENT_START,
418 comment);
419
420 fputc ('\n', asm_out_file);
421 }
422
423 return 4;
424 }
425
426 /* Output the address of SYMBOL. Also output COMMENT if flag_verbose_asm is
427 set. Return the address size. Just return the size if DOSIZEONLY is
428 nonzero. */
429
430 static int
431 write_debug_addr (const char *symbol, const char *comment, int dosizeonly)
432 {
433 if (!dosizeonly)
434 {
435 ASM_OUTPUT_DEBUG_ADDR (asm_out_file, symbol);
436 if (flag_verbose_asm)
437 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
438 fputc ('\n', asm_out_file);
439 }
440
441 return PTR_SIZE;
442 }
443
444 /* Output the single byte DATA1. Also output COMMENT if flag_verbose_asm is
445 set. Return the data size. Just return the size if DOSIZEONLY is
446 nonzero. */
447
448 static int
449 write_debug_data1 (unsigned int data1, const char *comment, int dosizeonly)
450 {
451 if (!dosizeonly)
452 {
453 ASM_OUTPUT_DEBUG_DATA1 (asm_out_file, data1);
454 if (flag_verbose_asm)
455 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
456 fputc ('\n', asm_out_file);
457 }
458
459 return 1;
460 }
461
462 /* Output the single word DATA2. Also output COMMENT if flag_verbose_asm is
463 set. Return the data size. Just return the size if DOSIZEONLY is
464 nonzero. */
465
466 static int
467 write_debug_data2 (unsigned int data2, const char *comment, int dosizeonly)
468 {
469 if (!dosizeonly)
470 {
471 ASM_OUTPUT_DEBUG_DATA2 (asm_out_file, data2);
472 if (flag_verbose_asm)
473 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
474 fputc ('\n', asm_out_file);
475 }
476
477 return 2;
478 }
479
480 /* Output double word DATA4. Also output COMMENT if flag_verbose_asm is set.
481 Return the data size. Just return the size if DOSIZEONLY is nonzero. */
482
483 static int
484 write_debug_data4 (unsigned long data4, const char *comment, int dosizeonly)
485 {
486 if (!dosizeonly)
487 {
488 ASM_OUTPUT_DEBUG_DATA4 (asm_out_file, data4);
489 if (flag_verbose_asm)
490 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
491 fputc ('\n', asm_out_file);
492 }
493
494 return 4;
495 }
496
497 /* Output quad word DATA8. Also output COMMENT if flag_verbose_asm is set.
498 Return the data size. Just return the size if DOSIZEONLY is nonzero. */
499
500 static int
501 write_debug_data8 (unsigned long long data8, const char *comment,
502 int dosizeonly)
503 {
504 if (!dosizeonly)
505 {
506 ASM_OUTPUT_DEBUG_DATA8 (asm_out_file, data8);
507 if (flag_verbose_asm)
508 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
509 fputc ('\n', asm_out_file);
510 }
511
512 return 8;
513 }
514
515 /* Output the difference between LABEL1 and LABEL2. Also output COMMENT if
516 flag_verbose_asm is set. Return the data size. Just return the size if
517 DOSIZEONLY is nonzero. */
518
519 static int
520 write_debug_delta4 (const char *label1, const char *label2,
521 const char *comment, int dosizeonly)
522 {
523 if (!dosizeonly)
524 {
525 ASM_OUTPUT_DEBUG_DELTA4 (asm_out_file, label1, label2);
526 if (flag_verbose_asm)
527 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
528 fputc ('\n', asm_out_file);
529 }
530
531 return 4;
532 }
533
534 /* Output a character string STRING. Also write COMMENT if flag_verbose_asm is
535 set. Return the string length. Just return the length if DOSIZEONLY is
536 nonzero. */
537
538 static int
539 write_debug_string (const char *string, const char *comment, int dosizeonly)
540 {
541 if (!dosizeonly)
542 {
543 ASM_OUTPUT_DEBUG_STRING (asm_out_file, string);
544 if (flag_verbose_asm)
545 fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
546 fputc ('\n', asm_out_file);
547 }
548
549 return strlen (string);
550 }
551
552 /* Output a module begin header and return the header size. Just return the
553 size if DOSIZEONLY is nonzero. */
554
555 static int
556 write_modbeg (int dosizeonly)
557 {
558 DST_MODULE_BEGIN modbeg;
559 DST_MB_TRLR mb_trlr;
560 int i;
561 char *module_name, *m;
562 int modnamelen;
563 int prodnamelen;
564 int totsize = 0;
565
566 /* Assumes primary filename has Unix syntax file spec. */
567 module_name = xstrdup (lbasename (primary_filename));
568
569 m = strrchr (module_name, '.');
570 if (m)
571 *m = 0;
572
573 modnamelen = strlen (module_name);
574 for (i = 0; i < modnamelen; i++)
575 module_name[i] = TOUPPER (module_name[i]);
576
577 prodnamelen = strlen (module_producer);
578
579 modbeg.dst_a_modbeg_header.dst__header_length.dst_w_length
580 = DST_K_MODBEG_SIZE + modnamelen + DST_K_MB_TRLR_SIZE + prodnamelen - 1;
581 modbeg.dst_a_modbeg_header.dst__header_type.dst_w_type = DST_K_MODBEG;
582 modbeg.dst_b_modbeg_flags.dst_v_modbeg_hide = 0;
583 modbeg.dst_b_modbeg_flags.dst_v_modbeg_version = 1;
584 modbeg.dst_b_modbeg_flags.dst_v_modbeg_unused = 0;
585 modbeg.dst_b_modbeg_unused = 0;
586 modbeg.dst_l_modbeg_language = (DST_LANGUAGE) module_language;
587 modbeg.dst_w_version_major = DST_K_VERSION_MAJOR;
588 modbeg.dst_w_version_minor = DST_K_VERSION_MINOR;
589 modbeg.dst_b_modbeg_name = strlen (module_name);
590
591 mb_trlr.dst_b_compiler = strlen (module_producer);
592
593 totsize += write_debug_header (&modbeg.dst_a_modbeg_header,
594 "modbeg", dosizeonly);
595 totsize += write_debug_data1 (*((char *) &modbeg.dst_b_modbeg_flags),
596 "flags", dosizeonly);
597 totsize += write_debug_data1 (modbeg.dst_b_modbeg_unused,
598 "unused", dosizeonly);
599 totsize += write_debug_data4 (modbeg.dst_l_modbeg_language,
600 "language", dosizeonly);
601 totsize += write_debug_data2 (modbeg.dst_w_version_major,
602 "DST major version", dosizeonly);
603 totsize += write_debug_data2 (modbeg.dst_w_version_minor,
604 "DST minor version", dosizeonly);
605 totsize += write_debug_data1 (modbeg.dst_b_modbeg_name,
606 "length of module name", dosizeonly);
607 totsize += write_debug_string (module_name, "module name", dosizeonly);
608 totsize += write_debug_data1 (mb_trlr.dst_b_compiler,
609 "length of compiler name", dosizeonly);
610 totsize += write_debug_string (module_producer, "compiler name", dosizeonly);
611
612 return totsize;
613 }
614
615 /* Output a module end trailer and return the trailer size. Just return
616 the size if DOSIZEONLY is nonzero. */
617
618 static int
619 write_modend (int dosizeonly)
620 {
621 DST_MODULE_END modend;
622 int totsize = 0;
623
624 modend.dst_a_modend_header.dst__header_length.dst_w_length
625 = DST_K_MODEND_SIZE - 1;
626 modend.dst_a_modend_header.dst__header_type.dst_w_type = DST_K_MODEND;
627
628 totsize += write_debug_header (&modend.dst_a_modend_header, "modend",
629 dosizeonly);
630
631 return totsize;
632 }
633
634 /* Output a routine begin header routine RTNNUM and return the header size.
635 Just return the size if DOSIZEONLY is nonzero. */
636
637 static int
638 write_rtnbeg (int rtnnum, int dosizeonly)
639 {
640 const char *rtnname;
641 int rtnnamelen;
642 char *rtnentryname;
643 int totsize = 0;
644 char label[MAX_ARTIFICIAL_LABEL_BYTES];
645 DST_ROUTINE_BEGIN rtnbeg;
646 DST_PROLOG prolog;
647
648 rtnname = funcnam_table[rtnnum];
649 rtnnamelen = strlen (rtnname);
650 rtnentryname = concat (rtnname, "..en", NULL);
651
652 if (!strcmp (rtnname, "main"))
653 {
654 DST_HEADER header;
655 const char *go = "TRANSFER$BREAK$GO";
656
657 /* This command isn't documented in DSTRECORDS, so it's made to
658 look like what DEC C does */
659
660 /* header size - 1st byte + flag byte + STO_LW size
661 + string count byte + string length */
662 header.dst__header_length.dst_w_length
663 = DST_K_DST_HEADER_SIZE - 1 + 1 + 4 + 1 + strlen (go);
664 header.dst__header_type.dst_w_type = DST_K_TBG;
665
666 totsize += write_debug_header (&header, "transfer", dosizeonly);
667
668 /* I think this is a flag byte, but I don't know what this flag means */
669 totsize += write_debug_data1 (0x1, "flags ???", dosizeonly);
670
671 /* Routine Begin PD Address */
672 totsize += write_debug_addr (rtnname, "main procedure descriptor",
673 dosizeonly);
674 totsize += write_debug_data1 (strlen (go), "length of main_name",
675 dosizeonly);
676 totsize += write_debug_string (go, "main name", dosizeonly);
677 }
678
679 /* The header length never includes the length byte. */
680 rtnbeg.dst_a_rtnbeg_header.dst__header_length.dst_w_length
681 = DST_K_RTNBEG_SIZE + rtnnamelen - 1;
682 rtnbeg.dst_a_rtnbeg_header.dst__header_type.dst_w_type = DST_K_RTNBEG;
683 rtnbeg.dst_b_rtnbeg_flags.dst_v_rtnbeg_unused = 0;
684 rtnbeg.dst_b_rtnbeg_flags.dst_v_rtnbeg_unalloc = 0;
685 rtnbeg.dst_b_rtnbeg_flags.dst_v_rtnbeg_prototype = 0;
686 rtnbeg.dst_b_rtnbeg_flags.dst_v_rtnbeg_inlined = 0;
687 rtnbeg.dst_b_rtnbeg_flags.dst_v_rtnbeg_no_call = 1;
688 rtnbeg.dst_b_rtnbeg_name = rtnnamelen;
689
690 totsize += write_debug_header (&rtnbeg.dst_a_rtnbeg_header, "rtnbeg",
691 dosizeonly);
692 totsize += write_debug_data1 (*((char *) &rtnbeg.dst_b_rtnbeg_flags),
693 "flags", dosizeonly);
694
695 /* Routine Begin Address */
696 totsize += write_debug_addr (rtnentryname, "routine entry name", dosizeonly);
697
698 /* Routine Begin PD Address */
699 totsize += write_debug_addr (rtnname, "routine procedure descriptor",
700 dosizeonly);
701
702 /* Routine Begin Name */
703 totsize += write_debug_data1 (rtnbeg.dst_b_rtnbeg_name,
704 "length of routine name", dosizeonly);
705
706 totsize += write_debug_string (rtnname, "routine name", dosizeonly);
707
708 free (rtnentryname);
709
710 if (debug_info_level > DINFO_LEVEL_TERSE)
711 {
712 prolog.dst_a_prolog_header.dst__header_length.dst_w_length
713 = DST_K_PROLOG_SIZE - 1;
714 prolog.dst_a_prolog_header.dst__header_type.dst_w_type = DST_K_PROLOG;
715
716 totsize += write_debug_header (&prolog.dst_a_prolog_header, "prolog",
717 dosizeonly);
718
719 ASM_GENERATE_INTERNAL_LABEL
720 (label, FUNC_PROLOG_LABEL,
721 funcnum_table[rtnnum]);
722 totsize += write_debug_addr (label, "prolog breakpoint addr",
723 dosizeonly);
724 }
725
726 return totsize;
727 }
728
729 /* Output a routine end trailer for routine RTNNUM and return the header size.
730 Just return the size if DOSIZEONLY is nonzero. */
731
732 static int
733 write_rtnend (int rtnnum, int dosizeonly)
734 {
735 DST_ROUTINE_END rtnend;
736 char label1[MAX_ARTIFICIAL_LABEL_BYTES];
737 char label2[MAX_ARTIFICIAL_LABEL_BYTES];
738 int totsize;
739
740 totsize = 0;
741
742 rtnend.dst_a_rtnend_header.dst__header_length.dst_w_length
743 = DST_K_RTNEND_SIZE - 1;
744 rtnend.dst_a_rtnend_header.dst__header_type.dst_w_type = DST_K_RTNEND;
745 rtnend.dst_b_rtnend_unused = 0;
746 rtnend.dst_l_rtnend_size = 0; /* Calculated below. */
747
748 totsize += write_debug_header (&rtnend.dst_a_rtnend_header, "rtnend",
749 dosizeonly);
750 totsize += write_debug_data1 (rtnend.dst_b_rtnend_unused, "unused",
751 dosizeonly);
752
753 ASM_GENERATE_INTERNAL_LABEL
754 (label1, FUNC_BEGIN_LABEL,
755 funcnum_table[rtnnum]);
756 ASM_GENERATE_INTERNAL_LABEL
757 (label2, FUNC_END_LABEL,
758 funcnum_table[rtnnum]);
759 totsize += write_debug_delta4 (label2, label1, "routine size", dosizeonly);
760
761 return totsize;
762 }
763
764 #define K_DELTA_PC(I) \
765 ((I) < 128 ? -(I) : (I) < 65536 ? DST_K_DELTA_PC_W : DST_K_DELTA_PC_L)
766
767 #define K_SET_LINUM(I) \
768 ((I) < 256 ? DST_K_SET_LINUM_B \
769 : (I) < 65536 ? DST_K_SET_LINUM : DST_K_SET_LINUM_L)
770
771 #define K_INCR_LINUM(I) \
772 ((I) < 256 ? DST_K_INCR_LINUM \
773 : (I) < 65536 ? DST_K_INCR_LINUM_W : DST_K_INCR_LINUM_L)
774
775 /* Output the PC to line number correlations and return the size. Just return
776 the size if DOSIZEONLY is nonzero */
777
778 static int
779 write_pclines (int dosizeonly)
780 {
781 unsigned i;
782 int fn;
783 int ln, lastln;
784 int linestart = 0;
785 int max_line;
786 DST_LINE_NUM_HEADER line_num;
787 DST_PCLINE_COMMANDS pcline;
788 char label[MAX_ARTIFICIAL_LABEL_BYTES];
789 char lastlabel[MAX_ARTIFICIAL_LABEL_BYTES];
790 int totsize = 0;
791 char buff[256];
792
793 max_line = file_info_table[1].max_line;
794 file_info_table[1].listing_line_start = linestart;
795 linestart = linestart + ((max_line / 100000) + 1) * 100000;
796
797 for (i = 2; i < file_info_table_in_use; i++)
798 {
799 max_line = file_info_table[i].max_line;
800 file_info_table[i].listing_line_start = linestart;
801 linestart = linestart + ((max_line / 10000) + 1) * 10000;
802 }
803
804 /* Set starting address to beginning of text section. */
805 line_num.dst_a_line_num_header.dst__header_length.dst_w_length = 8;
806 line_num.dst_a_line_num_header.dst__header_type.dst_w_type = DST_K_LINE_NUM;
807 pcline.dst_b_pcline_command = DST_K_SET_ABS_PC;
808
809 totsize += write_debug_header (&line_num.dst_a_line_num_header,
810 "line_num", dosizeonly);
811 totsize += write_debug_data1 (pcline.dst_b_pcline_command,
812 "line_num (SET ABS PC)", dosizeonly);
813
814 if (dosizeonly)
815 totsize += 4;
816 else
817 {
818 ASM_OUTPUT_DEBUG_ADDR (asm_out_file, TEXT_SECTION_ASM_OP);
819 if (flag_verbose_asm)
820 fprintf (asm_out_file, "\t%s line_num", ASM_COMMENT_START);
821 fputc ('\n', asm_out_file);
822 }
823
824 fn = line_info_table[1].dst_file_num;
825 ln = (file_info_table[fn].listing_line_start
826 + line_info_table[1].dst_line_num);
827 line_num.dst_a_line_num_header.dst__header_length.dst_w_length = 4 + 4;
828 pcline.dst_b_pcline_command = DST_K_SET_LINUM_L;
829
830 totsize += write_debug_header (&line_num.dst_a_line_num_header,
831 "line_num", dosizeonly);
832 totsize += write_debug_data1 (pcline.dst_b_pcline_command,
833 "line_num (SET LINUM LONG)", dosizeonly);
834
835 sprintf (buff, "line_num (%d)", ln ? ln - 1 : 0);
836 totsize += write_debug_data4 (ln ? ln - 1 : 0, buff, dosizeonly);
837
838 lastln = ln;
839 strcpy (lastlabel, TEXT_SECTION_ASM_OP);
840 for (i = 1; i < line_info_table_in_use; i++)
841 {
842 int extrabytes;
843
844 fn = line_info_table[i].dst_file_num;
845 ln = (file_info_table[fn].listing_line_start
846 + line_info_table[i].dst_line_num);
847
848 if (ln - lastln > 1)
849 extrabytes = 5; /* NUMBYTES (ln - lastln - 1) + 1; */
850 else if (ln <= lastln)
851 extrabytes = 5; /* NUMBYTES (ln - 1) + 1; */
852 else
853 extrabytes = 0;
854
855 line_num.dst_a_line_num_header.dst__header_length.dst_w_length
856 = 8 + extrabytes;
857
858 totsize += write_debug_header
859 (&line_num.dst_a_line_num_header, "line_num", dosizeonly);
860
861 if (ln - lastln > 1)
862 {
863 int lndif = ln - lastln - 1;
864
865 /* K_INCR_LINUM (lndif); */
866 pcline.dst_b_pcline_command = DST_K_INCR_LINUM_L;
867
868 totsize += write_debug_data1 (pcline.dst_b_pcline_command,
869 "line_num (INCR LINUM LONG)",
870 dosizeonly);
871
872 sprintf (buff, "line_num (%d)", lndif);
873 totsize += write_debug_data4 (lndif, buff, dosizeonly);
874 }
875 else if (ln <= lastln)
876 {
877 /* K_SET_LINUM (ln-1); */
878 pcline.dst_b_pcline_command = DST_K_SET_LINUM_L;
879
880 totsize += write_debug_data1 (pcline.dst_b_pcline_command,
881 "line_num (SET LINUM LONG)",
882 dosizeonly);
883
884 sprintf (buff, "line_num (%d)", ln - 1);
885 totsize += write_debug_data4 (ln - 1, buff, dosizeonly);
886 }
887
888 pcline.dst_b_pcline_command = DST_K_DELTA_PC_L;
889
890 totsize += write_debug_data1 (pcline.dst_b_pcline_command,
891 "line_num (DELTA PC LONG)", dosizeonly);
892
893 ASM_GENERATE_INTERNAL_LABEL (label, LINE_CODE_LABEL, i);
894 totsize += write_debug_delta4 (label, lastlabel, "increment line_num",
895 dosizeonly);
896
897 lastln = ln;
898 strcpy (lastlabel, label);
899 }
900
901 return totsize;
902 }
903
904 /* Output a source correlation for file FILEID using information saved in
905 FILE_INFO_ENTRY and return the size. Just return the size if DOSIZEONLY is
906 nonzero. */
907
908 static int
909 write_srccorr (int fileid, dst_file_info_entry file_info_entry,
910 int dosizeonly)
911 {
912 int src_command_size;
913 int linesleft = file_info_entry.max_line;
914 int linestart = file_info_entry.listing_line_start;
915 int flen = strlen (file_info_entry.file_name);
916 int linestodo = 0;
917 DST_SOURCE_CORR src_header;
918 DST_SRC_COMMAND src_command;
919 DST_SRC_COMMAND src_command_sf;
920 DST_SRC_COMMAND src_command_sl;
921 DST_SRC_COMMAND src_command_sr;
922 DST_SRC_COMMAND src_command_dl;
923 DST_SRC_CMDTRLR src_cmdtrlr;
924 char buff[256];
925 int totsize = 0;
926
927 if (fileid == 1)
928 {
929 src_header.dst_a_source_corr_header.dst__header_length.dst_w_length
930 = DST_K_SOURCE_CORR_HEADER_SIZE + 1 - 1;
931 src_header.dst_a_source_corr_header.dst__header_type.dst_w_type
932 = DST_K_SOURCE;
933 src_command.dst_b_src_command = DST_K_SRC_FORMFEED;
934
935 totsize += write_debug_header (&src_header.dst_a_source_corr_header,
936 "source corr", dosizeonly);
937
938 totsize += write_debug_data1 (src_command.dst_b_src_command,
939 "source_corr (SRC FORMFEED)",
940 dosizeonly);
941 }
942
943 src_command_size
944 = DST_K_SRC_COMMAND_SIZE + flen + DST_K_SRC_CMDTRLR_SIZE;
945 src_command.dst_b_src_command = DST_K_SRC_DECLFILE;
946 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_length
947 = src_command_size - 2;
948 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_flags = 0;
949 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_w_src_df_fileid
950 = fileid;
951 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_q_src_df_rms_cdt
952 = file_info_entry.cdt;
953 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_l_src_df_rms_ebk
954 = file_info_entry.ebk;
955 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_w_src_df_rms_ffb
956 = file_info_entry.ffb;
957 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_rms_rfo
958 = file_info_entry.rfo;
959 src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_filename
960 = flen;
961
962 src_header.dst_a_source_corr_header.dst__header_length.dst_w_length
963 = DST_K_SOURCE_CORR_HEADER_SIZE + src_command_size - 1;
964 src_header.dst_a_source_corr_header.dst__header_type.dst_w_type
965 = DST_K_SOURCE;
966
967 src_cmdtrlr.dst_b_src_df_libmodname = 0;
968
969 totsize += write_debug_header (&src_header.dst_a_source_corr_header,
970 "source corr", dosizeonly);
971 totsize += write_debug_data1 (src_command.dst_b_src_command,
972 "source_corr (DECL SRC FILE)", dosizeonly);
973 totsize += write_debug_data1
974 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_length,
975 "source_corr (length)", dosizeonly);
976
977 totsize += write_debug_data1
978 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_flags,
979 "source_corr (flags)", dosizeonly);
980
981 totsize += write_debug_data2
982 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_w_src_df_fileid,
983 "source_corr (fileid)", dosizeonly);
984
985 totsize += write_debug_data8
986 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_q_src_df_rms_cdt,
987 "source_corr (creation date)", dosizeonly);
988
989 totsize += write_debug_data4
990 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_l_src_df_rms_ebk,
991 "source_corr (EOF block number)", dosizeonly);
992
993 totsize += write_debug_data2
994 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_w_src_df_rms_ffb,
995 "source_corr (first free byte)", dosizeonly);
996
997 totsize += write_debug_data1
998 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_rms_rfo,
999 "source_corr (record and file organization)", dosizeonly);
1000
1001 totsize += write_debug_data1
1002 (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_b_src_df_filename,
1003 "source_corr (filename length)", dosizeonly);
1004
1005 totsize += write_debug_string (remap_debug_filename (
1006 file_info_entry.file_name),
1007 "source file name", dosizeonly);
1008 totsize += write_debug_data1 (src_cmdtrlr.dst_b_src_df_libmodname,
1009 "source_corr (libmodname)", dosizeonly);
1010
1011 src_command_sf.dst_b_src_command = DST_K_SRC_SETFILE;
1012 src_command_sf.dst_a_src_cmd_fields.dst_w_src_unsword = fileid;
1013
1014 src_command_sr.dst_b_src_command = DST_K_SRC_SETREC_W;
1015 src_command_sr.dst_a_src_cmd_fields.dst_w_src_unsword = 1;
1016
1017 src_command_sl.dst_b_src_command = DST_K_SRC_SETLNUM_L;
1018 src_command_sl.dst_a_src_cmd_fields.dst_l_src_unslong = linestart + 1;
1019
1020 src_command_dl.dst_b_src_command = DST_K_SRC_DEFLINES_W;
1021
1022 if (linesleft > 65534)
1023 linesleft = linesleft - 65534, linestodo = 65534;
1024 else
1025 linestodo = linesleft, linesleft = 0;
1026
1027 src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword = linestodo;
1028
1029 src_header.dst_a_source_corr_header.dst__header_length.dst_w_length
1030 = DST_K_SOURCE_CORR_HEADER_SIZE + 3 + 3 + 5 + 3 - 1;
1031 src_header.dst_a_source_corr_header.dst__header_type.dst_w_type
1032 = DST_K_SOURCE;
1033
1034 if (src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword)
1035 {
1036 totsize += write_debug_header (&src_header.dst_a_source_corr_header,
1037 "source corr", dosizeonly);
1038
1039 totsize += write_debug_data1 (src_command_sf.dst_b_src_command,
1040 "source_corr (src setfile)", dosizeonly);
1041
1042 totsize += write_debug_data2
1043 (src_command_sf.dst_a_src_cmd_fields.dst_w_src_unsword,
1044 "source_corr (fileid)", dosizeonly);
1045
1046 totsize += write_debug_data1 (src_command_sr.dst_b_src_command,
1047 "source_corr (setrec)", dosizeonly);
1048
1049 totsize += write_debug_data2
1050 (src_command_sr.dst_a_src_cmd_fields.dst_w_src_unsword,
1051 "source_corr (recnum)", dosizeonly);
1052
1053 totsize += write_debug_data1 (src_command_sl.dst_b_src_command,
1054 "source_corr (setlnum)", dosizeonly);
1055
1056 totsize += write_debug_data4
1057 (src_command_sl.dst_a_src_cmd_fields.dst_l_src_unslong,
1058 "source_corr (linenum)", dosizeonly);
1059
1060 totsize += write_debug_data1 (src_command_dl.dst_b_src_command,
1061 "source_corr (deflines)", dosizeonly);
1062
1063 sprintf (buff, "source_corr (%d)",
1064 src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword);
1065 totsize += write_debug_data2
1066 (src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword,
1067 buff, dosizeonly);
1068
1069 while (linesleft > 0)
1070 {
1071 src_header.dst_a_source_corr_header.dst__header_length.dst_w_length
1072 = DST_K_SOURCE_CORR_HEADER_SIZE + 3 - 1;
1073 src_header.dst_a_source_corr_header.dst__header_type.dst_w_type
1074 = DST_K_SOURCE;
1075 src_command_dl.dst_b_src_command = DST_K_SRC_DEFLINES_W;
1076
1077 if (linesleft > 65534)
1078 linesleft = linesleft - 65534, linestodo = 65534;
1079 else
1080 linestodo = linesleft, linesleft = 0;
1081
1082 src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword = linestodo;
1083
1084 totsize += write_debug_header (&src_header.dst_a_source_corr_header,
1085 "source corr", dosizeonly);
1086 totsize += write_debug_data1 (src_command_dl.dst_b_src_command,
1087 "source_corr (deflines)", dosizeonly);
1088 sprintf (buff, "source_corr (%d)",
1089 src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword);
1090 totsize += write_debug_data2
1091 (src_command_dl.dst_a_src_cmd_fields.dst_w_src_unsword,
1092 buff, dosizeonly);
1093 }
1094 }
1095
1096 return totsize;
1097 }
1098
1099 /* Output all the source correlation entries and return the size. Just return
1100 the size if DOSIZEONLY is nonzero. */
1101
1102 static int
1103 write_srccorrs (int dosizeonly)
1104 {
1105 unsigned int i;
1106 int totsize = 0;
1107
1108 for (i = 1; i < file_info_table_in_use; i++)
1109 totsize += write_srccorr (i, file_info_table[i], dosizeonly);
1110
1111 return totsize;
1112 }
1113 \f
1114 /* Output a marker (i.e. a label) for the beginning of a function, before
1115 the prologue. */
1116
1117 static void
1118 vmsdbgout_begin_prologue (unsigned int line, const char *file)
1119 {
1120 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1121
1122 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1123 (*dwarf2_debug_hooks.begin_prologue) (line, file);
1124
1125 if (debug_info_level > DINFO_LEVEL_NONE)
1126 {
1127 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
1128 current_function_funcdef_no);
1129 ASM_OUTPUT_LABEL (asm_out_file, label);
1130 }
1131 }
1132
1133 /* Output a marker (i.e. a label) for the beginning of a function, after
1134 the prologue. */
1135
1136 static void
1137 vmsdbgout_end_prologue (unsigned int line, const char *file)
1138 {
1139 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1140
1141 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1142 (*dwarf2_debug_hooks.end_prologue) (line, file);
1143
1144 if (debug_info_level > DINFO_LEVEL_TERSE)
1145 {
1146 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_PROLOG_LABEL,
1147 current_function_funcdef_no);
1148 ASM_OUTPUT_LABEL (asm_out_file, label);
1149
1150 /* VMS PCA expects every PC range to correlate to some line and file. */
1151 vmsdbgout_write_source_line (line, file, 0, true);
1152 }
1153 }
1154
1155 /* No output for VMS debug, but make obligatory call to Dwarf2 debug */
1156
1157 static void
1158 vmsdbgout_end_function (unsigned int line)
1159 {
1160 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1161 (*dwarf2_debug_hooks.end_function) (line);
1162 }
1163
1164 /* Output a marker (i.e. a label) for the beginning of the epilogue.
1165 This gets called *before* the epilogue code has been generated. */
1166
1167 static void
1168 vmsdbgout_begin_epilogue (unsigned int line, const char *file)
1169 {
1170 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1171 static int save_current_function_funcdef_no = -1;
1172
1173 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1174 (*dwarf2_debug_hooks.begin_epilogue) (line, file);
1175
1176 if (debug_info_level > DINFO_LEVEL_NONE)
1177 {
1178 if (save_current_function_funcdef_no != current_function_funcdef_no)
1179 {
1180 /* Output a label to mark the endpoint of the code generated for this
1181 function. */
1182 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_EPILOG_LABEL,
1183 current_function_funcdef_no);
1184
1185 ASM_OUTPUT_LABEL (asm_out_file, label);
1186
1187 save_current_function_funcdef_no = current_function_funcdef_no;
1188
1189 /* VMS PCA expects every PC range to correlate to some line and
1190 file. */
1191 vmsdbgout_write_source_line (line, file, 0, true);
1192 }
1193 }
1194 }
1195
1196 /* Output a marker (i.e. a label) for the absolute end of the generated code
1197 for a function definition. This gets called *after* the epilogue code has
1198 been generated. */
1199
1200 static void
1201 vmsdbgout_end_epilogue (unsigned int line, const char *file)
1202 {
1203 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1204
1205 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1206 (*dwarf2_debug_hooks.end_epilogue) (line, file);
1207
1208 if (debug_info_level > DINFO_LEVEL_NONE)
1209 {
1210 /* Output a label to mark the endpoint of the code generated for this
1211 function. */
1212 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
1213 current_function_funcdef_no);
1214 ASM_OUTPUT_LABEL (asm_out_file, label);
1215
1216 /* VMS PCA expects every PC range to correlate to some line and file. */
1217 vmsdbgout_write_source_line (line, file, 0, true);
1218 }
1219 }
1220
1221 /* Output a marker (i.e. a label) for the beginning of the generated code for
1222 a lexical block. */
1223
1224 static void
1225 vmsdbgout_begin_block (register unsigned line, register unsigned blocknum)
1226 {
1227 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1228 (*dwarf2_debug_hooks.begin_block) (line, blocknum);
1229
1230 if (debug_info_level > DINFO_LEVEL_TERSE)
1231 targetm.asm_out.internal_label (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
1232 }
1233
1234 /* Output a marker (i.e. a label) for the end of the generated code for a
1235 lexical block. */
1236
1237 static void
1238 vmsdbgout_end_block (register unsigned line, register unsigned blocknum)
1239 {
1240 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1241 (*dwarf2_debug_hooks.end_block) (line, blocknum);
1242
1243 if (debug_info_level > DINFO_LEVEL_TERSE)
1244 targetm.asm_out.internal_label (asm_out_file, BLOCK_END_LABEL, blocknum);
1245 }
1246
1247 /* Not implemented in VMS Debug. */
1248
1249 static bool
1250 vmsdbgout_ignore_block (const_tree block)
1251 {
1252 bool retval = 0;
1253
1254 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1255 retval = (*dwarf2_debug_hooks.ignore_block) (block);
1256
1257 return retval;
1258 }
1259
1260 /* Add an entry for function DECL into the funcnam_table. */
1261
1262 static void
1263 vmsdbgout_begin_function (tree decl)
1264 {
1265 const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
1266
1267 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1268 (*dwarf2_debug_hooks.begin_function) (decl);
1269
1270 /* Add the new entry to the end of the function name table. */
1271 funcnam_table.safe_push (xstrdup (name));
1272 funcnum_table.safe_push (current_function_funcdef_no);
1273 }
1274
1275 static char fullname_buff [4096];
1276
1277 /* Return the full file specification for FILENAME. The specification must be
1278 in VMS syntax in order to be processed by VMS Debug. */
1279
1280 static char *
1281 full_name (const char *filename)
1282 {
1283 #ifdef VMS
1284 FILE *fp = fopen (filename, "r");
1285
1286 fgetname (fp, fullname_buff, 1);
1287 fclose (fp);
1288 #else
1289 /* Unix paths really mess up VMS debug. Better to just output the
1290 base filename. */
1291 strcpy (fullname_buff, filename);
1292 #endif
1293
1294 return fullname_buff;
1295 }
1296
1297 /* Lookup a filename (in the list of filenames that we know about here in
1298 vmsdbgout.c) and return its "index". The index of each (known) filename is
1299 just a unique number which is associated with only that one filename. We
1300 need such numbers for the sake of generating labels and references
1301 to those files numbers. If the filename given as an argument is not
1302 found in our current list, add it to the list and assign it the next
1303 available unique index number. In order to speed up searches, we remember
1304 the index of the filename was looked up last. This handles the majority of
1305 all searches. */
1306
1307 static unsigned int
1308 lookup_filename (const char *file_name)
1309 {
1310 static unsigned int last_file_lookup_index = 0;
1311 register char *fn;
1312 register unsigned i;
1313 const char *fnam;
1314 long long cdt = 0;
1315 long ebk = 0;
1316 short ffb = 0;
1317 char rfo = 0;
1318 long siz = 0;
1319 int ver = 0;
1320
1321 fnam = full_name (file_name);
1322
1323 /* Check to see if the file name that was searched on the previous call
1324 matches this file name. If so, return the index. */
1325 if (last_file_lookup_index != 0)
1326 {
1327 fn = file_info_table[last_file_lookup_index].file_name;
1328 if (strcmp (fnam, fn) == 0)
1329 return last_file_lookup_index;
1330 }
1331
1332 /* Didn't match the previous lookup, search the table */
1333 for (i = 1; i < file_info_table_in_use; ++i)
1334 {
1335 fn = file_info_table[i].file_name;
1336 if (strcmp (fnam, fn) == 0)
1337 {
1338 last_file_lookup_index = i;
1339 return i;
1340 }
1341 }
1342
1343 /* Prepare to add a new table entry by making sure there is enough space in
1344 the table to do so. If not, expand the current table. */
1345 if (file_info_table_in_use == file_info_table_allocated)
1346 {
1347
1348 file_info_table_allocated += FILE_TABLE_INCREMENT;
1349 file_info_table = XRESIZEVEC (dst_file_info_entry, file_info_table,
1350 file_info_table_allocated);
1351 }
1352
1353 if (vms_file_stats_name (file_name, &cdt, &siz, &rfo, &ver) == 0)
1354 {
1355 ebk = siz / 512 + 1;
1356 ffb = siz - ((siz / 512) * 512);
1357 }
1358
1359 /* Add the new entry to the end of the filename table. */
1360 file_info_table[file_info_table_in_use].file_name = xstrdup (fnam);
1361 file_info_table[file_info_table_in_use].max_line = 0;
1362 file_info_table[file_info_table_in_use].cdt = cdt;
1363 file_info_table[file_info_table_in_use].ebk = ebk;
1364 file_info_table[file_info_table_in_use].ffb = ffb;
1365 file_info_table[file_info_table_in_use].rfo = rfo;
1366
1367 last_file_lookup_index = file_info_table_in_use++;
1368 return last_file_lookup_index;
1369 }
1370
1371 /* Output a label to mark the beginning of a source code line entry
1372 and record information relating to this source line, in
1373 'line_info_table' for later output of the .debug_line section. */
1374
1375 static void
1376 vmsdbgout_write_source_line (unsigned line, const char *filename,
1377 int /* discriminator */, bool /* is_stmt */)
1378 {
1379 dst_line_info_ref line_info;
1380
1381 targetm.asm_out.internal_label (asm_out_file, LINE_CODE_LABEL,
1382 line_info_table_in_use);
1383
1384 /* Expand the line info table if necessary. */
1385 if (line_info_table_in_use == line_info_table_allocated)
1386 {
1387 line_info_table_allocated += LINE_INFO_TABLE_INCREMENT;
1388 line_info_table = XRESIZEVEC (dst_line_info_entry, line_info_table,
1389 line_info_table_allocated);
1390 }
1391
1392 /* Add the new entry at the end of the line_info_table. */
1393 line_info = &line_info_table[line_info_table_in_use++];
1394 line_info->dst_file_num = lookup_filename (filename);
1395 line_info->dst_line_num = line;
1396 if (line > file_info_table[line_info->dst_file_num].max_line)
1397 file_info_table[line_info->dst_file_num].max_line = line;
1398 }
1399
1400 static void
1401 vmsdbgout_source_line (register unsigned line, register const char *filename,
1402 int discriminator, bool is_stmt)
1403 {
1404 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1405 (*dwarf2_debug_hooks.source_line) (line, filename, discriminator, is_stmt);
1406
1407 if (debug_info_level >= DINFO_LEVEL_TERSE)
1408 vmsdbgout_write_source_line (line, filename, discriminator, is_stmt);
1409 }
1410
1411 /* Record the beginning of a new source file, for later output.
1412 At present, unimplemented. */
1413
1414 static void
1415 vmsdbgout_start_source_file (unsigned int lineno, const char *filename)
1416 {
1417 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1418 (*dwarf2_debug_hooks.start_source_file) (lineno, filename);
1419 }
1420
1421 /* Record the end of a source file, for later output.
1422 At present, unimplemented. */
1423
1424 static void
1425 vmsdbgout_end_source_file (unsigned int lineno ATTRIBUTE_UNUSED)
1426 {
1427 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1428 (*dwarf2_debug_hooks.end_source_file) (lineno);
1429 }
1430
1431 /* Set up for Debug output at the start of compilation. */
1432
1433 static void
1434 vmsdbgout_init (const char *filename)
1435 {
1436 const char *language_string = lang_hooks.name;
1437
1438 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1439 (*dwarf2_debug_hooks.init) (filename);
1440
1441 if (debug_info_level == DINFO_LEVEL_NONE)
1442 return;
1443
1444 /* Remember the name of the primary input file. */
1445 primary_filename = filename;
1446
1447 /* Allocate the initial hunk of the file_info_table. */
1448 file_info_table = XCNEWVEC (dst_file_info_entry, FILE_TABLE_INCREMENT);
1449 file_info_table_allocated = FILE_TABLE_INCREMENT;
1450 /* Skip the first entry - file numbers begin at 1. */
1451 file_info_table_in_use = 1;
1452
1453 funcnam_table.create (FUNC_TABLE_INITIAL);
1454 funcnum_table.create (FUNC_TABLE_INITIAL);
1455
1456 /* Allocate the initial hunk of the line_info_table. */
1457 line_info_table = XCNEWVEC (dst_line_info_entry, LINE_INFO_TABLE_INCREMENT);
1458 line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
1459 /* zero-th entry is allocated, but unused */
1460 line_info_table_in_use = 1;
1461
1462 lookup_filename (primary_filename);
1463
1464 if (lang_GNU_C ())
1465 module_language = DST_K_C;
1466 else if (lang_GNU_CXX ())
1467 module_language = DST_K_CXX;
1468 else if (!strcmp (language_string, "GNU Ada"))
1469 module_language = DST_K_ADA;
1470 else if (!strcmp (language_string, "GNU F77"))
1471 module_language = DST_K_FORTRAN;
1472 else
1473 module_language = DST_K_UNKNOWN;
1474
1475 module_producer = concat (language_string, " ", version_string, NULL);
1476
1477 ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
1478
1479 }
1480
1481 /* Not implemented in VMS Debug. */
1482
1483 static void
1484 vmsdbgout_assembly_start (void)
1485 {
1486 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1487 (*dwarf2_debug_hooks.assembly_start) ();
1488 }
1489
1490 /* Not implemented in VMS Debug. */
1491
1492 static void
1493 vmsdbgout_define (unsigned int lineno, const char *buffer)
1494 {
1495 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1496 (*dwarf2_debug_hooks.define) (lineno, buffer);
1497 }
1498
1499 /* Not implemented in VMS Debug. */
1500
1501 static void
1502 vmsdbgout_undef (unsigned int lineno, const char *buffer)
1503 {
1504 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1505 (*dwarf2_debug_hooks.undef) (lineno, buffer);
1506 }
1507
1508 /* Not implemented in VMS Debug. */
1509
1510 static void
1511 vmsdbgout_function_decl (tree decl)
1512 {
1513 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1514 (*dwarf2_debug_hooks.function_decl) (decl);
1515 }
1516
1517 /* Not implemented in VMS Debug. */
1518
1519 static void
1520 vmsdbgout_early_global_decl (tree decl)
1521 {
1522 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1523 (*dwarf2_debug_hooks.early_global_decl) (decl);
1524 }
1525
1526 /* Not implemented in VMS Debug. */
1527
1528 static void
1529 vmsdbgout_late_global_decl (tree decl)
1530 {
1531 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1532 (*dwarf2_debug_hooks.late_global_decl) (decl);
1533 }
1534
1535 /* Not implemented in VMS Debug. */
1536
1537 static void
1538 vmsdbgout_type_decl (tree decl, int local)
1539 {
1540 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1541 (*dwarf2_debug_hooks.type_decl) (decl, local);
1542 }
1543
1544 /* Not implemented in VMS Debug. */
1545
1546 static void
1547 vmsdbgout_abstract_function (tree decl)
1548 {
1549 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1550 (*dwarf2_debug_hooks.outlining_inline_function) (decl);
1551 }
1552
1553 /* Output stuff that Debug requires at the end of every file and generate the
1554 VMS Debug debugging info. */
1555
1556 static void
1557 vmsdbgout_finish (const char *filename ATTRIBUTE_UNUSED)
1558 {
1559 unsigned int i, ifunc;
1560 int totsize;
1561
1562 if (write_symbols == VMS_AND_DWARF2_DEBUG)
1563 (*dwarf2_debug_hooks.finish) (filename);
1564
1565 if (debug_info_level == DINFO_LEVEL_NONE)
1566 return;
1567
1568 /* Output a terminator label for the .text section. */
1569 switch_to_section (text_section);
1570 targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
1571
1572 /* Output debugging information.
1573 Warning! Do not change the name of the .vmsdebug section without
1574 changing it in the assembler also. */
1575 switch_to_section (get_named_section (NULL, ".vmsdebug", 0));
1576 ASM_OUTPUT_ALIGN (asm_out_file, 0);
1577
1578 totsize = write_modbeg (1);
1579 FOR_EACH_VEC_ELT (funcnum_table, i, ifunc)
1580 {
1581 totsize += write_rtnbeg (i, 1);
1582 totsize += write_rtnend (i, 1);
1583 }
1584 totsize += write_pclines (1);
1585
1586 write_modbeg (0);
1587 FOR_EACH_VEC_ELT (funcnum_table, i, ifunc)
1588 {
1589 write_rtnbeg (i, 0);
1590 write_rtnend (i, 0);
1591 }
1592 write_pclines (0);
1593
1594 if (debug_info_level > DINFO_LEVEL_TERSE)
1595 {
1596 totsize = write_srccorrs (1);
1597 write_srccorrs (0);
1598 }
1599
1600 totsize = write_modend (1);
1601 write_modend (0);
1602 }
1603
1604 /* Need for both Dwarf2 on IVMS and VMS Debug on AVMS */
1605
1606 #ifdef VMS
1607 #define __NEW_STARLET 1
1608 #include <vms/rms.h>
1609 #include <vms/atrdef.h>
1610 #include <vms/fibdef.h>
1611 #include <vms/stsdef.h>
1612 #include <vms/iodef.h>
1613 #include <vms/fatdef.h>
1614 #include <vms/descrip.h>
1615 #include <unixlib.h>
1616
1617 #define MAXPATH 256
1618
1619 /* descrip.h doesn't have everything ... */
1620 typedef struct fibdef* __fibdef_ptr32 __attribute__ (( mode (SI) ));
1621 struct dsc$descriptor_fib
1622 {
1623 unsigned int fib$l_len;
1624 __fibdef_ptr32 fib$l_addr;
1625 };
1626
1627 /* I/O Status Block. */
1628 struct IOSB
1629 {
1630 unsigned short status, count;
1631 unsigned int devdep;
1632 };
1633
1634 static char *tryfile;
1635
1636 /* Variable length string. */
1637 struct vstring
1638 {
1639 short length;
1640 char string[NAM$C_MAXRSS+1];
1641 };
1642
1643 static char filename_buff [MAXPATH];
1644 static char vms_filespec [MAXPATH];
1645
1646 /* Callback function for filespec style conversion. */
1647
1648 static int
1649 translate_unix (char *name, int type ATTRIBUTE_UNUSED)
1650 {
1651 strncpy (filename_buff, name, MAXPATH);
1652 filename_buff [MAXPATH - 1] = (char) 0;
1653 return 0;
1654 }
1655
1656 /* Wrapper for DECC function that converts a Unix filespec
1657 to VMS style filespec. */
1658
1659 static char *
1660 to_vms_file_spec (char *filespec)
1661 {
1662 strncpy (vms_filespec, "", MAXPATH);
1663 decc$to_vms (filespec, translate_unix, 1, 1);
1664 strncpy (vms_filespec, filename_buff, MAXPATH);
1665
1666 vms_filespec [MAXPATH - 1] = (char) 0;
1667
1668 return vms_filespec;
1669 }
1670
1671 #else
1672 #define VMS_EPOCH_OFFSET 35067168000000000LL
1673 #define VMS_GRANULARITY_FACTOR 10000000
1674 #endif
1675
1676 /* Return VMS file date, size, format, version given a name. */
1677
1678 int
1679 vms_file_stats_name (const char *filename, long long *cdt, long *siz, char *rfo,
1680 int *ver)
1681 {
1682 #ifdef VMS
1683 struct FAB fab;
1684 struct NAM nam;
1685
1686 unsigned long long create;
1687 FAT recattr;
1688 char ascnamebuff [256];
1689
1690 ATRDEF atrlst[]
1691 = {
1692 { ATR$S_CREDATE, ATR$C_CREDATE, &create },
1693 { ATR$S_RECATTR, ATR$C_RECATTR, &recattr },
1694 { ATR$S_ASCNAME, ATR$C_ASCNAME, &ascnamebuff },
1695 { 0, 0, 0}
1696 };
1697
1698 FIBDEF fib;
1699 struct dsc$descriptor_fib fibdsc = {sizeof (fib), (void *) &fib};
1700
1701 struct IOSB iosb;
1702
1703 long status;
1704 unsigned short chan;
1705
1706 struct vstring file;
1707 struct dsc$descriptor_s filedsc
1708 = {NAM$C_MAXRSS, DSC$K_DTYPE_T, DSC$K_CLASS_S, (void *) file.string};
1709 struct vstring device;
1710 struct dsc$descriptor_s devicedsc
1711 = {NAM$C_MAXRSS, DSC$K_DTYPE_T, DSC$K_CLASS_S, (void *) device.string};
1712 struct vstring result;
1713 struct dsc$descriptor_s resultdsc
1714 = {NAM$C_MAXRSS, DSC$K_DTYPE_VT, DSC$K_CLASS_VS, (void *) result.string};
1715
1716 if (strcmp (filename, "<internal>") == 0
1717 || strcmp (filename, "<built-in>") == 0)
1718 {
1719 if (cdt)
1720 *cdt = 0;
1721
1722 if (siz)
1723 *siz = 0;
1724
1725 if (rfo)
1726 *rfo = 0;
1727
1728 if (ver)
1729 *ver = 0;
1730
1731 return 0;
1732 }
1733
1734 tryfile = to_vms_file_spec (filename);
1735
1736 /* Allocate and initialize a FAB and NAM structures. */
1737 fab = cc$rms_fab;
1738 nam = cc$rms_nam;
1739
1740 nam.nam$l_esa = file.string;
1741 nam.nam$b_ess = NAM$C_MAXRSS;
1742 nam.nam$l_rsa = result.string;
1743 nam.nam$b_rss = NAM$C_MAXRSS;
1744 fab.fab$l_fna = tryfile;
1745 fab.fab$b_fns = strlen (tryfile);
1746 fab.fab$l_nam = &nam;
1747
1748 /* Validate filespec syntax and device existence. */
1749 status = SYS$PARSE (&fab, 0, 0);
1750 if ((status & 1) != 1)
1751 return 1;
1752
1753 file.string[nam.nam$b_esl] = 0;
1754
1755 /* Find matching filespec. */
1756 status = SYS$SEARCH (&fab, 0, 0);
1757 if ((status & 1) != 1)
1758 return 1;
1759
1760 file.string[nam.nam$b_esl] = 0;
1761 result.string[result.length=nam.nam$b_rsl] = 0;
1762
1763 /* Get the device name and assign an IO channel. */
1764 strncpy (device.string, nam.nam$l_dev, nam.nam$b_dev);
1765 devicedsc.dsc$w_length = nam.nam$b_dev;
1766 chan = 0;
1767 status = SYS$ASSIGN (&devicedsc, &chan, 0, 0, 0);
1768 if ((status & 1) != 1)
1769 return 1;
1770
1771 /* Initialize the FIB and fill in the directory id field. */
1772 memset (&fib, 0, sizeof (fib));
1773 fib.fib$w_did[0] = nam.nam$w_did[0];
1774 fib.fib$w_did[1] = nam.nam$w_did[1];
1775 fib.fib$w_did[2] = nam.nam$w_did[2];
1776 fib.fib$l_acctl = 0;
1777 fib.fib$l_wcc = 0;
1778 strcpy (file.string, (strrchr (result.string, ']') + 1));
1779 filedsc.dsc$w_length = strlen (file.string);
1780 result.string[result.length = 0] = 0;
1781
1782 /* Open and close the file to fill in the attributes. */
1783 status
1784 = SYS$QIOW (0, chan, IO$_ACCESS|IO$M_ACCESS, &iosb, 0, 0,
1785 &fibdsc, &filedsc, &result.length, &resultdsc, &atrlst, 0);
1786 if ((status & 1) != 1)
1787 return 1;
1788 if ((iosb.status & 1) != 1)
1789 return 1;
1790
1791 result.string[result.length] = 0;
1792 status = SYS$QIOW (0, chan, IO$_DEACCESS, &iosb, 0, 0, &fibdsc, 0, 0, 0,
1793 &atrlst, 0);
1794 if ((status & 1) != 1)
1795 return 1;
1796 if ((iosb.status & 1) != 1)
1797 return 1;
1798
1799 /* Deassign the channel and exit. */
1800 status = SYS$DASSGN (chan);
1801 if ((status & 1) != 1)
1802 return 1;
1803
1804 if (cdt) *cdt = create;
1805 if (siz) *siz = (512 * 65536 * recattr.fat$w_efblkh) +
1806 (512 * (recattr.fat$w_efblkl - 1)) +
1807 recattr.fat$w_ffbyte;
1808 if (rfo) *rfo = recattr.fat$v_rtype;
1809 if (ver) *ver = strtol (strrchr (ascnamebuff, ';')+1, 0, 10);
1810
1811 return 0;
1812 #else
1813 struct stat buff;
1814
1815 if ((stat (filename, &buff)) != 0)
1816 return 1;
1817
1818 if (cdt)
1819 *cdt = (long long) (buff.st_mtime * VMS_GRANULARITY_FACTOR)
1820 + VMS_EPOCH_OFFSET;
1821
1822 if (siz)
1823 *siz = buff.st_size;
1824
1825 if (rfo)
1826 *rfo = 2; /* Stream LF format */
1827
1828 if (ver)
1829 *ver = 1;
1830
1831 return 0;
1832 #endif
1833 }
1834 #endif