DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { # ifdef WINDOWS dr_enable_console_printing(); # endif client_id = id; /* XXX: should use droption */ if (argc > 1 && strcmp(argv[1], "full-decode") == 0) { PRINT("Init annotation test client with full decoding"); dr_register_bb_event(empty_bb_event); } else if (argc > 1 && strlen(argv[1]) >= 8 && strncmp(argv[1], "truncate", 8) == 0) { bb_truncation_length = (argv[1][9] - '0'); /* format is "truncate@n" (0<n<10) */ ASSERT(bb_truncation_length < 10 && bb_truncation_length > 0); PRINT("Init annotation test client with bb truncation"); dr_register_bb_event(bb_event_truncate); } else { PRINT("Init annotation test client with fast decoding"); } register_call("test_annotation_two_args", (void *) test_two_args, 2); register_call("test_annotation_three_args", (void *) test_three_args, 3); register_call("test_annotation_eight_args", (void *) test_eight_args, 8); register_call("test_annotation_nine_args", (void *) test_nine_args, 9); register_call("test_annotation_ten_args", (void *) test_ten_args, 10); }
void ScreenPhone::hangUp(pjsua_call_id &call_id, const QString &account_id) { if(call_id<0) { return; } qDebug() << "Hanging up call: " << QString::number(call_id); register_call(call_id, account_id); if(m_c1_call_id == call_id) { this->setC1_timer(-1); this->setC1_call_id(-1); this->setC1_state("available"); this->setC1_sip_actiontext(""); this->setC1_downrate(""); this->setC1_uprate(""); this->setC1_loss(""); this->setC1_stream_info(""); if(c2_call_id() >= 0) { this->setActive_channel(2); if(c2_state() == "hold") this->unhold(this->m_c2_call_id); } } if(m_c2_call_id == call_id) { this->setC2_timer(-1); this->setC2_call_id(-1); this->setC2_state("available"); this->setC2_sip_actiontext(""); this->setC2_downrate(""); this->setC2_uprate(""); this->setC2_loss(""); this->setC2_stream_info(""); if(c1_call_id() >= 0) { this->setActive_channel(1); if (c1_state() == "hold") this->unhold(this->m_c1_call_id); } } if(this->m_c1_state!="incoming" && this->m_c2_state!="incoming") { this->ringsound.setMuted(true); } if(m_c1_call_id == -1 && m_c2_call_id == -1 ) { controller->setQml("screens/phone.qml", "phone"); } }
/* Second handler for an annotation with 8 arguments */ static void test_eight_args_v2(uint a, uint b, uint c, uint d, uint e, uint f, uint g, uint h) { PRINTF("Test many args (handler #2): " "a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d, h=%d", a, b, c, d, e, f, g, h); /* Verify that a reloaded module gets instrumented with the current handlers. This * registration executes only on the first iteration (`a` is the iteration count), * and the modules are unloaded and reloaded within each iteration. */ if (h == 18) { if (a == 1) register_call("test_annotation_nine_args", (void *) test_nine_args_v2, 9); else if (a == 3) dr_annotation_unregister_call("test_annotation_nine_args", test_nine_args_v1); } }
/* Parse CL options and register DR event handlers and annotation handlers */ DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) { context_lock = dr_mutex_create(); write_lock = dr_mutex_create(); # ifdef WINDOWS dr_enable_console_printing(); # endif client_id = id; /* XXX: should use droption */ if (argc > 1 && strcmp(argv[1], "full-decode") == 0) { PRINTF("Init annotation test client with full decoding"); dr_register_bb_event(empty_bb_event); } else if (argc > 1 && strlen(argv[1]) >= 8 && strncmp(argv[1], "truncate", 8) == 0) { bb_truncation_length = (argv[1][9] - '0'); /* format is "truncate@n" (0<n<10) */ ASSERT(bb_truncation_length < 10 && bb_truncation_length > 0); PRINTF("Init annotation test client with bb truncation"); dr_register_bb_event(bb_event_truncate); } else { PRINTF("Init annotation test client with fast decoding"); } context_list = dr_global_alloc(sizeof(context_list_t)); memset(context_list, 0, sizeof(context_list_t)); #if !(defined (WINDOWS) && defined (X64)) mem_defines = dr_global_alloc(sizeof(mem_defines_t)); memset(mem_defines, 0, sizeof(mem_defines_t)); #endif dr_register_exit_event(event_exit); register_call("test_annotation_init_mode", (void *) init_mode, 1); register_call("test_annotation_init_context", (void *) init_context, 3); register_call("test_annotation_get_mode", (void *) get_mode, 1); register_call("test_annotation_set_mode", (void *) set_mode, 2); #if !(defined (WINDOWS) && defined (X64)) register_call("test_annotation_rotate_valgrind_handler", (void *) rotate_valgrind_handler, 1); #endif register_call("test_annotation_eight_args", (void *) test_eight_args_v1, 8); register_call("test_annotation_eight_args", (void *) test_eight_args_v2, 8); /* Test removing the last handler */ dr_annotation_unregister_call("test_annotation_eight_args", test_eight_args_v1); register_call("test_annotation_nine_args", (void *) test_nine_args_v1, 9); register_call("test_annotation_nine_args", (void *) test_nine_args_v2, 9); /* Test removing the first handler */ dr_annotation_unregister_call("test_annotation_nine_args", test_nine_args_v2); /* Test multiple handlers */ register_call("test_annotation_ten_args", (void *) test_ten_args_v1, 10); register_call("test_annotation_ten_args", (void *) test_ten_args_v2, 10); dr_annotation_register_return("test_annotation_get_client_version", (void *) "2.2.8"); }