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