diff --git a/README.md b/README.md
index d61a183f6..1471695e3 100644
--- a/README.md
+++ b/README.md
@@ -101,6 +101,7 @@ Click F1 to show Visual studio code actions, then type **ESP-IDF** to
| Doctor command | | |
| Flash your project | ⌘ E F | Ctrl E F |
| Full clean project | ⌘ E X | Ctrl E X |
+| Get coverage data | | |
| Get HTML Coverage Report for project | | |
| Install ESP-ADF | | |
| Install ESP-IDF Python Packages | | |
diff --git a/i18n/en/package.i18n.json b/i18n/en/package.i18n.json
index adde5a5ab..42b90ef39 100644
--- a/i18n/en/package.i18n.json
+++ b/i18n/en/package.i18n.json
@@ -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",
diff --git a/i18n/es/package.i18n.json b/i18n/es/package.i18n.json
index 4c617a1fc..6534cc60c 100644
--- a/i18n/es/package.i18n.json
+++ b/i18n/es/package.i18n.json
@@ -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",
diff --git a/i18n/ru/package.i18n.json b/i18n/ru/package.i18n.json
index 58c1aeb94..94ca5d9cd 100644
--- a/i18n/ru/package.i18n.json
+++ b/i18n/ru/package.i18n.json
@@ -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",
diff --git a/i18n/zh-CN/package.i18n.json b/i18n/zh-CN/package.i18n.json
index e97a47dd7..4ff53fab9 100644
--- a/i18n/zh-CN/package.i18n.json
+++ b/i18n/zh-CN/package.i18n.json
@@ -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 管理器",
diff --git a/package.json b/package.json
index dfc902308..1cb6d1b74 100644
--- a/package.json
+++ b/package.json
@@ -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",
@@ -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%"
diff --git a/package.nls.json b/package.nls.json
index 225f5bb17..23ad4c851 100644
--- a/package.nls.json
+++ b/package.nls.json
@@ -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",
diff --git a/schema.i18n.json b/schema.i18n.json
index 6bd35af68..9e45ff5c5 100644
--- a/schema.i18n.json
+++ b/schema.i18n.json
@@ -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",
diff --git a/src/coverage/coverageManager.ts b/src/coverage/coverageManager.ts
new file mode 100644
index 000000000..83fcc101f
--- /dev/null
+++ b/src/coverage/coverageManager.ts
@@ -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;
+ }
+}
diff --git a/src/extension.ts b/src/extension.ts
index 78612516d..72e93c363 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -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;
@@ -243,6 +244,7 @@ export async function activate(context: vscode.ExtensionContext) {
appTraceTreeDataProvider,
appTraceArchiveTreeDataProvider
);
+ const gcovManager = new CoverageManager();
// register openOCD status bar item
registerOpenOCDStatusBarItem(context);
@@ -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 =
diff --git a/src/support/writeReport.ts b/src/support/writeReport.ts
index f46e5dd4c..4cb5506e5 100644
--- a/src/support/writeReport.ts
+++ b/src/support/writeReport.ts
@@ -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}`;