Skip to content

Commit 6fccbaa

Browse files
committed
add docs, organize and change userId -> id
1 parent 024b566 commit 6fccbaa

File tree

12 files changed

+103
-74
lines changed

12 files changed

+103
-74
lines changed

lldb/include/lldb/API/SBSymbol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ class LLDB_API SBSymbol {
8585

8686
SymbolType GetType();
8787

88+
/// Get the ID of this symbol, usually the original symbol table index. .
89+
///
90+
/// \returns
91+
/// Returns the ID of this symbol.
8892
uint32_t GetID();
8993

9094
bool operator==(const lldb::SBSymbol &rhs) const;

lldb/include/lldb/API/SBTarget.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,14 @@ class LLDB_API SBTarget {
324324

325325
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
326326

327+
/// Find a module with the given module specification.
328+
///
329+
/// \param[in] module_spec
330+
/// A lldb::SBModuleSpec object that contains module specification.
331+
///
332+
/// \return
333+
/// A lldb::SBModule object that represents the found module, or an
334+
/// invalid SBModule object if no module was found.
327335
lldb::SBModule FindModule(const lldb::SBModuleSpec &module_spec);
328336

329337
/// Find compile units related to *this target and passed source

lldb/tools/lldb-dap/Handler/ModuleSymbolsRequestHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- DAPGetModuleSymbolsRequestHandler.cpp -----------------------------===//
1+
//===-- ModuleSymbolsRequestHandler.cpp -----------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -61,7 +61,7 @@ ModuleSymbolsRequestHandler::Run(const ModuleSymbolsArguments &args) const {
6161
continue;
6262

6363
Symbol dap_symbol;
64-
dap_symbol.userId = symbol.GetID();
64+
dap_symbol.id = symbol.GetID();
6565
dap_symbol.type = symbol.GetType();
6666
dap_symbol.isDebug = symbol.IsDebug();
6767
dap_symbol.isSynthetic = symbol.IsSynthetic();

lldb/tools/lldb-dap/Protocol/DAPTypes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ llvm::json::Value toJSON(const SourceLLDBData &SLD) {
137137
bool fromJSON(const llvm::json::Value &Params, Symbol &DS, llvm::json::Path P) {
138138
json::ObjectMapper O(Params, P);
139139
std::string type_str;
140-
if (!(O && O.map("userId", DS.userId) && O.map("isDebug", DS.isDebug) &&
140+
if (!(O && O.map("id", DS.id) && O.map("isDebug", DS.isDebug) &&
141141
O.map("isSynthetic", DS.isSynthetic) &&
142142
O.map("isExternal", DS.isExternal) && O.map("type", type_str) &&
143143
O.map("fileAddress", DS.fileAddress) &&
@@ -151,7 +151,7 @@ bool fromJSON(const llvm::json::Value &Params, Symbol &DS, llvm::json::Path P) {
151151

152152
llvm::json::Value toJSON(const Symbol &DS) {
153153
json::Object result{
154-
{"userId", DS.userId},
154+
{"id", DS.id},
155155
{"isDebug", DS.isDebug},
156156
{"isSynthetic", DS.isSynthetic},
157157
{"isExternal", DS.isExternal},
@@ -165,4 +165,4 @@ llvm::json::Value toJSON(const Symbol &DS) {
165165
return result;
166166
}
167167

168-
} // namespace lldb_dap::protocol
168+
} // namespace lldb_dap::protocol

lldb/tools/lldb-dap/Protocol/DAPTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ bool fromJSON(const llvm::json::Value &, SourceLLDBData &, llvm::json::Path);
4949
llvm::json::Value toJSON(const SourceLLDBData &);
5050

5151
struct Symbol {
52-
/// The symbol uid.
53-
uint32_t userId;
52+
/// The symbol id, usually the original symbol table index.
53+
uint32_t id;
5454

5555
/// True if this symbol is debug information in a symbol.
5656
bool isDebug;

lldb/tools/lldb-dap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
],
4747
"main": "./out/extension",
4848
"scripts": {
49-
"bundle-symbols-table-view": "npx esbuild src-ts/webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
49+
"bundle-symbols-table-view": "npx tsc -p src-ts/webview --noEmit && npx esbuild src-ts/webview/symbols-table-view.ts --bundle --format=iife --outdir=./out/webview",
5050
"bundle-tabulator": "cp node_modules/tabulator-tables/dist/js/tabulator.min.js ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_midnight.min.css ./out/webview/ && cp node_modules/tabulator-tables/dist/css/tabulator_simple.min.css ./out/webview/",
5151
"bundle-webview": "npm run bundle-symbols-table-view && npm run bundle-tabulator",
5252
"vscode:prepublish": "npm run bundle-webview && tsc -p ./",

lldb/tools/lldb-dap/src-ts/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export {};
22

33
/// The symbol type we get from the lldb-dap server
4-
export declare interface DAPSymbolType {
5-
userId: number;
4+
export declare interface SymbolType {
5+
id: number;
66
isDebug: boolean;
77
isSynthetic: boolean;
88
isExternal: boolean;

lldb/tools/lldb-dap/src-ts/ui/symbols-provider.ts

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { DebugProtocol } from "@vscode/debugprotocol";
44
import { DebugSessionTracker } from "../debug-session-tracker";
55
import { DisposableContext } from "../disposable-context";
66

7-
import { DAPSymbolType } from "..";
7+
import { SymbolType } from "..";
8+
import { getSymbolsTableHTMLContent } from "./symbols-webview-html";
89
import { getDefaultConfigKey } from "../debug-configuration-provider";
910

1011
export class SymbolsProvider extends DisposableContext {
@@ -95,12 +96,12 @@ export class SymbolsProvider extends DisposableContext {
9596
}
9697
}
9798

98-
private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<DAPSymbolType[]> {
99-
const symbols_response: { symbols: Array<DAPSymbolType> } = await session.customRequest("moduleSymbols", { moduleId, moduleName: '' });
99+
private async getSymbolsForModule(session: vscode.DebugSession, moduleId: string): Promise<SymbolType[]> {
100+
const symbols_response: { symbols: Array<SymbolType> } = await session.customRequest("moduleSymbols", { moduleId, moduleName: '' });
100101
return symbols_response?.symbols || [];
101102
}
102103

103-
private async showSymbolsInNewTab(moduleName: string, symbols: DAPSymbolType[]) {
104+
private async showSymbolsInNewTab(moduleName: string, symbols: SymbolType[]) {
104105
const panel = vscode.window.createWebviewPanel(
105106
"lldb-dap.symbols",
106107
`Symbols for ${moduleName}`,
@@ -121,60 +122,10 @@ export class SymbolsProvider extends DisposableContext {
121122
const tabulatorJsPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "tabulator.min.js"));
122123
const symbolsTableScriptPath = panel.webview.asWebviewUri(vscode.Uri.joinPath(this.getExtensionResourcePath(), "symbols-table-view.js"));
123124

124-
panel.webview.html = this.getHTMLContentForSymbols(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath);
125+
panel.webview.html = getSymbolsTableHTMLContent(tabulatorJsPath, tabulatorCssPath, symbolsTableScriptPath);
125126
panel.webview.postMessage({ command: "updateSymbols", symbols: symbols });
126127
}
127128

128-
private getHTMLContentForSymbols(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbolsTableScriptPath: vscode.Uri): string {
129-
return `<!DOCTYPE html>
130-
<html>
131-
<head>
132-
<meta charset="UTF-8">
133-
<link href="${tabulatorCssPath}" rel="stylesheet">
134-
<style>
135-
.tabulator {
136-
background-color: var(--vscode-editor-background);
137-
color: var(--vscode-editor-foreground);
138-
}
139-
140-
.tabulator .tabulator-header .tabulator-col {
141-
background-color: var(--vscode-editor-background);
142-
color: var(--vscode-editor-foreground);
143-
}
144-
145-
.tabulator-row {
146-
background-color: var(--vscode-editor-background);
147-
color: var(--vscode-editor-foreground);
148-
}
149-
150-
.tabulator-row.tabulator-row-even {
151-
background-color: var(--vscode-editor-background);
152-
color: var(--vscode-editor-foreground);
153-
}
154-
155-
.tabulator-row.tabulator-selected {
156-
background-color: var(--vscode-editor-background);
157-
color: var(--vscode-editor-foreground);
158-
}
159-
160-
.tabulator-cell {
161-
text-overflow: clip !important;
162-
}
163-
164-
#symbols-table {
165-
width: 100%;
166-
height: 100vh;
167-
}
168-
</style>
169-
</head>
170-
<body>
171-
<div id="symbols-table"></div>
172-
<script src="${tabulatorJsPath}"></script>
173-
<script src="${symbolsTableScriptPath}"></script>
174-
</body>
175-
</html>`;
176-
}
177-
178129
private getExtensionResourcePath(): vscode.Uri {
179130
return vscode.Uri.joinPath(this.extensionContext.extensionUri, "out", "webview");
180131
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import * as vscode from "vscode";
2+
3+
export function getSymbolsTableHTMLContent(tabulatorJsPath: vscode.Uri, tabulatorCssPath: vscode.Uri, symbolsTableScriptPath: vscode.Uri): string {
4+
return `<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset="UTF-8">
8+
<link href="${tabulatorCssPath}" rel="stylesheet">
9+
<style>
10+
.tabulator {
11+
background-color: var(--vscode-editor-background);
12+
color: var(--vscode-editor-foreground);
13+
}
14+
15+
.tabulator .tabulator-header .tabulator-col {
16+
background-color: var(--vscode-editor-background);
17+
color: var(--vscode-editor-foreground);
18+
}
19+
20+
.tabulator-row {
21+
background-color: var(--vscode-editor-background);
22+
color: var(--vscode-editor-foreground);
23+
}
24+
25+
.tabulator-row.tabulator-row-even {
26+
background-color: var(--vscode-editor-background);
27+
color: var(--vscode-editor-foreground);
28+
}
29+
30+
.tabulator-row.tabulator-selected {
31+
background-color: var(--vscode-editor-background);
32+
color: var(--vscode-editor-foreground);
33+
}
34+
35+
.tabulator-cell {
36+
text-overflow: clip !important;
37+
}
38+
39+
#symbols-table {
40+
width: 100%;
41+
height: 100vh;
42+
}
43+
</style>
44+
</head>
45+
<body>
46+
<div id="symbols-table"></div>
47+
<script src="${tabulatorJsPath}"></script>
48+
<script src="${symbolsTableScriptPath}"></script>
49+
</body>
50+
</html>`;
51+
}

lldb/tools/lldb-dap/src-ts/webview/symbols-table-view.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { CellComponent, ColumnDefinition } from "tabulator-tables";
2-
import type { DAPSymbolType } from ".."
2+
import type { SymbolType } from ".."
33

4-
function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) => string {
4+
function getTabulatorHexaFormatter(padding: number): (cell: CellComponent) => string {
55
return (cell: CellComponent) => {
66
const val = cell.getValue();
77
if (val === undefined || val === null) {
@@ -13,7 +13,7 @@ function get_tabulator_hexa_formatter(padding: number): (cell: CellComponent) =>
1313
}
1414

1515
const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
16-
{ title: "User ID", field: "userId", headerTooltip: true, sorter: "number", widthGrow: 0.8 },
16+
{ title: "ID", field: "id", headerTooltip: true, sorter: "number", widthGrow: 0.6 },
1717
{
1818
title: "Name",
1919
field: "name",
@@ -69,17 +69,17 @@ const SYMBOL_TABLE_COLUMNS: ColumnDefinition[] = [
6969
headerTooltip: true,
7070
sorter: "number",
7171
widthGrow : 1.25,
72-
formatter: get_tabulator_hexa_formatter(16),
72+
formatter: getTabulatorHexaFormatter(16),
7373
},
7474
{
7575
title: "Load Address",
7676
field: "loadAddress",
7777
headerTooltip: true,
7878
sorter: "number",
7979
widthGrow : 1.25,
80-
formatter: get_tabulator_hexa_formatter(16),
80+
formatter: getTabulatorHexaFormatter(16),
8181
},
82-
{ title: "Size", field: "size", headerTooltip: true, sorter: "number", formatter: get_tabulator_hexa_formatter(8) },
82+
{ title: "Size", field: "size", headerTooltip: true, sorter: "number", formatter: getTabulatorHexaFormatter(8) },
8383
];
8484

8585
const vscode = acquireVsCodeApi();
@@ -93,7 +93,7 @@ const SYMBOLS_TABLE = new Tabulator("#symbols-table", {
9393
data: previousState?.symbols || [],
9494
});
9595

96-
function updateSymbolsTable(symbols: DAPSymbolType[]) {
96+
function updateSymbolsTable(symbols: SymbolType[]) {
9797
SYMBOLS_TABLE.setData(symbols);
9898
}
9999

0 commit comments

Comments
 (0)