NAME=ps+ libc++ 32bit
FILE=bins/elf/stdstring32-libc++.LOAD1
ARGS=-n -m 0x08049ee8
CMDS=<<EOF
on bins/elf/stdstring32-libc++.heap 0x09eb8000 > /dev/null
f obj.empty_str 12 @ 0x0804a064
f obj.long_str1 12 @ 0x0804a04c
f obj.short_str1 12 @ 0x0804a034
f obj.long_str2 12 @ 0x0804a058
f obj.short_str2 12 @ 0x0804a040
e asm.bits=32
e str.search.encoding=utf8
ps+ @ obj.short_str1
ps+ @ obj.short_str2
ps+ @ obj.empty_str
ps+ @ obj.long_str1
ps+ @ obj.long_str2
EOF
EXPECT=<<EOF
a
abcdefghij

abcdefghijk
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
EOF
RUN

NAME=ps+ libc++ 64bit
FILE=bins/elf/stdstring64-libc++.LOAD1
ARGS=-n -m 0x00600dc8
CMDS=<<EOF
on bins/elf/stdstring64-libc++.heap 0x0128b000 > /dev/null
f obj.empty_str 24 @ 0x006010b8
f obj.long_str1 24 @ 0x00601088
f obj.short_str1 24 @ 0x00601058
f obj.long_str2 24 @ 0x006010a0
f obj.short_str2 24 @ 0x00601070
e asm.bits=64
e str.search.encoding=utf8
ps+ @ obj.short_str1
ps+ @ obj.short_str2
ps+ @ obj.empty_str
ps+ @ obj.long_str1
ps+ @ obj.long_str2
EOF
EXPECT=<<EOF
a
abcdefghijklmnopqrstuv

abcdefghijklmnopqrstuvw
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
EOF
RUN

NAME=psn escapes newlines (#10037)
FILE==
CMDS=<<EOF
wz abc\n123\n
psn @! 9
EOF
EXPECT=<<EOF
abc\x0a123\x0a\x00
EOF
RUN

NAME=ps N and initial nulls (#10037)
FILE==
CMDS=<<EOF
ps block @! 1
ps block @! 2
ps block @! 3
ps block @! 4
ps block @! 8
EOF
EXPECT=<<EOF
\x00
\x00\x00
\x00\x00\x00
\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00
EOF
RUN

NAME=ps+ libc++ 16bit error
FILE==
CMDS=<<EOF
e asm.arch=x86
e asm.bits=16
f obj.empty_str 12 @ 0x0804a064
ps+ @ obj.empty_str
EOF
EXPECT_ERR=<<EOF
ERROR: core: 16 bits are not supported by ps+
EOF
RUN

NAME=psc define C C++ string
FILE==
CMDS=<<EOF
wx 90919241424322
psc @! 7
EOF
EXPECT=<<EOF
#define STRING_SIZE 7
const char s[STRING_SIZE] = "\x90\x91\x92\x41\x42\x43\x22";
EOF
RUN

NAME=psc define C C++ multiline string
FILE==
CMDS=<<EOF
wx 909192414243229091924142432290919241424322
psc @! 21
EOF
EXPECT=<<EOF
#define STRING_SIZE 21
const char s[STRING_SIZE] = "\x90\x91\x92\x41\x42\x43\x22\x90\x91\x92\x41\x42\x43\x22\x90\x91"
                            "\x92\x41\x42\x43\x22";
EOF
RUN

NAME=ps ascii detection with block/zero-terminated
FILE==
CMDS=<<EOF
o malloc://512
wx 4a757374206c696b652070696e656170 ; sd +16
wx 706c65206f6e2070697a7a612c207468 ; sd +16
wx 6973207461736b2f7468726561642070 ; sd +16
wx 6f727420646f65736e27742062656c6f ; sd +16
wx 6e6720686572652e204025733a256400 ; sd +16
wx 636f6d2e6170706c652e707269766174 ; sd +16
wx 652e7461736b5f706f6c696379007374 ; sd +16
wx 72616e6765207461736b20666c61766f ; sd +16
wx 72204025733a25640075736572737061 ; sd +16
wx 63652068617320636f6e74726f6c2061 ; sd +16
wx 636365737320746f2061206b65726e65 ; sd +16
wx 6c206d6170202570207468726f756768 ; sd +16
wx 207461736b202570204025733a256400 ; sd +16
wx 737472616e6765207468726561642066 ; sd +16
wx 6c61766f72204025733a256400736861 ; sd +16
wx 7265642e00646174612e007368617265 ; sd -256

ps block
echo \n
ps null
EOF
EXPECT=<<EOF
Just like pineapple on pizza, this task/thread port doesn't belong here. @%s:%d\x00com.apple.private.task_policy\x00strange task flavor @%s:%d\x00userspace has control access to a kernel map %p through task %p @%s:%d\x00strange thread flavor @%s:%d\x00shared.\x00data.\x00share


Just like pineapple on pizza, this task/thread port doesn't belong here. @%s:%d
EOF
RUN
