aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-04-10 12:45:18 +0000
committerNick Clifton <nickc@redhat.com>2008-04-10 12:45:18 +0000
commit83f10cb26a460a5ab1921b6305e63e848b1d798f (patch)
treebdeca9f8e57a8beda8fdfc407e2381b9eb202910 /gas
parent45a5551e7407cb5815016928bfce96262084b751 (diff)
downloadgdb-83f10cb26a460a5ab1921b6305e63e848b1d798f.zip
gdb-83f10cb26a460a5ab1921b6305e63e848b1d798f.tar.gz
gdb-83f10cb26a460a5ab1921b6305e63e848b1d798f.tar.bz2
* listing.c: Add -ag listing flag to show general information in
listings such as gas version, passed options, and time stamp. (listing_general_info): New function. (print_options): New function. (print_single_option): New function. (print_timestamp): New function. (MAX_DATELEN): Define. (listing_print): Add call to listing_general_info. * listing.h (LISTING_GENERAL): Define. (listing_print): Add new parameter. * as.c (show_usage): Print new switch. (parse_args): Parse new switch. (main): Pass command line on to listing_print. * NEWS: Mention this new feature. * doc/as.texinfo: Document the new sub-option. * gas/all/gas.exp: Check the performance of the -ag command line switch.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog18
-rw-r--r--gas/NEWS5
-rw-r--r--gas/as.c10
-rw-r--r--gas/doc/as.texinfo15
-rw-r--r--gas/listing.c95
-rw-r--r--gas/listing.h11
-rw-r--r--gas/testsuite/ChangeLog5
-rw-r--r--gas/testsuite/gas/all/gas.exp25
8 files changed, 171 insertions, 13 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 3f18678..c25d7a3 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,21 @@
+2008-04-10 Santiago Urueña <suruena@gmail.com>
+
+ * listing.c: Add -ag listing flag to show general information in
+ listings such as gas version, passed options, and time stamp.
+ (listing_general_info): New function.
+ (print_options): New function.
+ (print_single_option): New function.
+ (print_timestamp): New function.
+ (MAX_DATELEN): Define.
+ (listing_print): Add call to listing_general_info.
+ * listing.h (LISTING_GENERAL): Define.
+ (listing_print): Add new parameter.
+ * as.c (show_usage): Print new switch.
+ (parse_args): Parse new switch.
+ (main): Pass command line on to listing_print.
+ * NEWS: Mention this new feature.
+ * doc/as.texinfo: Document the new sub-option.
+
2008-04-08 Alan Modra <amodra@bigpond.net.au>
* dwarf2dbg.c (dwarf2_emit_insn): Simplify test before dwarf2_where
diff --git a/gas/NEWS b/gas/NEWS
index 20ac4bb..f6cd969 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,4 +1,9 @@
-*- text -*-
+* New sub-option added to the assembler's -a command line switch to
+ generate a listing output. The 'g' sub-option will insert into the listing
+ various information about the assembly, such as assembler version, the
+ command line options used, and a time stamp.
+
* New command line option -msse2avx for x86 target to encode SSE
instructions with VEX prefix.
diff --git a/gas/as.c b/gas/as.c
index 200a4d1..f1a535e 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1,6 +1,6 @@
/* as.c - GAS main program.
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -232,6 +232,7 @@ Options:\n\
Sub-options [default hls]:\n\
c omit false conditionals\n\
d omit debugging directives\n\
+ g include general info\n\
h include high-level source\n\
l include assembly\n\
m include macro expansions\n\
@@ -825,6 +826,9 @@ This program has absolutely no warranty.\n"));
case 'd':
listing |= LISTING_NODEBUG;
break;
+ case 'g':
+ listing |= LISTING_GENERAL;
+ break;
case 'h':
listing |= LISTING_HLL;
break;
@@ -1077,6 +1081,8 @@ create_obj_attrs_section (void)
int
main (int argc, char ** argv)
{
+ char ** argv_orig = argv;
+
int macro_strip_at;
int keep_it;
@@ -1232,7 +1238,7 @@ main (int argc, char ** argv)
fflush (stderr);
#ifndef NO_LISTING
- listing_print (listing_filename);
+ listing_print (listing_filename, argv_orig);
#endif
if (flag_fatal_warnings && had_warnings () > 0 && had_errors () == 0)
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index 0520e47..fbbfa21 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -228,7 +228,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
@c to be limited to one line for the header.
@smallexample
@c man begin SYNOPSIS
-@value{AS} [@b{-a}[@b{cdhlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
+@value{AS} [@b{-a}[@b{cdghlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
[@b{--debug-prefix-map} @var{old}=@var{new}]
[@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}]
[@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}]
@@ -462,7 +462,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
@table @gcctabopt
@include at-file.texi
-@item -a[cdhlmns]
+@item -a[cdghlmns]
Turn on listings, in any of a variety of ways:
@table @gcctabopt
@@ -472,6 +472,9 @@ omit false conditionals
@item -ad
omit debugging directives
+@item -ag
+include general information, like @value{AS} version and options passed
+
@item -ah
include high-level source
@@ -1576,7 +1579,7 @@ assembler.)
@c man end
@menu
-* a:: -a[cdhlns] enable listings
+* a:: -a[cdghlns] enable listings
* alternate:: --alternate enable alternate macro syntax
* D:: -D for compatibility
* f:: -f to work faster
@@ -1602,11 +1605,12 @@ assembler.)
@end menu
@node a
-@section Enable Listings: @option{-a[cdhlns]}
+@section Enable Listings: @option{-a[cdghlns]}
@kindex -a
@kindex -ac
@kindex -ad
+@kindex -ag
@kindex -ah
@kindex -al
@kindex -an
@@ -1624,6 +1628,9 @@ High-level listings require that a compiler debugging option like
@samp{-g} be used, and that assembly listings (@samp{-al}) be requested
also.
+Use the @samp{-ag} option to print a first section with general assembly
+information, like @value{AS} version, switches passed, or time stamp.
+
Use the @samp{-ac} option to omit false conditionals from a listing. Any lines
which are not assembled because of a false @code{.if} (or @code{.ifdef}, or any
other conditional), or a true @code{.if} followed by an @code{.else}, will be
diff --git a/gas/listing.c b/gas/listing.c
index 1eca647..adda391 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -1,6 +1,6 @@
/* listing.c - maintain assembly listings
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2005, 2006, 2007
+ 2001, 2002, 2003, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -94,6 +94,8 @@
#include "safe-ctype.h"
#include "input-file.h"
#include "subsegs.h"
+#include "bfdver.h"
+#include <time.h>
#ifndef NO_LISTING
@@ -115,6 +117,7 @@
#ifndef LISTING_LHS_CONT_LINES
#define LISTING_LHS_CONT_LINES 4
#endif
+#define MAX_DATELEN 30
/* This structure remembers which .s were used. */
typedef struct file_info_struct
@@ -1056,8 +1059,93 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
data_buffer = NULL;
}
+/* Print time stamp in ISO format: yyyy-mm-ddThh:mm:ss.ss+/-zzzz. */
+
+static void
+print_timestamp (void)
+{
+ const time_t now = time (NULL);
+ struct tm timestamp;
+ char stampstr[MAX_DATELEN];
+
+ /* Any portable way to obtain subsecond values??? */
+ localtime_r (&now, &timestamp);
+ strftime (stampstr, MAX_DATELEN, "%Y-%m-%dT%H:%M:%S.000%z", &timestamp);
+ fprintf (list_file, _("\n time stamp \t: %s\n\n"), stampstr);
+}
+
+static void
+print_single_option (char * opt, int *pos)
+{
+ int opt_len = strlen (opt);
+
+ if ((*pos + opt_len) < paper_width)
+ {
+ fprintf (list_file, _("%s "), opt);
+ *pos = *pos + opt_len;
+ }
+ else
+ {
+ fprintf (list_file, _("\n\t%s "), opt);
+ *pos = opt_len;
+ }
+}
+
+/* Print options passed to as. */
+
+static void
+print_options (char ** argv)
+{
+ const char *field_name = _("\n options passed\t: ");
+ int pos = strlen (field_name);
+ char **p;
+
+ fprintf (list_file, field_name);
+ for (p = &argv[1]; *p != NULL; p++)
+ if (**p == '-')
+ {
+ /* Ignore these. */
+ if (strcmp (*p, "-o") == 0)
+ {
+ if (p[1] != NULL)
+ p++;
+ continue;
+ }
+ if (strcmp (*p, "-v") == 0)
+ continue;
+
+ print_single_option (*p, &pos);
+ }
+}
+
+/* Print a first section with basic info like file names, as version,
+ options passed, target, and timestamp.
+ The format of this section is as follows:
+
+ AS VERSION
+
+ fieldname TAB ':' fieldcontents
+ { TAB fieldcontents-cont } */
+
+static void
+listing_general_info (char ** argv)
+{
+ /* Print the stuff on the first line. */
+ eject = 1;
+ listing_page (0);
+
+ fprintf (list_file,
+ _(" GNU assembler version %s (%s)\n\t using BFD version %s."),
+ VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
+ print_options (argv);
+ fprintf (list_file, _("\n input file \t: %s"), fn);
+ fprintf (list_file, _("\n output file \t: %s"), out_file_name);
+ fprintf (list_file, _("\n target \t: %s"), TARGET_CANONICAL);
+ print_timestamp ();
+}
+
void
-listing_print (char *name)
+listing_print (char *name, char **argv)
{
int using_stdout;
@@ -1085,6 +1173,9 @@ listing_print (char *name)
if (listing & LISTING_NOFORM)
paper_height = 0;
+ if (listing & LISTING_GENERAL)
+ listing_general_info (argv);
+
if (listing & LISTING_LISTING)
listing_listing (name);
diff --git a/gas/listing.h b/gas/listing.h
index d78c2b1..1969b34 100644
--- a/gas/listing.h
+++ b/gas/listing.h
@@ -1,6 +1,6 @@
/* This file is listing.h
Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1997, 1998,
- 2003, 2007 Free Software Foundation, Inc.
+ 2003, 2007, 2008 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -27,13 +27,14 @@
#define LISTING_NOFORM 4
#define LISTING_HLL 8
#define LISTING_NODEBUG 16
-#define LISTING_NOCOND 32
-#define LISTING_MACEXP 64
+#define LISTING_NOCOND 32
+#define LISTING_MACEXP 64
+#define LISTING_GENERAL 128
#define LISTING_DEFAULT (LISTING_LISTING | LISTING_HLL | LISTING_SYMBOLS)
#ifndef NO_LISTING
-#define LISTING_NEWLINE() { if (listing) listing_newline(NULL); }
+#define LISTING_NEWLINE() { if (listing) listing_newline (NULL); }
#else
#define LISTING_NEWLINE() {;}
#endif
@@ -48,7 +49,7 @@ void listing_flags (int);
void listing_list (int on);
void listing_newline (char *ps);
void listing_prev_line (void);
-void listing_print (char *name);
+void listing_print (char *, char **);
void listing_psize (int);
void listing_nopage (int);
void listing_source_file (const char *);
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 3ff7e45..bc31103 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-10 Santiago Urueña <suruena@gmail.com>
+
+ * gas/all/gas.exp: Check the performance of the -ag command line
+ switch.
+
2008-04-10 Andreas Krebbel <krebbel1@de.ibm.com>
* gas/s390/zarch-z10.d: Map the compare and branch variants
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 11d7b53..6b63d02 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -134,6 +134,31 @@ proc do_comment {} {
do_comment
+# This test checks the output of the -ag switch. It must detect at least
+# the name of the input file, output file, and options passed.
+proc general_info_section {} {
+ set testname "general info section in listings"
+ set x1 0
+ set x2 0
+ set x3 0
+ set white {[ \t]*}
+ gas_start "comment.s" "-agn"
+ while 1 {
+ expect {
+ -re "^ \[^\n\]*\t: \-agn\[^\n\]*\n" { set x1 1 }
+ -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
+ -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
+ -re "\[^\n\]*\n" { }
+ timeout { perror "timeout\n"; break }
+ eof { break }
+ }
+ }
+ gas_finish
+ if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
+}
+
+general_info_section
+
#
# Test x930509a -- correct assembly of differences involving forward
# references.