From 3cf55f763ef8c75e8e8c11fca3c3e564668aee52 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 8 Nov 2014 17:53:18 -0800 Subject: Make it easier to debug scripts, especially from coredumps --- src/map/script-call.cpp | 130 ------------------------------------------------ 1 file changed, 130 deletions(-) (limited to 'src/map/script-call.cpp') diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 8af5099..212e0e3 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -669,136 +669,6 @@ void run_func(ScriptState *st) } } -// pretend it's external so this can be called in the debugger -void dump_script(Borrowed script); -void dump_script(Borrowed script) -{ - ScriptPointer scriptp(script, 0); - while (scriptp.pos < reinterpret_cast *>(&*script)->size()) - { - PRINTF("%6zu: "_fmt, scriptp.pos); - switch (ByteCode c = get_com(&scriptp)) - { - case ByteCode::EOL: - PRINTF("EOL\n"_fmt); // extra newline between functions - break; - case ByteCode::INT: - // synthesized! - PRINTF("INT %d"_fmt, get_num(&scriptp)); - break; - - case ByteCode::POS: - case ByteCode::VARIABLE: - case ByteCode::FUNC_REF: - case ByteCode::PARAM: - { - int arg = 0; - arg |= static_cast(scriptp.pop()) << 0; - arg |= static_cast(scriptp.pop()) << 8; - arg |= static_cast(scriptp.pop()) << 16; - switch(c) - { - case ByteCode::POS: - PRINTF("POS %d"_fmt, arg); - break; - case ByteCode::VARIABLE: - PRINTF("VARIABLE %s"_fmt, variable_names.outtern(arg)); - break; - case ByteCode::FUNC_REF: - PRINTF("FUNC_REF %s"_fmt, builtin_functions[arg].name); - break; - case ByteCode::PARAM: - PRINTF("PARAM SP::#%d (sorry)"_fmt, arg); - break; - } - } - break; - case ByteCode::ARG: - PRINTF("ARG"_fmt); - break; - case ByteCode::STR: - PRINTF("STR \"%s\""_fmt, scriptp.pops()); - break; - case ByteCode::FUNC: - PRINTF("FUNC"_fmt); - break; - - case ByteCode::ADD: - PRINTF("ADD"_fmt); - break; - case ByteCode::SUB: - PRINTF("SUB"_fmt); - break; - case ByteCode::MUL: - PRINTF("MUL"_fmt); - break; - case ByteCode::DIV: - PRINTF("DIV"_fmt); - break; - case ByteCode::MOD: - PRINTF("MOD"_fmt); - break; - case ByteCode::EQ: - PRINTF("EQ"_fmt); - break; - case ByteCode::NE: - PRINTF("NE"_fmt); - break; - case ByteCode::GT: - PRINTF("GT"_fmt); - break; - case ByteCode::GE: - PRINTF("GE"_fmt); - break; - case ByteCode::LT: - PRINTF("LT"_fmt); - break; - case ByteCode::LE: - PRINTF("LE"_fmt); - break; - case ByteCode::AND: - PRINTF("AND"_fmt); - break; - case ByteCode::OR: - PRINTF("OR"_fmt); - break; - case ByteCode::XOR: - PRINTF("XOR"_fmt); - break; - case ByteCode::LAND: - PRINTF("LAND"_fmt); - break; - case ByteCode::LOR: - PRINTF("LOR"_fmt); - break; - case ByteCode::R_SHIFT: - PRINTF("R_SHIFT"_fmt); - break; - case ByteCode::L_SHIFT: - PRINTF("L_SHIFT"_fmt); - break; - case ByteCode::NEG: - PRINTF("NEG"_fmt); - break; - case ByteCode::NOT: - PRINTF("NOT"_fmt); - break; - case ByteCode::LNOT: - PRINTF("LNOT"_fmt); - break; - - case ByteCode::NOP: - PRINTF("NOP"_fmt); - break; - - default: - PRINTF("??? %d"_fmt, c); - break; - } - PRINTF("\n"_fmt); - } -} - /*========================================== * スクリプトの実行メイン部分 *------------------------------------------ -- cgit v1.2.3-70-g09d2