Convert pf d specifier to hex dword ##print (#20276)

Behavior now consistent with byte, word, and quadword specifiers
This commit is contained in:
Lazula 2022-06-10 15:29:53 -05:00 committed by GitHub
parent 07969a94cd
commit 80cc913688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 39 deletions

View File

@ -347,7 +347,7 @@ static const char *help_detail_pf[] = {
" ", "B", "resolve enum bitfield (see t?)",
" ", "c", "char (signed byte)",
" ", "C", "byte in decimal",
" ", "d", "0xHEX value (4 bytes) (see 'i' and 'x')",
" ", "d", "dword (4 bytes in hex) (see 'i' and 'x')",
" ", "D", "disassemble one opcode",
" ", "e", "temporally swap endian",
" ", "E", "resolve enum name (see t?)",

View File

@ -606,7 +606,7 @@ static void r_print_format_hex(const RPrint* p, int endian, int mode, const char
if (MUSTSET) {
p->cb_printf ("wv4 %s @ 0x%08"PFMT64x"\n", setval, seeki+((elem>=0)?elem*4:0));
} else if ((mode & R_PRINT_DOT) || MUSTSEESTRUCT) {
p->cb_printf ("%"PFMT64d, addr);
p->cb_printf ("0x%08"PFMT64x, addr);
} else if (MUSTSEE) {
if (!SEEVALUE && !ISQUIET) {
p->cb_printf ("0x%08" PFMT64x " = ", seeki + ((elem >= 0) ? elem * 4 : 0));
@ -615,7 +615,7 @@ static void r_print_format_hex(const RPrint* p, int endian, int mode, const char
if (addr == UT64_MAX || addr == UT32_MAX) {
p->cb_printf ("-1");
} else {
p->cb_printf ("%"PFMT64d, addr);
p->cb_printf ("0x%08"PFMT64x, addr);
}
} else {
if (!SEEVALUE) {
@ -628,10 +628,10 @@ static void r_print_format_hex(const RPrint* p, int endian, int mode, const char
if (addr == UT64_MAX || addr == UT32_MAX) {
p->cb_printf ("-1");
} else {
p->cb_printf ("%"PFMT64d, addr);
p->cb_printf ("0x%08"PFMT64x, addr);
}
} else {
p->cb_printf ("%"PFMT64d, addr);
p->cb_printf ("0x%08"PFMT64x, addr);
}
if (elem == 0) {
elem = -2;
@ -651,13 +651,13 @@ static void r_print_format_hex(const RPrint* p, int endian, int mode, const char
}
} else if (MUSTSEEJSON) {
if (size == -1) {
p->cb_printf ("%"PFMT64d, addr);
p->cb_printf ("0x%08"PFMT64x, addr);
} else {
p->cb_printf ("[ ");
while (size--) {
updateAddr (buf + i, size - i, endian, &addr, NULL);
if (elem == -1 || elem == 0) {
p->cb_printf ("%"PFMT64d, addr);
p->cb_printf ("0x%08"PFMT64x, addr);
if (elem == 0) {
elem = -2;
}
@ -2559,7 +2559,7 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len,
r_print_format_int (p, endian, mode, setval, seeki, buf, i, size);
i+= (size == -1)? 4: 4 * size;
break;
case 'd': //WHY?? help says: 0x%%08x hexadecimal value (4 bytes)
case 'd':
r_print_format_hex (p, endian, mode, setval, seeki, buf, i, size);
i+= (size == -1)? 4: 4 * size;
break;

View File

@ -79,7 +79,7 @@ RUN
NAME=seteq
FILE=malloc://1024
CMDS=<<EOF
pf.foo xd foo bar
pf.foo xi foo bar
pf.foo
EOF
EXPECT=<<EOF
@ -109,7 +109,7 @@ RUN
NAME=seteq2
FILE=malloc://1024
CMDS=<<EOF
pf.foo=xd foo bar
pf.foo=xi foo bar
pf.foo
EOF
EXPECT=<<EOF

View File

@ -1,7 +1,7 @@
NAME=pf xxd=123
NAME=pf xxi=123
FILE=-
CMDS=<<EOF
pf foo=xxd foo bar cow
pf foo=xxi foo bar cow
pf.foo
pf.foo.foo
.pf.foo.foo=123
@ -20,10 +20,10 @@ EXPECT=<<EOF
EOF
RUN
NAME=pf xxd.cow=123
NAME=pf xxi.cow=123
FILE=-
CMDS=<<EOF
pf foo=[2]xxd foo bar cow
pf foo=[2]xxi foo bar cow
pf.foo.cow
.pf.foo.cow=123
pf.foo.cow

View File

@ -214,12 +214,13 @@ RUN
NAME=mac ls pfc
FILE=bins/mach0/mac-ls
BROKEN=1
CMDS=pfc zdq foo bar cow
EXPECT=<<EOF
struct {
char* foo; // "UH..AWAVAUATSH..H."
int32_t bar; // 4085860352
uint64_t cow; // -450213120875525823
int32_t bar; // 0xf3894800
uint64_t cow; // 0xf9c0858d48fe8941
}
EOF
RUN

View File

@ -36,7 +36,7 @@ EXPECT=<<EOF
0x00000004 4155 push r13
0x00000006 4154 push r12
(int)
0x00000008 = 1442089289
0x00000008 = 0x55f48949
0x0000000c 53 push rbx
0x0000000d 89fd mov ebp, edi
0x0000000f 4881eca80300. sub rsp, 0x3a8
@ -98,7 +98,7 @@ EXPECT=<<EOF
(int)
0x00000000 = -1
(int)
0x00000008 = 0
0x00000008 = 0x00000000
(char *)
0x00000010 = "test"
EOF
@ -448,7 +448,7 @@ wx 13
tp person @ 0x0
EOF
EXPECT=<<EOF
age : 0x00000000 = 19
age : 0x00000000 = 0x00000013
name : 0x00000004 = "Carlos"
EOF
RUN
@ -510,11 +510,11 @@ ts foo
EOF
EXPECT=<<EOF
pf d? x (bar)moo
x : 0x00000000 = 0
x : 0x00000000 = 0x00000000
moo :
struct<bar>
a : 0x00000004 = 0
b : 0x00000008 = 0
a : 0x00000004 = 0x00000000
b : 0x00000008 = 0x00000000
EOF
RUN
@ -528,16 +528,16 @@ ts foo
EOF
EXPECT=<<EOF
pf d[2]? x (bar)moo
x : 0x00000000 = 0
x : 0x00000000 = 0x00000000
moo :
[
struct<bar>
a : 0x00000004 = 0
b : 0x00000008 = 0
a : 0x00000004 = 0x00000000
b : 0x00000008 = 0x00000000
struct<bar>
a : 0x0000000c = 0
b : 0x00000010 = 0
a : 0x0000000c = 0x00000000
b : 0x00000010 = 0x00000000
]
EOF
RUN
@ -622,14 +622,14 @@ b 4
tp foobar
EOF
EXPECT=<<EOF
a : 0x00000000 = 50462976
b : 0x00000004 = 117835012
c : 0x00000008 = 185207048
d : 0x0000000c = 252579084
a : 0x00000000 = 50462976
b : 0x00000004 = 117835012
c : 0x00000008 = 185207048
d : 0x0000000c = 252579084
a : 0x00000000 = 0x03020100
b : 0x00000004 = 0x07060504
c : 0x00000008 = 0x0b0a0908
d : 0x0000000c = 0x0f0e0d0c
a : 0x00000000 = 0x03020100
b : 0x00000004 = 0x07060504
c : 0x00000008 = 0x0b0a0908
d : 0x0000000c = 0x0f0e0d0c
EOF
RUN
@ -661,7 +661,7 @@ tpx foo 41414141441414141414420010000000
EOF
EXPECT=<<EOF
a : 0x00000000 = "AAAAD\x14\x14\x14\x14\x14B"
b : 0x0000000c = 16
b : 0x0000000c = 0x00000010
EOF
RUN
@ -877,7 +877,7 @@ ts foo
EOF
EXPECT=<<EOF
pf dpz x fp b
x : 0x00000000 = 0
x : 0x00000000 = 0x00000000
fp : 0x00000004 = (qword)0x0000000000000000
b : 0x0000000c = "\x05hello"
EOF
@ -1637,8 +1637,8 @@ pd 1
EOF
EXPECT=<<EOF
(foo)
a : 0x00000000 = 4000
b : 0x00000004 = 8000
a : 0x00000000 = 0x00000fa0
b : 0x00000004 = 0x00001f40
c : 0x00000008 = (qword)0x8000000000000008
EOF
RUN