iphone - 如何将时间字符串插入 GDB 日志中?

标签 iphone xcode debugging gdb breakpoints

我最近发现您可以在 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/

相关文章:

iphone - IOS 如何判断一个数是 NSInteger 还是 float ?

iphone - 核心数据中的 mach_msg_trap

iphone - 每点击一次按钮,将文本框中的数字减一

objective-c - 在 XCODE 中简单调整 UIImage 的大小

javascript - 如何查找 reactJS 错误?

python - Django/Python 单元测试 : Let exceptions rise

计算读取操作返回的字节数

c++ - iPhone 拇指和 VFP

swift - ImageView 和按钮未出现在模拟器中

iphone - iOS 导航栏平滑过渡