Source string Read only

(itstool) path: sect2/title
Context English State
The source code for the program is compiled. In effect, we change to the directory where the source was unpacked and do <command>make</command>—the program's own make file has the necessary information to build the program.
We now have a compiled version of the program. If we wish, we can test it now; when we feel confident about the program, we can type <userinput>make install</userinput>. This will cause the program and any supporting files it needs to be copied into the correct location; an entry is also made into a <database>package database</database>, so that the port can easily be uninstalled later if we change our mind about it.
Now I think you will agree that is rather impressive for a four line script!
The secret lies in the last line, which tells <command>make</command> to look in the system makefile called <filename></filename>. It is easy to overlook this line, but this is where all the clever stuff comes from—someone has written a makefile that tells <command>make</command> to do all the things above (plus a couple of other things I did not mention, including handling any errors that may occur) and anyone can get access to that just by putting a single line in their own make file!
If you want to have a look at these system makefiles, they are in <filename>/usr/share/mk</filename>, but it is probably best to wait until you have had a bit of practice with makefiles, as they are very complicated (and if you do look at them, make sure you have a flask of strong coffee handy!)
More Advanced Uses of <command>make</command>
<command>Make</command> is a very powerful tool, and can do much more than the simple example above shows. Unfortunately, there are several different versions of <command>make</command>, and they all differ considerably. The best way to learn what they can do is probably to read the documentation—hopefully this introduction will have given you a base from which you can do this.
The version of make that comes with FreeBSD is the <application>Berkeley make</application>; there is a tutorial for it in <filename>/usr/share/doc/psd/12.make</filename>. To view it, do
<prompt>%</prompt> <userinput>zmore paper.ascii.gz</userinput>
in that directory.
Many applications in the ports use <application>GNU make</application>, which has a very good set of <quote>info</quote> pages. If you have installed any of these ports, <application>GNU make</application> will automatically have been installed as <command>gmake</command>. It is also available as a port and package in its own right.
To view the info pages for <application>GNU make</application>, you will have to edit <filename>dir</filename> in the <filename>/usr/local/info</filename> directory to add an entry for it. This involves adding a line like
* Make: (make). The GNU Make utility.
to the file. Once you have done this, you can type <userinput>info</userinput> and then select <guimenuitem>make</guimenuitem> from the menu (or in <application>Emacs</application>, do <userinput>C-h i</userinput>).
Introduction to Available Debuggers
Using a debugger allows running the program under more controlled circumstances. Typically, it is possible to step through the program a line at a time, inspect the value of variables, change them, tell the debugger to run up to a certain point and then stop, and so on. It is also possible to attach to a program that is already running, or load a core file to investigate why the program crashed. It is even possible to debug the kernel, though that is a little trickier than the user applications we will be discussing in this section.
This section is intended to be a quick introduction to using debuggers and does not cover specialized topics such as debugging the kernel. For more information about that, refer to <xref linkend="kerneldebug"/>.
The standard debugger supplied with FreeBSD 12.1 is called <command>lldb</command> (<application>LLVM debugger</application>). As it is part of the standard installation for that release, there is no need to do anything special to use it. It has good command help, accessible via the <userinput>help</userinput> command, as well as <link xlink:href="">a web tutorial and documentation</link>.
The <command>lldb</command> command is available for FreeBSD 11.3 <link xlink:href="@@URL_RELPREFIX@@/doc/en_US.ISO8859-1/books/handbook/ports-using.html">from ports or packages</link> as <package>devel/llvm</package>. This will install the default version of lldb (currently 9.0).
The other debugger available with FreeBSD is called <command>gdb</command> (<application>GNU debugger</application>). Unlike lldb, it is not installed by default on FreeBSD 12.1; to use it, <link xlink:href="@@URL_RELPREFIX@@/doc/en_US.ISO8859-1/books/handbook/ports-using.html">install</link> <package>devel/gdb</package> from ports or packages. The version installed by default on FreeBSD 11.3 is old; instead, install <package>devel/gdb</package> there as well. It has quite good on-line help, as well as a set of info pages.
Which one to use is largely a matter of taste. If familiar with one only, use that one. People familiar with neither or both but wanting to use one from inside <application>Emacs</application> will need to use <command>gdb</command> as <command>lldb</command> is unsupported by <application>Emacs</application>. Otherwise, try both and see which one you prefer.
Using lldb
Starting lldb
Start up lldb by typing
<prompt>%</prompt> <userinput>lldb -- <replaceable>progname</replaceable></userinput>
Running a Program with lldb
Compile the program with <option>-g</option> to get the most out of using <command>lldb</command>. It will work without, but will only display the name of the function currently running, instead of the source code. If it displays a line like:
Breakpoint 1: where = temp`main, address = …
(without an indication of source code filename and line number) when setting a breakpoint, this means that the program was not compiled with <option>-g</option>.
Most <command>lldb</command> commands have shorter forms that can be used instead. The longer forms are used here for clarity.


User avatar None

New source string

FreeBSD Doc / books_developers-handbookEnglish

New source string 2 months ago
Browse all component changes


English English
No related strings found in the glossary.

Source information

Source string comment
(itstool) path: sect2/title
No labels currently set.
Source string location
Source string age
2 months ago
Translation file