简体   繁体   English

如何在gdb中挂接到命令x?

[英]How can I hook to the command x in gdb?

I've tried hooking to other commands such as echo and it works well. 我尝试挂钩到其他命令,例如echo,并且效果很好。 But when it comes to hooking the x command, it fails. 但是当涉及到钩挂x命令时,它会失败。 Here's the codes inside of my .gdbinit file. 这是我的.gdbinit文件中的代码。

set $pince_injection_failed = 1
set $pince_debugging_mode = 0
define hook-x
  if $pince_injection_failed = 1
    echo asdf
end

define hookpost-x
  if $pince_debugging_mode = 0
    echo zxcv
end

I'm aware that gdb doesn't accept aliases of a function for hooking. 我知道gdb不接受钩子函数的别名。 But x is already a full function isn't it? 但是x已经是一个全功能了,不是吗? I couldn't find any aliases for it. 我找不到任何别名。 I'm also doubting about it because a single character is too short for a command to be 我也对此感到怀疑,因为单个字符太短而无法执行命令

I found the solution thanks to the Mark Plotnick. 感谢Mark Plotnick,我找到了解决方案。 It seems like another fault of mine, I found out that there was a function that had a misplaced end, so all functions came after that function got ignored by gdb naturally. 似乎这是我的另一个错误,我发现有一个函数的末尾放错了位置,因此所有函数都在该函数自然被gdb忽略之后才出现。

define keks
  set $lel=0
  while($lel<10)
    x/x 0x00400000
    set $lel = $lel+1
end

Notice the missing end at the end of while loop 注意while循环end时缺少的end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM