英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论