If you'd like to watch as the code functions, which is often easier than reading the source directly, you can step through the code line by line with gdb(1).
For applications included with X, which use the OpenBSD-specific "Xenocara" build framework, you first need to obtain the source code, then create the object file structures. You don't need to build all of X.
Guidance for obtaining the Xenocara source, and for creating the object directories can be found in the release(8) man page. If you are running -release, you can download and unpack
xenocara.tar.gz from your nearby mirror. Source code for -stable or -current require the use of cvs(1).
For clarity, after placing source in
/usr/xenocara/:
Code:
# cd /usr/xenocara
# make bootstrap
# make obj
/usr/xenocara/README has guidance for building Xenocara source code with debugging symbols. To build xconsole:
Code:
# cd /usr/xenocara/app/xconsole
# rm /usr/xobj/xorg-config.cache.$(machine)
# env CFLAGS=-g make -f Makefile.bsd-wrapper build
And then you can load the unstripped binary in gdb(1) and step through the code starting with its main() function. For ease of use, after issuing the gdb
step command, you can press the Enter key alone to proceed line by line.
Code:
# gdb -q obj/xconsole
(gdb) b main
Breakpoint 1 at 0x1706: file /usr/xenocara/app/xconsole/xconsole.c, line 625.
(gdb) r
Starting program: /usr/xobj/app/xconsole/xconsole
Breakpoint 1 at 0x5138ab01706: file /usr/xenocara/app/xconsole/xconsole.c, line 625.
Breakpoint 1, main (argc=1, argv=0x7f7ffffcdaa8) at /usr/xenocara/app/xconsole/xconsole.c:625
625 {
(gdb) step
632 XtSetLanguageProc(NULL,NULL,NULL);
(gdb)
633 top = XtInitialize ("xconsole", "XConsole", options, XtNumber (options),
(gdb)
635 XtGetApplicationResources (top, (XtPointer)&app_resources, resources,
(gdb)
640 if (getuid() == 0) {
.
.
.