Apply clang-format for core/iwasm compilation and libraries (#784)
Apply clang-format for core/iwasm/compilation and core/iwasm/libraries files. Add wasm-c-api empty_imports sample to workflow test. And enable triggering workflow when core/config.h changes.
This commit is contained in:
@ -55,13 +55,13 @@ process_xfer(WASMGDBServer *server, const char *name, char *args)
|
||||
*args++ = '\0';
|
||||
|
||||
if (!strcmp(name, "libraries") && !strcmp(mode, "read")) {
|
||||
//TODO: how to get current wasm file name?
|
||||
// TODO: how to get current wasm file name?
|
||||
uint64_t addr = wasm_debug_instance_get_load_addr(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
char objname[128];
|
||||
wasm_debug_instance_get_current_object_name(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, objname, 128);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, objname, 128);
|
||||
sprintf(tmpbuf,
|
||||
"l<library-list><library name=\"%s\"><section "
|
||||
"address=\"0x%lx\"/></library></library-list>",
|
||||
@ -88,8 +88,8 @@ porcess_wasm_local(WASMGDBServer *server, char *args)
|
||||
sprintf(tmpbuf, "E01");
|
||||
if (sscanf(args, "%d;%d", &frame_index, &local_index) == 2) {
|
||||
ret = wasm_debug_instance_get_local(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, frame_index,
|
||||
local_index, buf, &size);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, frame_index,
|
||||
local_index, buf, &size);
|
||||
if (ret && size > 0) {
|
||||
mem2hex(buf, tmpbuf, size);
|
||||
}
|
||||
@ -109,8 +109,8 @@ porcess_wasm_global(WASMGDBServer *server, char *args)
|
||||
sprintf(tmpbuf, "E01");
|
||||
if (sscanf(args, "%d;%d", &frame_index, &global_index) == 2) {
|
||||
ret = wasm_debug_instance_get_global(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, frame_index,
|
||||
global_index, buf, &size);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, frame_index,
|
||||
global_index, buf, &size);
|
||||
if (ret && size > 0) {
|
||||
mem2hex(buf, tmpbuf, size);
|
||||
}
|
||||
@ -133,14 +133,15 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
if (!strcmp(name, "C")) {
|
||||
uint64_t pid, tid;
|
||||
pid = wasm_debug_instance_get_pid(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
tid = wasm_debug_instance_get_tid(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
snprintf(tmpbuf, sizeof(tmpbuf), "QCp%lx.%lx", pid, tid);
|
||||
write_packet(server, tmpbuf);
|
||||
}
|
||||
if (!strcmp(name, "Supported")) {
|
||||
sprintf(tmpbuf, "qXfer:libraries:read+;PacketSize=%x;", MAX_PACKET_SIZE);
|
||||
sprintf(tmpbuf, "qXfer:libraries:read+;PacketSize=%x;",
|
||||
MAX_PACKET_SIZE);
|
||||
write_packet(server, tmpbuf);
|
||||
}
|
||||
|
||||
@ -161,10 +162,9 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
}
|
||||
|
||||
if (!strcmp(name, "HostInfo")) {
|
||||
//Todo: change vendor to Intel for outside tree?
|
||||
// Todo: change vendor to Intel for outside tree?
|
||||
char triple[256];
|
||||
mem2hex("wasm32-Ant-wasi-wasm", triple,
|
||||
strlen("wasm32-Ant-wasi-wasm"));
|
||||
mem2hex("wasm32-Ant-wasi-wasm", triple, strlen("wasm32-Ant-wasi-wasm"));
|
||||
sprintf(tmpbuf,
|
||||
"vendor:Ant;ostype:wasi;arch:wasm32;"
|
||||
"triple:%s;endian:little;ptrsize:4;",
|
||||
@ -183,14 +183,13 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
write_packet(server, "");
|
||||
}
|
||||
if (!strcmp(name, "ProcessInfo")) {
|
||||
//Todo: process id parent-pid
|
||||
// Todo: process id parent-pid
|
||||
uint64_t pid;
|
||||
pid = wasm_debug_instance_get_pid(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
char triple[256];
|
||||
//arch-vendor-os-env(format)
|
||||
mem2hex("wasm32-Ant-wasi-wasm", triple,
|
||||
strlen("wasm32-Ant-wasi-wasm"));
|
||||
// arch-vendor-os-env(format)
|
||||
mem2hex("wasm32-Ant-wasi-wasm", triple, strlen("wasm32-Ant-wasi-wasm"));
|
||||
sprintf(tmpbuf,
|
||||
"pid:%lx;parent-pid:%lx;vendor:Ant;ostype:wasi;arch:wasm32;"
|
||||
"triple:%s;endian:little;ptrsize:4;",
|
||||
@ -200,9 +199,9 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
}
|
||||
if (!strcmp(name, "RegisterInfo0")) {
|
||||
sprintf(
|
||||
tmpbuf,
|
||||
"name:pc;alt-name:pc;bitsize:64;offset:0;encoding:uint;format:hex;"
|
||||
"set:General Purpose Registers;gcc:16;dwarf:16;generic:pc;");
|
||||
tmpbuf,
|
||||
"name:pc;alt-name:pc;bitsize:64;offset:0;encoding:uint;format:hex;"
|
||||
"set:General Purpose Registers;gcc:16;dwarf:16;generic:pc;");
|
||||
write_packet(server, tmpbuf);
|
||||
}
|
||||
else if (!strncmp(name, "RegisterInfo", strlen("RegisterInfo"))) {
|
||||
@ -215,24 +214,23 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
if (args && (!strcmp(name, "MemoryRegionInfo"))) {
|
||||
uint64_t addr = strtol(args, NULL, 16);
|
||||
WASMDebugMemoryInfo *mem_info = wasm_debug_instance_get_memregion(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr);
|
||||
if (mem_info) {
|
||||
char name[256];
|
||||
mem2hex(mem_info->name, name, strlen(mem_info->name));
|
||||
sprintf(tmpbuf, "start:%lx;size:%lx;permissions:%s;name:%s;",
|
||||
(uint64)mem_info->start, mem_info->size, mem_info->permisson, name);
|
||||
(uint64)mem_info->start, mem_info->size,
|
||||
mem_info->permisson, name);
|
||||
write_packet(server, tmpbuf);
|
||||
wasm_debug_instance_destroy_memregion(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, mem_info);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, mem_info);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(name, "WasmData")) {
|
||||
|
||||
}
|
||||
|
||||
if (!strcmp(name, "WasmMem")) {
|
||||
|
||||
}
|
||||
|
||||
if (!strcmp(name, "Symbol")) {
|
||||
@ -243,8 +241,8 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
uint64_t tid = strtol(args, NULL, 16);
|
||||
uint64_t buf[1024 / sizeof(uint64_t)];
|
||||
uint64_t count = wasm_debug_instance_get_call_stack_pcs(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, buf,
|
||||
1024 / sizeof(uint64_t));
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, buf,
|
||||
1024 / sizeof(uint64_t));
|
||||
if (count > 0) {
|
||||
mem2hex((char *)buf, tmpbuf, count * sizeof(uint64_t));
|
||||
write_packet(server, tmpbuf);
|
||||
@ -276,16 +274,17 @@ send_thread_stop_status(WASMGDBServer *server, uint32_t status, uint64_t tid)
|
||||
return;
|
||||
}
|
||||
tids_number = wasm_debug_instance_get_tids(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tids, 20);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tids, 20);
|
||||
uint64_t pc = wasm_debug_instance_get_pc(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
|
||||
if (status == WAMR_SIG_SINGSTEP) {
|
||||
gdb_status = WAMR_SIG_TRAP;
|
||||
}
|
||||
|
||||
//TODO: how name a wasm thread?
|
||||
len += sprintf(tmpbuf, "T%02xthread:%lx;name:%s;", gdb_status, tid, "nobody");
|
||||
// TODO: how name a wasm thread?
|
||||
len +=
|
||||
sprintf(tmpbuf, "T%02xthread:%lx;name:%s;", gdb_status, tid, "nobody");
|
||||
if (tids_number > 0) {
|
||||
len += sprintf(tmpbuf + len, "threads:");
|
||||
while (i < tids_number) {
|
||||
@ -336,12 +335,12 @@ handle_v_packet(WASMGDBServer *server, char *payload)
|
||||
*numstring++ = '\0';
|
||||
uint64_t tid = strtol(numstring, NULL, 16);
|
||||
wasm_debug_instance_set_cur_thread(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid);
|
||||
wasm_debug_instance_singlestep(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid);
|
||||
tid = wasm_debug_instance_wait_thread(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid,
|
||||
&status);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid,
|
||||
&status);
|
||||
send_thread_stop_status(server, status, tid);
|
||||
}
|
||||
}
|
||||
@ -352,11 +351,11 @@ void
|
||||
handle_threadstop_request(WASMGDBServer *server, char *payload)
|
||||
{
|
||||
uint64_t tid = wasm_debug_instance_get_tid(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
uint32_t status;
|
||||
|
||||
tid = wasm_debug_instance_wait_thread(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
||||
|
||||
send_thread_stop_status(server, status, tid);
|
||||
}
|
||||
@ -370,7 +369,7 @@ handle_set_current_thread(WASMGDBServer *server, char *payload)
|
||||
tid = strtol(payload, NULL, 16);
|
||||
if (tid > 0)
|
||||
wasm_debug_instance_set_cur_thread(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid);
|
||||
}
|
||||
write_packet(server, "OK");
|
||||
}
|
||||
@ -385,7 +384,7 @@ handle_get_register(WASMGDBServer *server, char *payload)
|
||||
return;
|
||||
}
|
||||
uint64_t regdata = wasm_debug_instance_get_pc(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
mem2hex((void *)®data, tmpbuf, 8);
|
||||
tmpbuf[8 * 2] = '\0';
|
||||
write_packet(server, tmpbuf);
|
||||
@ -423,8 +422,8 @@ handle_get_read_memory(WASMGDBServer *server, char *payload)
|
||||
char *buff = wasm_runtime_malloc(mlen);
|
||||
if (buff) {
|
||||
ret = wasm_debug_instance_get_mem(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, maddr, buff,
|
||||
&mlen);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, maddr,
|
||||
buff, &mlen);
|
||||
if (ret) {
|
||||
mem2hex(buff, tmpbuf, mlen);
|
||||
}
|
||||
@ -451,8 +450,8 @@ handle_get_write_memory(WASMGDBServer *server, char *payload)
|
||||
if (buff) {
|
||||
hex2mem(payload, buff, act_len);
|
||||
ret = wasm_debug_instance_set_mem(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, maddr, buff,
|
||||
&mlen);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, maddr,
|
||||
buff, &mlen);
|
||||
if (ret) {
|
||||
sprintf(tmpbuf, "%s", "OK");
|
||||
}
|
||||
@ -470,8 +469,8 @@ handle_add_break(WASMGDBServer *server, char *payload)
|
||||
if (sscanf(payload, "%zx,%zx,%zx", &type, &addr, &length) == 3) {
|
||||
if (type == eBreakpointSoftware) {
|
||||
bool ret = wasm_debug_instance_add_breakpoint(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr,
|
||||
length);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr,
|
||||
length);
|
||||
if (ret)
|
||||
write_packet(server, "OK");
|
||||
else
|
||||
@ -490,8 +489,8 @@ handle_remove_break(WASMGDBServer *server, char *payload)
|
||||
if (sscanf(payload, "%zx,%zx,%zx", &type, &addr, &length) == 3) {
|
||||
if (type == eBreakpointSoftware) {
|
||||
bool ret = wasm_debug_instance_remove_breakpoint(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr,
|
||||
length);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr,
|
||||
length);
|
||||
if (ret)
|
||||
write_packet(server, "OK");
|
||||
else
|
||||
@ -509,13 +508,13 @@ handle_continue_request(WASMGDBServer *server, char *payload)
|
||||
uint32_t status;
|
||||
|
||||
wasm_debug_instance_continue(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
|
||||
tid = wasm_debug_instance_get_tid(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
|
||||
tid = wasm_debug_instance_wait_thread(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
||||
|
||||
send_thread_stop_status(server, status, tid);
|
||||
}
|
||||
@ -527,13 +526,13 @@ handle_kill_request(WASMGDBServer *server, char *payload)
|
||||
uint32_t status;
|
||||
|
||||
wasm_debug_instance_kill(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
|
||||
tid = wasm_debug_instance_get_tid(
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
(WASMDebugInstance *)server->thread->debug_instance);
|
||||
|
||||
tid = wasm_debug_instance_wait_thread(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
||||
|
||||
send_thread_stop_status(server, status, tid);
|
||||
}
|
||||
@ -572,7 +571,8 @@ handle_malloc(WASMGDBServer *server, char *payload)
|
||||
args++;
|
||||
}
|
||||
addr = wasm_debug_instance_mmap(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, size, map_port);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, size,
|
||||
map_port);
|
||||
if (addr) {
|
||||
sprintf(tmpbuf, "%lx", addr);
|
||||
}
|
||||
@ -590,7 +590,7 @@ handle_free(WASMGDBServer *server, char *payload)
|
||||
addr = strtol(payload, NULL, 16);
|
||||
|
||||
ret = wasm_debug_instance_ummap(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr);
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr);
|
||||
if (ret) {
|
||||
sprintf(tmpbuf, "%s", "OK");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user