C ++ debugging compared to C debugging

Hi

I am usually a C programmer. I regularly debug C programs in unix using tools like gdb, dbx. I have never debugged large C ++ applications. This is very different from how we are debugging C. Theoretically, I am pretty good at C ++, but I have never had the opportunity to debug C ++ programs. I am also not sure about the technical issues that we encounter in C ++ that will force the developer to enable the debugger to figure out the problem. what are the common problems we face in C ++ that will run the debugger.

What are the problems that a c programmer may encounter while debugging a C ++ program? Is it complicated and complicated compared to C?

+3
source share
6 answers

This is basically the same.

Remember that when setting breakpoints manually, you need to fully qualify the method name with both the namespace and the class (as resul, someti es it is easier to use line numbers to define breakpoints)

Remember that calls to destructors are invisible at the source, but you can step through them at the end of the block.

+5
source

A few minor differences:

When entering a fully functional character, such as foo::bar::fum(args)in the gdb shell, you need to start with a single quotation mark for gdb to recognize it and calculate the completion.

, . std::vector, std::map .

, ++, , , . , shared_ptr, , . .

, , readline, . ( "foo" ? ? ?)

+2

GDB ++, , , ++ ( , - ), ( , , C). ...

+1

, , ..:

  • .
  • - - , setjmp/longjmp
  • - obj1 == obj2, POD,

, , , / get; [obj-name]. [var-name] .

+1

GDB ++. /.

, stl- gdb. std::string , . std::map , , .

/ ​​ .

stl ​​ gdb 7.0.

boost. gdb, shared_ptr.

, , ++ , .

+1

++ . , ( ), , "" ( ). , ++ ( ).

: - , . . , , .

It also gives you the advantage that you can "debug" problems offline later after your program is sent to end users.

0
source

Source: https://habr.com/ru/post/1750126/


All Articles