Typically, we receive customer tickets regarding crashes or bugs, where we request a core dump to analyze and identify the root cause or understand the unexpected behavior. To read the core dumps, we also request the linked libraries used by the server’s MySQL. However, there’s a more efficient way to achieve our goal: by using the same operating system as the customer and installing MySQL and the necessary libraries. We generally use Docker for this purpose. While installing all the debugging tools in the Docker container is straightforward, it adds extra steps to the debugging process.
We primarily use GDB as our debugging tool. However, after reading a blog post by my colleague Jinyou Ma, “Debugging MySQL Core File in Visual Studio Code,” I began exploring whether using Visual Studio Code to debug a core dump from Docker was possible. I found the following extension: https://code.visualstudio.com/docs/remote/remote-overview, which allows you to connect to a container or a remote machine to use as a developer environment.
Once the installation is complete, you will see the following icon on the sidebar in Visual Studio:
In the dropdown menu above, you can change the connection settings for Tunnels/SSH or Dev Containers:
In this case, we will select dev containers and log in to the CentOS:7 container named “blog.”
After joining, the container will indicate that no workspace has been created and prompt you to open a folder. In this case, we are selecting the folder /mnt/blog, which is mounted to point to the core dump folder on the host:
Once the folder in the above request loads, we can see that we are in the container blog, located in the folder /mnt/blog, which contains the core.0001 core dump file:
Some steps are covered in the blog post mentioned above by my colleague Jinyou Ma. Please refer to it in case of doubts, as I will not present them in this case. We are now installing the necessary extensions for C/C++, the mysqld binary, and its debug info.
We then created a JSON configuration file similar to the one presented in the previous blog, allowing us to start debugging the core dump file.
Now that everything is prepared, we can examine the core dump.
Conclusion
While the general steps remain similar to those in the previous blog post, configuring the debug on the Docker container simplifies the process once the required libraries are installed during the MySQL installation.