On Wed, Jul 11, 2012 at 6:13 PM, Sergey Prigogin
<
eclipse.sprigogin@xxxxxxxxx> wrote:
> I've submitted a different fix.
>
> -sergey
>
>
> On Wed, Jul 11, 2012 at 10:35 AM, Joseph Paul Cohen <
jcccnet@xxxxxxxxx>
> wrote:
>>
>> I made this change and now my code works. Not sure if it's correct
>> though. Can someone verify it? If the code is not making forward
>> progress then it returns false.
>>
>> diff --git
>> a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
>> index 072c70f..b8cbee2 100644
>> ---
>> a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
>> +++
>> b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
>> @@ -865,7 +865,8 @@ public class ChangeGenerator extends ASTVisitor {
>> Â Â Â Â Â*/
>> Â Â Â Â private boolean doesRegionContainNode(IASTTranslationUnit ast,
>> int offset, int length) {
>> Â Â Â Â Â Â Â Â IASTNodeSelector nodeSelector =
>> ast.getNodeSelector(ast.getFilePath());
>> - Â Â Â Â Â Â Â while (length > 0) {
>> + Â Â Â Â Â Â Â boolean loop = true;
>> + Â Â Â Â Â Â Â while (length > 0 && loop) {
>> Â Â Â Â Â Â Â Â Â Â Â Â IASTNode node =
>> nodeSelector.findFirstContainedNode(offset, length - 1);
>> Â Â Â Â Â Â Â Â Â Â Â Â if (node == null)
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return false;
>> @@ -874,6 +875,8 @@ public class ChangeGenerator extends ASTVisitor {
>> Â Â Â Â Â Â Â Â Â Â Â Â int oldOffset = offset;
>> Â Â Â Â Â Â Â Â Â Â Â Â offset = endOffset(node);
>> Â Â Â Â Â Â Â Â Â Â Â Â length -= offset - oldOffset;
>> + Â Â Â Â Â Â Â Â Â Â Â if ((offset - oldOffset) == 0)
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â loop = false;
>> Â Â Â Â Â Â Â Â }
>> Â Â Â Â Â Â Â Â return false;
>> Â Â Â Â }
>>
>>
>> On Wed, Jul 11, 2012 at 12:31 PM, Joseph Paul Cohen <
jcccnet@xxxxxxxxx>
>> wrote:
>> > It seems there is a endless loop here in file ChangeGenerator. ÂLength
>> > is never decreased because offset and oldOffset are always the same.
>> >
>> > The endOffset call is reaching into a ASTPreprocessorNode object and
>> > calling getNodeOffset() + getNodeLength().
>> >
>> > Can anyone give me a high level view of this code? Or know of any
>> > writeup regarding the ChangeGenerator?
>> >
>> >
>> > Â Â Â Â private boolean doesRegionContainNode(IASTTranslationUnit ast,
>> > int
>> > offset, int length) {
>> > Â Â Â Â Â Â Â Â IASTNodeSelector nodeSelector =
>> > ast.getNodeSelector(ast.getFilePath());
>> > Â Â Â Â Â Â Â Â while (length > 0) {
>> > Â Â Â Â Â Â Â Â Â Â Â Â IASTNode node =
>> > nodeSelector.findFirstContainedNode(offset, length - 1);
>> > Â Â Â Â Â Â Â Â Â Â Â Â if (node == null)
>> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return false;
>> > Â Â Â Â Â Â Â Â Â Â Â Â if (!isNodeRemoved(node))
>> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return true;
>> > Â Â Â Â Â Â Â Â Â Â Â Â int oldOffset = offset;
>> > Â Â Â Â Â Â Â Â Â Â Â Â offset = endOffset(node);
>> > Â Â Â Â Â Â Â Â Â Â Â Â length -= offset - oldOffset;
>> > Â Â Â Â Â Â Â Â }
>> > Â Â Â Â Â Â Â Â return false;
>> > Â Â Â Â }
>> >
>> > Thread dump:
>> > Thread [Worker-2] (Suspended)
>> > Â Â Â Â ChangeGenerator.doesRegionContainNode(IASTTranslationUnit, int,
>> > int) line: 876
>> > Â Â Â Â ChangeGenerator.getPreviousSiblingOrPreprocessorNode(IASTNode)
>> > line: 803
>> > Â Â Â Â ChangeGenerator.handleReplace(IASTNode) line: 593
>> > Â Â Â Â ChangeGenerator.visit(IASTDeclaration) line: 177
>> > Â Â Â Â CPPASTFunctionDefinition.accept(ASTVisitor) line: 178
>> > Â Â Â Â CPPASTTranslationUnit(ASTTranslationUnit).accept(ASTVisitor)
>> > line: 251
>> > Â Â Â Â ChangeGenerator.generateChange(IASTNode, ASTVisitor) line: 124
>> > Â Â Â Â ChangeGenerator.generateChange(IASTNode) line: 117
>> > Â Â Â Â ASTRewriteAnalyzer.rewriteAST(IASTTranslationUnit,
>> > ASTModificationStore, NodeCommentMap) line: 26
>> > Â Â Â Â ASTRewrite.rewriteAST() line: 213
>> > Â Â Â Â ModificationCollector.createFinalChange() line: 82
>> > Â Â Â Â RemoveFunctionAction$RemoveFunctionsJob.run(IProgressMonitor)
>> > line: 274
>> > Â Â Â Â Worker.run() line: 54
>> >
>> >
>> > Variable values at end of loop:
>> >
>> > this  ÂChangeGenerator Â(id=127)
>> > ast   CPPASTTranslationUnit Â(id=123)
>> > offset Â173
>> > length Â53
>> > nodeSelector  ÂASTNodeSelector Â(id=142)
>> > node  ÂCPPASTSimpleDeclSpecifier Â(id=198)
>> > oldOffset    173
>> >
>> >
>> >
>> > On Wed, Jul 11, 2012 at 12:03 PM, Joseph Paul Cohen <
jcccnet@xxxxxxxxx>
>> > wrote:
>> >> So it wasn't the thread waiting for DirtyRegionQueue. It's hanging in
>> >> a thread at
>> >> FindNodeForOffsetAction(ASTGenericVisitor).visit(IASTStatement)
>> >> line: 118.
>> >>
>> >> I will look into this file, thanks for noticing my mistake. ÂAlso
>> >> since my first email I changed to code to use a ModificationCollector
>> >> but it still hangs here.
>> >>
>> >> Thread Dump while preforming rewrite:
>> >>
>> >> org.eclipse.equinox.launcher.Main at localhost:40561 (Suspended)
>> >> Â Â Â Â Daemon System Thread [Signal Dispatcher] (Suspended)
>> >> Â Â Â Â Daemon System Thread [Finalizer] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: ReferenceQueue$Lock Â(id=78)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â ReferenceQueue<T>.remove(long) line: 135
>> >> Â Â Â Â Â Â Â Â ReferenceQueue<T>.remove() line: 151
>> >> Â Â Â Â Â Â Â Â Finalizer$FinalizerThread.run() line: 177
>> >> Â Â Â Â Daemon System Thread [Reference Handler] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: Reference$Lock Â(id=77)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â Reference$Lock(Object).wait() line: 503
>> >> Â Â Â Â Â Â Â Â Reference$ReferenceHandler.run() line: 133
>> >> Â Â Â Â Thread [main] (Suspended)
>> >> Â Â Â Â Â Â Â Â OS.Call(int, int, int, int) line: not available [native
>> >> method]
>> >> Â Â Â Â Â Â Â Â Display.sleep() line: 4036
>> >>
>> >> IDEWorkbenchAdvisor(WorkbenchAdvisor).eventLoopIdle(Display) line: 364
>> >> Â Â Â Â Â Â Â Â IDEWorkbenchAdvisor.eventLoopIdle(Display) line: 917
>> >> Â Â Â Â Â Â Â Â Workbench$3.eventLoopIdle(Display) line: 459
>> >> Â Â Â Â Â Â Â Â PartRenderingEngine$9.run() line: 1026
>> >> Â Â Â Â Â Â Â Â Realm.runWithDefault(Realm, Runnable) line: 332
>> >> Â Â Â Â Â Â Â Â PartRenderingEngine.run(MApplicationElement,
>> >> IEclipseContext) line: 916
>> >> Â Â Â Â Â Â Â Â E4Workbench.createAndRunUI(MApplicationElement) line:
>> >> 86
>> >> Â Â Â Â Â Â Â Â Workbench$5.run() line: 585
>> >> Â Â Â Â Â Â Â Â Realm.runWithDefault(Realm, Runnable) line: 332
>> >> Â Â Â Â Â Â Â Â Workbench.createAndRunWorkbench(Display,
>> >> WorkbenchAdvisor) line: 540
>> >> Â Â Â Â Â Â Â Â PlatformUI.createAndRunWorkbench(Display,
>> >> WorkbenchAdvisor) line: 149
>> >> Â Â Â Â Â Â Â Â IDEApplication.start(IApplicationContext) line: 124
>> >> Â Â Â Â Â Â Â Â EclipseAppHandle.run(Object) line: 196
>> >> Â Â Â Â Â Â Â Â EclipseAppLauncher.runApplication(Object) line: 110
>> >> Â Â Â Â Â Â Â Â EclipseAppLauncher.start(Object) line: 79
>> >> Â Â Â Â Â Â Â Â EclipseStarter.run(Object) line: 353
>> >> Â Â Â Â Â Â Â Â EclipseStarter.run(String[], Runnable) line: 180
>> >> Â Â Â Â Â Â Â Â NativeMethodAccessorImpl.invoke0(Method, Object,
>> >> Object[]) line: not
>> >> available [native method]
>> >> Â Â Â Â Â Â Â Â NativeMethodAccessorImpl.invoke(Object, Object[]) line:
>> >> 57
>> >> Â Â Â Â Â Â Â Â DelegatingMethodAccessorImpl.invoke(Object, Object[])
>> >> line: 43
>> >> Â Â Â Â Â Â Â Â Method.invoke(Object, Object...) line: 601
>> >> Â Â Â Â Â Â Â Â Main.invokeFramework(String[], URL[]) line: 629
>> >> Â Â Â Â Â Â Â Â Main.basicRun(String[]) line: 584
>> >> Â Â Â Â Â Â Â Â Main.run(String[]) line: 1438
>> >> Â Â Â Â Â Â Â Â Main.main(String[]) line: 1414
>> >> Â Â Â Â Thread [Framework Active Thread] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: Framework Â(id=76)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â Framework.run() line: 1863
>> >> Â Â Â Â Â Â Â Â Thread.run() line: 722
>> >> Â Â Â Â Daemon Thread [State Data Manager] (Suspended)
>> >> Â Â Â Â Â Â Â Â Thread.sleep(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â StateManager.run() line: 297
>> >> Â Â Â Â Â Â Â Â Thread.run() line: 722
>> >> Â Â Â Â Daemon Thread [Start Level Event Dispatcher] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: EventManager$EventThread Â(id=20)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread(Object).wait() line: 503
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread.getNextEvent() line: 400
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread.run() line: 336
>> >> Â Â Â Â Daemon Thread [Framework Event Dispatcher] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: EventManager$EventThread Â(id=22)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread(Object).wait() line: 503
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread.getNextEvent() line: 400
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread.run() line: 336
>> >> Â Â Â Â Daemon Thread [[Timer] - Main Queue Handler] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: Object Â(id=72)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â TimerImpl.run() line: 141
>> >> Â Â Â Â Â Â Â Â Thread.run() line: 722
>> >> Â Â Â Â Daemon Thread [Bundle File Closer] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: EventManager$EventThread Â(id=25)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread(Object).wait() line: 503
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread.getNextEvent() line: 400
>> >> Â Â Â Â Â Â Â Â EventManager$EventThread.run() line: 336
>> >> Â Â Â Â Thread [Worker-JM] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: ArrayList<E> Â(id=74)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â InternalWorker.run() line: 58
>> >> Â Â Â Â Thread [Worker-0] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: WorkerPool Â(id=71)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â WorkerPool.sleep(long) line: 188
>> >> Â Â Â Â Â Â Â Â WorkerPool.startJob(Worker) line: 220
>> >> Â Â Â Â Â Â Â Â Worker.run() line: 50
>> >> Â Â Â Â Thread [Worker-1] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: WorkerPool Â(id=71)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â WorkerPool.sleep(long) line: 188
>> >> Â Â Â Â Â Â Â Â WorkerPool.startJob(Worker) line: 220
>> >> Â Â Â Â Â Â Â Â Worker.run() line: 50
>> >> Â Â Â Â Thread [Worker-2] (Suspended)
>> >>
>> >> FindNodeForOffsetAction(ASTGenericVisitor).visit(IASTStatement) line: 118
>> >> Â Â Â Â Â Â Â Â CPPASTCompoundStatement.accept(ASTVisitor) line: 74
>> >> Â Â Â Â Â Â Â Â CPPASTFunctionDefinition.accept(ASTVisitor) line: 201
>> >>
>> >> CPPASTTranslationUnit(ASTTranslationUnit).accept(ASTVisitor) line: 251
>> >> Â Â Â Â Â Â Â Â ASTNodeSelector.getNode(ASTNodeSpecification<T>) line:
>> >> 115
>> >> Â Â Â Â Â Â Â Â ASTNodeSelector.findNode(int, int, Relation, Class<T>,
>> >> boolean) line: 88
>> >> Â Â Â Â Â Â Â Â ASTNodeSelector.findNode(int, int, Relation, Class<T>)
>> >> line: 50
>> >> Â Â Â Â Â Â Â Â ASTNodeSelector.findFirstContainedNode(int, int) line:
>> >> 122
>> >>
>> >> ChangeGenerator.doesRegionContainNode(IASTTranslationUnit, int, int)
>> >> line: 869
>> >>
>> >> ChangeGenerator.getPreviousSiblingOrPreprocessorNode(IASTNode) line: 803
>> >> Â Â Â Â Â Â Â Â ChangeGenerator.handleReplace(IASTNode) line: 593
>> >> Â Â Â Â Â Â Â Â ChangeGenerator.visit(IASTDeclaration) line: 177
>> >> Â Â Â Â Â Â Â Â CPPASTFunctionDefinition.accept(ASTVisitor) line: 178
>> >>
>> >> CPPASTTranslationUnit(ASTTranslationUnit).accept(ASTVisitor) line: 251
>> >> Â Â Â Â Â Â Â Â ChangeGenerator.generateChange(IASTNode, ASTVisitor)
>> >> line: 124
>> >> Â Â Â Â Â Â Â Â ChangeGenerator.generateChange(IASTNode) line: 117
>> >> Â Â Â Â Â Â Â Â ASTRewriteAnalyzer.rewriteAST(IASTTranslationUnit,
>> >> ASTModificationStore, NodeCommentMap) line: 26
>> >> Â Â Â Â Â Â Â Â ASTRewrite.rewriteAST() line: 213
>> >> Â Â Â Â Â Â Â Â ModificationCollector.createFinalChange() line: 82
>> >>
>> >> RemoveFunctionAction$RemoveFunctionsJob.run(IProgressMonitor) line: 274
>> >> Â Â Â Â Â Â Â Â Worker.run() line: 54
>> >> Â Â Â Â Thread [Worker-3] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: WorkerPool Â(id=71)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â WorkerPool.sleep(long) line: 188
>> >> Â Â Â Â Â Â Â Â WorkerPool.startJob(Worker) line: 220
>> >> Â Â Â Â Â Â Â Â Worker.run() line: 50
>> >> Â Â Â Â Daemon Thread [Java indexing] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: IndexManager Â(id=73)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â IndexManager(Object).wait() line: 503
>> >> Â Â Â Â Â Â Â Â IndexManager(JobManager).run() line: 382
>> >> Â Â Â Â Â Â Â Â Thread.run() line: 722
>> >> Â Â Â Â Thread [Worker-4] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: WorkerPool Â(id=71)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â WorkerPool.sleep(long) line: 188
>> >> Â Â Â Â Â Â Â Â WorkerPool.startJob(Worker) line: 220
>> >> Â Â Â Â Â Â Â Â Worker.run() line: 50
>> >> Â Â Â Â Daemon Thread [org.eclipse.cdt.internal.ui.text.CReconciler]
>> >> (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: DirtyRegionQueue Â(id=75)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â AbstractReconciler$BackgroundThread.run() line: 179
>> >> Â Â Â Â Daemon Thread [[ThreadPool Manager] - Idle Thread] (Suspended)
>> >> Â Â Â Â Â Â Â Â waiting for: Executor Â(id=68)
>> >> Â Â Â Â Â Â Â Â Object.wait(long) line: not available [native method]
>> >> Â Â Â Â Â Â Â Â Executor(Object).wait() line: 503
>> >> Â Â Â Â Â Â Â Â Executor.run() line: 106
>> >>
>> >>
>> >> On Wed, Jul 11, 2012 at 2:35 AM, Leherbauer, Anton (Toni)
>> >> <
Anton.Leherbauer@xxxxxxxxxxxxx> wrote:
>> >>> Hi,
>> >>>
>> >>> the screenshot shows the Reconciler thread in a state where it is idle
>> >>> (waiting for: DirtyRegionQueue).
>> >>> This is obviously not the thread that hangs in the rewriteAST method.
>> >>> A full thread dump would show more.
>> >>>
>> >>> Toni
>> >>>
>> >>>> -----Original Message-----
>> >>>> From:
cdt-dev-bounces@xxxxxxxxxxx
>> >>>> [mailto:
cdt-dev-bounces@xxxxxxxxxxx]
>> >>>> On Behalf Of Joseph Paul Cohen
>> >>>> Sent: Tuesday, July 10, 2012 17:09
>> >>>> To: cdt-dev
>> >>>> Subject: [cdt-dev] ASTRewrite
>> >>>>
>> >>>> Hello,
>> >>>>
>> >>>> I have been using the CDT ASTRewrite object to create changes. For
>> >>>> some
>> >>>> refactorings (not all) with multiple IAST nodes removed it hangs at
>> >>>> this line:
>> >>>>
>> >>>> final Change c = rw.rewriteAST();
>> >>>>
>> >>>> The thread says "waiting for: DirtyRegionQueue" (Image Attached)
>> >>>>
>> >>>> Can anyone tell me what this means? Or some hints at what to look at?
>> >>>>
>> >>>> -J
>> >>> _______________________________________________
>> >>> cdt-dev mailing list
>> >>>
cdt-dev@xxxxxxxxxxx
>> >>>
https://dev.eclipse.org/mailman/listinfo/cdt-dev
>> _______________________________________________
>> cdt-dev mailing list
>>
cdt-dev@xxxxxxxxxxx
>>
https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>
>
> _______________________________________________
> cdt-dev mailing list
>
cdt-dev@xxxxxxxxxxx
>
https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev