Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Adding new exception to list of exception breakpoints works.
Browse files Browse the repository at this point in the history
Updated image to make it visible both in dark and light theme.
Removed unhandled exception menu as it doesn't do anything.
  • Loading branch information
miniwolf committed May 11, 2018
1 parent c030eea commit a12eccf
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 77 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
UnityDebug/obj
bin
*.zip
*.vsix
*.vsix
*.DotSettings.user
.idea
.vscode
.vs
node_modules
oldExternal
out
packages
4 changes: 3 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
!bin/**
!Changelog.txt
!README.md
!Images/unity-logo128x128.png
!Images/unity-logo128x128.png
!Images/dark/Unity.png
!.idea
4 changes: 4 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Git: https://github.com/Unity-Technologies/vscode-unity-debug
Changes
-------

2.5.0
=====
- New support for halt on exception. In debug view a list of exceptions control which to break on.

2.4.2
=====
- Added support for Library/EditorInstance.json. The correct process is attached and multiple editors are running.
Expand Down
Binary file added Images/dark/Unity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 4 additions & 51 deletions UnityDebug/UnityDebugSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using System.Net;
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages;
using Mono.Debugging.Client;
using Mono.Debugging.Evaluation;
using Mono.Debugging.Soft;
using VSCodeDebug;
using MonoDevelop.Debugger.Soft.Unity;
using MonoDevelop.Unity.Debugger;
Expand Down Expand Up @@ -192,7 +194,7 @@ public override void Initialize(Response response, dynamic args)
supportsConfigurationDoneRequest = false,

// This debug adapter does not support function breakpoints.
supportsFunctionBreakpoints = true,
supportsFunctionBreakpoints = false,

// This debug adapter doesn't support conditional breakpoints.
supportsConditionalBreakpoints = true,
Expand All @@ -207,11 +209,7 @@ public override void Initialize(Response response, dynamic args)
supportsSetVariable = true,

// This debug adapter does not support exception breakpoint filters
exceptionBreakpointFilters = new[]
{
new ExceptionBreakpointsFilter("all_exceptions", "All Exceptions"),
new ExceptionBreakpointsFilter("unhandled", "Unhandled_exceptions"),
}
exceptionBreakpointFilters = new ExceptionBreakpointsFilter[0]
});

// Mono Debug is ready to accept breakpoints immediately
Expand Down Expand Up @@ -435,8 +433,6 @@ private void PauseDebugger()

protected override void SetVariable(Response response, object args)
{
SendOutput("stdout", "Found this: " + args);
SendOutput("stdout", "This is response: " + response);
int reference = getInt(args, "variablesReference", -1);
if (reference == -1) {
SendErrorResponse(response, 3009, "variables: property 'variablesReference' is missing", null, false, true);
Expand Down Expand Up @@ -679,45 +675,8 @@ public override void Threads(Response response, dynamic args)
SendResponse(response, new ThreadsResponseBody(threads));
}

private static string ParseEvaluate(string expression)
{
// Parse expressions created by using "Add Watch" in VS Code.
// Add Watch expressions examples:
// Done_PlayerController this.UnityEngine.GameObject gameObject.UnityEngine.SceneManagement.Scene scene.bool isLoaded
// Done_PlayerController this.UnityEngine.GameObject gameObject. Static members. Non-public members.int OffsetOfInstanceIDInCPlusPlusObject

// Replace "Static members" and "Non-public members" with strings without spaces, so we can Split the string correctly.
var exp = expression.Replace ("Static members.", "static-members").Replace ("Non-public members.", "non-public-members");
var expStrings = exp.Split (' ');
var parsedExpression = "";

if (expStrings.Length > 1)
{
foreach (var subexp in expStrings)
{
// Skip static and non public members substrings
if (subexp.StartsWith ("static-members") || subexp.StartsWith ("non-public-members"))
continue;

// If array operator, remove previous '.'
if (subexp.StartsWith ("["))
parsedExpression = parsedExpression.Substring (0, parsedExpression.Length - 1);

int index = subexp.IndexOf ('.');

if (index > 0)
parsedExpression += subexp.Substring (0, index + 1);
}

parsedExpression += expStrings.Last ();
Log.Write ("Parsed Expression: '" + expression + "' -> '" + parsedExpression + "'");
}
return parsedExpression;
}

public override void Evaluate(Response response, dynamic args)
{
SendOutput("stdout", "Starting");
var expression = getString(args, "expression");

if (expression == null) {
Expand All @@ -734,18 +693,12 @@ public override void Evaluate(Response response, dynamic args)
SendError(response, "invalid expression");
return;
}
SendOutput("stdout", "Valid expression " + args);

var evaluationOptions = m_DebuggerSessionOptions.EvaluationOptions.Clone();
evaluationOptions.EllipsizeStrings = false;
evaluationOptions.AllowMethodEvaluation = true;
m_Session.Options.EvaluationOptions = evaluationOptions;
m_Session.Options.ProjectAssembliesOnly = true;
m_Session.Options.StepOverPropertiesAndOperators = false;
var val = Frame.GetExpressionValue(expression, true);
SendOutput("stdout", "Sent expression");
val.WaitHandle.WaitOne();
SendOutput("stdout", "Waiting");

var flags = val.Flags;
if (flags.HasFlag(ObjectValueFlags.Error) || flags.HasFlag(ObjectValueFlags.NotSupported))
Expand Down
22 changes: 3 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "unity-debug",
"displayName": "Debugger for Unity",
"version": "2.4.2",
"version": "2.5.0",
"publisher": "Unity",
"description": "Unity debugger extension",
"license": "MIT",
Expand Down Expand Up @@ -41,14 +41,13 @@
"type": "git",
"url": "https://github.com/Unity-Technologies/vscode-unity-debug.git"
},
"icon": "Images/unity-logo128x128.png",
"icon": "Images/dark/Unity.png",
"main": "./out/attach.js",
"scripts": {
"prepare": "make build",
"vscode:prepublish": "make build",
"compile": "make build",
"watch": "tsc -w -p ./src/typescript",
"test": "make tests; mocha --timeout 10000 -u tdd ./out/tests",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"activationEvents": [
Expand All @@ -60,12 +59,6 @@
"command": "attach.attachToDebugger",
"title": "Unity Attach Debugger"
},
{
"command": "attach.configureExceptions",
"title": "Configure exception breakpoints",
"category": "Exceptions",
"icon": "Images/unity-logo128x128.png"
},
{
"command": "exceptions.addEntry",
"title": "Add",
Expand All @@ -76,16 +69,11 @@
},
{
"command": "exceptions.always",
"title": "Always",
"category": "inline"
"title": "Always"
},
{
"command": "exceptions.never",
"title": "Never"
},
{
"command": "exceptions.unhandled",
"title": "Unhandled"
}
],
"views": {
Expand All @@ -112,10 +100,6 @@
{
"command": "exceptions.never",
"when": "view == exceptions && viewItem == exception"
},
{
"command": "exceptions.unhandled",
"when": "view == exceptions && viewItem == exception"
}
]
},
Expand Down
5 changes: 1 addition & 4 deletions typescript/attach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {exec} from 'child_process';
import { Exceptions, ExceptionConfigurations } from './exceptions';

const localize = nls.config({locale: process.env.VSCODE_NLS_CONFIG})();

const configuration = workspace.getConfiguration('unity-debug');
var exceptions;

const DEFAULT_EXCEPTIONS: ExceptionConfigurations = {
Expand All @@ -33,7 +31,7 @@ export function activate(context: ExtensionContext) {
window.registerTreeDataProvider("exceptions", exceptions);
context.subscriptions.push(commands.registerCommand('exceptions.always', exception => exceptions.always(exception)));
context.subscriptions.push(commands.registerCommand('exceptions.never', exception => exceptions.never(exception)));
context.subscriptions.push(commands.registerCommand('exceptions.unhandled', exception => exceptions.unhandled(exception)));
context.subscriptions.push(commands.registerCommand('exceptions.addEntry', t => exceptions.addEntry(t)));
context.subscriptions.push(commands.registerCommand('attach.attachToDebugger', config => startSession(context, config)));
}

Expand Down Expand Up @@ -82,7 +80,6 @@ class UnityDebugConfigurationProvider implements DebugConfigurationProvider {
if (debugConfiguration && !debugConfiguration.__exceptionOptions) {
debugConfiguration.__exceptionOptions = exceptions.convertToExceptionOptionsDefault();
}
console.log("dimmer resolve");
return debugConfiguration;
}
}
Expand Down
16 changes: 15 additions & 1 deletion typescript/exceptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {QuickPickItem, TreeDataProvider, Event, EventEmitter, TreeItem, ProviderResult, window} from 'vscode';
import {QuickPickItem, TreeDataProvider, Event, EventEmitter, TreeItem, ProviderResult, window, InputBoxOptions} from 'vscode';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import {DebugProtocol} from 'vscode-debugprotocol';
Expand Down Expand Up @@ -42,6 +42,20 @@ export class Exceptions implements TreeDataProvider<Exception> {
this.setExceptionBreakpoints(this.exceptions);
}

public addEntry(t: any) {
let options: InputBoxOptions = {
placeHolder: "(Namespace.ExceptionName)"
}

window.showInputBox(options).then(value => {
if (!value) {
return;
}
this.exceptions[value] = "never";
this._onDidChangeTreeData.fire();
});
}

setExceptionBreakpoints(model: ExceptionConfigurations) {

const args: DebugProtocol.SetExceptionBreakpointsArguments = {
Expand Down

0 comments on commit a12eccf

Please sign in to comment.