From last few days , I have been working on a bug in JSON Server of Drizzle. And the bug is of Segmentation fault , which is not easy to recognize by just reading the code-base. So , the best way to get rid of this problem is to debug the code. But How ?
I used Visual Studio once during my internships to debug a project. So ,I tried to find out some IDEs that can be use with drizzle . But I figured it out as we can debug a C++ code-base easily and efficiently with GDB .
Here are few steps for debugging:
First of all build your server and enable debugging:
Start server and debug the code:
b <filename>:<line-number> or break <filename>:<line-number>
Run your server now :
List of these commands are mentioned here.
Problem Faced :
Once I started drizzle server with plugin. I got a message:
I was unable to get a single line of this problem, Thank to Henrik for solution.
Solution:
Toru and Padraig previously posted on this topic which may also be helpful.
Also You can find documentation on this at Drizzle wiki.
I used Visual Studio once during my internships to debug a project. So ,I tried to find out some IDEs that can be use with drizzle . But I figured it out as we can debug a C++ code-base easily and efficiently with GDB .
Here are few steps for debugging:
First of all build your server and enable debugging:
mohit@mohit-PC:~$ cd repos/drizzle/drizzle-json_server/
mohit@mohit-PC:~/repos/drizzle/drizzle-json_server$ ./config/autorun.sh && ./configure --with-debug && make install -j2
Default installation path is /usr/local/ but you can change it with --prefix = /installation_path/Start server and debug the code:
mohit@mohit-PC:~/repos/drizzle/drizzle-json_server$ gdb /usr/local/sbin/drizzled >
Now set arguments needed to start server with specific plugin (In my case , plugin is json_server)(gdb) set args --plugin-add=json_server
Set breakpoints,you can do that with this command:b <filename>:<line-number> or break <filename>:<line-number>
(gdb) break json_server.cc:1093
Since the json_server plugin is not loaded yet , hence it prompts with :No source file named json_server.cc.
Make breakpoint pending on future shared library load? (y or [n])
Go with "y"Run your server now :
(gdb) r
You will get something like this:Starting program: /usr/local/sbin/drizzled --plugin-add=json_server
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Now you can use various commands of GDB to debug your code.List of these commands are mentioned here.
Problem Faced :
Once I started drizzle server with plugin. I got a message:
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
/usr/local/sbin/drizzled: relocation error: /usr/local/sbin/drizzled: symbol _ZN8drizzled7message6AccessC1Ev, version DRIZZLE7 not defined in file libdrizzledmessage.so.0 with link time reference
[Inferior 1 (process 23532) exited with code 0177]
I was unable to get a single line of this problem, Thank to Henrik for solution.
Solution:
mohit@mohit-PC:~$ sudo rm /etc/ld.so.cache
mohit@mohit-PC:~$ ldconfig
Toru and Padraig previously posted on this topic which may also be helpful.
Also You can find documentation on this at Drizzle wiki.