This is the mail archive of the binutils@sources.redhat.com 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]

A comment-finding hack for hppa I found useful


Hello all,
   I found the following hack useful when debugging glibc sources for
hppa.  The comment in the first hunk below indicates why it's useful, but
I'm ambivalent as to whether this belongs in the official sources.
However if the general consensus (this ain't a democracy - some people 
have weightier votes than others!) is to put this in, I'll do so.  In any
case, posting it here means those who find the hack useful can use it.

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.

PS. Question for the language experts.  "#if MACRO" or "#ifdef MACRO",
which is preferred?  Given MACRO is either undefined or evaluates to 1,
there is no difference really (except I believe some really old compilers
don't even supprt #ifdef)


gas/ChangeLog
	* as.h (warn_comment, found_comment, found_comment_file): Declare.
	* app.c (do_scrub_chars): Record where first comment found.
	* read.c (read_a_source_file): Init found_comment on entry, and
	notify whether comments found on exit.
	* config/tc-hppa.c (md_shortopts): Add "c".
	(md_longopts): Add warn-comment.
	(md_parse_option): Handle it.
	* config/te-linux.h (FIND_HPPA_COMMENTS): Define to TC_HPPA.
	* config/te-hppalinux64.h (FIND_HPPA_COMMENTS): Likewise.

Index: as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.13
diff -u -p -r1.13 as.h
--- as.h	2000/05/08 10:24:05	1.13
+++ as.h	2000/07/11 06:58:42
@@ -640,6 +640,17 @@ COMMON int flag_m68k_mri;
 #define flag_m68k_mri 0
 #endif
 
+#if FIND_HPPA_COMMENTS
+/* Define to compile in an extra assembler option, -c, which enables a
+   warning (once per file) when a comment is encountered.
+   The hppa comment char is a `;' which tends to occur in random C asm
+   statements.  A semicolon is a line separator for most assemblers.
+   It's hard to find these lurking semicolons.  Thus...  */
+COMMON int warn_comment;
+COMMON unsigned int found_comment;
+COMMON char *found_comment_file;
+#endif
+
 #ifndef NUMBERS_WITH_SUFFIX
 #define NUMBERS_WITH_SUFFIX 0
 #endif
Index: app.c
===================================================================
RCS file: /cvs/src/src/gas/app.c,v
retrieving revision 1.10
diff -u -p -r1.10 app.c
--- app.c	2000/06/09 00:00:02	1.10
+++ app.c	2000/07/11 06:58:40
@@ -1171,6 +1171,10 @@ do_scrub_chars (get, tostart, tolen)
 	  if ((symver_state != NULL) && (*symver_state == 0))
 	    goto de_fault;
 #endif
+#if FIND_HPPA_COMMENTS
+	  if (!found_comment)
+	    as_where (&found_comment_file, &found_comment);
+#endif
 	  do
 	    {
 	      ch = GET ();
Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.24
diff -u -p -r1.24 read.c
--- read.c	2000/06/09 00:00:02	1.24
+++ read.c	2000/07/11 06:58:54
@@ -526,6 +526,10 @@ read_a_source_file (name)
   register int temp;
   pseudo_typeS *pop;
 
+#if FIND_HPPA_COMMENTS
+  found_comment = 0;
+#endif
+
   buffer = input_scrub_new_file (name);
 
   listing_file (name);
@@ -1098,6 +1102,13 @@ read_a_source_file (name)
   md_cleanup();
 #endif
   input_scrub_close ();		/* Close the input file */
+#if FIND_HPPA_COMMENTS
+  {
+    if (warn_comment && found_comment)
+      as_warn_where (found_comment_file, found_comment,
+		     "first comment found here");
+  }
+#endif
 }
 
 /* For most MRI pseudo-ops, the line actually ends at the first
Index: config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.59
diff -u -p -r1.59 tc-hppa.c
--- tc-hppa.c	2000/07/10 15:15:01	1.59
+++ tc-hppa.c	2000/07/11 06:59:10
@@ -4345,12 +4345,23 @@ md_estimate_size_before_relax (fragP, se
 }
 
 #ifdef OBJ_ELF
+# if FIND_HPPA_COMMENTS
+const char *md_shortopts = "Vc";
+# else
 const char *md_shortopts = "V";
+# endif
 #else
+# if FIND_HPPA_COMMENTS
+const char *md_shortopts = "c";
+# else
 const char *md_shortopts = "";
+# endif
 #endif
 
 struct option md_longopts[] = {
+#if FIND_HPPA_COMMENTS
+  {"warn-comment", no_argument, NULL, 'c'},
+#endif
   {NULL, no_argument, NULL, 0}
 };
 size_t md_longopts_size = sizeof(md_longopts);
@@ -4370,6 +4381,11 @@ md_parse_option (c, arg)
       print_version_id ();
       break;
 #endif
+#if FIND_HPPA_COMMENTS
+    case 'c':
+      warn_comment = 1;
+      break;
+#endif
     }
 
   return 1;
@@ -4431,7 +4447,7 @@ md_apply_fix (fixP, valp)
     }
 #endif
 
-  insn = bfd_get_32 (stdoutput, (unsigned char *)buf);
+  insn = bfd_get_32 (stdoutput, (unsigned char *) buf);
   /* There should have been an HPPA specific fixup associated
      with the GAS fixup.  */
   if (hppa_fixP)
Index: config/te-hppalinux64.h
===================================================================
RCS file: /cvs/src/src/gas/config/te-hppalinux64.h,v
retrieving revision 1.1
diff -u -p -r1.1 te-hppalinux64.h
--- te-hppalinux64.h	2000/07/09 08:16:21	1.1
+++ te-hppalinux64.h	2000/07/11 06:59:12
@@ -1,5 +1,13 @@
 #define TE_LINUX
 #define TARGET_ARCH_SIZE 64
 #define LOCAL_LABELS_FB 1
+#if 1
+/* Define to compile in an extra assembler option, -c, which enables a
+   warning (once per file) when a comment is encountered.
+   The hppa comment char is a `;' which tends to occur in random C asm
+   statements.  A semicolon is a line separator for most assemblers.
+   It's hard to find these lurking semicolons.  Thus...  */
+#define FIND_HPPA_COMMENTS TC_HPPA
+#endif
 
 #include "obj-format.h"
Index: config/te-linux.h
===================================================================
RCS file: /cvs/src/src/gas/config/te-linux.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 te-linux.h
--- te-linux.h	1999/05/03 07:28:44	1.1.1.1
+++ te-linux.h	2000/07/11 06:59:12
@@ -1,4 +1,12 @@
 #define TE_LINUX
 #define LOCAL_LABELS_FB 1
+#if 1
+/* Define to compile in an extra assembler option, -c, which enables a
+   warning (once per file) when a comment is encountered.
+   The hppa comment char is a `;' which tends to occur in random C asm
+   statements.  A semicolon is a line separator for most assemblers.
+   It's hard to find these lurking semicolons.  Thus...  */
+#define FIND_HPPA_COMMENTS TC_HPPA
+#endif
 
 #include "obj-format.h"


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