14 #define MAX_TRAN_TRIES 3
15 #define HOST_QNX_PROTOVER_MAJOR 0
16 #define HOST_QNX_PROTOVER_MINOR 3
124 g->architecture = architecture;
125 switch (architecture) {
133 eprintf(
"Error unknown architecture set\n");
150 if (!
g || !host ||
g->connected)
160 memmove(
g->host, host, strlen(host) + 1);
178 eprintf(
"%s: connection failed: %lld\n", __func__,
190 g->target_proto_major = 0;
191 g->target_proto_minor = 0;
198 eprintf(
"Connection failed (Protocol Version Query): %lld\n",
212 nto_send(
g,
sizeof(
g->tran.pkt.disconnect), 0);
225 if (
g->inferior_ptid.pid !=
pid) {
232 g->tran.pkt.attach.pid =
pid;
237 eprintf(
"%s: failed to attach to %d\n", __func__,
pid);
245 return g->inferior_ptid;
261 for (envc = 0; *
env;
env++, envc++)
265 eprintf(
"%s: error(s) occurred while sending environment\n", __func__);
277 eprintf(
"%s: failed to send executable file name\n", __func__);
286 eprintf(
"%s: error(s) occurred while sending args\n", __func__);
295 p =
g->tran.pkt.load.cmdline;
297 g->tran.pkt.load.envc = 0;
298 g->tran.pkt.load.argc = 0;
301 strncpy(
p,
file,
sizeof(
g->tran.pkt.load.cmdline) - 8);
314 eprintf(
"%s: inferior pid: %d\n", __func__, ptid.
pid);
315 g->inferior_ptid = ptid;
325 int len, rlen, regset;
333 while (
g->registers[
i].size > 0) {
337 eprintf(
"%s: unknown register %d\n", __func__,
i);
338 len =
g->registers[
i].size;
343 rlen =
nto_send(
g,
sizeof(
g->tran.pkt.regrd), 1);
348 g->recv.pkt.okdata.data,
len);
355 eprintf(
"%s: couldn't read register %d\n", __func__,
i);
366 int rcv_len, tot_len, ask_len;
372 tot_len = ask_len = 0;
376 addr = address + tot_len;
381 rcv_len =
nto_send(
g,
sizeof(
g->tran.pkt.memrd), 0) -
382 sizeof(
g->recv.pkt.hdr);
386 memcpy(data + tot_len,
g->recv.pkt.okdata.data, rcv_len);
390 }
while (tot_len !=
len);
407 switch (
g->recv.pkt.hdr.cmd) {
418 struct dspidlist *pidlist = (
void *)
g->recv.pkt.okdata.data;
453 g->tran.pkt.select.pid =
pid;
459 eprintf(
"%s: failed to select %d\n", __func__,
pid);
475 int tdep_len, regset;
483 if (
len < 0 || tdep_len !=
len) {
484 eprintf(
"%s: invalid length\n", __func__);
502 while (
g->registers[
i].size > 0) {
503 if (!strcmp(
g->registers[
i].name,
name)) {
508 if (
g->registers[
i].size == 0) {
509 eprintf(
"Error registername <%s> not found in profile\n",
name);
523 g->tran.pkt.run.step.count = 1;
532 eprintf(
"%s: waiting for stop\n", __func__);
533 g->waiting_for_stop = 1;
536 g->send_len =
sizeof(
g->tran.pkt.stop);
546 ptid_t returned_ptid =
g->inferior_ptid;
547 if (
g->inferior_ptid.pid !=
pid) {
552 char waiting_for_notify = 1;
554 eprintf(
"%s: waiting for inferior\n", __func__);
559 if (
g->waiting_for_stop) {
560 eprintf(
"%s: read eror while waiting for stop\n",
564 eprintf(
"%s: read packet error or NAK\n", __func__);
572 if (
g->waiting_for_stop &&
g->recv.pkt.hdr.cmd ==
DSrMsg_ok) {
573 g->waiting_for_stop = 0;
574 eprintf(
"%s: got stop response\n", __func__);
575 if (!waiting_for_notify)
581 g->tran.pkt.hdr.mid =
g->recv.pkt.hdr.mid;
584 g->send_len =
sizeof(
g->tran.pkt.ok);
596 return returned_ptid;
621 g->tran.pkt.brk.size = 0;
635 g->tran.pkt.brk.size = -1;
644 g->tran.pkt.hdr.cmd =
cmd;
645 g->tran.pkt.hdr.subcmd = subcmd;
647 g->tran.pkt.hdr.channel = chan;
658 eprintf(
"%s: parse notify %d\n", __func__,
g->recv.pkt.hdr.subcmd);
660 switch (
g->recv.pkt.hdr.subcmd) {
677 eprintf(
"%s: notify type DSMSG_NOTIFY_PIDLOAD\n", __func__);
684 eprintf(
"%s: notify type DSMSG_NOTIFY_DLLTID\n", __func__);
691 eprintf(
"%s: Unexpected notify type %d\n", __func__,
692 g->recv.pkt.hdr.subcmd);
707 if (
g->target_proto_minor >= 2) {
723 eprintf(
"Protovers < 0.2 do not handle env vars longer than %d\n",
740 eprintf(
"Argument too long: %.40s...\n",
arg);
752 if (!
g ||
g->connected == 0) {
756 for (tries = 0;; tries++) {
758 eprintf(
"%s: Remote exhausted %d retries.\n", __func__, tries);
769 eprintf(
"%s: NAK received - resending\n", __func__);
772 if ((rlen >= 0) && (
g->recv.pkt.hdr.mid ==
g->tran.pkt.hdr.mid))
774 eprintf(
"%s: mid mismatch: %d/%d\n", __func__,
g->recv.pkt.hdr.mid,
775 g->tran.pkt.hdr.mid);
778 switch (
g->channelrd) {
785 switch (
g->recv.pkt.hdr.subcmd) {
787 eprintf(
"remote: error packet with errno %d\n", nerrno);
790 eprintf(
"remote: no ptys available\n");
793 eprintf(
"remote: thread start error\n");
796 eprintf(
"remote: invalid console number\n");
799 eprintf(
"Remote (spawn error)\n");
802 eprintf(
"Remote (procfs [/proc] error)\n");
805 eprintf(
"Remote (devctl PROC_STOP error)\n");
808 eprintf(
"Remote (psinfo error)\n");
811 eprintf(
"Remote (invalid memory model [not flat])\n");
814 eprintf(
"Remote (proxy error)\n");
817 eprintf(
"Remote (__nto_debug_* error)\n");
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
#define SET_CHANNEL_DEBUG
#define SET_CHANNEL_RESET
#define PDEBUG_EQMEMMODEL
#define DSHDR_MSG_BIG_ENDIAN
static states step(struct re_guts *, sopno, sopno, states, int, states)
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define offsetof(type, member)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void() pidlist_cb_t(void *ctx, pid_t pid, char *name)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
static static fork const void static count static fd const char const char static newpath char char argv
static const char * conditions[]
@ RZ_DEBUG_REASON_UNKNOWN
@ RZ_DEBUG_REASON_BREAKPOINT
RZ_API int rz_socket_close(RzSocket *s)
#define rz_socket_connect_tcp(a, b, c, d)
RZ_API RzSocket * rz_socket_new(bool is_ssl)
RZ_API int rz_sys_sleep(int secs)
Sleep for secs seconds.
int qnxr_send_ch_debug(libqnxr_t *instance)
int qnxr_read_packet(libqnxr_t *instance)
Function reads data from the established connection.
int qnxr_send_packet(libqnxr_t *instance)
sends a packet sends a packet to the established connection
int qnxr_send_ch_reset(libqnxr_t *instance)
int host_signal_from_nto(int sig)
int i386nto_regset_id(int regno)
int i386nto_register_area(int regno, int regset, unsigned *off)
#define EXTRACT_UNSIGNED_INTEGER(addr, len)
ptid_t ptid_build(st32 pid, st64 tid)
#define EXTRACT_SIGNED_INTEGER(addr, len)
int qnxr_remove_hwbp(libqnxr_t *g, ut64 address)
int qnxr_set_bp(libqnxr_t *g, ut64 address, const char *conditions)
int qnxr_write_memory(libqnxr_t *g, ut64 address, const ut8 *data, ut64 len)
int qnxr_read_registers(libqnxr_t *g)
int qnxr_select(libqnxr_t *g, pid_t pid, int tid)
#define HOST_QNX_PROTOVER_MINOR
int qnxr_connect(libqnxr_t *g, const char *host, int port)
void nto_send_init(libqnxr_t *g, ut32 cmd, ut32 subcmd, ut32 chan)
int nto_send_env(libqnxr_t *g, const char *env)
int qnxr_remove_bp(libqnxr_t *g, ut64 address)
int qnxr_set_hwbp(libqnxr_t *g, ut64 address, const char *conditions)
int qnxr_continue(libqnxr_t *g, int thread_id)
int qnxr_cleanup(libqnxr_t *g)
static registers_t arm32[]
int qnxr_disconnect(libqnxr_t *g)
ptid_t qnxr_attach(libqnxr_t *g, pid_t pid)
void qnxr_pidlist(libqnxr_t *g, void *ctx, pidlist_cb_t *cb)
static registers_t x86_32[]
ptid_t qnxr_wait(libqnxr_t *g, pid_t pid)
int qnxr_set_architecture(libqnxr_t *g, ut8 architecture)
#define HOST_QNX_PROTOVER_MAJOR
int qnxr_read_memory(libqnxr_t *g, ut64 address, ut8 *data, ut64 len)
ptid_t qnxr_run(libqnxr_t *g, const char *file, char **args, char **env)
int nto_send_arg(libqnxr_t *g, const char *arg)
int qnxr_stop(libqnxr_t *g)
int nto_send(libqnxr_t *g, ut32 len, int report_errors)
int _qnxr_set_bp(libqnxr_t *g, ut64 address, const char *conditions, enum Breakpoint type)
ptid_t nto_parse_notify(libqnxr_t *g)
int qnxr_init(libqnxr_t *g)
int qnxr_write_reg(libqnxr_t *g, const char *name, char *value, int len)
int qnxr_write_register(libqnxr_t *g, int index, char *value, int len)
int qnxr_step(libqnxr_t *g, int thread_id)
int _qnxr_remove_bp(libqnxr_t *g, ut64 address, enum Breakpoint type)
int qnxr_send_vcont(libqnxr_t *g, int step, int thread_id)
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()