使用 Lauterbach (Trace32) 进行调试

发布于 2024-08-06 13:49:22 字数 205 浏览 6 评论 0原文

在使用跟踪时,我发现一些函数没有在源代码中列出,同时试图找到它们以设置断点。这些函数似乎只有当我以汇编格式查看源代码时才会出现。

我和我的前辈交谈过,他们告诉我如果任何函数只调用一次,它会被Trace优化并且会显示为内联,因此可以在汇编中看到。

我的问题是:

  1. 劳特巴赫如何进行这种优化?
  2. 这样有好处吗??

While using trace, I found that a few functions are not listed in the source while trying to find them in order to put a breakpoint. These functions seems to appear only when I view the source in assembly format.

I spoke to my seniors, they told me if any function is only called once, it will be optimised by Trace and will appear as inline, hence can be seen in assembly.

My questions are:

  1. How does this optimization happens through Lauterbach?
  2. Is this advantageous??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一袭水袖舞倾城 2024-08-13 13:49:22

有几件事:

  1. 关于语句我发现在尝试查找它们以放置断点时,源代码中没有列出一些函数” ,只需检查映射文件/映射文件,其中包含构建中使用的不同函数、它们在内存中的位置等,如果您在那里找不到您的函数,那么只需查看优化即可[只有这可能是问题]。

  2. 正如正确指出的,优化不是由 Lauterbach 完成的,而是由编译器完成的。通常,有不同的优化级别[在 ARM 中我们有 O0-O2],其中 O0 是可能的最高优化,但这仅应在向客户发布版本时使用,否则应使用优化级别 O2 进行调试。

  3. 如果您认为编译器可能会优化该函数,请尝试将其设置为易失性。< /p>

  4. 另一点可能与此不[直接]相关,但可能有帮助,那就是知道“您的文件位于内存的哪个区域”,因为很多时候,当您想要调试某些内容而该页面仍然不在时RAM 中,您将无法放置断点,直到该页面被放入 RAM 中为止 [基本上,类似于按需分页(如果您的系统中存在)]

希望这会有所帮助。

-hjsblogger

There are a couple of things:

  1. Regarding the statement I found that few functions are not listed in the source while trying to find them in order to put a breakpoints", just check the Mapping file/Map file which consists of the different functions which were used in the build, their locations in memory etc and if you don't find your function there there than just look into the optimization [Only that could be the issue].

  2. As rightly pointed out, the optimization is not done by the Lauterbach but it is done by the compiler. Normally, there are different optimization levels [in ARM we have O0-O2] where O0 is the highest optimization possible but this should only be used when there is a release to the customer else optimization level O2 should be used for debugging.

  3. If you feel the function might be optimized by the compiler, try making it volatile.

  4. Other point which might not be [directly] related to this but might help is to know "In which area of the memory is your file located" since many times, when you want to debug something and that Page is still not in the RAM, you won't be able to put the breakpoints till the time that page is taken in the RAM [Basically, something like On-Demand Paging if it is present in your system]

Hope this helps.

-hjsblogger

瞎闹 2024-08-13 13:49:22

优化是由编译器完成的,而不是由 Lauterbach 完成的。编译器尝试优化其汇编语言输出,默认设置通常会内联仅调用一次的函数。

要出于测试目的覆盖这些优化,您可以使用编译器标志--no_inline

The optimization is done by the compiler, not by the Lauterbach. The compiler tries to optimize its assembly language output, and the default settings typically will inline functions that are only called once.

To override these optimizations for test purposes, you can use the compiler flag --no_inline.

南汐寒笙箫 2024-08-13 13:49:22

内联仅被调用一次的函数可以由编译器完成。

优点是它节省了函数调用的开销(运行时、代码空间和堆栈空间),并且您仍然可以以良好的模块化方式将代码编写为多个函数。

缺点是调试变得更加困难,因为在调试过程中函数与调用者混合在一起。

关于跟踪工具的行为,您的问题相当不清楚。

Inlining a function that only is called once may be done by the compiler.

The advantage is that it saves the overhead of a function call (runtime, code space and stack space), and you can still write the code in a nice modular way as several functions.

The disadvantage is that debugging becomes harder, because during debugging function is mixed up with the caller.

W.r.t. the behavior of your trace tool your question is rather unclear.

属性 2024-08-13 13:49:22

如果您在源代码中找不到正在调用的函数,则不太可能是因为内联函数,原因有两个:

  1. 内联函数调用不会在汇编代码中显示为子例程调用 - 代码实现函数在函数调用原本应在的位置内联发出(这就是内联)

  2. 当编译器内联函数调用时,函数名称(如果您可以在汇编输出中看到它)仍然是源代码的一部分- 这就是编译器将代码内联的地方。

但是,编译器有时会将对内部辅助函数的神秘函数调用插入到生成的代码中,以实现 CPU 不直接支持的算术运算(例如整数除法或浮点运算)等操作。

“神秘函数”的名称是什么?

If there's a function being called that you can't find in your source code it's unlikely to be because of inlined functions for 2 reasons:

  1. inlined function calls won't show up as subroutine calls in the assembly code - the code to implement the function is emitted inline at the point where the function call would otherwise be (that's what inlining is)

  2. when the compiler inlines your function calls, the function name (if you could see it in the assembly output) would still be part of your source code - that's where the compiler would be getting the code to inline.

But, compilers sometimes insert mysterious function calls to internal helper functions into the generated code to implement things like arithmetic operations that the CPU doesn't directly support (integer division or floating point operations for example).

What are the names of the 'mystery functions'?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文