@@ -341,101 +341,6 @@ llvm::json::Value CreateScope(const llvm::StringRef name,
341341 return llvm::json::Value (std::move (object));
342342}
343343
344- static uint64_t GetDebugInfoSizeInSection (lldb::SBSection section) {
345- uint64_t debug_info_size = 0 ;
346- llvm::StringRef section_name (section.GetName ());
347- if (section_name.starts_with (" .debug" ) ||
348- section_name.starts_with (" __debug" ) ||
349- section_name.starts_with (" .apple" ) || section_name.starts_with (" __apple" ))
350- debug_info_size += section.GetFileByteSize ();
351- size_t num_sub_sections = section.GetNumSubSections ();
352- for (size_t i = 0 ; i < num_sub_sections; i++) {
353- debug_info_size +=
354- GetDebugInfoSizeInSection (section.GetSubSectionAtIndex (i));
355- }
356- return debug_info_size;
357- }
358-
359- static uint64_t GetDebugInfoSize (lldb::SBModule module ) {
360- uint64_t debug_info_size = 0 ;
361- size_t num_sections = module .GetNumSections ();
362- for (size_t i = 0 ; i < num_sections; i++) {
363- debug_info_size += GetDebugInfoSizeInSection (module .GetSectionAtIndex (i));
364- }
365- return debug_info_size;
366- }
367-
368- static std::string ConvertDebugInfoSizeToString (uint64_t debug_info) {
369- std::ostringstream oss;
370- oss << std::fixed << std::setprecision (1 );
371- if (debug_info < 1024 ) {
372- oss << debug_info << " B" ;
373- } else if (debug_info < 1024 * 1024 ) {
374- double kb = double (debug_info) / 1024.0 ;
375- oss << kb << " KB" ;
376- } else if (debug_info < 1024 * 1024 * 1024 ) {
377- double mb = double (debug_info) / (1024.0 * 1024.0 );
378- oss << mb << " MB" ;
379- } else {
380- double gb = double (debug_info) / (1024.0 * 1024.0 * 1024.0 );
381- oss << gb << " GB" ;
382- }
383- return oss.str ();
384- }
385-
386- llvm::json::Value CreateModule (lldb::SBTarget &target, lldb::SBModule &module ,
387- bool id_only) {
388- llvm::json::Object object;
389- if (!target.IsValid () || !module .IsValid ())
390- return llvm::json::Value (std::move (object));
391-
392- const char *uuid = module .GetUUIDString ();
393- object.try_emplace (" id" , uuid ? std::string (uuid) : std::string (" " ));
394-
395- if (id_only)
396- return llvm::json::Value (std::move (object));
397-
398- object.try_emplace (" name" , std::string (module .GetFileSpec ().GetFilename ()));
399- char module_path_arr[PATH_MAX];
400- module .GetFileSpec ().GetPath (module_path_arr, sizeof (module_path_arr));
401- std::string module_path (module_path_arr);
402- object.try_emplace (" path" , module_path);
403- if (module .GetNumCompileUnits () > 0 ) {
404- std::string symbol_str = " Symbols loaded." ;
405- std::string debug_info_size;
406- uint64_t debug_info = GetDebugInfoSize (module );
407- if (debug_info > 0 ) {
408- debug_info_size = ConvertDebugInfoSizeToString (debug_info);
409- }
410- object.try_emplace (" symbolStatus" , symbol_str);
411- object.try_emplace (" debugInfoSize" , debug_info_size);
412- char symbol_path_arr[PATH_MAX];
413- module .GetSymbolFileSpec ().GetPath (symbol_path_arr,
414- sizeof (symbol_path_arr));
415- std::string symbol_path (symbol_path_arr);
416- object.try_emplace (" symbolFilePath" , symbol_path);
417- } else {
418- object.try_emplace (" symbolStatus" , " Symbols not found." );
419- }
420- std::string load_address =
421- llvm::formatv (" {0:x}" ,
422- module .GetObjectFileHeaderAddress ().GetLoadAddress (target))
423- .str ();
424- object.try_emplace (" addressRange" , load_address);
425- std::string version_str;
426- uint32_t version_nums[3 ];
427- uint32_t num_versions =
428- module .GetVersion (version_nums, sizeof (version_nums) / sizeof (uint32_t ));
429- for (uint32_t i = 0 ; i < num_versions; ++i) {
430- if (!version_str.empty ())
431- version_str += " ." ;
432- version_str += std::to_string (version_nums[i]);
433- }
434- if (!version_str.empty ())
435- object.try_emplace (" version" , version_str);
436- return llvm::json::Value (std::move (object));
437- }
438-
439344// "Event": {
440345// "allOf": [ { "$ref": "#/definitions/ProtocolMessage" }, {
441346// "type": "object",
0 commit comments