/** | |
* Copyright (c) 2011 Broadcom Corporation and/or its subsidiary(-ies). | |
* All rights reserved. | |
* This component and the accompanying materials are made available | |
* under the terms of the License "Eclipse Public License v1.0" | |
* which accompanies this distribution, and is available | |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". | |
* | |
* Initial Contributors: | |
* Broadcom Corporation - initial contribution. | |
* | |
* Contributors: | |
* | |
* Description: | |
* | |
*/ | |
package org.eclipse.cdt.debug.edc.tests; | |
import java.util.Collection; | |
import org.eclipse.cdt.debug.edc.internal.services.dsf.Symbols; | |
import org.eclipse.cdt.debug.edc.symbols.IExecutableSymbolicsReader; | |
import org.eclipse.cdt.debug.edc.symbols.ISymbol; | |
import org.eclipse.cdt.utils.Addr32; | |
import org.junit.Test; | |
public class TestSymbolicsReader extends AbstractDwarfReaderTest { | |
@Test | |
public void getSymbolAtAddress() { | |
for (TestInfo info : testInfos.values()) { | |
IExecutableSymbolicsReader reader = Symbols.getSymbolReader(info.symFile); | |
assertNotNull(reader); | |
if (info.symbols == null){// No test data for that info | |
continue; | |
} | |
for (SymbolInfo symbol : info.symbols) { | |
String addressString = "0x" + symbol.address; | |
ISymbol gotSymbol = reader.getSymbolAtAddress(new Addr32(addressString)); | |
String assertMsgSuffix = symbol.toString() + ", " + gotSymbol.toString(); | |
assertNotNull("Null symbol for : " + assertMsgSuffix, gotSymbol); | |
assertEquals("Addresses equal: " + assertMsgSuffix, | |
addressString, gotSymbol.getAddress().toHexAddressString()); | |
assertEquals("Names equal " + assertMsgSuffix, | |
symbol.name, gotSymbol.getName()); | |
assertEquals("Size equal " + assertMsgSuffix, | |
symbol.size, gotSymbol.getSize()); | |
} | |
} | |
} | |
@Test | |
public void getSymbolsAtAddress() { | |
for (TestInfo info : testInfos.values()) { | |
IExecutableSymbolicsReader reader = Symbols.getSymbolReader(info.symFile); | |
assertNotNull(reader); | |
if (info.symbols == null){// No test data for that info | |
continue; | |
} | |
for (SymbolInfo symbol : info.symbols) { | |
String addressString = "0x" + symbol.address; | |
Collection<ISymbol> gotSymbols = reader.getSymbolsAtAddress(new Addr32(addressString)); | |
assertTrue("At least one symbol", gotSymbols.size() >= 1); | |
boolean foundEqualName = false; | |
for (ISymbol gotSymbol : gotSymbols) { | |
assertNotNull(gotSymbol); | |
assertEquals("Addresses equal", addressString, gotSymbol.getAddress().toHexAddressString()); | |
if (symbol.name.equals(gotSymbol.getName())) { | |
foundEqualName = true; | |
assertEquals("Size equal", symbol.size, gotSymbol.getSize()); | |
} | |
} | |
assertTrue(foundEqualName); | |
} | |
} | |
} | |
} |