Cannot find debug symbol (No symbol in current context)

I just start to learn Zig. I have a very simple program

const std = @import("std");

pub const User = struct {
    power: u64,
    name: []const u8,
};

pub fn main() void {
    const user = User{ .power = 9001, .name = "Goku" };
    std.debug.print("{s}'s power is {d}\n", .{ user.name, user.power });
}

I tried to use gdb to debug the program to make sure I can use debugger to debug Zig program.

I build above Zig program with zig build-exe src/main.zig -Doptimize=Debug and when I invoke gdb main, there is no symbol found by gdb as indicated below

Reading symbols from main...
(gdb) b main.main
Breakpoint 1 at 0x10de234: file main.zig, line 58.
(gdb) run
Starting program: /home/zeyuanhu/projects/hello-world/main 

Breakpoint 1, main.main () at main.zig:58
58	    std.debug.print("{s}'s power is {d}\n", .{ user.name, user.power });
(gdb) p user
No symbol "user" in current context.

I was expecting to print user variable but I cannot do so. I was wondering if there is anything wrong with my steps to allow me to use debugger on Zig program? Thank you very much!

I did a bit more research by adding the following code into main

const a = 10;
std.debug.print("{d}\n", .{a});

const b: u32 = 10;
std.debug.print("{d}\n", .{b});

I find that gdb cannot print value of a as well. However, gdb can print value of b. Not sure why.

My two cents: here as you don’t define a type for a it will be of type comptime_int. Maybe those comptime constants are stripped from the exe (reminds me of #define in C where you have to ask to gcc to keep those informations to be accessible from a debugger).
Maybe a cli arg could do that?

2 Likes

For better (experimental) debugging experience you can try zig-adjusted lldb fork by jacobly0 together with zig x86 backend (-fno-llvm).

(lldb) target create "main"
Current executable set to '/tmp/tmp.XQSvAW5vhG/main' (x86_64).
(lldb) b main
Breakpoint 1: where = main`main.main + 8 at main.zig:9:5, address = 0x0000000001150a36
(lldb) r
Process 114579 launched: '/tmp/tmp.XQSvAW5vhG/main' (x86_64)
Process 114579 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
    frame #0: 0x0000000001150a36 main`main.main at main.zig:9:5
   6   	};
   7   	
   8   	pub fn main() void {
-> 9   	    const user = User{ .power = 9001, .name = "Goku" };
   10  	    std.debug.print("{s}'s power is {d}\n", .{ user.name, user.power });
   11  	}
(lldb) n
Process 114579 stopped
* thread #1, name = 'main', stop reason = step over
    frame #0: 0x0000000001150a48 main`main.main at main.zig:10:20
   7   	
   8   	pub fn main() void {
   9   	    const user = User{ .power = 9001, .name = "Goku" };
-> 10  	    std.debug.print("{s}'s power is {d}\n", .{ user.name, user.power });
   11  	}
(lldb) p user
(main.main.User) {
  .power = 9001
  .name = len=4 {
    [0] = 71
    [1] = 111
    [2] = 107
    [3] = 117
  }
}
(lldb)
1 Like

Thank you very much for the pointer! I tried to build the custom zig-specific LLDB and I hit some issues. Here is what I did:

  1. git clone --depth=1 git@github.com:jacobly0/llvm-project.git zig-llvm-project
  2. git checkout lldb-zig
  3. mkdir ~/projects/zig-llvm-project-build/
  4. cd ~/projects/zig-llvm-project-build/
  5. cmake -B ~/projects/zig-llvm-project/llvm-build -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;lldb" -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ~/projects/zig-llvm-project/llvm
  6. cd ~/projects/zig-llvm-project/llvm-build
  7. make -j4

Now, I got the following error. I’m not sure if you have ever seen the issue before?

EDIT: it seems someone else hit the same issue. I was wondering which branch and commit you get a successful compilation? I would like to have those to try again. Thank you!

In file included from /usr/include/c++/9/utility:70,
                 from /usr/include/c++/9/tuple:38,
                 from /home/zeyuanhu/projects/zig-llvm-project/llvm/include/llvm/ADT/DenseMapInfo.h:20,
                 from /home/zeyuanhu/projects/zig-llvm-project/lldb/include/lldb/Utility/ConstString.h:12,
                 from /home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/ZigValue.h:12,
                 from /home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.h:12,
                 from /home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:9:
/usr/include/c++/9/bits/stl_pair.h: In instantiation of ‘struct std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE>’:
/usr/include/c++/9/ext/aligned_buffer.h:91:28:   required from ‘struct __gnu_cxx::__aligned_buffer<std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE> >’
/usr/include/c++/9/bits/hashtable_policy.h:233:43:   required from ‘struct std::__detail::_Hash_node_value_base<std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE> >’
/usr/include/c++/9/bits/hashtable_policy.h:279:12:   required from ‘struct std::__detail::_Hash_node<std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE>, false>’
/usr/include/c++/9/bits/hashtable_policy.h:2027:13:   required from ‘struct std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE>, false> > >’
/usr/include/c++/9/bits/hashtable.h:173:11:   required from ‘class std::_Hashtable<lldb_private::ZigScope*, std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE>, std::allocator<std::pair<lldb_private::ZigScope* const, lldb_private::plugin::dwarf::DWARFDIE> >, std::__detail::_Select1st, std::equal_to<lldb_private::ZigScope*>, std::hash<lldb_private::ZigScope*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, false> >’
/usr/include/c++/9/bits/unordered_map.h:1254:18:   required from ‘class std::unordered_multimap<lldb_private::ZigScope*, lldb_private::plugin::dwarf::DWARFDIE>’
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserZig.h:102:7:   required from here
/usr/include/c++/9/bits/stl_pair.h:215:11: error: ‘std::pair<_T1, _T2>::second’ has incomplete type
  215 |       _T2 second;                /// @c second is a copy of the second object
      |           ^~~~~~
In file included from /home/zeyuanhu/projects/zig-llvm-project/lldb/include/lldb/Core/Module.h:17,
                 from /home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.h:14,
                 from /home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:9:
/home/zeyuanhu/projects/zig-llvm-project/lldb/include/lldb/Symbol/TypeSystem.h:41:7: note: forward declaration of ‘class lldb_private::plugin::dwarf::DWARFDIE’
   41 | class DWARFDIE;
      |       ^~~~~~~~
[ 82%] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/GISel/X86LegalizerInfo.cpp.o
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In function ‘llvm::Align MaxIntAlignment(lldb_private::ArchSpec)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:1030:1: warning: control reaches end of non-void function [-Wreturn-type]
 1030 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘virtual bool lldb_private::TypeSystemZig::IsAggregateType(lldb::opaque_compiler_type_t)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2256:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
 2256 |     switch (llvm::cast<ZigPointerType>(zig_type)->GetSize()) {
      |     ^~~~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2264:3: note: here
 2264 |   case ZigValue::Kind::OptionalType:
      |   ^~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2276:1: warning: control reaches end of non-void function [-Wreturn-type]
 2276 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘virtual bool lldb_private::TypeSystemZig::IsScalarType(lldb::opaque_compiler_type_t)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2509:1: warning: control reaches end of non-void function [-Wreturn-type]
 2509 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘virtual uint32_t lldb_private::TypeSystemZig::GetTypeInfo(lldb::opaque_compiler_type_t, lldb_private::CompilerType*)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2616:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
 2616 |     }
      |     ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2618:3: note: here
 2618 |   case ZigValue::Kind::ArrayType:
      |   ^~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2636:1: warning: control reaches end of non-void function [-Wreturn-type]
 2636 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘virtual lldb::TypeClass lldb_private::TypeSystemZig::GetTypeClass(lldb::opaque_compiler_type_t)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2683:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
 2683 |     switch (llvm::cast<ZigPointerType>(zig_type)->GetSize()) {
      |     ^~~~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2691:3: note: here
 2691 |   case ZigValue::Kind::ArrayType:
      |   ^~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:2710:1: warning: control reaches end of non-void function [-Wreturn-type]
 2710 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘virtual lldb::Encoding lldb_private::TypeSystemZig::GetEncoding(lldb::opaque_compiler_type_t, uint64_t&)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:3064:1: warning: control reaches end of non-void function [-Wreturn-type]
 3064 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘virtual lldb::Format lldb_private::TypeSystemZig::GetFormat(lldb::opaque_compiler_type_t)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:3136:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
 3136 |     switch (llvm::cast<ZigPointerType>(zig_type)->GetSize()) {
      |     ^~~~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:3144:3: note: here
 3144 |   case ZigValue::Kind::ErrorSetType:
      |   ^~~~
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:3149:1: warning: control reaches end of non-void function [-Wreturn-type]
 3149 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘bool lldb_private::TypeSystemZig::DumpValue(lldb_private::ZigValue*, lldb_private::Stream&)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:4135:1: warning: control reaches end of non-void function [-Wreturn-type]
 4135 | }
      | ^
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp: In member function ‘bool lldb_private::TypeSystemZig::DumpTypeDecl(lldb::opaque_compiler_type_t, lldb_private::Stream&)’:
/home/zeyuanhu/projects/zig-llvm-project/lldb/source/Plugins/TypeSystem/Zig/TypeSystemZig.cpp:4395:1: warning: control reaches end of non-void function [-Wreturn-type]
 4395 | }
      | ^
make[2]: *** [tools/lldb/source/Plugins/TypeSystem/Zig/CMakeFiles/lldbPluginTypeSystemZig.dir/build.make:79: tools/lldb/source/Plugins/TypeSystem/Zig/CMakeFiles/lldbPluginTypeSystemZig.dir/TypeSystemZig.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:153611: tools/lldb/source/Plugins/TypeSystem/Zig/CMakeFiles/lldbPluginTypeSystemZig.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 82%] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/GISel/X86RegisterBankInfo.cpp.o
[ 82%] Linking CXX static library ../../libLLVMX86CodeGen.a
[ 82%] Built target LLVMX86CodeGen
make: *** [Makefile:156: all] Error 2
1 Like

Mine was compiled on March 3rd, d95039d, this commit is not available now. The issue you linked was reported on Feb 1st, so I think the issue is not in lldb-zig.

/usr/include/c++/9/

Your gcc is kinda old, I think the problem is in compiler’s std. I used gcc 14 to compile the debugger. I will try to compile latest commit again, will report the results later, it will take a while :grin:

EDIT: build is successful, so I would blame old gcc.

1 Like

Interesting. On macos ( 15.5 (24F74) ) and the following build script I also got an error.

➜  projects cat build-lldb-zig
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

LLVM_REPO_URL="https://github.com/jacobly0/llvm-project.git"
LLVM_SRC_DIR="./llvm-project"
LLVM_BLD_DIR="./llvm-project-build"
INSTALL_PREFIX="$HOME"
KNOWN_GOOD_COMMIT="d95039d"

# Clone if missing
if [[ ! -d "$LLVM_SRC_DIR" ]]; then
  echo "Cloning LLVM project..."
  git clone "$LLVM_REPO_URL" "$LLVM_SRC_DIR"
fi

cd "$LLVM_SRC_DIR"

# Ensure we're on lldb-zig branch
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$CURRENT_BRANCH" != "lldb-zig" ]]; then
  echo "Switching to branch lldb-zig..."
  git fetch origin lldb-zig
  git checkout lldb-zig
fi

# Ensure full history is available
if [[ $(git rev-parse --is-shallow-repository) == "true" ]]; then
  echo "Fetching full git history..."
  git fetch --unshallow
fi

cd ..

# Recreate build dir
if [[ -d "$LLVM_BLD_DIR" ]]; then
  echo "Removing old build directory..."
  rm -rf "$LLVM_BLD_DIR"
fi

echo "Configuring LLVM build..."
cmake -S "$LLVM_SRC_DIR/llvm" -B "$LLVM_BLD_DIR" -G Ninja \
  -DLLVM_ENABLE_PROJECTS="clang;lldb" \
  -DLLVM_INCLUDE_TESTS=OFF \
  -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
  -DLLDB_USE_SYSTEM_DEBUGSERVER=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \
  -DLLDB_ENABLE_PYTHON=OFF

# Build full LLVM
echo "Building all..."
ninja -C "$LLVM_BLD_DIR"

# Build lldb-vscode
echo "Building lldb-vscode..."
ninja -C "$LLVM_BLD_DIR" lldb-vscode

# Install
echo "Installing..."
ninja -C "$LLVM_BLD_DIR" install

echo "Done."

Error:

-- Generating done (5.2s)
-- Build files have been written to: /Users/dmitrymedvedev/projects/llvm-project-build
Building all...
ninja: Entering directory `./llvm-project-build'
[2586/6517] Linking CXX static library lib/libclangCodeGen.a
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'AMDGPU.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/AMDGPU.cpp.o(AMDGPU.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/AMDGPU.cpp.o(AMDGPU.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'ARM.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/ARM.cpp.o(ARM.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/ARM.cpp.o(ARM.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'DirectX.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/DirectX.cpp.o(DirectX.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/DirectX.cpp.o(DirectX.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'Hexagon.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/Hexagon.cpp.o(Hexagon.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/Hexagon.cpp.o(Hexagon.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'NVPTX.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/NVPTX.cpp.o(NVPTX.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/NVPTX.cpp.o(NVPTX.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'PPC.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/PPC.cpp.o(PPC.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/PPC.cpp.o(PPC.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'RISCV.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/RISCV.cpp.o(RISCV.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/RISCV.cpp.o(RISCV.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'SPIR.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/SPIR.cpp.o(SPIR.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/SPIR.cpp.o(SPIR.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'SystemZ.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/SystemZ.cpp.o(SystemZ.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/SystemZ.cpp.o(SystemZ.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'WebAssembly.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/WebAssembly.cpp.o(WebAssembly.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/WebAssembly.cpp.o(WebAssembly.cpp.o)'
/Library/Developer/CommandLineTools/usr/bin/libtool: warning duplicate member name 'X86.cpp.o' from 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetBuiltins/X86.cpp.o(X86.cpp.o)' and 'tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/X86.cpp.o(X86.cpp.o)'
[2685/6517] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerType.cpp.o
FAILED: [code=1] tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerType.cpp.o
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/dmitrymedvedev/projects/llvm-project-build/tools/lldb/source/Symbol -I/Users/dmitrymedvedev/projects/llvm-project/lldb/source/Symbol -I/Users/dmitrymedvedev/projects/llvm-project/lldb/include -I/Users/dmitrymedvedev/projects/llvm-project-build/tools/lldb/include -I/Users/dmitrymedvedev/projects/llvm-project-build/include -I/Users/dmitrymedvedev/projects/llvm-project/llvm/include -I/Users/dmitrymedvedev/projects/llvm-project/llvm/../clang/include -I/Users/dmitrymedvedev/projects/llvm-project-build/tools/lldb/../clang/include -I/Users/dmitrymedvedev/projects/llvm-project/lldb/source -I/Users/dmitrymedvedev/projects/llvm-project-build/tools/lldb/source -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/libxml2 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -MD -MT tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerType.cpp.o -MF tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerType.cpp.o.d -o tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerType.cpp.o -c /Users/dmitrymedvedev/projects/llvm-project/lldb/source/Symbol/CompilerType.cpp
/Users/dmitrymedvedev/projects/llvm-project/lldb/source/Symbol/CompilerType.cpp:971:28: error: out-of-line definition of 'GetStringPointer' does not match any declaration in 'lldb_private::CompilerType'
  971 | ValueObject *CompilerType::GetStringPointer(ValueObject *valobj,
      |                            ^~~~~~~~~~~~~~~~
1 error generated.
[2698/6517] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/SymbolContext.cpp.o
ninja: build stopped: subcommand failed.

If you’re looking for a debugging solution that ‘just works’ and you can tolerate VSCode, try the CodeLLDB plugin:

…with a .vscode/launch.json like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}/zig-out/bin/cube",
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}

…replace cube with your executable name in the zig-out/bin directory.

1 Like

I remember getting error like yours when system LLVM headers were included instead. I don’t have a MacOS device, so sadly I can’t look into this.

@floooh CodeLLDB uses upstream LLDB which is usually good enough for debugging (same thing goes for GDB) but sometimes, like in the case original poster presented, fails. By the way, this was 4 months ago, so maybe things are better today :grin:

1 Like