Help with modifying source and variables views during debugging (redirected) [message #1773011] |
Wed, 20 September 2017 04:22  |
Eclipse User |
|
|
|
Hi,
I've posted this question on the JDT forum and have been redirected here.
Hope Im in the correct forum section now :)
So here is the original post:
I am developing a DSL with Xtext which is generated to Java.
If I place a breakpoint in my DSL editor a corresponding breakpoint is placed in the generated Java code which allows me to debug through the generated code.
However what im trying to achieve, is that during stepping over code the source code of my DSL is shown instead of Java code. Furthermore Id like to edit the variables view.
So from what I understand JDIStackFrame holds all the needed data, i.e. source location, line and variables. Is this correct?
And could you point me to where this is initialized or how can I replace it with my own stackframe?
For now I have only managed to replace the JavaSourceLookupDirector with my own that points to the DSL code in my LaunchDelegate. However while it does show my dsl source code while stepping, it has no information on current line and the variables so no line highlighting etc.
Thanks,
Nikita.
|
|
|
|
|
Re: Help with modifying source and variables views during debugging (redirected) [message #1773080 is a reply to message #1773019] |
Thu, 21 September 2017 05:13   |
Eclipse User |
|
|
|
After debugging the org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant I have compared the ._trace files generated by an xbase example and by my codegen.
It seems the problem is that my trace files lack the useForDebugging attribute set to true for the required trace regions. The appended files show examples of xbase generated trace and that for my DSL. The regions marked with D have this attribute set to true.
When writing the generator I have followed this example.
How can I set certain lines to be able to be used by debugger (useForDebugging to true in trace region) during code generation?
For example each generated statement from the code below should have this attribute set to true.
Here is an excerpt from my generator.
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
val program = resource.contents.head as Program
if (program !== null) {
val programName = resource.URI.lastSegment.nameWithoutExtension.toFirstUpper
AthenaUtilGenerator.generateUtilFile(resource, fsa, context)
TurtleUtilGenerator.generateUtilFile(resource, fsa, context)
fsa.generateTracedFile("generated/" + programName + ".java", program, '''
package generated;
import java.util.ArrayList;
import java.util.Arrays;
/*
* Generated Java file, do not modify it!!!
*/
@SuppressWarnings("all")
public class «programName» {
static AthenaUtil util = new AthenaUtil();
«FOR typeDec : program.typeDeclarations»
«IF typeDec instanceof Composition»
«fsa.generateTracedFile("generated/" + typeDec.name + ".java", program, '''
package generated;
/*
* Generated Java file, do not modify it!!!
*/
public class «typeDec.name» {
«FOR attr : (typeDec as Composition).attributes»
«attr.generateAttribute»
«ENDFOR»
}
''')»
«ENDIF»
«IF typeDec instanceof Enumeration»
«fsa.generateTracedFile("generated/" + typeDec.name + ".java", program, '''
package generated;
/*
* Generated Java file, do not modify it!!!
*/
public enum «typeDec.name» {
«FOR value : (typeDec as Enumeration).values»
«value.name.toUpperCase»
«IF !(typeDec as Enumeration).values.get((typeDec as Enumeration).values.size-1).equals(value)», «ENDIF»
«ENDFOR»
}
''')»
«ENDIF»
«ENDFOR»
«FOR op : program.operations»
«op.generateOperation»
«ENDFOR»
«IF program.mainBlock !== null»
«program.mainBlock.generateMainMethod»
«ENDIF»
}
''')
}
}
@Traced def private generateOperation(Operation op) {
'''
«op.generateMethodSignature»{
«FOR s : op.block.statements»
«s.generateStatement»
«ENDFOR»
}
'''
}
def private generateStatement(Statement s) {
val n = s.trace
switch s {
VariableDeclaration: {
s.generateVariableDeclaration(n)
n.append(";")
}
Assignment: {
s.generateAssignment(n)
n.append(";")
}
OperationCall: {
s.generateOperationCall(n)
n.append(";")
}
Conditional: {
s.generateConditional(n)
}
WhileLoop: {
s.generateWhileLoop(n)
}
ForEachLoop: {
s.generateForEachLoop(n)
}
Return: {
n.append("return ")
s.expression.generateExpression(n)
n.append(";")
}
}
return n
}
Regards,
Nikita.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10417 seconds