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

[WIP] Gdb console #278

Closed
wants to merge 7 commits into from
Closed
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
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ env:
global:
- secure: es511klr3A8rLVIQ+ZxWkYl2/OLaZYzHpLH94O0EqFDC05t7sk76WOD+9fVT0jkINUKt7sK4Nozv19GmNYxFVXKaWwAH9jt7sHKYgbfCr+vTg58z9jyposMZSGEgsGPSbFn5DxPS7KdWbfQDEjxX18yiKMKN9k+7XwkC8p+WSgy4I30M5Y4YXffQooEwjqJpTdkpOm6p+o6t99mp3ufaxG5VOLtSwsZ0r3cKJo0rbqKxJGA62eNYLYksQ7PsFHDE2stQ8IDxFNXOrXB6ocwwd7KGphJIofU/t1UCXjpsGn0Ozr4LYvSpvl9nKQBmA3prKuAOnygLZh0YfYACIoIpBFa0/igxdX7j7INgp50Q+6CHRWwCb+YqZPgJ297EZi5mVKYNlAh0OeKKTo0NanunWR2pnzj29MGzR40wJqPVhQBRQvaKannwpoY5opK8MWi9jnDDY3xpzgZ8na3yOkw9wQ+a2nUm13BZnWmMDODGnaf9vy9eQ7bB26eiU2VSHlNWeniqDMY81sjqBlst22bHR4IgsI4qkh5UXMyyvMKbXltUIXERdCv1yK/Faa/VJ0Qrs+mk+G23bkT8/1f6cHBhjiVJX5HhXLcN3lHxImi+K9NkuCn8g+okX+SfD2lT5OPpRYHS8Jb51frNUIDWqWqRcjCioNjcuup2o6nbTlJaFb0=
- CXX=g++-4.8
- GDB_CACHE=$HOME/.cache/gdb-theia-ci
cache:
directories:
- ${GDB_CACHE}
dist: trusty
addons:
apt:
sources:
Expand All @@ -28,6 +33,7 @@ before_script:
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.0.2
- export PATH=$HOME/.yarn/bin:$PATH ;
- if [ ! -f ${GDB_CACHE}/done ]; then mkdir -p ${GDB_CACHE} && sudo apt-get -y build-dep gdb && config/scripts/download-build-gdb.sh -b $GDB_CACHE -j4 7.12.1 7.11.1 && touch ${GDB_CACHE}/done; fi
install: yarn
script: travis_retry yarn test ;
notifications:
Expand Down
6 changes: 4 additions & 2 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"@theia/python": "^0.1.1",
"@theia/terminal": "^0.1.1",
"@theia/typescript": "^0.1.1",
"@theia/workspace": "^0.1.1"
"@theia/workspace": "^0.1.1",
"@theia/debug": "^0.1.1",
"@theia/gdb": "^0.1.1"
},
"scripts": {
"prepare": "yarn run clean && yarn build",
Expand All @@ -39,4 +41,4 @@
"devDependencies": {
"@theia/cli": "^0.1.1"
}
}
}
6 changes: 4 additions & 2 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"@theia/python": "^0.1.1",
"@theia/terminal": "^0.1.1",
"@theia/typescript": "^0.1.1",
"@theia/workspace": "^0.1.1"
"@theia/workspace": "^0.1.1",
"@theia/debug": "^0.1.1",
"@theia/gdb": "^0.1.1"
},
"scripts": {
"prepare": "yarn run clean && yarn build",
Expand All @@ -38,4 +40,4 @@
"devDependencies": {
"@theia/cli": "^0.1.1"
}
}
}
10 changes: 10 additions & 0 deletions packages/debug/compile.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../configs/base.tsconfig",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
}
51 changes: 51 additions & 0 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@theia/debug",
"version": "0.1.1",
"description": "Theia - Debug Extension",
"dependencies": {
"@theia/core": "^0.1.1",
"@theia/process": "^0.1.1",
"@types/pegjs": "^0.10.0",
"pegjs": "^0.10.0",
"termios": "^0.1.6"
},
"publishConfig": {
"access": "public"
},
"theiaExtensions": [
{
"frontend": "lib/browser/debug-frontend-module",
"backend": "lib/node/debug-backend-module"
}
],
"keywords": [
"theia-extension"
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/theia-ide/theia.git"
},
"bugs": {
"url": "https://github.com/theia-ide/theia/issues"
},
"homepage": "https://github.com/theia-ide/theia",
"files": [
"lib",
"src"
],
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "theiaext clean",
"build": "theiaext build",
"watch": "theiaext watch",
"test": "theiaext test",
"docs": "theiaext docs"
},
"devDependencies": {
"@theia/ext-scripts": "^0.1.1"
},
"nyc": {
"extends": "../nyc.json"
}
}
17 changes: 17 additions & 0 deletions packages/debug/src/browser/debug-frontend-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { ContainerModule } from 'inversify';
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging';
import { IDebugServer, debugPath } from '../common/debug-protocol';

export default new ContainerModule(bind => {
bind(IDebugServer).toDynamicValue(ctx => {
const connection = ctx.container.get(WebSocketConnectionProvider);
return connection.createProxy<IDebugServer>(debugPath);
}).inSingletonScope();
});
23 changes: 23 additions & 0 deletions packages/debug/src/common/debug-protocol.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory';

export const IDebugServer = Symbol('IDebugServer');

export const debugPath = '/services/debug';

export interface IDebugServer extends JsonRpcServer<IDebugClient> {
createSession(): Promise<number>;
getSessionTerminalId(sessionId: number): Promise<number>;
}

export interface IDebugServerOptions {
}

export interface IDebugClient {
}
28 changes: 28 additions & 0 deletions packages/debug/src/node/debug-backend-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { ContainerModule } from 'inversify';
import { ConnectionHandler, JsonRpcConnectionHandler } from "@theia/core/lib/common/messaging";
import { IDebugSession, IDebugSessionFactory } from './debug-session';

import { DebugSessionManager } from './debug-session-manager';
import { IDebugServer, IDebugClient, debugPath } from '../common/debug-protocol';
import { DebugServer } from './debug-server';

export default new ContainerModule(bind => {
bind<DebugSessionManager>(DebugSessionManager).toSelf().inSingletonScope();
bind(IDebugSessionFactory).toAutoFactory(IDebugSession);
bind(IDebugServer).to(DebugServer).inSingletonScope();

bind(ConnectionHandler).toDynamicValue(ctx =>
new JsonRpcConnectionHandler<IDebugClient>(debugPath, client => {
const server = ctx.container.get<IDebugServer>(IDebugServer);
server.setClient(client);
return server;
})
).inSingletonScope();
});
27 changes: 27 additions & 0 deletions packages/debug/src/node/debug-process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

export const IDebugProcess = "IDebugProcess";

import { Event } from '@theia/core/lib/common';
import { IProcessExitEvent } from '@theia/process/lib/node';

export const IDebugProcessFactory = "IDebugProcessFactory";
export type IDebugProcessFactory = (options: object) => IDebugProcess;

export const IDebugProcessFactoryProvider = "IDebugProcessFactoryProvider";
export type IDebugProcessFactoryProvider = () => Promise<IDebugProcessFactory>;

export interface IDebugProcess {
id: number,
readStream: NodeJS.ReadableStream;
writeStream: NodeJS.WritableStream;
process: any;
terminal: any;
onExit: Event<IProcessExitEvent>;
onError: Event<Error>;
}
52 changes: 52 additions & 0 deletions packages/debug/src/node/debug-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { inject, injectable } from 'inversify';
import { IDebugSession, IDebugSessionFactory } from './debug-session';
import { DebugSessionManager } from './debug-session-manager';
import { IDebugServer, IDebugClient } from '../common/debug-protocol';
import { ILogger } from '@theia/core/lib/common';

@injectable()
export class DebugServer implements IDebugServer {

client: IDebugClient;

constructor(
@inject(DebugSessionManager) protected readonly debugSesssionManager: DebugSessionManager,
@inject(IDebugSessionFactory) protected readonly debugSessionFactory: () => IDebugSession,
@inject(ILogger) protected readonly logger: ILogger) {

}

createSession(): Promise<number> {
const session = this.debugSessionFactory();
session.start({});
return Promise.resolve(session.id);
}

/* FIXME make a Session server
So that we can do requests on a session directly
*/
getSessionTerminalId(sessionId: number): Promise<number> {
const session = this.debugSesssionManager.get(sessionId);
if (session !== undefined) {
const debugProcess = session.debugger.debugProcess;
return debugProcess.then(process => process.id);
} else {
throw (new Error(`No Session id: ${sessionId}`));
}
}

dispose() {

}

setClient(client: IDebugClient) {
this.client = client;
}
}
41 changes: 41 additions & 0 deletions packages/debug/src/node/debug-session-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { injectable } from 'inversify';
import { IDebugSession } from './debug-session';


@injectable()
export class DebugSessionManager {

protected readonly sessions: Map<number, IDebugSession> = new Map();
protected id: number = 0;

/* The current session id as selected from the UI, for now this is the last
* registred session */
public currentId: number = 0;

register(session: IDebugSession): number {
const id = this.id;
this.sessions.set(id, session);
this.id++;

this.currentId = id;
return id;
}

getCurrent() {
return this.sessions.get(this.currentId);
}

get(id: number): IDebugSession | undefined {
return this.sessions.get(id);
}

delete(id: number): void {
this.sessions.delete(id);
}
}
31 changes: 31 additions & 0 deletions packages/debug/src/node/debug-session.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { inject, injectable } from 'inversify';
import { DebugSessionManager } from './debug-session-manager';
import { IDebugger } from './debugger';

export const IDebugSession = Symbol("IDebugSession");
export const IDebugSessionFactory = Symbol("IDebugSessionFactory");

export interface IDebugSession {
id: number,
start(options: object): void;
debugger: IDebugger;
}

@injectable()
export abstract class DebugSession implements IDebugSession {

public readonly id: number;
public abstract debugger: IDebugger;

constructor( @inject(DebugSessionManager) protected readonly manager: DebugSessionManager) {
this.id = manager.register(this);
}

public abstract start(options: object): void;
}
18 changes: 18 additions & 0 deletions packages/debug/src/node/debugger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { IDebugProcess } from './debug-process';

export interface IDebugger {
id: number,
/* FIXME use a base options */
start(options: object): void;
debugProcess: Promise<IDebugProcess>;
}


/* FIXME add base debugger class */
11 changes: 11 additions & 0 deletions packages/debug/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
export * from './debug-process';
export * from './debug-server';
export * from './debug-session-manager';
export * from './debug-session';
export * from './debugger';
17 changes: 17 additions & 0 deletions packages/debug/src/node/inversify.spec-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) 2017 Ericsson and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { Container } from 'inversify';
import debugBackendModule from './debug-backend-module'
import { loggerBackendModule } from '@theia/core/lib/node/logger-backend-module';
import processBackendModule from '@theia/process/lib/node/process-backend-module';

const testContainer = new Container();

testContainer.load(processBackendModule);
testContainer.load(debugBackendModule);
testContainer.load(loggerBackendModule);
export { testContainer };
Loading