diff --git a/lldb/lit/Breakpoint/Inputs/case-sensitive.c b/lldb/lit/Breakpoint/Inputs/case-sensitive.c new file mode 100644 index 000000000000..6df38dcacd78 --- /dev/null +++ b/lldb/lit/Breakpoint/Inputs/case-sensitive.c @@ -0,0 +1,4 @@ +int main() { + int x = 47; // REGEX-THIS + return x; +} diff --git a/lldb/lit/Breakpoint/case-insensitive.test b/lldb/lit/Breakpoint/case-insensitive.test new file mode 100644 index 000000000000..fcfdf88717d4 --- /dev/null +++ b/lldb/lit/Breakpoint/case-insensitive.test @@ -0,0 +1,44 @@ +# REQUIRES: windows +# +# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t +# RUN: lldb-test breakpoints %t %s | FileCheck %s + +breakpoint set -f case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK: At least one location. diff --git a/lldb/lit/Breakpoint/case-sensitive.test b/lldb/lit/Breakpoint/case-sensitive.test new file mode 100644 index 000000000000..dd5635b952d6 --- /dev/null +++ b/lldb/lit/Breakpoint/case-sensitive.test @@ -0,0 +1,46 @@ +# REQUIRES: nowindows +# +# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t +# RUN: lldb-test breakpoints %t %s | FileCheck %s + +breakpoint set -f case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -l 3 +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -l 3 +# CHECK: 0 locations. + +breakpoint set -f Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -l 3 +# CHECK: 0 locations. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -l 3 +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -l 3 +# CHECK: 0 locations. + +breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/Inputs/case-sensitive.c -p REGEX-THIS +# CHECK: At least one location. + +breakpoint set -f %p/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/case-sensitive.c -p REGEX-THIS +# CHECK: 0 locations. + +breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f Case-Sensitive.c -p REGEX-THIS +# CHECK: 0 locations. + +breakpoint set -f %p/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK-LABEL: breakpoint set -f {{.*}}/INPUTS/Case-Sensitive.c -p REGEX-THIS +# CHECK: 0 locations. + + diff --git a/lldb/lit/Breakpoint/lit.local.cfg b/lldb/lit/Breakpoint/lit.local.cfg new file mode 100644 index 000000000000..df9b335dd131 --- /dev/null +++ b/lldb/lit/Breakpoint/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] diff --git a/lldb/lit/lit.cfg b/lldb/lit/lit.cfg index 4a190a7328ba..e312d4aa9cf4 100644 --- a/lldb/lit/lit.cfg +++ b/lldb/lit/lit.cfg @@ -1,160 +1,160 @@ # -*- Python -*- import os import platform import re import subprocess import locale import lit.formats import lit.util def binary_feature(on, feature, off_prefix): return feature if on else off_prefix + feature # Configuration file for the 'lit' test runner. # name: The name of this test suite. config.name = 'lldb' # testFormat: The test format to use to interpret tests. # # For now we require '&&' between commands, until they get globally killed and # the test runner updated. execute_external = (platform.system() != 'Windows' or lit_config.getBashPath() not in [None, ""]) config.test_format = lit.formats.ShTest(execute_external) # suffixes: We only support unit tests config.suffixes = [] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) # test_exec_root: The root path where tests should be run. config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit') # Tweak the PATH to include the tools dir and the scripts dir. lldb_tools_dir = config.lldb_tools_dir llvm_tools_dir = config.llvm_tools_dir path = os.path.pathsep.join((config.lldb_tools_dir, config.llvm_tools_dir, config.environment['PATH'])) config.environment['PATH'] = path path = os.path.pathsep.join((config.lldb_libs_dir, config.llvm_libs_dir, config.environment.get('LD_LIBRARY_PATH',''))) config.environment['LD_LIBRARY_PATH'] = path # Propagate LLVM_SRC_ROOT into the environment. config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '') # Propagate PYTHON_EXECUTABLE into the environment config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable', '') # Register substitutions config.substitutions.append(('%python', config.python_executable)) debugserver = lit.util.which('debugserver', lldb_tools_dir) lldb = lit.util.which('lldb', lldb_tools_dir) if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) if not os.path.exists(config.cxx): config.cxx = lit.util.which(config.cxx, config.environment['PATH']) if platform.system() in ['Darwin']: try: out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip() res = 0 except OSError: res = -1 if res == 0 and out: sdk_path = out lit_config.note('using SDKROOT: %r' % sdk_path) config.cc += " -isysroot %s" % sdk_path config.cxx += " -isysroot %s" % sdk_path config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: config.substitutions.append(('%debugserver', debugserver)) for pattern in [r"\bFileCheck\b", r"\blldb-test\b", r"\byaml2obj\b", r"\| \bnot\b"]: tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", pattern) tool_pipe = tool_match.group(2) tool_name = tool_match.group(4) tool_path = lit.util.which(tool_name, config.environment['PATH']) if not tool_path: # Warn, but still provide a substitution. lit_config.note( 'Did not find ' + tool_name + ' in ' + config.environment['PATH']) config.substitutions.append((pattern, tool_pipe + tool_path)) # Shell execution if platform.system() not in ['Windows'] or lit_config.getBashPath() != '': config.available_features.add('shell') # Running on Darwin OS if platform.system() in ['Darwin']: config.available_features.add('darwin') config.available_features.add('system-linker-mach-o') # Running on ELF based *nix if platform.system() in ['FreeBSD', 'Linux']: config.available_features.add('system-linker-elf') if platform.system() in ['FreeBSD']: config.available_features.add('freebsd') else: config.available_features.add('linux') -if platform.system() in ['Windows']: - config.available_features.add('windows') +config.available_features.add( + binary_feature(platform.system() in ['Windows'], 'windows', 'no')) if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple): config.available_features.add("armhf-linux") if re.match(r'icc', config.cc): config.available_features.add("compiler-icc") elif re.match(r'clang', config.cc): config.available_features.add("compiler-clang") elif re.match(r'gcc', config.cc): config.available_features.add("compiler-gcc") elif re.match(r'cl', config.cc): config.available_features.add("compiler-msvc") config.available_features.add(binary_feature(config.have_zlib, "zlib", "no")) # llvm-config knows whether it is compiled with asserts (and) # whether we are operating in release/debug mode. import subprocess try: llvm_config_cmd = \ subprocess.Popen([os.path.join(llvm_tools_dir, 'llvm-config'), '--build-mode', '--assertion-mode', '--targets-built'], stdout = subprocess.PIPE) except OSError as why: print("Could not find llvm-config in " + llvm_tools_dir) exit(42) llvm_config_output = llvm_config_cmd.stdout.read().decode('utf_8') llvm_config_output_list = llvm_config_output.split("\n") if re.search(r'DEBUG', llvm_config_output_list[0]): config.available_features.add('debug') if re.search(r'ON', llvm_config_output_list[1]): config.available_features.add('asserts') if re.search(r'ARM', llvm_config_output_list[2]): config.available_features.add('arm') if re.search(r'Mips', llvm_config_output_list[2]): config.available_features.add('mips') if re.search(r'X86', llvm_config_output_list[2]): config.available_features.add('x86') llvm_config_cmd.wait() diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile deleted file mode 100644 index 6067ee45e984..000000000000 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -LEVEL = ../../../make - -C_SOURCES := main.c -CFLAGS_EXTRAS += -std=c99 - -include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py deleted file mode 100644 index 8d174580f29d..000000000000 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py +++ /dev/null @@ -1,129 +0,0 @@ -""" -Test case sensitivity of paths on Windows / POSIX -llvm.org/pr22667 -""" - -import os -import lldb -from lldbsuite.test.lldbtest import * -from lldbsuite.test.decorators import * -from lldbsuite.test import lldbplatform, lldbplatformutil - - -class BreakpointCaseSensitivityTestCase(TestBase): - mydir = TestBase.compute_mydir(__file__) - BREAKPOINT_TEXT = 'Set a breakpoint here' - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - self.line = line_number('main.c', self.BREAKPOINT_TEXT) - - @skipIf(hostoslist=no_match(['windows'])) # Skip for non-windows platforms - def test_breakpoint_matches_file_with_different_case(self): - """Set breakpoint on file, should match files with different case on Windows""" - self.build() - self.case_sensitivity_breakpoint(True) - - @skipIf(hostoslist=['windows']) # Skip for windows platforms - def test_breakpoint_doesnt_match_file_with_different_case(self): - """Set breakpoint on file, shouldn't match files with different case on POSIX systems""" - self.build() - self.case_sensitivity_breakpoint(False) - - def case_sensitivity_breakpoint(self, case_insensitive): - """Set breakpoint on file, should match files with different case if case_insensitive is True""" - - # use different case to check CreateTarget - exe = 'a.out' - if case_insensitive: - exe = exe.upper() - - exe = self.getBuildArtifact(exe) - - # Create a target by the debugger. - self.target = self.dbg.CreateTarget(exe) - self.assertTrue(self.target, VALID_TARGET) - srcdir = self.getSourceDir() - - # try both BreakpointCreateByLocation and BreakpointCreateBySourceRegex - for regex in [False, True]: - # should always hit - self.check_breakpoint('main.c', regex, True) - # should always hit - self.check_breakpoint(os.path.join(srcdir, 'main.c'), regex, True) - # different case for directory - self.check_breakpoint(os.path.join(srcdir.upper(), 'main.c'), - regex, - case_insensitive) - # different case for file - self.check_breakpoint('Main.c', - regex, - case_insensitive) - # different case for both - self.check_breakpoint(os.path.join(srcdir.upper(), 'Main.c'), - regex, - case_insensitive) - - def check_breakpoint(self, file, source_regex, should_hit): - """ - Check breakpoint hit at given file set by given method - - file: - File where insert the breakpoint - - source_regex: - True for testing using BreakpointCreateBySourceRegex, - False for BreakpointCreateByLocation - - should_hit: - True if the breakpoint should hit, False otherwise - """ - - desc = ' file %s set by %s' % ( - file, 'regex' if source_regex else 'location') - if source_regex: - breakpoint = self.target.BreakpointCreateBySourceRegex( - self.BREAKPOINT_TEXT, lldb.SBFileSpec(file)) - else: - breakpoint = self.target.BreakpointCreateByLocation( - file, self.line) - - self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1, - should_hit, - VALID_BREAKPOINT + desc) - - # Get the breakpoint location from breakpoint after we verified that, - # indeed, it has one location. - location = breakpoint.GetLocationAtIndex(0) - - self.assertEqual(location.IsValid(), - should_hit, - VALID_BREAKPOINT_LOCATION + desc) - - process = self.target.LaunchSimple( - None, None, self.get_process_working_directory()) - self.assertTrue(process, PROCESS_IS_VALID + desc) - - if should_hit: - # Did we hit our breakpoint? - from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint - threads = get_threads_stopped_at_breakpoint(process, breakpoint) - self.assertEqual( - len(threads), - 1, - "There should be a thread stopped at breakpoint" + - desc) - # The hit count for the breakpoint should be 1. - self.assertEqual(breakpoint.GetHitCount(), 1) - - else: - # check the breakpoint was not hit - self.assertEqual(lldb.eStateExited, process.GetState()) - self.assertEqual(breakpoint.GetHitCount(), 0) - - # let process finish - process.Continue() - - # cleanup - self.target.BreakpointDelete(breakpoint.GetID()) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c deleted file mode 100644 index 281ddfe7ef67..000000000000 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int -main() -{ - printf("Set a breakpoint here.\n"); - return 0; -} diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp index 1fe2f5b63859..502e555dd7cd 100644 --- a/lldb/tools/lldb-test/lldb-test.cpp +++ b/lldb/tools/lldb-test/lldb-test.cpp @@ -1,126 +1,247 @@ //===- lldb-test.cpp ------------------------------------------ *- C++ --*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "FormatUtil.h" #include "SystemInitializerTest.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Initialization/SystemLifetimeManager.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/StreamString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include using namespace lldb; using namespace lldb_private; using namespace llvm; namespace opts { +static cl::SubCommand BreakpointSubcommand("breakpoints", + "Test breakpoint resolution"); cl::SubCommand ModuleSubcommand("module-sections", "Display LLDB Module Information"); cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file"); +namespace breakpoint { +static cl::opt Target(cl::Positional, cl::desc(""), + cl::Required, cl::sub(BreakpointSubcommand)); +static cl::opt CommandFile(cl::Positional, + cl::desc(""), + cl::init("-"), + cl::sub(BreakpointSubcommand)); +static cl::opt Persistent( + "persistent", + cl::desc("Don't automatically remove all breakpoints before each command"), + cl::sub(BreakpointSubcommand)); + +static llvm::StringRef plural(uintmax_t value) { return value == 1 ? "" : "s"; } +static void dumpState(const BreakpointList &List, LinePrinter &P); +static std::string substitute(StringRef Cmd); +static void evaluateBreakpoints(Debugger &Dbg); +} // namespace breakpoint + namespace module { cl::opt SectionContents("contents", cl::desc("Dump each section's contents"), cl::sub(ModuleSubcommand)); cl::list InputFilenames(cl::Positional, cl::desc(""), cl::OneOrMore, cl::sub(ModuleSubcommand)); } // namespace module namespace symbols { cl::list InputFilenames(cl::Positional, cl::desc(""), cl::OneOrMore, cl::sub(SymbolsSubcommand)); } } // namespace opts static llvm::ManagedStatic DebuggerLifetime; +void opts::breakpoint::dumpState(const BreakpointList &List, LinePrinter &P) { + P.formatLine("{0} breakpoint{1}", List.GetSize(), plural(List.GetSize())); + if (List.GetSize() > 0) + P.formatLine("At least one breakpoint."); + for (size_t i = 0, e = List.GetSize(); i < e; ++i) { + BreakpointSP BP = List.GetBreakpointAtIndex(i); + P.formatLine("Breakpoint ID {0}:", BP->GetID()); + AutoIndent Indent(P, 2); + P.formatLine("{0} location{1}.", BP->GetNumLocations(), + plural(BP->GetNumLocations())); + if (BP->GetNumLocations() > 0) + P.formatLine("At least one location."); + P.formatLine("{0} resolved location{1}.", BP->GetNumResolvedLocations(), + plural(BP->GetNumResolvedLocations())); + if (BP->GetNumResolvedLocations() > 0) + P.formatLine("At least one resolved location."); + for (size_t l = 0, le = BP->GetNumLocations(); l < le; ++l) { + BreakpointLocationSP Loc = BP->GetLocationAtIndex(l); + P.formatLine("Location ID {0}:", Loc->GetID()); + AutoIndent Indent(P, 2); + P.formatLine("Enabled: {0}", Loc->IsEnabled()); + P.formatLine("Resolved: {0}", Loc->IsResolved()); + P.formatLine("Address: {0}+{1:x}", + Loc->GetAddress().GetSection()->GetName(), + Loc->GetAddress().GetOffset()); + } + } + P.NewLine(); +} + +std::string opts::breakpoint::substitute(StringRef Cmd) { + std::string Result; + raw_string_ostream OS(Result); + while (!Cmd.empty()) { + switch (Cmd[0]) { + case '%': + if (Cmd.consume_front("%p") && (Cmd.empty() || !isalnum(Cmd[0]))) { + OS << sys::path::parent_path(CommandFile); + break; + } + // fall through + default: + size_t pos = Cmd.find('%'); + OS << Cmd.substr(0, pos); + Cmd = Cmd.substr(pos); + break; + } + } + return std::move(OS.str()); +} + +void opts::breakpoint::evaluateBreakpoints(Debugger &Dbg) { + TargetSP Target; + Status ST = + Dbg.GetTargetList().CreateTarget(Dbg, breakpoint::Target, /*triple*/ "", + /*get_dependent_modules*/ false, + /*platform_options*/ nullptr, Target); + if (ST.Fail()) { + errs() << formatv("Failed to create target '{0}: {1}\n", breakpoint::Target, + ST); + exit(1); + } + + auto MB = MemoryBuffer::getFileOrSTDIN(CommandFile); + if (!MB) { + errs() << formatv("Could not open file '{0}: {1}\n", CommandFile, + MB.getError().message()); + exit(1); + } + + LinePrinter P(4, outs()); + StringRef Rest = (*MB)->getBuffer(); + while (!Rest.empty()) { + StringRef Line; + std::tie(Line, Rest) = Rest.split('\n'); + Line = Line.ltrim(); + if (Line.empty() || Line[0] == '#') + continue; + + if (!Persistent) + Target->RemoveAllBreakpoints(/*internal_also*/ true); + + std::string Command = substitute(Line); + P.formatLine("Command: {0}", Command); + CommandReturnObject Result; + if (!Dbg.GetCommandInterpreter().HandleCommand( + Command.c_str(), /*add_to_history*/ eLazyBoolNo, Result)) { + P.formatLine("Failed: {0}", Result.GetErrorData()); + continue; + } + + dumpState(Target->GetBreakpointList(/*internal*/ false), P); + } +} + static void dumpSymbols(Debugger &Dbg) { for (const auto &File : opts::symbols::InputFilenames) { ModuleSpec Spec{FileSpec(File, false)}; Spec.GetSymbolFileSpec().SetFile(File, false); auto ModulePtr = std::make_shared(Spec); StreamString Stream; ModulePtr->ParseAllDebugSymbols(); ModulePtr->Dump(&Stream); llvm::outs() << Stream.GetData() << "\n"; llvm::outs().flush(); } } static void dumpModules(Debugger &Dbg) { LinePrinter Printer(4, llvm::outs()); for (const auto &File : opts::module::InputFilenames) { ModuleSpec Spec{FileSpec(File, false)}; Spec.GetSymbolFileSpec().SetFile(File, false); auto ModulePtr = std::make_shared(Spec); SectionList *Sections = ModulePtr->GetSectionList(); if (!Sections) { llvm::errs() << "Could not load sections for module " << File << "\n"; continue; } size_t Count = Sections->GetNumSections(0); Printer.formatLine("Showing {0} sections", Count); for (size_t I = 0; I < Count; ++I) { AutoIndent Indent(Printer, 2); auto S = Sections->GetSectionAtIndex(I); assert(S); Printer.formatLine("Index: {0}", I); Printer.formatLine("Name: {0}", S->GetName().GetStringRef()); Printer.formatLine("VM size: {0}", S->GetByteSize()); Printer.formatLine("File size: {0}", S->GetFileSize()); if (opts::module::SectionContents) { DataExtractor Data; S->GetSectionData(Data); ArrayRef Bytes = {Data.GetDataStart(), Data.GetDataEnd()}; Printer.formatBinary("Data: ", Bytes, 0); } Printer.NewLine(); } } } int main(int argc, const char *argv[]) { StringRef ToolName = argv[0]; sys::PrintStackTraceOnErrorSignal(ToolName); PrettyStackTraceProgram X(argc, argv); llvm_shutdown_obj Y; cl::ParseCommandLineOptions(argc, argv, "LLDB Testing Utility\n"); DebuggerLifetime->Initialize(llvm::make_unique(), nullptr); auto Dbg = lldb_private::Debugger::CreateInstance(); + if (opts::BreakpointSubcommand) + opts::breakpoint::evaluateBreakpoints(*Dbg); if (opts::ModuleSubcommand) dumpModules(*Dbg); else if (opts::SymbolsSubcommand) dumpSymbols(*Dbg); DebuggerLifetime->Terminate(); return 0; }