TRACE_WRAPPER
void
trace_n2p_set_property(void *object, struct PP_Var name, struct PP_Var value,
                       struct PP_Var *exception)
{
    char *s_name = trace_var_as_string(name);
    char *s_value = trace_var_as_string(value);
    trace_info("[CLS] {zilch} %s object=%p, name=%s, value=%s\n", __func__+6, object,
               s_name, s_value);
    g_free(s_name);
    g_free(s_value);
    n2p_set_property(object, name, value, exception);
}
TRACE_WRAPPER
PP_Bool
trace_ppb_flash_draw_glyphs(PP_Instance instance, PP_Resource pp_image_data,
                            const struct PP_BrowserFont_Trusted_Description *font_desc,
                            uint32_t color, const struct PP_Point *position,
                            const struct PP_Rect *clip, const float transformation[3][3],
                            PP_Bool allow_subpixel_aa, uint32_t glyph_count,
                            const uint16_t glyph_indices[], const struct PP_Point glyph_advances[])
{
    char *s_position = trace_point_as_string(position);
    char *s_clip = trace_rect_as_string(clip);
    char *s_face = trace_var_as_string(font_desc->face);
    trace_info("[PPB] {full} %s instance=%d, pp_image_data=%d, font_desc={.face=%s, .family=%d, "
               ".size=%u, .weight=%d, .italic=%u, .small_caps=%u, .letter_spacing=%d, "
               ".word_spacing=%d}, color=0x%x, position=%s, clip=%s, transformation={{%f,%f,%f},"
               "{%f,%f,%f},{%f,%f,%f}}, allow_subpixel_aa=%d, glyph_count=%u, glyph_indices=%p, "
               "glyph_advances=%p\n", __func__+6, instance, pp_image_data, s_face,
               font_desc->family, font_desc->size, font_desc->weight, font_desc->italic,
               font_desc->small_caps, font_desc->letter_spacing, font_desc->word_spacing,
               color, s_position, s_clip,
               transformation[0][0], transformation[0][1], transformation[0][2],
               transformation[1][0], transformation[1][1], transformation[1][2],
               transformation[2][0], transformation[2][1], transformation[2][2],
               allow_subpixel_aa, glyph_count, glyph_indices, glyph_advances);
    g_free(s_position);
    g_free(s_clip);
    g_free(s_face);
    return ppb_flash_draw_glyphs(instance, pp_image_data, font_desc, color, position, clip,
                                 transformation, allow_subpixel_aa, glyph_count, glyph_indices,
                                 glyph_advances);
}
TRACE_WRAPPER
PP_Resource
trace_ppb_keyboard_input_event_create_1_2(PP_Instance instance, PP_InputEvent_Type type,
                                          PP_TimeTicks time_stamp, uint32_t modifiers,
                                          uint32_t key_code, struct PP_Var character_text,
                                          struct PP_Var code)
{
    char *s_character_text = trace_var_as_string(character_text);
    char *s_code = trace_var_as_string(code);
    trace_info("[PPB] {full} %s instance=%d, type=%d, time_stamp=%f, modifiers=0x%x, "
               "key_code=%u, character_text=%s, code=%s\n", __func__+6, instance, type, time_stamp,
               modifiers, key_code, s_character_text, s_code);
    g_free(s_character_text);
    g_free(s_code);
    return ppb_keyboard_input_event_create_1_2(instance, type, time_stamp, modifiers, key_code,
                                               character_text, code);
}
// trace wrappers
TRACE_WRAPPER
void
trace_ppb_messaging_post_message(PP_Instance instance, struct PP_Var message)
{
    gchar *s_message = trace_var_as_string(message);
    trace_info("[PPB] {zilch} %s instance=%d, message=%s\n", __func__+6, instance, s_message);
    g_free(s_message);
    return ppb_messaging_post_message(instance, message);
}
TRACE_WRAPPER
bool
trace_n2p_has_method(void *object, struct PP_Var name, struct PP_Var *exception)
{
    char *s_name = trace_var_as_string(name);
    trace_info("[CLS] {zilch} %s object=%p, name=%s\n", __func__+6, object, s_name);
    g_free(s_name);
    return n2p_has_method(object, name, exception);
}
TRACE_WRAPPER
struct PP_Var
trace_n2p_get_property(void *object, struct PP_Var name, struct PP_Var *exception)
{
    char *s_name = trace_var_as_string(name);
    trace_info("[CLS] {full} %s object=%p, name=%s\n", __func__+6, object, s_name);
    g_free(s_name);
    return n2p_get_property(object, name, exception);
}
TRACE_WRAPPER
PP_Bool
trace_ppb_flash_set_crash_data(PP_Instance instance, PP_FlashCrashKey key, struct PP_Var value)
{
    char *value_str = trace_var_as_string(value);
    trace_info("[PPB] {full} %s instance=%d, key=%d, value=%s\n", __func__+6, instance, key,
               value_str);
    g_free(value_str);
    return ppb_flash_set_crash_data(instance, key, value);
}
TRACE_WRAPPER
int32_t
trace_ppb_font_measure_text(PP_Resource font, const struct PP_TextRun_Dev *text)
{
    gchar *s_text = trace_var_as_string(text->text);
    trace_info("[PPB] {full} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}\n",
               __func__+6, font, s_text, text->rtl, text->override_direction);
    g_free(s_text);
    return ppb_font_measure_text(font, text);
}
TRACE_WRAPPER
struct PP_Var
trace_ppb_instance_private_execute_script(PP_Instance instance, struct PP_Var script,
                                          struct PP_Var *exception)
{
    char *s_script = trace_var_as_string(script);
    trace_info("[PPB] {full} %s instance=%d, script=%s\n", __func__+6, instance, s_script);
    g_free(s_script);
    return ppb_instance_private_execute_script(instance, script, exception);
}
TRACE_WRAPPER
PP_Bool
trace_ppb_url_request_info_set_property(PP_Resource request, PP_URLRequestProperty property,
                                        struct PP_Var value)
{
    char *value_str = trace_var_as_string(value);
    trace_info("[PPB] {full} %s request=%d, property=%s, value=%s\n", __func__+6, request,
               reverse_pp_url_request_property(property), value_str);
    g_free(value_str);
    return ppb_url_request_info_set_property(request, property, value);
}
static
int32_t
trace_ppb_browser_font_trusted_measure_text(PP_Resource font,
                                      const struct PP_BrowserFont_Trusted_TextRun *text)
{
    char *s_text_text = trace_var_as_string(text->text);
    trace_info("[PPB] {full} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}\n",
               __func__+6, font, s_text_text, text->rtl, text->override_direction);
    free(s_text_text);
    return ppb_browser_font_trusted_measure_text(font, text);
}
TRACE_WRAPPER
struct PP_Var
trace_n2p_call(void *object, struct PP_Var method_name, uint32_t argc, struct PP_Var *argv,
                struct PP_Var *exception)
{
    char *s_method_name = trace_var_as_string(method_name);
    trace_info("[CLS] {full} %s object=%p, method_name=%s, argc=%u, argv=%p\n", __func__+6,
               object, s_method_name, argc, argv);
    g_free(s_method_name);
    return n2p_call(object, method_name, argc, argv, exception);
}
static
int32_t
trace_ppb_browser_font_trusted_pixel_offset_for_character(PP_Resource font,
                    const struct PP_BrowserFont_Trusted_TextRun *text, uint32_t char_offset)
{
    char *s_text_text = trace_var_as_string(text->text);
    trace_info("[PPB] {zilch} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}, "
               "char_offset=%u\n", __func__+6, font, s_text_text, text->rtl,
               text->override_direction, char_offset);
    free(s_text_text);
    return ppb_browser_font_trusted_pixel_offset_for_character(font, text, char_offset);
}
TRACE_WRAPPER
int32_t
trace_ppb_font_pixel_offset_for_character(PP_Resource font, const struct PP_TextRun_Dev *text,
                                          uint32_t char_offset)
{
    gchar *s_text = trace_var_as_string(text->text);
    trace_info("[PPB] {zilch} %s font=%d, text={.text=%s, .rtl=%u, .override_direction=%u}, "
               "char_offset=%u\n", __func__+6, font, s_text, text->rtl, text->override_direction,
               char_offset);
    g_free(s_text);
    return ppb_font_pixel_offset_for_character(font, text, char_offset);
}
TRACE_WRAPPER
PP_Resource
trace_ppb_font_create(PP_Instance instance, const struct PP_FontDescription_Dev *description)
{
    gchar *s_face = trace_var_as_string(description->face);
    trace_info("[PPB] {full} %s instance=%d, description={.face=%s, .family=%u, .size=%u, "
               ".weight=%u, .italic=%u, .small_caps=%u, .letter_spacing=%d, .word_spacing=%d}\n",
               __func__+6, instance, s_face, description->family, description->size,
               description->weight, description->italic, description->small_caps,
               description->letter_spacing, description->word_spacing);
    g_free(s_face);
    return ppb_font_create(instance, description);
}
static
PP_Resource
trace_ppb_browser_font_trusted_create(PP_Instance instance,
                                const struct PP_BrowserFont_Trusted_Description *description)
{
    char *s_face = trace_var_as_string(description->face);
    trace_info("[PPB] {full} %s instance=%d, description={.face=%s, .family=%d, .size=%u, "
               ".weight=%d, .italic=%u, .small_caps=%u, .letter_spacing=%d, .word_spacing=%d}\n",
               __func__+6, instance, s_face, description->family, description->size,
               description->weight, description->italic, description->small_caps,
               description->letter_spacing, description->word_spacing);
    free(s_face);
    return ppb_browser_font_trusted_create(instance, description);
}
TRACE_WRAPPER
PP_Resource
trace_ppb_ime_input_event_create(PP_Instance instance, PP_InputEvent_Type type,
                                 PP_TimeTicks time_stamp, struct PP_Var text,
                                 uint32_t segment_number, const uint32_t segment_offsets[],
                                 int32_t target_segment, uint32_t selection_start,
                                 uint32_t selection_end)
{
    char *s_text = trace_var_as_string(text);
    trace_info("[PPB] {zilch} %s instance=%d, type=%d, time_stamp=%f, text=%s, segment_number=%u, "
               "segment_offsets=%p, target_segment=%d, selection_start=%u, selection_end=%u\n",
               __func__+6, instance, type, time_stamp, s_text, segment_number, segment_offsets,
               target_segment, selection_start, selection_end);
    g_free(s_text);
    return ppb_ime_input_event_create(instance, type, time_stamp, text, segment_number,
                                      segment_offsets, target_segment, selection_start,
                                      selection_end);
}
static
PP_Bool
trace_ppb_browser_font_trusted_draw_text_at(PP_Resource font, PP_Resource image_data,
                                      const struct PP_BrowserFont_Trusted_TextRun *text,
                                      const struct PP_Point *position, uint32_t color,
                                      const struct PP_Rect *clip, PP_Bool image_data_is_opaque)
{
    char *s_text_text = trace_var_as_string(text->text);
    char *s_position = trace_point_as_string(position);
    char *s_clip = trace_rect_as_string(clip);
    trace_info("[PPB] {full} %s font=%d, image_data=%d, text={.text=%s, .rtl=%u, "
               ".override_direction=%u}, position=%s, color=0x%06x, clip=%s, "
               "image_data_is_opaque=%u\n", __func__+6, font, image_data, s_text_text, text->rtl,
               text->override_direction, s_position, color, s_clip, image_data_is_opaque);
    free(s_text_text);
    free(s_position);
    free(s_clip);
    return ppb_browser_font_trusted_draw_text_at(font, image_data, text, position, color, clip,
                                                 image_data_is_opaque);
}