void cache_access(struct cache *cache, int access_type, void *addr) { if (!cache) return; cache->access_count[access_type]++; struct decoded_address d_addr; decode_address(&d_addr, addr, cache); struct set *set = &cache->sets[d_addr.index]; bool hit = set_access(set, d_addr.tag, access_type); if (!hit) cache_miss(cache, access_type, set, &d_addr); }
asmlinkage void double_fault_c(struct pt_regs *fp) { console_verbose(); oops_in_progress = 1; #ifdef CONFIG_DEBUG_VERBOSE printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n"); #ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT if (((long)fp->seqstat & SEQSTAT_EXCAUSE) == VEC_UNCOV) { unsigned int cpu = smp_processor_id(); char buf[150]; decode_address(buf, cpu_pda[cpu].retx); printk(KERN_EMERG "While handling exception (EXCAUSE = 0x%x) at %s:\n", (unsigned int)cpu_pda[cpu].seqstat & SEQSTAT_EXCAUSE, buf); decode_address(buf, cpu_pda[cpu].dcplb_fault_addr); printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %s\n", buf); decode_address(buf, cpu_pda[cpu].icplb_fault_addr); printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %s\n", buf); decode_address(buf, fp->retx); printk(KERN_NOTICE "The instruction at %s caused a double exception\n", buf); } else #endif { dump_bfin_process(fp); dump_bfin_mem(fp); show_regs(fp); } #endif panic("Double Fault - unrecoverable event\n"); }
static InternetAddress * decode_group (const char **in) { InternetAddressGroup *group; InternetAddress *addr; const char *inptr; inptr = *in; addr = internet_address_group_new (NULL); group = (InternetAddressGroup *) addr; decode_lwsp (&inptr); while (*inptr && *inptr != ';') { InternetAddress *member; if ((member = decode_address (&inptr))) _internet_address_group_add_member (group, member); decode_lwsp (&inptr); while (*inptr == ',') { inptr++; decode_lwsp (&inptr); if ((member = decode_address (&inptr))) _internet_address_group_add_member (group, member); decode_lwsp (&inptr); } } *in = inptr; return addr; }
void dump_bfin_trace_buffer(void) { #ifdef CONFIG_DEBUG_VERBOSE #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON int tflags, i = 0; char buf[150]; unsigned short *addr; #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND int j, index; #endif trace_buffer_save(tflags); printk(KERN_NOTICE "Hardware Trace:\n"); #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND printk(KERN_NOTICE "WARNING: Expanded trace turned on - can not trace exceptions\n"); #endif if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { decode_address(buf, (unsigned long)bfin_read_TBUF()); printk(KERN_NOTICE "%4i Target : %s\n", i, buf); addr = (unsigned short *)bfin_read_TBUF(); decode_address(buf, (unsigned long)addr); printk(KERN_NOTICE " Source : %s ", buf); decode_instruction(addr); printk("\n"); } } #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND if (trace_buff_offset) index = trace_buff_offset / 4; else index = EXPAND_LEN; j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; while (j) { decode_address(buf, software_trace_buff[index]); printk(KERN_NOTICE "%4i Target : %s\n", i, buf); index -= 1; if (index < 0 ) index = EXPAND_LEN; decode_address(buf, software_trace_buff[index]); printk(KERN_NOTICE " Source : %s ", buf); decode_instruction((unsigned short *)software_trace_buff[index]); printk("\n"); index -= 1; if (index < 0) index = EXPAND_LEN; j--; i++; } #endif trace_buffer_restore(tflags); #endif #endif }
void dump_bfin_trace_buffer(void) { #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON int tflags, i = 0; char buf[150]; #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND int j, index; #endif trace_buffer_save(tflags); printk(KERN_NOTICE "Hardware Trace:\n"); if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { decode_address(buf, (unsigned long)bfin_read_TBUF()); printk(KERN_NOTICE "%4i Target : %s\n", i, buf); decode_address(buf, (unsigned long)bfin_read_TBUF()); printk(KERN_NOTICE " Source : %s\n", buf); } } #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND if (trace_buff_offset) index = trace_buff_offset/4 - 1; else index = EXPAND_LEN; j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; while (j) { decode_address(buf, software_trace_buff[index]); printk(KERN_NOTICE "%4i Target : %s\n", i, buf); index -= 1; if (index < 0 ) index = EXPAND_LEN; decode_address(buf, software_trace_buff[index]); printk(KERN_NOTICE " Source : %s\n", buf); index -= 1; if (index < 0) index = EXPAND_LEN; j--; i++; } #endif trace_buffer_restore(tflags); #endif }
/* Handle all of the extended 'Q' packets. */ static void handle_set (char *arg_own_buf, int *new_packet_len_p) { if (strcmp ("QStartNoAckMode", arg_own_buf) == 0) { noack_mode = True; write_ok (arg_own_buf); return; } if (strncmp ("QPassSignals:", arg_own_buf, 13) == 0) { int i; char *from, *to; char *end = arg_own_buf + strlen(arg_own_buf); CORE_ADDR sig; for (i = 0; i < TARGET_SIGNAL_LAST; i++) pass_signals[i] = 0; from = arg_own_buf + 13; while (from < end) { to = strchr(from, ';'); if (to == NULL) to = end; decode_address (&sig, from, to - from); pass_signals[(int)sig] = 1; dlog(1, "pass_signal gdb_nr %d %s\n", (int)sig, target_signal_to_name(sig)); from = to; if (*from == ';') from++; } write_ok (arg_own_buf); return; } /* Otherwise we didn't know what packet it was. Say we didn't understand it. */ arg_own_buf[0] = 0; }
void show_regs(struct pt_regs *fp) { char buf [150]; printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\n"); printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", (long)fp->seqstat, fp->ipend, fp->syscfg); decode_address(buf, fp->rete); printk(KERN_NOTICE " RETE: %s\n", buf); decode_address(buf, fp->retn); printk(KERN_NOTICE " RETN: %s\n", buf); decode_address(buf, fp->retx); printk(KERN_NOTICE " RETX: %s\n", buf); decode_address(buf, fp->rets); printk(KERN_NOTICE " RETS: %s\n", buf); decode_address(buf, fp->pc); printk(KERN_NOTICE " PC: %s\n", buf); if ((long)fp->seqstat & SEQSTAT_EXCAUSE) { decode_address(buf, bfin_read_DCPLB_FAULT_ADDR()); printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf); decode_address(buf, bfin_read_ICPLB_FAULT_ADDR()); printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf); } printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n"); printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n", fp->r0, fp->r1, fp->r2, fp->r3); printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n", fp->r4, fp->r5, fp->r6, fp->r7); printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n", fp->p0, fp->p1, fp->p2, fp->p3); printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n", fp->p4, fp->p5, fp->fp, (long)fp); printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n", fp->lb0, fp->lt0, fp->lc0); printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n", fp->lb1, fp->lt1, fp->lc1); printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n", fp->b0, fp->l0, fp->m0, fp->i0); printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n", fp->b1, fp->l1, fp->m1, fp->i1); printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n", fp->b2, fp->l2, fp->m2, fp->i2); printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n", fp->b3, fp->l3, fp->m3, fp->i3); printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", fp->a0w, fp->a0x, fp->a1w, fp->a1x); printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n", rdusp(), fp->astat); printk(KERN_NOTICE "\n"); }
static unsigned hw_ide_io_write_buffer(device *me, const void *source, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_ide_device *ide = (hw_ide_device *)device_data(me); int control_nr; int reg; ide_controller *controller; /* find the interface */ decode_address(me, &ide->decoder, space, addr, &control_nr, ®, is_write); controller = &ide->controller[control_nr]; /* process the access */ switch (reg) { case ide_data_reg: do_fifo_write(me, controller, source, nr_bytes); break; case ide_command_reg: do_command(me, controller, *(unsigned8*)source); break; case ide_control_reg: controller->reg[reg] = *(unsigned8*)source; /* possibly cancel interrupts */ if ((controller->reg[reg] & 0x02) == 0x02) clear_interrupt(me, controller); break; case ide_feature_reg: case ide_sector_count_reg: case ide_sector_number_reg: case ide_cylinder_reg0: case ide_cylinder_reg1: case ide_drive_head_reg: case ide_dma_command_reg: case ide_dma_status_reg: case ide_dma_prd_table_address_reg0: case ide_dma_prd_table_address_reg1: case ide_dma_prd_table_address_reg2: case ide_dma_prd_table_address_reg3: controller->reg[reg] = *(unsigned8*)source; break; default: device_error(me, "bus-error at 0x%lx", addr); break; } return nr_bytes; }
static unsigned hw_ide_io_read_buffer(device *me, void *dest, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_ide_device *ide = (hw_ide_device *)device_data(me); int control_nr; int reg; ide_controller *controller; /* find the interface */ decode_address(me, &ide->decoder, space, addr, &control_nr, ®, is_read); controller = & ide->controller[control_nr]; /* process the transfer */ memset(dest, 0, nr_bytes); switch (reg) { case ide_data_reg: do_fifo_read(me, controller, dest, nr_bytes); break; case ide_status_reg: *(unsigned8*)dest = get_status(me, controller); clear_interrupt(me, controller); break; case ide_alternate_status_reg: *(unsigned8*)dest = get_status(me, controller); break; case ide_error_reg: case ide_sector_count_reg: case ide_sector_number_reg: case ide_cylinder_reg0: case ide_cylinder_reg1: case ide_drive_head_reg: case ide_control_reg: case ide_dma_command_reg: case ide_dma_status_reg: case ide_dma_prd_table_address_reg0: case ide_dma_prd_table_address_reg1: case ide_dma_prd_table_address_reg2: case ide_dma_prd_table_address_reg3: *(unsigned8*)dest = controller->reg[reg]; break; default: device_error(me, "bus-error at address 0x%lx", addr); break; } return nr_bytes; }
void tracing_insn_begin(DECAF_Callback_Params* params) { CPUState* env = NULL; #if 0 // AWH if (params != NULL) { env = params->ib.env; } #else if (!params) return; env = params->ib.env; #endif // AWH if (DECAF_is_in_kernel(env) && should_trace_all_kernel) goto TRACE_KERNEL; /* If tracing start condition not satisified, or not tracing return */ if ((!tracing_start_condition) || (tracepid == 0)) return; /* If not tracing kernel and kernel instruction , return */ if (DECAF_is_in_kernel(env) && !tracing_kernel()) return; if(DECAF_getPGD(env) != tracecr3 && (!DECAF_is_in_kernel(env))) return; TRACE_KERNEL: cpu_disable_ticks(); /* Get thread id */ current_tid = VMI_get_current_tid_c(env); /* Clear flags before processing instruction */ // Flag to be set if the instruction is written insn_already_written = 0; // Flag to be set if instruction encounters a page fault // NOTE: currently not being used. Tracing uses it to avoid logging twice // these instructions, but was missing some has_page_fault = 0; // Flag to be set if instruction accesses user memory access_user_mem = 0; /* Disassemble the instruction */ insn_tainted = 0; if (skip_decode_address == 0) { decode_address(/* AWH cpu_single_*/ env->eip, &eh); } cpu_enable_ticks(); }
void test_decode_address(CuTest *tc) { struct decoded_address d; struct cache c; c.c = 0; c.s = 0; c.b = 0; void *addr = (void *) 0xDEADBEEF; decode_address(&d, addr, &c); CuAssertTrue(tc, (unsigned long) addr == d.tag); CuAssertTrue(tc, 0 == d.index); CuAssertTrue(tc, 0 == d.offset); c.b = 4; c.c = 8; decode_address(&d, addr, &c); CuAssertIntEquals(tc, 0xDEADBE, d.tag); CuAssertIntEquals(tc, 0xE, d.index); CuAssertIntEquals(tc, 0xF, d.offset); c.b = 8; c.c = 16; decode_address(&d, addr, &c); CuAssertIntEquals(tc, 0xDEAD, d.tag); CuAssertIntEquals(tc, 0xBE, d.index); CuAssertIntEquals(tc, 0xEF, d.offset); c.c = 16; c.s = 4; c.b = 4; decode_address(&d, addr, &c); CuAssertIntEquals(tc, 0xDEADB, d.tag); CuAssertIntEquals(tc, 0xEE, d.index); CuAssertIntEquals(tc, 0xF, d.offset); }
/** * internet_address_list_parse_string: * @str: a string containing internet addresses * * Construct a list of internet addresses from the given string. * * Returns: (transfer full): a #InternetAddressList or %NULL if the * input string does not contain any addresses. **/ InternetAddressList * internet_address_list_parse_string (const char *str) { InternetAddressList *addrlist; const char *inptr = str; InternetAddress *addr; const char *start; addrlist = internet_address_list_new (); while (inptr && *inptr) { start = inptr; if ((addr = decode_address (&inptr))) { _internet_address_list_add (addrlist, addr); } else { w(g_warning ("Invalid or incomplete address: %.*s", inptr - start, start)); } decode_lwsp (&inptr); if (*inptr == ',') { inptr++; decode_lwsp (&inptr); /* obs-mbox-list and obs-addr-list allow for empty members (commas with nothing between them) */ while (*inptr == ',') { inptr++; decode_lwsp (&inptr); } } else if (*inptr) { w(g_warning ("Parse error at '%s': expected ','", inptr)); /* try skipping to the next address */ if ((inptr = strchr (inptr, ','))) inptr++; } } if (addrlist->array->len == 0) { g_object_unref (addrlist); addrlist = NULL; } return addrlist; }
void tracing_insn_begin(DECAF_Callback_Params* params) { CPUState* env = NULL; if (params != NULL) { env = params->ib.env; } /* If tracing start condition not satisified, return */ if (!tracing_start_condition) return; /* If not tracing, return */ // This should not be needed, as if not tracing insn_begin unregistered // if (tracepid == 0) // return; /* If not tracing kernel and kernel instruction , return */ // This should not be needed, as should_monitor captures this condition //if ( DECAF_is_in_kernel() && !tracing_kernel() ) // return; /* Get thread id */ current_tid = get_current_tid(env); // Flag to be set if the instruction is written insn_already_written = 0; // Flag to be set if instruction accesses user memory access_user_mem = 0; /* Disassemble the instruction */ insn_tainted=0; if (skip_decode_address == 0) { decode_address(*DECAF_cpu_eip, &eh, get_st(current_tid)); } }
/*=========================================================================== FUNCTION loc_ni_request_handler DESCRIPTION Displays the NI request and awaits user input. If a previous request is in session, it is ignored. RETURN VALUE none ===========================================================================*/ static void loc_ni_request_handler(const char *msg, const rpc_loc_ni_event_s_type *ni_req) { GpsNiNotification notif; char lcs_addr[32]; // Decoded LCS address for UMTS CP NI notif.size = sizeof(notif); strlcpy(notif.text, "[text]", sizeof notif.text); // defaults strlcpy(notif.requestor_id, "[requestor id]", sizeof notif.requestor_id); /* If busy, use default or deny */ if (loc_eng_ni_data.notif_in_progress) { /* XXX Consider sending a NO RESPONSE reply or queue the request */ LOC_LOGW("loc_ni_request_handler, notification in progress, new NI request ignored, type: %d", ni_req->event); } else { /* Print notification */ LOC_LOGD("NI Notification: %s, event: %d", msg, ni_req->event); pthread_mutex_lock(&loc_eng_ni_data.loc_ni_lock); /* Save request */ memcpy(&loc_eng_ni_data.loc_ni_request, ni_req, sizeof loc_eng_ni_data.loc_ni_request); /* Set up NI response waiting */ loc_eng_ni_data.notif_in_progress = TRUE; loc_eng_ni_data.current_notif_id = abs(rand()); /* Fill in notification */ notif.notification_id = loc_eng_ni_data.current_notif_id; const rpc_loc_ni_vx_notify_verify_req_s_type *vx_req; const rpc_loc_ni_supl_notify_verify_req_s_type *supl_req; const rpc_loc_ni_umts_cp_notify_verify_req_s_type *umts_cp_req; switch (ni_req->event) { case RPC_LOC_NI_EVENT_VX_NOTIFY_VERIFY_REQ: vx_req = &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.vx_req; notif.ni_type = GPS_NI_TYPE_VOICE; notif.timeout = LOC_NI_NO_RESPONSE_TIME; // vx_req->user_resp_timer_val; memset(notif.extras, 0, sizeof notif.extras); memset(notif.text, 0, sizeof notif.text); memset(notif.requestor_id, 0, sizeof notif.requestor_id); // Requestor ID hexcode(notif.requestor_id, sizeof notif.requestor_id, vx_req->requester_id.requester_id, vx_req->requester_id.requester_id_length); notif.text_encoding = 0; // No text and no encoding notif.requestor_id_encoding = convert_encoding_type(vx_req->encoding_scheme); // Set default_response & notify_flags loc_ni_fill_notif_verify_type(¬if, vx_req->notification_priv_type); // Privacy override handling if (vx_req->notification_priv_type == RPC_LOC_NI_USER_PRIVACY_OVERRIDE) { loc_eng_mute_one_session(); } break; case RPC_LOC_NI_EVENT_UMTS_CP_NOTIFY_VERIFY_REQ: umts_cp_req = &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.umts_cp_req; notif.ni_type = GPS_NI_TYPE_UMTS_CTRL_PLANE; notif.timeout = LOC_NI_NO_RESPONSE_TIME; // umts_cp_req->user_response_timer; memset(notif.extras, 0, sizeof notif.extras); memset(notif.text, 0, sizeof notif.text); memset(notif.requestor_id, 0, sizeof notif.requestor_id); // Stores notification text #if (AMSS_VERSION==3200) hexcode(notif.text, sizeof notif.text, umts_cp_req->notification_text.notification_text_val, umts_cp_req->notification_length); #else hexcode(notif.text, sizeof notif.text, umts_cp_req->notification_text, umts_cp_req->notification_length); #endif /* #if (AMSS_VERSION==3200) */ // Stores requestor ID #if (AMSS_VERSION==3200) hexcode(notif.requestor_id, sizeof notif.requestor_id, umts_cp_req->requestor_id.requestor_id_string.requestor_id_string_val, umts_cp_req->requestor_id.string_len); #else hexcode(notif.requestor_id, sizeof notif.requestor_id, umts_cp_req->requestor_id.requestor_id_string, umts_cp_req->requestor_id.string_len); #endif // Encodings notif.text_encoding = convert_encoding_type(umts_cp_req->datacoding_scheme); notif.requestor_id_encoding = convert_encoding_type(umts_cp_req->datacoding_scheme); // LCS address (using extras field) if (umts_cp_req->ext_client_address_data.ext_client_address_len != 0) { // Copy LCS Address into notif.extras in the format: Address = 012345 strlcat(notif.extras, LOC_NI_NOTIF_KEY_ADDRESS, sizeof notif.extras); strlcat(notif.extras, " = ", sizeof notif.extras); int addr_len = 0; const char *address_source = NULL; #if (AMSS_VERSION==3200) address_source = umts_cp_req->ext_client_address_data.ext_client_address.ext_client_address_val; #else address_source = umts_cp_req->ext_client_address_data.ext_client_address; #endif /* #if (AMSS_VERSION==3200) */ addr_len = decode_address(lcs_addr, sizeof lcs_addr, address_source, umts_cp_req->ext_client_address_data.ext_client_address_len); // The address is ASCII string if (addr_len) { strlcat(notif.extras, lcs_addr, sizeof notif.extras); } } // Set default_response & notify_flags loc_ni_fill_notif_verify_type(¬if, umts_cp_req->notification_priv_type); // Privacy override handling if (umts_cp_req->notification_priv_type == RPC_LOC_NI_USER_PRIVACY_OVERRIDE) { loc_eng_mute_one_session(); } break; case RPC_LOC_NI_EVENT_SUPL_NOTIFY_VERIFY_REQ: supl_req = &ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req; notif.ni_type = GPS_NI_TYPE_UMTS_SUPL; notif.timeout = LOC_NI_NO_RESPONSE_TIME; // supl_req->user_response_timer; memset(notif.extras, 0, sizeof notif.extras); memset(notif.text, 0, sizeof notif.text); memset(notif.requestor_id, 0, sizeof notif.requestor_id); // Client name if (supl_req->flags & RPC_LOC_NI_CLIENT_NAME_PRESENT) { #if (AMSS_VERSION==3200) hexcode(notif.text, sizeof notif.text, supl_req->client_name.client_name_string.client_name_string_val, /* buffer */ supl_req->client_name.string_len /* length */ ); #else hexcode(notif.text, sizeof notif.text, supl_req->client_name.client_name_string, /* buffer */ supl_req->client_name.string_len /* length */ ); #endif /* #if (AMSS_VERSION==3200) */ LOC_LOGV("SUPL NI: client_name: %s len=%d", notif.text, supl_req->client_name.string_len); } else { LOC_LOGV("SUPL NI: client_name not present."); } // Requestor ID if (supl_req->flags & RPC_LOC_NI_REQUESTOR_ID_PRESENT) { #if (AMSS_VERSION==3200) hexcode(notif.requestor_id, sizeof notif.requestor_id, supl_req->requestor_id.requestor_id_string.requestor_id_string_val, /* buffer */ supl_req->requestor_id.string_len /* length */ ); #else hexcode(notif.requestor_id, sizeof notif.requestor_id, supl_req->requestor_id.requestor_id_string, /* buffer */ supl_req->requestor_id.string_len /* length */ ); #endif /* #if (AMSS_VERSION==3200) */ LOC_LOGV("SUPL NI: requestor_id: %s len=%d", notif.requestor_id, supl_req->requestor_id.string_len); } else { LOC_LOGV("SUPL NI: requestor_id not present."); } // Encoding type if (supl_req->flags & RPC_LOC_NI_ENCODING_TYPE_PRESENT) { notif.text_encoding = convert_encoding_type(supl_req->datacoding_scheme); notif.requestor_id_encoding = convert_encoding_type(supl_req->datacoding_scheme); } else { notif.text_encoding = notif.requestor_id_encoding = GPS_ENC_UNKNOWN; } // Set default_response & notify_flags loc_ni_fill_notif_verify_type(¬if, ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req.notification_priv_type); // Privacy override handling if (ni_req->payload.rpc_loc_ni_event_payload_u_type_u.supl_req.notification_priv_type == RPC_LOC_NI_USER_PRIVACY_OVERRIDE) { loc_eng_mute_one_session(); } break; default: LOC_LOGE("loc_ni_request_handler, unknown request event: %d", ni_req->event); return; } /* Log requestor ID and text for debugging */ LOC_LOGI("Notification: notif_type: %d, timeout: %d, default_resp: %d", notif.ni_type, notif.timeout, notif.default_response); LOC_LOGI(" requestor_id: %s (encoding: %d)", notif.requestor_id, notif.requestor_id_encoding); LOC_LOGI(" text: %s text (encoding: %d)", notif.text, notif.text_encoding); if (notif.extras[0]) { LOC_LOGI(" extras: %s", notif.extras); } /* For robustness, spawn a thread at this point to timeout to clear up the notification status, even though * the OEM layer in java does not do so. **/ loc_eng_ni_data.response_time_left = 5 + (notif.timeout != 0 ? notif.timeout : LOC_NI_NO_RESPONSE_TIME); LOC_LOGI("Automatically sends 'no response' in %d seconds (to clear status)\n", loc_eng_ni_data.response_time_left); /* @todo may required when android framework issue is fixed * loc_eng_ni_data.callbacks_ref->create_thread_cb("loc_api_ni", loc_ni_thread_proc, NULL); */ int rc = 0; rc = pthread_create(&loc_eng_ni_data.loc_ni_thread, NULL, loc_ni_thread_proc, NULL); if (rc) { LOC_LOGE("Loc NI thread is not created.\n"); } rc = pthread_detach(loc_eng_ni_data.loc_ni_thread); if (rc) { LOC_LOGE("Loc NI thread is not detached.\n"); } pthread_mutex_unlock(&loc_eng_ni_data.loc_ni_lock); /* Notify callback */ if (loc_eng_data.ni_notify_cb != NULL) { loc_eng_data.ni_notify_cb(¬if); } } }
void show_regs(struct pt_regs *fp) { char buf [150]; struct irqaction *action; unsigned int i; unsigned long flags; printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted()); printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", (long)fp->seqstat, fp->ipend, fp->syscfg); printk(KERN_NOTICE " HWERRCAUSE: 0x%lx\n", (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14); printk(KERN_NOTICE " EXCAUSE : 0x%lx\n", fp->seqstat & SEQSTAT_EXCAUSE); for (i = 6; i <= 15 ; i++) { if (fp->ipend & (1 << i)) { decode_address(buf, bfin_read32(EVT0 + 4*i)); printk(KERN_NOTICE " physical IVG%i asserted : %s\n", i, buf); } } /* if no interrupts are going off, don't print this out */ if (fp->ipend & ~0x3F) { for (i = 0; i < (NR_IRQS - 1); i++) { spin_lock_irqsave(&irq_desc[i].lock, flags); action = irq_desc[i].action; if (!action) goto unlock; decode_address(buf, (unsigned int)action->handler); printk(KERN_NOTICE " logical irq %3d mapped : %s", i, buf); for (action = action->next; action; action = action->next) { decode_address(buf, (unsigned int)action->handler); printk(", %s", buf); } printk("\n"); unlock: spin_unlock_irqrestore(&irq_desc[i].lock, flags); } } decode_address(buf, fp->rete); printk(KERN_NOTICE " RETE: %s\n", buf); decode_address(buf, fp->retn); printk(KERN_NOTICE " RETN: %s\n", buf); decode_address(buf, fp->retx); printk(KERN_NOTICE " RETX: %s\n", buf); decode_address(buf, fp->rets); printk(KERN_NOTICE " RETS: %s\n", buf); decode_address(buf, fp->pc); printk(KERN_NOTICE " PC : %s\n", buf); if (((long)fp->seqstat & SEQSTAT_EXCAUSE) && (((long)fp->seqstat & SEQSTAT_EXCAUSE) != VEC_HWERR)) { decode_address(buf, saved_dcplb_fault_addr); printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf); decode_address(buf, saved_icplb_fault_addr); printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf); } printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n"); printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n", fp->r0, fp->r1, fp->r2, fp->r3); printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n", fp->r4, fp->r5, fp->r6, fp->r7); printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n", fp->p0, fp->p1, fp->p2, fp->p3); printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n", fp->p4, fp->p5, fp->fp, (long)fp); printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n", fp->lb0, fp->lt0, fp->lc0); printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n", fp->lb1, fp->lt1, fp->lc1); printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n", fp->b0, fp->l0, fp->m0, fp->i0); printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n", fp->b1, fp->l1, fp->m1, fp->i1); printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n", fp->b2, fp->l2, fp->m2, fp->i2); printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n", fp->b3, fp->l3, fp->m3, fp->i3); printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", fp->a0w, fp->a0x, fp->a1w, fp->a1x); printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n", rdusp(), fp->astat); printk(KERN_NOTICE "\n"); }
void show_stack(struct task_struct *task, unsigned long *stack) { unsigned int *addr, *endstack, *fp = 0, *frame; unsigned short *ins_addr; char buf[150]; unsigned int i, j, ret_addr, frame_no = 0; /* * If we have been passed a specific stack, use that one otherwise * if we have been passed a task structure, use that, otherwise * use the stack of where the variable "stack" exists */ if (stack == NULL) { if (task) { /* We know this is a kernel stack, so this is the start/end */ stack = (unsigned long *)task->thread.ksp; endstack = (unsigned int *)(((unsigned int)(stack) & ~(THREAD_SIZE - 1)) + THREAD_SIZE); } else { /* print out the existing stack info */ stack = (unsigned long *)&stack; endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack); } } else endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack); decode_address(buf, (unsigned int)stack); printk(KERN_NOTICE "Stack info:\n" KERN_NOTICE " SP: [0x%p] %s\n", stack, buf); addr = (unsigned int *)((unsigned int)stack & ~0x3F); /* First thing is to look for a frame pointer */ for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0; addr < endstack; addr++, i++) { if (*addr & 0x1) continue; ins_addr = (unsigned short *)*addr; ins_addr--; if (is_bfin_call(ins_addr)) fp = addr - 1; if (fp) { /* Let's check to see if it is a frame pointer */ while (fp >= (addr - 1) && fp < endstack && fp) fp = (unsigned int *)*fp; if (fp == 0 || fp == endstack) { fp = addr - 1; break; } fp = 0; } } if (fp) { frame = fp; printk(" FP: (0x%p)\n", fp); } else frame = 0; /* * Now that we think we know where things are, we * walk the stack again, this time printing things out * incase there is no frame pointer, we still look for * valid return addresses */ /* First time print out data, next time, print out symbols */ for (j = 0; j <= 1; j++) { if (j) printk(KERN_NOTICE "Return addresses in stack:\n"); else printk(KERN_NOTICE " Memory from 0x%08lx to %p", ((long unsigned int)stack & ~0xF), endstack); fp = frame; frame_no = 0; for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0; addr <= endstack; addr++, i++) { ret_addr = 0; if (!j && i % 8 == 0) printk("\n" KERN_NOTICE "%p:",addr); /* if it is an odd address, or zero, just skip it */ if (*addr & 0x1 || !*addr) goto print; ins_addr = (unsigned short *)*addr; /* Go back one instruction, and see if it is a CALL */ ins_addr--; ret_addr = is_bfin_call(ins_addr); print: if (!j && stack == (unsigned long *)addr) printk("[%08x]", *addr); else if (ret_addr) if (j) { decode_address(buf, (unsigned int)*addr); if (frame == addr) { printk(KERN_NOTICE " frame %2i : %s\n", frame_no, buf); continue; } printk(KERN_NOTICE " address : %s\n", buf); } else printk("<%08x>", *addr); else if (fp == addr) { if (j) frame = addr+1; else printk("(%08x)", *addr); fp = (unsigned int *)*addr; frame_no++; } else if (!j) printk(" %08x ", *addr); } if (!j) printk("\n"); } }
void dump_bfin_trace_buffer(void) { #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON int tflags, i = 0, fault = 0; char buf[150]; unsigned short *addr; unsigned int cpu = raw_smp_processor_id(); #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND int j, index; #endif trace_buffer_save(tflags); pr_notice("Hardware Trace:\n"); #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND pr_notice("WARNING: Expanded trace turned on - can not trace exceptions\n"); #endif if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { addr = (unsigned short *)bfin_read_TBUF(); decode_address(buf, (unsigned long)addr); pr_notice("%4i Target : %s\n", i, buf); if (!fault && addr == ((unsigned short *)evt_ivhw)) { addr = (unsigned short *)bfin_read_TBUF(); decode_address(buf, (unsigned long)addr); pr_notice(" FAULT : %s ", buf); decode_instruction(addr); pr_cont("\n"); fault = 1; continue; } if (!fault && addr == (unsigned short *)trap && (cpu_pda[cpu].seqstat & SEQSTAT_EXCAUSE) > VEC_EXCPT15) { decode_address(buf, cpu_pda[cpu].icplb_fault_addr); pr_notice(" FAULT : %s ", buf); decode_instruction((unsigned short *)cpu_pda[cpu].icplb_fault_addr); pr_cont("\n"); fault = 1; } addr = (unsigned short *)bfin_read_TBUF(); decode_address(buf, (unsigned long)addr); pr_notice(" Source : %s ", buf); decode_instruction(addr); pr_cont("\n"); } } #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND if (trace_buff_offset) index = trace_buff_offset / 4; else index = EXPAND_LEN; j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; while (j) { decode_address(buf, software_trace_buff[index]); pr_notice("%4i Target : %s\n", i, buf); index -= 1; if (index < 0) index = EXPAND_LEN; decode_address(buf, software_trace_buff[index]); pr_notice(" Source : %s ", buf); decode_instruction((unsigned short *)software_trace_buff[index]); pr_cont("\n"); index -= 1; if (index < 0) index = EXPAND_LEN; j--; i++; } #endif trace_buffer_restore(tflags); #endif }
/* Handle all of the extended 'q' packets. */ void handle_query (char *own_buf, int packet_len, int *new_packet_len_p) { static struct inferior_list_entry *thread_ptr; /* Reply the current thread id. */ if (strcmp ("qC", own_buf) == 0) { thread_ptr = all_threads.head; if (thread_ptr == NULL) strcpy (own_buf, "unset"); else sprintf (own_buf, "QC%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); return; } if (strcmp ("qSymbol::", own_buf) == 0) { if (the_target->look_up_symbols != NULL) (*the_target->look_up_symbols) (); strcpy (own_buf, "OK"); return; } if (strcmp ("qfThreadInfo", own_buf) == 0) { thread_ptr = all_threads.head; sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } if (strcmp ("qsThreadInfo", own_buf) == 0) { if (thread_ptr != NULL) { sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } else { sprintf (own_buf, "l"); return; } } if (the_target->read_offsets != NULL && strcmp ("qOffsets", own_buf) == 0) { CORE_ADDR text, data; if (the_target->read_offsets (&text, &data)) sprintf (own_buf, "Text=%lX;Data=%lX;Bss=%lX", (long)text, (long)data, (long)data); else write_enn (own_buf); return; } if (the_target->qxfer_spu != NULL && strncmp ("qXfer:spu:read:", own_buf, 15) == 0) { char *annex; int n; unsigned int len; CORE_ADDR ofs; unsigned char *spu_buf; strcpy (own_buf, "E00"); if (decode_xfer_read (own_buf + 15, &annex, &ofs, &len) < 0) return; if (len > PBUFSIZ - 2) len = PBUFSIZ - 2; spu_buf = malloc (len + 1); if (!spu_buf) return; n = (*the_target->qxfer_spu) (annex, spu_buf, NULL, ofs, len + 1); if (n < 0) write_enn (own_buf); else if (n > len) *new_packet_len_p = write_qxfer_response (own_buf, spu_buf, len, 1); else *new_packet_len_p = write_qxfer_response (own_buf, spu_buf, n, 0); free (spu_buf); return; } if (the_target->qxfer_spu != NULL && strncmp ("qXfer:spu:write:", own_buf, 16) == 0) { char *annex; int n; unsigned int len; CORE_ADDR ofs; unsigned char *spu_buf; strcpy (own_buf, "E00"); spu_buf = malloc (packet_len - 15); if (!spu_buf) return; if (decode_xfer_write (own_buf + 16, packet_len - 16, &annex, &ofs, &len, spu_buf) < 0) { free (spu_buf); return; } n = (*the_target->qxfer_spu) (annex, NULL, (unsigned const char *)spu_buf, ofs, len); if (n < 0) write_enn (own_buf); else sprintf (own_buf, "%x", n); free (spu_buf); return; } if (the_target->read_auxv != NULL && strncmp ("qXfer:auxv:read:", own_buf, 16) == 0) { unsigned char *data; int n; CORE_ADDR ofs; unsigned int len; char *annex; /* Reject any annex; grab the offset and length. */ if (decode_xfer_read (own_buf + 16, &annex, &ofs, &len) < 0 || annex[0] != '\0') { strcpy (own_buf, "E00"); return; } /* Read one extra byte, as an indicator of whether there is more. */ if (len > PBUFSIZ - 2) len = PBUFSIZ - 2; data = malloc (len + 1); n = (*the_target->read_auxv) (ofs, data, len + 1); if (n < 0) write_enn (own_buf); else if (n > len) *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1); else *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0); free (data); return; } if (strncmp ("qXfer:features:read:", own_buf, 20) == 0) { CORE_ADDR ofs; unsigned int len, total_len; const char *document; char *annex; /* Check for support. */ document = get_features_xml ("target.xml"); if (document == NULL) { own_buf[0] = '\0'; return; } /* Grab the annex, offset, and length. */ if (decode_xfer_read (own_buf + 20, &annex, &ofs, &len) < 0) { strcpy (own_buf, "E00"); return; } /* Now grab the correct annex. */ document = get_features_xml (annex); if (document == NULL) { strcpy (own_buf, "E00"); return; } total_len = strlen (document); if (len > PBUFSIZ - 2) len = PBUFSIZ - 2; if (ofs > total_len) write_enn (own_buf); else if (len < total_len - ofs) *new_packet_len_p = write_qxfer_response (own_buf, document + ofs, len, 1); else *new_packet_len_p = write_qxfer_response (own_buf, document + ofs, total_len - ofs, 0); return; } if (strncmp ("qXfer:libraries:read:", own_buf, 21) == 0) { CORE_ADDR ofs; unsigned int len, total_len; char *document, *p; struct inferior_list_entry *dll_ptr; char *annex; /* Reject any annex; grab the offset and length. */ if (decode_xfer_read (own_buf + 21, &annex, &ofs, &len) < 0 || annex[0] != '\0') { strcpy (own_buf, "E00"); return; } /* Over-estimate the necessary memory. Assume that every character in the library name must be escaped. */ total_len = 64; for (dll_ptr = all_dlls.head; dll_ptr != NULL; dll_ptr = dll_ptr->next) total_len += 128 + 6 * strlen (((struct dll_info *) dll_ptr)->name); document = malloc (total_len); strcpy (document, "<library-list>\n"); p = document + strlen (document); for (dll_ptr = all_dlls.head; dll_ptr != NULL; dll_ptr = dll_ptr->next) { struct dll_info *dll = (struct dll_info *) dll_ptr; char *name; strcpy (p, " <library name=\""); p = p + strlen (p); name = xml_escape_text (dll->name); strcpy (p, name); free (name); p = p + strlen (p); strcpy (p, "\"><segment address=\""); p = p + strlen (p); sprintf (p, "0x%lx", (long) dll->base_addr); p = p + strlen (p); strcpy (p, "\"/></library>\n"); p = p + strlen (p); } strcpy (p, "</library-list>\n"); total_len = strlen (document); if (len > PBUFSIZ - 2) len = PBUFSIZ - 2; if (ofs > total_len) write_enn (own_buf); else if (len < total_len - ofs) *new_packet_len_p = write_qxfer_response (own_buf, document + ofs, len, 1); else *new_packet_len_p = write_qxfer_response (own_buf, document + ofs, total_len - ofs, 0); free (document); return; } /* Protocol features query. */ if (strncmp ("qSupported", own_buf, 10) == 0 && (own_buf[10] == ':' || own_buf[10] == '\0')) { sprintf (own_buf, "PacketSize=%x", PBUFSIZ - 1); #if !defined (NO_PASS_SIGNALS) strcat (own_buf, ";QPassSignals+", PBUFSIZ - 1); #endif #if !defined (NO_LIBRARIES) /* We do not have any hook to indicate whether the target backend supports qXfer:libraries:read, so always report it. */ strcat (own_buf, ";qXfer:libraries:read+"); #endif strcat (own_buf, ";qXfer:memory map:read+"); if (the_target->read_auxv != NULL) strcat (own_buf, ";qXfer:auxv:read+"); if (the_target->qxfer_spu != NULL) strcat (own_buf, ";qXfer:spu:read+;qXfer:spu:write+"); if (get_features_xml ("target.xml") != NULL) strcat (own_buf, ";qXfer:features:read+"); return; } /* Thread-local storage support. */ if (the_target->get_tls_address != NULL && strncmp ("qGetTLSAddr:", own_buf, 12) == 0) { char *p = own_buf + 12; CORE_ADDR parts[3], address = 0; int i, err; for (i = 0; i < 3; i++) { char *p2; int len; if (p == NULL) break; p2 = strchr (p, ','); if (p2) { len = p2 - p; p2++; } else { len = strlen (p); p2 = NULL; } decode_address (&parts[i], p, len); p = p2; } if (p != NULL || i < 3) err = 1; else { struct thread_info *thread = gdb_id_to_thread (parts[0]); if (thread == NULL) err = 2; else err = the_target->get_tls_address (thread, parts[1], parts[2], &address); } if (err == 0) { sprintf (own_buf, "%llx", address); return; } else if (err > 0) { write_enn (own_buf); return; } /* Otherwise, pretend we do not understand this packet. */ } /* Handle "monitor" commands. */ if (strncmp ("qRcmd,", own_buf, 6) == 0) { char *mon = malloc (PBUFSIZ); int len = strlen (own_buf + 6); if ((len % 1) != 0 || unhexify (mon, own_buf + 6, len / 2) != len / 2) { write_enn (own_buf); free (mon); return; } mon[len / 2] = '\0'; write_ok (own_buf); if (strcmp (mon, "set debug 1") == 0) { debug_threads = 1; monitor_output ("Debug output enabled.\n"); } else if (strcmp (mon, "set debug 0") == 0) { debug_threads = 0; monitor_output ("Debug output disabled.\n"); } else if (strcmp (mon, "set remote-debug 1") == 0) { remote_debug = 1; monitor_output ("Protocol debug output enabled.\n"); } else if (strcmp (mon, "set remote-debug 0") == 0) { remote_debug = 0; monitor_output ("Protocol debug output disabled.\n"); } else if (strcmp (mon, "help") == 0) monitor_show_help (); else { int ok = 0; if (the_target->commands) ok = (*the_target->commands) (mon, len); else monitor_output ("Unknown monitor command.\n\n"); if (!ok) { monitor_show_help (); write_enn (own_buf); } } free (mon); return; } /* Otherwise we didn't know what packet it was. Say we didn't understand it. */ own_buf[0] = 0; }
virtual void b_transport( int id, tlm::tlm_generic_payload& trans, sc_time& delay ) { int target_nr = 0; sc_dt::uint64 address = trans.get_address(); sc_dt::uint64 read_address = 0; sc_dt::uint64 write_address = 0 ; decode_address( address, read_address, write_address, id, startAdr[id]); if(id == 0){//Writer writeAllowed = true; trans.set_address(write_address); (*init_socket[target_nr])->b_transport(trans, delay); cout << "\tID is: " << id << " - After calling b_transport in Switch: " << endl; if(trans.is_response_ok() && writerCounter < startAdr[id + 1]) writerCounter = writerCounter + 8; // Change since now 8-bit words. if(trans.is_response_ok() && writerCounter >= startAdr[id + 1]){ writeAllowed = false; mtfAllowed = true; } } else if(id == 1){//mtf if(mtfAllowed == true){ if(trans.get_command() == tlm::TLM_WRITE_COMMAND) trans.set_address( write_address ); if(trans.get_command() == tlm::TLM_READ_COMMAND) trans.set_address(read_address); (*init_socket[target_nr])->b_transport(trans, delay); cout << "\tID is: " << id << " - After calling b_transport in Switch: " << endl; if(trans.is_response_ok() && MTFCounter < startAdr[id + 1]) MTFCounter = MTFCounter + 8; // Change since now 8-bit words. if(trans.is_response_ok() && MTFCounter >= startAdr[id + 1]){ runAllowed.write(true); } } } else if(id == 2){//runL if(runAllowed == true){ if(trans.get_command() == tlm::TLM_WRITE_COMMAND) trans.set_address( write_address ); if(trans.get_command() == tlm::TLM_READ_COMMAND) trans.set_address(read_address); (*init_socket[target_nr])->b_transport(trans, delay); //cout << "\tID is: " << id << " - After calling b_transport in Switch: " << endl; if(trans.is_response_ok() && runCounter < startAdr[id + 1]) runCounter = runCounter + 8; // Change since now 8-bit words. if(trans.is_response_ok() && runCounter >= startAdr[id + 1]- startAdr[id]){ readAllowed.write(true); } } } else if(id == 3){//Reader if(readAllowed == true){ if(trans.get_command() == tlm::TLM_READ_COMMAND) trans.set_address(read_address ); (*init_socket[target_nr])->b_transport(trans, delay); //cout << "\tID is: " << id << " - After calling b_transport in Switch: " << endl; if(readCounter <= startAdr[id]- startAdr[id - 1]){ readCounter = readCounter + 8; // Change since now 8-bit words. trans.set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); } else if(readCounter > startAdr[id]- startAdr[id - 1]){ trans.set_response_status(tlm::TLM_OK_RESPONSE); } } else trans.set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); } }
/* Handle all of the extended 'q' packets. */ void handle_query (char *own_buf, int *new_packet_len_p) { static struct inferior_list_entry *thread_ptr; if (strcmp ("qSymbol::", own_buf) == 0) { if (the_target->look_up_symbols != NULL) (*the_target->look_up_symbols) (); strcpy (own_buf, "OK"); return; } if (strcmp ("qfThreadInfo", own_buf) == 0) { thread_ptr = all_threads.head; sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } if (strcmp ("qsThreadInfo", own_buf) == 0) { if (thread_ptr != NULL) { sprintf (own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } else { sprintf (own_buf, "l"); return; } } if (the_target->read_offsets != NULL && strcmp ("qOffsets", own_buf) == 0) { CORE_ADDR text, data; if (the_target->read_offsets (&text, &data)) sprintf (own_buf, "Text=%lX;Data=%lX;Bss=%lX", (long)text, (long)data, (long)data); else write_enn (own_buf); return; } if (the_target->read_auxv != NULL && strncmp ("qXfer:auxv:read:", own_buf, 16) == 0) { unsigned char *data; int n; CORE_ADDR ofs; unsigned int len; char *annex; /* Reject any annex; grab the offset and length. */ if (decode_xfer_read (own_buf + 16, &annex, &ofs, &len) < 0 || annex[0] != '\0') { strcpy (own_buf, "E00"); return; } /* Read one extra byte, as an indicator of whether there is more. */ if (len > PBUFSIZ - 2) len = PBUFSIZ - 2; data = malloc (len + 1); n = (*the_target->read_auxv) (ofs, data, len + 1); if (n < 0) write_enn (own_buf); else if (n > len) *new_packet_len_p = write_qxfer_response (own_buf, data, len, 1); else *new_packet_len_p = write_qxfer_response (own_buf, data, n, 0); free (data); return; } /* Protocol features query. */ if (strncmp ("qSupported", own_buf, 10) == 0 && (own_buf[10] == ':' || own_buf[10] == '\0')) { sprintf (own_buf, "PacketSize=%x", PBUFSIZ - 1); if (the_target->read_auxv != NULL) strcat (own_buf, ";qXfer:auxv:read+"); return; } /* Thread-local storage support. */ if (the_target->get_tls_address != NULL && strncmp ("qGetTLSAddr:", own_buf, 12) == 0) { char *p = own_buf + 12; CORE_ADDR parts[3], address = 0; int i, err; for (i = 0; i < 3; i++) { char *p2; int len; if (p == NULL) break; p2 = strchr (p, ','); if (p2) { len = p2 - p; p2++; } else { len = strlen (p); p2 = NULL; } decode_address (&parts[i], p, len); p = p2; } if (p != NULL || i < 3) err = 1; else { struct thread_info *thread = gdb_id_to_thread (parts[0]); if (thread == NULL) err = 2; else err = the_target->get_tls_address (thread, parts[1], parts[2], &address); } if (err == 0) { sprintf (own_buf, "%llx", address); return; } else if (err > 0) { write_enn (own_buf); return; } /* Otherwise, pretend we do not understand this packet. */ } /* Otherwise we didn't know what packet it was. Say we didn't understand it. */ own_buf[0] = 0; }
/* Handle all of the extended 'q' packets. */ static void handle_query (char *arg_own_buf, int *new_packet_len_p) { static struct inferior_list_entry *thread_ptr; /* thread local storage query */ if (strncmp ("qGetTLSAddr:", arg_own_buf, 12) == 0) { char *from, *to; char *end = arg_own_buf + strlen(arg_own_buf); unsigned long gdb_id; CORE_ADDR lm; CORE_ADDR offset; struct thread_info *ti; from = arg_own_buf + 12; to = strchr(from, ','); *to = 0; gdb_id = strtoul (from, NULL, 16); from = to + 1; to = strchr(from, ','); decode_address (&offset, from, to - from); from = to + 1; to = end; decode_address (&lm, from, to - from); dlog(2, "qGetTLSAddr thread %lu offset %p lm %p\n", gdb_id, (void*)offset, (void*)lm); ti = gdb_id_to_thread (gdb_id); if (ti != NULL) { ThreadState *tst; Addr tls_addr; tst = (ThreadState *) inferior_target_data (ti); if (valgrind_get_tls_addr(tst, offset, lm, &tls_addr)) { VG_(sprintf) (arg_own_buf, "%lx", tls_addr); return; } // else we will report we do not support qGetTLSAddr } else { write_enn (arg_own_buf); return; } } /* qRcmd, monitor command handling. */ if (strncmp ("qRcmd,", arg_own_buf, 6) == 0) { char *p = arg_own_buf + 6; int cmdlen = strlen(p)/2; char cmd[cmdlen+1]; if (unhexify (cmd, p, cmdlen) != cmdlen) { write_enn (arg_own_buf); return; } cmd[cmdlen] = '\0'; if (handle_gdb_monitor_command (cmd)) { write_ok (arg_own_buf); return; } else { /* cmd not recognised */ VG_(gdb_printf) ("command '%s' not recognised\n" "In gdb, try 'monitor help'\n" "In a shell, try 'vgdb help'\n", cmd); write_ok (arg_own_buf); return; } } /* provide some valgrind specific info in return to qThreadExtraInfo. */ if (strncmp ("qThreadExtraInfo,", arg_own_buf, 17) == 0) { unsigned long gdb_id; struct thread_info *ti; ThreadState *tst; gdb_id = strtoul (&arg_own_buf[17], NULL, 16); ti = gdb_id_to_thread (gdb_id); if (ti != NULL) { tst = (ThreadState *) inferior_target_data (ti); /* Additional info is the tid, the thread status and the thread's name, if any. */ SizeT len = strlen(VG_(name_of_ThreadStatus)(tst->status)) + 20; if (tst->thread_name) len += strlen(tst->thread_name); /* As the string will be hexified and copied into own_buf we need to limit the length to avoid buffer overflow. */ if (len * 2 > (PBUFSIZ + POVERHSIZ)) len = (PBUFSIZ + POVERHSIZ) / 2; char status[len]; if (tst->thread_name) { VG_(snprintf) (status, sizeof(status), "tid %d %s %s", tst->tid, VG_(name_of_ThreadStatus)(tst->status), tst->thread_name); } else { VG_(snprintf) (status, sizeof(status), "tid %d %s", tst->tid, VG_(name_of_ThreadStatus)(tst->status)); } hexify (arg_own_buf, status, strlen(status)); return; } else { write_enn (arg_own_buf); return; } } if (strcmp ("qAttached", arg_own_buf) == 0) { /* tell gdb to always detach, never kill the process */ arg_own_buf[0] = '1'; arg_own_buf[1] = 0; return; } if (strcmp ("qSymbol::", arg_own_buf) == 0) { /* We have no symbol to read. */ write_ok (arg_own_buf); return; } if (strcmp ("qfThreadInfo", arg_own_buf) == 0) { thread_ptr = all_threads.head; VG_(sprintf) (arg_own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } if (strcmp ("qsThreadInfo", arg_own_buf) == 0) { if (thread_ptr != NULL) { VG_(sprintf) (arg_own_buf, "m%x", thread_to_gdb_id ((struct thread_info *)thread_ptr)); thread_ptr = thread_ptr->next; return; } else { VG_(sprintf) (arg_own_buf, "l"); return; } } if (valgrind_target_xml(VG_(clo_vgdb_shadow_registers)) != NULL && strncmp ("qXfer:features:read:", arg_own_buf, 20) == 0) { CORE_ADDR ofs; unsigned int len, doc_len; const char *annex = NULL; // First, the annex is extracted from the packet received. // Then, it is replaced by the corresponding file name. int fd; /* Grab the annex, offset, and length. */ if (decode_xfer_read (arg_own_buf + 20, &annex, &ofs, &len) < 0) { strcpy (arg_own_buf, "E00"); return; } if (strcmp (annex, "target.xml") == 0) { annex = valgrind_target_xml(VG_(clo_vgdb_shadow_registers)); if (annex != NULL && VG_(clo_vgdb_shadow_registers)) { /* Ensure the shadow registers are initialized. */ initialize_shadow_low(True); } if (annex == NULL) { strcpy (arg_own_buf, "E00"); return; } } { char doc[VG_(strlen)(VG_(libdir)) + 1 + VG_(strlen)(annex) + 1]; struct vg_stat stat_doc; char toread[len]; int len_read; VG_(sprintf)(doc, "%s/%s", VG_(libdir), annex); fd = VG_(fd_open) (doc, VKI_O_RDONLY, 0); if (fd == -1) { strcpy (arg_own_buf, "E00"); return; } if (VG_(fstat) (fd, &stat_doc) != 0) { VG_(close) (fd); strcpy (arg_own_buf, "E00"); return; } doc_len = stat_doc.size; if (len > PBUFSIZ - POVERHSIZ) len = PBUFSIZ - POVERHSIZ; if (ofs > doc_len) { write_enn (arg_own_buf); VG_(close) (fd); return; } VG_(lseek) (fd, ofs, VKI_SEEK_SET); len_read = VG_(read) (fd, toread, len); *new_packet_len_p = write_qxfer_response (arg_own_buf, (unsigned char *)toread, len_read, ofs + len_read < doc_len); VG_(close) (fd); return; } } if (strncmp ("qXfer:auxv:read:", arg_own_buf, 16) == 0) { unsigned char *data; int n; CORE_ADDR ofs; unsigned int len; const char *annex; /* Reject any annex; grab the offset and length. */ if (decode_xfer_read (arg_own_buf + 16, &annex, &ofs, &len) < 0 || annex[0] != '\0') { strcpy (arg_own_buf, "E00"); return; } if (len > PBUFSIZ - POVERHSIZ) len = PBUFSIZ - POVERHSIZ; data = malloc (len); { UWord *client_auxv = VG_(client_auxv); unsigned int client_auxv_len = 0; while (*client_auxv != 0) { dlog(4, "auxv %lld %llx\n", (ULong)*client_auxv, (ULong)*(client_auxv+1)); client_auxv++; client_auxv++; client_auxv_len += 2 * sizeof(UWord); } client_auxv_len += 2 * sizeof(UWord); dlog(4, "auxv len %d\n", client_auxv_len); if (ofs >= client_auxv_len) n = -1; else { n = client_auxv_len - ofs; VG_(memcpy) (data, (unsigned char *) VG_(client_auxv), n); } } if (n < 0) write_enn (arg_own_buf); else if (n > len) *new_packet_len_p = write_qxfer_response (arg_own_buf, data, len, 1); else *new_packet_len_p = write_qxfer_response (arg_own_buf, data, n, 0); free (data); return; } if (strncmp ("qXfer:exec-file:read:", arg_own_buf, 21) == 0) { unsigned char *data; int n; CORE_ADDR ofs; unsigned int len; const char *annex; unsigned long pid; const HChar *name; /* grab the annex, offset and length. */ if (decode_xfer_read (arg_own_buf + 21, &annex, &ofs, &len) < 0) { strcpy (arg_own_buf, "E00"); return; } /* Reject any annex with invalid/unexpected pid */ if (strlen(annex) > 0) pid = strtoul (annex, NULL, 16); else pid = 0; if ((int)pid != VG_(getpid)() && pid != 0) { VG_(sprintf) (arg_own_buf, "E.Valgrind gdbserver pid is %d." " Cannot give info for pid %d", VG_(getpid)(), (int) pid); return; } if (len > PBUFSIZ - 2) len = PBUFSIZ - 2; data = malloc (len); if (!VG_(resolve_filename)(VG_(cl_exec_fd), &name)) { VG_(sprintf) (arg_own_buf, "E.Valgrind gdbserver could not" " resolve pid %d exec filename.", VG_(getpid)()); return; } if (ofs >= strlen(name)) n = -1; else { n = strlen(name) - ofs; VG_(memcpy) (data, name, n); } if (n < 0) write_enn (arg_own_buf); else if (n > len) *new_packet_len_p = write_qxfer_response (arg_own_buf, data, len, 1); else *new_packet_len_p = write_qxfer_response (arg_own_buf, data, n, 0); free (data); return; } if (strncmp ("qXfer:siginfo:read:", arg_own_buf, 19) == 0) { vki_siginfo_t info; int n; CORE_ADDR ofs; unsigned int len; const char *annex; /* Reject any annex; grab the offset and length. */ if (decode_xfer_read (arg_own_buf + 19, &annex, &ofs, &len) < 0 || annex[0] != '\0') { strcpy (arg_own_buf, "E00"); return; } if (len > PBUFSIZ - POVERHSIZ) len = PBUFSIZ - POVERHSIZ; gdbserver_pending_signal_to_report(&info); if (ofs >= sizeof(info)) n = -1; else n = sizeof(info) - ofs; if (n < 0) write_enn (arg_own_buf); else if (n > len) *new_packet_len_p = write_qxfer_response (arg_own_buf, (unsigned char *)&info, len, 1); else *new_packet_len_p = write_qxfer_response (arg_own_buf, (unsigned char *)&info, n, 0); return; } /* Protocol features query. */ if (strncmp ("qSupported", arg_own_buf, 10) == 0 && (arg_own_buf[10] == ':' || arg_own_buf[10] == '\0')) { VG_(sprintf) (arg_own_buf, "PacketSize=%x", PBUFSIZ - 1); /* Note: max packet size including frame and checksum, but without trailing null byte, which is not sent/received. */ strcat (arg_own_buf, ";QStartNoAckMode+"); strcat (arg_own_buf, ";QPassSignals+"); if (VG_(client_auxv)) strcat (arg_own_buf, ";qXfer:auxv:read+"); if (valgrind_target_xml(VG_(clo_vgdb_shadow_registers)) != NULL) { strcat (arg_own_buf, ";qXfer:features:read+"); /* if a new gdb connects to us, we have to reset the register set to the normal register sets to allow this new gdb to decide to use or not the shadow registers. Note that the reset is only done for gdb that are sending qSupported packets. If a user first connected with a recent gdb using shadow registers and then with a very old gdb that does not use qSupported packet, then the old gdb will not properly connect. */ initialize_shadow_low(False); } strcat (arg_own_buf, ";qXfer:exec-file:read+"); strcat (arg_own_buf, ";qXfer:siginfo:read+"); return; } /* Otherwise we didn't know what packet it was. Say we didn't understand it. */ arg_own_buf[0] = 0; }