NAME=k
FILE==
CMDS=<<EOF
k
k abc=123
k abc
# BSDs don't have a syscall namespace.
k **~!syscall
k analysis/**
e asm.arch=x86
k analysis/cc/*
EOF
EXPECT=<<EOF
orig_baddr=0
123
analysis
bin
debug
spec
cc
classes
noreturn
amd64=cc
amd64syscall=cc
cc.amd64.arg0=rdi
cc.amd64.arg1=rsi
cc.amd64.arg10=xmm4
cc.amd64.arg2=rdx
cc.amd64.arg3=rcx
cc.amd64.arg4=r8
cc.amd64.arg5=r9
cc.amd64.arg6=xmm0
cc.amd64.arg7=xmm1
cc.amd64.arg8=xmm2
cc.amd64.arg9=xmm3
cc.amd64.maxargs=11
cc.amd64.ret=rax
cc.amd64syscall.arg0=rdi
cc.amd64syscall.arg1=rsi
cc.amd64syscall.arg2=rdx
cc.amd64syscall.arg3=r10
cc.amd64syscall.arg4=r8
cc.amd64syscall.arg5=r9
cc.amd64syscall.maxargs=6
cc.amd64syscall.ret=rax
cc.ms.arg0=rcx
cc.ms.arg1=rdx
cc.ms.arg2=r8
cc.ms.arg3=r9
cc.ms.argn=stack
cc.ms.maxargs=4
cc.ms.ret=rax
cc.reg.arg0=rdi
cc.reg.arg1=rsi
cc.reg.arg2=rdx
cc.reg.arg3=rcx
cc.reg.maxargs=4
cc.reg.ret=rdi
cc.swift.arg0=rdi
cc.swift.arg1=rsi
cc.swift.arg10=xmm4
cc.swift.arg2=rdx
cc.swift.arg3=rcx
cc.swift.arg4=r8
cc.swift.arg5=r9
cc.swift.arg6=xmm0
cc.swift.arg7=xmm1
cc.swift.arg8=xmm2
cc.swift.arg9=xmm3
cc.swift.error=r12
cc.swift.maxargs=11
cc.swift.ret=rax
cc.swift.self=r13
default.cc=amd64
ms=cc
reg=cc
swift=cc
EOF
RUN

NAME=ko/kd
BROKEN=1
FILE==
CMDS=<<EOF
k debug/abc=123
kd output_file debug
kd file.sdb debug
k debug/abc=0
k debug/*
kd output_file debug
k debug/*
rm output_file
rm file.sdb
EOF
EXPECT=<<EOF
abc=123
abc=0
abc=123
EOF
RUN

NAME=1: k syscall/
FILE=malloc://512
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
e asm.os=linux
k syscall/0x80.4
EOF
EXPECT=<<EOF
stat
EOF
RUN

NAME=2: k syscall/
FILE=malloc://512
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
e asm.os=linux
k syscall/stat
EOF
EXPECT=<<EOF
0x80,4,2,
EOF
RUN

NAME=3: test kj
FILE=bins/elf/ioli/crackme0x03
ARGS=-A
CMDS=<<EOF
kj~{}
EOF
EXPECT=<<EOF
{
  "analysis": {
    "cur_cmd": [
      "spec",
      "gcc=spec",
      "spec.gcc.c=char",
      "spec.gcc.d=int",
      "spec.gcc.f=float",
      "spec.gcc.g=double",
      "spec.gcc.ld=long int",
      "spec.gcc.lf=double",
      "spec.gcc.li=long int",
      "spec.gcc.lld=long long int",
      "spec.gcc.lli=long long int",
      "spec.gcc.llu=unsigned long long int",
      "spec.gcc.lu=unsigned long int",
      "spec.gcc.p=void *",
      "spec.gcc.s=const char *",
      "spec.gcc.u=unsigned int",
      "cc",
      "borland=cc",
      "cc.borland.arg0=eax",
      "cc.borland.arg1=edx",
      "cc.borland.arg2=ecx",
      "cc.borland.argn=stack_rev",
      "cc.borland.maxargs=3",
      "cc.cdecl-fastcall-ms.argn=stack",
      "cc.cdecl-fastcall-ms.maxargs=1",
      "cc.cdecl-fastcall-ms.ret=eax",
      "cc.cdecl-thiscall-ms.arg0=ecx",
      "cc.cdecl.argn=stack",
      "cc.cdecl.maxargs=0",
      "cc.cdecl.ret=eax",
      "cc.fastcall.arg0=ecx",
      "cc.fastcall.arg1=edx",
      "cc.fastcall.argn=stack",
      "cc.fastcall.maxargs=2",
      "cc.fastcall.ret=eax",
      "cc.optlink.arg0=eax",
      "cc.optlink.arg1=edx",
      "cc.optlink.arg2=ecx",
      "cc.optlink.argn=stack",
      "cc.optlink.maxargs=3",
      "cc.optlink.ret=eax",
      "cc.pascal.argn=stack_rev",
      "cc.pascal.maxargs=0",
      "cc.reg.arg0=eax",
      "cc.reg.arg1=ebx",
      "cc.reg.arg2=ecx",
      "cc.reg.arg3=edx",
      "cc.reg.maxargs=4",
      "cc.reg.ret=eax",
      "cc.stdcall.argn=stack",
      "cc.stdcall.maxargs=0",
      "cc.stdcall.ret=eax",
      "cc.watcom.arg0=eax",
      "cc.watcom.arg1=edx",
      "cc.watcom.arg2=ebx",
      "cc.watcom.arg3=ecx",
      "cc.watcom.argn=stack",
      "cc.watcom.maxargs=4",
      "cdecl=cc",
      "cdecl-thiscall-ms=cc",
      "default.cc=cdecl",
      "fastcall=cc",
      "optlink=cc",
      "pascal=cc",
      "reg=cc",
      "stdcall=cc",
      "watcom=cc",
      "classes",
      "noreturn"
    ]
  }
}
EOF
RUN
