Unable to use breakpoints and other features in lldb [duplicate] - c

I'm on Windows 10, compiled llvm 11 with MSVC 16.
This is main.cpp:
#include <iostream>
int main()
{
std::cout << "Hello world" << std::endl;
}
These are the commands I run
clang -g -O0 main.cpp -o a.exe
lldb a.exe
(lldb) target create "a.exe
Current executable set to 'C:\a.exe' (x86_64).
(lldb) b main.cpp:5
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) b main
Breakpoint 2: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) breakpoint set --name main
Breakpoint 3: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
What am I doing wrong?

I succeeded by recompiling llvm with these detailed instructions for compiling lldb on windows.
Specifically:
Installed Visual Studio sdk for Visual Studio Community 2019
Installed the latest Windows 10 sdk
Registered the Debug Interface Access DLLs with regsvr32 (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\msdia140.dll and C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll)

Related

How to set a breakpoint for ClickHouse code?

I am building ClickHouse like this:
$ cmake -DCMAKE_C_COMPILER=$(which clang-14) -DCMAKE_CXX_COMPILER=$(which clang++-14) -DCMAKE_BUILD_TYPE=Debug ..
Launching debugger
$ lldb ./clickhouse -- server
Current executable set to '/home/user/ClickHouse/build/programs/clickhouse' (x86_64).
Trying to set a breakpoint
$ breakpoint set --file /home/user/ClickHouse/src/Storages/MergeTree/MergeTreeData.cpp --line 3564
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
But unable to do it. How to set a breakpoint?
Versions:
Commit 075bcf3f5fce73f8f554a5c132730d0f79c77707
Ubuntu 20.04.2 LTS
lldb version 10.0.0
Ubuntu clang version 14.0.0-++20220309053128+569b773323a3-1~exp1~20220309053228.98
cmake version 3.16.3
ninja version 1.10.0

Cannot debug executable with lldb on macOS M1: attach failed ((os/kern) invalid argument

I am trying to debug a C executable compiled for arm64 on an Apple M1 MacBook Pro, running macOS Monterey. However, when I try to run the program in lldb, I receive the following error:
(lldb) run
error: process exited with status -1 (attach failed ((os/kern) invalid argument))
To debug an arm64 executable on a system running Rosetta, you need to explicitly run lldb within the arm64 architecture. To do this:
arch -arm64 lldb ./your-program

Unresolved Inclusions in Eclipse-Cygwin- #include <stdio.h>

I have been trying to test a program using cygwin64 (on Windows 10 and Eclipse 20-21) because my target is a Linux Realtime system, I have installed cygwin64 and as per this document (https://www.eclipse.org/4diac/documentation/html/installation/cygwin.html) . I have to add environment in windows
still my inclusion #include<stdio.h>, #include <stdlib.h> etc says unresolved
I checked if Cygwin is installed by going to cmd and giving bash. which returned correctly
My path variables are like this
My toolchain settings are like this
This is my build report
15:52:34 **** Incremental Build of configuration Debug for project udpexx1 ****
Info: Internal Builder is used for build
gcc "-IC:\\cygwin64" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\udpexx1.o" "..\\src\\udpexx1.c"
Cannot run program "gcc": Launching failed
Error: Program "gcc" not found in PATH
PATH=[C:\cygwin64\bin]
15:52:34 Build Finished. 0 errors, 0 warnings. (took 94ms)
#####################################################################
Is there anything that im missing or need to do?
my run configurations are like this

LLDB warning : Unable to resolve the breakpoint location

I am trying to debug a program with lldb and clang.
Error is thrown
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations
I am trying it on Windows 10 and have latest version of clang (8.0)
I am trying with a command to compile a program with this clang -g -O0 test.c -o test and to debug I am giving lldb test and for breakpoint
b test.c:3
I am actually looking for debug information . But nothing seems to be working fine...any solution for this ?
I tried the same thing on ubuntu , with same command and everything works correctly.
I think Windows version of LLDB still under development.

Debugging C with Code::Blocks

I made my code as a standalone .c file and read that, in order to debug, the file must be in a project. So I made an empty project and added my file to it, set some breakpoints and, when i run the debugger, I get this on console:
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 13112
Error in re-setting breakpoint 2: PC register is not available
Error in re-setting breakpoint -3: PC register is not available
In ()
Tried some tutorials and whatched some videos without success. Does somebody knows a fix for that? Is there a simpler way to debug a .c file?
For linux system you could use gdb as debugger in this way:
$ vim hello.c
# include <stdio.h>
int main()
{
printf("hello \n");
}
$ gcc -o hello hello.c
$ ./hello
$ gdb hello
(gdb) break main
(gdb) run
and then you can use:
c or continue
n or next
s or step
For more details see this.
Updated MinGW downloading it from its sourceforge repositor.
Downloaded the 6.2.0 version that is available in this link.
Then I unziped it to C:\ and modified the environment variable Path to add the new C:\MinGW\bin folder. To know if you made it correctly just open CMD and type gcc --version.
After that, I modified the compiller and debugger settings of Code::Blocks to use the new version of MinGW and its executables.
Now it is compiling and debugging properly.
According to Free Pascal's GDB Debugger Tips the problem is with GDB and they cite Bug 14018.
It appears you should use a different version of GDB. They suggest downgrading to 7.2. Now I believe other versions are now available, like 8.0. I don't know if GDB 8.0 suffers it too.

Resources