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.
+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
-*- 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.
/* 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.
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\
case 'd':
listing |= LISTING_NODEBUG;
break;
+ case 'g':
+ listing |= LISTING_GENERAL;
+ break;
case 'h':
listing |= LISTING_HLL;
break;
int
main (int argc, char ** argv)
{
+ char ** argv_orig = argv;
+
int macro_strip_at;
int keep_it;
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)
@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}]
@table @gcctabopt
@include at-file.texi
-@item -a[cdhlmns]
+@item -a[cdghlmns]
Turn on listings, in any of a variety of ways:
@table @gcctabopt
@item -ad
omit debugging directives
+@item -ag
+include general information, like @value{AS} version and options passed
+
@item -ah
include high-level source
@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
@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
@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
/* 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.
#include "safe-ctype.h"
#include "input-file.h"
#include "subsegs.h"
+#include "bfdver.h"
+#include <time.h>
#ifndef NO_LISTING
#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
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, ×tamp);
+ strftime (stampstr, MAX_DATELEN, "%Y-%m-%dT%H:%M:%S.000%z", ×tamp);
+ 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;
if (listing & LISTING_NOFORM)
paper_height = 0;
+ if (listing & LISTING_GENERAL)
+ listing_general_info (argv);
+
if (listing & LISTING_LISTING)
listing_listing (name);
/* 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.
#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
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 *);
+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
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.