Information About C++ Debugging

Asked 2 years ago, Updated 2 years ago, 69 views

We are currently creating computer shogi by referring to the website here.
This time, I would like to ask you how to debug C++.Ideally, I'd like to stop using the Rails term binding.pry and see what's inside the variable.

So I had an urge to debug from the command line, so I tried debugging chapter 2 of this site using lldb which says mac is standard.Here's the command you typed.

After compiling with makefile,

lldb./shogi
bkyokumen.c:29
r

I wanted to set the breakpoint and stop on line 29 of kyokumen.c, but I don't know if the shogi program started and stopped like when I typed the ./shogi command normally.

I would like to stop my ideal as follows.

(lldb)r
Process 93890 launched: '/Path/To/hoge' (x86_64)
Process 93890 stopped
* thread#1:tid=0x53c0ae,0x0000000100000f23 hoge`main(argc=1,argv=0x00007ffff5ffff460)+51 athoge.c:6,queue='com.apple.main-thread', stop reason=breakpoint1.1
    frame#0:0x0000000100000f23 hoge`main(argc=1,argv=0x00007ffff5ffbff460) +51 athoge.c:6
   3 int main(intargc, char**argv){
   4 char*test = "This is a debug demo.";
   5 char*name = "edo";
->6 intage=20;
   7
   8 printf("Name:%s, Age:%d\n", name, age);
   9
(lldb)

Please let me know if there is any solution.

c++ macos

2022-09-30 10:28

1 Answers

What compiler do you use? If you do not compile with debug information with options such as -g, you will not be able to stop at the breakpoint.


2022-09-30 10:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.