Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Help with modifying source and variables views during debugging (redirected)
Help with modifying source and variables views during debugging (redirected) [message #1773011] Wed, 20 September 2017 08:22 Go to next message
Nikita Dümmel is currently offline Nikita DümmelFriend
Messages: 19
Registered: September 2017
Junior Member
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 #1773014 is a reply to message #1773011] Wed, 20 September 2017 08:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you should have a look what xbase does.
org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant installs the smap information into the class files created by jdt.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Help with modifying source and variables views during debugging (redirected) [message #1773019 is a reply to message #1773014] Wed, 20 September 2017 08:45 Go to previous messageGo to next message
Nikita Dümmel is currently offline Nikita DümmelFriend
Messages: 19
Registered: September 2017
Junior Member
Thank you for the advice!
Re: Help with modifying source and variables views during debugging (redirected) [message #1773080 is a reply to message #1773019] Thu, 21 September 2017 09:13 Go to previous messageGo to next message
Nikita Dümmel is currently offline Nikita DümmelFriend
Messages: 19
Registered: September 2017
Junior Member
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.
Re: Help with modifying source and variables views during debugging (redirected) [message #1773086 is a reply to message #1773080] Thu, 21 September 2017 09:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
for me this looks like a bug/missing feature. can you file an issue at https://github.com/eclipse/xtext-core

org.eclipse.xtext.generator.trace.node.GeneratorNodeProcessor.doProcess(TraceNode, Context) sets useForDebugging to false. active annotations dont offer to customize this.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Help with modifying source and variables views during debugging (redirected) [message #1773087 is a reply to message #1773086] Thu, 21 September 2017 10:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
maybe you can customize a custom traceregionserializer to change the debussing to true always but this might have bad side effects

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Help with modifying source and variables views during debugging (redirected) [message #1773144 is a reply to message #1773087] Fri, 22 September 2017 07:58 Go to previous messageGo to next message
Nikita Dümmel is currently offline Nikita DümmelFriend
Messages: 19
Registered: September 2017
Junior Member
Thank you, I will file an issue at github.

[Updated on: Fri, 22 September 2017 07:59]

Report message to a moderator

Re: Help with modifying source and variables views during debugging (redirected) [message #1773149 is a reply to message #1773144] Fri, 22 September 2017 09:36 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
https://github.com/eclipse/xtext-core/issues/467

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtext parser rules overlap problem
Next Topic:Maven Tycho Best Practice Template for Xtext DSL
Goto Forum:
  


Current Time: Thu Apr 18 03:35:06 GMT 2024

Powered by FUDForum. Page generated in 0.01936 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top