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

一曲冷凌霜 提交于 2019-12-03 12:35:08
neuron

Here's the easy way I found out:

define hook-stop
  ...commands to be executed when execution stops
end

Refer to this page for details: http://sourceware.org/gdb/current/onlinedocs/gdb/Hooks.html#Hooks

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!