Files
CPlusPlusThings/site_extras/cpp-tools-bazel-debugging.md
light-city dfe1c933b3 docs: address community issue feedback (#5 #338 #142 #246 #136 #303)
- const README: rewrite the space-saving claim per issue #5 follow-ups
  (constant-expression const vs #define immediates; which const qualify
  as constant expressions)
- const README: fix the class-section diagnosis per issue #338 (overload
  resolution picks the const overload; the restriction only surfaces
  once that overload is removed)
- sizeof README: virtual-inheritance result is compiler-dependent
  (GCC merges vbptr+vfptr -> 16, MSVC keeps them separate -> 32) #246
- static README: new section on internal linkage / access restriction
  with anonymous-namespace comparison #142
- 10-day practice: full problem list table + fixed day links #136
- new design_pattern/singleton/singleton_default.hpp: reusable
  thread-safe CRTP singleton template, compile+concurrency tested #303
2026-10-13 19:23:54 +08:00

36 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
> 来自 [C++那些事网站](https://light-city.github.io/stories_things/cpp-tools/bazel-debugging/) 的文章,由站点同步脚本导出。
# Bazel 与 LLDB 联合调试
今天在调试时发现通过bazel编译出来的文件在mac上没法调试了,竟然全是汇编代码。
```
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000fd0 hello_world`main
hello_world`main:
-> 0x100000fd0 <+0>: pushq %rbp
0x100000fd1 <+1>: movq %rsp, %rbp
0x100000fd4 <+4>: subq $0x60, %rsp
0x100000fd8 <+8>: movl $0x0, -0x4(%rbp)
(lldb) quit
```
如何解决呢?
默认是standalone,我们需要disable,这里采用local,这意味着输出将与其依赖项链接,而不是采用默认的`standalone`策略。
```cpp
build --spawn_strategy=local
```
这样的话可以看到代码了。
```cpp
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000fdf hello_world`main at hello_world.cc:14:21
11
12 int main() {
13 // Create a thread pool
-> 14 auto threadPool = GetCpuThreadPool();
15 if (!threadPool) {
```