Skip to content

Commit

Permalink
fixup! fixup! Remove the dependency of core->block in pi/pI
Browse files Browse the repository at this point in the history
  • Loading branch information
PeiweiHu committed Dec 20, 2023
1 parent 88fa5d0 commit 090c0da
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 29 deletions.
22 changes: 0 additions & 22 deletions librz/core/cio.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@ RZ_API void rz_core_seek_arch_bits(RzCore *core, ut64 addr) {
}
}

/**
* \brief Read \p size bytes from \p addr of mapped regions into \p buf
* \param core reference to RzCore instance
* \param addr address where to read from
* \param buf buffer where to store the read data
* \param size number of bytes to read
* \return true if all reads on mapped regions are successful and complete, false otherwise
**/
RZ_API bool rz_core_read_at(RzCore *core, ut64 addr, ut8 *buf, int size) {
rz_return_val_if_fail(core && buf && addr != UT64_MAX, false);
if (size < 1) {
return false;
}
// if cached in core->block
if (addr >= core->offset && addr + size <= core->offset + core->blocksize) {
int offset = addr - core->offset;
memcpy(buf, core->block + offset, size);
return true;
}
return rz_io_nread_at(core->io, addr, buf, size) != -1;
}

RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size) {
rz_return_val_if_fail(core && buf && addr != UT64_MAX, false);
if (size < 1) {
Expand Down
2 changes: 1 addition & 1 deletion librz/core/core_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ RZ_IPI void rz_core_flag_range_print(RzFlag *f, RzCmdStateOutput *state, ut64 ra
/* cdisasm.c */
RZ_IPI bool rz_disasm_check_end(int nb_opcodes, int i_opcodes, int nb_bytes, int i_bytes);
RZ_IPI void rz_core_asm_bb_middle(RZ_NONNULL RzCore *core, ut64 at, RZ_INOUT RZ_NONNULL int *oplen, RZ_NONNULL int *ret);
RZ_IPI bool rz_core_handle_backwards_disasm(RZ_NONNULL RzCore *core,
RZ_DEPRECATE RZ_IPI bool rz_core_handle_backwards_disasm(RZ_NONNULL RzCore *core,
RZ_NONNULL RZ_INOUT int *pn_opcodes, RZ_NONNULL RZ_INOUT int *pn_bytes);

/* cprint.c */
Expand Down
2 changes: 1 addition & 1 deletion librz/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5661,7 +5661,7 @@ RZ_API int rz_core_print_disasm_instructions_with_buf(RzCore *core, ut64 address
RZ_LOG_ERROR("Fail to alloc memory.");
return 0;
}
if (!rz_core_read_at(core, address, buf, RZ_ABS(nb_bytes) + 1)) {
if (rz_io_nread_at(core->io, address, buf, RZ_ABS(nb_bytes) + 1) == -1) {
RZ_LOG_ERROR("Fail to read from 0x%" PFMT64x ".", address);
return 0;
}
Expand Down
1 change: 0 additions & 1 deletion librz/include/rz_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ RZ_API bool rz_core_file_bin_raise(RzCore *core, ut32 num);
RZ_API void rz_core_io_file_open(RZ_NONNULL RzCore *core, int fd);
RZ_API void rz_core_io_file_reopen(RZ_NONNULL RzCore *core, int fd, int perms);
RZ_API bool rz_core_extend_at(RzCore *core, ut64 addr, ut64 size);
RZ_API bool rz_core_read_at(RzCore *core, ut64 addr, ut8 *buf, int size);
RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size);
RZ_API bool rz_core_write_value_at(RzCore *core, ut64 addr, ut64 value, int sz);
RZ_API bool rz_core_write_value_inc_at(RzCore *core, ut64 addr, st64 value, int sz);
Expand Down
12 changes: 8 additions & 4 deletions test/db/analysis/tms320.c64x_32
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ b0 = 2 .bitset b0 .. 2
a30 = (word) *+b15[0x4883]
*+b15[0x47c1] = (word) b17
*+b15[0x7fff] = (word) b31
a2 = (half) *+b15[0x0]
a16 = a17 * a29
b0 = b18 + 4
b16 = 2 == b22
a1 = a16 * a15
*-a3[a7] = (word) b1
a10 = 8 ext a0 .. 0
a18 = max(a24, a16)
b20 = (half) *+b14[0x5bc3]
b30 = (word) *-a16[0]
a0 = 0x10 ext a15 .. 0
a2 = 8 ext a29 .. 0x18
Expand Down Expand Up @@ -201,6 +202,9 @@ a16 = (half) *+b14[0x29f0]
a0 = 0 ext a0 .. 0
b30 = b30 * b17
a16 = 2 .bitset a2 .. 2
a0 = 0x10 .bitset a28 .. 0x10
b3 = b15 * b16
a7:a6 = a5 * a18
EOF
RUN

Expand Down
3 changes: 3 additions & 0 deletions test/db/cmd/cmd_open
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,16 @@ pi 2
oml
omb 1 0x3000
oml
pi 2
pi 2 @ 0x3000
EOF
EXPECT=<<EOF
nop
nop
1 fd: 3 +0x00000000 0x00000000 * 0x000001ff rwx
1 fd: 3 +0x00000000 0x00003000 - 0x000031ff rwx
invalid
invalid
nop
nop
EOF
Expand Down

0 comments on commit 090c0da

Please sign in to comment.