Copyright (C) 2000-2012 |
Whole document tree HACKINGLessTif is a complicated system, but not overwhelming. We've collected some tips on hacking LessTif here for your debugging and hacking pleasure. There are some features that are compiled in by default to make finding problems a little easier. Most can be turned off with configure options. One such feature is editres support. If you don't know what this is I suggest you search the web for editres.There is a good section in bugs.html describing tracking down bugs in _any_ X based app. Don't forget about "cvs log"!!!! The comments on previous commits can be very helpful, especially if you're new to the game. Useful Environment VariablesDEBUG_SOURCESDEBUG_SOURCES is an environment variable you can set
to get debugging output on a particular collection of source files.
DEBUG_SOURCES=all will
give you more information than you ever wanted about what LessTif is
doing internally. You can also set DEBUG_SOURCES to a
single file, or a list of files separated by colons ':'.
The ".c" postfix is optional here.
If your shell is sh, bash, or ksh, you can for example
set DEBUG_SOURCES by
DEBUG_SOURCES=MainW.c:FileSB.c export DEBUG_SOURCESIf your shell is csh or tcsh, you can set DEBUG_SOURCES by
setenv DEBUG_SOURCES "MainW.c:FileSB.c"If you unset DEBUG_SOURCES or set it to
"none" then no debugging output will be produced.
To block single files from producing debugging output, you
may add a "-" prefix to their entry. Obviously this
makes only sense if used in conjunction with the
"all" keyword:
DEBUG_FILEThe amount of diagnostics generated byDEBUG_SOURCES
can exceed the line buffering of typical terminal settings. The environmental
variable DEBUG_FILE can be used to direct the output to a file
instead of stdout.
An alternate method is to run the tests as follows:
DEBUG_SOURCES=MainW.c:FileSB.c ./test1 2>&1 | tee debug.logThe advantage of this is that you also get to see the messages on the screen as well as in a file. DEBUG_SOURCES is not limited to file names.
In reality it can be any string that matches what is in the source
for the _LtDebug() call. For example, DEBUG_SOURCES=FOCUS will
print debug info related to menu focus events, regardless of the file the
statement is in. There are some more in there also. Usually relating to
specific problems involving many different files. To find out what is
available try:
grep _LtDebug *.c | grep -v __FILE__ DEBUG_REDIRECT_XMWARNINGTo avoid infinite loops in applications that redirect stderr to a scrolledText. you may setDEBUG_REDIRECT_XMWARNING .
Output of _XmWarning() and equivalent functions (XmeWarning(), etc.)
is then sent to the content of DEBUG_FILE
DEBUG_PRINT_WIDGETIDIf this variable exists, then all widgets printed with _LtDebug() etc. will also print their widget ID. If the variable doesn't exist, then they only print their name for identification.DEBUG_SIGNALIt specifies the alphanumeric value of the signal which should be used to switch the built-in LessTif debugging system. Valid values depend on the system on which LessTif was compiled and is running on. Currently we support:SIGBREAK, SIGUNUSED, SIGUSR1, SIGUSR2, SIGUSR3
DEBUG_TOGGLEThis specifies the initial status of the built-in LessTif debugging system. Valid values are 'on' and 'off'Useful Interfaceslib/Xm/DebugUtil.c and include/Motif-1.2/XmI/DebugUtil.h contain the stuff which we use for our own debugging purposes, i.e. routines which actually produce the formatted debugging output and so on. The interactive methods to adjust the debug level also include interfaces which you may call from your application if have the source._LtDebugInit#include <XmI/DebugUtil.h> extern Boolean _LtDebugInit(void);Call to initialize the debugging subsystem. Useful if called before any other library calls are done. _LtDebugSet#include <XmI/DebugUtil.h> extern void _LtDebugSet(Boolean flag);Explicitly turn the debugging on/off according to flag .
_LtDebugToggle#include <XmI/DebugUtil.h> extern void _LtDebugToggle(void);Toggles the debugging system on/off. Testing patchesLessTif has an extensive test tree undertest/ .
Since even the most seemingly trivial change can often have unexpected
consequences, we recommend running the testall script under
test/ before and after applying a patch, to make sure that you
haven't broken anything else with your fix.
In these test programs, there is data that is labeled "expected".
Where do these values come from?
In the make motif-testsin any of the test directories all the tests in that directory will be compiled and linked with Motif, assuming it is available. Therefore test1 will be the test compiled and linked with LessTif, test1.motif will be the same code compiled and linked with Motif. You can also build individual tests with make test1.motifThe test library also includes a bunch of functions to simulate button, presses, pointer movement, and other things necessary for automated testing. The best thing about the tests is that they tell you whether everything it was meant to test worked. For an example, take a look at rowcolumn/test51. Try remembering to do all that everytime you make a change!!!! Really, the best way to fix a bug, and have it stay fixed, is to write a test and have it included in the test tree. Once a test has passed, a change to the library will not be accepted if it causes a previously passing test to fail. Well, it won't be accepted easily anyway :)
If you're hunting for bugs in mwm (our window manager) you have
several options: either you start a normal X11 session on your system,
e.g. on DISPLAY :1 if you have already one :0. Since you may not
need any fancy setup, starting the X server directly
may work and then you run mwm from an arbitrary terminal,
probably inside a debugger. Being non-root on un*x systems
you have to use Feedback Last modified on $Date: 2001/10/31 13:59:14 $ |