Game Engine Architecture

(Ben Green) #1

388 9. Tools for Debugging and Development


voidb()
{
d();
e();
f();
}
voidc() { ... }
voidd() { ... }
voide() { ... }
voidf() { ... }
Assuming function a() is called directly from main(), this function call hier-
archy is shown in Figure 9.13.
When debugging a program, the call stack shows only a snapshot of this
tree. Specifi cally, it shows us the path from whichever function in the hierarchy
is currently executing all the way to the root function in the tree. In C/C++, the
root function is usually main() or WinMain(), although technically this func-
tion is called by a start-up function that is part of the standard C runtime library
(CRT), so that function is the true root of the hierarchy. If we set a breakpoint in
function e(), for example, the call stack would look something like this:
e() ÅThe currently-executing function.
b()
a()
main()
_crt_startup() ÅRoot of the call hierarchy.
This call stack is depicted in Figure 9.14 as a pathway from function e() to the
root of the function call tree.

f()

a()
b()

c()

d()
e()

Figure 9.13. A hy-
pothetical func-
tion call hierar-
chy.


f()

a()
b()

c()

d()
e()

main()

_crt_startup()

Figure 9.14. Call stack resulting from setting a break point in function e().
Free download pdf