January 1, 2010

How to compile a portion of FreeBSD code with debugging? (Sysinstall for this example)

Filed under: FreeBSD — J. Abram barneck @ 6:09 pm
Tags: , , ,

Ok, so maybe you want to work on fixing something in a portion of FreeBSD code, but you lack the knowledge to get started. That is what this document is for, to get you started.

For this example, I am going to use Sysinstall, which is a pretty old installer but still in use and functional. Let’s be honest, when the developers write in the code that Sysinstall needs to be completely rewritten and those notes are almost a decade old, you can guess that the installer is living far past its days. However, I don’t mind Sysinstall and many others don’t mind it either, which is probably why it is not updated yet. So lets at least see if we can inspire some contributors to start working on it. Sysinstall is actually on the Project Ideas page for a couple reasons, though I am surprised that “complete rewrite” is not one of them.

So lets get started.

Step 1 – Install FreeBSD
You need a FreeBSD Environment, so install one. Following one of these documents:
How do I install FreeBSD?
or if you want a FreeBSD install with a desktop as well:
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

Step 2 – Download the FreeBSD Source
Follow this guide to make sure you have the source you need.
How to download FreeBSD-Current or FreeBSD-Stable using svn?

Now that you have read that post and have the source, you should understand what I mean when I say for this example I checked out head.

Step 3 – Find the location of the portion of source you wish to compile (Sysinstall in this example)

  1. Change to the directory where your source is stored.
    $ cd /usr/home/jared/Devel/FreeBSD/head
  2. It is probably a good idea to browse the folders and get an understanding of what code is where. But this is a task you should perform over time. For now, lets search for exactly what we want: sysinstall.
    $ find ./ -name sysinstall

    You will see that sysinstall is here: ./usr.sbin/sysinstall

  3. Change to that directory.
    $ cd usr.sbin/sysinstall

Step 4 – Compile with debugging.
FreeBSD uses make to manage the compiling of the code, so it is really easy to compile it all.

  1. Run this command to compile Syinstall with debugging.
    $ make DEBUG_FLAGS=-g

You should now see all the .o libraries and the sysinstall libraries. You have just compiled a portion of FreeBSD.

Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.


1 Comment »

  1. […] Uncategorized — rhyous @ 6:44 pm Well, in my last FreeBSD Friday post, I talked about How to compile a portion of FreeBSD code with debugging? (Sysinstall for this example). The next step is to learn to step through the code. There is a debugging tool included with […]

    Pingback by How to debug a portion of FreeBSD code using gdb from a shell? (Using Sysinstall code as an example) « Rhyous's or ::1 — January 15, 2010 @ 11:32 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: