The Computer Oracle

In GDB, how can I jump directly up to the topmost call stack frame?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5 Looping

--

Chapters
00:00 In Gdb, How Can I Jump Directly Up To The Topmost Call Stack Frame?
01:05 Accepted Answer Score 11
01:17 Answer 2 Score 29
01:34 Answer 3 Score 2
01:42 Thank you

--

Full question
https://superuser.com/questions/308173/i...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#debug #c #gdb

#avk47



ANSWER 1

Score 29


You can specify 'bt' with a negative number to start from topmost frame:

bt -20

You can then use 'frame' (or 'f') to directly go to the frame you wish.




ACCEPTED ANSWER

Score 11


In my tests, using 'up' with a very large number resulted in the topmost frame being displayed, e.g.

(gdb) up 99999
#58 0x0000000000442fb4 in main ()



ANSWER 3

Score 2


fr 0 will take you to the top-most stack frame. fr stands for frame.