Hello, everyone. I'm investigating a bug on Cinnamon and that has led me to one of the C files within that applet.
I've noticed it has a bunch of "g_debug" function calls so I tried to add my own, but I can't seen to see any output, at least on Melange or .xsession-errors.
Do I need to do something to activate logging with g_debug or am I just looking at the wrong place? I'm using mint-build to generate the relevant Cinnamon files and copying them on a virtual machine to install them there.
[SOLVED] How to debug C files used in Cinnamon applets?
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
-
- Level 1
- Posts: 2
- Joined: Sat Feb 04, 2023 9:16 am
[SOLVED] How to debug C files used in Cinnamon applets?
Last edited by LockBot on Fri Aug 04, 2023 10:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How to debug C files used in Cinnamon applets?
Try using:
Many C libraries also have their own debug flags that you can set, if you want to see more info for that particular library, for example, run:
You could then run:
to get extra info about Gtk program widget sizing.
When I need to do some serious debugging of C calls going on in Cinnamon, it's easiest to have a second computer, and use it to run Cinnamon from over ssh. You can then run it in a debugger like 'gdb' and use breakpoints, etc.. without worrying about your desktop freezing. There are lots of tutorials out there on using gdb, though you can be pretty effective with it learning only a small set of commands. In your case you can make sure your VM is visible on the local network ('bridge mode', not NAT mode), then ssh into the VM from the host machine.
- Install openssh-server on the Cinnamon machine you wish to debug
- On another machine connect to it - ssh user@x.x.x.x (your user and ip address of the other machine).
Then you can run:
At any point you can break into the program (ctrl-C)
... maybe add breakpoints:
When it stops at a breakpoint:
You can even run C functions on variables, and a lot more...
This applies to any C applications, though you really only need a second machine for debugging cinnamon.
Note: You'll need to install the debug symbols for any of these libraries to get useful results from the backtrace command.
sorry for the length...
Code: Select all
$ G_MESSAGES_DEBUG=all cinnamon-launcher
Code: Select all
$ GTK_DEBUG=help nemo
...
Supported debug values: misc plugsocket text tree updates keybindings multihead modules geometry icontheme printing builder size-request no-css-cache baselines pixel-cache no-pixel-cache interactive touchscreen actions resize layout all help
Code: Select all
$ GTK_DEBUG=geometry G_MESSAGES_DEBUG=all nemo
When I need to do some serious debugging of C calls going on in Cinnamon, it's easiest to have a second computer, and use it to run Cinnamon from over ssh. You can then run it in a debugger like 'gdb' and use breakpoints, etc.. without worrying about your desktop freezing. There are lots of tutorials out there on using gdb, though you can be pretty effective with it learning only a small set of commands. In your case you can make sure your VM is visible on the local network ('bridge mode', not NAT mode), then ssh into the VM from the host machine.
- Install openssh-server on the Cinnamon machine you wish to debug
- On another machine connect to it - ssh user@x.x.x.x (your user and ip address of the other machine).
Then you can run:
Code: Select all
$ DISPLAY=:0 gdb --args cinnamon --replace
...
...
... maybe add breakpoints:
Code: Select all
break st-label.c:st_label_get_text
c # continue running
Code: Select all
bt # backtrace
...
...
...
select 2 # select a frame of the backtrace
print *stringarg # print value of variable stringarg in that frame
c # continue some more
This applies to any C applications, though you really only need a second machine for debugging cinnamon.
Note: You'll need to install the debug symbols for any of these libraries to get useful results from the backtrace command.
sorry for the length...
-
- Level 1
- Posts: 2
- Joined: Sat Feb 04, 2023 9:16 am
Re: How to debug C files used in Cinnamon applets?
Thanks, mtwebster. The first command worked! I will also try the more complex ones out if I need to go more in depth, but it's good to already know them.