aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gas/ChangeLog22
-rw-r--r--gas/doc/as.texinfo47
-rw-r--r--gas/dwarf2dbg.c205
-rw-r--r--gas/dwarf2dbg.h7
-rw-r--r--gas/testsuite/ChangeLog6
-rw-r--r--gas/testsuite/gas/lns/lns-common-1.d29
-rw-r--r--gas/testsuite/gas/lns/lns-common-1.s16
-rw-r--r--gas/testsuite/gas/lns/lns-diag-1.l11
-rw-r--r--gas/testsuite/gas/lns/lns-diag-1.s26
-rw-r--r--gas/testsuite/gas/lns/lns.exp26
10 files changed, 333 insertions, 62 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1140fec..c2f76ef 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,25 @@
+2005-09-07 Richard Henderson <rth@redhat.com>
+
+ * dwarf2dbg.c: Include safe-ctype.h.
+ (DWARF2_LINE_OPCODE_BASE): Bump to 13.
+ (current): Initialize.
+ (dwarf2_emit_insn): Clear DWARF2_FLAG_BASIC_BLOCK,
+ DWARF2_FLAG_PROLOGUE_END, DWARF2_FLAG_EPILOGUE_BEGIN.
+ (dwarf2_directive_file): Cope with invalid filename.
+ (dwarf2_directive_loc): Add handling for basic_block, prologue_end,
+ epilogue_begin, is_stmt, isa.
+ (emit_inc_line_addr): Move line_delta == 0, addr_delta == 0 special
+ case down lower.
+ (process_entries): Handle isa, DWARF2_FLAG_PROLOGUE_END,
+ and DWARF2_FLAG_EPILOGUE_BEGIN.
+ (out_debug_line): Emit sizes for DW_LNS_set_prologue_end,
+ DW_LNS_set_epilogue_begin, DW_LNS_set_isa.
+ * dwarf2dbg.h (DWARF2_FLAG_IS_STMT): Rename from DWARF2_FLAG_BEGIN_STMT.
+ (DWARF2_FLAG_BASIC_BLOCK): Rename from DWARF2_FLAG_BEGIN_BLOCK.
+ (DWARF2_FLAG_PROLOGUE_END, DWARF2_FLAG_EPILOGUE_BEGIN): New.
+ (struct dwarf2_line_info): Add isa member.
+ * doc/as.texinfo (LNS directives): New node.
+
2005-09-07 David Ung <davidu@mips.com>
* config/tc-mips.c (append_insn): Undo last change. Instead add
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index 0721631..e85677d 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -3745,9 +3745,12 @@ Some machine configurations provide additional directives.
* Line:: @code{.line @var{line-number}}
@end ifclear
-* Ln:: @code{.ln @var{line-number}}
* Linkonce:: @code{.linkonce [@var{type}]}
* List:: @code{.list}
+* Ln:: @code{.ln @var{line-number}}
+
+* LNS directives:: @code{.file}, @code{.loc}, etc.
+
* Long:: @code{.long @var{expressions}}
@ignore
* Lsym:: @code{.lsym @var{symbol}, @var{expression}}
@@ -4049,6 +4052,48 @@ Allows the user to add arbitrary bytes to the unwind info. One
might use this to add OS-specific CFI opcodes, or generic CFI
opcodes that GAS does not yet support.
+@node LNS directives
+@section @code{.file @var{fileno} @var{filename}}
+@cindex @code{file} directive
+When emitting dwarf2 line number information @code{.file} assigns filenames
+to the @code{.debug_line} file name table. The @var{fileno} operand should
+be a unique positive integer to use as the index of the entry in the table.
+The @var{filename} operand is a C string literal.
+
+The detail of filename indicies is exposed to the user because the filename
+table is shared with the @code{.debug_info} section of the dwarf2 debugging
+information, and thus the user must know the exact indicies that table
+entries will have.
+
+@section @code{.loc @var{fileno} @var{lineno} [@var{column}]}
+@cindex @code{loc} directive
+The @code{.loc} directive will add row to the @code{.debug_line} line
+number matrix corresponding to the immediately following assembly
+instruction. The @var{fileno}, @var{lineno}, and optional @var{column}
+arguments will be applied to the @code{.debug_line} state machine before
+the row is added.
+
+@section @code{.loc basic_block}
+This directive will set the @code{basic_block} register in the
+@code{.debug_line} state machine to @code{true}.
+
+@section @code{.loc prologue_end}
+This directive will set the @code{prologue_end} register in the
+@code{.debug_line} state machine to @code{true}.
+
+@section @code{.loc epilogue_begin}
+This directive will set the @code{epilogue_begin} register in the
+@code{.debug_line} state machine to @code{true}.
+
+@section @code{.loc is_stmt @var{value}}
+This directive will set the @code{epilogue_begin} register in the
+@code{.debug_line} state machine to @code{value}, which must be
+either 0 or 1.
+
+@section @code{.loc isa @var{value}}
+This directive will set the @code{isa} register in the @code{.debug_line}
+state machine to @var{value}, which must be an unsigned integer.
+
@node Data
@section @code{.data @var{subsection}}
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 281177e..7ebb25b 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -21,15 +21,20 @@
02110-1301, USA. */
/* Logical line numbers can be controlled by the compiler via the
- following two directives:
+ following directives:
.file FILENO "file.c"
.loc FILENO LINENO [COLUMN]
-
- FILENO is the filenumber. */
+ .loc basic_block
+ .loc prologue_end
+ .loc epilogue_begin
+ .loc is_stmt [VALUE]
+ .loc isa [VALUE]
+*/
#include "ansidecl.h"
#include "as.h"
+#include "safe-ctype.h"
#ifdef HAVE_LIMITS_H
#include <limits.h>
@@ -68,8 +73,8 @@
/* First special line opcde - leave room for the standard opcodes.
Note: If you want to change this, you'll have to update the
"standard_opcode_lengths" table that is emitted below in
- dwarf2_finish(). */
-#define DWARF2_LINE_OPCODE_BASE 10
+ out_debug_line(). */
+#define DWARF2_LINE_OPCODE_BASE 13
#ifndef DWARF2_LINE_BASE
/* Minimum line offset in a special line info. opcode. This value
@@ -88,10 +93,7 @@
# define DWARF2_LINE_MIN_INSN_LENGTH 1
#endif
-/* Flag that indicates the initial value of the is_stmt_start flag.
- In the present implementation, we do not mark any lines as
- the beginning of a source statement, because that information
- is not made available by the GCC front-end. */
+/* Flag that indicates the initial value of the is_stmt_start flag. */
#define DWARF2_LINE_DEFAULT_IS_STMT 1
/* Given a special op, return the line skip amount. */
@@ -150,7 +152,10 @@ static unsigned int dirs_allocated;
static bfd_boolean loc_directive_seen;
/* Current location as indicated by the most recent .loc directive. */
-static struct dwarf2_line_info current;
+static struct dwarf2_line_info current = {
+ 1, 1, 0, 0,
+ DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0
+};
/* The size of an address on the target. */
static unsigned int sizeof_address;
@@ -291,7 +296,7 @@ dwarf2_where (struct dwarf2_line_info *line)
as_where (&filename, &line->line);
line->filenum = get_filenum (filename, 0);
line->column = 0;
- line->flags = DWARF2_FLAG_BEGIN_STMT;
+ line->flags = DWARF2_FLAG_IS_STMT;
}
else
*line = current;
@@ -324,9 +329,13 @@ dwarf2_emit_insn (int size)
else if (debug_type != DEBUG_DWARF2)
return;
else
- dwarf2_where (& loc);
+ dwarf2_where (&loc);
dwarf2_gen_line_info (frag_now_fix () - size, &loc);
+
+ current.flags &= ~(DWARF2_FLAG_BASIC_BLOCK
+ | DWARF2_FLAG_PROLOGUE_END
+ | DWARF2_FLAG_EPILOGUE_BEGIN);
}
/* Get a .debug_line file number for FILENAME. If NUM is nonzero,
@@ -449,6 +458,8 @@ dwarf2_directive_file (int dummy ATTRIBUTE_UNUSED)
num = get_absolute_expression ();
filename = demand_copy_C_string (&filename_len);
+ if (filename == NULL)
+ return NULL;
demand_empty_rest_of_line ();
if (num < 1)
@@ -471,53 +482,105 @@ dwarf2_directive_file (int dummy ATTRIBUTE_UNUSED)
void
dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
{
- offsetT filenum, line, column;
-
- filenum = get_absolute_expression ();
SKIP_WHITESPACE ();
- line = get_absolute_expression ();
- SKIP_WHITESPACE ();
- column = get_absolute_expression ();
- demand_empty_rest_of_line ();
-
- if (filenum < 1)
+ if (ISALPHA (*input_line_pointer))
{
- as_bad (_("file number less than one"));
- return;
+ char *p, c;
+ offsetT value;
+
+ p = input_line_pointer;
+ c = get_symbol_end ();
+
+ if (strcmp (p, "basic_block") == 0)
+ {
+ current.flags |= DWARF2_FLAG_BASIC_BLOCK;
+ *input_line_pointer = c;
+ }
+ else if (strcmp (p, "prologue_end") == 0)
+ {
+ current.flags |= DWARF2_FLAG_PROLOGUE_END;
+ *input_line_pointer = c;
+ }
+ else if (strcmp (p, "epilogue_begin") == 0)
+ {
+ current.flags |= DWARF2_FLAG_EPILOGUE_BEGIN;
+ *input_line_pointer = c;
+ }
+ else if (strcmp (p, "is_stmt") == 0)
+ {
+ *input_line_pointer = c;
+ value = get_absolute_expression ();
+ if (value == 0)
+ current.flags &= ~DWARF2_FLAG_IS_STMT;
+ else if (value == 1)
+ current.flags |= DWARF2_FLAG_IS_STMT;
+ else
+ as_bad (_("is_stmt value not 0 or 1"));
+ }
+ else if (strcmp (p, "isa") == 0)
+ {
+ *input_line_pointer = c;
+ value = get_absolute_expression ();
+ if (value < 0)
+ as_bad (_("isa number less than zero"));
+ else
+ current.isa = value;
+ }
+ else
+ {
+ as_bad (_("unknown .loc sub-directive %s"), p);
+ *input_line_pointer = c;
+ }
}
- if (filenum >= (int) files_in_use || files[filenum].filename == 0)
+ else
{
- as_bad (_("unassigned file number %ld"), (long) filenum);
- return;
- }
+ offsetT filenum, line, column;
- current.filenum = filenum;
- current.line = line;
- current.column = column;
- current.flags = DWARF2_FLAG_BEGIN_STMT;
+ filenum = get_absolute_expression ();
+ SKIP_WHITESPACE ();
+ line = get_absolute_expression ();
+ SKIP_WHITESPACE ();
+ column = get_absolute_expression ();
- loc_directive_seen = TRUE;
+ if (filenum < 1)
+ {
+ as_bad (_("file number less than one"));
+ return;
+ }
+ if (filenum >= (int) files_in_use || files[filenum].filename == 0)
+ {
+ as_bad (_("unassigned file number %ld"), (long) filenum);
+ return;
+ }
+
+ current.filenum = filenum;
+ current.line = line;
+ current.column = column;
#ifndef NO_LISTING
- if (listing)
- {
- if (files[filenum].dir)
+ if (listing)
{
- size_t dir_len = strlen (dirs[files[filenum].dir]);
- size_t file_len = strlen (files[filenum].filename);
- char *cp = (char *) alloca (dir_len + 1 + file_len + 1);
-
- memcpy (cp, dirs[files[filenum].dir], dir_len);
- cp[dir_len] = '/';
- memcpy (cp + dir_len + 1, files[filenum].filename, file_len);
- cp[dir_len + file_len + 1] = '\0';
- listing_source_file (cp);
+ if (files[filenum].dir)
+ {
+ size_t dir_len = strlen (dirs[files[filenum].dir]);
+ size_t file_len = strlen (files[filenum].filename);
+ char *cp = (char *) alloca (dir_len + 1 + file_len + 1);
+
+ memcpy (cp, dirs[files[filenum].dir], dir_len);
+ cp[dir_len] = '/';
+ memcpy (cp + dir_len + 1, files[filenum].filename, file_len);
+ cp[dir_len + file_len + 1] = '\0';
+ listing_source_file (cp);
+ }
+ else
+ listing_source_file (files[filenum].filename);
+ listing_source_line (line);
}
- else
- listing_source_file (files[filenum].filename);
- listing_source_line (line);
- }
#endif
+ }
+
+ demand_empty_rest_of_line ();
+ loc_directive_seen = TRUE;
}
static struct frag *
@@ -759,19 +822,19 @@ emit_inc_line_addr (int line_delta, addressT addr_delta, char *p, int len)
*p++ = DW_LNS_advance_line;
p += output_leb128 (p, line_delta, 1);
- /* Prettier, I think, to use DW_LNS_copy instead of a
- "line +0, addr +0" special opcode. */
- if (addr_delta == 0)
- {
- *p++ = DW_LNS_copy;
- goto done;
- }
-
line_delta = 0;
tmp = 0 - DWARF2_LINE_BASE;
need_copy = 1;
}
+ /* Prettier, I think, to use DW_LNS_copy instead of a "line +0, addr +0"
+ special opcode. */
+ if (line_delta == 0 && addr_delta == 0)
+ {
+ *p++ = DW_LNS_copy;
+ goto done;
+ }
+
/* Bias the opcode by the special opcode base. */
tmp += DWARF2_LINE_OPCODE_BASE;
@@ -913,7 +976,8 @@ process_entries (segT seg, struct line_entry *e)
unsigned filenum = 1;
unsigned line = 1;
unsigned column = 0;
- unsigned flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_BEGIN_STMT : 0;
+ unsigned isa = 0;
+ unsigned flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
fragS *frag = NULL;
fragS *last_frag;
addressT frag_ofs = 0;
@@ -940,19 +1004,39 @@ process_entries (segT seg, struct line_entry *e)
changed = 1;
}
- if ((e->loc.flags ^ flags) & DWARF2_FLAG_BEGIN_STMT)
+ if (isa != e->loc.isa)
+ {
+ isa = e->loc.isa;
+ out_opcode (DW_LNS_set_isa);
+ out_uleb128 (isa);
+ changed = 1;
+ }
+
+ if ((e->loc.flags ^ flags) & DWARF2_FLAG_IS_STMT)
{
flags = e->loc.flags;
out_opcode (DW_LNS_negate_stmt);
changed = 1;
}
- if (e->loc.flags & DWARF2_FLAG_BEGIN_BLOCK)
+ if (e->loc.flags & DWARF2_FLAG_BASIC_BLOCK)
{
out_opcode (DW_LNS_set_basic_block);
changed = 1;
}
+ if (e->loc.flags & DWARF2_FLAG_PROLOGUE_END)
+ {
+ out_opcode (DW_LNS_set_prologue_end);
+ changed = 1;
+ }
+
+ if (e->loc.flags & DWARF2_FLAG_EPILOGUE_BEGIN)
+ {
+ out_opcode (DW_LNS_set_epilogue_begin);
+ changed = 1;
+ }
+
/* Don't try to optimize away redundant entries; gdb wants two
entries for a function where the code starts on the same line as
the {, and there's no way to identify that case here. Trust gcc
@@ -1115,6 +1199,9 @@ out_debug_line (segT line_seg)
out_byte (0); /* DW_LNS_set_basic_block */
out_byte (0); /* DW_LNS_const_add_pc */
out_byte (1); /* DW_LNS_fixed_advance_pc */
+ out_byte (0); /* DW_LNS_set_prologue_end */
+ out_byte (0); /* DW_LNS_set_epilogue_begin */
+ out_byte (1); /* DW_LNS_set_isa */
out_file_list ();
diff --git a/gas/dwarf2dbg.h b/gas/dwarf2dbg.h
index 2fe461e..34c923f 100644
--- a/gas/dwarf2dbg.h
+++ b/gas/dwarf2dbg.h
@@ -23,13 +23,16 @@
#include "as.h"
-#define DWARF2_FLAG_BEGIN_STMT (1 << 0) /* beginning of statement */
-#define DWARF2_FLAG_BEGIN_BLOCK (1 << 1) /* beginning of basic block */
+#define DWARF2_FLAG_IS_STMT (1 << 0)
+#define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
+#define DWARF2_FLAG_PROLOGUE_END (1 << 2)
+#define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
struct dwarf2_line_info {
unsigned int filenum;
unsigned int line;
unsigned int column;
+ unsigned int isa;
unsigned int flags;
};
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index eff92aa..4616c8d 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-09-07 Richard Henderson <rth@redhat.com>
+
+ * gas/lns/lns.exp: New file.
+ * gas/lns/lns-common-1.[sd]: New test.
+ * gas/lns/lns-diag-1.[sl]: New test.
+
2005-09-06 Chao-ying Fu <fu@mips.com>
* gas/mips/mips.exp: Run MT test for mips32r2 only.
diff --git a/gas/testsuite/gas/lns/lns-common-1.d b/gas/testsuite/gas/lns/lns-common-1.d
new file mode 100644
index 0000000..bb250e2
--- /dev/null
+++ b/gas/testsuite/gas/lns/lns-common-1.d
@@ -0,0 +1,29 @@
+#readelf: -wl
+#name: lns-common-1
+Dump of debug contents of section \.debug_line:
+#...
+ DWARF Version: 2
+ Prologue Length: 28
+ Minimum Instruction Length: 1
+ Initial value of 'is_stmt': 1
+ Line Base: -5
+ Line Range: 14
+ Opcode Base: 13
+#...
+ Line Number Statements:
+ Extended opcode 2: set Address to 0x0
+ Copy
+ Set prologue_end to true
+ Special opcode 19: advance Address by .* to .* and Line by 0 to 1
+ Set epilogue_begin to true
+ Special opcode 20: advance Address by .* to .* and Line by 1 to 2
+ Set ISA to 1
+ Set basic block
+ Special opcode 20: advance Address by .* to .* and Line by 1 to 3
+ Set is_stmt to 0
+ Special opcode 19: advance Address by .* to .* and Line by 0 to 3
+ Set is_stmt to 1
+ Special opcode 19: advance Address by .* to .* and Line by 0 to 3
+ Advance PC by .* to .*
+ Extended opcode 1: End of Sequence
+#...
diff --git a/gas/testsuite/gas/lns/lns-common-1.s b/gas/testsuite/gas/lns/lns-common-1.s
new file mode 100644
index 0000000..8d3fec3
--- /dev/null
+++ b/gas/testsuite/gas/lns/lns-common-1.s
@@ -0,0 +1,16 @@
+ .file 1 "foo.c"
+ .loc 1 1
+ nop
+ .loc prologue_end
+ nop
+ .loc epilogue_begin
+ .loc 1 2
+ nop
+ .loc isa 1
+ .loc basic_block
+ .loc 1 3
+ nop
+ .loc is_stmt 0
+ nop
+ .loc is_stmt 1
+ nop
diff --git a/gas/testsuite/gas/lns/lns-diag-1.l b/gas/testsuite/gas/lns/lns-diag-1.l
new file mode 100644
index 0000000..52207ed
--- /dev/null
+++ b/gas/testsuite/gas/lns/lns-diag-1.l
@@ -0,0 +1,11 @@
+.*: Assembler messages:
+.*:2: Error: file number less than one
+.*:3: Error: missing string
+.*:4: Error: file number 1 already allocated
+.*:8: Error: unassigned file number 3
+.*:9: Error: junk at end of line, first unrecognized character is `1'
+.*:12: Error: junk at end of line, first unrecognized character is `0'
+.*:18: Error: is_stmt value not 0 or 1
+.*:19: Error: bad or irreducible absolute expression
+.*:23: Error: isa number less than zero
+.*:26: Error: unknown .loc sub-directive frobnitz
diff --git a/gas/testsuite/gas/lns/lns-diag-1.s b/gas/testsuite/gas/lns/lns-diag-1.s
new file mode 100644
index 0000000..8193559
--- /dev/null
+++ b/gas/testsuite/gas/lns/lns-diag-1.s
@@ -0,0 +1,26 @@
+ .file 1 "foo.c"
+ .file 0 "bar.c"
+ .file 2 baz.c
+ .file 1 "bar.c"
+
+ .loc 1 1
+ .loc 1 2 3
+ .loc 3 1
+ .loc 1 1 1 1
+
+ .loc basic_block
+ .loc basic_block 0
+ .loc prologue_end
+ .loc epilogue_begin
+
+ .loc is_stmt 0
+ .loc is_stmt 1
+ .loc is_stmt 2
+ .loc is_stmt foo
+
+ .loc isa 1
+ .loc isa 2
+ .loc isa -1
+ .loc isa 0
+
+ .loc frobnitz
diff --git a/gas/testsuite/gas/lns/lns.exp b/gas/testsuite/gas/lns/lns.exp
new file mode 100644
index 0000000..784f9a3
--- /dev/null
+++ b/gas/testsuite/gas/lns/lns.exp
@@ -0,0 +1,26 @@
+# ??? This probably shouldn't be replicated here...
+proc run_list_test { name opts } {
+ global srcdir subdir
+ set testname "lns $name"
+ set file $srcdir/$subdir/$name
+ gas_run ${name}.s $opts ">&dump.out"
+ if { [regexp_diff "dump.out" "${file}.l"] } then {
+ fail $testname
+ verbose "output is [file_contents "dump.out"]" 2
+ return
+ }
+ pass $testname
+}
+
+if ![is_elf_format] then {
+ return
+}
+
+run_list_test "lns-diag-1" ""
+
+# ??? Won't work on targets that don't have a bare "nop" insn,
+# which is only ia64, afaik. Perhaps we could arrange for an
+# include file or something that defined a macro...
+if ![istarget ia64*-*-*] {
+ run_dump_test "lns-common-1"
+}