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

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

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

问题

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

print $ymm0.v8_int32

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

pv ymm0

有没有办法做到这一点?

英文:

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

print $ymm0.v8_int32

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

pv ymm0

Is there any way to do this?

答案1

得分: 1

这大概已经足够接近了:

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

(gdb) define pv
输入定义“pv”的命令。
以一行只写“end”结束。
>打印 $arg0.v8_int32
>end

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

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

define pv
  print $arg0.v8_int32
end

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


<details>
<summary>英文:</summary>

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}

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

define pv
print $arg0.v8_int32
end

See also [GDB documentation][1] on user-defined commands.


  [1]: https://sourceware.org/gdb/onlinedocs/gdb/Define.html

</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:

确定