mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 23:50:40 +00:00
* Fix eflags parsing for x86-32/64 debugger
- added ?f and ?b commands to parse bits and flags
This commit is contained in:
parent
8ed7004780
commit
89680b63f0
@ -1174,8 +1174,33 @@ static int cmd_seek(void *data, const char *input) {
|
|||||||
|
|
||||||
static int cmd_help(void *data, const char *input) {
|
static int cmd_help(void *data, const char *input) {
|
||||||
RCore *core = (RCore *)data;
|
RCore *core = (RCore *)data;
|
||||||
|
char out[65];
|
||||||
ut64 n;
|
ut64 n;
|
||||||
switch (input[0]) {
|
switch (input[0]) {
|
||||||
|
case 'b':
|
||||||
|
{
|
||||||
|
n = r_num_get (core->num, input+1);
|
||||||
|
r_num_to_bits (out, n);
|
||||||
|
r_cons_printf ("%s\n", out);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
if (input[1]==' ') {
|
||||||
|
char *q, *p = strdup (input+2);
|
||||||
|
if (!p) {
|
||||||
|
eprintf ("Cannot strdup\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
q = strchr (p, ' ');
|
||||||
|
if (q) {
|
||||||
|
*q = 0;
|
||||||
|
n = r_num_get (core->num, p);
|
||||||
|
r_str_bits (out, (const ut8*)&n, sizeof (n), q+1);
|
||||||
|
r_cons_printf ("%s\n", out);
|
||||||
|
} else eprintf ("Usage: \"?b value bitstring\"\n");
|
||||||
|
free (p);
|
||||||
|
} else eprintf ("Whitespace expected after '?b'\n");
|
||||||
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
n = r_num_math (core->num, input+1);
|
n = r_num_math (core->num, input+1);
|
||||||
r_cons_printf ("%"PFMT64d" 0x%"PFMT64x"\n", n,n);
|
r_cons_printf ("%"PFMT64d" 0x%"PFMT64x"\n", n,n);
|
||||||
@ -1225,6 +1250,8 @@ static int cmd_help(void *data, const char *input) {
|
|||||||
" ? eip-0x804800 ; calculate result for this math expr\n"
|
" ? eip-0x804800 ; calculate result for this math expr\n"
|
||||||
" ?= eip-0x804800 ; same as above without user feedback\n"
|
" ?= eip-0x804800 ; same as above without user feedback\n"
|
||||||
" ?? [cmd] ; ? == 0 run command when math matches\n"
|
" ?? [cmd] ; ? == 0 run command when math matches\n"
|
||||||
|
" ?b [num] ; show binary value of number\n"
|
||||||
|
" ?f [num] [str] ; map each bit of the number as flag string index\n"
|
||||||
" ?z str ; returns the length of string (0 if null)\n"
|
" ?z str ; returns the length of string (0 if null)\n"
|
||||||
" ?t cmd ; returns the time to run a command\n"
|
" ?t cmd ; returns the time to run a command\n"
|
||||||
" ?! [cmd] ; ? != 0\n"
|
" ?! [cmd] ; ? != 0\n"
|
||||||
|
@ -316,7 +316,7 @@ static const char *r_debug_native_reg_profile() {
|
|||||||
"gpr ebp .32 172 0\n"
|
"gpr ebp .32 172 0\n"
|
||||||
"gpr eip .32 176 0\n"
|
"gpr eip .32 176 0\n"
|
||||||
"seg cs .32 184 0\n"
|
"seg cs .32 184 0\n"
|
||||||
"flg eflags .32 188 0 cpastidor0\n"
|
"gpr eflags .32 188 0 c1p.a.zstido.n.rv\n" // XXX must be flg
|
||||||
"seg esp .32 192 0\n"
|
"seg esp .32 192 0\n"
|
||||||
"seg ss .32 196 0\n"
|
"seg ss .32 196 0\n"
|
||||||
/* +512 bytes for maximum supoprted extension extended registers */
|
/* +512 bytes for maximum supoprted extension extended registers */
|
||||||
@ -418,7 +418,7 @@ static const char *r_debug_native_reg_profile() {
|
|||||||
"seg xcs .32 52 0\n"
|
"seg xcs .32 52 0\n"
|
||||||
"seg cs .16 52 0\n"
|
"seg cs .16 52 0\n"
|
||||||
"seg xss .32 52 0\n"
|
"seg xss .32 52 0\n"
|
||||||
"gpr eflags .32 56 0 cpazstidoinrvavvi\n"
|
"gpr eflags .32 56 0 c1p.a.zstido.n.rv\n"
|
||||||
"gpr flags .16 56 0\n"
|
"gpr flags .16 56 0\n"
|
||||||
"flg carry .1 .448 0\n"
|
"flg carry .1 .448 0\n"
|
||||||
"flg flag_p .1 .449 0\n"
|
"flg flag_p .1 .449 0\n"
|
||||||
@ -468,7 +468,7 @@ static const char *r_debug_native_reg_profile() {
|
|||||||
"gpr rip .64 128 0\n"
|
"gpr rip .64 128 0\n"
|
||||||
"seg cs .64 136 0\n"
|
"seg cs .64 136 0\n"
|
||||||
//"flg eflags .64 144 0\n"
|
//"flg eflags .64 144 0\n"
|
||||||
"flg eflags .32 144 0 cpastidor0\n"
|
"gpr eflags .32 144 0 c1p.a.zstido.n.rv\n"
|
||||||
"gpr rsp .64 152 0\n"
|
"gpr rsp .64 152 0\n"
|
||||||
"seg ss .64 160 0\n"
|
"seg ss .64 160 0\n"
|
||||||
"seg fs_base .64 168 0\n"
|
"seg fs_base .64 168 0\n"
|
||||||
|
@ -190,7 +190,7 @@ R_API int r_num_to_bits(char *out, ut64 num);
|
|||||||
|
|
||||||
/* strings */
|
/* strings */
|
||||||
#define r_str_write(x,y) write (x, y, strlen(y))
|
#define r_str_write(x,y) write (x, y, strlen(y))
|
||||||
R_API int r_str_bits (char *strout, ut8 *buf, int len, const char *bitz);
|
R_API int r_str_bits (char *strout, const ut8 *buf, int len, const char *bitz);
|
||||||
R_API int r_str_rwx(const char *str);
|
R_API int r_str_rwx(const char *str);
|
||||||
R_API void r_str_subchr (char *s, int a, int b);
|
R_API void r_str_subchr (char *s, int a, int b);
|
||||||
R_API const char *r_str_rwx_i(int rwx);
|
R_API const char *r_str_rwx_i(int rwx);
|
||||||
|
@ -21,11 +21,12 @@ R_API void r_str_subchr (char *s, int a, int b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do not use toupper.. must support modes to also append lowercase chars like in r1
|
// TODO: do not use toupper.. must support modes to also append lowercase chars like in r1
|
||||||
R_API int r_str_bits (char *strout, ut8 *buf, int len, const char *bitz) {
|
R_API int r_str_bits (char *strout, const ut8 *buf, int len, const char *bitz) {
|
||||||
int i, j, *p = (int*)buf;
|
int i, j, *p = (int*)buf;
|
||||||
for (i=j=0; i<len && bitz[i]; i++)
|
for (i=j=0; i<len && bitz[i]; i++) {
|
||||||
if (*p&(1<<(i)))
|
if (*p&(1<<i))
|
||||||
strout[j++] = toupper (bitz[i]);
|
strout[j++] = toupper (bitz[i]);
|
||||||
|
}
|
||||||
strout[j] = 0;
|
strout[j] = 0;
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user