1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.callstack
;
15 import java
.io
.BufferedReader
;
17 import java
.io
.FileNotFoundException
;
18 import java
.io
.FileReader
;
19 import java
.io
.IOException
;
20 import java
.util
.Collections
;
21 import java
.util
.HashMap
;
24 import org
.eclipse
.jdt
.annotation
.Nullable
;
27 * Class containing the different methods to import an address->name mapping.
29 * @author Alexandre Montplaisir
31 class FunctionNameMapper
{
33 public static @Nullable Map
<String
, String
> mapFromNmTextFile(File mappingFile
) {
34 Map
<String
, String
> map
= new HashMap
<String
, String
>();
38 fr
= new FileReader(mappingFile
);
39 } catch (FileNotFoundException e
) {
42 BufferedReader reader
= new BufferedReader(fr
);
45 for (String line
= reader
.readLine(); line
!= null; line
= reader
.readLine()) {
46 String
[] elems
= line
.split(" "); //$NON-NLS-1$
47 /* Only lines with 3 elements contain addresses */
48 if (elems
.length
== 3) {
49 /* Strip the leading zeroes from the address */
50 String address
= elems
[0].replaceFirst("^0+(?!$)", ""); //$NON-NLS-1$ //$NON-NLS-2$;
51 String name
= elems
[elems
.length
- 1];
52 map
.put(address
, name
);
56 } catch (IOException e
) {
57 /* Stop reading the file at this point */
61 } catch (IOException e
) {}
67 return Collections
.unmodifiableMap(map
);
This page took 0.056245 seconds and 6 git commands to generate.