#include #include #include static enum mxdbg_status identify_kernel( struct mxdbg_host *host, const struct mxdbg_packet *req) { struct mxdbg_packet_identify_kernel id = {0}; mxdbg_packet_init( &id.id_base, sizeof id, MXDBG_PACKET_IDENTIFY_KERNEL, MXDBG_PACKET_F_RESPONSE); mxdbg_host_identify( host, MXDBG_IDENTITY_KERNEL_NAME, id.id_kernel_name, sizeof id.id_kernel_name); mxdbg_host_identify( host, MXDBG_IDENTITY_KERNEL_VERSION, id.id_kernel_version, sizeof id.id_kernel_version); mxdbg_host_identify( host, MXDBG_IDENTITY_KERNEL_ARCH, id.id_kernel_arch, sizeof id.id_kernel_arch); mxdbg_host_send(host, &id.id_base); return MXDBG_SUCCESS; } static enum mxdbg_status identify_task( struct mxdbg_host *host, const struct mxdbg_packet *packet) { struct mxdbg_packet_identify_task *req = (struct mxdbg_packet_identify_task *)packet; struct mxdbg_packet_identify_task id = {0}; id.id_base = *packet; mxdbg_host_recv_packet_data(host, &id.id_base); unsigned int tid = id.id_task; mxdbg_packet_init( &id.id_base, sizeof id, MXDBG_PACKET_IDENTIFY_TASK, MXDBG_PACKET_F_RESPONSE); mxdbg_host_identify_task( host, tid, MXDBG_IDENTITY_TASK_NAME, id.id_task_name, sizeof id.id_task_name); mxdbg_host_identify_task( host, tid, MXDBG_IDENTITY_TASK_PARENT, &id.id_parent, sizeof id.id_parent); mxdbg_host_identify_task( host, tid, MXDBG_IDENTITY_TASK_NR_THREADS, &id.id_thread_count, sizeof id.id_thread_count); size_t w; mxdbg_host_send(host, &id.id_base); debug_printf("debug: identify_task response sent"); return MXDBG_SUCCESS; } static enum mxdbg_status resume( struct mxdbg_host *host, const struct mxdbg_packet *req) { return mxdbg_host_resume(host); } enum mxdbg_status mxdbg_handle_request( struct mxdbg_host *host, const struct mxdbg_packet *req) { switch (req->pkt_type) { case MXDBG_PACKET_IDENTIFY_KERNEL: return identify_kernel(host, req); case MXDBG_PACKET_IDENTIFY_TASK: return identify_task(host, req); case MXDBG_PACKET_RESUME: return resume(host, req); default: debug_printf( "debug: unrecognised packet 0x%02x", req->pkt_type); return MXDBG_ERR_NOT_SUPPORTED; } return MXDBG_SUCCESS; }