diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java new file mode 100644 index 00000000000..1a95d5829fc --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/TypeInfoProvider.java @@ -0,0 +1,282 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +/* + * Created on Jul 5, 2004 + */ +package org.eclipse.cdt.internal.core.parser.pst; + +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo.PtrOp; +import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo.eType; + + +public class TypeInfoProvider +{ + private static final int BASIC = 0; + private static final int TYPE = 1; + private static final int TEMPLATE = 2; + private static final int POOL_SIZE = 16; + + private final ITypeInfo [][] pool; + private final boolean [][] free; + private final int [] firstFreeHint; + + protected TypeInfoProvider() + { + + pool = new ITypeInfo[POOL_SIZE][3]; + free = new boolean [POOL_SIZE][3]; + firstFreeHint = new int [] { 0, 0, 0 }; + + for( int i = 0; i < POOL_SIZE; i++ ) + { + pool[i] = new ITypeInfo[] { newInfo( ITypeInfo.t_void, true ), + newInfo( ITypeInfo.t_type, true ), + newInfo( ITypeInfo.t_templateParameter, true ) }; + free[i] = new boolean [] { true, true, true }; + } + } + + public ITypeInfo getTypeInfo( eType t ) + { + int idx = BASIC; + if( t == ITypeInfo.t_type || t == ITypeInfo.t_enumerator ) + idx = TYPE; + else if( t == ITypeInfo.t_templateParameter ) + idx = TEMPLATE; + + ITypeInfo returnType = null; + for( int i = firstFreeHint[idx]; i < POOL_SIZE; ++i ) + { + if( free[i][idx] ) + { + free[i][idx] = false; + firstFreeHint[idx] = i + 1; + returnType = pool[i][idx]; + break; + } + } + if( returnType == null ){ + //if there is nothing free, just give them a new one + if( t == ITypeInfo.t_type ){ + returnType = new TypeInfo(); + } else if( t == ITypeInfo.t_templateParameter ) { + returnType = new TemplateParameterTypeInfo(); + } else { + returnType = new BasicTypeInfo(); + } + } + + returnType.setType( t ); + return returnType; + } + + public void returnTypeInfo( ITypeInfo t ) + { + int idx = BASIC; + if( t instanceof TemplateParameterTypeInfo ) + idx = TEMPLATE; + else if ( t instanceof TypeInfo ) + idx = TYPE; + + for( int i = 0; i < POOL_SIZE; i++ ){ + if( pool[i][idx] == t ){ + t.clear(); + free[i][idx] = true; + if( i < firstFreeHint[idx] ){ + firstFreeHint[idx] = i; + } + return; + } + } + //else it was one allocated outside the pool + } + + public int numAllocated(){ + int num = 0; + for( int i = 0; i < POOL_SIZE; i++ ){ + num += ( free[i][0] ? 0 : 1 ) + + ( free[i][1] ? 0 : 1 ) + + ( free[i][2] ? 0 : 1 ); + } + return num; + } + + /** + * @param topInfo + * @return + */ + static final public ITypeInfo newTypeInfo( ITypeInfo topInfo ) { + ITypeInfo newInfo = newInfo( topInfo.getType(), topInfo.getDefault() != null ); + + newInfo.copy( topInfo ); + return newInfo; + } + + /** + * + * @param type + * @param bits + * @param typeSymbol + * @param ptrOp + * @param hasDefault + * @return + */ + static final public ITypeInfo newTypeInfo( eType type, int bits, ISymbol typeSymbol, PtrOp ptrOp, boolean hasDefault ) { + ITypeInfo newInfo = newTypeInfo( type, bits, ptrOp, hasDefault ); + newInfo.setTypeSymbol( typeSymbol ); + return newInfo; + } + + /** + * + * @param type + * @param bits + * @param typeSymbol + * @return + */ + static final public ITypeInfo newTypeInfo( eType type, int bits, ISymbol typeSymbol ) { + ITypeInfo newInfo = newTypeInfo( type ); + newInfo.setTypeBits( bits ); + newInfo.setTypeSymbol( typeSymbol ); + return newInfo; + } + + /** + * + * @param type + * @param bits + * @param ptrOp + * @param hasDefault + * @return + */ + static final public ITypeInfo newTypeInfo( eType type, int bits, PtrOp ptrOp, boolean hasDefault ) { + ITypeInfo newInfo = newTypeInfo( type ); + newInfo.setTypeBits( bits ); + newInfo.addPtrOperator( ptrOp ); + newInfo.setHasDefault( hasDefault ); + return newInfo; + } + + /** + * @param typeInfo + * @return + */ + static final public ITypeInfo newTypeInfo( eType type ) { + ITypeInfo newInfo = newInfo( type, false ); + newInfo.setType( type ); + return newInfo; + } + + /** + * + * @param type + * @param bits + * @param symbol + * @param op + * @param def + * @return + */ + public final static ITypeInfo newTypeInfo( eType type, int bits, ISymbol symbol, PtrOp op, Object def ) { + ITypeInfo newInfo = newInfo( type, def != null ); + + newInfo.setType( type ); + newInfo.setTypeBits( bits ); + newInfo.setDefault( def ); + newInfo.setTypeSymbol( symbol ); + newInfo.addPtrOperator( op ); + return newInfo; + } + /** + * @return + */ + public final static ITypeInfo newTypeInfo() { + return new BasicTypeInfo(); + } + + /** + * Functions for constructing a Type info a piece at a time. + */ + private eType type; + private ISymbol typeSymbol; + private int bits; + private Object defaultObj; + private boolean hasDef; + private eType templateParamType; + + public void setType( eType t ) { type = t; } + public void setTypeSymbol( ISymbol s ) { typeSymbol = s; } + public void setTypeBits( int b ) { bits = b; } + public void setHasDef( boolean b ) { hasDef = b; } + public void setDefaultObj( Object obj ) { defaultObj = obj; } + public void setTemplateParameterType( eType t ) { templateParamType = t; } + + public void setBit( boolean b, int mask ) { + if( b ) bits = bits | mask; + else bits = bits & ~mask; + } + + public void beginTypeConstruction(){ + type = ITypeInfo.t_undef; + typeSymbol = null; + bits = 0; + defaultObj = null; + templateParamType = null; + hasDef = false; + } + + public ITypeInfo completeConstruction(){ + ITypeInfo newInfo = newTypeInfo( type, bits, typeSymbol, null, defaultObj ); + newInfo.setHasDefault( hasDef ); + if( templateParamType != null ) + newInfo.setTemplateParameterType( templateParamType ); + + //clear the fields + beginTypeConstruction(); + return newInfo; + } + + private final static ITypeInfo newInfo( eType type, boolean def ){ + ITypeInfo newInfo = null; + if( type == ITypeInfo.t_type || type == ITypeInfo.t_enumerator ){ + if( def ) + newInfo = new TypeInfo(){ + public void copy( ITypeInfo t ) { super.copy( t ); _defObj = t.getDefault(); } + public void setDefault( Object t ) { _defObj = t; } + public Object getDefault() { return _defObj;} + private Object _defObj; + }; + else + newInfo = new TypeInfo(); + } else if( type == ITypeInfo.t_templateParameter ){ + if( def ) + newInfo = new TemplateParameterTypeInfo(){ + public void copy( ITypeInfo t ) { super.copy( t ); _defObj = t.getDefault(); } + public void setDefault( Object t ) { _defObj = t; } + public Object getDefault() { return _defObj;} + private Object _defObj; + }; + else + newInfo = new TemplateParameterTypeInfo(); + } else { + if( def ) + newInfo = new BasicTypeInfo(){ + public void copy( ITypeInfo t ) { super.copy( t ); _defObj = t.getDefault(); } + public void setDefault( Object t ) { _defObj = t; } + public Object getDefault() { return _defObj;} + private Object _defObj; + }; + else + newInfo = new BasicTypeInfo(); + } + return newInfo; + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java new file mode 100644 index 00000000000..c83936ed8a0 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/AR.java @@ -0,0 +1,352 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.utils.som; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.Vector; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.utils.coff.ReadMemoryAccess; + +/** + * The AR class is used for parsing standard SOM archive (ar) files. + * + * @author vhirsl + */ +public class AR { + public static final String NL = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + + protected String filename; + protected RandomAccessFile file; + private byte[] ar_magic = new byte[8]; + private LSTHeader lstHeader; + private ARHeader[] memberHeaders; + + /** + * Archive and archive member header. Does not include 8-byte magic character. + * + * @author vhirsl + */ + public class ARHeader { + public static final int HEADER_SIZE = 60; + + // fields + private byte[] ar_name = new byte[16]; // file member name - '/' terminated + private byte[] ar_date = new byte[12]; // file member date - decimal + private byte[] ar_uid = new byte[6]; // file member user id - decimal + private byte[] ar_gid = new byte[6]; // file member group id - decimal + private byte[] ar_mode = new byte[8]; // file member mode - octal + private byte[] ar_size = new byte[10]; // file member size - decimal + private byte[] ar_fmag = new byte[2]; // ARFMAG - string to end header + + // derived information + String name; + public int somOffset; + public int somSize; + + public ARHeader(long offset) throws IOException { + try { + getRandomAccessFile(); + file.seek(offset); + + file.read(ar_name); + for (int i = 0; i < 16; ++ i) { + if (ar_name[i] == '/') { + name = new String(ar_name, 0, i); + } + } + file.read(ar_date); + file.read(ar_uid); + file.read(ar_gid); + file.read(ar_mode); + file.read(ar_size); + file.read(ar_fmag); + } catch (IOException e) { + dispose(); + CCorePlugin.log(e); + } + } + + /** Get the name of the object file */ + public String getObjectName() { + return name; + } + + /** Get the size of the object file . */ + public long getSize() { + return somSize; + } + + public byte[] getObjectData() throws IOException { + byte[] temp = new byte[somSize]; + file = getRandomAccessFile(); + file.seek(somOffset); + file.read(temp); + dispose(); + return temp; + } + + /** + * Create a new SOM object for the object file. + * + * @throws IOException + * Not a valid SOM object file. + * @return A new SOM object. + * @see SOM#SOM( String, long ) + */ + public SOM getSOM() throws IOException { + return new SOM(filename, somOffset); + } + } + + /** + * Library Symbol Table header + * + * @author vhirsl + */ + public class LSTHeader { + public static final int LST_HEADER_OFFSET = 68; + public static final int LST_HEADER_SIZE = 19 * 4; + + // record fields + public short system_id; + public short a_magic; + public int version_id; + public int file_time_sec; + public int file_time_nano; + public int hash_loc; + public int hash_size; + public int module_count; + public int module_limit; + public int dir_loc; + public int export_loc; + public int export_count; + public int import_loc; + public int aux_loc; + public int aux_size; + public int string_loc; + public int string_size; + public int free_list; + public int file_end; + public int checksum; + + public LSTHeader() throws IOException { + try { + getRandomAccessFile(); + file.seek(LST_HEADER_OFFSET); + byte[] lstRecord = new byte[LST_HEADER_SIZE]; + file.readFully(lstRecord); + ReadMemoryAccess memory = new ReadMemoryAccess(lstRecord, false); + + system_id = memory.getShort(); + a_magic = memory.getShort(); + version_id = memory.getInt(); + file_time_sec = memory.getInt(); + file_time_nano = memory.getInt(); + hash_loc = memory.getInt(); + hash_size = memory.getInt(); + module_count = memory.getInt(); + module_limit = memory.getInt(); + dir_loc = memory.getInt(); + export_loc = memory.getInt(); + export_count = memory.getInt(); + import_loc = memory.getInt(); + aux_loc = memory.getInt(); + aux_size = memory.getInt(); + string_loc = memory.getInt(); + string_size = memory.getInt(); + free_list = memory.getInt(); + file_end = memory.getInt(); + checksum = memory.getInt(); + } catch (IOException e) { + dispose(); + CCorePlugin.log(e); + } + } + + } + + /** + * Creates a new AR object from the contents of + * the given file. + * + * @param filename The file to process. + * @throws IOException The file is not a valid archive. + */ + public AR(String filename) throws IOException { + this.filename = filename; + file = new RandomAccessFile(filename, "r"); //$NON-NLS-1$ + file.read(ar_magic); + if (!isARHeader(ar_magic)) { + file.close(); + throw new IOException(CCorePlugin.getResourceString("Util.exception.invalidArchive")); //$NON-NLS-1$ + } + // load a LST header + lstHeader = new LSTHeader(); + } + + public void dispose() { + try { + if (file != null) { + file.close(); + file = null; + } + } catch (IOException e) { + } + } + + protected void finalize() throws Throwable { + try { + dispose(); + } finally { + super.finalize(); + } + } + + public static boolean isARHeader(byte[] ident) { + if (ident.length < 8 + || ident[0] != '!' + || ident[1] != '<' + || ident[2] != 'a' + || ident[3] != 'r' + || ident[4] != 'c' + || ident[5] != 'h' + || ident[6] != '>' + || ident[7] != '\n') + return false; + return true; + } + + private RandomAccessFile getRandomAccessFile () throws IOException { + if (file == null) { + file = new RandomAccessFile(filename, "r"); //$NON-NLS-1$ + } + return file; + } + + /** + * Get an array of all the object file headers for this archive. + * + * @throws IOException + * Unable to process the archive file. + * @return An array of headers, one for each object within the archive. + * @see ARHeader + */ + public ARHeader[] getHeaders() throws IOException { + loadHeaders(); + return memberHeaders; + } + + /** Load the headers from the file (if required). */ + private void loadHeaders() throws IOException { + if (memberHeaders != null) + return; + + Vector v = new Vector(); + try { + // + // Check for EOF condition + // + // get the SOM directory + long somDirOffset = lstHeader.dir_loc + LSTHeader.LST_HEADER_OFFSET; + // each SOM Directory entry has 2 32bit words: SOM offset from LST and size + int somDirSize = lstHeader.module_limit * 8; + getRandomAccessFile(); + file.seek(somDirOffset); + byte[] somDirectory = new byte[somDirSize]; + file.readFully(somDirectory); + ReadMemoryAccess memory = new ReadMemoryAccess(somDirectory, false); + for (int i = 0; i < lstHeader.module_limit; ++i) { + int somOffset = memory.getInt(); + int somSize = memory.getInt(); + ARHeader aHeader = new ARHeader(somOffset-ARHeader.HEADER_SIZE); + aHeader.somOffset = somOffset; + aHeader.somSize = somSize; + v.add(aHeader); + } + } catch (IOException e) { + } + memberHeaders = (ARHeader[]) v.toArray(new ARHeader[v.size()]); + } + + public String[] extractFiles(String outdir) throws IOException { + return extractFiles(outdir, null); + } + + private String[] extractFiles(String outdir, String[] names) throws IOException { + Vector names_used = new Vector(); + String object_name; + int count; + + loadHeaders(); + + count = 0; + for (int i = 0; i < memberHeaders.length; i++) { + object_name = memberHeaders[i].getObjectName(); + if (names != null && !stringInStrings(object_name, names)) + continue; + + object_name = "" + count + "_" + object_name; //$NON-NLS-1$ //$NON-NLS-2$ + count++; + + byte[] data = memberHeaders[i].getObjectData(); + File output = new File(outdir, object_name); + names_used.add(object_name); + + RandomAccessFile rfile = new RandomAccessFile(output, "rw"); //$NON-NLS-1$ + rfile.write(data); + rfile.close(); + } + + return (String[]) names_used.toArray(new String[0]); + } + + private boolean stringInStrings(String str, String[] set) { + for (int i = 0; i < set.length; i++) + if (str.compareTo(set[i]) == 0) + return true; + return false; + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + if (lstHeader != null) { + buffer.append("LST HEADER VALUES").append(NL); //$NON-NLS-1$ + buffer.append("system_id = ").append(lstHeader.system_id).append(NL); //$NON-NLS-1$ + buffer.append("a_magic = ").append(lstHeader.a_magic).append(NL); //$NON-NLS-1$ + buffer.append("version_id = ").append(lstHeader.version_id).append(NL); //$NON-NLS-1$ + buffer.append("module_count = ").append(lstHeader.module_count).append(NL); //$NON-NLS-1$ + buffer.append("module_limit = ").append(lstHeader.module_limit).append(NL); //$NON-NLS-1$ + buffer.append("dir_loc = ").append(lstHeader.dir_loc).append(NL); //$NON-NLS-1$ + + for (int i = 0; i < memberHeaders.length; ++i) { + buffer.append("MEMBER HEADER VALUES").append(NL); //$NON-NLS-1$ + buffer.append("name = ").append(memberHeaders[i].getObjectName()).append(NL); //$NON-NLS-1$ + buffer.append("somOffset = ").append(memberHeaders[i].somOffset).append(NL); //$NON-NLS-1$ + buffer.append("somSize = ").append(memberHeaders[i].getSize()).append(NL); //$NON-NLS-1$ + } + } + return buffer.toString(); + } + + public static void main(String[] args) { + try { + AR ar = new AR(args[0]); + ar.getHeaders(); + ar.extractFiles(args[1]); + System.out.println(ar); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/SOM.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/SOM.java new file mode 100644 index 00000000000..37a5adbf31c --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/SOM.java @@ -0,0 +1,570 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.utils.som; + +import java.io.EOFException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.utils.coff.ReadMemoryAccess; + +/** + * Representation of a HP-UX SOM binary format + * + * @author vhirsl + */ +public class SOM { + public static final String NL = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + + String filename; + FileHeader filehdr; + RandomAccessFile rfile; + long startingOffset; + byte[] string_table; + Symbol[] symbols; + + /** + * SOM Header record + * + * @author vhirsl + */ + public static class FileHeader { + public final static int FILHSZ = 32*4; + + // Consts + public static final short PA_RISC_10 = 0x20b; + public static final short PA_RISC_11 = 0x210; + public static final short PA_RISC_20 = 0x214; + + public static final short EXE_SOM_LIB = 0x104; // executable SOM library + public static final short REL_SOM = 0x106; // relocatable SOM + public static final short PRIV_EXEC_SOM = 0x107; // non-sharable, executable SOM + public static final short SHARE_EXEC_SOM = 0x108; // sharable, executable SOM + public static final short SHARE_DEMAND_LOAD_EXE_SOM = 0x10b; // sharable, demand-loadable executable SOM + public static final short DYN_LOAD_LIB = 0x10d; // dynamic load library + public static final short SHARED_LIB = 0x10e; // shared library + public static final short RELOC_SOM_LIB = 0x619; // relocatable SOM library + + // Fields + public short system_id; // magic number - system + public short a_magic; // magic number - file type + public int version_id; // version id; format = YYMMDDHH + public long file_time_sec; // system clock - zero if unused + public long file_time_nano; // system clock - zero if unused + public int entry_space; // index of space containing entry point + public int entry_subspace; // index of subspace for entry point + public int entry_offset; // offset of entry point + public int aux_header_location; // auxiliary header location + public int aux_header_size; // auxiliary header size + public int som_length; // length in bytes of entire som + public int presumed_dp; // DP value assumed during compilation + public int space_location; // location in file of space dictionary + public int space_total; // number of space entries + public int subspace_location; // location of subspace entries + public int subspace_total; // number of subspace entries + public int loader_fixup_location; // MPE/iX loader fixup + public int loader_fixup_total; // number of loader fixup records + public int space_strings_location; // file location of string area for space and subspace names + public int space_strings_size; // size of string area for space and subspace names + public int init_array_location; // reserved for use by system + public int init_array_total; // reserved for use by system + public int compiler_location; // location in file of module dictionary + public int compiler_total; // number of modules + public int symbol_location; // location in file of symbol dictionary + public int symbol_total; // number of symbol records + public int fixup_request_location; // location in file of fix-up requests + public int fixup_request_total; // number of fixup requests + public int symbol_strings_location; // file location of string area for module and symbol names + public int symbol_strings_size; // size of string area for module and symbol names + public int unloadable_sp_location; // byte offset of first byte of datafor unloadable spaces + public int unloadable_sp_size; // byte length of data for unloadable spaces + public int checksum; + + public FileHeader (RandomAccessFile file) throws IOException { + this(file, file.getFilePointer()); + } + + public FileHeader (RandomAccessFile file, long offset) throws IOException { + file.seek(offset); + byte[] hdr = new byte[FILHSZ]; + file.readFully(hdr); + commonSetup(hdr, false); + } + + public FileHeader (byte[] hdr, boolean little) throws IOException { + commonSetup(hdr, little); + } + + public void commonSetup(byte[] hdr, boolean little) throws IOException { + if (hdr == null || hdr.length < FILHSZ) { + throw new EOFException(CCorePlugin.getResourceString("Util.exception.arrayToSmall")); //$NON-NLS-1$ + } + if (!isSOMHeader(hdr)) { + throw new IOException(CCorePlugin.getResourceString("Util.exception.notSOM")); //$NON-NLS-1$ + } + ReadMemoryAccess memory = new ReadMemoryAccess(hdr, little); + + system_id = memory.getShort(); + a_magic = memory.getShort(); + version_id = memory.getInt(); + file_time_sec = memory.getInt(); + file_time_nano = memory.getInt(); + entry_space = memory.getInt(); + entry_subspace = memory.getInt(); + entry_offset = memory.getInt(); + aux_header_location = memory.getInt(); + aux_header_size = memory.getInt(); + som_length = memory.getInt(); + presumed_dp = memory.getInt(); + space_location = memory.getInt(); + space_total = memory.getInt(); + subspace_location = memory.getInt(); + subspace_total = memory.getInt(); + loader_fixup_location = memory.getInt(); + loader_fixup_total = memory.getInt(); + space_strings_location = memory.getInt(); + space_strings_size = memory.getInt(); + init_array_location = memory.getInt(); + init_array_total = memory.getInt(); + compiler_location = memory.getInt(); + compiler_total = memory.getInt(); + symbol_location = memory.getInt(); + symbol_total = memory.getInt(); + fixup_request_location = memory.getInt(); + fixup_request_total = memory.getInt(); + symbol_strings_location = memory.getInt(); + symbol_strings_size = memory.getInt(); + unloadable_sp_location = memory.getInt(); + unloadable_sp_size = memory.getInt(); + checksum = memory.getInt(); + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("FILE HEADER VALUES").append(NL); //$NON-NLS-1$ + + buffer.append("system_id = ").append(system_id).append(NL); //$NON-NLS-1$ + buffer.append("a_magic = ").append(a_magic).append(NL); //$NON-NLS-1$ + buffer.append("version_id = ").append(version_id).append(NL); //$NON-NLS-1$ + buffer.append("file_time_sec = ").append(file_time_sec).append(NL); //$NON-NLS-1$ + buffer.append("file_time_nano = ").append(file_time_nano).append(NL); //$NON-NLS-1$ + buffer.append("entry_space = ").append(entry_space).append(NL); //$NON-NLS-1$ + buffer.append("entry_subspace = ").append(entry_subspace).append(NL); //$NON-NLS-1$ + buffer.append("aux_header_location = ").append(aux_header_location).append(NL); //$NON-NLS-1$ + buffer.append("aux_header_size = ").append(aux_header_size).append(NL); //$NON-NLS-1$ + buffer.append("som_length = ").append(som_length).append(NL); //$NON-NLS-1$ + buffer.append("presumed_dp = ").append(presumed_dp).append(NL); //$NON-NLS-1$ + buffer.append("space_location = ").append(space_location).append(NL); //$NON-NLS-1$ + buffer.append("space_total = ").append(space_total).append(NL); //$NON-NLS-1$ + buffer.append("subspace_location = ").append(subspace_location).append(NL); //$NON-NLS-1$ + buffer.append("subspace_total = ").append(subspace_total).append(NL); //$NON-NLS-1$ + buffer.append("loader_fixup_location = ").append(loader_fixup_location).append(NL); //$NON-NLS-1$ + buffer.append("loader_fixup_total = ").append(loader_fixup_total).append(NL); //$NON-NLS-1$ + buffer.append("space_strings_location = ").append(space_strings_location).append(NL); //$NON-NLS-1$ + buffer.append("space_strings_size = ").append(space_strings_size).append(NL); //$NON-NLS-1$ + buffer.append("init_array_location = ").append(init_array_location).append(NL); //$NON-NLS-1$ + buffer.append("init_array_total = ").append(init_array_total).append(NL); //$NON-NLS-1$ + buffer.append("compiler_location = ").append(compiler_location).append(NL); //$NON-NLS-1$ + buffer.append("compiler_total = ").append(compiler_total).append(NL); //$NON-NLS-1$ + buffer.append("symbol_location = ").append(symbol_location).append(NL); //$NON-NLS-1$ + buffer.append("symbol_total = ").append(symbol_total).append(NL); //$NON-NLS-1$ + buffer.append("fixup_request_location = ").append(fixup_request_location).append(NL); //$NON-NLS-1$ + buffer.append("fixup_request_total = ").append(fixup_request_total).append(NL); //$NON-NLS-1$ + buffer.append("symbol_strings_location = ").append(symbol_strings_location).append(NL); //$NON-NLS-1$ + buffer.append("symbol_strings_size = ").append(symbol_strings_size).append(NL); //$NON-NLS-1$ + buffer.append("unloadable_sp_location = ").append(unloadable_sp_location).append(NL); //$NON-NLS-1$ + buffer.append("unloadable_sp_size = ").append(unloadable_sp_size).append(NL); //$NON-NLS-1$ + buffer.append("checksum = ").append(checksum).append(NL); //$NON-NLS-1$ + return buffer.toString(); + } + } + + public class Symbol { + public static final int SYMSZ = 5*4; // 5 words = 20 bytes + // masks + // NOTE: HP-UX denotes bit 0 as a leftmost bit in a word + // following representation denotes bit 0 as a rightmost bit in a word + public static final int B31_MASK = 0x80000000; + public static final int B30_MASK = 0x40000000; + public static final int B29_24_MASK = 0x3f000000; + public static final int B23_20_MASK = 0x00f00000; + public static final int B19_17_MASK = 0x000e0000; + public static final int B16_MASK = 0x00010000; + public static final int B15_MASK = 0x00008000; + public static final int B14_MASK = 0x00004000; + public static final int B13_MASK = 0x00002000; + public static final int B12_MASK = 0x00001000; + public static final int B11_10_MASK = 0x00000C00; + public static final int B9_0_MASK = 0x000003ff; + public static final int B23_0_MASK = 0x00ffffff; + public static final int B7_0_MASK = 0x000000ff; + + // symbol type + public static final int NULL = 0; // Invalid symbol record + public static final int ABSOLUTE = 1; // Absolute constant + public static final int DATA = 2; // Normal initialized data + public static final int CODE = 3; // Unspecified code + public static final int PRI_PROG = 4; // Primary program entry point + public static final int SEC_PROG = 5; // Secondary program entry point + public static final int ENTRY = 6; // Any code entry point + public static final int STORAGE = 7; // Uninitialized common data blocks + public static final int STUB = 8; // Import external call stub or a parameter relocation stub + public static final int MODULE = 9; // Source module name + public static final int SYM_EXT = 10; // Extension record of the current entry + public static final int ARG_EXT = 11; // -||- + public static final int MILLICODE = 12; // Millicode routine + public static final int PLABEL = 13; // Export stub for a procedure + public static final int OCT_DIS = 14; // Pointer to translated code segment exists but disabled + public static final int MILLI_EXT = 15; // Address of an external millicode routine + public static final int ST_DATA = 15; // Thread specific data + + // symbol scope + public static final int UNSAT = 0; // Import request that has not been satisfied + public static final int EXTERNAL = 1; // Import request linked to a symbol in another SOM + public static final int LOCAL = 2; // The symbol is not exported for use outside the SOM + public static final int UNIVERSAL = 3; // The symbol is exported for use outside the SOM + + // fields + public boolean hidden; // W1 b31 + public boolean secondary_def; // W1 b30 + public int symbol_type; // W1 b29-24 + public int symbol_scope; // W1 b23-20 + public int check_level; // W1 b19-17 + public boolean must_qualify; // W1 b16 + public boolean initially_frozen; // W1 b15 + public boolean memory_resident; // W1 b14 + public boolean is_common; // W1 b13 + public boolean dup_common; // W1 b12 + public int xleast; // W1 b11-10 + public int arg_reloc; // W1 b9-0 + public int name_offset; // W2 + public int qualifier_name_offset; // W3 + public boolean has_long_return; // W4 b31 + public boolean no_relocation; // W4 b30 + public int symbol_info; // W4 b23-0 + public int symbol_value; // W5 + + public Symbol(RandomAccessFile file) throws IOException { + this(file, file.getFilePointer()); + } + + public Symbol(RandomAccessFile file, long offset) throws IOException { + file.seek(offset); + byte[] bytes = new byte[SYMSZ]; + file.readFully(bytes); + ReadMemoryAccess memory = new ReadMemoryAccess(bytes, false); // big endian + // first word + int word = memory.getInt(); + hidden = (word & B31_MASK) != 0; + secondary_def = (word & B30_MASK) != 0; + symbol_type = (word & B29_24_MASK) >> 24; + symbol_scope = (word & B23_20_MASK) >> 20; + check_level = (word & B19_17_MASK) >> 17; + must_qualify = (word & B16_MASK) != 0; + initially_frozen = (word & B15_MASK) != 0; + memory_resident = (word & B14_MASK) != 0; + is_common = (word & B13_MASK) != 0; + dup_common = (word & B12_MASK) != 0; + xleast = (word & B11_10_MASK) >> 10; + arg_reloc = word & B9_0_MASK; + // second word + name_offset = memory.getInt(); + // third word + qualifier_name_offset = memory.getInt(); + // fourth word + word = memory.getInt(); + has_long_return = (word & B31_MASK) != 0; + no_relocation = (word & B30_MASK) != 0; + symbol_info = word & B23_0_MASK; + // fifth word + symbol_value = memory.getInt(); + + // check for symbol extension record and descriptor array records + if (check_level >= 1) { + // bytes = new byte[SYMSZ]; + file.readFully(bytes); + memory = new ReadMemoryAccess(bytes, false); // big endian + // an extension record is present (size 5 words = 20 bytes) + word = memory.getInt(); + int num_args = word & B7_0_MASK; + // check for argument descriptor arrays + if (num_args > 3 && check_level >=3) { + int num_descs = (num_args-3)%4 == 0 ? (num_args-3)/4 : (num_args-3)/4 + 1; + for (int i = 0; i < num_descs; ++ i) { + file.readFully(bytes); + } + } + } + } + + public String getName(byte[] table) { + if (qualifier_name_offset != 0) { + byte[] len = new byte[4]; + System.arraycopy(table, qualifier_name_offset-4, len, 0, 4); + ReadMemoryAccess memory = new ReadMemoryAccess(len, false); // big endian + int length = memory.getInt(); + return new String(table, qualifier_name_offset, length); + } + if (name_offset != 0) { + byte[] len = new byte[4]; + System.arraycopy(table, name_offset-4, len, 0, 4); + ReadMemoryAccess memory = new ReadMemoryAccess(len, false); // big endian + int length = memory.getInt(); + return new String(table, name_offset, length); + } + return ""; //$NON-NLS-1$ + } + + public boolean isFunction() { + return (symbol_type == PRI_PROG || + (symbol_type == ENTRY && symbol_scope != LOCAL)); + } + + public boolean isVariable() { + return ((symbol_type == DATA && symbol_scope != LOCAL) || + symbol_type == STORAGE); + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("SYMBOL TABLE ENTRY").append(NL); //$NON-NLS-1$ + buffer.append("symbol_name = "); + try { + buffer.append(getName(getStringTable())).append(NL); + } + catch (IOException e) { + buffer.append("I/O error"); //$NON-NLS-1$ + } + buffer.append("symbol_value = ").append(symbol_value).append(NL); //$NON-NLS-1$ + buffer.append("symbol_type = ").append(symbol_type).append(NL); //$NON-NLS-1$ + buffer.append("symbol_scope = ").append(symbol_scope).append(NL); //$NON-NLS-1$ + return buffer.toString(); + } + } + + public static class Attribute { + public static final int SOM_TYPE_EXE = 1; + public static final int SOM_TYPE_SHLIB = 2; + public static final int SOM_TYPE_OBJ = 3; + public static final int SOM_TYPE_CORE = 4; + + String cpu; + int type; + boolean bDebug; + boolean isle; + + public String getCPU() { + return cpu; + } + + public int getType() { + return type; + } + + public boolean hasDebug() { + return bDebug; + } + + public boolean isLittleEndian() { + return isle; + } + } + + /* + * SOM class implementation + */ + // A hollow entry, to be used with caution in controlled situations + protected SOM() { + } + + public SOM(String filename) throws IOException { + this(filename, 0); + } + + public SOM(String filename, long offset) throws IOException { + this.filename = filename; + commonSetup(new RandomAccessFile(filename, "r"), offset); + } + + void commonSetup(RandomAccessFile file, long offset) throws IOException { + startingOffset = offset; + rfile = file; + try { + filehdr = new FileHeader(rfile, startingOffset); + } finally { + dispose(); + } + } + + public void dispose() throws IOException { + if (rfile != null) { + rfile.close(); + rfile = null; + } + } + + RandomAccessFile getRandomAccessFile () throws IOException { + if (rfile == null) { + rfile = new RandomAccessFile(filename, "r"); //$NON-NLS-1$ + } + return rfile; + } + + public FileHeader getFileHeader() throws IOException { + return filehdr; + } + + public Attribute getAttributes() { + Attribute attrib = new Attribute(); + // Machine type. + switch (filehdr.system_id) { + case FileHeader.PA_RISC_10: + attrib.cpu = "pa-risc_1.0"; //$NON-NLS-1$ + break; + case FileHeader.PA_RISC_11: + attrib.cpu = "pa-risc_1.1"; //$NON-NLS-1$ + break; + case FileHeader.PA_RISC_20: + attrib.cpu = "pa-risc_2.0"; //$NON-NLS-1$ + break; + default: + attrib.cpu = "unknown"; //$NON-NLS-1$ + break; + } + + /* SOM characteristics, FileHeader.a_magic. */ + switch (filehdr.a_magic) { + case FileHeader.EXE_SOM_LIB: + case FileHeader.PRIV_EXEC_SOM: + case FileHeader.SHARE_EXEC_SOM: + case FileHeader.SHARE_DEMAND_LOAD_EXE_SOM: + attrib.type = Attribute.SOM_TYPE_EXE; + break; + case FileHeader.DYN_LOAD_LIB: + case FileHeader.SHARED_LIB: + attrib.type = Attribute.SOM_TYPE_SHLIB; + break; + default: + attrib.type = Attribute.SOM_TYPE_OBJ; + } + + // For HP-UX SOM always assume big endian unless otherwise. + attrib.isle = false; + + // No debug information. + if (filehdr.symbol_location == 0 && filehdr.symbol_total == 0) { + attrib.bDebug = false; + } else { + attrib.bDebug = true; + } + + return attrib; + } + + public Symbol[] getSymbols() throws IOException { + if (symbols == null) { + long offset = startingOffset + getFileHeader().symbol_location; + getRandomAccessFile(); + rfile.seek(offset); + int numSymbols = getFileHeader().symbol_total; + ArrayList symList = new ArrayList(numSymbols); + for (int i = 0; i < numSymbols; ++i) { + Symbol v = new Symbol(rfile); + symList.add(v); + } + symbols = (Symbol[]) symList.toArray(new Symbol[symList.size()]); + } + return symbols; + } + + public byte[] getStringTable() throws IOException { + if (string_table == null) { + if (getFileHeader().symbol_strings_size > 0) { + getRandomAccessFile(); + long offset = startingOffset+ getFileHeader().symbol_strings_location; + rfile.seek(offset); + string_table = new byte[getFileHeader().symbol_strings_size]; + rfile.readFully(string_table); + } + else { + string_table = new byte[0]; + } + } + return string_table; + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + try { + FileHeader header = null; + header = getFileHeader(); + if (header != null) { + buffer.append(header); + } + getSymbols(); + for (int i = 0; i < symbols.length; ++i) { + buffer.append(symbols[i]); + } + } catch (IOException e) { + e.printStackTrace(); + } + return buffer.toString(); + } + + /** + * @param hints + * @return + */ + public static boolean isSOMHeader(byte[] hints) { + if (hints != null && hints[0] == 0x02 && + (hints[1] == (byte)0xb || hints[1] == (byte)0x10 || hints[1] == (byte)0x14) ) { + return true; + } + return false; + } + + /** + * @param hints + * @return + * @throws IOException + */ + public static Attribute getAttributes(byte[] hints) throws IOException { + SOM emptyXCoff = new SOM(); + emptyXCoff.filehdr = new SOM.FileHeader(hints, false); // big endian + Attribute attribute = emptyXCoff.getAttributes(); + emptyXCoff.dispose(); + return attribute; + } + + /** + * @param file + * @return + * @throws IOException + */ + public static Attribute getAttributes(String file) throws IOException { + SOM xcoff = new SOM(file); + Attribute attribute = xcoff.getAttributes(); + xcoff.dispose(); + return attribute; + } + + public static void main(String[] args) { + try { + SOM som = new SOM(args[0]); + System.out.println(som); + } + catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java new file mode 100644 index 00000000000..83f5828ee93 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java @@ -0,0 +1,107 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.utils.som.parser; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.IBinaryParser; +import org.eclipse.cdt.core.IBinaryParser.ISymbol; +import org.eclipse.core.runtime.IPath; + +import org.eclipse.cdt.utils.CPPFilt; +import org.eclipse.cdt.utils.Symbol; +import org.eclipse.cdt.utils.som.AR; +import org.eclipse.cdt.utils.som.SOM; + +/** + * A member of a SOM archive + * + * @author vhirsl + */ +public class ARMember extends SOMBinaryObject { + private AR.ARHeader header; + + /** + * @param parser + * @param path + */ + public ARMember(IBinaryParser parser, IPath path, AR.ARHeader header) { + super(parser, path); + this.header = header; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.som.parser.SOMBinaryObject#addSymbols(org.eclipse.cdt.utils.som.SOM.Symbol[], byte[], org.eclipse.cdt.utils.Addr2line, org.eclipse.cdt.utils.CPPFilt, org.eclipse.cdt.utils.CygPath, java.util.List) + */ + protected void addSymbols(SOM.Symbol[] peSyms, byte[] table, List list) { + CPPFilt cppfilt = getCPPFilt(); + for (int i = 0; i < peSyms.length; i++) { + if (peSyms[i].isFunction() || peSyms[i].isVariable()) { + String name = peSyms[i].getName(table); + if (name == null || name.trim().length() == 0 || + !Character.isJavaIdentifierStart(name.charAt(0))) { + continue; + } + if (cppfilt != null) { + try { + name = cppfilt.getFunction(name); + } catch (IOException e1) { + cppfilt = null; + } + } + Symbol sym = new Symbol(this, name, peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE, peSyms[i].symbol_value, 1); + + list.add(sym); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.som.parser.SOMBinaryObject#getSOM() + */ + protected SOM getSOM() throws IOException { + if (header != null) { + return header.getSOM(); + } + throw new IOException(CCorePlugin.getResourceString("Util.exception.noFileAssociation")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getContents() + */ + public InputStream getContents() { + InputStream stream = null; + if (path != null && header != null) { + try { + stream = new ByteArrayInputStream(header.getObjectData()); + } catch (IOException e) { + } + } + if (stream == null) { + stream = super.getContents(); + } + return stream; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryObject#getName() + */ + public String getName() { + if (header != null) { + return header.getObjectName(); + } + return ""; //$NON-NLS-1$ + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/BinaryArchive.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/BinaryArchive.java new file mode 100644 index 00000000000..5713f1d0ce6 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/BinaryArchive.java @@ -0,0 +1,74 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.utils.som.parser; + +import java.io.IOException; +import java.util.ArrayList; + +import org.eclipse.cdt.core.IBinaryParser; +import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; +import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; +import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; +import org.eclipse.cdt.utils.BinaryFile; +import org.eclipse.cdt.utils.som.AR; +import org.eclipse.core.runtime.IPath; + +/** + * SOM binary archive + * + * @author vhirsl + */ +public class BinaryArchive extends BinaryFile implements IBinaryArchive { + private ArrayList children; + + /** + * @param parser + * @param path + * @throws IOException + */ + public BinaryArchive(IBinaryParser parser, IPath path) throws IOException { + super(parser, path); + new AR(path.toOSString()).dispose(); // check file type + children = new ArrayList(5); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType() + */ + public int getType() { + return IBinaryFile.ARCHIVE; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryArchive#getObjects() + */ + public IBinaryObject[] getObjects() { + if (hasChanged()) { + children.clear(); + AR ar = null; + try { + ar = new AR(getPath().toOSString()); + AR.ARHeader[] headers = ar.getHeaders(); + for (int i = 0; i < headers.length; i++) { + IBinaryObject bin = new ARMember(getBinaryParser(), getPath(), headers[i]); + children.add(bin); + } + } catch (IOException e) { + //e.printStackTrace(); + } + if (ar != null) { + ar.dispose(); + } + children.trimToSize(); + } + return (IBinaryObject[]) children.toArray(new IBinaryObject[0]); + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java new file mode 100644 index 00000000000..769a495cbed --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java @@ -0,0 +1,265 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.utils.som.parser; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +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.Addr2line; +import org.eclipse.cdt.utils.BinaryObjectAdapter; +import org.eclipse.cdt.utils.CPPFilt; +import org.eclipse.cdt.utils.Objdump; +import org.eclipse.cdt.utils.som.SOM; +import org.eclipse.cdt.utils.som.parser.SOMParser; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * Binary file in HP-UX SOM format + * + * @author vhirsl + */ +public class SOMBinaryObject extends BinaryObjectAdapter { + Addr2line addr2line; + BinaryObjectInfo info; + ISymbol[] symbols; + + /** + * @param parser + * @param path + */ + public SOMBinaryObject(IBinaryParser parser, IPath path) { + super(parser, path); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryObject#getSymbols() + */ + public ISymbol[] getSymbols() { + 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() { + if (hasChanged() || info == null) { + try { + loadInfo(); + } catch (IOException e) { + info = new BinaryObjectInfo(); + } + } + return info; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType() + */ + public int getType() { + return IBinaryFile.OBJECT; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getContents() + */ + public InputStream getContents() { + InputStream stream = null; + Objdump objdump = getObjdump(); + if (objdump != null) { + try { + byte[] contents = objdump.getOutput(); + stream = new ByteArrayInputStream(contents); + } catch (IOException e) { + // Nothing + } + } + if (stream == null) { + stream = super.getContents(); + } + return stream; + } + + protected SOM getSOM() throws IOException { + return new SOM(getPath().toOSString()); + } + + protected void loadAll() throws IOException { + SOM som = null; + try { + som = getSOM(); + loadInfo(som); + loadSymbols(som); + } finally { + if (som != null) { + som.dispose(); + } + } + } + + protected void loadInfo() throws IOException { + SOM som = null; + try { + som = getSOM(); + loadInfo(som); + } finally { + if (som != null) { + som.dispose(); + } + } + } + + protected void loadInfo(SOM som) throws IOException { + info = new BinaryObjectInfo(); + SOM.Attribute attribute = som.getAttributes(); + info.isLittleEndian = attribute.isLittleEndian(); + info.hasDebug = attribute.hasDebug(); + info.cpu = attribute.getCPU(); + } + + protected void loadSymbols(SOM som) throws IOException { + ArrayList list = new ArrayList(); + + SOM.Symbol[] peSyms = som.getSymbols(); + byte[] table = som.getStringTable(); + addSymbols(peSyms, table, list); + + symbols = (ISymbol[])list.toArray(NO_SYMBOLS); + Arrays.sort(symbols); + list.clear(); + } + + protected void addSymbols(SOM.Symbol[] peSyms, byte[] table, List list) { + CPPFilt cppfilt = getCPPFilt(); + Addr2line addr2line = getAddr2line(false); + for (int i = 0; i < peSyms.length; i++) { + if (peSyms[i].isFunction() || peSyms[i].isVariable()) { + String name = peSyms[i].getName(table); + if (name == null || name.trim().length() == 0 || + !Character.isJavaIdentifierStart(name.charAt(0))) { + continue; + } + int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; + int addr = peSyms[i].symbol_value; + int size = 4; + if (cppfilt != null) { + try { + name = cppfilt.getFunction(name); + } catch (IOException e1) { + cppfilt = null; + } + } + if (addr2line != null) { + try { + String filename = addr2line.getFileName(addr); + // Addr2line returns the funny "??" when it can not find the file. + if (filename != null && filename.equals("??")) { //$NON-NLS-1$ + filename = null; + } + + IPath file = filename != null ? new Path(filename) : Path.EMPTY; + int startLine = addr2line.getLineNumber(addr); + int endLine = addr2line.getLineNumber(addr + size - 1); + list.add(new SomSymbol(this, name, type, addr, size, file, startLine, endLine)); + } catch (IOException e) { + addr2line = null; + // the symbol still needs to be added + list.add(new SomSymbol(this, name, type, addr, size)); + } + } else { + list.add(new SomSymbol(this, name, type, addr, size)); + } + } + } + if (cppfilt != null) { + cppfilt.dispose(); + } + if (addr2line != null) { + addr2line.dispose(); + } + } + + public Addr2line getAddr2line(boolean autodisposing) { + if (!autodisposing) { + SOMParser parser = (SOMParser) getBinaryParser(); + return parser.getAddr2line(getPath()); + } + if (addr2line == null) { + SOMParser parser = (SOMParser) getBinaryParser(); + addr2line = parser.getAddr2line(getPath()); + if (addr2line != null) { + timestamp = System.currentTimeMillis(); + Runnable worker = new Runnable() { + + public void run() { + long diff = System.currentTimeMillis() - timestamp; + while (diff < 10000) { + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + break; + } + diff = System.currentTimeMillis() - timestamp; + } + stopAddr2Line(); + } + }; + new Thread(worker, "Addr2line Reaper").start(); //$NON-NLS-1$ + } + } else { + timestamp = System.currentTimeMillis(); + } + return addr2line; + } + + synchronized void stopAddr2Line() { + if (addr2line != null) { + addr2line.dispose(); + } + addr2line = null; + } + + protected CPPFilt getCPPFilt() { + SOMParser parser = (SOMParser)getBinaryParser(); + return parser.getCPPFilt(); + } + + protected Objdump getObjdump() { + SOMParser parser = (SOMParser)getBinaryParser(); + return parser.getObjdump(getPath()); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class adapter) { + if (adapter == Addr2line.class) { + return getAddr2line(false); + } else if (adapter == CPPFilt.class) { + return getCPPFilt(); + } + return super.getAdapter(adapter); + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java new file mode 100644 index 00000000000..d17f552548e --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMParser.java @@ -0,0 +1,267 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.utils.som.parser; + +import java.io.EOFException; +import java.io.IOException; + +import org.eclipse.cdt.core.AbstractCExtension; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.IBinaryParser; +import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.cdt.utils.Addr2line; +import org.eclipse.cdt.utils.CPPFilt; +import org.eclipse.cdt.utils.IGnuToolFactory; +import org.eclipse.cdt.utils.Objdump; +import org.eclipse.cdt.utils.som.AR; +import org.eclipse.cdt.utils.som.SOM; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * HP-UX SOM binary parser + * + * @author vhirsl + */ +public class SOMParser extends AbstractCExtension implements IBinaryParser, IGnuToolFactory { + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser#getBinary(byte[], org.eclipse.core.runtime.IPath) + */ + public IBinaryFile getBinary(byte[] hints, IPath path) throws IOException { + if (path == null) { + throw new IOException(CCorePlugin.getResourceString("Util.exception.nullPath")); //$NON-NLS-1$ + } + + IBinaryFile binary = null; + if (isBinary(hints, path)) { + try { + SOM.Attribute attribute = null; + if (hints != null && hints.length > 0) { + try { + attribute = SOM.getAttributes(hints); + } catch (EOFException eof) { + // continue, the array was to small. + } + } + + //Take a second run at it if the data array failed. + if(attribute == null) { + attribute = SOM.getAttributes(path.toOSString()); + } + + if (attribute != null) { + switch (attribute.getType()) { + case SOM.Attribute.SOM_TYPE_EXE : + binary = createBinaryExecutable(path); + break; + + case SOM.Attribute.SOM_TYPE_SHLIB : + binary = createBinaryShared(path); + break; + + case SOM.Attribute.SOM_TYPE_OBJ : + binary = createBinaryObject(path); + break; + + case SOM.Attribute.SOM_TYPE_CORE : + binary = createBinaryCore(path); + break; + } + } + } catch (IOException e) { + binary = createBinaryArchive(path); + } + } + return binary; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath) + */ + public IBinaryFile getBinary(IPath path) throws IOException { + return getBinary(null, path); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser#getFormat() + */ + public String getFormat() { + return "SOM"; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath) + */ + public boolean isBinary(byte[] hints, IPath path) { + return SOM.isSOMHeader(hints) || AR.isARHeader(hints); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser#getHintBufferSize() + */ + public int getHintBufferSize() { + return 512; // size of file header + } + + /** + * @param path + * @return + */ + private IBinaryFile createBinaryExecutable(IPath path) { + return new SOMBinaryObject(this, path) { + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType() + */ + public int getType() { + return IBinaryFile.EXECUTABLE; + } + }; + } + + /** + * @param path + * @return + */ + private IBinaryFile createBinaryShared(IPath path) { + return new SOMBinaryObject(this, path) { + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType() + */ + public int getType() { + return IBinaryFile.SHARED; + } + }; + } + + /** + * @param path + * @return + */ + private IBinaryFile createBinaryObject(IPath path) { + return new SOMBinaryObject(this, path); + } + + /** + * @param path + * @return + */ + private IBinaryFile createBinaryCore(IPath path) { + return new SOMBinaryObject(this, path) { + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.IBinaryFile#getType() + */ + public int getType() { + return IBinaryFile.CORE; + } + }; + } + + /** + * @param path + * @return + * @throws IOException + */ + private IBinaryFile createBinaryArchive(IPath path) throws IOException { + return new BinaryArchive(this, path); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IGnuToolFactory#getAddr2line(org.eclipse.core.runtime.IPath) + */ + public Addr2line getAddr2line(IPath path) { + IPath addr2LinePath = getAddr2linePath(); + Addr2line addr2line = null; + if (addr2LinePath != null && !addr2LinePath.isEmpty()) { + try { + addr2line = new Addr2line(addr2LinePath.toOSString(), path.toOSString()); + } catch (IOException e1) { + } + } + return addr2line; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IGnuToolFactory#getCPPFilt() + */ + public CPPFilt getCPPFilt() { + IPath cppFiltPath = getCPPFiltPath(); + CPPFilt cppfilt = null; + if (cppFiltPath != null && ! cppFiltPath.isEmpty()) { + try { + cppfilt = new CPPFilt(cppFiltPath.toOSString()); + } catch (IOException e2) { + } + } + return cppfilt; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IGnuToolFactory#getObjdump(org.eclipse.core.runtime.IPath) + */ + public Objdump getObjdump(IPath path) { + IPath objdumpPath = getObjdumpPath(); + String objdumpArgs = getObjdumpArgs(); + Objdump objdump = null; + if (objdumpPath != null && !objdumpPath.isEmpty()) { + try { + objdump = new Objdump(objdumpPath.toOSString(), objdumpArgs, path.toOSString()); + } catch (IOException e1) { + } + } + return objdump; + } + + protected IPath getAddr2linePath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("addr2line"); //$NON-NLS-1$ + if (value == null || value.length() == 0) { + value = "addr2line"; //$NON-NLS-1$ + } + return new Path(value); + } + + protected IPath getObjdumpPath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("objdump"); //$NON-NLS-1$ + if (value == null || value.length() == 0) { + value = "objdump"; //$NON-NLS-1$ + } + return new Path(value); + } + + protected String getObjdumpArgs() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("objdumpArgs"); //$NON-NLS-1$ + if (value == null || value.length() == 0) { + value = ""; //$NON-NLS-1$ + } + return value; + } + + protected IPath getCPPFiltPath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$ + if (value == null || value.length() == 0) { + value = "c++filt"; //$NON-NLS-1$ + } + return new Path(value); + } + + protected IPath getStripPath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("strip"); //$NON-NLS-1$ + if (value == null || value.length() == 0) { + value = "strip"; //$NON-NLS-1$ + } + return new Path(value); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java new file mode 100644 index 00000000000..c62576190bd --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java @@ -0,0 +1,266 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 IBM Corporation 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.ui.dialogs; + +import java.io.File; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.cdt.internal.ui.CUIMessages; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.utils.ui.controls.ControlFactory; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * Abstract base binary parser page for GNU binutils based binary parsers + */ +public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage { + + public final static String PREF_ADDR2LINE_PATH = CUIPlugin.PLUGIN_ID + ".addr2line"; //$NON-NLS-1$ + public final static String PREF_CPPFILT_PATH = CUIPlugin.PLUGIN_ID + ".cppfilt"; //$NON-NLS-1$ + + protected Text fAddr2LineCommandText; + protected Text fCPPFiltCommandText; + private String parserID = null; + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor) + */ + public void performApply(IProgressMonitor monitor) throws CoreException { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + + String addr2line = fAddr2LineCommandText.getText().trim(); + String cppfilt = fCPPFiltCommandText.getText().trim(); + + monitor.beginTask(CUIMessages.getString("BinaryParserPage.task.savingAttributes"), 1); //$NON-NLS-1$ + IProject proj = getContainer().getProject(); + if (proj != null) { + ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false); + ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID); + if (cext.length > 0) { + initializeParserId(); + for (int i = 0; i < cext.length; i++) { + if (cext[i].getID().equals(parserID)) { + String orig = cext[i].getExtensionData("addr2line"); //$NON-NLS-1$ + if (orig == null || !orig.equals(addr2line)) { + cext[i].setExtensionData("addr2line", addr2line); //$NON-NLS-1$ + } + orig = cext[i].getExtensionData("c++filt"); //$NON-NLS-1$ + if (orig == null || !orig.equals(cppfilt)) { + cext[i].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$ + } + } + } + } + } else { + Preferences store = getContainer().getPreferences(); + if (store != null) { + store.setValue(PREF_ADDR2LINE_PATH, addr2line); + store.setValue(PREF_CPPFILT_PATH, cppfilt); + } + } + } + + private void initializeParserId() { + if (parserID == null) { + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$ + IConfigurationElement[] infos = point.getConfigurationElements(); + for (int i = 0; i < infos.length; i++) { + String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$ + String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$ + String ego = getRealBinaryParserPage().getClass().getName(); + if (clazz != null && clazz.equals(ego)) { + parserID = id; + return; + } + } + parserID = ""; //$NON-NLS-1$ + } + } + + /** + * If this class is inherited from then this method MUST be implemented + * in the derived class. + */ + abstract protected AbstractGNUBinaryParserPage getRealBinaryParserPage(); + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() + */ + public void performDefaults() { + String addr2line = null; + String cppfilt = null; + IProject proj = getContainer().getProject(); + Preferences store = getContainer().getPreferences(); + if (store != null) { + if (proj != null) { + addr2line = store.getString(PREF_ADDR2LINE_PATH); + cppfilt = store.getString(PREF_CPPFILT_PATH); + } else { + addr2line = store.getDefaultString(PREF_ADDR2LINE_PATH); + cppfilt = store.getDefaultString(PREF_CPPFILT_PATH); + } + fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line); //$NON-NLS-1$ + fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$ + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Group comp = new Group(parent, SWT.SHADOW_ETCHED_IN); + comp.setText(CUIMessages.getString("BinaryParserBlock.binaryParserOptions")); //$NON-NLS-1$ + comp.setLayout(new GridLayout(2, true)); + comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; + + Label label = ControlFactory.createLabel(comp, CUIMessages.getString("BinaryParserPage.label.addr2lineCommand")); //$NON-NLS-1$ + GridData gd = new GridData(); + gd.horizontalSpan = 2; + label.setLayoutData(gd); + + fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER); + fAddr2LineCommandText.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent evt) { + //updateLaunchConfigurationDialog(); + } + }); + + Button button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse")); //$NON-NLS-1$ + button.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent evt) { + handleAddr2LineButtonSelected(); + //updateLaunchConfigurationDialog(); + } + + private void handleAddr2LineButtonSelected() { + FileDialog dialog = new FileDialog(getShell(), SWT.NONE); + dialog.setText(CUIMessages.getString("BinaryParserPage.label.addr2lineCommand")); //$NON-NLS-1$ + String command = fAddr2LineCommandText.getText().trim(); + int lastSeparatorIndex = command.lastIndexOf(File.separator); + if (lastSeparatorIndex != -1) { + dialog.setFilterPath(command.substring(0, lastSeparatorIndex)); + } + String res = dialog.open(); + if (res == null) { + return; + } + fAddr2LineCommandText.setText(res); + } + }); + + label = ControlFactory.createLabel(comp, CUIMessages.getString("BinaryParserPage.label.cppfiltCommand")); //$NON-NLS-1$ + gd = new GridData(); + gd.horizontalSpan = 2; + label.setLayoutData(gd); + + fCPPFiltCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); + fCPPFiltCommandText.setLayoutData(gd); + fCPPFiltCommandText.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent evt) { + //updateLaunchConfigurationDialog(); + } + }); + button = ControlFactory.createPushButton(comp, CUIMessages.getString("BinaryParserPage.label.browse1")); //$NON-NLS-1$ + button.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent evt) { + handleCPPFiltButtonSelected(); + //updateLaunchConfigurationDialog(); + } + + private void handleCPPFiltButtonSelected() { + FileDialog dialog = new FileDialog(getShell(), SWT.NONE); + dialog.setText(CUIMessages.getString("BinaryParserPage.label.cppfiltCommand")); //$NON-NLS-1$ + String command = fCPPFiltCommandText.getText().trim(); + int lastSeparatorIndex = command.lastIndexOf(File.separator); + if (lastSeparatorIndex != -1) { + dialog.setFilterPath(command.substring(0, lastSeparatorIndex)); + } + String res = dialog.open(); + if (res == null) { + return; + } + fCPPFiltCommandText.setText(res); + } + }); + + setControl(comp); + initialziedValues(); + } + + private void initialziedValues() { + String addr2line = null; + String cppfilt = null; + IProject proj = getContainer().getProject(); + if (proj != null) { + try { + ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false); + ICExtensionReference[] cext = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID); + if (cext.length > 0) { + initializeParserId(); + for (int i = 0; i < cext.length; i++) { + if (cext[i].getID().equals(parserID)) { + addr2line = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$ + cppfilt = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$ + break; + } + } + } + } catch (CoreException e) { + } + } else { + Preferences store = getContainer().getPreferences(); + if (store != null) { + addr2line = store.getString(PREF_ADDR2LINE_PATH); + cppfilt = store.getString(PREF_CPPFILT_PATH); + } + } + fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line); //$NON-NLS-1$ + fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$ + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java new file mode 100644 index 00000000000..a2aeffa371f --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java @@ -0,0 +1,29 @@ +/********************************************************************** + * Copyright (c) 2004 IBM Corporation 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: + * IBM - Initial API and implementation + **********************************************************************/ +package org.eclipse.cdt.ui.dialogs; + +/** + * Reusing AbstractGNUBinaryParserPage. + * New class is required for the algorithm in method performApply. + * Must implement getRealBinaryParserPage method. + * + * @author vhirsl + */ +public class GNUSomBinaryParserPage extends AbstractGNUBinaryParserPage { + + /* (non-Javadoc) + * @see org.eclipse.cdt.ui.dialogs.AbstractGNUBinaryParserPage#getRealBinaryParserPage() + */ + protected AbstractGNUBinaryParserPage getRealBinaryParserPage() { + return this; + } + +} diff --git a/releng/org.eclipse.cdt.releng/build.sh b/releng/org.eclipse.cdt.releng/build.sh new file mode 100644 index 00000000000..ff583a58e7d --- /dev/null +++ b/releng/org.eclipse.cdt.releng/build.sh @@ -0,0 +1,10 @@ +# Treat this is an example build script +# Please adjust paths as necessary for your build machine + +export JAVA_HOME=/opt/java/j2sdk1.4.2_03 +export PATH=$JAVA_HOME/bin:$PATH +export ECLIPSE_HOME=~/eclipse/3.0/eclipse + +cd `dirname $0` + +java -cp $ECLIPSE_HOME/startup.jar org.eclipse.core.launcher.Main -application org.eclipse.ant.core.antRunner $* 2>&1 | tee build.log diff --git a/releng/org.eclipse.cdt.releng/build.xml b/releng/org.eclipse.cdt.releng/build.xml new file mode 100644 index 00000000000..7af6900fb54 --- /dev/null +++ b/releng/org.eclipse.cdt.releng/build.xml @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + @buildId@ + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/releng/org.eclipse.cdt.releng/buildindex.html b/releng/org.eclipse.cdt.releng/buildindex.html new file mode 100644 index 00000000000..e1c42ffbfc4 --- /dev/null +++ b/releng/org.eclipse.cdt.releng/buildindex.html @@ -0,0 +1,124 @@ + + + + CDT @branchVersion@ Build @buildId@ + + +

CDT @branchVersion@ Build @buildId@

+

Compile Log
+

+

CDT Runtime Feature

+

includes editor, search, builders, launch, debug, gnu toolchain +integrations for build/debug, user documentation
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AIX/ppcorg.eclipse.cdt-@branchVersion@-@buildId@-aix.ppc.zip
+
HPUX/PA_RISC
+
org.eclipse.cdt-@branchVersion@-@buildId@-hpux.PA_RISC.zip
+
Linux/x86
+
org.eclipse.cdt-@branchVersion@-@buildId@-linux.x86.zip
MacOSX/ppc
+
org.eclipse.cdt-@branchVersion@-@buildId@-macosx.ppc.tar.gz
+
QNX/x86
+
org.eclipse.cdt-@branchVersion@-@buildId@-qnx.x86.zip
+
Solaris/sparc
+
org.eclipse.cdt-@branchVersion@-@buildId@-solaris.sparc.zip
+
Win32/x86
+
org.eclipse.cdt-@branchVersion@-@buildId@-win32.x86.zip
+
+
+

CDT SDK Feature

+

superset of runtime that adds source and extension point schemas

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AIX/ppcorg.eclipse.cdt.sdk-@branchVersion@-@buildId@-aix.ppc.zip
+
HPUX/PA_RISC
+
org.eclipse.cdt.sdk-@branchVersion@-@buildId@-hpux.PA_RISC.zip
+
Linux/x86
+
org.eclipse.cdt.sdk-@branchVersion@-@buildId@-linux.x86.zip
MacOSX/ppc
+
org.eclipse.cdt.sdk-@branchVersion@-@buildId@-macosx.ppc.tar.gz
+
QNX/x86
+
org.eclipse.cdt.sdk-@branchVersion@-@buildId@-qnx.x86.zip
+
Solaris/sparc
+
org.eclipse.cdt.sdk-@branchVersion@-@buildId@-solaris.sparc.zip
+
Win32/x86
+
org.eclipse.cdt.sdk-@branchVersion@-@buildId@-win32.x86.zip
+
+
+
+ + diff --git a/releng/org.eclipse.cdt.releng/maps/cdt.map b/releng/org.eclipse.cdt.releng/maps/cdt.map new file mode 100644 index 00000000000..45365cb8a9f --- /dev/null +++ b/releng/org.eclipse.cdt.releng/maps/cdt.map @@ -0,0 +1,45 @@ +! Cross platform + +plugin@org.eclipse.cdt.core=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core +plugin@org.eclipse.cdt.ui=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.ui + +plugin@org.eclipse.cdt.make.core=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-build/org.eclipse.cdt.make.core +plugin@org.eclipse.cdt.make.ui=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-build/org.eclipse.cdt.make.ui + +plugin@org.eclipse.cdt.managedbuilder.core=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.core +plugin@org.eclipse.cdt.managedbuilder.ui=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-build/org.eclipse.cdt.managedbuilder.ui + +plugin@org.eclipse.cdt.debug.core=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-debug/org.eclipse.cdt.debug.core +plugin@org.eclipse.cdt.debug.ui=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-debug/org.eclipse.cdt.debug.ui + +plugin@org.eclipse.cdt.debug.mi.core=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core +plugin@org.eclipse.cdt.debug.mi.ui=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.ui + +plugin@org.eclipse.cdt.launch=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-launch/org.eclipse.cdt.launch + +plugin@org.eclipse.cdt.doc.user=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-doc/org.eclipse.cdt.doc.user + +plugin@org.eclipse.cdt=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-releng/org.eclipse.cdt +feature@org.eclipse.cdt=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-releng/org.eclipse.cdt-feature + +! Platform specific + +fragment@org.eclipse.cdt.core.aix=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.aix +fragment@org.eclipse.cdt.core.linux=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.linux +fragment@org.eclipse.cdt.core.macosx=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.macosx +fragment@org.eclipse.cdt.core.qnx=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.qnx +fragment@org.eclipse.cdt.core.solaris=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.solaris +fragment@org.eclipse.cdt.core.win32=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.win32 + +! Testing feature + +plugin@org.eclipse.cdt.core.tests=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.core.tests +plugin@org.eclipse.cdt.ui.tests=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-core/org.eclipse.cdt.ui.tests +plugin@org.eclipse.cdt.debug.ui.tests=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-debug/org.eclipse.cdt.debug.ui.tests +plugin@org.eclipse.cdt.testing=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-releng/org.eclipse.cdt.testing +feature@org.eclipse.cdt.testing=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-releng/org.eclipse.cdt.testing-feature + +! SDK Feature + +plugin@org.eclipse.cdt.sdk=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-releng/org.eclipse.cdt.sdk +feature@org.eclipse.cdt.sdk=HEAD,:pserver:anonymous@dev.eclipse.org:/home/tools,,org.eclipse.cdt-releng/org.eclipse.cdt.sdk-feature diff --git a/releng/org.eclipse.cdt.releng/message.in b/releng/org.eclipse.cdt.releng/message.in new file mode 100644 index 00000000000..8600e42f5c2 --- /dev/null +++ b/releng/org.eclipse.cdt.releng/message.in @@ -0,0 +1,6 @@ +The build is available at + + http://download.eclipse.org/tools/cdt/builds/@branchVersion@/@buildId@ + +Cheers, +dschaefer2, the buildmaster... diff --git a/releng/org.eclipse.cdt.releng/platform/build.properties b/releng/org.eclipse.cdt.releng/platform/build.properties new file mode 100644 index 00000000000..59eb35b9f48 --- /dev/null +++ b/releng/org.eclipse.cdt.releng/platform/build.properties @@ -0,0 +1,86 @@ +##################### +# Parameters describing how and where to execute the build. +# Typical users need only update the following properties: +# baseLocation - where things you are building against are installed +# bootclasspath - The base jars to compile against (typicaly rt.jar) +# configs - the list of {os, ws, arch} configurations to build. +# +# Of course any of the settings here can be overridden by spec'ing +# them on the command line (e.g., -DbaseLocation=d:/eclipse + +############# CVS CONTROL ################ +# The CVS tag to use when fetching the map files from the repository +# mapVersionTag=HEAD + +# The CVS tag to use when fetching elements to build. By default the +# builder will use whatever is in the maps. Use this value to override +# for example, when doing a nightly build out of HEAD +# fetchTag=HEAD + + +############## BUILD / GENERATION CONTROL ################ +# The directory into which the build elements will be fetched and where +# the build will take place. buildDirectory and install should be the same +# value. +buildDirectory=build + +# Type of build. Used in naming the build output. Typically this value is +# one of I, N, M, S, ... +buildType=I + +# ID of the build. Used in naming the build output. +buildId=TestBuild + +# Label for the build. Used in naming the build output +buildLabel=${buildType}.${buildId} + +# Timestamp for the build. Used in naming the build output +timestamp=007 + +# Base location for anything the build needs to compile against. For example, +# when building GEF, the baseLocation should be the location of a previously +# installed Eclipse against which the GEF code will be compiled. +baseLocation= + +#Os/Ws/Arch/nl of the eclipse specified by baseLocation +#baseos +#basews +#basearch +#basenl + +# The location underwhich all of the build output will be collected. This will be +# the root path in the resultant zip file. +collPlace=eclipse + +# The directory in which to execute zip of the ${collPlace} directory +collBase=. + +# The list of {os, ws, arch} configurations to build. This +# value is a '&' separated list of ',' separate triples. For example, +# configs=win32,win32,x86 & linux,motif,x86 +# By default the value is *,*,* +configs=\ + aix,*,ppc \ + & hpux,*,PA_RISC \ + & linux,*,x86 \ + & macosx,*,ppc \ + & qnx,*,x86 \ + & solaris,*,sparc \ + & win32,*,x86 + +#Arguments to send to the zip executable +zipargs= + +############# JAVA COMPILER OPTIONS ############## +# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE +#bootclasspath=d:/ibm1.3.1/jre/lib/rt.jar + +javacDebugInfo=on +javacVerbose=true +javacFailOnError=false + +# The version of the source code +#javaSource=1.3 + +# The version of the byte code targeted +#javacTarget=1.1 diff --git a/releng/org.eclipse.cdt.releng/platform/customTargets.xml b/releng/org.eclipse.cdt.releng/platform/customTargets.xml new file mode 100644 index 00000000000..3c04bfc27cf --- /dev/null +++ b/releng/org.eclipse.cdt.releng/platform/customTargets.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/releng/org.eclipse.cdt.releng/sdk/build.properties b/releng/org.eclipse.cdt.releng/sdk/build.properties new file mode 100644 index 00000000000..096390d9b58 --- /dev/null +++ b/releng/org.eclipse.cdt.releng/sdk/build.properties @@ -0,0 +1,88 @@ +##################### +# Parameters describing how and where to execute the build. +# Typical users need only update the following properties: +# baseLocation - where things you are building against are installed +# bootclasspath - The base jars to compile against (typicaly rt.jar) +# configs - the list of {os, ws, arch} configurations to build. +# +# Of course any of the settings here can be overridden by spec'ing +# them on the command line (e.g., -DbaseLocation=d:/eclipse + +############# CVS CONTROL ################ +# The CVS tag to use when fetching the map files from the repository +mapVersionTag=HEAD + +# The CVS tag to use when fetching elements to build. By default the +# builder will use whatever is in the maps. Use this value to override +# for example, when doing a nightly build out of HEAD +# fetchTag=HEAD + + +############## BUILD / GENERATION CONTROL ################ +# The directory into which the build elements will be fetched and where +# the build will take place. buildDirectory and install should be the same +# value. +buildDirectory=build + +# Type of build. Used in naming the build output. Typically this value is +# one of I, N, M, S, ... +buildType=I + +# ID of the build. Used in naming the build output. +buildId=TestBuild + +# Label for the build. Used in naming the build output +buildLabel=${buildType}.${buildId} + +# Timestamp for the build. Used in naming the build output +timestamp=007 + +# Base location for anything the build needs to compile against. For example, +# when building GEF, the baseLocation should be the location of a previously +# installed Eclipse against which the GEF code will be compiled. +baseLocation= + +#Os/Ws/Arch/nl of the eclipse specified by baseLocation +#baseos +#basews +#basearch +#basenl + +# The location underwhich all of the build output will be collected. This will be +# the root path in the resultant zip file. +collPlace=eclipse + +# The directory in which to execute zip of the ${collPlace} directory +collBase=. + +# The list of {os, ws, arch} configurations to build. This +# value is a '&' separated list of ',' separate triples. For example, +# configs=win32,win32,x86 & linux,motif,x86 +# By default the value is *,*,* +configs=\ + aix,*,ppc \ + & hpux,*,PA_RISC \ + & linux,*,x86 \ + & macosx,*,ppc \ + & qnx,*,x86 \ + & solaris,*,sparc \ + & win32,*,x86 + +#Arguments to send to the zip executable +zipargs= + +############# JAVA COMPILER OPTIONS ############## +# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE +#bootclasspath=d:/ibm1.3.1/jre/lib/rt.jar + +# Whether or not to include debug info in the output jars +javacDebugInfo=true + +# Whether or not to fail the build if there are compiler errors +javacfailonerror=true + +# The version of the source code +#javaSource=1.3 + +# The version of the byte code targeted +#javacTarget=1.1 diff --git a/releng/org.eclipse.cdt.releng/sdk/customTargets.xml b/releng/org.eclipse.cdt.releng/sdk/customTargets.xml new file mode 100644 index 00000000000..5c1bd01519d --- /dev/null +++ b/releng/org.eclipse.cdt.releng/sdk/customTargets.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/releng/org.eclipse.cdt.releng/site.in b/releng/org.eclipse.cdt.releng/site.in new file mode 100644 index 00000000000..b9de38310c5 --- /dev/null +++ b/releng/org.eclipse.cdt.releng/site.in @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/releng/org.eclipse.cdt.testing-feature/feature.xml b/releng/org.eclipse.cdt.testing-feature/feature.xml new file mode 100644 index 00000000000..65c061b18ff --- /dev/null +++ b/releng/org.eclipse.cdt.testing-feature/feature.xml @@ -0,0 +1,61 @@ + + + + + %description + + + + %license + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/releng/org.eclipse.cdt.testing/plugin.xml b/releng/org.eclipse.cdt.testing/plugin.xml new file mode 100644 index 00000000000..547ed6bf8c6 --- /dev/null +++ b/releng/org.eclipse.cdt.testing/plugin.xml @@ -0,0 +1,12 @@ + + + + + + + +