Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 136a95efc7e6b8a53f1e3bb8439ebe095eadd86e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tm.internal.tcf.dsf.launch;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.tm.internal.tcf.debug.launch.TCFSourceLookupParticipant;
import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
import org.eclipse.tm.internal.tcf.dsf.services.TCFDSFStack.TCFFrameDMC;
import org.eclipse.tm.tcf.protocol.Protocol;

/**
 * The TCF source lookup participant knows how to translate a TCFFrameData
 * into a source file name
 */
public class TCFDSFSourceLookupParticipant extends TCFSourceLookupParticipant {

    @Override
    public String getSourceName(final Object object) throws CoreException {
        if (object instanceof TCFFrameDMC) {
            final Object[] res = new Object[1];
            synchronized (res) {
                Protocol.invokeLater(new Runnable() {
                    public void run() {
                        TCFFrameDMC dmc = (TCFFrameDMC)object;
                        if (!dmc.context_cache.validate()) {
                            dmc.context_cache.wait(this);
                            return;
                        }
                        if (!dmc.source_cache.validate()) {
                            dmc.source_cache.wait(this);
                            return;
                        }
                        synchronized (res) {
                            TCFSourceRef ref = dmc.source_cache.getData();
                            if (ref != null) res[0] = ref.area;
                            res.notify();
                        }
                    }
                });
                try {
                    res.wait();
                }
                catch (InterruptedException e) {
                }
            }
            return super.getSourceName(res[0]);
        }
        return super.getSourceName(object);
    }
}

Back to the top