GDB inherits the environment variables from your shell. Some environment variables, like LD_LIBRARY_PATH, might not be inherited for safety reasons. This can cause errors like this when you try to debug:
$ gdb --args ./a.out
/path/to/a.out: error while loading shared libraries: libfoobar.so.5: cannot open shared object file: No such file or directory
You can set the LD_LIBRARY_PATH environment variable at the gdb shell using the set env command like this:
(gdb) set env LD_LIBRARY_PATH /path/to/1:/path/to/2
However, if you use a shell like Fish, you will notice that this will silently not work and you still get the cannot open shared object file error.
This is because under the covers, gdb is reading the SHELL environment variable to understand what is the shell and doing what is right for that shell. It might not understand how to work with the Fish, which is a relatively new shell.
The solution that works for me, is to set the SHELL variable at the Fish shell to the Bash path:
$ set SHELL (which bash)
And then launch gdb and set the environment variable as shown above. It works after that.
I processed a JSON file using some tool and the resulting JSON text file would not be accepted by other tools. They would complain that this was a UTF-8 Unicode (with BOM) text file. I had to remove whatever this BOM was from my UTF-8 file.
BOM is a byte order mark added by some tools to UTF-8 files. BOM is this 3-byte sequence: 0xEF,0xBB,0xBF.
You could use any tool or process to remove these 3-byte sequences. If you are on Linux, the awesome sed tool can do the job:
A problem I face regularly with GDB is the backtrace. The stack trace lists out the function frames currently on the stack and it is a wall of text. it is hard to discern the function address, function name, function parameters, source file path and line number.
This is precisely the problem that GDB Colour Filter solves. Clone its repo and source its Python file inside your ~/.gdbinit and you are set. Backtraces are now printed with distinctly different colors and formatting for all the components of a function frame. I especially find it useful to pick out the function name and the source file and line number.
There is only one slight problem: to display the components of a function frame at a consistent column this breaks down a frame into two lines. So your backtrace lines are doubled and might fill up the display when you try this.
A team member shared a Google Form for me to fill out. Strangely that form URL could not open in Firefox. It would not load with this error:
The page isn’t redirecting properly
An error occurred during a connection to docs.google.com.
This problem can sometimes be caused by disabling or refusing to accept cookies.
I did not have any setting in Firefox to disable or refuse some cookies. So that error was wrong. But it gave a hint that the problem might be caused by cookies.
I went into the Firefox options and deleted all cookies involved with the URL google.com. There is no need to delete all cookies, just those that have this URL. Once I did that, the Google Form URL opened correctly.
Makefiles and especially recursive Makefiles can be hard to understand and debug. But the good old debugging method of printing out values from certain locations in the source code can be employed here too.
To print a message when make parses past that location in the Makefile:
$(info Hello World Make just parsed past this line)
Note that make typically parses a file twice before it executes what is needed to satisfy its targets. So, you will see the message you are printing twice.
To print the value of a make variable at a certain location in the Makefile:
CDex is a Windows tool for ripping audio tracks from audio CDs to WAV or MP3 files. This is a great utility for ripping the audio CD collection gathering dust in your attic and converting them for playing on devices without a CD/DVD drive.
CDex is straightforward to use:
Insert your audio CD into a drive connected to your Windows computer. Its tracks will appear listed in CDex.
You can pull the artist/album/track info from FreeDB using the CDDB → Read remote FreeDB option. You would need to provide an email address in the Settings before this can work.
To rip to MP3, use the Extract CD tracks to Compressed Audio Files option on the right. This uses the LAME MP3 Encoder, which is installed along with CDex.
You can configure the directory and filename format for the ripped MP3 files in the settings.
However, depending on your version of Ubuntu, the CMake version that is installed might be very old. So, you might run into problems when you build projects that use features from more recent versions of CMake.
CMake provides binary versions for Linux x86_64. Installing the latest version of CMake from these packages is easy:
Remove the Ubuntu version of CMake:
$ sudo apt remove cmake cmake-data
Download the .sh binary package of the CMake version you want from here. When I downloaded, I got cmake-3.14.0-Linux-x86_64.sh
Move the downloaded package to /opt and execute it:
Growth factor is the factor by which the new size of a C++ STL vector is computed when we need to insert beyond its current capacity. There are containers similar to the STL vector in other languages and it is quite interesting to see what factors were chosen in those implementations.
The last time I looked into this (see this post), VC++ vector had a growth factor of 1.5 and GCC vector had a growth factor of 2.
Java ArrayList seems to have a growth factor of 1.5. See line 240 in ArrayList.java.