forked from OSchip/llvm-project
[lldb-vscode] Add Compile Unit List to Modules View
Summary: User can expand and check compile unit list for the modules that have debug info. Reviewers: wallace, clayborg Reviewed By: clayborg Subscribers: aprantl, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D83072
This commit is contained in:
parent
f7f8015975
commit
03ef61033f
|
@ -760,6 +760,16 @@ class DebugCommunication(object):
|
|||
}
|
||||
return self.send_recv(command_dict)
|
||||
|
||||
def request_getCompileUnits(self, moduleId):
|
||||
args_dict = {'moduleId': moduleId}
|
||||
command_dict = {
|
||||
'command': 'getCompileUnits',
|
||||
'type': 'request',
|
||||
'arguments': args_dict
|
||||
}
|
||||
response = self.send_recv(command_dict)
|
||||
return response
|
||||
|
||||
def request_completions(self, text):
|
||||
args_dict = {
|
||||
'text': text,
|
||||
|
|
|
@ -47,3 +47,21 @@ class TestVSCode_module(lldbvscode_testcase.VSCodeTestCaseBase):
|
|||
self.assertEqual(symbol_path, program_module['symbolFilePath'])
|
||||
self.assertIn('addressRange', program_module)
|
||||
|
||||
def test_compile_units(self):
|
||||
program= self.getBuildArtifact("a.out")
|
||||
self.build_and_launch(program)
|
||||
source = "main.cpp"
|
||||
main_source_path = self.getSourcePath(source)
|
||||
breakpoint1_line = line_number(source, '// breakpoint 1')
|
||||
lines = [breakpoint1_line]
|
||||
breakpoint_ids = self.set_source_breakpoints(source, lines)
|
||||
self.continue_to_breakpoints(breakpoint_ids)
|
||||
moduleId = self.vscode.get_active_modules()['a.out']['id']
|
||||
response = self.vscode.request_getCompileUnits(moduleId)
|
||||
print(response['body'])
|
||||
self.assertTrue(response['body'])
|
||||
self.assertTrue(len(response['body']['compileUnits']) == 1,
|
||||
'Only one source file should exist')
|
||||
self.assertTrue(response['body']['compileUnits'][0]['compileUnitPath'] == main_source_path,
|
||||
'Real path to main.cpp matches')
|
||||
|
|
@ -937,4 +937,13 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
|
|||
return llvm::json::Value(std::move(object));
|
||||
}
|
||||
|
||||
llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit) {
|
||||
llvm::json::Object object;
|
||||
char unit_path_arr[PATH_MAX];
|
||||
unit.GetFileSpec().GetPath(unit_path_arr, sizeof(unit_path_arr));
|
||||
std::string unit_path(unit_path_arr);
|
||||
object.try_emplace("compileUnitPath", unit_path);
|
||||
return llvm::json::Value(std::move(object));
|
||||
}
|
||||
|
||||
} // namespace lldb_vscode
|
||||
|
|
|
@ -441,6 +441,8 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread &thread, uint32_t stop_id);
|
|||
llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
|
||||
int64_t varID, bool format_hex);
|
||||
|
||||
llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit);
|
||||
|
||||
} // namespace lldb_vscode
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1174,6 +1174,72 @@ void request_evaluate(const llvm::json::Object &request) {
|
|||
g_vsc.SendJSON(llvm::json::Value(std::move(response)));
|
||||
}
|
||||
|
||||
// "getCompileUnitsRequest": {
|
||||
// "allOf": [ { "$ref": "#/definitions/Request" }, {
|
||||
// "type": "object",
|
||||
// "description": "Compile Unit request; value of command field is
|
||||
// 'getCompileUnits'.",
|
||||
// "properties": {
|
||||
// "command": {
|
||||
// "type": "string",
|
||||
// "enum": [ "getCompileUnits" ]
|
||||
// },
|
||||
// "arguments": {
|
||||
// "$ref": "#/definitions/getCompileUnitRequestArguments"
|
||||
// }
|
||||
// },
|
||||
// "required": [ "command", "arguments" ]
|
||||
// }]
|
||||
// },
|
||||
// "getCompileUnitsRequestArguments": {
|
||||
// "type": "object",
|
||||
// "description": "Arguments for 'getCompileUnits' request.",
|
||||
// "properties": {
|
||||
// "moduleId": {
|
||||
// "type": "string",
|
||||
// "description": "The ID of the module."
|
||||
// }
|
||||
// },
|
||||
// "required": [ "moduleId" ]
|
||||
// },
|
||||
// "getCompileUnitsResponse": {
|
||||
// "allOf": [ { "$ref": "#/definitions/Response" }, {
|
||||
// "type": "object",
|
||||
// "description": "Response to 'getCompileUnits' request.",
|
||||
// "properties": {
|
||||
// "body": {
|
||||
// "description": "Response to 'getCompileUnits' request. Array of
|
||||
// paths of compile units."
|
||||
// }
|
||||
// }
|
||||
// }]
|
||||
// }
|
||||
|
||||
void request_getCompileUnits(const llvm::json::Object &request) {
|
||||
llvm::json::Object response;
|
||||
FillResponse(request, response);
|
||||
lldb::SBProcess process = g_vsc.target.GetProcess();
|
||||
llvm::json::Object body;
|
||||
llvm::json::Array units;
|
||||
auto arguments = request.getObject("arguments");
|
||||
std::string module_id = std::string(GetString(arguments, "moduleId"));
|
||||
int num_modules = g_vsc.target.GetNumModules();
|
||||
for (int i = 0; i < num_modules; i++) {
|
||||
auto curr_module = g_vsc.target.GetModuleAtIndex(i);
|
||||
if (module_id == curr_module.GetUUIDString()) {
|
||||
int num_units = curr_module.GetNumCompileUnits();
|
||||
for (int j = 0; j < num_units; j++) {
|
||||
auto curr_unit = curr_module.GetCompileUnitAtIndex(j);\
|
||||
units.emplace_back(CreateCompileUnit(curr_unit));\
|
||||
}
|
||||
body.try_emplace("compileUnits", std::move(units));
|
||||
break;
|
||||
}
|
||||
}
|
||||
response.try_emplace("body", std::move(body));
|
||||
g_vsc.SendJSON(llvm::json::Value(std::move(response)));
|
||||
}
|
||||
|
||||
// "InitializeRequest": {
|
||||
// "allOf": [ { "$ref": "#/definitions/Request" }, {
|
||||
// "type": "object",
|
||||
|
@ -2759,6 +2825,7 @@ const std::map<std::string, RequestCallback> &GetRequestHandlers() {
|
|||
REQUEST_CALLBACK(disconnect),
|
||||
REQUEST_CALLBACK(evaluate),
|
||||
REQUEST_CALLBACK(exceptionInfo),
|
||||
REQUEST_CALLBACK(getCompileUnits),
|
||||
REQUEST_CALLBACK(initialize),
|
||||
REQUEST_CALLBACK(launch),
|
||||
REQUEST_CALLBACK(next),
|
||||
|
|
Loading…
Reference in New Issue