[gjs: 12/26] function: Add more marshalling debug logs



commit be6872836f7292274c880528971f733f0f83c3f0
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Mar 9 11:44:27 2019 -0800

    function: Add more marshalling debug logs
    
    Add some debug log statements explaining a bit more about what is
    happening when arguments are converted to and from introspected
    functions.
    
    There should be no performance concern about adding these logging
    statements, because they are ifdef'd out unless you build with
    GJS_VERBOSE_ENABLE_MARSHAL=1 defined.

 gi/arg.cpp      | 12 +++++++++---
 gi/function.cpp | 17 +++++++++++++++--
 2 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index c7be410c..4b6b892b 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1297,6 +1297,11 @@ gjs_array_to_explicit_array_internal(JSContext       *context,
     GITypeInfo *param_info;
     bool found_length;
 
+    gjs_debug_marshal(
+        GJS_DEBUG_GFUNCTION,
+        "Converting argument '%s' JS value %s to C array, transfer %d",
+        arg_name, gjs_debug_value(value).c_str(), transfer);
+
     param_info = g_type_info_get_param_type(type_info, 0);
 
     if ((value.isNull() && !may_be_null) ||
@@ -1613,9 +1618,10 @@ gjs_value_to_g_argument(JSContext      *context,
 {
     GITypeTag type_tag = g_type_info_get_tag(type_info);
 
-    gjs_debug_marshal(GJS_DEBUG_GFUNCTION,
-                      "Converting JS::Value to GArgument %s",
-                      g_type_tag_to_string(type_tag));
+    gjs_debug_marshal(
+        GJS_DEBUG_GFUNCTION,
+        "Converting argument '%s' JS value %s to GIArgument type %s", arg_name,
+        gjs_debug_value(value).c_str(), g_type_tag_to_string(type_tag));
 
     bool nullable_type = false;
     bool wrong = false;  // return false
diff --git a/gi/function.cpp b/gi/function.cpp
index 809dfac2..fffb3178 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -865,11 +865,16 @@ gjs_invoke_c_function(JSContext                             *context,
         GIArgInfo arg_info;
         bool arg_removed = false;
 
-        /* gjs_debug(GJS_DEBUG_GFUNCTION, "gi_arg_pos: %d c_arg_pos: %d js_arg_pos: %d", gi_arg_pos, 
c_arg_pos, js_arg_pos); */
-
         g_callable_info_load_arg( (GICallableInfo*) function->info, gi_arg_pos, &arg_info);
         direction = g_arg_info_get_direction(&arg_info);
 
+        gjs_debug_marshal(
+            GJS_DEBUG_GFUNCTION,
+            "Processing argument '%s' (direction %d), %d/%d GI args, "
+            "%d/%d C args, %d/%zu JS args",
+            g_base_info_get_name(&arg_info), direction, gi_arg_pos, gi_argc,
+            c_arg_pos, c_argc, js_arg_pos, args.length());
+
         g_assert_cmpuint(c_arg_pos, <, c_argc);
         ffi_arg_pointers[c_arg_pos] = &in_arg_cvalues[c_arg_pos];
 
@@ -1214,6 +1219,14 @@ release:
                  */
                 transfer = GI_TRANSFER_NOTHING;
             }
+
+            gjs_debug_marshal(
+                GJS_DEBUG_GFUNCTION,
+                "Releasing in-argument '%s' (direction %d, transfer %d), "
+                "%d/%d GI args, %d/%d C args",
+                g_base_info_get_name(&arg_info), direction, transfer,
+                gi_arg_pos, gi_argc, c_arg_pos, processed_c_args);
+
             if (param_type == PARAM_CALLBACK) {
                 ffi_closure *closure = (ffi_closure *) arg->v_pointer;
                 if (closure) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]