static void read_getcapabilities_struct(InputStream * inp, const char * name,
        void * x) {
    PortConnection * conn = (PortConnection *) x;

    if (strcmp(name, "AutoConnect") == 0) conn->auto_connect_stream =
            json_read_boolean(inp);
    else json_skip_object(inp);
}
static void read_getconfig_struct(InputStream * inp, const char * name,
        void * x) {
    PortConnection * conn = (PortConnection *) x;

    if (strcmp(name, "InputStream") == 0) conn->in_stream_id =
            json_read_alloc_string(inp);
    else if (strcmp(name, "OutputStream") == 0) conn->out_stream_id =
            json_read_alloc_string(inp);
    else json_skip_object(inp);
}
Example #3
0
static void read_location_element(InputStream * inp, void * args) {
    Location * loc = (Location *)args;
    switch (loc_pos) {
    case 0:
        json_read_string(inp, loc->id, sizeof(loc->id));
        break;
    case 1:
        loc->offs = json_read_ulong(inp);
        break;
    case 2:
        loc->size = json_read_ulong(inp);
        break;
    default:
        json_skip_object(inp);
        break;
    }
    loc_pos++;
}
Example #4
0
static void read_disassembly_params(InputStream * inp, const char * name, void * x) {
    DisassembleCmdArgs * args = (DisassembleCmdArgs *) x;

    if (strcmp(name, "ISA") == 0) {
        args->isa = json_read_alloc_string(inp);
    }
    else if (strcmp(name, "Simplified") == 0) {
        args->simplified = json_read_boolean(inp);
    }
    else if (strcmp(name, "Pseudo") == 0) {
        args->pseudo_instr = json_read_boolean(inp);
    }
    else if (strcmp(name, "OpcodeValue") == 0) {
        args->opcode_value =json_read_boolean(inp);
    }
    else {
        json_skip_object(inp);
    }
}
Example #5
0
static void safe_memory_fill(void * parm) {
    MemoryCommandArgs * args = (MemoryCommandArgs *)parm;
    Channel * c = args->c;
    Context * ctx = args->ctx;

    if (!is_channel_closed(c)) {
        Trap trap;
        if (set_trap(&trap)) {
            InputStream * inp = &c->inp;
            OutputStream * out = &c->out;
            char * token = args->token;
            ContextAddress addr0 = args->addr;
            ContextAddress addr = args->addr;
            unsigned long size = args->size;
            MemoryErrorInfo err_info;
            MemoryFillBuffer buf;
            char * tmp = NULL;
            int err = 0;

            memset(&err_info, 0, sizeof(err_info));
            if (ctx->exiting || ctx->exited) err = ERR_ALREADY_EXITED;

            memset(&buf, 0, sizeof(buf));
            buf.buf = (char *)tmp_alloc(buf.max = BUF_SIZE);

            if (err) json_skip_object(inp);
            else json_read_array(inp, read_memory_fill_array_cb, &buf);
            json_test_char(inp, MARKER_EOA);
            json_test_char(inp, MARKER_EOM);

            while (err == 0 && buf.pos < size && buf.pos <= buf.max / 2) {
                if (buf.pos == 0) {
                    buf.buf[buf.pos++] = 0;
                }
                else {
                    memcpy(buf.buf + buf.pos, buf.buf, buf.pos);
                    buf.pos *= 2;
                }
            }

            while (err == 0 && addr < addr0 + size) {
                /* Note: context_write_mem() modifies buffer contents */
                unsigned wr = (unsigned)(addr0 + size - addr);
                if (tmp == NULL) tmp = (char *)tmp_alloc(buf.pos);
                if (wr > buf.pos) wr = buf.pos;
                /* TODO: word size, mode */
                memcpy(tmp, buf.buf, wr);
                if (context_write_mem(ctx, addr, tmp, wr) < 0) {
                    err = errno;
#if ENABLE_ExtendedMemoryErrorReports
                    context_get_mem_error_info(&err_info);
#endif
                }
                else {
                    addr += wr;
                }
            }

            send_event_memory_changed(ctx, addr0, size);

            write_stringz(out, "R");
            write_stringz(out, token);
            write_errno(out, err);
            if (err == 0) {
                write_stringz(out, "null");
            }
            else {
                write_ranges(out, addr0, (int)(addr - addr0), BYTE_CANNOT_WRITE, &err_info);
            }
            write_stream(out, MARKER_EOM);
            clear_trap(&trap);
        }
        else {
            trace(LOG_ALWAYS, "Exception in Memory.fill: %s", errno_to_str(trap.error));
            channel_close(c);
        }
    }
    channel_unlock(c);
    context_unlock(ctx);
    loc_free(args);
}
static void resume_params_callback(InputStream * inp, char * name, void * args) {
    int * err = (int *)args;
    /* Current agent implementation does not support resume parameters */
    loc_free(json_skip_object(inp));
    *err = ERR_UNSUPPORTED;
}
Example #7
0
static void read_filter_attrs(InputStream * inp, const char * nm, void * arg) {
    json_skip_object(inp);
}
Example #8
0
static void read_getcapabilities_struct(InputStream * inp, const char * name,
        void * x) {
    json_skip_object(inp);
}