Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDR: add support for OSX core files #5127

Merged
merged 2 commits into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2018 IBM Corp. and others
* Copyright (c) 2009, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -38,6 +38,7 @@
import com.ibm.j9ddr.corereaders.aix.AIXDumpReaderFactory;
import com.ibm.j9ddr.corereaders.debugger.JniReader;
import com.ibm.j9ddr.corereaders.elf.ELFDumpReaderFactory;
import com.ibm.j9ddr.corereaders.macho.MachoDumpReaderFactory;
import com.ibm.j9ddr.corereaders.minidump.MiniDumpReader;

/**
Expand All @@ -61,6 +62,7 @@ public class CoreReader
localReaders.add(JniReader.class);
localReaders.add(MiniDumpReader.class);
localReaders.add(ELFDumpReaderFactory.class);
localReaders.add(MachoDumpReaderFactory.class);

// Use reflection to find TDumpReader: it is not available on all platforms.
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
/*******************************************************************************
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*******************************************************************************/
package com.ibm.j9ddr.corereaders.macho;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.stream.ImageInputStream;

public class BuildVersionCommand extends LoadCommand
{

// version numbers are encoded as nibbles in an int in xxxx.yy.zz format
public static class Version
{
int major;
int minor;
int patch;

public Version(int encoding)
{
for (int i = 8; i > 4; i--) {
major = major * 10 + ((encoding >>> (i * 4)) & 0xf);
}
for (int i = 4; i > 2; i--) {
minor = minor * 10 + ((encoding >>> (i * 4)) & 0xf);
}
for (int i = 2; i > 0; i--) {
patch = patch * 10 + ((encoding >>> (i * 4)) & 0xf);
}
}
}

public static class BuildToolVersion
{
public static final int TOOL_CLANG = 1;
public static final int TOOL_SWIFT = 2;
public static final int TOOL_LD = 3;
int toolType;
int version;
}

int platform;
int minOs;
int sdk;
int numTools;
Version minOsVersion;
Version sdkVersion;
List<BuildToolVersion> tools;

public BuildVersionCommand() {}

public BuildVersionCommand readCommand(ImageInputStream stream, long streamSegmentOffset) throws IOException
{
super.readCommand(stream, streamSegmentOffset);
minOs = stream.readInt();
sdk = stream.readInt();
minOsVersion = new Version(minOs);
sdkVersion = new Version(sdk);
numTools = stream.readInt();
tools = new ArrayList<>(numTools);
for (int i = 0; i < numTools; i++) {
BuildToolVersion tool = new BuildToolVersion();
tool.toolType = stream.readInt();
tool.version = stream.readInt();
tools.add(tool);
}
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
/*******************************************************************************
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*******************************************************************************/
package com.ibm.j9ddr.corereaders.macho;

import java.io.IOException;

import javax.imageio.stream.ImageInputStream;

public class DSymtabCommand extends LoadCommand
{
long indexLocalSymbols;
int numLocalSymbols;
long indexExternalSymbols;
int numExternalSymbols;
long indexUndefinedSymbols;
int numUndefinedSymbols;
long tableOfContentsOffset;
int tableOfContentsEntries;
long moduleTableOffset;
int moduleTableEntries;
long externalSymbolTableOffset;
int externalSymbolTableEntries;
long indirectSymbolTableOffset;
int indirectSymbolTableEntries;
long externalRelocationOffset;
int externalRelocationEntries;
long internalRelocationOffset;
int internalRelocationEntries;

public DSymtabCommand() {}

public DSymtabCommand readCommand(ImageInputStream stream, long streamSegmentOffset) throws IOException
{
super.readCommand(stream, streamSegmentOffset);
indexLocalSymbols = stream.readUnsignedInt();
numLocalSymbols = stream.readInt();
indexExternalSymbols = stream.readUnsignedInt();
numExternalSymbols = stream.readInt();
indexUndefinedSymbols = stream.readUnsignedInt();
numUndefinedSymbols = stream.readInt();
tableOfContentsOffset = stream.readUnsignedInt();
tableOfContentsEntries = stream.readInt();
moduleTableOffset = stream.readUnsignedInt();
moduleTableEntries = stream.readInt();
externalSymbolTableOffset = stream.readUnsignedInt();
externalSymbolTableEntries = stream.readInt();
indirectSymbolTableOffset = stream.readUnsignedInt();
indirectSymbolTableEntries = stream.readInt();
externalRelocationOffset = stream.readUnsignedInt();
externalRelocationEntries = stream.readInt();
internalRelocationOffset = stream.readUnsignedInt();
internalRelocationEntries = stream.readInt();
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
/*******************************************************************************
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*******************************************************************************/
package com.ibm.j9ddr.corereaders.macho;

import java.io.IOException;

import javax.imageio.stream.ImageInputStream;

public class DyldInfoCommand extends LoadCommand
{
int rebaseOffset;
int rebaseSize;
int bindOffset;
int bindSize;
int weakBindOffset;
int weakBindSize;
int lazyBindOffset;
int lazyBindSize;
int exportOffset;
int exportSize;

public DyldInfoCommand() {}

public DyldInfoCommand readCommand(ImageInputStream stream, long streamSegmentOffset) throws IOException
{
super.readCommand(stream, streamSegmentOffset);
rebaseOffset = stream.readInt();
rebaseSize = stream.readInt();
bindOffset = stream.readInt();
bindSize = stream.readInt();
weakBindOffset = stream.readInt();
weakBindSize = stream.readInt();
lazyBindOffset = stream.readInt();
lazyBindSize = stream.readInt();
exportOffset = stream.readInt();
exportSize = stream.readInt();
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
/*******************************************************************************
* Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
* Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*******************************************************************************/
package com.ibm.j9ddr.corereaders.macho;

import java.io.IOException;

import javax.imageio.stream.ImageInputStream;

public class DylibCommand extends LoadCommand
{

public static class Dylib
{
LoadCommandString name;
int timestamp;
int currentVersion;
int compatibilityVersion;
}

Dylib dylib;

public DylibCommand() {}

public DylibCommand readCommand(ImageInputStream stream, long streamSegmentOffset) throws IOException
{
super.readCommand(stream, streamSegmentOffset);
dylib = new Dylib();
dylib.name = new LoadCommandString();
dylib.name.readLcString(stream);
dylib.timestamp = stream.readInt();
dylib.currentVersion = stream.readInt();
dylib.compatibilityVersion = stream.readInt();
return this;
}
}
Loading