gdb: defer commit resume until all available events are consumed
[deliverable/binutils-gdb.git] / gdb / reply_mig_hack.awk
index 97e080f254cd4568a6a9001ed875be477f310762..6ff683a841bbe99710eff4335bc3a8930b17138f 100644 (file)
@@ -1,6 +1,6 @@
 # Reply server mig-output massager
 #
-#   Copyright (C) 1995-2013 Free Software Foundation, Inc.
+#   Copyright (C) 1995-2020 Free Software Foundation, Inc.
 #
 #   Written by Miles Bader <miles@gnu.ai.mit.edu>
 #
@@ -49,7 +49,7 @@ parse_phase == 2 {
   print; next;
 }
 
-parse_phase == 3 && /}/ {
+parse_phase == 3 && /} Request/ {
   # The args structure is over.
   if (num_args > 1)
     parse_phase = 5;
@@ -60,27 +60,44 @@ parse_phase == 3 && /}/ {
   print; next;
 }
 
-parse_phase == 3 {
+parse_phase == 3 && num_args == 0 {
   # The type field for an argument.
+  # This won't be accurate in case of unions being used in the Request struct,
+  # but that doesn't matter, as we'll only be looking at arg_type_code_name[0],
+  # which will not be a union type.
   arg_type_code_name[num_args] = $2;
   sub (/;$/, "", arg_type_code_name[num_args]) # Get rid of the semi-colon
   parse_phase = 4;
   print; next;
 }
 
+parse_phase == 3 && num_args == 1 {
+  # We've got more than one argument (but we don't care what it is).
+  num_args++;
+  print; next;
+}
+
+parse_phase == 3 {
+  # We've know everything we need; now just wait for the end of the Request
+  # struct.
+  print; next;
+}
+
 parse_phase == 4 {
   # The value field for an argument.
+  # This won't be accurate in case of unions being used in the Request struct,
+  # but that doesn't matter, as we'll only be looking at arg_name[0], which
+  # will not be a union type.
   arg_name[num_args] = $2;
   sub (/;$/, "", arg_name[num_args]) # Get rid of the semi-colon
-  arg_type[num_args] = $1;
   num_args++;
   parse_phase = 3;
   print; next;
 }
 
-parse_phase == 5 && /^[ \t]*(auto|static) const mach_msg_type_t/ {
+parse_phase == 5 && /^[ \t]*(auto |static )?const mach_msg_type_t/ {
   # The type check structure for an argument.
-  arg_check_name[num_checks] = $4;
+  arg_check_name[num_checks] = $(NF - 2);
   num_checks++;
   print; next;
 }
@@ -92,6 +109,12 @@ parse_phase == 5 && /^[ \t]*mig_external kern_return_t/ {
 }
 
 parse_phase == 5 && /^#if[ \t]TypeCheck/ {
+  # Keep going if we have not yet collected the type check structures.
+  if (num_checks == 0)
+    {
+      print; next;
+    }
+
   # The first args type checking statement; we need to insert our chunk of
   # code that bypasses all the type checks if this is an error return, after
   # which we're done until we get to the next function.  Handily, the size
@@ -103,15 +126,12 @@ parse_phase == 5 && /^#if[ \t]TypeCheck/ {
   print "\t    && In0P->" arg_name[0] " != 0)";
   print "\t  /* Error return, only the error code argument is passed.  */";
   print "\t  {";
-  # Force the function into a type that only takes the first two args, via
-  # the temp variable SFUN (is there another way to correctly do this cast?).
+  # Force the function user_function_name into a type that only takes the first
+  # two arguments.
   # This is possibly bogus, but easier than supplying bogus values for all
   # the other args (we can't just pass 0 for them, as they might not be scalar).
-  printf ("\t    kern_return_t (*sfun)(mach_port_t");
-  for (i = 0; i < num_args; i++)
-    printf (", %s", arg_type[i]);
-  printf (") = %s;\n", user_function_name);
-  print "\t    OutP->RetCode = (*(kern_return_t (*)(mach_port_t, kern_return_t))sfun) (In0P->Head.msgh_request_port, In0P->" arg_name[0] ");";
+  print "\t    void * __error_call = " user_function_name ";";
+  print "\t    OutP->RetCode = (*(kern_return_t (*)(mach_port_t, kern_return_t)) __error_call) (In0P->Head.msgh_request_port, In0P->" arg_name[0] ");";
   print "\t    return;";
   print "\t  }";
   print "";
This page took 0.0254 seconds and 4 git commands to generate.