debugging

Difference between version 51 and 52 - Previous - Next
'''Debugging''' is the of process diagnosing and correcting unexpected behaviour
of programs.



** Description **

There are many '''debugging''' techniques, ranging from simple [puts] commands
added appropriately to visually oriented tools supporting breakpoints, etc.

Use of a virtualization environment such as VMware, or the free alternative, [http://www.virtualbox.org/%|%VirtualBox], allow one to set up an entire environment - perhaps even unique operating system - then perform testing with less impact on the machine itself.

If you are testing across various platforms, you might find Virtual Network Computing (VNC) (also known as remote control) helpful software, as it allows you to connect to other computers and interact with them as if you were sitting with with that software installed on your desktop. 




** See Also **

   [Category Debugging]:    

   [IDE]:   many of which provide debugging functionality along with other features

   [Profiling Tcl]:   

   [Static syntax analysis]:   Tools for the analysis of source code.



** Concepts **

   [call graph]:   


** Tools for Dynamic Analysis **

   [a basic debugger]:   

   [a debugger with syntax highlighting using ctext]:   

   [https://github.com/google/sanitizers/wiki/AddressSanitizer%|%AddressSanitizer (asan)]:   A memory error detector for [C]/[C++].

   [A minimal debugger]:   

   [atkdebugger]:   A patch for Tcl 8.5 is available at the website

   [d: A handy little debugging proc]:   by [Ed Suominen], for development of PRIVARIA [http://www.privaria.org/], an end-user TCL app with a lot going on inside.

   [a minimal debugger]:   implements breakpoints, allowing to run any Tcl command, including inspecting and setting the local variables...

   [https://github.com/csmith-project/creduce%|%creduce]:   Takes a large C or C++ program that has a property of interest (such as triggering a compiler bug) and automatically produces a much smaller C/C++ program that has the same
property.

   [Errx]:   a mixed debug-message / stack backtrace introspection "puts"

   [Flow tracing]:   Replace `[proc]` to provide a graphical display of flow of a script.

   [gdb]:   

   [https://github.com/TACC/GDBase%|%GDBase]:   Offline parallel debugger; works by collecting user-specified data during the execution of a job and storing it in a database, which is available for offline inspection.  Also includes dynamic breakpoint API, which allows attaching Tcl scripts to breakpoints to be executed when breakpoint is hit.

   [https://github.com/google/sanitizers/wiki/MemorySanitizer%|%MemorySanitizer (msan)]:   A detector of uninitialized memory reads in [C]/[C++] programs.

   [Guarded proc]:   [RS]: monitors or prevents redefining an existing proc


   [Tkinspect]:   a stand alone application that queries a running Tk application and then displays its state.  This allows you to display current variable values and modify procs or variables. A [Tix]-enabled version of it is in [TixInspect]. The [Tcl Dev Kit] provides an enhanced version of TkInspect since release 2.5.

   [TkCon]:   [http://www.purl.org/net/hobbs/tcl/script/tkcon/]:  by [JH%|%Jeff Hobbs%|%]. A great way to interact with a running Tcl/Tk application. It can be attached to any Tcl/Tk interpreter or namespace and allows any modification. This application comes bundled with [ActiveTcl] and therefore also with [Tcl Dev Kit].  Sports facilities such as [http://tkcon.sourceforge.net/docs/idebug.html%|%idedebug%|%] and [http://tkcon.sourceforge.net/docs/observe.html%|%observe%|%], which provide sophisticated breakpoint and tracing facilities, and '''hot errors''',  which displays the source of the proc in dig-down style

   [Tracing with enterstep]:   How to limit the output from [trace%|%tracing], plus a method for performing intelligent single-stepping without modifying the source.

   [INSPECT app]:   

   undefined behaviour sanitizer (UBsan):   Not a program, but a compiler options for [https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html%|%gcc] and [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html%|%llvm/Clang] that instrument instructions to detect out-of-bounds and use-after-free bugs.

   [valgrind]:   

   [Electric Fence]:   

   [PED]:   

   [procstep]:   A drop-in replacement for `[proc]` that provides a hook prior to the evaluation of command, and another hook for exceptional return codes.

   [RamDebugger]:   A graphical debugger/IDE.

   [Yet another Tcl debugger]:   

   [Tagma Debugger]:   A rewrite of Yet another Tcl debugger.

   [TclPro]:   A popular open-source debugger originally sold by [Scriptics].  Provides not only static and dynamic debugging aids, but similar to [basekits], also a way to create a single distribution file that contain all the pieces one needs to execute a Tcl program.

   [Tuba]:   providing source code viewing as you step thru the code, breakpoints on specific lines and procs, and ability to set watchpoints on variables

   [ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/%|%TDebug%|%]:   a Tk based debugger that is sourced into your script.  Works conceptually like the emacs-lisp debugger.  An updated version of it is in [TixDebug].

   The 'tracecommand' extension:   based on a patch [ftp://ftp.ucsd.edu/pub/alpha/tcl/extensions/trace.c] [[does [Vince Darley] have a more recent version of this?]] to the Tcl core, is available from the scriptics bug database [[we need a URL here]].  It can be used to dump before/after command+argument+result evaluations both globally or only inside a given command or procedure.  It is similar to the 'trace dump' facility available in the Tcl-scripted MacOS editor 'Alpha'.

   [http://www.fridu.com/Html/jTcl.html%|%jTcl%|%]:   a Java-like object interface which provides debugging facilities.  [escargo]  2004-02-04: dead link. 

   [http://web.archive.org/web/20051013082553/systems.cs.uchicago.edu/wad/%|%WAD%|%]:   (Wrapped Application Debugger) is an embedded debugging system that is intended to simplify the task of debugging scripting language extensions. It does this by converting catastrophic errors such as segmentation faults and failed assertions into scripting language exceptions. This, in turn, allows a scripting language interpreter to generate an informative cross-language stack trace. By the author of [SWIG].

   [https://github.com/dyninst/tools/tree/master/dyner%|%dyner]:   A debugging and dynamic instrumentation tool delivered as a Tcl library that wraps the http://www.dyninst.org/%|%DynInst API.  The DynInst package allows changing program values and injecting code into running binaries.  Dyner provides extra functionality on top of Dyninst such as declaration of new variables, navigational commands for type system, function trace facility and efficient conditional breakpoints. 

   [https://github.com/karlredgate/redx%|%RedX]:   Pronounced "red-cross".  Tcl loadable library in C/C++, a system tool providing scriptable access to low level system calls, hypervisor calls, system information, etc.; e.g.:

   * kernel symbols

   * memory usage (free)

   * process list (/proc)

   * memory hogs 

   [http://www.sevenuc.com/en/speare.html%|%Speare]:    An ultra lightweight code editor and a small IDE that provides debugging environment for C, C++, Ruby, mruby, Lua, Python, PHP, Perl and Tcl. It was originally developed to provide a native scripting language debugging environment that seamlessly integrated with C and C++, and with an efficient code navigation and call routines tracing ability. 
   [https://github.com/screwtop/Melonade%|%Melonade]:   browsing variables, editing procs, viewing widget hierarchies, browser/inspector for actions scheduled by [after], channel browser

** Publications **

   [http://computerworld.com/newsletter/0%2C4902%2C77375%2C0.html?nlid=APP%|%A Debugging Primer%|%]:   an excerpt [Debugging: The 9 Indispensable Rules For Finding Even the Most Elusive Software and Hardware Problems, David J. Agans]

   [How to be a Programmer: A Short, Comprehensive, and Personal Summary, Robert L. Read, 2002]:   [PYK] 2012-12: a quick glance-through indicates that this is worth the read.  Others have received it positively as well.



** See Also **

   [C compiled image processing on an interactive Bwise canvas]:   

   [Commonly encountered problems in Tcl]:   

   [Debugging Aid For Production Code]:   

   [Debugging Expect programs]:   

   [debug with trace]:   

   [Dynamic Debugger]:   A strange breed.  For whatever reason, many programmers are either unfamilar or dissatisfied with most of the products in this category.

   [Debugging via introspection]:   

   [Effective ways to request help with Tcl-related problems]:   

   [Favorite debugging techniques applicable to Tcl]:   

   [Help! My Tcl application just crashed!]:   

   [How to debug memory faults in Tcl and extensions]:   

   [Leak Hunt (C level)]:   

   [List the call stack]:   

   [Memory introspection]:   Important when trying to find bugs going into the C-level, especially hard to pin-down memory trouble.


   [Pstack]:    Displays the calling sequence for a proc.

   [regular expression debugging tips]:   

   [Static syntax analysis]:   Static code checkers are tools which read your Tcl code and attempt to identify either real, or potential, problems.  This is similar to the Unix ''lint'' command.

   [Steppin' out]:   uses Tcl's own command tracing

   [traceproc helper]:   specify a list of commands to monitor, and see the actual arguments passed to the commands when they are run, as well as the result.

   [traceback]:   

   [what debugging tools are available to a Tcl programmer]:   

   [Whole-Script Tracing]:   


** Components with Debugging Features **

   [Tcl%|%Tcl itself]:   provides enhanced command tracing since release 8.4 (See [TIP] #62). Example of usage is at [Steppin' out].

   [BLT]:   comes with several useful debugging commands.

   [TclX]:   comes with commands for profiling and debugging facilities, for example [cmdtrace].  Break down program runtime by [proc%|%procedure].

   [http://www.csua.berkeley.edu/%7Esls/woa/distrib/%|%SNTL%|%]:   includes a debugging message system.

   [Source Navigator]:   an IDE with code comprehension features.  It is written in Tcl/Tk/itcl, but allows you to understand code written in a wide variety of languages.


** Projects **

   [GSoC Idea: Debugging tools for NRE]:   




<<categories>> Application | Debugging | Dev. Tools