Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java')
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java168
1 files changed, 0 insertions, 168 deletions
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java
deleted file mode 100644
index 1089635ce72..00000000000
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003,2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.utils.macho.parser;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.IBinaryParser;
-import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.core.IBinaryParser.ISymbol;
-import org.eclipse.cdt.utils.BinaryObjectAdapter;
-import org.eclipse.cdt.utils.CPPFilt;
-import org.eclipse.cdt.utils.Symbol;
-import org.eclipse.cdt.utils.macho.MachO;
-import org.eclipse.cdt.utils.macho.MachOHelper;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/*
- * MachOBinaryObject
- */
-public class MachOBinaryObject extends BinaryObjectAdapter {
-
- private BinaryObjectInfo info;
- private ISymbol[] symbols;
-
- public MachOBinaryObject(IBinaryParser parser, IPath path) {
- super(parser, path);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType()
- */
- public int getType() {
- return IBinaryFile.OBJECT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.IBinaryParser.IBinaryObject#getSymbols()
- */
- public ISymbol[] getSymbols() {
- // Call the hasChanged first, to initialize the timestamp
- if (hasChanged() || symbols == null) {
- try {
- loadAll();
- } catch (IOException e) {
- symbols = NO_SYMBOLS;
- }
- }
- return symbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.utils.BinaryObjectAdapter#getBinaryObjectInfo()
- */
- protected BinaryObjectInfo getBinaryObjectInfo() {
- // Call the hasChanged first, to initialize the timestamp
- if (hasChanged() || info == null) {
- try {
- loadInfo();
- } catch (IOException e) {
- info = new BinaryObjectInfo();
- }
- }
- return info;
- }
-
- protected MachOHelper getMachOHelper() throws IOException {
- return new MachOHelper(getPath().toOSString());
- }
-
- protected void loadAll() throws IOException {
- MachOHelper helper = null;
- try {
- helper = getMachOHelper();
- loadInfo(helper);
- loadSymbols(helper);
- } finally {
- if (helper != null) {
- helper.dispose();
- }
- }
- }
-
- protected void loadInfo() throws IOException {
- MachOHelper helper = null;
- try {
- helper = getMachOHelper();
- loadInfo(helper);
- } finally {
- if (helper != null) {
- helper.dispose();
- }
- }
- }
-
- protected void loadInfo(MachOHelper helper) throws IOException {
- info = new BinaryObjectInfo();
- info.needed = helper.getNeeded();
- MachOHelper.Sizes sizes = helper.getSizes();
- info.bss = sizes.bss;
- info.data = sizes.data;
- info.text = sizes.text;
-
- info.soname = helper.getSoname();
-
- MachO.Attribute attribute = helper.getMachO().getAttributes();
- info.isLittleEndian = attribute.isLittleEndian();
- info.hasDebug = attribute.hasDebug();
- info.cpu = attribute.getCPU();
- }
-
- protected CPPFilt getCPPFilt() {
- MachOParser parser = (MachOParser) getBinaryParser();
- return parser.getCPPFilt();
- }
-
- protected void loadSymbols(MachOHelper helper) throws IOException {
- ArrayList list = new ArrayList();
- // Hack should be remove when Elf is clean
- helper.getMachO().setCppFilter(false);
-
- CPPFilt cppfilt = getCPPFilt();
-
- addSymbols(helper.getExternalFunctions(), ISymbol.FUNCTION, cppfilt, list);
- addSymbols(helper.getLocalFunctions(), ISymbol.FUNCTION, cppfilt, list);
- addSymbols(helper.getExternalObjects(), ISymbol.VARIABLE, cppfilt, list);
- addSymbols(helper.getLocalObjects(), ISymbol.VARIABLE, cppfilt, list);
- list.trimToSize();
-
- if (cppfilt != null) {
- cppfilt.dispose();
- }
-
- symbols = (ISymbol[])list.toArray(NO_SYMBOLS);
- Arrays.sort(symbols);
- list.clear();
- }
-
- protected void addSymbols(MachO.Symbol[] array, int type, CPPFilt cppfilt, List list) {
- for (int i = 0; i < array.length; i++) {
- String name = array[i].toString();
- if (cppfilt != null) {
- try {
- name = cppfilt.getFunction(name);
- } catch (IOException e1) {
- cppfilt = null;
- }
- }
- long addr = array[i].n_value;
- int size = 0;
- String filename = array[i].getFilename();
- IPath filePath = (filename != null) ? new Path(filename) : null; //$NON-NLS-1$
- list.add(new Symbol(this, name, type, array[i].n_value, size, filePath, array[i].getLineNumber(addr), array[i].getLineNumber(addr + size - 1)));
- }
- }
-
-}

Back to the top