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

Get Coverage data command #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Click <kbd>F1</kbd> to show Visual studio code actions, then type **ESP-IDF** to
| Doctor command | | |
| Flash your project | <kbd>⌘</kbd> <kbd>E</kbd> <kbd>F</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>F</kbd> |
| Full clean project | <kbd>⌘</kbd> <kbd>E</kbd> <kbd>X</kbd> | <kbd>Ctrl</kbd> <kbd>E</kbd> <kbd>X</kbd> |
| Get coverage data | | |
| Get HTML Coverage Report for project | | |
| Install ESP-ADF | | |
| Install ESP-IDF Python Packages | | |
Expand Down
1 change: 1 addition & 0 deletions i18n/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"espIdf.buildFlashMonitor.title": "ESP-IDF: Build, Flash and start a monitor on your device",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Pick a workspace folder",
"espIdf.size.title": "ESP-IDF: Size analysis of the binaries",
"espIdf.gcovDump.title": "ESP-IDF: Get source code coverage",
"espIdf.apptrace.title": "ESP-IDF: App Trace",
"espIdf.heaptrace.title": "ESP-IDF: Heap Trace",
"espIdf.openOCDCommand.title": "ESP-IDF: OpenOCD Manager",
Expand Down
1 change: 1 addition & 0 deletions i18n/es/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"espIdf.buildFlashMonitor.title": "ESP-IDF: Construir, Programar y empezar monitor de dispositivo",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Elige una carpeta de trabajo",
"espIdf.size.title": "ESP-IDF: Size analysis of the binaries",
"espIdf.gcovDump.title": "ESP-IDF: Obtener cobertura de código fuente",
"espIdf.apptrace.title": "ESP-IDF: App Trace",
"espIdf.heaptrace.title": "ESP-IDF: Heap Trace",
"espIdf.openOCDCommand.title": "ESP-IDF: OpenOCD Manager",
Expand Down
1 change: 1 addition & 0 deletions i18n/ru/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"espIdf.buildFlashMonitor.title": "ESP-IDF: Сборка, прошивка и запуск мониторинга вашего устройства",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Выберите папку рабочего окружения",
"espIdf.size.title": "ESP-IDF: Анализ размера двоичных файлов",
"espIdf.gcovDump.title": "ESP-IDF: Получите покрытие исходного кода",
"espIdf.apptrace.title": "ESP-IDF: Трассировка приложения",
"espIdf.heaptrace.title": "ESP-IDF: Трасировка динамической памяти",
"espIdf.openOCDCommand.title": "ESP-IDF: Менеджер OpenOCD",
Expand Down
1 change: 1 addition & 0 deletions i18n/zh-CN/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"espIdf.buildFlashMonitor.title": "ESP-IDF:构建、烧写项目并启动监视器",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF:选择工作文件夹",
"espIdf.size.title": "ESP-IDF:分析二进制文件的大小",
"espIdf.gcovDump.title": "ESP-IDF: 获取源代码覆盖率",
"espIdf.apptrace.title": "ESP-IDF:跟踪应用程序",
"espIdf.heaptrace.title": "ESP-IDF: 堆跟踪",
"espIdf.openOCDCommand.title": "ESP-IDF:OpenOCD 管理器",
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"onCommand:espIdf.erase_flash",
"onCommand:espIdf.size",
"onCommand:espIdf.fullClean",
"onCommand:espIdf.gcovDump",
"onCommand:espIdf.apptrace",
"onCommand:espIdf.heaptrace",
"onCommand:espIdf.openOCDCommand",
Expand Down Expand Up @@ -678,6 +679,10 @@
"command": "espIdf.size",
"title": "%espIdf.size.title%"
},
{
"command": "espIdf.gcovDump",
"title": "%espIdf.gcovDump.title%"
},
{
"command": "espIdf.apptrace",
"title": "%espIdf.apptrace.title%"
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"espIdf.buildFlashMonitor.title": "ESP-IDF: Build, Flash and start a monitor on your device",
"espIdf.pickAWorkspaceFolder.title": "ESP-IDF: Pick a workspace folder",
"espIdf.size.title": "ESP-IDF: Size analysis of the binaries",
"espIdf.gcovDump.title": "ESP-IDF: Get coverage data",
"espIdf.apptrace.title": "ESP-IDF: App Trace",
"espIdf.heaptrace.title": "ESP-IDF: Heap Trace",
"espIdf.openOCDCommand.title": "ESP-IDF: OpenOCD Manager",
Expand Down
1 change: 1 addition & 0 deletions schema.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"espIdf.searchInEspIdfDocs.title",
"espIdf.addArduinoAsComponentToCurFolder.title",
"espIdf.size.title",
"espIdf.gcovDump.title",
"espIdf.apptrace.title",
"espIdf.heaptrace.title",
"espIdf.openOCDCommand.title",
Expand Down
71 changes: 71 additions & 0 deletions src/coverage/coverageManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Project: ESP-IDF VSCode Extension
* File Created: Tuesday, 16th March 2021 11:52:51 am
* Copyright 2021 Espressif Systems (Shanghai) CO LTD
* 
* 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
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { EventEmitter } from "events";
import { OpenOCDManager } from "../espIdf/openOcd/openOcdManager";
import { TCLClient, TCLConnection } from "../espIdf/openOcd/tcl/tclClient";
import * as idfConf from "../idfConfiguration";
import { Logger } from "../logger/logger";

export class CoverageManager extends EventEmitter {
private tclConnectionParams: TCLConnection;
private tclClient: TCLClient;
public isRunning: boolean = false;

constructor() {
super();
const host = idfConf.readParameter("openocd.tcl.host");
const port = idfConf.readParameter("openocd.tcl.port");
this.tclConnectionParams = { host, port };
}

public async start() {
try {
if (await OpenOCDManager.init().promptUserToLaunchOpenOCDServer()) {
this.isRunning = true;
this.tclClient = this.sendCommandToTCLSession("esp gcov dump");
this.tclClient.on("response", (resp: Buffer) => {
const respStr = resp.toString();
if (respStr.includes("GCOV data have been dumped.")) {
this.stop();
}
});
this.tclClient.on("error", (error: Error) => {
Logger.error(
`Some error prevailed while dumping data with gcov`,
error
);
this.stop();
});
}
} catch (error) {
Logger.errorNotify(error.message, error);
}
}

public async stop() {
this.isRunning = false;
this.tclClient.stop();
}

private sendCommandToTCLSession(command: string) {
const tclHandler = new TCLClient(this.tclConnectionParams);
tclHandler.sendCommandWithCapture(command);
return tclHandler;
}
}
10 changes: 10 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import { writeTextReport } from "./support/writeReport";
import { kill } from "process";
import { getNewProjectArgs } from "./newProject/newProjectInit";
import { NewProjectPanel } from "./newProject/newProjectPanel";
import { CoverageManager } from "./coverage/coverageManager";

// Global variables shared by commands
let workspaceRoot: vscode.Uri;
Expand Down Expand Up @@ -243,6 +244,7 @@ export async function activate(context: vscode.ExtensionContext) {
appTraceTreeDataProvider,
appTraceArchiveTreeDataProvider
);
const gcovManager = new CoverageManager();

// register openOCD status bar item
registerOpenOCDStatusBarItem(context);
Expand Down Expand Up @@ -1508,6 +1510,14 @@ export async function activate(context: vscode.ExtensionContext) {
});
});

registerIDFCommand("espIdf.gcovDump", () => {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
gcovManager.isRunning
? await gcovManager.stop()
: await gcovManager.start();
});
});

registerIDFCommand("espIdf.apptrace", () => {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
const appTraceLabel =
Expand Down
4 changes: 2 additions & 2 deletions src/support/writeReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export async function writeTextReport(
const lineBreak = `--------------------------------------------------------------------------------------------------------------------------------------------${EOL}`;
output += `OS ${reportedResult.systemInfo.platform} ${reportedResult.systemInfo.architecture} ${reportedResult.systemInfo.systemName} ${EOL}`;
output += `System environment variable PATH ${EOL} ${reportedResult.systemInfo.envPath} ${EOL}`;
output += `Visual Studio Code version ${reportedResult.systemInfo.extensionVersion} ${EOL}`;
output += `Visual Studio Code version ${reportedResult.systemInfo.vscodeVersion} ${EOL}`;
output += `Visual Studio Code language ${reportedResult.systemInfo.language} ${EOL}`;
output += `Visual Studio Code shell ${reportedResult.systemInfo.shell} ${EOL}`;
output += `ESP-IDF Extension version ${reportedResult.systemInfo.vscodeVersion} ${EOL}`;
output += `ESP-IDF Extension version ${reportedResult.systemInfo.extensionVersion} ${EOL}`;
output += `---------------------------------------------------- Extension configuration settings ------------------------------------------------------${EOL}`;
output += `ESP-IDF Path (idf.espIdfPath) ${reportedResult.configurationSettings.espIdfPath}${EOL}`;
output += `Custom extra paths (idf.customExtraPaths) ${reportedResult.configurationSettings.customExtraPaths}${EOL}`;
Expand Down