O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Looking inside the program

When we run a program that contains a function call, GAWK maintains a stack of all function calls to lead you up to where you are executing. We can see how we got there, where we are and also move inside the stack with the help of the backtrace command or bt or the alias where. Any of these three commands can be used to print the backtrace of function calls (stack frames).

Here, frame 0 is the currently executing innermost frame (function call). Frame 1 is the frame that called the innermost frame 0 and the highest-numbered frame represents the main program:

gawk> backtrace#0 find_add(num1, num2) at `calc.awk':2#1 in calc() at `calc.awk':18#2 in main() at `calc.awk':26gawk>

The output contains the frame number, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required