[PATCH] D43385: [clangd] Add "clangd.trace" VSCode setting to enable tracing.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 16 07:06:22 PST 2018


sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, klimek.

Setting the CLANGD_TRACE environment variable directly is awkward with VSCode's
"reload from the command palette" workflow.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43385

Files:
  clangd/clients/clangd-vscode/package.json
  clangd/clients/clangd-vscode/src/extension.ts


Index: clangd/clients/clangd-vscode/src/extension.ts
===================================================================
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -16,11 +16,16 @@
  *  your extension is activated the very first time the command is executed
  */
 export function activate(context: vscode.ExtensionContext) {
-    const clangdPath = getConfig<string>('path');
-    const clangdArgs = getConfig<string[]>('arguments');
     const syncFileEvents = getConfig<boolean>('syncFileEvents', true);
 
-    const serverOptions: vscodelc.ServerOptions = { command: clangdPath, args: clangdArgs };
+    const clangd: vscodelc.Executable = {
+        command: getConfig<string>('path'),
+        args: getConfig<string[]>('arguments')
+    };
+    const traceFile = getConfig<string>('trace');
+    if (traceFile != null)
+        clangd.options = {env: {CLANGD_TRACE: traceFile}};
+    const serverOptions: vscodelc.ServerOptions = clangd;
 
     const filePattern: string = '**/*.{' +
       ['cpp', 'c', 'cc', 'cxx', 'c++', 'm', 'mm', 'h', 'hh', 'hpp', 'hxx', 'inc'].join() + '}';
Index: clangd/clients/clangd-vscode/package.json
===================================================================
--- clangd/clients/clangd-vscode/package.json
+++ clangd/clients/clangd-vscode/package.json
@@ -43,8 +43,8 @@
         "@types/mocha": "^2.2.32"
     },
     "repository": {
-      "type": "svn",
-      "url": "http://llvm.org/svn/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/"
+        "type": "svn",
+        "url": "http://llvm.org/svn/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/"
     },
     "contributes": {
         "configuration": {
@@ -68,6 +68,10 @@
                     "type": "boolean",
                     "default": true,
                     "description": "Whether or not to send file events to clangd (File created, changed or deleted). This can be disabled for performance consideration."
+                },
+                "clangd.trace": {
+                    "type": "string",
+                    "description": "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format."
                 }
             }
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43385.134612.patch
Type: text/x-patch
Size: 2291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180216/7ca22ab4/attachment.bin>


More information about the cfe-commits mailing list