In GDB, how do I execute a command automatically when program stops? (like display)

前端 未结 2 1199
余生分开走
余生分开走 2021-02-14 03:38

I want some commands to be automatically executed each time the program stops, just like what display does with x. How do I do that?

2条回答
  •  别跟我提以往
    2021-02-14 04:28

    Another "new" way to do it is with the Python Event interface:

     def stop_handler (event):
         print "event type: stop"
    
     gdb.events.stop.connect (stop_handler)
    

    which will trigger the stop_handler function each the the inferior stops.

    There are two other similar events type:

    events.cont
    events.exited
    

    respectively triggered when the inferior is continued or exists.

提交回复
热议问题