Blog overview

Latest entries:

2021-07-12: Debug symbol download in gdb

Since I had OpenSuse tumbleweed running on my laptop, I noticed an issue with gdb downloading quite a lot of debugging symbols. I did not know why it happens, nor where it loads the symbols from, nor how to stop it from doing so.

Due to the nature of a rolling linux distribution, base packages get updated quite often. So the debug symbols for many base libraries need to be downloaded again and again for every update which is really annoying.

I can see that there are use cases where it helps to have access to debug symbols from build servers, but I don't know why it is enabled by default. It is very hard for users to see what is happening, why gdb accesses some server the user did not configured, storing data on some unknown location, and how to stop.

I personally don't need that functionality at all and it gets in my way more often than not. When debugging a locally built binary, I do have the symbols in place, and for all third-party libraries I don't need the symbols most of the time. On slow network connections, it can take a long time (several minutes) to get all symbols, and the user does not even get at least some basic progress feedback. Sometimes it is possible to abort the download with Ctrl-C but in my experience it does not work reliable and also only for a single library, so even it works, you have to press it quite often.

I expect to have debugging symbols as part of the devel package, or some separate debug packages. In OpenSuse, those packages are named *debuginfo*.

This feature can also be a security issue, especially if the user does not know why it download stuff and from which server.

So here is what is happening and how to avoid/configure it at least.

1. What is happening?

Since version 10.1 gdb supports Debuginfod, a server infrastructure for getting debug symbols for a given build ID.

OpenSuse installs a package named libdebuginfod which sets up the stuff so GDB contacts https://debuginfod.opensuse.org/ for symbols. The environment variable DEBUGINFOD_URLS describes the server to use. It is defined in the file /etc/profile.d/debuginfod.*

2. How to disable it

There are two ways to disabled the use of online servers.

You can undefine the environment DEBUGINFOD_URLS to temporarily disable it.

To permanently disable it, uninstall the package libdebuginfod1. It will install a dummy package instead.

3. Final thoughts

This feature can be quite useful in certain environments, but in my opinion, it should not be enabled by default. There are quite some downsides:
  • downloads a lot of data
  • unaware user can't see where the data is coming from
  • no progress indication, can take a few seconds or several minutes
  • no hint how to configure/disable it
  • it is completely unclear from gdb changelog and debuginfod web page, if the data downloaded is signed with a well-defined gpg key to avoid security issues with handling untrusted data
tags: gdb1

2021-03-16: Code completion for emacs with LSP

1. Overview

There are a lot of packages for code development in emacs for a varity of languages, like cedet, company and others. The feature set starts from some keyword lookup for references, project handling, and code completion.

The language server protocol (LSP) is powerful,generic way to integrate IDE features into editors. For emacs, there is the lsp-mode which works great. There is excellent documentation at the homepage, but I wanted to write down some condensed steps to install it.

2. Installation

The simplest way to install is to use the emacs package manager and install the package "lsp-mode".

You need a LSP backend. For C there are two implementations, clangd is one of it so you might want to install that. It will be used automatically if it is available.

For a quick test, you can open a C file and execute "M-x lsp". I experienced a problem with an undefined symbol "-compose" which came from an old version of "dash" so you might want to update this package as well.

When opening a C file, emacs usually asks you to import the file as a project, you can press "i" to just import the current file or use "I" to manually set the project root directory which is often so better option. The project information are stored in the file

~/.emacs.d/.lsp-session-v1

3. Helping clangd to know about the project

clangd need to know how to compile the project and where to find include files etc. For this, a file named "compile_commands.json" must be created.

There are different ways to create such a file for different build environments. You can create the manually if you want to. For cmake you can use the option "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON". For make based project you can use the tool "bear" to create the file tool. Run "bear make" to create this file.

When everything is set up, you should be able to open any C/C++ file and start the lsp integration with "M-x lsp" (when applying the config in the next section, it will be done automatically). Then tab completion should just work if you have company active. You can also try to press M-. to jump to definition of a symbol.

4. Configuration

I use the following config to automatically enable lsp:
(add-hook 'c-mode-hook 'lsp-deferred)
(add-hook 'c++-mode-hook 'lsp-deferred)
(setq gc-cons-threshold (* 100 1024 1024)
      read-process-output-max (* 1024 1024)
      treemacs-space-between-root-nodes nil
      company-idle-delay 0.0
      company-minimum-prefix-length 1
      lsp-idle-delay 0.1)
(with-eval-after-load 'lsp-mode
 (add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))

5. Remaining issues

I experienced the following small issues:
  • I got a message
       Error running timer lsp--on-idle: (wrong-type-argument listp
       
    and it looks like it comes from the breadcrumb integration. You can disable the breadcrumb by running "M-x lsp-headerline-breadcrumb-mode" or disable it completely by using the configuration
       (setq lsp-headerline-breadcrumb-enable nil)
       
  • tab completion collides with yas-snipplet sometimes. I don't have a solution right now, you have to cancel the completion C-g and press tab again to get the yas-snipplet completion.
  • lsp sometimes asks for system includes to be part of the project, I don't know an other workaround than blacklisting them (the dialog allows to do that).

6. Final notes

This is just a very short version of how to install this mode but there is a nice tutorial at the "lsp-mode" homepage with a lot of more information.
tags: emacs2

2021-02-16: Installing OpenSuse Tumbleweed on an AMD Ryzen7 laptop with NVidia graphics

I recently bought a laptop with an AMD Ryzen7 4800H with hybrid graphics (Radeon and NVidia GTX 1650 Ti) and installed OpenSuse Tumbleweed.

I chose Tumbleweed over Leap 15.2 as I experienced serious issues with the older kernel shipped with 15.2. The system was not stable at all. Tumbleweed had kernel 5.9 at that time and currently runs 5.10 which works fine for the Ryzen CPU.

Basically everything worked out of the box with the exception of the proprietary graphics driver which is of course not installed by default. The rest of this artical describes the things I had to do to get everything working.

I have chosen this hardware combination since I wanted a powerful AMD Ryzen laptop CPU with powerful 3D graphics while still being small enough. I wanted to have a dedicated Radeon graphics to avoid proprietary nvidia drivers (which makes it hard to track down and fix stability issues), but there weren't any offers available so I opted for a NVidia card.

Since I don't care for battery time I choose to always use the dedicated graphics card. Otherwise I would have just used the integrated Radeon graphics of the 4800H CPU, which is reasonable fast for normal using.

Installation

First I booted and installed OpenSuse Tumbleweed from a current DVD image (on USB drive of course). During installation I chose NOT to install the nouveau driver since it did not really support the GTX 1650 Ti anyway and I want to use the proprietary driver.

At this point the integrated Radeon graphics should just work with AMDGPU driver.

I have added the nvidia repo to the opensuse repositories and install the package nvidia-glG05 and suse-prime. The later is for selecting which graphics card to use.

After a reboot, I ran

prime-select

to select the nvidia card for the main graphics card.

At this point, everything runs as expected. The CPU is fully supported by the kernel, WiFi/Bluetooth works, sound as well and the 3D driver is running fine.

Remaining issues

Hibernation

While suspend (to ram) worked out-of-the box, hibernate (or suspend to disk) did not work. The following steps are necessary to enable it:
  • Add "resume" to dracut configuration:
    vi /etc/dracut.conf.d/90-resume.conf
    add_dracutmodules+=" resume "
  • execute "mkinitrd" to create the new initrd.
  • add the kernel parameter so it knows where to restore from: yast -> bootloader -> kernel parameter
    resume=/dev/mapper/system-swap
    I'm not completely sure if this is necessary as dracut should take care if it.
After reboot you should be able to select hibernate from the lockin/lockout screen, but you can try it out manually be executing
systemctl hibernate

HDMI audio

Another thing which did not work directly was audio output over HDMI. Turned out the reason why it wasn't working was the prime-select package I have installed to be able to switch to the dedicated graphics cards. Otherwise it would probably just worked.

The reason why it was not working was a special udev rule set that have been installed by the package prime-select. To be able to disabled the dedicated graphics card on demand to reduce power usage and therefore increase battery time, the nvidia audio and usb devices had to be removed. Of course, since the audio device is removed, HDMI audio does not work.

I prefer to have HDMI audio working and don't care about battery life time, so I hat to remove the udev rule. One way is to deinstall the "prime-select" tool but I am not sure if this have some side effect for the nvidia driver. So I decided to just remove the udev file. Of course, whenever the prime-select package is updated, I have to remove it again.

For reference, the udev rule in question is the file

/usr/lib/udev/rules.d/90-nvidia-udev-pm*

USB autosuspend

Another minor issue is the USB autosuspend feature of the linux kernel. It has nothing to do with the opensuse installation itself, but this is something one might want to disable to be able to charge USB devices even if they are not in used.

You can disabled the power suspend individually for each USB device by writing "-1" into the autosuspend file in the /sys/ filesystem:

echo -1 >/sys/devices/pci0000:00/0000:00:1a.0/usb3/power/autosuspend
(of course adjust the address to the correct address of your device).

You can also disable it completely for all newly connected devices by writing "-1" to the file of the usbcore module:

echo -1 >/sys/module/usbcore/parameters/autosuspend
And you can also add a kernel parameter to disable it on startup:
usbcore.autosuspend=-1
Of course this will reduce battery life time a bit.

Final notes

One issue left is the use of hybrid graphics. In theory it should be possible to use the Radeon graphics as default and only use the NVidia on demand. For some little time I tried to play around with xrandr and the graphics provider settings but with no success. However, I do not care about this feature as I wanted to have a dedicated graphics anyway and the systems runs on main power most of the time.

All blog entries: all