|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.pi.instr; |
|
19 |
|
20 import java.io.File; |
|
21 |
|
22 import com.nokia.carbide.cpp.internal.pi.model.Binary; |
|
23 import com.nokia.carbide.cpp.internal.pi.model.Function; |
|
24 import com.nokia.carbide.cpp.internal.pi.model.FunctionResolver; |
|
25 import com.nokia.carbide.cpp.internal.pi.resolvers.RofsSymbolFileFunctionResolver; |
|
26 import com.nokia.carbide.cpp.pi.importer.SampleImporter; |
|
27 |
|
28 |
|
29 public class PiInstrFunctionResolver implements FunctionResolver { |
|
30 private IttTrace122 ittTrace122; |
|
31 private BinaryReader122 binaryReader122; |
|
32 private RofsSymbolFileFunctionResolver rofsResolver; |
|
33 |
|
34 boolean ableToResolve = false; |
|
35 |
|
36 String notFound = com.nokia.carbide.cpp.internal.pi.resolvers.Messages.getString("CachedFunctionResolver.notFound"); //$NON-NLS-1$ |
|
37 |
|
38 public PiInstrFunctionResolver(BinaryReader122 binaryReader122,IttTrace122 ittTrace122,int parsedMapFileCount) |
|
39 { |
|
40 this.binaryReader122 = binaryReader122; |
|
41 this.ittTrace122 = ittTrace122; |
|
42 this.rofsResolver = new RofsSymbolFileFunctionResolver(); |
|
43 |
|
44 if (ittTrace122.getEvents().size() > 0 || parsedMapFileCount > 0) |
|
45 this.ableToResolve = true; |
|
46 |
|
47 //reads the symbol name path from configuration data |
|
48 String[] list = SampleImporter.getInstance().getRofsSymbolFileList(); |
|
49 for (String filename : list) { |
|
50 File rofsSymbolFile = new File(filename); |
|
51 if (rofsSymbolFile.exists()) { |
|
52 rofsResolver.parseAndProcessSymbolFile(rofsSymbolFile); |
|
53 this.ableToResolve = true; |
|
54 } |
|
55 } |
|
56 rofsResolver.adjustRuntimeBinary(binaryReader122.getHostNameToBinary()); |
|
57 } |
|
58 |
|
59 public Binary findBinaryForAddress(long address) { |
|
60 Function f = this.findFunctionForAddress(address); |
|
61 |
|
62 if (f != null) |
|
63 return f.functionBinary; |
|
64 else |
|
65 return null; |
|
66 } |
|
67 |
|
68 public String findBinaryNameForAddress(long address) { |
|
69 Function f = this.findFunctionForAddress(address); |
|
70 if (f != null) |
|
71 { |
|
72 return f.functionBinary.binaryName; |
|
73 } |
|
74 else |
|
75 { |
|
76 return Messages.getString("PiInstrFunctionResolver.binaryNotFound"); //$NON-NLS-1$ |
|
77 } |
|
78 } |
|
79 |
|
80 public Function findFunctionForAddress(long address) { |
|
81 Function f; |
|
82 f = this.rofsResolver.findFunctionForAddress(address); |
|
83 if (f == null) { //$NON-NLS-1$ |
|
84 f = this.ittTrace122.getFunctionForAddress(address,this.binaryReader122); |
|
85 } |
|
86 return f; |
|
87 } |
|
88 |
|
89 public String findFunctionNameForAddress(long address) { |
|
90 Function f = this.findFunctionForAddress(address); |
|
91 if (f != null) |
|
92 { |
|
93 return f.functionName; |
|
94 } |
|
95 else |
|
96 { |
|
97 return Messages.getString("PiInstrFunctionResolver.functionNotFound"); //$NON-NLS-1$ |
|
98 } |
|
99 } |
|
100 |
|
101 public String getResolverName() { |
|
102 return "ITT"; //$NON-NLS-1$ |
|
103 } |
|
104 |
|
105 public String getResolverString() { |
|
106 return Messages.getString("PiInstrFunctionResolver.resolverITT"); //$NON-NLS-1$ |
|
107 } |
|
108 |
|
109 public boolean canResolve() { |
|
110 return this.ableToResolve; |
|
111 } |
|
112 } |