diff options
-rw-r--r-- | agent/machine/a64/tcf/stack-crawl-a64.c | 4 | ||||
-rw-r--r-- | agent/machine/arm/tcf/stack-crawl-arm.c | 6 | ||||
-rw-r--r-- | agent/system/GNU/Linux/tcf/context-linux.c | 64 | ||||
-rw-r--r-- | agent/tcf/framework/channel.c | 6 | ||||
-rw-r--r-- | agent/tcf/framework/channel_tcp.c | 15 | ||||
-rw-r--r-- | agent/tcf/framework/events.c | 18 | ||||
-rw-r--r-- | agent/tcf/framework/mdep.h | 15 | ||||
-rw-r--r-- | agent/tcf/framework/myalloc.c | 10 | ||||
-rw-r--r-- | agent/tcf/framework/outputbuf.c | 4 | ||||
-rw-r--r-- | agent/tcf/framework/protocol.c | 4 | ||||
-rw-r--r-- | agent/tcf/main/gdb-rsp.c | 2 | ||||
-rw-r--r-- | agent/tcf/main/main_lua.c | 540 | ||||
-rw-r--r-- | agent/tcf/services/breakpoints.c | 2 | ||||
-rw-r--r-- | agent/tcf/services/discovery_udp.c | 4 | ||||
-rw-r--r-- | agent/tcf/services/dwarfframe.c | 10 | ||||
-rw-r--r-- | agent/tcf/services/expressions.c | 4 | ||||
-rw-r--r-- | agent/tcf/services/filesystem.c | 4 | ||||
-rw-r--r-- | agent/tcf/services/linenumbers_proxy.c | 4 | ||||
-rw-r--r-- | agent/tcf/services/runctrl.c | 2 | ||||
-rw-r--r-- | agent/tcf/services/stacktrace.c | 6 | ||||
-rw-r--r-- | agent/tcf/services/symbols_win32.c | 6 | ||||
-rw-r--r-- | agent/tcf/services/tcf_elf.c | 6 |
22 files changed, 343 insertions, 393 deletions
diff --git a/agent/machine/a64/tcf/stack-crawl-a64.c b/agent/machine/a64/tcf/stack-crawl-a64.c index 916a6f81..c087eaff 100644 --- a/agent/machine/a64/tcf/stack-crawl-a64.c +++ b/agent/machine/a64/tcf/stack-crawl-a64.c @@ -1007,7 +1007,7 @@ static int trace_a64(void) { unsigned i; /* Unknown/undecoded. May alter some register, so invalidate file */ for (i = 0; i < 30; i++) reg_data[i].o = 0; - trace(LOG_STACK, "Stack crawl: unknown ARM A64 instruction %08x", instr); + trace(LOG_STACK, "Stack crawl: unknown ARM A64 instruction %08" PRIx32, instr); } if (!trace_return && !trace_branch) { @@ -1026,7 +1026,7 @@ static int trace_instructions(void) { unsigned t = 0; BranchData * b = NULL; if (chk_loaded(REG_ID_SP) < 0) return -1; - trace(LOG_STACK, "Stack crawl: pc 0x%" PRIX64 ", sp 0x%" PRIX64, + trace(LOG_STACK, "Stack crawl: pc 0x%" PRIx64 ", sp 0x%" PRIx64, pc_data.o ? pc_data.v : (uint64_t)0, reg_data[REG_ID_SP].o ? reg_data[REG_ID_SP].v : (uint64_t)0); for (t = 0; t < MAX_INST; t++) { diff --git a/agent/machine/arm/tcf/stack-crawl-arm.c b/agent/machine/arm/tcf/stack-crawl-arm.c index ca936405..5eb11fc8 100644 --- a/agent/machine/arm/tcf/stack-crawl-arm.c +++ b/agent/machine/arm/tcf/stack-crawl-arm.c @@ -2216,7 +2216,7 @@ static int trace_arm(void) { unsigned i; /* Unknown/undecoded. May alter some register, so invalidate file */ for (i = 0; i < 11; i++) reg_data[i].o = 0; - trace(LOG_STACK, "Stack crawl: unknown ARM A32 instruction %08x", instr); + trace(LOG_STACK, "Stack crawl: unknown ARM A32 instruction %08" PRIx32, instr); } if (!trace_return && !trace_branch) { @@ -2254,7 +2254,7 @@ static int trace_instructions(void) { sym_addr + sym_size <= 0x100000000) { func_addr = (uint32_t)sym_addr; func_size = (uint32_t)sym_size; - trace(LOG_STACK, "Function symbol: addr 0x%08x, size 0x%08x", func_addr, func_size); + trace(LOG_STACK, "Function symbol: addr 0x%08" PRIx32 ", size 0x%08" PRIx32, func_addr, func_size); } } #endif @@ -2266,7 +2266,7 @@ static int trace_instructions(void) { BranchData * b = NULL; if (chk_loaded(13) < 0) return -1; if (chk_loaded(15) < 0) return -1; - trace(LOG_STACK, "Stack crawl: pc 0x%08x, sp 0x%08x", + trace(LOG_STACK, "Stack crawl: pc 0x%08" PRIx32 ", sp 0x%08" PRIx32, reg_data[15].o ? reg_data[15].v : 0, reg_data[13].o ? reg_data[13].v : 0); for (t = 0; t < 200; t++) { diff --git a/agent/system/GNU/Linux/tcf/context-linux.c b/agent/system/GNU/Linux/tcf/context-linux.c index 177e9e3c..b962f52d 100644 --- a/agent/system/GNU/Linux/tcf/context-linux.c +++ b/agent/system/GNU/Linux/tcf/context-linux.c @@ -249,7 +249,7 @@ static int context_detach(Context * ctx) { assert(ctx->parent == NULL); assert(!ctx->exited); - trace(LOG_CONTEXT, "context: detach ctx %#lx, id %s", ctx, ctx->id); + trace(LOG_CONTEXT, "context: detach ctx %#" PRIxPTR ", id %s", (uintptr_t)ctx, ctx->id); unplant_breakpoints(ctx); ctx->exiting = 1; @@ -290,8 +290,8 @@ static int get_process_state(pid_t pid) { int context_stop(Context * ctx) { ContextExtensionLinux * ext = EXT(ctx); - trace(LOG_CONTEXT, "context:%s suspending ctx %#lx id %s", - ctx->pending_intercept ? "" : " temporary", ctx, ctx->id); + trace(LOG_CONTEXT, "context:%s suspending ctx %#" PRIxPTR ", id %s", + ctx->pending_intercept ? "" : " temporary", (uintptr_t)ctx, ctx->id); assert(is_dispatch_thread()); assert(context_has_state(ctx)); assert(!ctx->exited); @@ -323,8 +323,8 @@ int context_stop(Context * ctx) { return 0; } trace(LOG_ALWAYS, - "error: tkill(SIGSTOP) failed: ctx %#lx, id %s, error %d %s", - ctx, ctx->id, err, errno_to_str(err)); + "error: tkill(SIGSTOP) failed: ctx %#" PRIxPTR ", id %s, error %d %s", + (uintptr_t)ctx, ctx->id, err, errno_to_str(err)); errno = err; return -1; } @@ -430,8 +430,8 @@ static int flush_regs(Context * ctx) { { RegisterDefinition * def = get_reg_definitions(ctx); while (def->name != NULL && (def->offset > i || def->offset + def->size <= i)) def++; - trace(LOG_ALWAYS, "error: writing register %s failed: ctx %#lx, id %s, error %d %s", - def->name ? def->name : "?", ctx, ctx->id, err, errno_to_str(err)); + trace(LOG_ALWAYS, "error: writing register %s failed: ctx %#" PRIxPTR ", id %s, error %d %s", + def->name ? def->name : "?", (uintptr_t)ctx, ctx->id, err, errno_to_str(err)); if (err == ESRCH) { ctx->exiting = 1; memset(ext->regs_dirty, 0, sizeof(REG_SET)); @@ -490,14 +490,14 @@ static int do_single_step(Context * ctx) { if (skip_breakpoint(ctx, 1)) return 0; if (!ctx->stopped) return 0; - trace(LOG_CONTEXT, "context: single step ctx %#lx, id %s", ctx, ctx->id); + trace(LOG_CONTEXT, "context: single step ctx %#" PRIxPTR ", id %s", (uintptr_t)ctx, ctx->id); if (cpu_enable_stepping_mode(ctx, &is_cont) < 0) return -1; if (flush_regs(ctx) < 0) return -1; if (is_cont) cmd = PTRACE_CONT; if (ptrace(cmd, ext->pid, 0, 0) < 0) { int err = errno; - trace(LOG_ALWAYS, "error: ptrace(%s, ...) failed: ctx %#lx, id %s, error %d %s", - get_ptrace_cmd_name(cmd), ctx, ctx->id, err, errno_to_str(err)); + trace(LOG_ALWAYS, "error: ptrace(%s, ...) failed: ctx %#" PRIxPTR ", id %s, error %d %s", + get_ptrace_cmd_name(cmd), (uintptr_t)ctx, ctx->id, err, errno_to_str(err)); if (err == ESRCH) { ctx->exiting = 1; send_context_started_event(ctx); @@ -571,7 +571,7 @@ int context_continue(Context * ctx) { assert(signal != SIGTRAP); } - trace(LOG_CONTEXT, "context: resuming ctx %#lx, id %s, with signal %d", ctx, ctx->id, signal); + trace(LOG_CONTEXT, "context: resuming ctx %#" PRIxPTR ", id %s, with signal %d", (uintptr_t)ctx, ctx->id, signal); #if defined(__i386__) || defined(__x86_64__) if (ext->regs->user.regs.eflags & 0x100) { ext->regs->user.regs.eflags &= ~0x100; @@ -583,8 +583,8 @@ int context_continue(Context * ctx) { sigset_is_empty(&ctx->pending_signals)) cmd = PTRACE_DETACH; if (ptrace(cmd, ext->pid, 0, signal) < 0) { int err = errno; - trace(LOG_ALWAYS, "error: ptrace(%s, ...) failed: ctx %#lx, id %s, error %d %s", - get_ptrace_cmd_name(cmd), ctx, ctx->id, err, errno_to_str(err)); + trace(LOG_ALWAYS, "error: ptrace(%s, ...) failed: ctx %#" PRIxPTR ", id %s, error %d %s", + get_ptrace_cmd_name(cmd), (uintptr_t)ctx, ctx->id, err, errno_to_str(err)); if (err == ESRCH) { ctx->exiting = 1; send_context_started_event(ctx); @@ -692,14 +692,14 @@ int context_write_mem(Context * ctx, ContextAddress address, void * buf, size_t assert(is_dispatch_thread()); assert(!ctx->exited); trace(LOG_CONTEXT, - "context: write memory ctx %#lx, id %s, address %#lx, size %zu", - ctx, ctx->id, address, size); + "context: write memory ctx %#" PRIxPTR ", id %s, address %#lx, size %zu", + (uintptr_t)ctx, ctx->id, address, size); mem_err_info.error = 0; if (size == 0) return 0; if (address + size < address) { trace(LOG_CONTEXT, - "context: write past the end of memory: ctx %#lx, id %s, addr %#lx, size %ld", - ctx, ctx->id, address, size); + "context: write past the end of memory: ctx %#" PRIxPTR ", id %s, addr %#lx, size %ld", + (uintptr_t)ctx, ctx->id, address, size); errno = EFAULT; return -1; } @@ -714,8 +714,8 @@ int context_write_mem(Context * ctx, ContextAddress address, void * buf, size_t error = errno; if (error != ESRCH || ctx != ctx->mem) { trace(LOG_CONTEXT, - "context: ptrace(PTRACE_PEEKDATA, ...) failed: ctx %#lx, id %s, addr %#lx, error %d %s", - ctx, ctx->id, word_addr, error, errno_to_str(error)); + "context: ptrace(PTRACE_PEEKDATA, ...) failed: ctx %#" PRIxPTR ", id %s, addr %#lx, error %d %s", + (uintptr_t)ctx, ctx->id, word_addr, error, errno_to_str(error)); } break; } @@ -732,8 +732,8 @@ int context_write_mem(Context * ctx, ContextAddress address, void * buf, size_t error = errno; if (error != ESRCH || ctx != ctx->mem) { trace(LOG_ALWAYS, - "error: ptrace(PTRACE_POKEDATA, ...) failed: ctx %#lx, id %s, addr %#lx, error %d %s", - ctx, ctx->id, word_addr, error, errno_to_str(error)); + "error: ptrace(PTRACE_POKEDATA, ...) failed: ctx %#" PRIxPTR ", id %s, addr %#lx, error %d %s", + (uintptr_t)ctx, ctx->id, word_addr, error, errno_to_str(error)); } break; } @@ -792,14 +792,14 @@ int context_read_mem(Context * ctx, ContextAddress address, void * buf, size_t s assert(is_dispatch_thread()); assert(!ctx->exited); trace(LOG_CONTEXT, - "context: read memory ctx %#lx, id %s, address %#lx, size %zu", - ctx, ctx->id, address, size); + "context: read memory ctx %#" PRIxPTR ", id %s, address %#lx, size %zu", + (uintptr_t)ctx, ctx->id, address, size); mem_err_info.error = 0; if (size == 0) return 0; if ((address + size) < address) { trace(LOG_CONTEXT, - "context: read past the end of memory: ctx %#lx, id %s, addr %#lx, size %ld", - ctx, ctx->id, address, size); + "context: read past the end of memory: ctx %#" PRIxPTR ", id %s, addr %#lx, size %ld", + (uintptr_t)ctx, ctx->id, address, size); errno = EFAULT; return -1; } @@ -811,8 +811,8 @@ int context_read_mem(Context * ctx, ContextAddress address, void * buf, size_t s error = errno; if (error != ESRCH || ctx != ctx->mem) { trace(LOG_CONTEXT, - "context: ptrace(PTRACE_PEEKDATA, ...) failed: ctx %#lx, id %s, addr %#lx, error %d %s", - ctx, ctx->id, word_addr, error, errno_to_str(error)); + "context: ptrace(PTRACE_PEEKDATA, ...) failed: ctx %#" PRIxPTR ", id %s, addr %#lx, error %d %s", + (uintptr_t)ctx, ctx->id, word_addr, error, errno_to_str(error)); } break; } @@ -979,8 +979,8 @@ int context_read_reg(Context * ctx, RegisterDefinition * def, unsigned offs, uns } if (err) { - trace(LOG_ALWAYS, "error: reading registers failed: ctx %#lx, id %s, error %d %s", - ctx, ctx->id, err, errno_to_str(err)); + trace(LOG_ALWAYS, "error: reading registers failed: ctx %#" PRIxPTR ", id %s, error %d %s", + (uintptr_t)ctx, ctx->id, err, errno_to_str(err)); errno = err; return -1; } @@ -1243,7 +1243,7 @@ static void event_pid_exited(pid_t pid, int status, int signal) { * between PTRACE_CONT (or PTRACE_SYSCALL) and SIGTRAP/PTRACE_EVENT_EXIT. So, ctx->exiting can be 0. */ Context * prs = ctx->parent; - trace(LOG_EVENTS, "event: ctx %#lx, pid %d, exit status %d, term signal %d", ctx, pid, status, signal); + trace(LOG_EVENTS, "event: ctx %#" PRIxPTR ", pid %d, exit status %d, term signal %d", (uintptr_t)ctx, pid, status, signal); assert(EXT(prs)->attach_callback == NULL); assert(!prs->exited); assert(!ctx->exited); @@ -1352,7 +1352,7 @@ static Context * add_thread(Context * parent, Context * creator, pid_t pid) { #if ENABLE_ProfilerSST profiler_sst_add(ctx); #endif - trace(LOG_EVENTS, "event: new context 0x%x, id %s", ctx, ctx->id); + trace(LOG_EVENTS, "event: new context %#" PRIxPTR ", id %s", (uintptr_t)ctx, ctx->id); send_context_created_event(ctx); return ctx; } @@ -1527,7 +1527,7 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) { (ctx2->parent = prs)->ref_count++; list_add_last(&ctx2->cldl, &prs->children); link_context(ctx2); - trace(LOG_EVENTS, "event: new context 0x%x, id %s", ctx2, ctx2->id); + trace(LOG_EVENTS, "event: new context %#" PRIxPTR ", id %s", (uintptr_t)ctx2, ctx2->id); send_context_created_event(ctx2); if (state == 't' || state == 'T') { event_pid_stopped(child_pid, SIGSTOP, 0, 0); diff --git a/agent/tcf/framework/channel.c b/agent/tcf/framework/channel.c index d43149cb..98c20fca 100644 --- a/agent/tcf/framework/channel.c +++ b/agent/tcf/framework/channel.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016-2017 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -585,7 +585,7 @@ void add_channel_transport(const char * transportname, ChannelServerCreate creat * Start communication of a newly created channel */ void channel_start(Channel * c) { - trace(LOG_PROTOCOL, "Starting channel %#lx %s", c, c->peer_name); + trace(LOG_PROTOCOL, "Starting channel %#" PRIxPTR " %s", (uintptr_t)c, c->peer_name); assert(c->protocol != NULL); assert(c->state == ChannelStateStartWait); c->state = ChannelStateStarted; @@ -596,6 +596,6 @@ void channel_start(Channel * c) { * Close communication channel */ void channel_close(Channel * c) { - trace(LOG_PROTOCOL, "Closing channel %#lx %s", c, c->peer_name); + trace(LOG_PROTOCOL, "Closing channel %#" PRIxPTR " %s", (uintptr_t)c, c->peer_name); c->close(c, 0); } diff --git a/agent/tcf/framework/channel_tcp.c b/agent/tcf/framework/channel_tcp.c index 06ae5c44..e74e4874 100644 --- a/agent/tcf/framework/channel_tcp.c +++ b/agent/tcf/framework/channel_tcp.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -224,7 +224,7 @@ static int certificate_verify_callback(int preverify_ok, X509_STORE_CTX * ctx) { #endif /* ENABLE_SSL */ static void delete_channel(ChannelTCP * c) { - trace(LOG_PROTOCOL, "Deleting channel %#lx", c); + trace(LOG_PROTOCOL, "Deleting channel %#" PRIxPTR, (uintptr_t)c); assert(c->lock_cnt == 0); assert(c->out_flush_cnt == 0); assert(c->magic == CHANNEL_MAGIC); @@ -328,7 +328,7 @@ static void post_write_request(OutputBuffer * bf) { } else { int error = set_ssl_errno(); - trace(LOG_PROTOCOL, "Can't SSL_write() on channel %#lx: %s", c, errno_to_str(error)); + trace(LOG_PROTOCOL, "Can't SSL_write() on channel %#" PRIxPTR ": %s", (uintptr_t)c, errno_to_str(error)); c->wr_req.type = AsyncReqSend; c->wr_req.error = error; c->wr_req.u.sio.rval = -1; @@ -601,7 +601,7 @@ static void tcp_post_read(InputBuf * ibuf, unsigned char * buf, size_t size) { } else { if (c->chan->state != ChannelStateDisconnected) { - trace(LOG_ALWAYS, "Can't SSL_read() on channel %#lx: %s", c, errno_to_str(set_ssl_errno())); + trace(LOG_ALWAYS, "Can't SSL_read() on channel %#" PRIxPTR ": %s", (uintptr_t)c, errno_to_str(set_ssl_errno())); } c->read_done = 0; post_event(c->rd_req.done, &c->rd_req); @@ -675,7 +675,7 @@ static void send_eof_and_close(Channel * channel, int err) { channel->disconnected(channel); } else { - trace(LOG_PROTOCOL, "channel %#lx disconnected", c); + trace(LOG_PROTOCOL, "channel %#" PRIxPTR " disconnected", (uintptr_t)c); if (channel->protocol != NULL) protocol_release(channel->protocol); } channel->protocol = NULL; @@ -694,7 +694,7 @@ static void handle_channel_msg(void * x) { has_msg = ibuf_start_message(&c->ibuf); if (has_msg <= 0) { if (has_msg < 0 && c->chan->state != ChannelStateDisconnected) { - trace(LOG_PROTOCOL, "Socket is shutdown by remote peer, channel %#lx %s", c, c->chan->peer_name); + trace(LOG_PROTOCOL, "Socket is shutdown by remote peer, channel %#" PRIxPTR " %s", (uintptr_t)c, c->chan->peer_name); channel_close(c->chan); } } @@ -1149,7 +1149,8 @@ static int setup_unix_sockaddr(PeerServer * ps, struct sockaddr_un * localhost) memset(localhost, 0, sizeof(struct sockaddr_un)); if (strlen(host) >= sizeof(localhost->sun_path)) { - trace(LOG_ALWAYS, "Socket file path is too long (%d > %d)", strlen(host), sizeof(localhost->sun_path) - 1); + trace(LOG_ALWAYS, "Socket file path is too long (%u > %u)", + (unsigned)strlen(host), (unsigned)sizeof(localhost->sun_path) - 1); return E2BIG; } diff --git a/agent/tcf/framework/events.c b/agent/tcf/framework/events.c index 41ab9529..9e7de6f7 100644 --- a/agent/tcf/framework/events.c +++ b/agent/tcf/framework/events.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015, 2017 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -183,8 +183,8 @@ static void post_from_bg_thread(EventCallBack * handler, void * arg, unsigned lo else { prev->next = ev; } - trace(LOG_EVENTCORE, "post_event: event %#lx, handler %#lx, arg %#lx, runtime %02d%02d.%03d", - ev, ev->handler, ev->arg, + trace(LOG_EVENTCORE, "post_event: event %#" PRIxPTR ", handler %#" PRIxPTR ", arg %#" PRIxPTR ", runtime %02ld%02ld.%03ld", + (uintptr_t)ev, (uintptr_t)ev->handler, (uintptr_t)ev->arg, ev->runtime.tv_sec / 60 % 60, ev->runtime.tv_sec % 60, ev->runtime.tv_nsec / 1000000); check_error(pthread_mutex_unlock(&event_lock)); } @@ -221,8 +221,8 @@ void post_event_with_delay(EventCallBack * handler, void * arg, unsigned long de } check_error(pthread_mutex_unlock(&event_lock)); - trace(LOG_EVENTCORE, "post_event: event %#lx, handler %#lx, arg %#lx, runtime %02d%02d.%03d", - ev, ev->handler, ev->arg, + trace(LOG_EVENTCORE, "post_event: event %#" PRIxPTR ", handler %#" PRIxPTR ", arg %#" PRIxPTR ", runtime %02ld%02ld.%03ld", + (uintptr_t)ev, (uintptr_t)ev->handler, (uintptr_t)ev->arg, ev->runtime.tv_sec / 60 % 60, ev->runtime.tv_sec % 60, ev->runtime.tv_nsec / 1000000); } else { @@ -248,7 +248,8 @@ void post_event(EventCallBack * handler, void * arg) { event_last->next = ev; event_last = ev; } - trace(LOG_EVENTCORE, "post_event: event %#lx, handler %#lx, arg %#lx", ev, ev->handler, ev->arg); + trace(LOG_EVENTCORE, "post_event: event %#" PRIxPTR ", handler %#" PRIxPTR ", arg %#" PRIxPTR, + (uintptr_t)ev, (uintptr_t)ev->handler, (uintptr_t)ev->arg); } else { post_from_bg_thread(handler, arg, 0); @@ -263,7 +264,7 @@ int cancel_event(EventCallBack * handler, void * arg, int wait) { assert(handler != NULL); assert(cancel_handler == NULL); - trace(LOG_EVENTCORE, "cancel_event: handler %#lx, arg %#lx, wait %d", handler, arg, wait); + trace(LOG_EVENTCORE, "cancel_event: handler %#" PRIxPTR ", arg %#" PRIxPTR ", wait %d", (uintptr_t)handler, (uintptr_t)arg, wait); prev = NULL; ev = event_queue; while (ev != NULL) { @@ -449,7 +450,8 @@ void run_event_loop(void) { event_last = NULL; } - trace(LOG_EVENTCORE, "run_event_loop: event %#lx, handler %#lx, arg %#lx", ev, ev->handler, ev->arg); + trace(LOG_EVENTCORE, "run_event_loop: event %#" PRIxPTR ", handler %#" PRIxPTR ", arg %#" PRIxPTR, + (uintptr_t)ev, (uintptr_t)ev->handler, (uintptr_t)ev->arg); if (ev->runtime.tv_sec == 0 && ev->runtime.tv_nsec == 0) { /* Don't count timer queue events since getting new timer events * before the previous batch of timer events are processed diff --git a/agent/tcf/framework/mdep.h b/agent/tcf/framework/mdep.h index 5c89e837..5c5d7080 100644 --- a/agent/tcf/framework/mdep.h +++ b/agent/tcf/framework/mdep.h @@ -96,10 +96,13 @@ #elif defined(_WIN32) typedef long ssize_t; #endif +# define PRIx32 "I32x" # define PRIu64 "I64u" # define PRId64 "I64d" +# define PRIx64 "I64x" # define PRIX64 "I64X" # define SCNx64 "I64x" +# define PRIxPTR "Ix" #else # include <inttypes.h> #endif @@ -316,15 +319,27 @@ extern int tkill(pid_t pid, int signal); #endif +#ifndef PRIx32 +# define PRIx32 "lx" +#endif +#ifndef PRIu64 +# define PRIu64 "llu" +#endif #ifndef PRId64 # define PRId64 "lld" #endif +#ifndef PRIx64 +# define PRIx64 "llx" +#endif #ifndef PRIX64 # define PRIX64 "llX" #endif #ifndef SCNx64 # define SCNx64 "llx" #endif +#ifndef PRIxPTR +# define PRIxPTR "x" +#endif #ifndef MEM_USAGE_FACTOR # define MEM_USAGE_FACTOR 32 diff --git a/agent/tcf/framework/myalloc.c b/agent/tcf/framework/myalloc.c index 7d7eb32e..a088479e 100644 --- a/agent/tcf/framework/myalloc.c +++ b/agent/tcf/framework/myalloc.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -177,7 +177,7 @@ void * loc_alloc(size_t size) { perror("malloc"); exit(1); } - trace(LOG_ALLOC, "loc_alloc(%u) = %#lx", (unsigned)size, p); + trace(LOG_ALLOC, "loc_alloc(%u) = %#" PRIxPTR, (unsigned)size, (uintptr_t)p); return p; } @@ -190,7 +190,7 @@ void * loc_alloc_zero(size_t size) { exit(1); } memset(p, 0, size); - trace(LOG_ALLOC, "loc_alloc_zero(%u) = %#lx", (unsigned)size, p); + trace(LOG_ALLOC, "loc_alloc_zero(%u) = %#" PRIxPTR, (unsigned)size, (uintptr_t)p); return p; } @@ -202,12 +202,12 @@ void * loc_realloc(void * ptr, size_t size) { perror("realloc"); exit(1); } - trace(LOG_ALLOC, "loc_realloc(%#lx, %u) = %#lx", ptr, (unsigned)size, p); + trace(LOG_ALLOC, "loc_realloc(%#" PRIxPTR ", %u) = %#" PRIxPTR, (uintptr_t)ptr, (unsigned)size, (uintptr_t)p); return p; } void loc_free(const void * p) { - trace(LOG_ALLOC, "loc_free %#lx", p); + trace(LOG_ALLOC, "loc_free %#" PRIxPTR, (uintptr_t)p); free((void *)p); } diff --git a/agent/tcf/framework/outputbuf.c b/agent/tcf/framework/outputbuf.c index a18aa7e4..8348d1a0 100644 --- a/agent/tcf/framework/outputbuf.c +++ b/agent/tcf/framework/outputbuf.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -123,7 +123,7 @@ void output_queue_done(OutputQueue * q, int error, int size) { assert(q->error == 0); if (error) { q->error = error; - trace(LOG_PROTOCOL, "Can't write() on output queue %#lx: %s", q, errno_to_str(q->error)); + trace(LOG_PROTOCOL, "Can't write() on output queue %#" PRIxPTR ": %s", (uintptr_t)q, errno_to_str(q->error)); output_queue_clear(q); } else { diff --git a/agent/tcf/framework/protocol.c b/agent/tcf/framework/protocol.c index 04dc2854..f43320a3 100644 --- a/agent/tcf/framework/protocol.c +++ b/agent/tcf/framework/protocol.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -697,7 +697,7 @@ static void channel_closed(Channel * c) { clear_trap(&trap); } else { - trace(LOG_ALWAYS, "Exception handling reply %ul: %d %s", + trace(LOG_ALWAYS, "Exception handling reply %lu: %d %s", rh->tokenid, trap.error, errno_to_str(trap.error)); } if (c->state != ChannelStateDisconnected) { diff --git a/agent/tcf/main/gdb-rsp.c b/agent/tcf/main/gdb-rsp.c index f134c075..b2659699 100644 --- a/agent/tcf/main/gdb-rsp.c +++ b/agent/tcf/main/gdb-rsp.c @@ -1482,7 +1482,7 @@ static int handle_Z_command(GdbClient * c) { write_stream(out, ']'); break; case 3: - snprintf(str, sizeof(str), "0x%" PRIX64, (uint64_t)addr); + snprintf(str, sizeof(str), "%#" PRIx64, (uint64_t)addr); json_write_string(out, str); break; case 4: diff --git a/agent/tcf/main/main_lua.c b/agent/tcf/main/main_lua.c index cf85b392..95ff7aa0 100644 --- a/agent/tcf/main/main_lua.c +++ b/agent/tcf/main/main_lua.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -127,8 +127,7 @@ static struct lua_read_command_state lua_read_command_state; static void lua_read_command_fillbuf(struct lua_read_command_state *state); -static struct luaref *luaref_new(lua_State *L, void * owner) -{ +static struct luaref *luaref_new(lua_State *L, void * owner) { struct luaref *refp = (struct luaref *)loc_alloc(sizeof *refp); refp->ref = luaL_ref(L, LUA_REGISTRYINDEX); @@ -138,14 +137,13 @@ static struct luaref *luaref_new(lua_State *L, void * owner) return refp; } -static void luaref_free(lua_State *L, struct luaref *p) -{ +static void luaref_free(lua_State *L, struct luaref *p) { struct luaref **refpp; struct luaref *refp; refpp = &refroot; - while((refp = *refpp) != NULL) { - if(refp == p) { + while ((refp = *refpp) != NULL) { + if (refp == p) { *refpp = refp->next; luaL_unref(L, LUA_REGISTRYINDEX, refp->ref); loc_free(refp); @@ -156,14 +154,13 @@ static void luaref_free(lua_State *L, struct luaref *p) assert(!"lua reference not found in list"); } -static void luaref_owner_free(lua_State *L, void * owner) -{ +static void luaref_owner_free(lua_State *L, void * owner) { struct luaref **refpp; struct luaref *refp; refpp = &refroot; - while((refp = *refpp) != NULL) { - if(refp->owner == owner) { + while ((refp = *refpp) != NULL) { + if (refp->owner == owner) { *refpp = refp->next; luaL_unref(L, LUA_REGISTRYINDEX, refp->ref); loc_free(refp); @@ -174,11 +171,10 @@ static void luaref_owner_free(lua_State *L, void * owner) } #ifndef NDEBUG -static int lua_isclass(lua_State *L, int index, const char *name) -{ +static int lua_isclass(lua_State *L, int index, const char *name) { int rval; - if(!lua_getmetatable(L, index)) return 0; + if (!lua_getmetatable(L, index)) return 0; lua_getfield(L, LUA_REGISTRYINDEX, name); rval = lua_rawequal(L, -1, -2); lua_pop(L, 2); @@ -186,79 +182,66 @@ static int lua_isclass(lua_State *L, int index, const char *name) } #endif -static struct peer_extra *lua2peer(lua_State *L, int index) -{ - if(luaL_checkudata(L, index, "tcf_peer") == NULL) { - return NULL; - } +static struct peer_extra *lua2peer(lua_State *L, int index) { + if (luaL_checkudata(L, index, "tcf_peer") == NULL) return NULL; return (struct peer_extra *)lua_touserdata(L, index); } -static struct protocol_extra *lua2protocol(lua_State *L, int index) -{ - if(luaL_checkudata(L, index, "tcf_protocol") == NULL) { - return NULL; - } +static struct protocol_extra *lua2protocol(lua_State *L, int index) { + if (luaL_checkudata(L, index, "tcf_protocol") == NULL) return NULL; return (struct protocol_extra *)lua_touserdata(L, index); } -static struct channel_extra *lua2channel(lua_State *L, int index) -{ - if(luaL_checkudata(L, index, "tcf_channel") == NULL) { - return NULL; - } +static struct channel_extra *lua2channel(lua_State *L, int index) { + if (luaL_checkudata(L, index, "tcf_channel") == NULL) return NULL; return (struct channel_extra *)lua_touserdata(L, index); } -static struct post_event_extra *lua2postevent(lua_State *L, int index) -{ - if(luaL_checkudata(L, index, "tcf_post_event") == NULL) { - return NULL; - } +static struct post_event_extra *lua2postevent(lua_State *L, int index) { + if (luaL_checkudata(L, index, "tcf_post_event") == NULL) return NULL; return (struct post_event_extra *)lua_touserdata(L, index); } -static void lua_read_command_getline(void *client_data) -{ +static void lua_read_command_getline(void *client_data) { int c; lua_State *L = luastate; struct lua_read_command_state *state = (struct lua_read_command_state *)client_data; assert(state->reqline != 0); assert(state->reqdata == 0); - while(state->bufrd < state->bufwr) { + while (state->bufrd < state->bufwr) { c = state->buf[state->bufrd++]; - switch(state->bufst) { + switch (state->bufst) { case bufst_normal: case_bufst_normal: - if(c == '\\') { + if (c == '\\') { state->bufst = bufst_esc; continue; } - if(c == '\r') { + if (c == '\r') { state->bufst = bufst_eol_optnl; goto eol; } - if(c == '\n') { + if (c == '\n') { state->bufst = bufst_eol; goto eol; } break; case bufst_normal_optnl: - if(c == '\n') { + if (c == '\n') { state->bufst = bufst_normal; continue; } goto case_bufst_normal; case bufst_esc: - if(c == '\r') { + if (c == '\r') { state->bufst = bufst_normal_optnl; c = '\n'; break; } - if(c == '\n') { + if (c == '\n') { state->bufst = bufst_normal; break; } @@ -277,14 +260,14 @@ static void lua_read_command_getline(void *client_data) case bufst_eol_optnl: state->bufst = bufst_normal; - if(c == '\n') continue; + if (c == '\n') continue; goto case_bufst_normal; default: assert(!"unexpected state"); } - if(state->lineind == state->linemax) { - if(state->linemax == 0) { + if (state->lineind == state->linemax) { + if (state->linemax == 0) { state->linemax = 1024; state->line = (char *)loc_alloc(state->linemax); } @@ -296,7 +279,7 @@ static void lua_read_command_getline(void *client_data) state->line[state->lineind++] = (char)c; } eol: - if(state->bufst != bufst_eol_optnl && state->bufst != bufst_eol && !state->eof) { + if (state->bufst != bufst_eol_optnl && state->bufst != bufst_eol && !state->eof) { assert(state->bufrd == state->bufwr); lua_read_command_fillbuf(state); return; @@ -306,7 +289,7 @@ eol: lua_rawgeti(L, LUA_REGISTRYINDEX, state->refp->ref); luaref_free(L, state->refp); state->refp = NULL; - if(state->lineind > 0 || !state->eof) { + if (state->lineind > 0 || !state->eof) { trace(LOG_LUA, "lua_read_command: %.*s", state->lineind, state->line); lua_pushlstring(L, state->line, state->lineind); state->lineind = 0; @@ -315,21 +298,20 @@ eol: trace(LOG_LUA, "lua_read_command: EOF"); lua_pushnil(L); } - if(lua_pcall(L, 1, 0, 0) != 0) { + if (lua_pcall(L, 1, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } return; } -static void lua_read_command_done(void *client_data) -{ +static void lua_read_command_done(void *client_data) { AsyncReqInfo *req = (AsyncReqInfo *)client_data; struct lua_read_command_state *state = (struct lua_read_command_state *)req->client_data; assert(state->reqdata != 0); state->reqdata = 0; - if(state->req.u.fio.rval > 0) { + if (state->req.u.fio.rval > 0) { state->bufwr += state->req.u.fio.rval; state->eof = 0; } @@ -339,8 +321,7 @@ static void lua_read_command_done(void *client_data) lua_read_command_getline(state); } -static void lua_read_command_fillbuf(struct lua_read_command_state *state) -{ +static void lua_read_command_fillbuf(struct lua_read_command_state *state) { assert(state->reqdata == 0); assert(state->bufrd == state->bufwr); state->reqdata = 1; @@ -354,20 +335,19 @@ static void lua_read_command_fillbuf(struct lua_read_command_state *state) async_req_post(&state->req); } -static int lua_read_command(lua_State *L) -{ +static int lua_read_command(lua_State *L) { struct lua_read_command_state *state = &lua_read_command_state; assert(L == luastate); assert(state->reqline == 0); - if(lua_gettop(L) != 1 || !lua_isfunction(L, 1)) { + if (lua_gettop(L) != 1 || !lua_isfunction(L, 1)) { luaL_error(L, "wrong number or type of arguments"); } trace(LOG_LUA, "lua_read_command start"); lua_pushvalue(L, 1); state->refp = luaref_new(L, state); state->reqline = 1; - if(state->bufrd == state->bufwr) { + if (state->bufrd == state->bufwr) { lua_read_command_fillbuf(state); } else { @@ -376,14 +356,13 @@ static int lua_read_command(lua_State *L) return 0; } -static struct peer_extra *lookup_pse(lua_State *L, PeerServer *ps) -{ +static struct peer_extra *lookup_pse(lua_State *L, PeerServer *ps) { struct peer_extra *pse; lua_rawgeti(L, LUA_REGISTRYINDEX, peers_refp->ref); lua_pushstring(L, ps->id); /* Key */ lua_rawget(L, -2); - if((pse = (struct peer_extra *)lua_touserdata(L, -1)) == NULL) { + if ((pse = (struct peer_extra *)lua_touserdata(L, -1)) == NULL) { assert(lua_isnil(L, -1)); lua_pop(L, 2); return NULL; @@ -393,8 +372,7 @@ static struct peer_extra *lookup_pse(lua_State *L, PeerServer *ps) return pse; } -static struct peer_extra *lua_alloc_pse(lua_State *L, PeerServer *ps) -{ +static struct peer_extra *lua_alloc_pse(lua_State *L, PeerServer *ps) { struct peer_extra *pse; /* Allocate new LUA object for peer */ @@ -408,14 +386,13 @@ static struct peer_extra *lua_alloc_pse(lua_State *L, PeerServer *ps) return pse; } -static struct peer_extra *lua_push_pse(lua_State *L, PeerServer *ps) -{ +static struct peer_extra *lua_push_pse(lua_State *L, PeerServer *ps) { struct peer_extra *pse; lua_rawgeti(L, LUA_REGISTRYINDEX, peers_refp->ref); lua_pushstring(L, ps->id); /* Key */ lua_rawget(L, -2); - if((pse = (struct peer_extra *)lua_touserdata(L, -1)) != NULL) { + if ((pse = (struct peer_extra *)lua_touserdata(L, -1)) != NULL) { assert(lua_isclass(L, -1, "tcf_peer")); assert(pse->managed); @@ -437,12 +414,11 @@ static struct peer_extra *lua_push_pse(lua_State *L, PeerServer *ps) return pse; } -static void peer_server_changes(PeerServer *ps, int changeType, void * client_data) -{ +static void peer_server_changes(PeerServer *ps, int changeType, void * client_data) { lua_State *L = (lua_State *)client_data; struct peer_extra *pse = lookup_pse(L, ps); - switch(changeType) { + switch (changeType) { case PS_EVENT_ADDED: assert(pse == NULL); break; @@ -451,11 +427,11 @@ static void peer_server_changes(PeerServer *ps, int changeType, void * client_da break; case PS_EVENT_CHANGED: - if(pse != NULL) pse->ps = ps; + if (pse != NULL) pse->ps = ps; break; case PS_EVENT_REMOVED: - if(pse != NULL) pse->ps = NULL; + if (pse != NULL) pse->ps = NULL; break; default: @@ -463,19 +439,18 @@ static void peer_server_changes(PeerServer *ps, int changeType, void * client_da } } -static int lua_peer_server_find(lua_State *L) -{ +static int lua_peer_server_find(lua_State *L) { PeerServer *ps; const char *name; assert(L == luastate); - if(lua_gettop(L) != 1 || !lua_isstring(L, 1)) { + if (lua_gettop(L) != 1 || !lua_isstring(L, 1)) { luaL_error(L, "wrong number or type of arguments"); } name = lua_tostring(L, 1); ps = peer_server_find(name); - trace(LOG_LUA, "lua_peer_server_find %s %p", name, ps); - if(ps == NULL) { + trace(LOG_LUA, "lua_peer_server_find %s %#" PRIxPTR, name, (uintptr_t)ps); + if (ps == NULL) { lua_pushnil(L); return 1; } @@ -483,18 +458,16 @@ static int lua_peer_server_find(lua_State *L) return 1; } -static int lua_peer_server_list_entry(PeerServer * ps, void * client_data) -{ +static int lua_peer_server_list_entry(PeerServer * ps, void * client_data) { lua_State *L = (lua_State *)client_data; lua_push_pse(L, ps); lua_rawseti(L, -2, lua_objlen(L, -2) + 1); return 0; } -static int lua_peer_server_list(lua_State *L) -{ +static int lua_peer_server_list(lua_State *L) { assert(L == luastate); - if(lua_gettop(L) != 0) { + if (lua_gettop(L) != 0) { luaL_error(L, "wrong number of arguments"); } trace(LOG_LUA, "lua_peer_server_list"); @@ -503,29 +476,27 @@ static int lua_peer_server_list(lua_State *L) return 1; } -static int lua_peer_server_from_url(lua_State *L) -{ +static int lua_peer_server_from_url(lua_State *L) { PeerServer *ps; const char *url; assert(L == luastate); - if(lua_gettop(L) != 1 || !lua_isstring(L, 1)) { + if (lua_gettop(L) != 1 || !lua_isstring(L, 1)) { luaL_error(L, "wrong number or type of arguments"); } url = lua_tostring(L, 1); ps = channel_peer_from_url(url); - trace(LOG_LUA, "lua_peer_server_from_url %s %p", url, ps); - if(ps == NULL) luaL_error(L, "cannot parse url: %s", lua_tostring(L, 1)); - if(ps->id == NULL) { + trace(LOG_LUA, "lua_peer_server_from_url %s %#" PRIxPTR, url, (uintptr_t)ps); + if (ps == NULL) luaL_error(L, "cannot parse url: %s", lua_tostring(L, 1)); + if (ps->id == NULL) { peer_server_addprop(ps, loc_strdup("ID"), loc_strdup(lua_tostring(L, 1))); } lua_alloc_pse(L, ps); return 1; } -static struct protocol_extra *lua_protocol_ref(struct protocol_extra *pe, int index) -{ - if(pe->ucnt == 0) { +static struct protocol_extra *lua_protocol_ref(struct protocol_extra *pe, int index) { + if (pe->ucnt == 0) { assert(lua_touserdata(pe->L, index) == pe); lua_pushvalue(pe->L, index); /* Prevent GC while connection is active */ pe->self_refp = luaref_new(pe->L, pe); @@ -534,23 +505,21 @@ static struct protocol_extra *lua_protocol_ref(struct protocol_extra *pe, int in return pe; } -static void lua_protocol_unref(struct protocol_extra *pe) -{ +static void lua_protocol_unref(struct protocol_extra *pe) { assert(pe->ucnt > 0); assert(pe->self_refp != NULL); pe->ucnt--; - if(pe->ucnt == 0) { + if (pe->ucnt == 0) { luaref_free(pe->L, pe->self_refp); pe->self_refp = NULL; } } -static int lua_protocol_alloc(lua_State *L) -{ +static int lua_protocol_alloc(lua_State *L) { struct protocol_extra *pe; assert(L == luastate); - if(lua_gettop(L) != 0) { + if (lua_gettop(L) != 0) { luaL_error(L, "wrong number or type of arguments"); } trace(LOG_LUA, "lua_protocol_alloc"); @@ -563,8 +532,7 @@ static int lua_protocol_alloc(lua_State *L) return 1; } -static int lua_channel_server(lua_State *L) -{ +static int lua_channel_server(lua_State *L) { trace(LOG_LUA, "lua_channel_server"); luaL_error(L, "not implemented"); return 0; @@ -575,14 +543,14 @@ static void channel_connecting(Channel * c) { struct channel_extra *ce = (struct channel_extra *)c->client_data; lua_State *L = ce->L; - if(ce->connecting_cbrefp != NULL) { + if (ce->connecting_cbrefp != NULL) { lua_rawgeti(L, LUA_REGISTRYINDEX, ce->connecting_cbrefp->ref); - if(lua_pcall(L, 0, 0, 0) != 0) { + if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } } - trace(LOG_LUA, "lua_channel_connecting %p", c); + trace(LOG_LUA, "lua_channel_connecting %#" PRIxPTR, (uintptr_t)c); send_hello_message(c); } @@ -590,10 +558,10 @@ static void channel_connected(Channel * c) { struct channel_extra *ce = (struct channel_extra *)c->client_data; lua_State *L = ce->L; - trace(LOG_LUA, "lua_channel_connected %p", c); - if(ce->connected_cbrefp != NULL) { + trace(LOG_LUA, "lua_channel_connected %#" PRIxPTR, (uintptr_t)c); + if (ce->connected_cbrefp != NULL) { lua_rawgeti(L, LUA_REGISTRYINDEX, ce->connected_cbrefp->ref); - if(lua_pcall(L, 0, 0, 0) != 0) { + if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } @@ -604,10 +572,10 @@ static void channel_receive(Channel * c) { struct channel_extra *ce = (struct channel_extra *)c->client_data; lua_State *L = ce->L; - trace(LOG_LUA, "lua_channel_receive %p", c); - if(ce->receive_cbrefp != NULL) { + trace(LOG_LUA, "lua_channel_receive %#" PRIxPTR, (uintptr_t)c); + if (ce->receive_cbrefp != NULL) { lua_rawgeti(L, LUA_REGISTRYINDEX, ce->receive_cbrefp->ref); - if(lua_pcall(L, 0, 0, 0) != 0) { + if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } @@ -619,10 +587,10 @@ static void channel_disconnected(Channel * c) { struct channel_extra *ce = (struct channel_extra *)c->client_data; lua_State *L = ce->L; - trace(LOG_LUA, "lua_channel_disconnected %p", c); - if(ce->disconnected_cbrefp != NULL) { + trace(LOG_LUA, "lua_channel_disconnected %#" PRIxPTR, (uintptr_t)c); + if (ce->disconnected_cbrefp != NULL) { lua_rawgeti(L, LUA_REGISTRYINDEX, ce->disconnected_cbrefp->ref); - if(lua_pcall(L, 0, 0, 0) != 0) { + if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } @@ -634,15 +602,14 @@ static void channel_disconnected(Channel * c) { luaref_owner_free(L, ce); } -static void lua_channel_connect_cb(void * client_data, int error, Channel * c) -{ +static void lua_channel_connect_cb(void * client_data, int error, Channel * c) { struct channel_extra *ce = (struct channel_extra *)client_data; lua_State *L = ce->L; - trace(LOG_LUA, "lua_channel_connect_cb %p %d", c, error); + trace(LOG_LUA, "lua_channel_connect_cb %#" PRIxPTR " %d", (uintptr_t)c, error); assert(ce->connect_cbrefp != NULL); lua_rawgeti(L, LUA_REGISTRYINDEX, ce->connect_cbrefp->ref); - if(!error) { + if (!error) { assert(c != NULL); ce->c = c; c->client_data = ce; @@ -660,27 +627,26 @@ static void lua_channel_connect_cb(void * client_data, int error, Channel * c) lua_pushnil(L); lua_pushstring(L, errno_to_str(error)); } - if(lua_pcall(L, 2, 0, 0) != 0) { + if (lua_pcall(L, 2, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } } -static int lua_channel_connect(lua_State *L) -{ +static int lua_channel_connect(lua_State *L) { struct peer_extra *pse = NULL; struct protocol_extra *pe = NULL; struct channel_extra *ce; assert(L == luastate); - if(lua_gettop(L) != 3 || + if (lua_gettop(L) != 3 || (pse = lua2peer(L, 1)) == NULL || (pe = lua2protocol(L, 2)) == NULL || !lua_isfunction(L, 3)) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_channel_connect %p", pse->ps); - if(pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_channel_connect %#" PRIxPTR, (uintptr_t)pse->ps); + if (pse->ps == NULL) luaL_error(L, "stale peer"); ce = (struct channel_extra *)lua_newuserdata(L, sizeof *ce); memset(ce, 0, sizeof *ce); lua_pushvalue(L, -1); /* Prevent GC while connection is active */ @@ -695,29 +661,27 @@ static int lua_channel_connect(lua_State *L) return 0; } -static void lua_post_event_cb(void * client_data) -{ +static void lua_post_event_cb(void * client_data) { struct post_event_extra *p = (struct post_event_extra *)client_data; lua_State *L = p->L; assert(p->handler_refp != NULL); - trace(LOG_LUA, "lua_post_event_cb %d", p->handler_refp); + trace(LOG_LUA, "lua_post_event_cb %#" PRIxPTR, (uintptr_t)p->handler_refp); lua_rawgeti(L, LUA_REGISTRYINDEX, p->handler_refp->ref); luaref_owner_free(L, p); - if(lua_pcall(L, 0, 0, 0) != 0) { + if (lua_pcall(L, 0, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } } -static int lua_post_event(lua_State *L) -{ +static int lua_post_event(lua_State *L) { struct post_event_extra *p; unsigned long delay; assert(L == luastate); - if(lua_gettop(L) > 2 || !lua_isfunction(L, 1) || + if (lua_gettop(L) > 2 || !lua_isfunction(L, 1) || (lua_gettop(L) > 1 && !(lua_isnil(L, 2) || lua_isnumber(L, 2)))) { luaL_error(L, "wrong number or type of arguments"); } @@ -728,11 +692,11 @@ static int lua_post_event(lua_State *L) p->self_refp = luaref_new(L, p); lua_pushvalue(L, 1); p->handler_refp = luaref_new(L, p); - trace(LOG_LUA, "lua_post_event %d", p->handler_refp); + trace(LOG_LUA, "lua_post_event %#" PRIxPTR, (uintptr_t)p->handler_refp); luaL_getmetatable(L, "tcf_post_event"); lua_setmetatable(L, -2); delay = lua_tointeger(L, 2); - if(delay == 0) { + if (delay == 0) { post_event(lua_post_event_cb, p); } else { @@ -754,30 +718,28 @@ static const luaL_Reg tcffuncs[] = { }; -static int lua_protocol_tostring(lua_State *L) -{ +static int lua_protocol_tostring(lua_State *L) { struct protocol_extra *pe = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pe = lua2protocol(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pe = lua2protocol(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_protocol_tostring %p", pe->p); - lua_pushfstring(L, "tcf_protocol (%p, %d)", pe, pe->ucnt); + trace(LOG_LUA, "lua_protocol_tostring %#" PRIxPTR, (uintptr_t)pe->p); + lua_pushfstring(L, "tcf_protocol (%#" PRIxPTR ", %d)", (uintptr_t)pe, pe->ucnt); return 1; } -static int lua_protocol_gc(lua_State *L) -{ +static int lua_protocol_gc(lua_State *L) { struct protocol_extra *pe = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pe = lua2protocol(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pe = lua2protocol(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } assert(pe->ucnt == 0); assert(pe->p != NULL); - trace(LOG_LUA, "lua_protocol_gc %p", pe->p); + trace(LOG_LUA, "lua_protocol_gc %#" PRIxPTR, (uintptr_t)pe->p); protocol_release(pe->p); pe->p = NULL; return 0; @@ -794,26 +756,25 @@ static void protocol_command_handler(char * token, Channel * c, void * client_da lua_rawgeti(L, LUA_REGISTRYINDEX, refp->ref); lua_pushstring(L, token); luaL_buffinit(L, &msg); - while((ch = read_stream(inp)) >= 0) { + while ((ch = read_stream(inp)) >= 0) { luaL_addchar(&msg, ch); } luaL_pushresult(&msg); trace(LOG_LUA, "lua_protocol_command %d %s", refp->ref, lua_tostring(L, -1)); - if(lua_pcall(L, 2, 0, 0) != 0) { + if (lua_pcall(L, 2, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } } -static int lua_protocol_command_handler(lua_State *L) -{ +static int lua_protocol_command_handler(lua_State *L) { struct protocol_extra *pe = NULL; struct luaref *refp; const char *service; const char *name; assert(L == luastate); - if(lua_gettop(L) != 4 || (pe = lua2protocol(L, 1)) == NULL || + if (lua_gettop(L) != 4 || (pe = lua2protocol(L, 1)) == NULL || !lua_isstring(L, 2) || !lua_isstring(L, 3) || !lua_isfunction(L, 4)) { luaL_error(L, "wrong number or type of arguments"); @@ -836,10 +797,9 @@ static const luaL_Reg protocolfuncs[] = { }; -static const char *channel_state_string(Channel * c) -{ +static const char *channel_state_string(Channel * c) { if (c == NULL) return "Disconnected"; - switch(c->state) { + switch (c->state) { case ChannelStateStartWait: return "StartWait"; case ChannelStateStarted: return "Started"; case ChannelStateHelloSent: return "HelloSent"; @@ -852,119 +812,112 @@ static const char *channel_state_string(Channel * c) } } -static int lua_channel_tostring(lua_State *L) -{ +static int lua_channel_tostring(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_channel_tostring %p", ce->c); - if(ce->c != NULL) { - lua_pushfstring(L, "tcf_channel (%s, %p, %s)", ce->c->peer_name, ce, + trace(LOG_LUA, "lua_channel_tostring %#" PRIxPTR, (uintptr_t)ce->c); + if (ce->c != NULL) { + lua_pushfstring(L, "tcf_channel (%s, %#" PRIxPTR ", %s)", (uintptr_t)ce->c->peer_name, ce, channel_state_string(ce->c)); } else { - lua_pushfstring(L, "tcf_channel (<disconnected>, %p)", ce); + lua_pushfstring(L, "tcf_channel (<disconnected>, %#" PRIxPTR ")", (uintptr_t)ce); } return 1; } -static int lua_channel_state(lua_State *L) -{ +static int lua_channel_state(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_channel_state %p", ce->c); + trace(LOG_LUA, "lua_channel_state %#" PRIxPTR, (uintptr_t)ce->c); lua_pushstring(L, channel_state_string(ce->c)); return 1; } -static int lua_channel_close(lua_State *L) -{ +static int lua_channel_close(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_channel_close %p", ce->c); - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + trace(LOG_LUA, "lua_channel_close %#" PRIxPTR, (uintptr_t)ce->c); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); channel_close(ce->c); return 0; } static void update_callback(lua_State *L, int index, struct luaref **cbrefpp, void * owner) { - if(!lua_isfunction(L, index) && !lua_isnil(L, index)) { + if (!lua_isfunction(L, index) && !lua_isnil(L, index)) { luaL_error(L, "handler must be function or nil"); } - if(*cbrefpp != NULL) { + if (*cbrefpp != NULL) { luaref_free(L, *cbrefpp); *cbrefpp = NULL; } - if(lua_isfunction(L, index)) { + if (lua_isfunction(L, index)) { lua_pushvalue(L, index); *cbrefpp = luaref_new(L, owner); } } -static int lua_channel_connecting_handler(lua_State *L) -{ +static int lua_channel_connecting_handler(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); update_callback(L, 2, &ce->connecting_cbrefp, ce); - trace(LOG_LUA, "lua_channel_connecting_handler %p", ce->c, ce->connecting_cbrefp->ref); + trace(LOG_LUA, "lua_channel_connecting_handler %#" PRIxPTR " %#" PRIxPTR, (uintptr_t)ce->c, (uintptr_t)ce->connecting_cbrefp->ref); return 0; } -static int lua_channel_connected_handler(lua_State *L) -{ +static int lua_channel_connected_handler(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); update_callback(L, 2, &ce->connected_cbrefp, ce); - trace(LOG_LUA, "lua_channel_connected_handler %p", ce->c, ce->connected_cbrefp->ref); + trace(LOG_LUA, "lua_channel_connected_handler %#" PRIxPTR " %#" PRIxPTR, (uintptr_t)ce->c, (uintptr_t)ce->connected_cbrefp->ref); return 0; } -static int lua_channel_receive_handler(lua_State *L) -{ +static int lua_channel_receive_handler(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); update_callback(L, 2, &ce->receive_cbrefp, ce); - trace(LOG_LUA, "lua_channel_receive_handler %p", ce->c, ce->receive_cbrefp->ref); + trace(LOG_LUA, "lua_channel_receive_handler %#" PRIxPTR " %#" PRIxPTR, (uintptr_t)ce->c, (uintptr_t)ce->receive_cbrefp->ref); return 0; } -static int lua_channel_disconnected_handler(lua_State *L) -{ +static int lua_channel_disconnected_handler(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); update_callback(L, 2, &ce->disconnected_cbrefp, ce); - trace(LOG_LUA, "lua_channel_disconnected_handler %p", ce->c, ce->disconnected_cbrefp->ref); + trace(LOG_LUA, "lua_channel_disconnected_handler %#" PRIxPTR " %#" PRIxPTR, (uintptr_t)ce->c, (uintptr_t)ce->disconnected_cbrefp->ref); return 0; } @@ -978,81 +931,77 @@ static void channel_event_handler(Channel * c, void * client_data) { lua_rawgeti(L, LUA_REGISTRYINDEX, refp->ref); luaL_buffinit(L, &msg); - while((ch = read_stream(inp)) >= 0) { + while ((ch = read_stream(inp)) >= 0) { luaL_addchar(&msg, ch); } luaL_pushresult(&msg); - trace(LOG_LUA, "lua_channel_event %p %d %s", c, refp->ref, lua_tostring(L, -1)); - if(lua_pcall(L, 1, 0, 0) != 0) { + trace(LOG_LUA, "lua_channel_event %#" PRIxPTR " %d %s", (uintptr_t)c, refp->ref, lua_tostring(L, -1)); + if (lua_pcall(L, 1, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } } -static int lua_channel_event_handler(lua_State *L) -{ +static int lua_channel_event_handler(lua_State *L) { struct channel_extra *ce = NULL; struct luaref *refp; const char *service; const char *name; assert(L == luastate); - if(lua_gettop(L) != 4 || (ce = lua2channel(L, 1)) == NULL || + if (lua_gettop(L) != 4 || (ce = lua2channel(L, 1)) == NULL || !lua_isstring(L, 2) || !lua_isstring(L, 3) || !lua_isfunction(L, 4)) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); lua_pushvalue(L, 4); refp = luaref_new(L, ce); service = lua_tostring(L, 2); name = lua_tostring(L, 3); - trace(LOG_LUA, "lua_channel_event_handler %p %s %s %d", ce->c, service, name, refp->ref); + trace(LOG_LUA, "lua_channel_event_handler %#" PRIxPTR " %s %s %d", (uintptr_t)ce->c, service, name, refp->ref); add_event_handler2(ce->c, service, name, channel_event_handler, refp); return 0; } -static int lua_channel_start(lua_State *L) -{ +static int lua_channel_start(lua_State *L) { struct channel_extra *ce = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); - trace(LOG_LUA, "lua_channel_start %p", ce->c); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); + trace(LOG_LUA, "lua_channel_start %#" PRIxPTR, (uintptr_t)ce->c); channel_start(ce->c); return 0; } -static int lua_channel_send_message(lua_State *L) -{ +static int lua_channel_send_message(lua_State *L) { struct channel_extra *ce = NULL; OutputStream *out; const char *s; size_t l; assert(L == luastate); - if(lua_gettop(L) != 2 || + if (lua_gettop(L) != 2 || (ce = lua2channel(L, 1)) == NULL || !lua_isstring(L, 2)) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); s = lua_tolstring(L, 2, &l); - trace(LOG_LUA, "lua_channel_send_message %p %.*s", ce->c, l, s); + trace(LOG_LUA, "lua_channel_send_message %#" PRIxPTR " %.*s", (uintptr_t)ce->c, (int)l, s); out = &ce->c->out; - while(l-- > 0) { + while (l-- > 0) { write_stream(out, (*s++) & 0xff); } write_stream(out, MARKER_EOM); return 0; } -static void channel_send_command_cb(Channel * c, void * client_data, int error) -{ +static void channel_send_command_cb(Channel * c, void * client_data, int error) { struct channel_extra *ce = (struct channel_extra *)c->client_data; struct command_extra *cmd = (struct command_extra *)client_data; lua_State *L = ce->L; @@ -1061,29 +1010,28 @@ static void channel_send_command_cb(Channel * c, void * client_data, int error) int ch; lua_rawgeti(L, LUA_REGISTRYINDEX, cmd->result_cbrefp->ref); - if(!error) { + if (!error) { luaL_buffinit(L, &msg); - while((ch = read_stream(inp)) >= 0) { + while ((ch = read_stream(inp)) >= 0) { luaL_addchar(&msg, ch); } luaL_pushresult(&msg); lua_pushnil(L); - trace(LOG_LUA, "lua_channel_send_command_reply %p %d %s", c, cmd->result_cbrefp->ref, lua_tostring(L, -2)); + trace(LOG_LUA, "lua_channel_send_command_reply %#" PRIxPTR " %d %s", (uintptr_t)c, cmd->result_cbrefp->ref, lua_tostring(L, -2)); } else { lua_pushnil(L); lua_pushstring(L, errno_to_str(error)); - trace(LOG_LUA, "lua_channel_send_command_reply %p %d error %d", c, cmd->result_cbrefp->ref, error); + trace(LOG_LUA, "lua_channel_send_command_reply %#" PRIxPTR " %d error %d", (uintptr_t)c, cmd->result_cbrefp->ref, error); } - if(lua_pcall(L, 2, 0, 0) != 0) { + if (lua_pcall(L, 2, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } luaref_owner_free(L, cmd); } -static int lua_channel_send_command(lua_State *L) -{ +static int lua_channel_send_command(lua_State *L) { struct channel_extra *ce = NULL; struct command_extra *cmd; OutputStream *out; @@ -1091,7 +1039,7 @@ static int lua_channel_send_command(lua_State *L) size_t l; assert(L == luastate); - if(lua_gettop(L) != 5 || + if (lua_gettop(L) != 5 || (ce = lua2channel(L, 1)) == NULL || !lua_isstring(L, 2) || !lua_isstring(L, 3) || @@ -1099,7 +1047,7 @@ static int lua_channel_send_command(lua_State *L) !lua_isfunction(L, 5)) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); /* Object to track outstanding command */ cmd = (struct command_extra *)lua_newuserdata(L, sizeof *cmd); @@ -1119,57 +1067,54 @@ static int lua_channel_send_command(lua_State *L) lua_tostring(L, 3), channel_send_command_cb, cmd); s = lua_tolstring(L, 4, &l); - trace(LOG_LUA, "lua_channel_send_command %p %d %.*s", ce->c, cmd->result_cbrefp->ref, l, s); + trace(LOG_LUA, "lua_channel_send_command %#" PRIxPTR " %d %.*s", (uintptr_t)ce->c, cmd->result_cbrefp->ref, (int)l, s); out = &ce->c->out; - while(l-- > 0) { + while (l-- > 0) { write_stream(out, (*s++) & 0xff); } write_stream(out, MARKER_EOM); return 1; } -static int lua_channel_cancel_command(lua_State *L) -{ +static int lua_channel_cancel_command(lua_State *L) { trace(LOG_LUA, "lua_channel_cancel_command"); luaL_error(L, "not implemented"); return 0; } -static void channel_redirect_cb(Channel * c, void * client_data, int error) -{ +static void channel_redirect_cb(Channel * c, void * client_data, int error) { struct channel_extra *ce = (struct channel_extra *)c->client_data; struct command_extra *cmd = (struct command_extra *)client_data; lua_State *L = ce->L; lua_rawgeti(L, LUA_REGISTRYINDEX, cmd->result_cbrefp->ref); - if(!error) { + if (!error) { lua_pushnil(L); - trace(LOG_LUA, "lua_channel_redirect_reply %p %d %s", c, cmd->result_cbrefp->ref, lua_tostring(L, -2)); + trace(LOG_LUA, "lua_channel_redirect_reply %#" PRIxPTR " %d %s", (uintptr_t)c, cmd->result_cbrefp->ref, lua_tostring(L, -2)); } else { lua_pushstring(L, errno_to_str(error)); - trace(LOG_LUA, "lua_channel_redirect_reply %p %d error %d", c, cmd->result_cbrefp->ref, error); + trace(LOG_LUA, "lua_channel_redirect_reply %#" PRIxPTR " %d error %d", (uintptr_t)c, cmd->result_cbrefp->ref, error); } - if(lua_pcall(L, 1, 0, 0) != 0) { + if (lua_pcall(L, 1, 0, 0) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } luaref_owner_free(L, cmd); } -static int lua_channel_redirect(lua_State *L) -{ +static int lua_channel_redirect(lua_State *L) { struct channel_extra *ce = NULL; struct command_extra *cmd; assert(L == luastate); - if(lua_gettop(L) != 3 || + if (lua_gettop(L) != 3 || (ce = lua2channel(L, 1)) == NULL || !lua_isstring(L, 2) || !lua_isfunction(L, 3)) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); /* Object to track outstanding command */ cmd = (struct command_extra *)lua_newuserdata(L, sizeof *cmd); @@ -1184,25 +1129,22 @@ static int lua_channel_redirect(lua_State *L) cmd->result_cbrefp = luaref_new(L, cmd); /* Send command header */ - cmd->replyinfo = send_redirect_command(ce->c, - lua_tostring(L, 2), - channel_redirect_cb, cmd); - trace(LOG_LUA, "lua_channel_redirect %p %d %s", ce->c, cmd->result_cbrefp->ref, lua_tostring(L, 2)); + cmd->replyinfo = send_redirect_command(ce->c, lua_tostring(L, 2), channel_redirect_cb, cmd); + trace(LOG_LUA, "lua_channel_redirect %#" PRIxPTR " %d %s", (uintptr_t)ce->c, cmd->result_cbrefp->ref, lua_tostring(L, 2)); return 1; } -static int lua_channel_get_services(lua_State *L) -{ +static int lua_channel_get_services(lua_State *L) { struct channel_extra *ce = NULL; int i; assert(L == luastate); - if(lua_gettop(L) != 1 || + if (lua_gettop(L) != 1 || (ce = lua2channel(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(ce->c == NULL) luaL_error(L, "disconnected channel"); - trace(LOG_LUA, "lua_channel_get_services %p", ce->c); + if (ce->c == NULL) luaL_error(L, "disconnected channel"); + trace(LOG_LUA, "lua_channel_get_services %#" PRIxPTR "", (uintptr_t)ce->c); lua_newtable(L); for (i = 0; i < ce->c->peer_service_cnt; i++) { lua_pushstring(L, ce->c->peer_service_list[i]); @@ -1229,60 +1171,56 @@ static const luaL_Reg channelfuncs[] = { { 0 } }; -static int lua_peer_tostring(lua_State *L) -{ +static int lua_peer_tostring(lua_State *L) { struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_peer_tostring %p", pse->ps); - lua_pushfstring(L, "tcf_peer (%s, %p)", pse->ps ? pse->ps->id : "<stale>", pse); + trace(LOG_LUA, "lua_peer_tostring %#" PRIxPTR, (uintptr_t)pse->ps); + lua_pushfstring(L, "tcf_peer (%s, %#" PRIxPTR ")", pse->ps ? pse->ps->id : "<stale>", (uintptr_t)pse); return 1; } -static int lua_peer_gc(lua_State *L) -{ +static int lua_peer_gc(lua_State *L) { struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->managed == 0) { - trace(LOG_LUA, "lua_peer_gc %p", pse->ps); + if (pse->managed == 0) { + trace(LOG_LUA, "lua_peer_gc %#" PRIxPTR, (uintptr_t)pse->ps); peer_server_free(pse->ps); pse->ps = NULL; } return 0; } -static int lua_peer_getid(lua_State *L) -{ +static int lua_peer_getid(lua_State *L) { struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->ps == NULL) luaL_error(L, "stale peer"); - trace(LOG_LUA, "lua_peer_getid %p", pse->ps); + if (pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_peer_getid %#" PRIxPTR, (uintptr_t)pse->ps); lua_pushstring(L, pse->ps->id); return 1; } -static int lua_peer_getnames(lua_State *L) -{ +static int lua_peer_getnames(lua_State *L) { unsigned i; struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->ps == NULL) luaL_error(L, "stale peer"); - trace(LOG_LUA, "lua_peer_getnames %p", pse->ps); + if (pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_peer_getnames %#" PRIxPTR, (uintptr_t)pse->ps); lua_createtable(L, pse->ps->ind, 0); for(i = 0; i < pse->ps->ind; i++) { lua_pushstring(L, pse->ps->list[i].name); @@ -1291,20 +1229,19 @@ static int lua_peer_getnames(lua_State *L) return 1; } -static int lua_peer_getvalue(lua_State *L) -{ +static int lua_peer_getvalue(lua_State *L) { struct peer_extra *pse = NULL; const char *s; assert(L == luastate); - if(lua_gettop(L) != 2 || + if (lua_gettop(L) != 2 || (pse = lua2peer(L, 1)) == NULL || !lua_isstring(L, 2)) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->ps == NULL) luaL_error(L, "stale peer"); - trace(LOG_LUA, "lua_peer_getvalue %p", pse->ps); - if((s = peer_server_getprop(pse->ps, lua_tostring(L, 2), NULL)) == NULL) { + if (pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_peer_getvalue %#" PRIxPTR, (uintptr_t)pse->ps); + if ((s = peer_server_getprop(pse->ps, lua_tostring(L, 2), NULL)) == NULL) { lua_pushnil(L); return 1; } @@ -1312,43 +1249,41 @@ static int lua_peer_getvalue(lua_State *L) return 1; } -static int lua_peer_setvalue(lua_State *L) -{ +static int lua_peer_setvalue(lua_State *L) { struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 3 || (pse = lua2peer(L, 1)) == NULL || + if (lua_gettop(L) != 3 || (pse = lua2peer(L, 1)) == NULL || !lua_isstring(L, 2) || !lua_isstring(L, 3)) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->ps == NULL) luaL_error(L, "stale peer"); - trace(LOG_LUA, "lua_peer_setvalue %p", pse->ps); + if (pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_peer_setvalue %#" PRIxPTR, (uintptr_t)pse->ps); peer_server_addprop(pse->ps, loc_strdup(lua_tostring(L, 2)), loc_strdup(lua_tostring(L, 3))); return 0; } -static int lua_peer_getflags(lua_State *L) -{ +static int lua_peer_getflags(lua_State *L) { struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (pse = lua2peer(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->ps == NULL) luaL_error(L, "stale peer"); - trace(LOG_LUA, "lua_peer_getflags %p", pse->ps); + if (pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_peer_getflags %#" PRIxPTR, (uintptr_t)pse->ps); lua_createtable(L, 0, 0); - if(pse->ps->flags & PS_FLAG_LOCAL) { + if (pse->ps->flags & PS_FLAG_LOCAL) { lua_pushstring(L, "local"); lua_pushboolean(L, 1); lua_rawset(L, -3); } - if(pse->ps->flags & PS_FLAG_PRIVATE) { + if (pse->ps->flags & PS_FLAG_PRIVATE) { lua_pushstring(L, "private"); lua_pushboolean(L, 1); lua_rawset(L, -3); } - if(pse->ps->flags & PS_FLAG_DISCOVERABLE) { + if (pse->ps->flags & PS_FLAG_DISCOVERABLE) { lua_pushstring(L, "discoverable"); lua_pushboolean(L, 1); lua_rawset(L, -3); @@ -1356,38 +1291,37 @@ static int lua_peer_getflags(lua_State *L) return 1; } -static int lua_peer_setflags(lua_State *L) -{ +static int lua_peer_setflags(lua_State *L) { struct peer_extra *pse = NULL; assert(L == luastate); - if(lua_gettop(L) != 2 || (pse = lua2peer(L, 1)) == NULL || + if (lua_gettop(L) != 2 || (pse = lua2peer(L, 1)) == NULL || !lua_istable(L, 2)) { luaL_error(L, "wrong number or type of arguments"); } - if(pse->ps == NULL) luaL_error(L, "stale peer"); - trace(LOG_LUA, "lua_peer_setflags %p", pse->ps); + if (pse->ps == NULL) luaL_error(L, "stale peer"); + trace(LOG_LUA, "lua_peer_setflags %#" PRIxPTR, (uintptr_t)pse->ps); lua_pushnil(L); - while(lua_next(L, 2) != 0) { - if(lua_isstring(L, -2)) { - if(strcmp(lua_tostring(L, -2), "local") == 0) { - if(lua_toboolean(L, 2)) { + while (lua_next(L, 2) != 0) { + if (lua_isstring(L, -2)) { + if (strcmp(lua_tostring(L, -2), "local") == 0) { + if (lua_toboolean(L, 2)) { pse->ps->flags |= PS_FLAG_LOCAL; } else { pse->ps->flags &= ~PS_FLAG_LOCAL; } } - else if(strcmp(lua_tostring(L, -2), "private") == 0) { - if(lua_toboolean(L, 2)) { + else if (strcmp(lua_tostring(L, -2), "private") == 0) { + if (lua_toboolean(L, 2)) { pse->ps->flags |= PS_FLAG_PRIVATE; } else { pse->ps->flags &= ~PS_FLAG_PRIVATE; } } - else if(strcmp(lua_tostring(L, -2), "discoverable") == 0) { - if(lua_toboolean(L, 2)) { + else if (strcmp(lua_tostring(L, -2), "discoverable") == 0) { + if (lua_toboolean(L, 2)) { pse->ps->flags |= PS_FLAG_DISCOVERABLE; } else { @@ -1413,28 +1347,26 @@ static const luaL_Reg peerfuncs[] = { { 0 } }; -static int lua_post_event_tostring(lua_State *L) -{ +static int lua_post_event_tostring(lua_State *L) { struct post_event_extra *p = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (p = lua2postevent(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (p = lua2postevent(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_post_event_tostring %p", p); - lua_pushfstring(L, "tcf_post_event (%s, %p)", p->handler_refp ? "pending" : "stale", p); + trace(LOG_LUA, "lua_post_event_tostring %#" PRIxPTR, (uintptr_t)p); + lua_pushfstring(L, "tcf_post_event (%s, %#" PRIxPTR ")", p->handler_refp ? "pending" : "stale", (uintptr_t)p); return 1; } -static int lua_post_event_cancel(lua_State *L) -{ +static int lua_post_event_cancel(lua_State *L) { struct post_event_extra *p = NULL; assert(L == luastate); - if(lua_gettop(L) != 1 || (p = lua2postevent(L, 1)) == NULL) { + if (lua_gettop(L) != 1 || (p = lua2postevent(L, 1)) == NULL) { luaL_error(L, "wrong number or type of arguments"); } - trace(LOG_LUA, "lua_post_event_cancel %p", p); + trace(LOG_LUA, "lua_post_event_cancel %#" PRIxPTR, (uintptr_t)p); p->self_refp = NULL; p->handler_refp = NULL; luaref_owner_free(L, p); @@ -1551,7 +1483,7 @@ int main(int argc, char ** argv) { #endif if (script_name != NULL) { - if((lua_read_command_state.req.u.fio.fd = open(script_name, O_RDONLY, 0)) < 0) { + if ((lua_read_command_state.req.u.fio.fd = open(script_name, O_RDONLY, 0)) < 0) { fprintf(stderr, "%s: error: cannot open script: %s\n", progname, script_name); exit(1); } @@ -1562,7 +1494,7 @@ int main(int argc, char ** argv) { discovery_start(); - if((luastate = L = luaL_newstate()) == NULL) { + if ((luastate = L = luaL_newstate()) == NULL) { fprintf(stderr, "error from luaL_newstate\n"); exit(1); } @@ -1615,12 +1547,12 @@ int main(int argc, char ** argv) { peers_refp = luaref_new(L, NULL); peer_server_add_listener(peer_server_changes, L); - if((error = luaL_loadfile(L, engine_name)) != 0) { + if ((error = luaL_loadfile(L, engine_name)) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } - if((error = lua_pcall(L, 0, LUA_MULTRET, 0)) != 0) { + if ((error = lua_pcall(L, 0, LUA_MULTRET, 0)) != 0) { fprintf(stderr, "%s\n", lua_tostring(L,1)); exit(1); } diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c index b5700834..8c384777 100644 --- a/agent/tcf/services/breakpoints.c +++ b/agent/tcf/services/breakpoints.c @@ -3031,7 +3031,7 @@ static void safe_restore_breakpoint(void * arg) { safe_skip_breakpoint(arg); return; } - trace(LOG_ALWAYS, "Skip breakpoint error: wrong PC %#lx", pc); + trace(LOG_ALWAYS, "Skip breakpoint error: wrong PC %#" PRIx64, pc); } } ext->stepping_over_bp = NULL; diff --git a/agent/tcf/services/discovery_udp.c b/agent/tcf/services/discovery_udp.c index 17acd761..072ed6e8 100644 --- a/agent/tcf/services/discovery_udp.c +++ b/agent/tcf/services/discovery_udp.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -857,7 +857,7 @@ static void udp_server_recv(void * x) { } static void local_peer_changed(PeerServer * ps, int type, void * arg) { - trace(LOG_DISCOVERY, "Peer changed: ps=0x%x, type=%d", ps, type); + trace(LOG_DISCOVERY, "Peer changed: ps=%#" PRIxPTR ", type=%d", (uintptr_t)ps, type); switch (type) { case PS_EVENT_ADDED: case PS_EVENT_CHANGED: diff --git a/agent/tcf/services/dwarfframe.c b/agent/tcf/services/dwarfframe.c index 34c76f6b..f3c1d15c 100644 --- a/agent/tcf/services/dwarfframe.c +++ b/agent/tcf/services/dwarfframe.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014-2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -1026,8 +1026,8 @@ static void read_frame_cie(U8_T fde_pos, U8_T pos) { rules.cie_pos = pos; if (pos >= rules.section->size) { str_fmt_exception(ERR_INV_DWARF, - "Invalid CIE pointer 0x%" PRIX64 - " in FDE at 0x%" PRIX64, pos, fde_pos); + "Invalid CIE pointer %#" PRIx64 + " in FDE at %#" PRIx64, pos, fde_pos); } dio_SetPos(pos); cie_length = dio_ReadU4(); @@ -1218,8 +1218,8 @@ static void create_search_index(DWARFCache * cache, FrameInfoIndex * index) { } else { str_fmt_exception(ERR_INV_DWARF, - "Invalid length 0x%" PRIX64 - " in FDE at 0x%" PRIX64, fde_length, fde_pos); + "Invalid length %#" PRIx64 + " in FDE at %#" PRIx64, fde_length, fde_pos); } } cie_ref = fde_dwarf64 ? dio_ReadU8() : dio_ReadU4(); diff --git a/agent/tcf/services/expressions.c b/agent/tcf/services/expressions.c index b8b85384..597b6826 100644 --- a/agent/tcf/services/expressions.c +++ b/agent/tcf/services/expressions.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -2861,7 +2861,7 @@ static void op_funccall(int mode, Value * v) { /* Create breakpoint at the function return address */ assert(state->bp == NULL); - snprintf(ret_addr, sizeof(ret_addr), "0x%" PRIX64, state->ret_addr); + snprintf(ret_addr, sizeof(ret_addr), "%#" PRIx64, state->ret_addr); state->bp = create_eventpoint(ret_addr, state->ctx, funcccall_breakpoint, state); /* Set PC to the function address */ diff --git a/agent/tcf/services/filesystem.c b/agent/tcf/services/filesystem.c index 8093bac7..60734ea3 100644 --- a/agent/tcf/services/filesystem.c +++ b/agent/tcf/services/filesystem.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -217,7 +217,7 @@ static void channel_close_listener(Channel * c) { OpenFileInfo * h = ring2file(list_next); if (h->inp == &c->inp) { int posted = 0; - trace(LOG_ALWAYS, "file handle left open by client: FS%d", h->handle); + trace(LOG_ALWAYS, "file handle left open by client: FS%lu", h->handle); list_remove(&h->link_hash); while (!list_is_empty(&h->link_reqs)) { LINK * link = h->link_reqs.next; diff --git a/agent/tcf/services/linenumbers_proxy.c b/agent/tcf/services/linenumbers_proxy.c index c2115de4..bdc8867e 100644 --- a/agent/tcf/services/linenumbers_proxy.c +++ b/agent/tcf/services/linenumbers_proxy.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. + * Copyright (c) 2011, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -311,7 +311,7 @@ int address_to_line(Context * ctx, ContextAddress addr0, ContextAddress addr1, L } else if (entry->error != NULL) { exception(set_fmt_errno(set_error_report_errno(entry->error), - "Text position not found for address 0x%" PRIX64"..0x%" PRIX64, (uint64_t)addr0, (uint64_t)addr1)); + "Text position not found for address %#" PRIx64 "..%#" PRIx64, (uint64_t)addr0, (uint64_t)addr1)); } else { unsigned i; diff --git a/agent/tcf/services/runctrl.c b/agent/tcf/services/runctrl.c index 72402c7e..047b8be6 100644 --- a/agent/tcf/services/runctrl.c +++ b/agent/tcf/services/runctrl.c @@ -1565,7 +1565,7 @@ static BreakpointInfo * create_step_machine_breakpoint(ContextAddress addr, Cont json_write_boolean(out, 1); break; case 1: - snprintf(str, sizeof(str), "0x%" PRIX64, (uint64_t)addr); + snprintf(str, sizeof(str), "%#" PRIx64, (uint64_t)addr); json_write_string(out, str); break; case 2: diff --git a/agent/tcf/services/stacktrace.c b/agent/tcf/services/stacktrace.c index 1093d550..229dd243 100644 --- a/agent/tcf/services/stacktrace.c +++ b/agent/tcf/services/stacktrace.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -272,7 +272,7 @@ static void trace_stack(Context * ctx, StackTrace * stack, int max_frames) { for (def = get_reg_definitions(ctx); def->name != NULL; def++) { if (def->no_read || def->read_once || def->bits) continue; if (read_reg_value(frame, def, &v) != 0) continue; - trace(LOG_STACK, " %-8s %16" PRIX64, def->name, v); + trace(LOG_STACK, " %-8s %16" PRIx64, def->name, v); } } #endif @@ -295,7 +295,7 @@ static void trace_stack(Context * ctx, StackTrace * stack, int max_frames) { } } assert(down.area == NULL); - trace(LOG_STACK, " cfa %16" PRIX64, (uint64_t)frame->fp); + trace(LOG_STACK, " cfa %16" PRIx64, (uint64_t)frame->fp); if (!down.has_reg_data) { stack->complete = 1; free_frame(&down); diff --git a/agent/tcf/services/symbols_win32.c b/agent/tcf/services/symbols_win32.c index 8a4f8858..585b060b 100644 --- a/agent/tcf/services/symbols_win32.c +++ b/agent/tcf/services/symbols_win32.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -297,11 +297,11 @@ const char * symbol2id(const Symbol * sym) { assert(sym->ctx == sym->base->ctx); assert(sym->sym_class == SYM_CLASS_TYPE); strlcpy(base, symbol2id(sym->base), sizeof(base)); - snprintf(buf, sizeof(buf), "@P%" PRIX64 ".%s", (uint64_t)sym->length, base); + snprintf(buf, sizeof(buf), "@P%" PRIx64 ".%s", (uint64_t)sym->length, base); } else { int i = sym->info ? (int)(sym->info - basic_type_info) + 1 : 0; - snprintf(buf, sizeof(buf), "@S%" PRIX64 ".%lX.%X.%X.%s", + snprintf(buf, sizeof(buf), "@S%" PRIx64 ".%lX.%X.%X.%s", (uint64_t)sym->module, sym->index, sym->frame, i, sym->ctx->id); } return buf; diff --git a/agent/tcf/services/tcf_elf.c b/agent/tcf/services/tcf_elf.c index 7517eb69..cd82bcbd 100644 --- a/agent/tcf/services/tcf_elf.c +++ b/agent/tcf/services/tcf_elf.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -1022,7 +1022,7 @@ int elf_load(ELF_Section * s) { } else { s->data = (char *)s->mmap_addr + (size_t)(s->offset - offs); - trace(LOG_ELF, "Section %s in ELF file %s is mapped to %#lx", s->name, s->file->name, s->data); + trace(LOG_ELF, "Section %s in ELF file %s is mapped to %#" PRIxPTR, s->name, s->file->name, (uintptr_t)s->data); } } } @@ -1039,7 +1039,7 @@ int elf_load(ELF_Section * s) { } else { s->data = (char *)s->mmap_addr + (size_t)(s->offset - offs); - trace(LOG_ELF, "Section %s in ELF file %s is mapped to %#lx", s->name, s->file->name, s->data); + trace(LOG_ELF, "Section %s in ELF file %s is mapped to %#" PRIxPTR, s->name, s->file->name, (uintptr_t)s->data); } } #endif |