以下是 lldb 会话的片段:
* thread #1, name = 'so', stop reason = breakpoint 5.1
frame #0: 0x000000000040113c so`test(hello="Hello, world!") at so.c:5:18
2
3 void test(char* hello)
4 {
-> 5 printf("%s\n", hello);
6 }
在
frame #0
行中,C 函数test
的参数显示为字符串。我如何设置所有char*
类型的参数都被lldb显示为指针,而不是字符串?
type summary
的一些文档,但我看不出如何将其应用于 char*
类型的所有用途(当我尝试时,我的语法显然无法解析,以至于 lldb 崩溃了: )
删除正则表达式匹配摘要比应该的更难。你可以做几件事。您可以禁用此摘要所属的类别,幸运的是其中没有那么多。如果你手边有 char * 指针,你可以找到哪个摘要:
(lldb) 类型摘要信息 my_ptr 应用于 (char *) my_ptr 的摘要是:
${var%s}
(跳过指针)
然后执行
type summary list
,您会找到具有该摘要字符串的那个:
-----------------------
Category: system
-----------------------
OSType: `${var%O}` (not cascading) (skip pointers) (skip references)
^(unsigned )?char ?(\*|\[\])$: `${var%s}` (skip pointers)
^((un)?signed )?char ?\[[0-9]+\]$: `${var%char[]}` (hide value) (skip pointers)
那么:
(lldb) 类型类别禁用系统 (lldb) v my_ptr (char *) my_ptr = 0x0000000100003fa0
您可以在需要时再次打开它。您还可以覆盖内置摘要。您可以在上面的输出中看到正则表达式字符串,例如:
(lldb) type summary add --summary-string ' ' "^(unsigned )?char ?(\*|\[\])$" -x
(lldb) v my_ptr
(char *) my_ptr = 0x0000000100003fa0
这也应该有效:
(lldb) 类型摘要删除 "^(unsigned )?char ?(*|[])$"
但这似乎不适用于内置摘要。