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
<>();
36 try (FileReader fr
= new FileReader(mappingFile
);
37 BufferedReader reader
= new BufferedReader(fr
);) {
38 for (String line
= reader
.readLine(); line
!= null; line
= reader
.readLine()) {
39 String
[] elems
= line
.split(" "); //$NON-NLS-1$
40 /* Only lines with 3 elements contain addresses */
41 if (elems
.length
== 3) {
42 /* Strip the leading zeroes from the address */
43 String address
= elems
[0].replaceFirst("^0+(?!$)", ""); //$NON-NLS-1$ //$NON-NLS-2$;
44 String name
= elems
[elems
.length
- 1];
45 map
.put(address
, name
);
48 } catch (FileNotFoundException e
) {
50 } catch (IOException e
) {
51 /* Stop reading the file at this point */
57 return Collections
.unmodifiableMap(map
);
This page took 0.035919 seconds and 5 git commands to generate.