是否有方法向GDB别名添加参数或创建函数?

huangapple go评论85阅读模式
英文:

any way to add parameters to gdb aliases or create a function?

问题

在gdb中,我想创建一个命令,用于打印出一个矢量寄存器:

  1. print $ymm0.v8_int32

理想情况下,能够传入寄存器的名称,如:

  1. pv ymm0

有没有办法做到这一点?

英文:

In gdb, I want to create a command that will print out a vector register:

  1. print $ymm0.v8_int32

ideally, being able to pass in the name of the register, like:

  1. pv ymm0

Is there any way to do this?

答案1

得分: 1

  1. 这大概已经足够接近了:
  2. ```c
  3. (gdb) p $ymm0.v8_int32
  4. $1 = {199136, 0, 5664, 0, 0, 0, 0, 0}
  5. (gdb) define pv
  6. 输入定义“pv”的命令。
  7. 以一行只写“end”结束。
  8. >打印 $arg0.v8_int32
  9. >end
  10. (gdb) pv $ymm0
  11. $2 = {199136, 0, 5664, 0, 0, 0, 0, 0}

你可以将这段代码放入 ~/.gdbinit 文件中:

  1. define pv
  2. print $arg0.v8_int32
  3. end

也可以参考GDB文档中有关用户自定义命令的部分。

  1. <details>
  2. <summary>英文:</summary>
  3. This is probably close enough:

(gdb) p $ymm0.v8_int32
$1 = {199136, 0, 5664, 0, 0, 0, 0, 0}

(gdb) define pv
Type commands for definition of "pv".
End with a line saying just "end".
>print $arg0.v8_int32
>end

(gdb) pv $ymm0
$2 = {199136, 0, 5664, 0, 0, 0, 0, 0}

  1. You can put this into `~/.gdbinit` as:

define pv
print $arg0.v8_int32
end

  1. See also [GDB documentation][1] on user-defined commands.
  2. [1]: https://sourceware.org/gdb/onlinedocs/gdb/Define.html
  3. </details>

huangapple
  • 本文由 发表于 2023年7月14日 00:45:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681659.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定