* dwarf2dbg.c (dwarf2_where): Set line->isa.

(dwarf2_set_isa): New.
        (dwarf2_directive_loc): Rearrange to allow all options on one line.
        * dwarf2dbg.h (dwarf2_set_isa): Declare.
        * doc/as.texinfo: Update .loc documentation.

        * gas/lns/lns-common-1.d: Don't match header or special opcode numbers.
        * gas/lns/lns-common-1.s: Update for syntax change.
        * gas/lns/lns-diag-1.[sl]: Likewise.
This commit is contained in:
Richard Henderson 2005-09-07 19:22:42 +00:00
parent bd12172103
commit ecea767983
9 changed files with 145 additions and 99 deletions

View file

@ -1,3 +1,11 @@
2005-09-07 Richard Henderson <rth@redhat.com>
* dwarf2dbg.c (dwarf2_where): Set line->isa.
(dwarf2_set_isa): New.
(dwarf2_directive_loc): Rearrange to allow all options on one line.
* dwarf2dbg.h (dwarf2_set_isa): Declare.
* doc/as.texinfo: Update .loc documentation.
2005-09-07 Richard Henderson <rth@redhat.com> 2005-09-07 Richard Henderson <rth@redhat.com>
* dwarf2dbg.c: Include safe-ctype.h. * dwarf2dbg.c: Include safe-ctype.h.

View file

@ -4065,7 +4065,7 @@ 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 information, and thus the user must know the exact indicies that table
entries will have. entries will have.
@section @code{.loc @var{fileno} @var{lineno} [@var{column}]} @section @code{.loc @var{fileno} @var{lineno} [@var{column}] [@var{options}]}
@cindex @code{loc} directive @cindex @code{loc} directive
The @code{.loc} directive will add row to the @code{.debug_line} line The @code{.loc} directive will add row to the @code{.debug_line} line
number matrix corresponding to the immediately following assembly number matrix corresponding to the immediately following assembly
@ -4073,26 +4073,30 @@ instruction. The @var{fileno}, @var{lineno}, and optional @var{column}
arguments will be applied to the @code{.debug_line} state machine before arguments will be applied to the @code{.debug_line} state machine before
the row is added. the row is added.
@section @code{.loc basic_block} The @var{options} are a sequence of the following tokens in any order:
This directive will set the @code{basic_block} register in the
@table @code
@item basic_block
This option will set the @code{basic_block} register in the
@code{.debug_line} state machine to @code{true}. @code{.debug_line} state machine to @code{true}.
@section @code{.loc prologue_end} @item prologue_end
This directive will set the @code{prologue_end} register in the This option will set the @code{prologue_end} register in the
@code{.debug_line} state machine to @code{true}. @code{.debug_line} state machine to @code{true}.
@section @code{.loc epilogue_begin} @item epilogue_begin
This directive will set the @code{epilogue_begin} register in the This option will set the @code{epilogue_begin} register in the
@code{.debug_line} state machine to @code{true}. @code{.debug_line} state machine to @code{true}.
@section @code{.loc is_stmt @var{value}} @item is_stmt @var{value}
This directive will set the @code{epilogue_begin} register in the This option will set the @code{is_stmt} register in the
@code{.debug_line} state machine to @code{value}, which must be @code{.debug_line} state machine to @code{value}, which must be
either 0 or 1. either 0 or 1.
@section @code{.loc isa @var{value}} @item isa @var{value}
This directive will set the @code{isa} register in the @code{.debug_line} This directive will set the @code{isa} register in the @code{.debug_line}
state machine to @var{value}, which must be an unsigned integer. state machine to @var{value}, which must be an unsigned integer.
@end table
@node Data @node Data
@section @code{.data @var{subsection}} @section @code{.data @var{subsection}}

View file

@ -24,12 +24,8 @@
following directives: following directives:
.file FILENO "file.c" .file FILENO "file.c"
.loc FILENO LINENO [COLUMN] .loc FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
.loc basic_block [epilogue_begin] [is_stmt VALUE] [isa VALUE]
.loc prologue_end
.loc epilogue_begin
.loc is_stmt [VALUE]
.loc isa [VALUE]
*/ */
#include "ansidecl.h" #include "ansidecl.h"
@ -287,6 +283,11 @@ dwarf2_gen_line_info (addressT ofs, struct dwarf2_line_info *loc)
ss->ptail = &e->next; ss->ptail = &e->next;
} }
/* Returns the current source information. If .file directives have
been encountered, the info for the corresponding source file is
returned. Otherwise, the info for the assembly source file is
returned. */
void void
dwarf2_where (struct dwarf2_line_info *line) dwarf2_where (struct dwarf2_line_info *line)
{ {
@ -297,11 +298,21 @@ dwarf2_where (struct dwarf2_line_info *line)
line->filenum = get_filenum (filename, 0); line->filenum = get_filenum (filename, 0);
line->column = 0; line->column = 0;
line->flags = DWARF2_FLAG_IS_STMT; line->flags = DWARF2_FLAG_IS_STMT;
line->isa = current.isa;
} }
else else
*line = current; *line = current;
} }
/* A hook to allow the target backend to inform the line number state
machine of isa changes when assembler debug info is enabled. */
void
dwarf2_set_isa (unsigned int isa)
{
current.isa = isa;
}
/* Called for each machine instruction, or relatively atomic group of /* Called for each machine instruction, or relatively atomic group of
machine instructions (ie built-in macro). The instruction or group machine instructions (ie built-in macro). The instruction or group
is SIZE bytes in length. If dwarf2 line number generation is called is SIZE bytes in length. If dwarf2 line number generation is called
@ -482,8 +493,55 @@ dwarf2_directive_file (int dummy ATTRIBUTE_UNUSED)
void void
dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED) dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
{ {
offsetT filenum, line;
filenum = get_absolute_expression ();
SKIP_WHITESPACE (); SKIP_WHITESPACE ();
if (ISALPHA (*input_line_pointer)) line = get_absolute_expression ();
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;
#ifndef NO_LISTING
if (listing)
{
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);
}
#endif
SKIP_WHITESPACE ();
if (ISDIGIT (*input_line_pointer))
{
current.column = get_absolute_expression ();
SKIP_WHITESPACE ();
}
while (ISALPHA (*input_line_pointer))
{ {
char *p, c; char *p, c;
offsetT value; offsetT value;
@ -515,68 +573,31 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
else if (value == 1) else if (value == 1)
current.flags |= DWARF2_FLAG_IS_STMT; current.flags |= DWARF2_FLAG_IS_STMT;
else else
as_bad (_("is_stmt value not 0 or 1")); {
as_bad (_("is_stmt value not 0 or 1"));
return;
}
} }
else if (strcmp (p, "isa") == 0) else if (strcmp (p, "isa") == 0)
{ {
*input_line_pointer = c; *input_line_pointer = c;
value = get_absolute_expression (); value = get_absolute_expression ();
if (value < 0) if (value >= 0)
as_bad (_("isa number less than zero"));
else
current.isa = value; current.isa = value;
else
{
as_bad (_("isa number less than zero"));
return;
}
} }
else else
{ {
as_bad (_("unknown .loc sub-directive %s"), p); as_bad (_("unknown .loc sub-directive `%s'"), p);
*input_line_pointer = c; *input_line_pointer = c;
}
}
else
{
offsetT filenum, line, column;
filenum = get_absolute_expression ();
SKIP_WHITESPACE ();
line = get_absolute_expression ();
SKIP_WHITESPACE ();
column = get_absolute_expression ();
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; return;
} }
current.filenum = filenum; SKIP_WHITESPACE ();
current.line = line;
current.column = column;
#ifndef NO_LISTING
if (listing)
{
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);
}
#endif
} }
demand_empty_rest_of_line (); demand_empty_rest_of_line ();

View file

@ -55,6 +55,10 @@ extern void dwarf2_directive_loc (int dummy);
returned. */ returned. */
extern void dwarf2_where (struct dwarf2_line_info *l); extern void dwarf2_where (struct dwarf2_line_info *l);
/* A hook to allow the target backend to inform the line number state
machine of isa changes when assembler debug info is enabled. */
extern void dwarf2_set_isa (unsigned int isa);
/* This function generates .debug_line info based on the address and /* This function generates .debug_line info based on the address and
source information passed in the arguments. ADDR should be the source information passed in the arguments. ADDR should be the
frag-relative offset of the instruction the information is for and frag-relative offset of the instruction the information is for and

View file

@ -1,3 +1,9 @@
2005-09-07 Richard Henderson <rth@redhat.com>
* gas/lns/lns-common-1.d: Don't match header or special opcode numbers.
* gas/lns/lns-common-1.s: Update for syntax change.
* gas/lns/lns-diag-1.[sl]: Likewise.
2005-09-07 Richard Henderson <rth@redhat.com> 2005-09-07 Richard Henderson <rth@redhat.com>
* gas/mips/mips16-dwarf2.d: Don't match anything but address and line * gas/mips/mips16-dwarf2.d: Don't match anything but address and line

View file

@ -2,28 +2,25 @@
#name: lns-common-1 #name: lns-common-1
Dump of debug contents of section \.debug_line: Dump of debug contents of section \.debug_line:
#... #...
DWARF Version: 2
Prologue Length: 28
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1 Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
#... #...
Line Number Statements: Line Number Statements:
Extended opcode 2: set Address to 0x0 Extended opcode 2: set Address to .*
Copy Copy
Set column to 3
Special opcode .*: advance Address by .* to .* and Line by 1 to 2
Set prologue_end to true Set prologue_end to true
Special opcode 19: advance Address by .* to .* and Line by 0 to 1 Special opcode .*: advance Address by .* to .* and Line by 1 to 3
Set column to 0
Set epilogue_begin to true Set epilogue_begin to true
Special opcode 20: advance Address by .* to .* and Line by 1 to 2 Special opcode .*: advance Address by .* to .* and Line by 1 to 4
Set ISA to 1 Set ISA to 1
Set basic block Set basic block
Special opcode 20: advance Address by .* to .* and Line by 1 to 3 Special opcode .*: advance Address by .* to .* and Line by 1 to 5
Set is_stmt to 0 Set is_stmt to 0
Special opcode 19: advance Address by .* to .* and Line by 0 to 3 Special opcode .*: advance Address by .* to .* and Line by 1 to 6
Set is_stmt to 1 Set is_stmt to 1
Special opcode 19: advance Address by .* to .* and Line by 0 to 3 Special opcode .*: advance Address by .* to .* and Line by 1 to 7
Advance PC by .* to .* Advance PC by .* to .*
Extended opcode 1: End of Sequence Extended opcode 1: End of Sequence
#... #...

View file

@ -1,16 +1,15 @@
.file 1 "foo.c" .file 1 "foo.c"
.loc 1 1 .loc 1 1
nop nop
.loc prologue_end .loc 1 2 3
nop nop
.loc epilogue_begin .loc 1 3 prologue_end
.loc 1 2
nop nop
.loc isa 1 .loc 1 4 0 epilogue_begin
.loc basic_block
.loc 1 3
nop nop
.loc is_stmt 0 .loc 1 5 isa 1 basic_block
nop nop
.loc is_stmt 1 .loc 1 6 is_stmt 0
nop
.loc 1 7 is_stmt 1
nop nop

View file

@ -8,4 +8,8 @@
.*:18: Error: is_stmt value not 0 or 1 .*:18: Error: is_stmt value not 0 or 1
.*:19: Error: bad or irreducible absolute expression .*:19: Error: bad or irreducible absolute expression
.*:23: Error: isa number less than zero .*:23: Error: isa number less than zero
.*:26: Error: unknown .loc sub-directive frobnitz .*:26: Error: bad or irreducible absolute expression
.*:26: Error: file number less than one
.*:27: Error: bad or irreducible absolute expression
.*:28: Error: unknown .loc sub-directive `frobnitz'
.*:29: Error: unknown .loc sub-directive `frobnitz'

View file

@ -8,19 +8,22 @@
.loc 3 1 .loc 3 1
.loc 1 1 1 1 .loc 1 1 1 1
.loc basic_block .loc 1 1 basic_block
.loc basic_block 0 .loc 1 1 basic_block 0
.loc prologue_end .loc 1 1 prologue_end
.loc epilogue_begin .loc 1 1 epilogue_begin
.loc is_stmt 0 .loc 1 1 1 is_stmt 0
.loc is_stmt 1 .loc 1 1 1 is_stmt 1
.loc is_stmt 2 .loc 1 1 1 is_stmt 2
.loc is_stmt foo .loc 1 1 1 is_stmt foo
.loc isa 1 .loc 1 1 isa 1
.loc isa 2 .loc 1 1 isa 2
.loc isa -1 .loc 1 1 isa -1
.loc isa 0 .loc 1 1 isa 0
.loc frobnitz .loc frobnitz
.loc 1 frobnitz
.loc 1 1 frobnitz
.loc 1 1 1 frobnitz