xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Christian Lindig <christian.lindig@citrix.com>,
	Wei Liu <wl@xen.org>, David Scott <dave@recoil.org>
Subject: [Xen-devel] [PATCH v3 07/12] tools/ocaml: abi-check: Improve output and error messages
Date: Tue, 10 Sep 2019 13:02:02 +0100	[thread overview]
Message-ID: <20190910120207.10358-8-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <20190910120207.10358-1-ian.jackson@eu.citrix.com>

In the generated C, add some comments saying where we found the ocaml
type.  This helps with debugging.  (I considered emitting #line
directives but decided this would be more confusing than helpful.)

Improve two dies.

Use better-named filehandles (perl prints thier names when it dies).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/ocaml/libs/xc/abi-check | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/ocaml/libs/xc/abi-check b/tools/ocaml/libs/xc/abi-check
index a470c05e0b..9450676429 100755
--- a/tools/ocaml/libs/xc/abi-check
+++ b/tools/ocaml/libs/xc/abi-check
@@ -15,7 +15,7 @@ our %enums;
 @ARGV == 2 or die;
 our ($c, $o) = @ARGV;
 
-open STDIN, "<", $c or die $!;
+open C_FILE, "<", $c or die $!;
 
 our $cline = -1;
 our $ei;
@@ -29,7 +29,7 @@ our $ei;
 #   /* ! CPrefix CFinal CFinalHow */
 #
 # The function definitions use /* ! */ which simply skips that instance.
-while (<>) {
+while (<C_FILE>) {
     if ($cline == -1) {
         if (m/c_bitmap_to_ocaml_list|ocaml_list_to_c_bitmap/) {
             $cline = 0;
@@ -37,7 +37,8 @@ while (<>) {
         }
     } else {
         $cline++;
-        m{^\s+/\* \s+ ! \s+ (.*?) \s* \*/\s*$}x or die "$cline $_ ?";
+        m{^\s+/\* \s+ ! \s+ (.*?) \s* \*/\s*$}x or
+            die "at line $cline of annotation, did not expect $_ ?";
         my @vals = split /\s+/, $1;
         if ($cline == 1 && !@vals) {
             $cline = -1;
@@ -45,7 +46,7 @@ while (<>) {
             $ei->{$_} = shift @vals foreach qw(OType OPrefix Mangle);
         } elsif ($cline == 2 && @vals == 3) {
             $ei->{$_} = shift @vals foreach qw(CPrefix CFinal CFinalHow);
-            die if $enums{ $ei->{OType} };
+            die "redefining OType $ei->{OType}" if $enums{ $ei->{OType} };
             $enums{ $ei->{OType} } = $ei;
             $cline = -1;
         } else {
@@ -58,13 +59,14 @@ sub expect ($$) {
     printf "BUILD_BUG_ON( %-30s != %-10s );\n", @_ or die $!;
 }
 
-open STDIN, "<", $o or die $!;
+open OCAML_FILE, "<", $o or die $!;
 my $cval;
 $ei = undef;
 my $bitnum = 0;
-while (<>) {
+while (<OCAML_FILE>) {
     if (!$ei) {
         if (m{^type \s+ (\w+) \s* \= \s* $/}x && $enums{$1}) {
+            print "// found ocaml type $1 at $o:$.\n" or die $!;
             $ei = $enums{$1};
             $cval = '';
             $bitnum = 0;
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-09-10 12:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 12:01 [Xen-devel] [PATCH v3 00/12] ocaml abi fixes Ian Jackson
2019-09-10 12:01 ` [Xen-devel] [PATCH v3 01/12] tools/ocaml: Add missing X86_EMU_VPCI Ian Jackson
2019-09-10 12:01 ` [Xen-devel] [PATCH v3 02/12] tools/ocaml: Add missing CAP_PV Ian Jackson
2019-09-10 12:01 ` [Xen-devel] [PATCH v3 03/12] tools/ocaml: Introduce xenctrl ABI build-time checks Ian Jackson
2019-09-10 12:17   ` Jan Beulich
2019-09-10 12:18     ` Andrew Cooper
2019-09-10 12:01 ` [Xen-devel] [PATCH v3 04/12] xen/domctl: Drop guest suffix from XEN_DOMCTL_CDF_hvm Ian Jackson
2019-09-10 12:20   ` Andrew Cooper
2019-09-10 12:41     ` Ian Jackson
2019-09-10 13:44     ` Julien Grall
2019-09-10 13:32   ` Jan Beulich
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 05/12] tools/ocaml: abi-check: Add comments Ian Jackson
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 06/12] tools/ocaml: abi handling: Provide ocaml->C conversion/check Ian Jackson
2019-09-10 12:22   ` Andrew Cooper
2019-09-10 12:50     ` Ian Jackson
2019-09-10 12:02 ` Ian Jackson [this message]
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 08/12] tools/ocaml: abi-check: Cope with multiple conversions of same type Ian Jackson
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 09/12] tools/ocaml: Reformat domain_create_flag Ian Jackson
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 10/12] tools/ocaml: abi-check: Check properly Ian Jackson
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 11/12] tools/ocaml: tools/ocaml: Add missing CDF_* values Ian Jackson
2019-09-10 12:02 ` [Xen-devel] [PATCH v3 12/12] tools/ocaml: abi: Use formal conversion and check in more places Ian Jackson
2019-09-10 12:18   ` Jan Beulich
2019-09-10 13:24 ` [Xen-devel] [PATCH v3 00/12] ocaml abi fixes Ian Jackson
2019-09-10 13:27   ` Christian Lindig
2019-09-10 13:45   ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910120207.10358-8-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=christian.lindig@citrix.com \
    --cc=dave@recoil.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).