菜鸟教程小白 发表于 2022-12-13 14:47:21

ios - 如何在 Xcode 调试窗口中更改 float 和 double 的显示格式?


                                            <p><p>我在 Xcode 中调试 C 并在函数中设置断点以检查各种 double 值的值。 Xcode 坚持使用科学计数法来显示它们,这真的很痛苦。我需要查看十进制表示。 <em>十进制</em>的右键“查看值”菜单选项,会做一些奇怪的事情。任何人都知道如何让这个在 printf'n 我想看到的所有内容中播放得很好??</p>
<p> <img src="/image/wo4Tj.png" alt="enter image description here"/> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>查看 <a href="http://lldb.llvm.org/varformats.html" rel="noreferrer noopener nofollow">LLDB Variable Formatting</a>文档,特别是靠近顶部的 <em>Type Format</em> 部分。</p>

<p>您可以使用 <code>type format</code> 命令更改默认输出。</p>

<p>从上面的链接</p>

<blockquote>
<p>Type formats enable you to quickly override the default format for
displaying primitive types (the usual basic C/C++/ObjC types: int,
float, char, ...).</p>

<p>If for some reason you want all int variables in your program to print
out as hex, you can add a format to the int type.</p>

<p>This is done by typing</p>

<p>(lldb) type format add --format hex int</p>
</blockquote>

<p>要更改 jDate 对象的默认显示,您应该能够执行类似 </p> 的操作

<pre><code>type format add -f float jDate
</code></pre>

<p>您可以使用 <code>help <format></code> 从调试器本身获取更多信息,但上面链接的页面读起来非常好。</p>

<p>如果这不能解决您的问题,您可能需要进一步阅读<em>类型摘要</em>。我不记得 Xcode 显示的内容,无论是格式还是摘要。</p>

<p>此外,WWDC2012session<strong># 415 "Debugging with LLDB"</strong> 展示了更改这些显示格式并添加您自己的格式的方法。相关部分在 35 分钟左右,但整个 session 很棒。</p>

<p>希望有帮助!</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在 Xcode 调试窗口中更改 float 和 double 的显示格式?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/11488028/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/11488028/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在 Xcode 调试窗口中更改 float 和 double 的显示格式?