NAME=ELF Itanium exception cleanup region
FILE=bins/elf/ClassCpp.out
CMDS=iwj~{[0]}
EXPECT=<<EOF
{"index":0,"source":4713,"from":4778,"to":4872,"handler":4908,"filter":0,"kind":"cleanup"}
EOF
RUN

NAME=rabin2 lists exception regions
FILE=bins/elf/ClassCpp.out
CMDS=!!rabin2 -wr ${R2_FILE}~try.0.
EXPECT=<<EOF
f try.0.1269.from=0x000012aa
f try.0.1269.to=0x00001308
f try.0.1269.cleanup=0x0000132c
EOF
RUN

NAME=exception regions readable and quiet output
FILE=bins/elf/ClassCpp.out
CMDS=<<EOF
iw~0x000012aa
iwq~0x000012aa
!!rabin2 -w ${R2_FILE}~0x000012aa
EOF
EXPECT=<<EOF
0 0x000012aa-0x00001308 cleanup -> 0x0000132c (source 0x00001269)
0x000012aa 0x00001308 0x0000132c
0 0x000012aa-0x00001308 cleanup -> 0x0000132c (source 0x00001269)
EOF
RUN

NAME=ELF Itanium catch-all region
FILE=bins/elf/demangle-test-cpp
CMDS=iwj~{[1]}
EXPECT=<<EOF
{"index":1,"source":5546,"from":5808,"to":5871,"handler":6019,"filter":0,"kind":"catch","typeFilter":1,"catchAll":true}
EOF
RUN

NAME=ELF Itanium typed catch region
FILE=bins/elf/0pack
CMDS=iwj~{[0]}
EXPECT=<<EOF
{"index":0,"source":4684212,"from":4684240,"to":4684243,"handler":4684248,"filter":0,"kind":"catch","typeFilter":1,"type":"std::exception"}
EOF
RUN

NAME=ELF readable typed catch
FILE=bins/elf/0pack
CMDS=iw~^0 0x004779d0
EXPECT=<<EOF
0 0x004779d0-0x004779d3 catch (std::exception) -> 0x004779d8 (source 0x004779b4)
EOF
RUN

NAME=disasm exception region annotations and clipped views
FILE=bins/elf/ClassCpp.out
CMDS=<<EOF
e asm.flags=false
pd 2 @ 0x12aa~try 0x
pd 1 @ 0x12af~try 0x
pd 1 @ 0x1308~try 0x
pdJ 2 @ 0x12aa~try 0x
e asm.lines=false
pd 2 @ 0x12aa~try 0x
e asm.lines=true
e asm.trycatch=false
pd 2 @ 0x12aa~try 0x
EOF
EXPECT=<<EOF
            ; try 0x000012aa-0x00001308 cleanup -> 0x0000132c
            ; try 0x000012aa-0x00001308 cleanup -> 0x0000132c
EOF
RUN

NAME=disasm typed and catch-all handlers sharing a region
FILE=bins/elf/0pack
CMDS=<<EOF
pd 2 @ 0x4779d0~try 0x
EOF
EXPECT=<<EOF
            ; try 0x004779d0-0x004779d3 catch (std::exception) -> 0x004779d8
            ; try 0x004779d0-0x004779d3 catch (...) -> 0x004779d8
EOF
RUN

NAME=disasm exception background stops at the exclusive end
FILE=bins/elf/ClassCpp.out
CMDS=<<EOF
f-*
e asm.comments=false
e asm.bytes=false
e asm.addr=false
e scr.color=1
ec linehl white blue
pd 2 @ 0x1303
EOF
EXPECT=<<EOF
            [44m[34m     [1;32mcall[33m [32m0x1110[27;22;24;25;28;39m[0m
                 [36mmov[37m ebx[0m,[37m [32m0[0m
EOF
RUN

NAME=ELF shared catch handler analysis without try flags
FILE=bins/elf/0pack
CMDS=<<EOF
e anal.trycatch=false
af @ 0x4779b4
afbq @ 0x4779b4~?0x004779d8
af-*
e anal.trycatch=true
f-try.*
af @ 0x4779b4
afbq @ 0x4779b4~?0x004779d8
EOF
EXPECT=<<EOF
0
1
EOF
RUN

NAME=ELF cleanup handler is not added to its function
FILE=bins/elf/ClassCpp.out
CMDS=<<EOF
af @ 0x1269
afbq @ 0x1269~?0x0000132c
EOF
EXPECT=<<EOF
0
EOF
RUN
