* Makefile.am: Rename .dep* files to DEP*. Change DEP variable to
[deliverable/binutils-gdb.git] / gas / dwarf2dbg.c
CommitLineData
fac0d250 1/* dwarf2dbg.c - DWARF2 debug support
89b66cde 2 Copyright (C) 1999 Free Software Foundation, Inc.
fac0d250
RH
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
89b66cde 20 02111-1307, USA. */
fac0d250 21
89b66cde 22/* Logical line numbers can be controlled by the compiler via the
fac0d250
RH
23 following two directives:
24
25 .file FILENO "file.c"
26 .loc FILENO LINENO [COLUMN]
27
28 FILENO is the filenumber. */
29
30#include "ansidecl.h"
31
32#include "as.h"
33#include "dwarf2dbg.h"
34#include "subsegs.h"
35
d9ac5a3b 36#include "elf/dwarf2.h"
fac0d250 37
fac0d250
RH
38/* Since we can't generate the prolog until the body is complete, we
39 use three different subsegments for .debug_line: one holding the
40 prolog, one for the directory and filename info, and one for the
41 body ("statement program"). */
42#define DL_PROLOG 0
43#define DL_FILES 1
44#define DL_BODY 2
45
46/* First special line opcde - leave room for the standard opcodes.
47 Note: If you want to change this, you'll have to update the
48 "standard_opcode_lengths" table that is emitted below in
49 dwarf2_finish(). */
50#define DWARF2_LINE_OPCODE_BASE 10
51
52#ifndef DWARF2_LINE_BASE
53 /* Minimum line offset in a special line info. opcode. This value
54 was chosen to give a reasonable range of values. */
55# define DWARF2_LINE_BASE -5
56#endif
57
58/* Range of line offsets in a special line info. opcode. */
59#ifndef DWARF2_LINE_RANGE
60# define DWARF2_LINE_RANGE 14
61#endif
62
63#ifndef DWARF2_LINE_MIN_INSN_LENGTH
64 /* Define the architecture-dependent minimum instruction length (in
65 bytes). This value should be rather too small than too big. */
66# define DWARF2_LINE_MIN_INSN_LENGTH 4
67#endif
68
69/* Flag that indicates the initial value of the is_stmt_start flag.
70 In the present implementation, we do not mark any lines as
71 the beginning of a source statement, because that information
72 is not made available by the GCC front-end. */
73#define DWARF2_LINE_DEFAULT_IS_STMT 1
74
75/* Flag that indicates the initial value of the is_stmt_start flag.
76 In the present implementation, we do not mark any lines as
77 the beginning of a source statement, because that information
78 is not made available by the GCC front-end. */
79#define DWARF2_LINE_DEFAULT_IS_STMT 1
80
81/* Given a special op, return the line skip amount: */
82#define SPECIAL_LINE(op) \
83 (((op) - DWARF2_LINE_OPCODE_BASE)%DWARF2_LINE_RANGE + DWARF2_LINE_BASE)
84
85/* Given a special op, return the address skip amount (in units of
86 DWARF2_LINE_MIN_INSN_LENGTH. */
87#define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)
88
89/* The maximum address skip amont that can be encoded with a special op: */
90#define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255)
91
92#define INITIAL_STATE \
93 /* initialize as per DWARF2.0 standard: */ \
94 0, /* address */ \
95 1, /* file */ \
96 1, /* line */ \
97 0, /* column */ \
98 DWARF2_LINE_DEFAULT_IS_STMT, /* is_stmt */ \
99 0, /* basic_block */ \
100 1 /* empty_sequence */
101
102static struct
103 {
104 /* state machine state as per DWARF2 manual: */
105 struct dwarf2_sm
106 {
9e3af0e7 107 addressT addr;
fac0d250
RH
108 unsigned int filenum;
109 unsigned int line;
110 unsigned int column;
111 unsigned int
112 is_stmt : 1,
113 basic_block : 1,
114 empty_sequence : 1; /* current code sequence has no DWARF2 directives? */
115 }
116 sm;
117
118 unsigned int
119 any_dwarf2_directives : 1; /* did we emit any DWARF2 line debug directives? */
120
121 segT text_seg; /* text segment "addr" is relative to */
122 subsegT text_subseg;
123 segT line_seg; /* ".debug_line" segment */
124 int last_filename; /* index of last filename that was used */
125 int num_filenames; /* index of last filename in use */
126 int filename_len; /* length of the filename array */
127 struct
128 {
129 int dir; /* valid after gen_dir_list() only */
130 char *name; /* full path before gen_dir_list(), filename afterwards */
131 }
132 *file;
133
134 struct dwarf2_line_info current; /* current source info: */
135
136 /* counters for statistical purposes: */
137 unsigned int num_line_entries;
138 unsigned int opcode_hist[256]; /* histogram of opcode frequencies */
139 }
140ls =
141 {
142 {
143 INITIAL_STATE
144 },
ab9da554
ILT
145 0,
146 0,
147 0,
148 0,
149 0,
150 0,
151 0,
152 NULL,
153 { NULL, 0, 0, 0, 0 },
154 0,
155 {
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
172 }
fac0d250
RH
173 };
174
58b5739a
RH
175
176/* Function prototypes: */
9e3af0e7
ILT
177static void out_uleb128 PARAMS ((addressT));
178static void out_sleb128 PARAMS ((offsetT));
179static void gen_addr_line PARAMS ((int, addressT));
58b5739a 180static void reset_state_machine PARAMS ((void));
9e3af0e7 181static void out_set_addr PARAMS ((addressT));
58b5739a
RH
182static void out_end_sequence PARAMS ((void));
183static int get_filenum PARAMS ((int, char *));
184static void gen_dir_list PARAMS ((void));
185static void gen_file_list PARAMS ((void));
186static void print_stats PARAMS ((unsigned long));
187
188
fac0d250
RH
189#define out_byte(byte) FRAG_APPEND_1_CHAR(byte)
190#define out_opcode(opc) (out_byte ((opc)), ++ls.opcode_hist[(opc) & 0xff])
191
192/* Output an unsigned "little-endian base 128" number. */
193static void
58b5739a 194out_uleb128 (value)
9e3af0e7 195 addressT value;
fac0d250
RH
196{
197 unsigned char byte, more = 0x80;
198
199 do
200 {
201 byte = value & 0x7f;
202 value >>= 7;
203 if (value == 0)
204 more = 0;
205 out_byte (more | byte);
206 }
207 while (more);
208}
209
210/* Output a signed "little-endian base 128" number. */
211static void
58b5739a 212out_sleb128 (value)
9e3af0e7 213 offsetT value;
fac0d250
RH
214{
215 unsigned char byte, more = 0x80;
216
217 do
218 {
219 byte = value & 0x7f;
220 value >>= 7;
221 if (((value == 0) && ((byte & 0x40) == 0))
222 || ((value == -1) && ((byte & 0x40) != 0)))
223 more = 0;
224 out_byte (more | byte);
225 }
226 while (more);
227}
228
229/* Encode a pair of line and address skips as efficiently as possible.
230 Note that the line skip is signed, whereas the address skip is
231 unsigned. */
232static void
58b5739a
RH
233gen_addr_line (line_delta, addr_delta)
234 int line_delta;
9e3af0e7 235 addressT addr_delta;
fac0d250
RH
236{
237 unsigned int tmp, opcode;
238
239 tmp = line_delta - DWARF2_LINE_BASE;
240
241 if (tmp >= DWARF2_LINE_RANGE)
242 {
243 out_opcode (DW_LNS_advance_line);
244 out_sleb128 (line_delta);
245 tmp = 0 - DWARF2_LINE_BASE;
246 line_delta = 0;
247 }
248
249 tmp += DWARF2_LINE_OPCODE_BASE;
250
251 /* try using a special opcode: */
252 opcode = tmp + addr_delta*DWARF2_LINE_RANGE;
253 if (opcode <= 255)
254 {
255 out_opcode (opcode);
256 return;
257 }
258
259 /* try using DW_LNS_const_add_pc followed by special op: */
260 opcode = tmp + (addr_delta - MAX_SPECIAL_ADDR_DELTA)*DWARF2_LINE_RANGE;
261 if (opcode <= 255)
262 {
263 out_opcode (DW_LNS_const_add_pc);
264 out_opcode (opcode);
265 return;
266 }
267
268 out_opcode (DW_LNS_advance_pc);
269 out_uleb128 (addr_delta);
270
271 if (line_delta)
272 out_opcode (tmp); /* output line-delta */
273 else
274 out_opcode (DW_LNS_copy); /* append new row with current info */
275}
276
277static void
58b5739a 278reset_state_machine ()
fac0d250
RH
279{
280 static const struct dwarf2_sm initial_state = { INITIAL_STATE };
281
282 ls.sm = initial_state;
283}
284
285/* Set an absolute address (may results in a relocation entry): */
286static void
58b5739a 287out_set_addr (addr)
9e3af0e7 288 addressT addr;
fac0d250
RH
289{
290 subsegT saved_subseg;
291 segT saved_seg;
292 expressionS expr;
293 symbolS *sym;
9e3af0e7 294 int bytes_per_address;
fac0d250
RH
295
296 saved_seg = now_seg;
297 saved_subseg = now_subseg;
298
299 subseg_set (ls.text_seg, ls.text_subseg);
300 sym = symbol_new (".L0\001", now_seg, addr, frag_now);
301
302 subseg_set (saved_seg, saved_subseg);
303
9e3af0e7
ILT
304#ifdef BFD_ASSEMBLER
305 bytes_per_address = bfd_arch_bits_per_address (stdoutput) / 8;
306#else
307 /* FIXME. */
308 bytes_per_address = 4;
309#endif
310
fac0d250 311 out_opcode (DW_LNS_extended_op);
9e3af0e7 312 out_uleb128 (bytes_per_address + 1);
fac0d250
RH
313
314 out_opcode (DW_LNE_set_address);
315 expr.X_op = O_symbol;
316 expr.X_add_symbol = sym;
317 expr.X_add_number = 0;
9e3af0e7 318 emit_expr (&expr, bytes_per_address);
fac0d250
RH
319}
320
321/* Emit DW_LNS_end_sequence and reset state machine. Does not
322 preserve the current segment/sub-segment! */
323static void
58b5739a 324out_end_sequence ()
fac0d250 325{
9e3af0e7 326 addressT addr, delta;
fac0d250
RH
327
328 if (ls.text_seg)
329 {
330 subseg_set (ls.text_seg, ls.text_subseg);
331#ifdef md_current_text_addr
332 addr = md_current_text_addr ();
333#else
334 addr = frag_now_fix ();
335#endif
336 subseg_set (ls.line_seg, DL_BODY);
337 if (addr < ls.sm.addr)
338 {
339 out_set_addr (addr);
340 ls.sm.addr = addr;
341 }
342 else
343 {
344 delta = addr - ls.sm.addr;
345 if (delta > 0)
346 gen_addr_line (0, delta / DWARF2_LINE_MIN_INSN_LENGTH);
347 }
348 }
349 else
350 subseg_set (ls.line_seg, DL_BODY);
351
352 out_opcode (DW_LNS_extended_op);
353 out_uleb128 (1);
354 out_byte (DW_LNE_end_sequence);
355
356 reset_state_machine ();
357}
358
359/* Look up a filenumber either by filename or by filenumber. If both
360 a filenumber and a filename are specified, lookup by filename takes
361 precedence. If the filename cannot be found, it is added to the
362 filetable the filenumber for the new entry is returned. */
363static int
58b5739a
RH
364get_filenum (filenum, file)
365 int filenum;
366 char *file;
fac0d250
RH
367{
368 int i, last = filenum - 1;
369 char char0 = file[0];
370
ab9da554 371 if (last >= ls.num_filenames)
fac0d250
RH
372 last = ls.last_filename;
373
374 /* do a quick check against the previously used filename: */
375 if (ls.num_filenames > 0 && ls.file[last].name[0] == char0
376 && strcmp (ls.file[last].name + 1, file + 1) == 0)
377 return last + 1;
378
379 /* no match, fall back to simple linear scan: */
380 for (i = 0; i < ls.num_filenames; ++i)
381 {
382 if (ls.file[i].name[0] == char0
383 && strcmp (ls.file[i].name + 1, file + 1) == 0)
384 {
385 ls.last_filename = i;
386 return i + 1;
387 }
388 }
389
390 /* no match: enter new filename */
391 if (ls.num_filenames >= ls.filename_len)
392 {
393 ls.filename_len += 13;
394 ls.file = xrealloc (ls.file, ls.filename_len * sizeof (ls.file[0]));
395 }
396 ls.file[ls.num_filenames].dir = 0;
397 ls.file[ls.num_filenames].name = file;
398 return ++ls.num_filenames;
399}
400
401void
58b5739a 402dwarf2_gen_line_info (addr, l)
9e3af0e7 403 addressT addr;
58b5739a 404 struct dwarf2_line_info *l;
fac0d250
RH
405{
406 unsigned int filenum = l->filenum;
407 unsigned int any_output = 0;
408 subsegT saved_subseg;
409 segT saved_seg;
fac0d250
RH
410
411 if (flag_debug)
966ed0b4
ILT
412 fprintf (stderr, "line: addr %lx file `%s' line %u col %u flags %x\n",
413 (unsigned long) addr, l->filename, l->line, l->column, l->flags);
fac0d250
RH
414
415 if (filenum > 0 && !l->filename)
416 {
ab9da554 417 if (filenum >= (unsigned int) ls.num_filenames)
fac0d250
RH
418 {
419 as_warn ("Encountered bad file number in line number debug info!");
420 return;
421 }
422 }
423 else if (l->filename)
424 filenum = get_filenum (filenum, l->filename);
425 else
426 return; /* no filename, no filnum => no play */
427
428 if (!ls.line_seg)
429 {
9e3af0e7 430#ifdef BFD_ASSEMBLER
9de8d8f1 431 symbolS *secsym;
9e3af0e7 432#endif
9de8d8f1 433
6576f0b5 434 ls.line_seg = subseg_new (".debug_line", 0);
9e3af0e7
ILT
435
436#ifdef BFD_ASSEMBLER
fac0d250 437 bfd_set_section_flags (stdoutput, ls.line_seg, SEC_READONLY);
6576f0b5
RH
438
439 /* We're going to need this symbol. */
9de8d8f1
RH
440 secsym = symbol_find (".debug_line");
441 if (secsym != NULL)
442 symbol_set_bfdsym (secsym, ls.line_seg->symbol);
443 else
444 symbol_table_insert (section_symbol (ls.line_seg));
9e3af0e7 445#endif
fac0d250
RH
446 }
447
448 saved_seg = now_seg;
449 saved_subseg = now_subseg;
450 subseg_set (ls.line_seg, DL_BODY);
451
452 if (ls.text_seg != saved_seg || ls.text_subseg != saved_subseg)
453 {
454 if (!ls.sm.empty_sequence)
455 {
456 out_end_sequence (); /* terminate previous sequence */
457 ls.sm.empty_sequence = 1;
458 }
459 any_output = 1;
460 ls.text_seg = saved_seg;
461 ls.text_subseg = saved_subseg;
462 out_set_addr (addr);
463 ls.sm.addr = addr;
464 }
465
466 if (ls.sm.filenum != filenum)
467 {
468 any_output = 1;
469 out_opcode (DW_LNS_set_file);
470 out_uleb128 (filenum);
471 ls.sm.filenum = filenum;
472 }
473
474 if (ls.sm.column != l->column)
475 {
476 any_output = 1;
477 out_opcode (DW_LNS_set_column);
478 out_uleb128 (l->column);
479 ls.sm.column = l->column;
480 }
481
482 if (((l->flags & DWARF2_FLAG_BEGIN_STMT) != 0) != ls.sm.is_stmt)
483 {
484 any_output = 1;
485 out_opcode (DW_LNS_negate_stmt);
486 }
487
488 if (l->flags & DWARF2_FLAG_BEGIN_BLOCK)
489 {
490 any_output = 1;
491 out_opcode (DW_LNS_set_basic_block);
492 }
493
494 if (ls.sm.line != l->line)
495 {
496 any_output = 1;
497 if (addr < ls.sm.addr)
498 {
a340d270
RH
499 /* This happens when a new frag got allocated (for whatever
500 reason). Deal with it by generating a reference symbol.
501 Note: no end_sequence needs to be generated because the
502 address did not really decrease (only the reference point
503 changed).
504
505 ??? Perhaps we should directly check for a change of
506 frag_now instead? */
fac0d250
RH
507 out_set_addr (addr);
508 ls.sm.addr = addr;
509 }
510 gen_addr_line (l->line - ls.sm.line,
511 (addr - ls.sm.addr) / DWARF2_LINE_MIN_INSN_LENGTH);
512 ls.sm.basic_block = 0;
513 ls.sm.line = l->line;
514 ls.sm.addr = addr;
515 }
516
517 subseg_set (saved_seg, saved_subseg);
518
519 ls.num_line_entries += any_output;
520 if (any_output)
521 ls.sm.empty_sequence = 0;
522}
523
524static void
58b5739a 525gen_dir_list ()
fac0d250
RH
526{
527 char *str, *slash, *dir_list, *dp, *cp;
528 int i, j, num_dirs;
529
530 dir_list = frag_more (0);
531 num_dirs = 0;
532
533 for (i = 0; i < ls.num_filenames; ++i)
534 {
535 str = ls.file[i].name;
536 slash = strrchr (str, '/');
537 if (slash)
538 {
539 *slash = '\0';
540 for (j = 0, dp = dir_list; j < num_dirs; ++j)
541 {
542 if (strcmp (str, dp) == 0)
543 {
a340d270 544 ls.file[i].dir = j + 1;
fac0d250
RH
545 break;
546 }
547 dp += strlen (dp);
548 }
549 if (j >= num_dirs)
550 {
551 /* didn't find this directory: append it to the list */
552 size_t size = strlen (str) + 1;
553 cp = frag_more (size);
554 memcpy (cp, str, size);
555 ls.file[i].dir = ++num_dirs;
556 }
557 *slash = '/';
558 ls.file[i].name = slash + 1;
559 }
560 }
561 out_byte ('\0'); /* terminate directory list */
562}
563
564static void
58b5739a 565gen_file_list ()
fac0d250
RH
566{
567 size_t size;
568 char *cp;
569 int i;
570
571 for (i = 0; i < ls.num_filenames; ++i)
572 {
573 size = strlen (ls.file[i].name) + 1;
574 cp = frag_more (size);
575 memcpy (cp, ls.file[i].name, size);
576
577 out_uleb128 (ls.file[i].dir); /* directory number */
578 out_uleb128 (0); /* last modification timestamp */
579 out_uleb128 (0); /* filesize */
580 }
581 out_byte (0); /* terminate filename list */
582}
583
58b5739a
RH
584static void
585print_stats (total_size)
586 unsigned long total_size;
fac0d250
RH
587{
588 static const char *opc_name[] =
589 {
590 "extended", "copy", "advance_pc", "advance_line", "set_file",
591 "set_column", "negate_stmt", "set_basic_block", "const_add_pc",
592 "fixed_advance_pc"
593 };
ab9da554
ILT
594 size_t i;
595 int j;
fac0d250
RH
596
597 fprintf (stderr, "Average size: %g bytes/line\n",
598 total_size / (double) ls.num_line_entries);
599
600 fprintf (stderr, "\nStandard opcode histogram:\n");
601
602 for (i = 0; i < sizeof (opc_name)/sizeof (opc_name[0]); ++i)
603 {
604 fprintf (stderr, "%s", opc_name[i]);
605 for (j = strlen (opc_name[i]); j < 16; ++j)
606 fprintf (stderr, " ");
607 fprintf (stderr, ": %u\n", ls.opcode_hist[i]);
608 }
609
610 fprintf (stderr, "\nSpecial opcodes:\naddr\t\t\t\tline skip\n");
611
612 fprintf (stderr, "skip: ");
613 for (j = DWARF2_LINE_BASE; j < DWARF2_LINE_BASE + DWARF2_LINE_RANGE; ++j)
614 fprintf (stderr, "%3d", j);
615 fprintf (stderr, "\n-----");
616
617 for (; i < 256; ++i)
618 {
619 j = SPECIAL_LINE (i);
620 if (j == DWARF2_LINE_BASE)
621 fprintf (stderr, "\n%4u: ",
622 DWARF2_LINE_MIN_INSN_LENGTH*SPECIAL_ADDR (i));
623 fprintf (stderr, " %2u", ls.opcode_hist[i]);
624 }
625 fprintf (stderr, "\n");
626}
627
628void
58b5739a 629dwarf2_finish ()
fac0d250 630{
9e3af0e7 631 addressT body_size, total_size, prolog_size;
58b5739a 632 subsegT saved_subseg;
fac0d250
RH
633 segT saved_seg;
634 char *cp;
635
636 if (!ls.line_seg)
637 /* no .debug_line segment, no work to do... */
638 return;
639
640 saved_seg = now_seg;
641 saved_subseg = now_subseg;
642
643 if (!ls.sm.empty_sequence)
644 out_end_sequence ();
645 total_size = body_size = frag_now_fix ();
646
647 /* now generate the directory and file lists: */
648 subseg_set (ls.line_seg, DL_FILES);
649 gen_dir_list ();
650 gen_file_list ();
651 total_size += frag_now_fix ();
652
653 /* and now the header ("statement program prolog", in DWARF2 lingo...) */
654 subseg_set (ls.line_seg, DL_PROLOG);
655
656 cp = frag_more (15 + DWARF2_LINE_OPCODE_BASE - 1);
657
658 total_size += frag_now_fix ();
659 prolog_size = total_size - body_size - 10;
660
661# define STUFF(val,size) md_number_to_chars (cp, val, size); cp += size;
662 STUFF (total_size - 4, 4); /* length */
663 STUFF (2, 2); /* version */
664 STUFF (prolog_size, 4); /* prologue_length */
665 STUFF (DWARF2_LINE_MIN_INSN_LENGTH, 1);
666 STUFF (DWARF2_LINE_DEFAULT_IS_STMT, 1);
667 STUFF (DWARF2_LINE_BASE, 1);
668 STUFF (DWARF2_LINE_RANGE, 1);
669 STUFF (DWARF2_LINE_OPCODE_BASE, 1);
670
671 /* standard_opcode_lengths: */
672 STUFF (0, 1); /* DW_LNS_copy */
673 STUFF (1, 1); /* DW_LNS_advance_pc */
674 STUFF (1, 1); /* DW_LNS_advance_line */
675 STUFF (1, 1); /* DW_LNS_set_file */
676 STUFF (1, 1); /* DW_LNS_set_column */
677 STUFF (0, 1); /* DW_LNS_negate_stmt */
678 STUFF (0, 1); /* DW_LNS_set_basic_block */
679 STUFF (0, 1); /* DW_LNS_const_add_pc */
680 STUFF (1, 1); /* DW_LNS_fixed_advance_pc */
681
682 subseg_set (saved_seg, saved_subseg);
683
684 if (flag_debug)
685 print_stats (total_size);
686}
687
688void
58b5739a 689dwarf2_directive_file (dummy)
ab9da554 690 int dummy ATTRIBUTE_UNUSED;
fac0d250
RH
691{
692 int len;
693
58b5739a
RH
694 /* Continue to accept a bare string and pass it off. */
695 SKIP_WHITESPACE ();
696 if (*input_line_pointer == '"')
697 {
698 s_app_file (0);
699 return;
700 }
701
fac0d250
RH
702 ls.any_dwarf2_directives = 1;
703
704 if (debug_type == DEBUG_NONE)
705 /* Automatically turn on DWARF2 debug info unless something else
706 has been selected. */
707 debug_type = DEBUG_DWARF2;
708
709 ls.current.filenum = get_absolute_expression ();
710 ls.current.filename = demand_copy_C_string (&len);
711
712 demand_empty_rest_of_line ();
713}
714
715void
58b5739a 716dwarf2_directive_loc (dummy)
ab9da554 717 int dummy ATTRIBUTE_UNUSED;
fac0d250
RH
718{
719 ls.any_dwarf2_directives = 1;
720
721 ls.current.filenum = get_absolute_expression ();
722 SKIP_WHITESPACE ();
723 ls.current.line = get_absolute_expression ();
724 SKIP_WHITESPACE ();
725 ls.current.column = get_absolute_expression ();
726 demand_empty_rest_of_line ();
727
728 ls.current.flags = DWARF2_FLAG_BEGIN_STMT;
729
730#ifndef NO_LISTING
731 if (listing)
732 listing_source_line (ls.current.line);
733#endif
734}
735
736void
58b5739a
RH
737dwarf2_where (line)
738 struct dwarf2_line_info *line;
fac0d250
RH
739{
740 if (ls.any_dwarf2_directives)
741 *line = ls.current;
742 else
743 {
fac0d250
RH
744 as_where (&line->filename, &line->line);
745 line->filenum = 0;
746 line->column = 0;
747 line->flags = DWARF2_FLAG_BEGIN_STMT;
748 }
749}
This page took 0.057111 seconds and 4 git commands to generate.