This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] General info in AS listings


Hi, this simple patch adds a new 'g' sub-option to the '-a' gas switch
to print general information in assembly listings like gas version,
options passed, or time stamp.

For example:

$ as tasking.s -o tasking.o -L -alg --traditional-format --MD
Makefile.tasking -I ..
SPARC GAS  tasking.s                    page 1


 GNU assembler version 2.18.50 (sparc-elf)
         using BFD version (GNU Binutils) 2.18.50.20080330.
 options passed : -L -alg --traditional-format --MD -I
 input file     : tasking.s
 output file    : tasking.o
 target         : sparc-unknown-elf
 time stamp     : 2008-03-30T17:41:09.000-0400

^LSPARC GAS  tasking.s                  page 2


   1                            .file   "tasking.adb"
   2                            .global tasking_E
   3                            .section        ".data"
   4                            .type   tasking_E, #object
   5                            .size   tasking_E, 1
   6                    tasking_E:
   7 0000 00                    .skip   1
   8                            .local  tasking___chain
   9                            .common tasking___chain,4,4
  10                            .type   tasking__periodicTKE, #object
  11                            .size   tasking__periodicTKE, 1

...


This is my first patch in a FSF project. It is very simple, do I need
to sign the copyright papers? I've no problem in doing that. The patch
includes the Changefile and texi changes.

Best regards,

-- 
Santiago Urueña Pascual <suruena@gmail.com>
Index: gas/ChangeLog
===================================================================
RCS file: /cvs/src/src/gas/ChangeLog,v
retrieving revision 1.3523
diff -u -r1.3523 ChangeLog
--- gas/ChangeLog	28 Mar 2008 21:51:37 -0000	1.3523
+++ gas/ChangeLog	30 Mar 2008 21:15:59 -0000
@@ -1,3 +1,9 @@
+2008-03-30  Santiago Urueña  <suruena@gmail.com>
+
+	* listing.c (listing_general_info): Additional listing flag
+	to show general information in listings like passed options
+	and gas version.
+
 2008-03-28  Eric B. Weddington  <eric.weddington@atmel.com>
 
 	* config/tc-avr.c (mcu_types): Add attiny167.
Index: gas/as.c
===================================================================
RCS file: /cvs/src/src/gas/as.c,v
retrieving revision 1.78
diff -u -r1.78 as.c
--- gas/as.c	26 Sep 2007 06:54:00 -0000	1.78
+++ gas/as.c	30 Mar 2008 21:15:59 -0000
@@ -232,6 +232,7 @@
                       	  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\
@@ -370,10 +371,6 @@
 static void
 parse_args (int * pargc, char *** pargv)
 {
-  int old_argc;
-  int new_argc;
-  char ** old_argv;
-  char ** new_argv;
   /* Starting the short option string with '-' is for programs that
      expect options and other ARGV-elements in any order and that care about
      the ordering of the two.  We describe each non-option ARGV-element
@@ -825,6 +822,9 @@
 		    case 'd':
 		      listing |= LISTING_NODEBUG;
 		      break;
+		    case 'g':
+		      listing |= LISTING_GENERAL;
+		      break;
 		    case 'h':
 		      listing |= LISTING_HLL;
 		      break;
Index: gas/as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.59
diff -u -r1.59 as.h
--- gas/as.h	17 Oct 2007 16:45:54 -0000	1.59
+++ gas/as.h	30 Mar 2008 21:16:00 -0000
@@ -381,6 +381,10 @@
 typedef struct relax_type relax_typeS;
 
 /* main program "as.c" (command arguments etc).  */
+COMMON int old_argc;
+COMMON int new_argc;
+COMMON char ** old_argv;
+COMMON char ** new_argv;
 
 COMMON unsigned char flag_no_comments; /* -f */
 COMMON unsigned char flag_debug; /* -D */
Index: gas/listing.c
===================================================================
RCS file: /cvs/src/src/gas/listing.c,v
retrieving revision 1.32
diff -u -r1.32 listing.c
--- gas/listing.c	3 Jul 2007 11:01:03 -0000	1.32
+++ gas/listing.c	30 Mar 2008 21:16:00 -0000
@@ -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
@@ -217,6 +220,10 @@
 static void list_symbol_table (void);
 static void print_source (file_info_type *, list_info_type *, char *, unsigned int);
 static int debugging_pseudo (list_info_type *, const char *);
+static void print_timestamp (void);
+static void print_single_option (const char * opt, int *pos);
+static void print_options (void);
+static void listing_general_info (void);
 static void listing_listing (char *);
 
 static void
@@ -1056,6 +1063,83 @@
   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     : %s\n\n"), stampstr);
+}
+
+
+static void
+print_single_option (const 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%s "), opt);
+        *pos = opt_len;
+     }
+}
+
+/* Print options passed to as. */
+static void
+print_options (void)
+{
+  char **p;
+  int pos = 0;
+
+  fprintf (list_file, _("\n options passed : "));
+  for (p = &old_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.      */
+static void
+listing_general_info (void)
+{
+
+  /* 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 ();
+  fprintf (list_file, _("\n input file     : %s"), fn);
+  fprintf (list_file, _("\n output file    : %s"), out_file_name);
+  fprintf (list_file, _("\n target         : %s"), TARGET_CANONICAL);
+  print_timestamp ();
+}
+
 void
 listing_print (char *name)
 {
@@ -1085,6 +1169,9 @@
   if (listing & LISTING_NOFORM)
     paper_height = 0;
 
+  if (listing & LISTING_GENERAL)
+    listing_general_info ();
+
   if (listing & LISTING_LISTING)
     listing_listing (name);
 
Index: gas/listing.h
===================================================================
RCS file: /cvs/src/src/gas/listing.h,v
retrieving revision 1.6
diff -u -r1.6 listing.h
--- gas/listing.h	3 Jul 2007 11:01:03 -0000	1.6
+++ gas/listing.h	30 Mar 2008 21:16:00 -0000
@@ -27,8 +27,9 @@
 #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)
 
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.177
diff -u -r1.177 as.texinfo
--- gas/doc/as.texinfo	22 Jan 2008 19:16:44 -0000	1.177
+++ gas/doc/as.texinfo	30 Mar 2008 21:16:07 -0000
@@ -228,7 +228,7 @@
 @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 @@
 @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 @@
 @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 @@
 @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 @@
 @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 @@
 @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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]