Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-debug-dev] Debug options.

Kris,

If your editor works within Eclipse, it should be fine.

It is harder to implement JSP source level debugging because you have to
implement the class file mangling inside of your application server rather
than as a builder inside of Eclipse.  I know that Websphere currently does
this mangling and Tomcat does _not_.  I have not tried any other
application servers.

This is how languages other than Java usually get compiled to Java
classfiles and run with the Java VM.

1. Programmer writes in language X.
2. Language X source is compiled into intermediate Java source (translation
compilation).
3. Java source gets compiled into Java class files.
4. java.exe is started, which loads and runs the classfiles.

In the case of an application server & JSP, it works this way.

1. Programmer writes in JSP, deploys the code, starts the server, and hits
the web page.
2. Server runs the JSP page compiler over the JSP source to create Java
source (translation compilation).
3. Server runs javac over the Java source creating classfiles.
4. Server loads and runs the class to display content.

The classfile mangling needs to happen before the class is loaded, so you
need to do the mangling between steps three and four.  This is why in the
JSP case you need to control the implementation of your application server.

What exactly does the classfile mangler do?  A reasonable implementation
does the following.
1. During the translation compilation, keep a table of "Java source line"
-> "Language X source line".
2. After the classfiles have been generated, open the classfiles and locate
the debug line information.
3. For all debug line numbers, replace with Language X lines if available.

The mangler also needs to replace the source file name, the source file
name is the simple name of the source file.  So for "java.lang.Object", it
is "Object.java".  This is a bit harder to solve because the Language X
source file name could be longer than the Java source file name and you
cannot change the size of a classfile (you can... but it is very hard).
Here is a reasonable alternate solution.

During translation compilation, add a private static final String field to
the Java source with the value of the Language X source file name.  Name
the field something unlikely to be used like, "___SourceFileName___", or
something similar.  Then your classfile mangler changes the source file
name attribute to point to this field in the constant table, rather than
the one for the Java source file name.

Note that JSR 45 proposes a solution to this entire problem which is more
elegant than this.  Their proposal is to add "debug strata" which are
layers of debug information.  When people begin to implement this, we
should be able to debug JSPs at both the JSP source level and the Java
source level (pretty sweet).  This is, however, just vaporware at the
moment.

jkca



                                                                                                                         
                    "N V S Rama Krishna"                                                                                 
                    <ram_kri@xxxxxxxxx>               To:     <platform-debug-dev@xxxxxxxxxxx>                           
                    Sent by:                          cc:                                                                
                    platform-debug-dev-admin@e        Subject:     Re: [platform-debug-dev] Debug options.               
                    clipse.org                                                                                           
                                                                                                                         
                                                                                                                         
                    11/28/2001 03:31 PM                                                                                  
                    Please respond to                                                                                    
                    platform-debug-dev                                                                                   
                                                                                                                         
                                                                                                                         



Hi jed,
        First of all lemme thank you for giving me such precious
information. I am planning to implement JSP source level debugging but
before that I have a couple of doubts which I would like have them
clarified.
         Your first point says one has to implement an editor for "that"
language, now we have JSP-editor that gets shipped along, cant we use that
for the same purpose or do we have to implement another editor ?  Do we
have
extension-points for the current editor ?
          The last paragraph of your mail says its harder to implement
source-level debugger for JSPs...is it harder or impossible ?
           I am just going through various resources as to how can one
implement a Java-debugger. What is this mangling of debug information you
are talking of ? Does the tool interacts or pushes some code straight into
the .class file or sth ?
           Thanks in advance for the your precious reply to this mail.

Regards,
Kris

----- Original Message -----
From: <Jed_Anderson@xxxxxxx>
To: <platform-debug-dev@xxxxxxxxxxx>
Sent: Monday, November 26, 2001 1:04 PM
Subject: Re: [platform-debug-dev] Debug options.


>
> The debugger does not support JSP source level debugging "out of the
box".
> However, it is possible to implement JSP source level debugging on your
> own.
>
> To support debugging of any language that gets compiled to Java classes
you
> must provide the following:
>
> 1. An editor for the language.
> 2. A tool that mangles the debug information in the .class file.  The
debug
> information should point to the line numbers in the original source.
> Usually, the debug information contains references to the line numbers in
> the intermediate Java source.  This tool must be run after every compile
of
> the source.
> 3. A source locator: the source locator takes a stack frame and returns
an
> object that can be used as input to the editor
> 4. A launcher that understands how to start a program written in your
> language.  Currently, it must use the PatternDebugTarget when registering
> with the debug plugin (rather than the JDIDebugTarget).
> 5. The ability to set breakpoints in your editor.  You ask
> PatternBreakpointFactory to create a new pattern breakpoint on a file,
line
> & with a given pattern.  The pattern you supply is matched against the
name
> of the classfiles that are loaded.  Currently it is a basic algorithm, we
> simply check to see that the fully qualified name of the class starts
with
> the given pattern.
>
> In the case of JSPs it's a little harder.  JSPs are compiled by the
> application server, so your post-processing of the classfiles (as
required
> by #2) must be built into the server.  Also, launching is a bit more
> confused because it requires you to start your server (or restart your
> application).
>
> jkca
>
>
>
>
>                     "N V S Rama Krishna"
>                     <ram_kri@xxxxxxxxx>               To:
<platform-debug-dev@xxxxxxxxxxx>
>                     Sent by:                          cc:
>                     platform-debug-dev-admin@e        Subject:
[platform-debug-dev] Debug options.
>                     clipse.org
>
>
>                     11/26/2001 04:06 PM
>                     Please respond to

>                     platform-debug-dev
>
>
>
>
>
> Hi,
>   I would like to know if we can step into JSPs using the current
Debugger
> (The plugin that gets shipped )? To what extent it is possible. I
> personally think its not possible but just want to confirm if I am
missing
> anything here. Shall be thankful if somebody can throw light on this
issue.
>              Thanks in advance.
>
> Regards,
> Kris
>
>
>
> _______________________________________________
> platform-debug-dev mailing list
> platform-debug-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-debug-dev


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

_______________________________________________
platform-debug-dev mailing list
platform-debug-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-debug-dev






Back to the top