Support This Project

Creating scripts

To order things properly, we will put all script files in a separate directory. Create a directory ~/.gdb, and tell gdb to source your script when starting:

mkdir ~/.gdb
echo "source ~/.gdb/wzdftpd" >> ~/.gdbinit

Now, create file ~/.gdb/wzdftpd containing:

# save this file in ~/.gdb or some where easy to find.
# then in ~/.gdbinit add the following line...
# source ~/.gdb/wzdftpd
#
# help p_wzd_context_list_size
# help p_wzd_context_list
define p_wzd_context_list_size
        set $list = ($arg0)
        if ($list == 0)
                print "0"
        end
        set $list_size = 0
        set $node = $list->head
        while ($node != 0)
                set $list_size++
                set $node = $node->next
        end

        printf "List size: %d\n", $list_size
end
document p_wzd_context_list_size
p_wzd_context_list_size <list>: Print size of wzd_context_t list
end
define p_wzd_context_list
        set $list = ($arg0)
        set $list_size = 0
        set $node = $list->head
        while ($node != 0)
                set $list_size++
                print (wzd_context_t*)$node->data
                set $node = $node->next
        end
end
document p_wzd_context_list
p_wzd_context_list <list>: Prints the content of the list.
To see the value, use the print command
For example: print *$1
end

Now you can use the commands like regular commands in gdb:

(gdb) help p_wzd_context_list
p_wzd_context_list <list>: Prints the content of the list.
To see the value, use the print command
For example: print *$1
(gdb) p_wzd_context_list context_list
$1 = (struct wzd_context_t *) 0x532dc0
(gdb) p *$1
$1 = {magic = 178814277, family = WZD_INET4, .....
...}