Yearly Archives: 2017


A small note on how we use valgrind

valgrind is a suite of tools for debugging and profiling programs.
We use it for debugging and profiling Linux executable files.

Despite the fact that it can do a whole lot of stuff, usually we use it as follows (when we do not forget) to test our applications for memory leaks:

valgrind --show-leak-kinds=all --leak-check=full $application $application_arguments;

The options we chose are the following:

  • --show-leak-kinds=all It will show all leaks (definite, indirect, possible, reachable) in the full leak search (see next bullet)
  • --leak-check=full this option instructs valgrind to search for memory leaks when the client program finishes.
    Each individual leak will be shown in detail and be counted as an error.

These options are extremely useful as they will catch a lot of little leaks that you might have missed (e.g. closing a file, freeing some memory, …)


List available functions in a shared library .so file

Recently, we wanted to see if a certain function call was available in a shared library (.so).

To do so we used the command nm.
nm lists symbols from object files.

We used the command nm -D /libs/mylib.so.1.
The parameter -D (or --dynamic) displays the dynamic symbols rather than the normal symbols.  (This is only meaningful for dynamic objects, such as certain types of shared libraries.)

We got a huge list which was similar to this

...
000000000000e6e0 T sudo_SHA512Update
000000000000eb20 T sudo_sig2str
000000000000b970 T sudo_strlcat
000000000000b910 T sudo_strlcpy
0000000000006f60 T sudo_strsplit_v1
00000000000070a0 T sudo_strtobool_v1
0000000000007330 T sudo_strtoid_v1
0000000000007570 T sudo_strtomode_v1
000000000000bb20 T sudo_strtonum
000000000000ac20 T sudo_term_cbreak_v1
000000000000adb0 T sudo_term_copy_v1
000000000021339c B sudo_term_erase
00000000002133a0 B sudo_term_kill
000000000000a920 T sudo_term_noecho_v1
000000000000aa80 T sudo_term_raw_v1
000000000000a860 T sudo_term_restore_v1
00000000000052a0 T sudo_vfatal_nodebug_v1
00000000000052d0 T sudo_vfatalx_nodebug_v1
0000000000005480 T sudo_vwarn_nodebug_v1
00000000000054b0 T sudo_vwarnx_nodebug_v1
00000000000055c0 T sudo_warn_gettext_v1
00000000000052f0 T sudo_warn_nodebug_v1
00000000000055a0 T sudo_warn_set_conversation_v1
...

We filtered out all elements that had the value T or t on the second column as those objects are symbol in the text (code) section and we found the function call we wanted there!


Fedora 25 with GNOME 3: Making a Wi-Fi hotspot 7

Recently we tried to create a Wi-Fi hotspot on Fedora 25 running GNOME 3.

When we clicked on the Use as Hotspot... button  on the network manager it did not activate the hotspot.
Actually, nothing changed after we clicked on the button.
We tried this several times, some while being disconnected from all networks, others with having the Wi-Fi device disabled etc. None of the tests payed out.

To mitigate the problem, we used nm-connection-editor to create the hotspot configuration and then activate it from the network manager.

After we starter nm-connection-editor, we pressed the Add button to create a new configuration:

From the prompt, we selected the option Wi-Fi and then clicked on the Create... button.

In the newly appeared window, we filled in

  • the Connection name (which is not used by the system, it is only for us to identify which configuration this is),
  • then the SSID (which is the name of the network you will create and connect to),
  • we set Mode to Hotspot

Then we switched to the Wi-Fi Security tab where we filled in the type of protection we want the hotspot to have and the password for it.

We clicked Save and then we closed the Network Connections window as well.

From the network manager, we clicked on Use as Hotspot... button and then the Turn On button on the confirmation popup to finish the activation.

After this, the network manager changed its screen and showed a page which had all the necessary information that are needed to connect to our newly created hotspot.

Note:

In case you cannot connect because the password verification fails even though you are providing the correct password, you can always do the ugly hack of setting up a hotspot with no security to get your job done…


Git: Create a branch on your local machine, switch to it and then push it on the server

Following are a couple of simple commands that we use daily to create a new branch on git and push it to the git server.

The following command will create locally a new branch called branch_name and switch to it.

git checkout -b branch_name;

The following command will push the local branch you are currently switched to on the git server.
It will be made available to the server using the name branch_name.

git push --set-upstream origin branch_name;