scripts/gdb: add internal helper and convenience function to retrieve thread_info