Re: How to debug an svgalib program

Search this archive.

From: Dr. Michael Weller (eowmob@exp-math.uni-essen.de)
Date: Fri 20 Apr 2001 - 11:48:00 IDT


[Giving a subject to your mail makes it less likely to be ignored and
 erased and attracts the right people to read it. Only sheer luck made
 me read it]

On Thu, 19 Apr 2001, Mochinushi Shingo wrote:

> How to debug program?
> 
>     Dear Sirs,
> 
>     I will write an interesting game program using SVGAlib.
> But since a program using SVGAlib uses a console under
> graphics mode, I am afraid that I can not communicate with
> a debugger program.

This is a general problem of any GUI program. Even under X11 there
are cases where the application locks the keyboard or mouse and you
can't use a debugger.

The following ideas come to mind:

1) There is a 'kind of internal' function vga_flip(). When you don't
   use raw keyboard mode.. just whenever you are in the debugger, enter a
   call to vga_flip() blindly to return to text_mode and back to graphics
   on exit. AFAIK, there are ways to ease or automate these calls with
   macros in debuggers like gdb.

   If vga card is in a screwed state or in a state where the mode can't
   flipped... well... you are doomed.

   In principle... even in raw keyboard mode.. if you can set macros for
   gdb to be execed on automatic (hmm.. maybe just use a display
   vga_flip() or similar) you can even have it make the calls to reset
   keyboard to normal operation for you w/o a key press.

2) Use an alternate way into your machine: Log in through a serial
   terminal (I've one at home I used for such things some time ago (B4 I
   got a 2nd machine)) or from another PC over tcp. Nowadays even
   Organizers or scientific calculators (I used one from a friend B4 I
   used that serial terminal) have serial ports and some kind of vt100
   emulation.

   It is possible to start the svgalib application under the debugger from
   there, just point its stderr to a VC (or let it search one itself).

3) Use poor man's debugger. Honestly, I use it often (and mostly not
   even for svgalib). A tiny printf in the right place is soo easy and
   often gives you the right hint where the bug is when you would have to
   single step to your prog ages for finding the right info.

   You can redirect stdout of svgalib apps to a file or another textmode
   console to see the output.

Michael.

--

Michael Weller: eowmob@exp-math.uni-essen.de, eowmob@ms.exp-math.uni-essen.de,
or even mat42b@spi.power.uni-essen.de. If you encounter an eowmob account on
any machine in the net, it's very likely it's me.


------------------------------------------------------------------
Unsubscribe:  To:   listbot@svgalib.org
              Body: unsubscribe linux-svgalib


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST