DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Packages and Ports

OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 3rd March 2018
Funkygoby Funkygoby is offline
Fdisk Soldier
 
Join Date: Aug 2015
Posts: 57
Default How to debug a port

Thunar (the Xfce's file manager) have been dumping .core files and I am willing to investigate.
Note: I set my /etc/mk.conf so that my ports tree is read-only. Everything produced by the tree goes in /var/ports

I have several, a lot, of questions:
1. I need a binary build with debug symbols so that I can use it with [cmd]gdb[/cmd] and the .core file, but can I use a .core file produced by a binary without debug symbols ?
2. How to make a binary with debug symbols. I tried # cd /usr/ports/x11/xfce4/thunar && make DEBUG_FLAGS=-g ?
3. By doing # make install I am sure /usr/local/bin/thunar binary will be replaced ?
4. I don't want to install the new binary. I just want to use it for the debugging part: % gdb /var/ports/obj/ ... /.libs/thunar thunar.core. Is this reasonnable? By the way, thunar seems to be a shared library.
5. How to properly clean the ports tree ? # make clean && make clean=depends && make clean=dist && pkg_delete -a is ok ?

Thank you.
Reply With Quote
  #2   (View Single Post)  
Old 4th March 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

Quote:
Originally Posted by Funkygoby View Post
...can I use a .core file produced by a binary without debug symbols ?
I don't know. I don't recall ever trying. Normally, if I want symbols I also want a module that is not optimized.
Quote:
...How to make a binary with debug symbols.
It depends on the compiler, usually -g (and -O0) are added to CFLAGS or CXXFLAGS. I usually do this by copying Makefile to makefile, then editing the makefile, as make(1) will ignore Makefile if makefile exists. But this is for debugging only. If I need to edit the port to correct a problem after debugging, I rm(1) my temporary debugging makefile and make myedits to the Makefile, as I need to produce a useful diff(1) against the CVS repository to post a patch.
Quote:
... I am sure /usr/local/bin/thunar binary will be replaced ?
Only if you make install. You can make fake, which is a pre-packaging step used with every port. It install the port into a private directory structure. See THE FAKE FRAMEWORK in bsd.ports.mk(5).
Quote:
By the way, thunar seems to be a shared library.
looking at its PLIST, it includes shared libraries. That seems reasonable, as there are 4 thunar applications in the x11/xfce4 branch of the ports tree.
Quote:
5. How to properly clean the ports tree ?
Building a port makes no changes within a port's "leaf" of the tree. There are directory structures used to build the port's package or packages. The upstream distribution source is fetched to the $DISTDIR structure, extracted, built, and readied for packaging in the $WRKDIR structure. There are additional registrations, such as the contents of the packing list ("plist") and in a bulk build, there are bulk-build cookies and log/status files. Any build dependencies that were not already installed will be built or fetched, depending on $FETCH_PACKAGES and whether the $PKG_PATH contains a correct, installable version of the necessary dependency. For x11/xfce4/thunar, by default $DISTDIR and $WRKDIR are /usr/ports/distfiles and
/usr/ports/pobj/thunar-1.6.12 at 6.2-release, or /usr/ports/pobj/thunar-1.6.14 at -current.

Your "clean" example both removed too much and too little. You don't need to delete the package from your system -- unless you install it, which you state you do not want to do. And your clean skipped the plist registration (in /usr/ports/plist).

A terrific resource for port testing and debugging is the Port Testing Guide, a chapter in the Porter's Handbook.

http://www.openbsd.org/faq/ports/testing.html

Last edited by jggimi; 4th March 2018 at 03:40 PM. Reason: ports are not packaged in $WRKDIR
Reply With Quote
  #3   (View Single Post)  
Old 4th March 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

And, I forgot to mention that when packages are built, they are stored in the $PACKAGE_REPOSITORY structure. By default, this is /usr/ports/packages.

Last edited by jggimi; 4th March 2018 at 03:36 PM. Reason: clarity
Reply With Quote
  #4   (View Single Post)  
Old 6th March 2018
Funkygoby Funkygoby is offline
Fdisk Soldier
 
Join Date: Aug 2015
Posts: 57
Default

OK jggimi, thank you.

I already edited /etc/mk.conf regarding those variables, using [oman=7]ports[/man].

I am using a makefile instead of Makefile now. Simply adding a line
Code:
CFLAGS="-g"
allow me to build a debuggable version.

I used make fake and managed to re-trigger the crash with the thunar from the fake install directory but no .core dumped.
So I make install it and now I have my .core file and the binary to debug it.

I have little (as in "not much but already successfuly used it") experience in gdb. I can see the backtrace.
I guess the next step is to run the debuggable binary in gdb, add breakpoints, read variables then edit sources file, rebuild ,repeat ...

The porter's guide is my next read for sure.
Thank you.

P.S:
Along the way, I was hoping to get .core file from the thunar in the OBSD package. Just for research purposes ...
So I removed the thunar from /usr/local/bin and run # pkg_check to repair the installation from the packages provided by OBSD. I believe the package used was the one I built myself which defeated the purpose.
Reply With Quote
  #5   (View Single Post)  
Old 6th March 2018
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

.core file creation is managed by your shell.
  • You must have write access to the working directory.
  • You can prevent the creation of core files or control their size limits with the shell's ulimit/limit function.
Reply With Quote
Reply

Tags
debug, ports

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Security Security hole in Sudo's debug option closed J65nko News 0 31st January 2012 10:24 PM
The right way to build an OpenBSD port with debug symbols WeakSauceIII OpenBSD Packages and Ports 7 20th April 2009 12:40 PM
SSH on port 443 maxrussell General software and network 4 6th April 2009 05:16 AM
Trying to Debug C++ Compile Error [Shibboleth] on FreeBSD starbuck Programming 4 15th January 2009 10:30 PM
port forwarding ikevmowe OpenBSD Security 13 21st November 2008 06:03 PM


All times are GMT. The time now is 10:58 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick