我最近发现您可以在 Xcode 中设置断点,这些断点将打印到控制台并自动继续 - 这意味着您可以插入日志语句,而无需编写 NSLog() 调用并重新编译(即时日志记录,woot) )。
唯一的问题是,在执行日志时可以显示的内容似乎有点有限。 它显示了一些您可以插入的标记,例如 %B 打印出有关当前断点的一些信息,或 %H 打印命中计数。
我想知道是否有任何方法可以将特定格式的时间戳插入日志行?
我尝试使用“shell script”断点操作,但它告诉我日期命令不存在......奇怪......
任何帮助都会很棒, 谢谢大家!
最佳答案
阅读GDB manual about Breakpoint Command Lists
You can give any breakpoint (or watchpoint or catchpoint) a series of commands to execute when your program stops due to that breakpoint. For example, you might want to print the values of certain expressions, or enable other breakpoints.
特别是:
for example, here is how you could use breakpoint commands to print the value of x at entry to foo whenever x is positive.
break foo if x>0
commands
silent
printf "x is %d\n",x
cont
end
这能回答你的问题吗?
关于iphone - 如何将时间字符串插入 GDB 日志中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/940540/