Line number support for interpreter

Mark Wielaard mark@klomp.org
Mon May 10 14:00:00 GMT 2004


Hi,

Here is a first attempt at a patch to add support for line number and
source file name support to interpreted classes/methods.

The patch does the following:
- Implement reading of class and code attributes.
  - _Jv_InterpClass gets an extra source_name field.
  - _Jv_InterpMethod gets an extra line_table and length field.
  - There is a new struct _Jv_LineTableEntry that holds the information.
- For the direct-threaded interpreter the line_table pc field is
  remapped during compile().
- For the interpreter the _Jv_MethodChain now has a new pc field that
  holds the current 'pc' (this replaces the, also stack allocated, pc
  field in the run() method).
- This new field is used by StackTrace to fill in the _Jv_frame_info.
  - _Jv_frame_info.addr now either holds the actual address or the
  _Jv_InterpMethod pointer depending on whether _Jv_frame_info.interp is
  NULL or not. If it is not NULL then it contains the actual pc_t for
  the frame.
- _Jv_InterpMethod has a new get_source_line(pc_t) method which is
  called from NameFinder to fill in the appropriate fields of the
  StackTraceElement.

It contains several hacks that might not be a good idea, but not being a
real C or C++ hacker I didn't know how to solve this better for now. So
the DIRECT_THREADED define and pc_t typedef moved to the java-interp.h
include file. In interpret.cc there is terrible hack since I was lazy
and didn't want to rename all occurrences of 'pc' to 'frame_desc.pc'.
I'll try to clean those up after I get some comments on this.

I haven't tested the patch very much yet. But a simple test class that
throws some exceptions works and shows the correct line numbers. And I
am able to startup eclipse (2.1.2) with it under plain or
direct-threaded interpreter. (This was also the motivation for the patch
since I use to run eclipse under gij and got annoyed by the fact that
exceptions didn't have source and line numbers.)

So, Comments?

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intrp-line.patch
Type: text/x-patch
Size: 14048 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040510/42c5d456/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040510/42c5d456/attachment.sig>


More information about the Java-patches mailing list