public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: A comment-finding hack for hppa I found useful
@ 2000-07-11 12:10 Nick Clifton
  2000-07-11 13:24 ` Jeffrey A Law
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nick Clifton @ 2000-07-11 12:10 UTC (permalink / raw)
  To: binutils

Hi Alan,

:    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.

So basically the problem is that (for the hppa) the comment chracater,
(';') is the same as the line seperator character for lots of other
assemblers, and that tihs leads to confusion, especially when writing
C asm statements ?

I guess I have no objections to adding the feature, although I think
that it will only very occaisionally be useful.  perhaps it could be
part of the output with the -D switch ?

: 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)

I had not heard about old compilers not supporting #ifdef, but I think
from a very strict point of view, I would prefer '#ifdef MACRO" over
"#if MACRO" since this makes clear that all that is being tested is
the fact that MACRO is defined, not what value it might happen to
have.

Cheers
	Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread
* A comment-finding hack for hppa I found useful
@ 2000-07-11  1:03 Alan Modra
  0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2000-07-11  1:03 UTC (permalink / raw)
  To: binutils

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
 }
 \f
 #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"

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-07-27 22:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-11 12:10 A comment-finding hack for hppa I found useful Nick Clifton
2000-07-11 13:24 ` Jeffrey A Law
2000-07-11 19:51 ` Alan Modra
2000-07-12 15:37 ` Michael Meissner
2000-07-12 15:48   ` Ulrich Drepper
2000-07-12 18:11   ` Alan Modra
2000-07-27 22:03 ` Alan Modra
  -- strict thread matches above, loose matches on Subject: below --
2000-07-11  1:03 Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).