CraftSpider / GCDecompiler

A project to decompile and recompile gamecube games
MIT License
47 stars 7 forks source link

Every command leads to an error #10

Open brickedware opened 1 year ago

brickedware commented 1 year ago

Hello, I have compiled the source and I am currently running it on an SSH'ed Raspberry Pi, the compiled app however, keeps throwing the same error for each command. The command usually starts normally: (dol as an example)

INFO: Disassembling PPC
INFO: Generating symbols
INFO: Symbol generation complete

But then, it would throw this exact error:

terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoul
Aborted

And it happens with every command, is there a specific reason for this? Thanks in advance.

CraftSpider commented 1 year ago

Apologies for the long response time. This tool is largely abandonware, but I was looking at it today and trying to get it building. I'm not sure why stoul would be throwing an error in general, but it looks to be part of the custom formatting code that is causing the issue. If you're still interested, I can try to track down a dol to test this on and debug the issue.

yne commented 9 months ago

Just to add more context to this issue, here is the stacktrace of the stoul error:

#10 0x000000000045c4a2 in std::__cxx11::stoul(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long*, int) ()
#11 0x000000000045e4db in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > util::format<unsigned char*>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char*) ()
#12 0x00000000004533fe in PPC::Instruction::get_variables[abi:cxx11]() ()
#13 0x0000000000453535 in PPC::Instruction::used_registers() ()
#14 0x000000000045414a in PPC::Instruction::source_registers() ()
#15 0x0000000000468140 in PPC::Symbol::gen_inputs() ()
#16 0x000000000046834a in PPC::Symbol::get_input_regular() ()
#17 0x00000000004510c6 in PPC::decompile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) ()
#18 0x000000000046d445 in command_decomp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ArgParser&) ()
#19 0x00000000004704c9 in main ()

Caused by this line: https://github.com/CraftSpider/AlphaTools/blob/70ff9cd4ec4184f67d7e8b779538ef88f1e88682/include/utils/format.tpp#L44

With the following context

format=r{b0:6,10}
str=b0:6,10
colon_pos=2

which leads to stoll("b0")

Possible solution: