1

How to create c++ object via new operator in gdb.
I am looking for something similar to

option-1) (gdb) call new ClassType()
or
option-2) (gdb) set $obj = new ClassType()

But both of these options failing in gdb.

sunil
  • 491
  • 4
  • 10

1 Answers1

1

Try this way:

set var $new = malloc(sizeof(class ClassType))
call ClassType::ClassType($var)
  • Also see https://stackoverflow.com/questions/7060099/how-to-call-constructor-in-gdb-for-pretty-printers if that didn't work – jpalecek Jul 18 '23 at 01:25