[patch] Add discriminator support to gas .loc directive
Cary Coutant
ccoutant@google.com
Tue Apr 21 18:46:00 GMT 2009
>> * Please add a line to gas/NEWS mentioning the new feature and extend the
>> description of the .loc directive in gas/doc/as.texinfo.
>> PS. When you submit the binutils/dwarf.c patch please could you also extend
>> the gas/testsuite/gas/lns/lns-common-1.s test to cover the new sub-command.
Here's the revised gas patch. This now depends on my readelf/objdump patch.
-cary
* NEWS: Add item about discriminator support.
* dwarf2dbg.h (struct dwarf2_line_info): Add discriminator field.
* dwarf2dbg.c (current): Add discriminator field.
(dwarf2_where): Copy discriminator value.
(dwarf2_consume_line_info): Set discriminator to 0.
(dwarf2_directive_loc): Process discriminator sub-op.
(out_leb128): New function.
(process_entries): Output DW_LNE_set_discriminator.
* doc/as.texinfo: Add discriminator operand to .loc directive.
* testsuite/gas/lns/lns-common-1.d: Add test for discriminator.
* testsuite/gas/lns/lns-common-1.s: Likewise.
-------------- next part --------------
Index: gas/NEWS
===================================================================
RCS file: /cvs/src/src/gas/NEWS,v
retrieving revision 1.103
diff -u -p -r1.103 NEWS
--- gas/NEWS 2 Mar 2009 10:33:06 -0000 1.103
+++ gas/NEWS 21 Apr 2009 18:41:22 -0000
@@ -1,5 +1,8 @@
-*- text -*-
+* Add support for the new discriminator column in the DWARF line table,
+ with a discriminator operand for the .loc directive.
+
* Add support for Sunplus score architecture.
* Add support for Lattice Mico32 (lm32) architecture.
Index: gas/dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.100
diff -u -p -r1.100 dwarf2dbg.c
--- gas/dwarf2dbg.c 3 Mar 2009 10:04:58 -0000 1.100
+++ gas/dwarf2dbg.c 21 Apr 2009 18:41:22 -0000
@@ -25,7 +25,8 @@
.file FILENO "file.c"
.loc FILENO LINENO [COLUMN] [basic_block] [prologue_end] \
- [epilogue_begin] [is_stmt VALUE] [isa VALUE]
+ [epilogue_begin] [is_stmt VALUE] [isa VALUE] \
+ [discriminator VALUE]
*/
#include "as.h"
@@ -194,7 +195,8 @@ bfd_boolean dwarf2_loc_mark_labels;
/* Current location as indicated by the most recent .loc directive. */
static struct dwarf2_line_info current = {
1, 1, 0, 0,
- DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0
+ DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0,
+ 0
};
/* The size of an address on the target. */
@@ -331,6 +333,7 @@ dwarf2_where (struct dwarf2_line_info *l
line->column = 0;
line->flags = DWARF2_FLAG_IS_STMT;
line->isa = current.isa;
+ line->discriminator = current.discriminator;
}
else
*line = current;
@@ -379,6 +382,7 @@ dwarf2_consume_line_info (void)
current.flags &= ~(DWARF2_FLAG_BASIC_BLOCK
| DWARF2_FLAG_PROLOGUE_END
| DWARF2_FLAG_EPILOGUE_BEGIN);
+ current.discriminator = 0;
}
/* Called for each (preferably code) label. If dwarf2_loc_mark_labels
@@ -581,6 +585,7 @@ dwarf2_directive_loc (int dummy ATTRIBUT
current.filenum = filenum;
current.line = line;
+ current.discriminator = 0;
#ifndef NO_LISTING
if (listing)
@@ -659,6 +664,18 @@ dwarf2_directive_loc (int dummy ATTRIBUT
return;
}
}
+ else if (strcmp (p, "discriminator") == 0)
+ {
+ *input_line_pointer = c;
+ value = get_absolute_expression ();
+ if (value >= 0)
+ current.discriminator = value;
+ else
+ {
+ as_bad (_("discriminator less than zero"));
+ return;
+ }
+ }
else
{
as_bad (_("unknown .loc sub-directive `%s'"), p);
@@ -748,6 +765,14 @@ out_uleb128 (addressT value)
output_leb128 (frag_more (sizeof_leb128 (value, 0)), value, 0);
}
+/* Emit a signed "little-endian base 128" number. */
+
+static void
+out_leb128 (addressT value)
+{
+ output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1);
+}
+
/* Emit a tuple for .debug_abbrev. */
static inline void
@@ -1208,6 +1233,14 @@ process_entries (segT seg, struct line_e
out_uleb128 (column);
}
+ if (e->loc.discriminator != 0)
+ {
+ out_opcode (DW_LNS_extended_op);
+ out_leb128 (1 + sizeof_leb128 (e->loc.discriminator, 0));
+ out_opcode (DW_LNE_set_discriminator);
+ out_uleb128 (e->loc.discriminator);
+ }
+
if (isa != e->loc.isa)
{
isa = e->loc.isa;
Index: gas/dwarf2dbg.h
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.h,v
retrieving revision 1.22
diff -u -p -r1.22 dwarf2dbg.h
--- gas/dwarf2dbg.h 15 Jan 2009 12:42:52 -0000 1.22
+++ gas/dwarf2dbg.h 21 Apr 2009 18:41:22 -0000
@@ -34,6 +34,7 @@ struct dwarf2_line_info {
unsigned int column;
unsigned int isa;
unsigned int flags;
+ unsigned int discriminator;
};
/* Implements the .file FILENO "FILENAME" directive. FILENO can be 0
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.199
diff -u -p -r1.199 as.texinfo
--- gas/doc/as.texinfo 27 Mar 2009 08:26:18 -0000 1.199
+++ gas/doc/as.texinfo 21 Apr 2009 18:41:22 -0000
@@ -5108,6 +5108,10 @@ either 0 or 1.
This directive will set the @code{isa} register in the @code{.debug_line}
state machine to @var{value}, which must be an unsigned integer.
+@item discriminator @var{value}
+This directive will set the @code{discriminator} register in the @code{.debug_line}
+state machine to @var{value}, which must be an unsigned integer.
+
@end table
@node Loc_mark_labels
Index: gas/testsuite/gas/lns/lns-common-1.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/lns/lns-common-1.d,v
retrieving revision 1.3
diff -u -p -r1.3 lns-common-1.d
--- gas/testsuite/gas/lns/lns-common-1.d 11 Apr 2008 17:51:15 -0000 1.3
+++ gas/testsuite/gas/lns/lns-common-1.d 21 Apr 2009 18:41:22 -0000
@@ -21,6 +21,8 @@ Raw dump of debug contents of section \.
Special opcode .*: advance Address by .* to .* and Line by 1 to 6
Set is_stmt to 1
Special opcode .*: advance Address by .* to .* and Line by 1 to 7
+ Extended opcode 4: set Discriminator to 1
+ Special opcode .*: advance Address by .* to .* and Line by 0 to 7
Advance PC by .* to .*
Extended opcode 1: End of Sequence
#...
Index: gas/testsuite/gas/lns/lns-common-1.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/lns/lns-common-1.s,v
retrieving revision 1.2
diff -u -p -r1.2 lns-common-1.s
--- gas/testsuite/gas/lns/lns-common-1.s 7 Sep 2005 19:22:42 -0000 1.2
+++ gas/testsuite/gas/lns/lns-common-1.s 21 Apr 2009 18:41:22 -0000
@@ -13,3 +13,5 @@
nop
.loc 1 7 is_stmt 1
nop
+ .loc 1 7 discriminator 1
+ nop
More information about the Binutils
mailing list