samedi 23 octobre 2021

Passing a String into a Function With GDB

So, I have a function with the prototype according to GDB: {std::string (std::string)} 0x56027729e545 <function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)> , and I would like to pass a string into it using GDB. To attempt this, I've used the following GDB commands to create a new string on the heap.

set $mystr = (std::string*) malloc(sizeof(std::string))
call $mystr->basic_string()
call mystr->assign("foobar")
call (std::string) function(*$mystr)

In the last line, I am getting the error Couldn't find method std::string::std::string. Any ideas?

Unfortunately, I can't modify the code to fix this.

Aucun commentaire:

Enregistrer un commentaire