Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Debug Nemo #2309

Closed
blueray453 opened this issue Jan 27, 2020 · 5 comments
Closed

How to Debug Nemo #2309

blueray453 opened this issue Jan 27, 2020 · 5 comments

Comments

@blueray453
Copy link

blueray453 commented Jan 27, 2020

I am using Linux Mint 19.3 Tricia.

I am tinkering with the nemo source code. I need a little debugging help. I checked https://forums.linuxmint.com/viewtopic.php?t=235125
https://stackoverflow.com/questions/31282505/how-to-debug-nemo-linux-mint-file-manager

The way I am changing the code and trying to debug is -

turned on 'source code repositories'.

git clone https://github.com/linuxmint/nemo
cd nemo

Now I am editing the code. I am using printf( "key_1 %s \n", key_1); to observe different variables.

sudo apt-get build-dep nemo 
dpkg-buildpackage 
cd .. && sudo dpkg -i *.deb

ctrl+alt+backspace to restart Xorg

Then I am using

$ gdb nemo
(gdb) r

Then looking for the printf output.

I am sure there is a more elegant solution. Is there any way I can debug the code without printf, dpkg-buildpackage, ctrl+alt+backspace?

@blueray453 blueray453 changed the title Debug Nemo How to Debug Nemo Jan 29, 2020
@blueray453
Copy link
Author

@mtwebster I think nemo-main.c is the main entry point. If I put breakpoint in VSCode, and run this file, will it work? What command shall I give to run nemo-main.c.

@mtwebster
Copy link
Member

Hi sorry, I meant to respond sooner.

The way you're building is fine. One thing I'll do to save time after the initial build and install using dpkg-buildpackage, is instead run:
sudo ninja -C debian/build install
-- to recompile subsequent times - it's much much faster, and there aren't any packages to install again (the system doesn't really care, you're copying over existing files) - this is good for doing as you are - adding debug output, etc. Just understand that when you want to do another 'real' build using dpkg-buildpackage, you'll need to use sudo to clean out the build folder (I use sudo git clean -fdx - this returns it to its pristine state).

I've never tried to develop in a full ide, so I'm not even really sure how breakpoints work there. The simplest method is to insert a G_BREAKPOINT() wherever you want it to stop - then you can do whatever you need to do in gdb.

You don't need to restart the session to restart nemo, just either do:
nemo --quit
or
killall nemo

If you want to debug the desktop icons, that is run with nemo-desktop, so you'll need to kill/restart it instead. (You need to kill it twice the first time, the session manager attempts to restart it exactly once after the session starts, if it terminates).

I use print statements mostly, or gdb if I need to do something more complicated (there's plenty of documentation out there) - it depends on what you're attempting to fix or work on. Valgrind is a good tool for looking for memory leaks - check out https://wiki.gnome.org/Valgrind.

If you're getting glib/gtk/gobject warnings you can run G_DEBUG=fatal_warnings gdb to start gdb, which will break on those warnings (and you can continue past them).

This library - https://developer.gnome.org/glib/stable is what pretty much everything is based on in nemo (along with gtk3) - I usually install the 'devhelp' program, along with -doc packages for these, which I find faster than browsing the web docs.

@icarter09
Copy link
Member

@blueray453 thank you for asking. I have been wondering the in's and out's as well for this.

@mtwebster thank you for guidance and pointing in the correct direction.

@blueray453
Copy link
Author

@icarter09 life is hard so have to ask.

@blueray453
Copy link
Author

blueray453 commented Feb 8, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants