gdb加载python脚本的方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xuzhina/article/details/76733977

脚本名称为hello.py,内容如下:

import gdb 
class HelloPrefixCommand( gdb.Command ):
    "just to say hello"

    def __init__(self):
        super( HelloPrefixCommand, self).__init__("hello",
                gdb.COMMAND_SUPPORT,
                gdb.COMPLETE_NONE, True )
HelloPrefixCommand()

加载方法1:

sudo gdb httpd -x hello.py

查看一下:

(gdb) help hello
just to say hello

List of hello subcommands:


Type "help hello" followed by hello subcommand name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.

加载方法2:

(gdb) source hello.py

查看一下:

(gdb) help hello
just to say hello

List of hello subcommands:


Type "help hello" followed by hello subcommand name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.




猜你喜欢

转载自blog.csdn.net/xuzhina/article/details/76733977