[Lldb-commits] [PATCH] D83731: Add Debug Info Size to Symbol Status
Yifan Shen via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 13 16:44:57 PDT 2020
aelitashen created this revision.
aelitashen added reviewers: wallace, clayborg.
Herald added subscribers: lldb-commits, aprantl.
Herald added a project: LLDB.
Debug Info Size is displayed with Symbol Status Message.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83731
Files:
lldb/tools/lldb-vscode/JSONUtils.cpp
lldb/tools/lldb-vscode/JSONUtils.h
Index: lldb/tools/lldb-vscode/JSONUtils.h
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -443,6 +443,8 @@
llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit);
+uint64_t DebugInfoInSection(lldb::SBSection section);
+
} // namespace lldb_vscode
#endif
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -338,7 +338,32 @@
std::string module_path(module_path_arr);
object.try_emplace("path", module_path);
if (module.GetNumCompileUnits() > 0) {
- object.try_emplace("symbolStatus", "Symbols loaded.");
+ std::string symbol_str = "Symbols loaded.";
+ uint64_t debug_info = 0;
+ size_t num_sections = module.GetNumSections();
+ if (num_sections > 0) {
+ for (int i = 0; i < (int)num_sections; i++) {
+ lldb::SBSection section = module.GetSectionAtIndex(i);
+ debug_info += DebugInfoInSection(section);
+ }
+ }
+ if (debug_info > 0) {
+ char debug_info_size[10];
+ if (debug_info < 1024) {
+ sprintf(debug_info_size, " (%lluKB)", debug_info);
+ } else if (debug_info < 1024*1024) {
+ debug_info = double(debug_info*10/1024);
+ sprintf(debug_info_size, " (%.1fKB)", double(debug_info/10));
+ } else if (debug_info < 1024*1024*1024) {
+ debug_info = debug_info*10/(1024*1024);
+ sprintf(debug_info_size, " (%.1fMB)", double(debug_info/10));
+ } else {
+ debug_info = debug_info*10/(1024*1024*1024);
+ sprintf(debug_info_size, " (%.1fGB)", double(debug_info/10));
+ }
+ symbol_str = symbol_str + debug_info_size;
+ }
+ object.try_emplace("symbolStatus", symbol_str);
char symbol_path_arr[PATH_MAX];
module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
std::string symbol_path(symbol_path_arr);
@@ -362,6 +387,16 @@
return llvm::json::Value(std::move(object));
}
+uint64_t DebugInfoInSection(lldb::SBSection section) {
+ uint64_t section_size = 0;
+ size_t num_sub_sections = section.GetNumSubSections();
+ for (int i = 0; i < (int)num_sub_sections; i++) {
+ lldb::SBSection sub_section = section.GetSubSectionAtIndex(i);
+ section_size += sub_section.GetFileByteSize();
+ }
+ return section_size;
+}
+
void AppendBreakpoint(lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints,
llvm::Optional<llvm::StringRef> request_path,
llvm::Optional<uint32_t> request_line) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83731.277613.patch
Type: text/x-patch
Size: 2672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200713/9b9dda2b/attachment.bin>
More information about the lldb-commits
mailing list