Skip to content

Instantly share code, notes, and snippets.

@ariscop
Created March 4, 2021 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariscop/5c2089d7d1922f36d67e2b02f0556404 to your computer and use it in GitHub Desktop.
Save ariscop/5c2089d7d1922f36d67e2b02f0556404 to your computer and use it in GitHub Desktop.
awful gdb script to measure pathfinder cost by train in factorio
file factorio
set $train_id = (int)0
set $start = (unsigned long long)0
set $end = (unsigned long long)0
# for 1.1.26, linux build
break _ZN5Train11requestPathEPK4Rail13RailDirectionPK20InChainSignalSection
commands
set $train_id = *(int*)((void*)$rdi + 0x30)
# location of the train pathfinder time used counter
set $start = *(unsigned long long*)(*(void**)0x2a2b740 + 0x1e98)
continue
end
# return instruction
break *_ZN5Train11requestPathEPK4Rail13RailDirectionPK20InChainSignalSection + 367
commands
set $end= *(unsigned long long*)(*(void**)0x2a2b740 + 0x1e98)
printf "id: %d delta: %d", $train_id, $end - $start
continue
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment