Skip to content

Commit

Permalink
Merge pull request sdbg#109 from ivmarkov/master
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Jan 21, 2015
2 parents a39b4df + aff65a5 commit 33956c7
Show file tree
Hide file tree
Showing 64 changed files with 5,669 additions and 3,203 deletions.
3 changes: 3 additions & 0 deletions com.github.sdbg.debug.core/plugin.xml
Expand Up @@ -96,6 +96,7 @@
delegateClass="com.github.sdbg.debug.core.internal.expr.WatchExpressionDelegate"/>
</extension>

<!--
<extension point="org.eclipse.debug.core.logicalStructureTypes">
<logicalStructureType
id="com.github.sdbg.debug.core.logical.mapStructureType"
Expand All @@ -104,6 +105,8 @@
modelIdentifier="com.github.sdbg.debug.core">
</logicalStructureType>
</extension>
-->

<extension
point="com.github.sdbg.debug.core.domResourceTracker">
<tracker
Expand Down
Expand Up @@ -14,6 +14,7 @@

package com.github.sdbg.debug.core.internal.expr;

import com.github.sdbg.debug.core.model.IExpressionEvaluator;
import com.github.sdbg.utilities.AdapterUtilities;

import org.eclipse.debug.core.model.IDebugElement;
Expand Down

This file was deleted.

Expand Up @@ -14,127 +14,27 @@

package com.github.sdbg.debug.core.internal.util;

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IStackFrame;

import com.github.sdbg.debug.core.model.IExceptionStackFrame;

import java.util.Arrays;
import java.util.List;

/**
* This class contains static utility methods for use by the debugger.
*/
public class DebuggerUtils {

/**
* Returns whether the given frame needs some additional disambiguating information from its two
* surrounding frames.
*
* @param frame
* @return
* @throws DebugException
*/
public static boolean areSiblingNamesUnique(IExceptionStackFrame frame) throws DebugException {
List<IStackFrame> frames = Arrays.asList(frame.getThread().getStackFrames());

int index = frames.indexOf(frame);

if (index == -1) {
return true;
}

if (index > 0) {
IExceptionStackFrame other = (IExceptionStackFrame) frames.get(index - 1);

if (needsDisambiguating(other, frame)) {
return false;
}
}

if ((index + 1) < frames.size()) {
IExceptionStackFrame other = (IExceptionStackFrame) frames.get(index + 1);

if (needsDisambiguating(frame, other)) {
return false;
}
}

return true;
public static String demangleClassName(String name) {
return name; // Note: now done with Logical Structure Types demangle(name);
}

/**
* The names of private fields are mangled by the VM.
* <p>
* _foo@652376 ==> _foo
* <p>
* Also, remove "set:" and "get:", as these are artifacts of the VM implementation.
* <p>
* e.x., Cat.get:color() ==> Cat.color()
*
* @param name
* @return
*/
public static String demangleVmName(String name) {
if (name == null) {
return null;
}

int atIndex = name.indexOf('@');

while (atIndex != -1) {
// check for _foo@76876.bar (or _Process@14117cc4._reportError@14117cc4)
int endIndex = name.indexOf('.', atIndex);

if (endIndex == -1) {
name = name.substring(0, atIndex);
} else {
name = name.substring(0, atIndex) + name.substring(endIndex);
}

atIndex = name.indexOf('@');
}

// Also remove the trailing '.' for default constructors.
if (name.endsWith(".")) {
name = name.substring(0, name.length() - 1);
}

// remove "set:" and "get:"
// Cat.get:color() ==> Cat.color()
if (name.indexOf(".set:") != -1) {
int index = name.indexOf(".set:");
name = name.substring(0, index + 1) + name.substring(index + 5);
}

if (name.indexOf(".get:") != -1) {
int index = name.indexOf(".get:");
name = name.substring(0, index + 1) + name.substring(index + 5);
}

return name;
public static String demangleFunctionName(String name) {
return demangle(name);
}

public static boolean isInternalMethodName(String methodName) {
return methodName.startsWith("Object._noSuchMethod@");
public static String demangleVariableName(String name) {
return name; // Note: now done with Logical Structure Types demangle(name);
}

/**
* @return whether the given debugger symbol name represents a private symbol
*/
public static boolean isPrivateName(String name) {
// These are special names generated by dart2js.
if (name.startsWith("$.") || name.startsWith("$$.")) {
return false;
}

// A private top-level method (_foo()).
if (name.startsWith("_")) {
return true;
}

// A private static or instance method (i.e Foo._bar()).
return name.indexOf("._") != -1;
return false;
}

public static String printString(String str) {
Expand Down Expand Up @@ -162,19 +62,14 @@ public static String printString(String str) {
}
}

private static boolean needsDisambiguating(IExceptionStackFrame frame1,
IExceptionStackFrame frame2) {
if (frame1.getShortName().equals(frame2.getShortName())) {
// These will need disambiguating if the long names are different.

return !frame1.getLongName().equals(frame2.getLongName());
private static String demangle(String name) {
if (name == null) {
return null;
} else {
return name.replaceAll("_[0-9]+_g\\$$", ""); // TODO XXX FIXME: GWT SuperDevMode-specific
}

return false;
}

private DebuggerUtils() {

}

}

0 comments on commit 33956c7

Please sign in to comment.