manpagez: man pages & more
info gawk
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.3.6 Miscellaneous Commands

There are a few more commands which do not fit into the previous categories, as follows:

dump [filename]

Dump bytecode of the program to standard output or to the file named in filename. This prints a representation of the internal instructions which gawk executes to implement the awk commands in a program. This can be very enlightening, as the following partial dump of Davide Brini’s obfuscated code (see section And Now For Something Completely Different) demonstrates:

 
dgawk> dump
-|        # BEGIN
-|
-| [     2:0x89faef4] Op_rule             : [in_rule = BEGIN] [source_file = brini.awk]
-| [     3:0x89fa428] Op_push_i           : "~" [PERM|STRING|STRCUR]
-| [     3:0x89fa464] Op_push_i           : "~" [PERM|STRING|STRCUR]
-| [     3:0x89fa450] Op_match            : 
-| [     3:0x89fa3ec] Op_store_var        : O [do_reference = FALSE]
-| [     4:0x89fa48c] Op_push_i           : "==" [PERM|STRING|STRCUR]
-| [     4:0x89fa4c8] Op_push_i           : "==" [PERM|STRING|STRCUR]
-| [     4:0x89fa4b4] Op_equal            : 
-| [     4:0x89fa400] Op_store_var        : o [do_reference = FALSE]
-| [     5:0x89fa4f0] Op_push             : o
-| [     5:0x89fa4dc] Op_plus_i           : 0 [PERM|NUMCUR|NUMBER]
-| [     5:0x89fa414] Op_push_lhs         : o [do_reference = TRUE]
-| [     5:0x89fa4a0] Op_assign_plus      : 
-| [      :0x89fa478] Op_pop              : 
-| [     6:0x89fa540] Op_push             : O
-| [     6:0x89fa554] Op_push_i           : "" [PERM|STRING|STRCUR]
-| [      :0x89fa5a4] Op_no_op            : 
-| [     6:0x89fa590] Op_push             : O
-| [      :0x89fa5b8] Op_concat           : [expr_count = 3] [concat_flag = 0]
-| [     6:0x89fa518] Op_store_var        : x [do_reference = FALSE]
-| [     7:0x89fa504] Op_push_loop        : [target_continue = 0x89fa568] [target_break = 0x89fa680]
-| [     7:0x89fa568] Op_push_lhs         : X [do_reference = TRUE]
-| [     7:0x89fa52c] Op_postincrement    : 
-| [     7:0x89fa5e0] Op_push             : x
-| [     7:0x89fa61c] Op_push             : o
-| [     7:0x89fa5f4] Op_plus             : 
-| [     7:0x89fa644] Op_push             : o
-| [     7:0x89fa630] Op_plus             : 
-| [     7:0x89fa5cc] Op_leq              : 
-| [      :0x89fa57c] Op_jmp_false        : [target_jmp = 0x89fa680]
-| [     7:0x89fa694] Op_push_i           : "%c" [PERM|STRING|STRCUR]
-| [      :0x89fa6d0] Op_no_op            : 
-| [     7:0x89fa608] Op_assign_concat    : c
-| [      :0x89fa6a8] Op_jmp              : [target_jmp = 0x89fa568]
-| [      :0x89fa680] Op_pop_loop         : 
-| 
…
-| 
-| [     8:0x89fa658] Op_K_printf         : [expr_count = 17] [redir_type = ""]
-| [      :0x89fa374] Op_no_op            : 
-| [      :0x89fa3d8] Op_atexit           : 
-| [      :0x89fa6bc] Op_stop             : 
-| [      :0x89fa39c] Op_no_op            : 
-| [      :0x89fa3b0] Op_after_beginfile  : 
-| [      :0x89fa388] Op_no_op            : 
-| [      :0x89fa3c4] Op_after_endfile    : 
dgawk>
help
h

Print a list of all of the dgawk commands with a short summary of their usage. ‘help command’ prints the information about the command command.

list [- | + | n | filename:n | nm | function]
l [- | + | n | filename:n | nm | function]

Print the specified lines (default 15) from the current source file or the file named filename. The possible arguments to list are as follows:

-

Print lines before the lines last printed.

+

Print lines after the lines last printed. list without any argument does the same thing.

n

Print lines centered around line number n.

nm

Print lines from n to m.

filename:n

Print lines centered around line number n in source file filename. This command may change the current source file.

function

Print lines centered around beginning of the function function. This command may change the current source file.

quit
q

Exit the debugger. Debugging is great fun, but sometimes we all have to tend to other obligations in life, and sometimes we find the bug, and are free to go on to the next one! As we saw above, if you are running a program, dgawk warns you if you accidentally type ‘q’ or ‘quit’, to make sure you really want to quit.

trace on | off

Turn on or off a continuous printing of instructions which are about to be executed, along with printing the awk line which they implement. The default is off.

It is to be hoped that most of the “opcodes” in these instructions are fairly self-explanatory, and using stepi and nexti while trace is on will make them into familiar friends.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.