Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

JDB (how to generate debug code)
Hi:

Can anyone direct me to a doc/manual that describes how a compiler could
generate debug code for the JDB (Java Debugger).

Thanks.

Napi


Report this thread to moderator Post Follow-up to this message
Old Post
napi
09-22-04 08:59 AM


Re: JDB (how to generate debug code)
napi <napi@axiomsol.com> wrote:
> Can anyone direct me to a doc/manual that describes how a compiler could
> generate debug code for the JDB (Java Debugger).

In the Java bytecode, generating debuggable versions of the class files
is done through the attribute mechanism: a classfile consists of some
administration data, such as magic identifier at the beginning
(0xCAFEBABE), minor and major versions of the class file format etc.
Then there are five tables, namely
- Constant pool
- Implemented interfaces
- Fields of the class
- Methods of the class
- Class level attributes

Fields-table and Methods-table can also contain attributes of their own,
I'll talk about them later.

Now, having sanely debuggable code takes part in (at least) three
places: the constant pool and Class-level attributes and attributes
of the Methods-table.

The class-level attributes are relevant to debuggability, as it contains
an attribute named 'SourceFile', which is used to recover the file that
this class was generated from. Most debuggers don't try to decompile the
bytecode to a higher-level form, but rely on the availability of the
source file.

Having your constants readable improves debuggability a lot. The
constant pool contains entries to the 'public' interface of the class:
class name, super class name, member variables, etc. An usual
obfuscation technique is to twist the public interface of the class to a
unreadable form. When debugging, it is advisable to have these in their
unobfuscated form.

Then, the Method table contains all the methods defined in the class. It
has two pre-defined attributes: Exceptions and Code. Exceptions contains
all the exception handlers in the method and Code contains the actual
bytecode of the method.

Now, Code contains yet another attributes: LineNumberTable and
LocalVariableTable. These are used to map bytecode ranges to lines in
the original source file and to give meaningful names to local variables
in the method, respectively.

A more thorough document can be found at almost any book that discusses
the Java VM; I used the one published by O'Reilly; 'Java Virtual Machine'
by Jon Meyer & Trow Downing, 1997. Other books on this topic (that I'm
aware of) include 'Inside the Java Virtual Machine' by Bill Venners and
'Programming for the Java(TM) Virtual Machine' by Joshua Engel. I
believe that any of these will do good enough.

Of course, the most accessible text is 'The Structure of the Java
Virtual Machine' by Tim Lindholm and Frank Yellin; It is also available
via web.

br,
Pietu Pohjalainen

Report this thread to moderator Post Follow-up to this message
Old Post
A Pietu Pohjalainen
09-24-04 09:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Compilers archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.