Category : 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() ..

Read more

I try to build the GNU Debugger on Windows 64 bit and for Windows 32 bit. Therefore I used MSYS2 as proposed on https://sourceware.org/gdb/wiki/BuildingOnWindows. Unfortunately I ran into the following error: make[4]: *** [Makefile:509: as.info] Error 1 make[4]: Leaving directory ‘/c/GIT/binutils-gdb-WIN/gas/doc’ make[3]: *** [Makefile:1283: all-recursive] Error 1 make[3]: Leaving directory ‘/c/GIT/binutils-gdb-WIN/gas’ make[2]: *** [Makefile:819: all] ..

Read more

I was working with code to include rapidjson headers in my server application. When I compiled, it was ok. but when some other library part in the application was running, it turned out to be dead with gdb core file. #0 0x00007f36c614e922 in rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>::Malloc (this=0x7f36a4037700, size=256) at ../../common/include/rapidjson/allocators.h:321 321 RAPIDJSON_NOEXCEPT_ASSERT(shared_->refcount > 0); … #17 0x00007f36c57999cb ..

Read more

Sometimes there is a function in my binary that I’m sure hasn’t been optimized away, because it’s called by another function: (gdb) disassemble ‘k3::(anonymous namespace)::BM_AwaitLongReadyChain(testing::benchmark::State&)’ Dump of assembler code for function k3::(anonymous namespace)::BM_AwaitLongReadyChain(testing::benchmark::State&): […] 0x00000000003a416d <+45>: call 0x3ad0e0 <k3::(anonymous namespace)::RecursivelyAwait<k3::(anonymous namespace)::Immediate17>(unsigned long, k3::(anonymous namespace)::Immediate17&&)> End of assembler dump. But if I ask GDB to disassemble ..

Read more

Using gdb 11.1, I tried to use this trick : calling operator<< in gdb to print a custom type that has an overloads to print it graphically. However, I get a segfault calling it (by the way, it works very well when called from the program and not gdb…) while trying to track this, I ..

Read more

I want to print some information from gdb but don’t see how. I am used to p/s p/x formats. But don’t know what to do in the case below. #include<iostream> #include<climits> #include <stdio.h> #include <time.h> #include <stdint.h> using namespace std; int main() { time_t dataFrom = 1234560; cout << "dataFrom = " << asctime(gmtime(&dataFrom)) << ..

Read more