NAME=ELF: core segments
FILE=bins/elf/analysis/core.1159
CMDS=iSS~?
EXPECT=<<EOF
20
EOF
RUN

NAME=ELF: core sections with reg name
FILE=bins/elf/analysis/core.1159
BROKEN=1
CMDS=iS~?reg;iS
EXPECT=<<EOF
6
EOF
RUN

NAME=core registers
FILE=bins/elf/analysis/core.1159
CMDS=ar
EXPECT=<<EOF
rax = 0x0000000000000000
rbx = 0x0000000000000000
rcx = 0x0000000000000000
rdx = 0x00007ffe70e05a58
rsi = 0x00007ffe70e05a48
rdi = 0x0000000000000001
r8 = 0x00007f594881de10
r9 = 0x00007f5948831660
r10 = 0x000000000000083e
r11 = 0x00007f594849d590
r12 = 0x00000000004003c0
r13 = 0x00007ffe70e05a40
r14 = 0x0000000000000000
r15 = 0x0000000000000000
rip = 0x00000000004004c6
rbp = 0x00007ffe70e05950
rflags = 0x0000000000010246
rsp = 0x00007ffe70e05950
EOF
RUN

NAME=segment comment
FILE=bins/elf/analysis/core.1159
CMDS=<<EOF
e asm.bytes=true
e asm.cmt.right=true
pd 1 @ 0x7ffe70f68000
echo
e asm.cmt.right=false
pd 1 @ 0x7ffe70f68000
EOF
EXPECT=<<EOF
            ;-- segment.LOAD14:
        ,=< 0x7ffe70f68000      7f45           jg    0x7ffe70f68047    ; [15] -r-x segment size 8192 named LOAD14

            ; [15] -r-x segment size 8192 named LOAD14
            ;-- segment.LOAD14:
        ,=< 0x7ffe70f68000      7f45           jg 0x7ffe70f68047
EOF
RUN

NAME=core maps linux x86
FILE=bins/elf/core/core-linux-x86
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00001000 0x56621000 - 0x56621fff r-- fmap./home/florian/dev/crash/crash-linux-x86
 2 fd: 4 +0x00000000 0x56622000 - 0x56622fff r-x mmap./home/florian/dev/crash/crash-linux-x86
 3 fd: 5 +0x00000000 0x56623000 - 0x56623fff r-- mmap./home/florian/dev/crash/crash-linux-x86
 4 fd: 3 +0x00002000 0x56624000 - 0x56624fff r-- fmap./home/florian/dev/crash/crash-linux-x86
 5 fd: 3 +0x00003000 0x56625000 - 0x56625fff r-- fmap./home/florian/dev/crash/crash-linux-x86
 6 fd: 6 +0x00000000 0xf7d51000 - 0xf7d6cfff r-- mmap./usr/lib32/libc-2.33.so
 7 fd: 3 +0x00004000 0xf7d50000 - 0xf7d50fff r-- fmap./usr/lib32/libc-2.33.so
 8 fd: 7 +0x00000000 0xf7d6d000 - 0xf7ec9fff r-x mmap./usr/lib32/libc-2.33.so
 9 fd: 8 +0x00000000 0xf7eca000 - 0xf7f3bfff r-- mmap./usr/lib32/libc-2.33.so
10 fd: 5 +0x00000000 0xf7f3c000 - 0xf7f3cfff r-- mmap./usr/lib32/libc-2.33.so
11 fd: 3 +0x00005000 0xf7f3d000 - 0xf7f3efff r-- fmap./usr/lib32/libc-2.33.so
12 fd: 3 +0x00007000 0xf7f3f000 - 0xf7f40fff r-- fmap./usr/lib32/libc-2.33.so
13 fd: 3 +0x00009000 0xf7f41000 - 0xf7f49fff r-- fmap.LOAD11
14 fd: 3 +0x00012000 0xf7f97000 - 0xf7f9afff r-- fmap.LOAD12
15 fd: 3 +0x00016000 0xf7f9b000 - 0xf7f9cfff r-x fmap.LOAD13
16 fd: 3 +0x00018000 0xf7f9d000 - 0xf7f9dfff r-- fmap./usr/lib32/ld-2.33.so
17 fd: 9 +0x00000000 0xf7f9e000 - 0xf7fbffff r-x mmap./usr/lib32/ld-2.33.so
18 fd: 10 +0x00000000 0xf7fc0000 - 0xf7fccfff r-- mmap./usr/lib32/ld-2.33.so
19 fd: 3 +0x00019000 0xf7fcd000 - 0xf7fcefff r-- fmap./usr/lib32/ld-2.33.so
20 fd: 3 +0x0001b000 0xf7fcf000 - 0xf7fcffff r-- fmap./usr/lib32/ld-2.33.so
21 fd: 3 +0x0001c000 0xffb6b000 - 0xffb8bfff r-- fmap.[stack]
EOF
RUN

NAME=core regs linux x86
FILE=bins/elf/core/core-linux-x86
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
oeax = 0xffffffff
eax = 0x56625000
ebx = 0x00000000
ecx = 0xffb8a8a0
edx = 0x00000000
esi = 0x00000001
edi = 0x56622060
esp = 0xffb8a870
ebp = 0xffb8a888
eip = 0x566221c3
eflags = 0x00010216
EOF
RUN

NAME=core maps linux x86_64
FILE=bins/elf/core/core-linux-x86_64
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00002000 0x56149dfaf000 - 0x56149dfaffff r-- fmap./home/florian/dev/crash/crash-linux-x86_64
 2 fd: 4 +0x00000000 0x56149dfb0000 - 0x56149dfb0fff r-x mmap./home/florian/dev/crash/crash-linux-x86_64
 3 fd: 5 +0x00000000 0x56149dfb1000 - 0x56149dfb1fff r-- mmap./home/florian/dev/crash/crash-linux-x86_64
 4 fd: 3 +0x00003000 0x56149dfb2000 - 0x56149dfb2fff r-- fmap./home/florian/dev/crash/crash-linux-x86_64
 5 fd: 3 +0x00004000 0x56149dfb3000 - 0x56149dfb3fff r-- fmap./home/florian/dev/crash/crash-linux-x86_64
 6 fd: 3 +0x00005000 0x7f582fa2e000 - 0x7f582fa2ffff r-- fmap.LOAD5
 7 fd: 6 +0x00000000 0x7f582fa31000 - 0x7f582fa55fff r-- mmap./usr/lib/libc-2.33.so
 8 fd: 3 +0x00007000 0x7f582fa30000 - 0x7f582fa30fff r-- fmap./usr/lib/libc-2.33.so
 9 fd: 7 +0x00000000 0x7f582fa56000 - 0x7f582fba1fff r-x mmap./usr/lib/libc-2.33.so
10 fd: 8 +0x00000000 0x7f582fba2000 - 0x7f582fbedfff r-- mmap./usr/lib/libc-2.33.so
11 fd: 3 +0x00008000 0x7f582fbee000 - 0x7f582fbf0fff r-- fmap./usr/lib/libc-2.33.so
12 fd: 3 +0x0000b000 0x7f582fbf1000 - 0x7f582fbf3fff r-- fmap./usr/lib/libc-2.33.so
13 fd: 3 +0x0000e000 0x7f582fbf4000 - 0x7f582fbfefff r-- fmap.LOAD11
14 fd: 3 +0x00019000 0x7f582fc4c000 - 0x7f582fc4cfff r-- fmap./usr/lib/ld-2.33.so
15 fd: 9 +0x00000000 0x7f582fc4d000 - 0x7f582fc70fff r-x mmap./usr/lib/ld-2.33.so
16 fd: 10 +0x00000000 0x7f582fc71000 - 0x7f582fc79fff r-- mmap./usr/lib/ld-2.33.so
17 fd: 3 +0x0001a000 0x7f582fc7b000 - 0x7f582fc7cfff r-- fmap./usr/lib/ld-2.33.so
18 fd: 3 +0x0001c000 0x7f582fc7d000 - 0x7f582fc7efff r-- fmap./usr/lib/ld-2.33.so
19 fd: 3 +0x0001e000 0x7ffc8352d000 - 0x7ffc8354dfff r-- fmap.[stack]
20 fd: 3 +0x0003f000 0x7ffc83558000 - 0x7ffc8355bfff r-- fmap.LOAD18
21 fd: 3 +0x00043000 0x7ffc8355c000 - 0x7ffc8355dfff r-x fmap.LOAD19
22 fd: 3 +0x00045000 0xffffffffff600000 - 0xffffffffff600fff r-x fmap.LOAD20
EOF
RUN

NAME=core regs linux x86_64
FILE=bins/elf/core/core-linux-x86_64
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
rax = 0x0000000000000000
rbx = 0x000056149dfb0170
rcx = 0x00007f582fbf1598
rdx = 0x00007ffc8354c1c8
rsi = 0x00007ffc8354c1b8
rdi = 0x0000000000000001
r8 = 0x0000000000000000
r9 = 0x00007f582fc5c070
r10 = 0x00000000069682ac
r11 = 0x0000000000000202
r12 = 0x000056149dfb0040
r13 = 0x0000000000000000
r14 = 0x0000000000000000
r15 = 0x0000000000000000
rip = 0x000056149dfb014d
rbp = 0x00007ffc8354c0c0
rflags = 0x0000000000010202
rsp = 0x00007ffc8354c0b0
EOF
RUN

NAME=core maps linux arm64
FILE=bins/elf/core/core-linux-arm64
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00001000 0x558ce37000 - 0x558ce37fff r-x fmap./home/alarm/crash/crash-linux-arm64
 2 fd: 3 +0x00002000 0x558ce47000 - 0x558ce47fff r-- fmap./home/alarm/crash/crash-linux-arm64
 3 fd: 3 +0x00003000 0x558ce48000 - 0x558ce48fff r-- fmap./home/alarm/crash/crash-linux-arm64
 4 fd: 4 +0x00000000 0x7f8bd61000 - 0x7f8bebafff r-x mmap./usr/lib/libc-2.32.so
 5 fd: 3 +0x00004000 0x7f8bd60000 - 0x7f8bd60fff r-x fmap./usr/lib/libc-2.32.so
 6 fd: 5 +0x00000000 0x7f8bebb000 - 0x7f8becafff r-- mmap./usr/lib/libc-2.32.so
 7 fd: 3 +0x00005000 0x7f8becb000 - 0x7f8becdfff r-- fmap./usr/lib/libc-2.32.so
 8 fd: 3 +0x00008000 0x7f8bece000 - 0x7f8bed0fff r-- fmap./usr/lib/libc-2.32.so
 9 fd: 3 +0x0000b000 0x7f8bed1000 - 0x7f8bed3fff r-- fmap.LOAD7
10 fd: 6 +0x00000000 0x7f8bef9000 - 0x7f8bf19fff r-x mmap./usr/lib/ld-2.32.so
11 fd: 3 +0x0000e000 0x7f8bef8000 - 0x7f8bef8fff r-x fmap./usr/lib/ld-2.32.so
12 fd: 3 +0x0000f000 0x7f8bf26000 - 0x7f8bf27fff r-- fmap.LOAD9
13 fd: 3 +0x00011000 0x7f8bf28000 - 0x7f8bf28fff r-- fmap.LOAD10
14 fd: 3 +0x00012000 0x7f8bf29000 - 0x7f8bf29fff r-x fmap.LOAD11
15 fd: 3 +0x00013000 0x7f8bf2a000 - 0x7f8bf2afff r-- fmap./usr/lib/ld-2.32.so
16 fd: 3 +0x00014000 0x7f8bf2b000 - 0x7f8bf2cfff r-- fmap./usr/lib/ld-2.32.so
17 fd: 3 +0x00016000 0x7ff5e96000 - 0x7ff5eb6fff r-- fmap.[stack]
EOF
RUN

NAME=core regs linux arm64
FILE=bins/elf/core/core-linux-arm64
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
x0 = 0x0000000000000000
x1 = 0x0000007ff5eb5ed8
x2 = 0x0000007ff5eb5ee8
x3 = 0x000000558ce37744
x4 = 0x0000000000000000
x5 = 0x2bc88a8092e0763f
x6 = 0x0000007f8bed0590
x7 = 0x0000004554415649
x8 = 0x00000000000000d7
x9 = 0x0000000000000000
x10 = 0x0000000000000000
x11 = 0x0000000000000000
x12 = 0x0000007f8bd67310
x13 = 0x0000000000000000
x14 = 0x0000000000000000
x15 = 0x000000006fffff47
x16 = 0x0000000000000000
x17 = 0x0000000000000000
x18 = 0x0000000000000000
x19 = 0x000000558ce37780
x20 = 0x0000000000000000
x21 = 0x000000558ce37630
x22 = 0x0000000000000000
x23 = 0x0000000000000000
x24 = 0x0000000000000000
x25 = 0x0000000000000000
x26 = 0x0000000000000000
x27 = 0x0000000000000000
x28 = 0x0000000000000000
x29 = 0x0000007ff5eb5d60
x30 = 0x0000007f8bd84538
tmp = 0x0000000000000000
wzr = 0x00000000
fp = 0x0000007ff5eb5d60
lr = 0x0000007f8bd84538
sp = 0x0000007ff5eb5d60
pc = 0x000000558ce37754
zr = 0x0000000000000000
xzr = 0x0000000000000000
pstate = 0x0000000000000000
EOF
RUN

NAME=core maps linux arm32
FILE=bins/elf/core/core-linux-arm32
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00001000 0x00010000 - 0x00010fff r-x fmap./home/pi/crash/crash-linux-arm32
 2 fd: 3 +0x00002000 0x00020000 - 0x00020fff r-- fmap./home/pi/crash/crash-linux-arm32
 3 fd: 3 +0x00003000 0x00021000 - 0x00021fff r-- fmap./home/pi/crash/crash-linux-arm32
 4 fd: 4 +0x00000000 0x76e4a000 - 0x76f80fff r-x mmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 5 fd: 3 +0x00004000 0x76e49000 - 0x76e49fff r-x fmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 6 fd: 5 +0x00000000 0x76f81000 - 0x76f90fff r-- mmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 7 fd: 3 +0x00005000 0x76f91000 - 0x76f92fff r-- fmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 8 fd: 3 +0x00007000 0x76f93000 - 0x76f93fff r-- fmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 9 fd: 3 +0x00008000 0x76f94000 - 0x76f96fff r-- fmap.LOAD7
10 fd: 6 +0x00000000 0x76f97000 - 0x76f9afff r-x mmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
11 fd: 7 +0x00000000 0x76f9b000 - 0x76fa9fff r-- mmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
12 fd: 3 +0x0000b000 0x76faa000 - 0x76faafff r-- fmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
13 fd: 3 +0x0000c000 0x76fab000 - 0x76fabfff r-- fmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
14 fd: 8 +0x00000000 0x76fad000 - 0x76fcbfff r-x mmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
15 fd: 3 +0x0000d000 0x76fac000 - 0x76facfff r-x fmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
16 fd: 3 +0x0000e000 0x76fda000 - 0x76fdbfff r-- fmap.LOAD13
17 fd: 3 +0x00010000 0x76fdc000 - 0x76fdcfff r-- fmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
18 fd: 3 +0x00011000 0x76fdd000 - 0x76fddfff r-- fmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
19 fd: 3 +0x00012000 0x7ea6c000 - 0x7ea8cfff r-- fmap.[stack]
20 fd: 3 +0x00033000 0x7eb68000 - 0x7eb68fff r-x fmap.LOAD17
21 fd: 3 +0x00034000 0x7eb69000 - 0x7eb69fff r-- fmap.LOAD18
22 fd: 3 +0x00035000 0x7eb6a000 - 0x7eb6afff r-x fmap.LOAD19
23 fd: 3 +0x00036000 0xffff0000 - 0xffff0fff r-x fmap.LOAD20
EOF
RUN

NAME=core regs linux arm32
FILE=bins/elf/core/core-linux-arm32
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
sb = 0x00000000
sl = 0x76fdd000
fp = 0x7ea8c4f4
ip = 0x7ea8c570
sp = 0x7ea8c4e8
lr = 0x76e60718
pc = 0x00010420
r0 = 0x00000001
r1 = 0x7ea8c644
r2 = 0x7ea8c64c
r3 = 0x00000000
r4 = 0x00000000
r5 = 0x00010444
r6 = 0x00010318
r7 = 0x00000000
r8 = 0x00000000
r9 = 0x00000000
r10 = 0x76fdd000
r11 = 0x7ea8c4f4
r12 = 0x7ea8c570
r13 = 0x7ea8c4e8
r14 = 0x76e60718
r15 = 0x00010420
cpsr = 0x60000010
fpscr = 0x00000000
EOF
RUN
