Skip to content

Cp/r139804630 revert wip corefile segment combination pass #9871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,335 changes: 1,202 additions & 1,133 deletions lldb/bindings/python/static-binding/LLDBWrapPython.cpp

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions lldb/bindings/python/static-binding/lldb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.2.1
# Version 4.3.0
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.
Expand Down Expand Up @@ -99,7 +99,7 @@ class _SwigNonDynamicMeta(type):
#3.0.18.
def _to_int(hex):
return hex // 0x10 % 0x10 * 10 + hex % 0x10
swig_version = (_to_int(0x040201 // 0x10000), _to_int(0x040201 // 0x100), _to_int(0x040201))
swig_version = (_to_int(0x040300 // 0x10000), _to_int(0x040300 // 0x100), _to_int(0x040300))
del _to_int


Expand Down Expand Up @@ -1679,8 +1679,6 @@ def lldb_iter(obj, getsize, getelem):

eSaveCoreStackOnly = _lldb.eSaveCoreStackOnly

eSaveCoreCustomOnly = _lldb.eSaveCoreCustomOnly

eTraceEventDisabledSW = _lldb.eTraceEventDisabledSW

eTraceEventDisabledHW = _lldb.eTraceEventDisabledHW
Expand Down Expand Up @@ -4196,10 +4194,6 @@ def RemoveThread(self, thread):
r"""RemoveThread(SBSaveCoreOptions self, SBThread thread) -> bool"""
return _lldb.SBSaveCoreOptions_RemoveThread(self, thread)

def AddMemoryRegionToSave(self, region):
r"""AddMemoryRegionToSave(SBSaveCoreOptions self, SBMemoryRegionInfo region) -> SBError"""
return _lldb.SBSaveCoreOptions_AddMemoryRegionToSave(self, region)

def Clear(self):
r"""Clear(SBSaveCoreOptions self)"""
return _lldb.SBSaveCoreOptions_Clear(self)
Expand Down Expand Up @@ -5094,6 +5088,14 @@ def SetTerminalWidth(self, term_width):
r"""SetTerminalWidth(SBDebugger self, uint32_t term_width)"""
return _lldb.SBDebugger_SetTerminalWidth(self, term_width)

def GetTerminalHeight(self):
r"""GetTerminalHeight(SBDebugger self) -> uint32_t"""
return _lldb.SBDebugger_GetTerminalHeight(self)

def SetTerminalHeight(self, term_height):
r"""SetTerminalHeight(SBDebugger self, uint32_t term_height)"""
return _lldb.SBDebugger_SetTerminalHeight(self, term_height)

def GetID(self):
r"""GetID(SBDebugger self) -> lldb::user_id_t"""
return _lldb.SBDebugger_GetID(self)
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/API/SBMemoryRegionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
private:
friend class SBProcess;
friend class SBMemoryRegionInfoList;
friend class SBSaveCoreOptions;

friend class lldb_private::ScriptInterpreter;

lldb_private::MemoryRegionInfo &ref();
Expand Down
15 changes: 0 additions & 15 deletions lldb/include/lldb/API/SBSaveCoreOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,6 @@ class LLDB_API SBSaveCoreOptions {
/// True if the thread was removed, false if it was not in the list.
bool RemoveThread(lldb::SBThread thread);

/// Add a memory region to save in the core file.
///
/// \param region
/// The memory region to save.
///
/// \returns
/// An empty SBError upon success, or an error if the region is invalid.
///
/// \note
/// Ranges that overlapped will be unioned into a single region, this also
/// supercedes stack minification. Specifying full regions and a non-custom
/// core style will include the specified regions and union them with all
/// style specific regions.
SBError AddMemoryRegionToSave(const SBMemoryRegionInfo &region);

/// Reset all options.
void Clear();

Expand Down
11 changes: 2 additions & 9 deletions lldb/include/lldb/Symbol/SaveCoreOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H

#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"

#include <optional>
#include <set>
#include <string>
#include <unordered_set>

using MemoryRanges = lldb_private::RangeVector<lldb::addr_t, lldb::addr_t>;

namespace lldb_private {

class SaveCoreOptions {
Expand All @@ -40,12 +38,8 @@ class SaveCoreOptions {
Status AddThread(lldb::ThreadSP thread_sp);
bool RemoveThread(lldb::ThreadSP thread_sp);
bool ShouldThreadBeSaved(lldb::tid_t tid) const;
bool HasSpecifiedThreads() const;

Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
const MemoryRanges &GetCoreFileMemoryRanges() const;

void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo &region);

void Clear();

Expand All @@ -57,7 +51,6 @@ class SaveCoreOptions {
std::optional<lldb::SaveCoreStyle> m_style;
lldb::ProcessSP m_process_sp;
std::unordered_set<lldb::tid_t> m_threads_to_save;
MemoryRanges m_regions_to_save;
};
} // namespace lldb_private

Expand Down
5 changes: 1 addition & 4 deletions lldb/include/lldb/Target/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Host/ProcessRunLock.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/Memory.h"
Expand Down Expand Up @@ -735,9 +734,7 @@ class Process : public std::enable_shared_from_this<Process>,
}
};

using CoreFileMemoryRanges =
lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t,
CoreFileMemoryRange>;
using CoreFileMemoryRanges = std::vector<CoreFileMemoryRange>;

/// Helper function for Process::SaveCore(...) that calculates the address
/// ranges that should be saved. This allows all core file plug-ins to save
Expand Down
2 changes: 0 additions & 2 deletions lldb/include/lldb/Utility/RangeMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@ class RangeDataVector {

void Append(const Entry &entry) { m_entries.emplace_back(entry); }

void Append(B &&b, S &&s, T &&t) { m_entries.emplace_back(Entry(b, s, t)); }

bool Erase(uint32_t start, uint32_t end) {
if (start >= end || end > m_entries.size())
return false;
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/lldb-enumerations.h
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,6 @@ enum SaveCoreStyle {
eSaveCoreFull = 1,
eSaveCoreDirtyOnly = 2,
eSaveCoreStackOnly = 3,
eSaveCoreCustomOnly = 4,
};

/// Events that might happen during a trace session.
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/lldb-forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ class StackFrameRecognizer;
class StackFrameRecognizerManager;
class StackID;
class Status;
class SaveCoreOptions;
class StopInfo;
class Stoppoint;
class StoppointCallbackContext;
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/lldb-private-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLDB_LLDB_PRIVATE_INTERFACES_H
#define LLDB_LLDB_PRIVATE_INTERFACES_H

#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private-enumerations.h"
Expand Down
11 changes: 0 additions & 11 deletions lldb/source/API/SBSaveCoreOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "lldb/API/SBSaveCoreOptions.h"
#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Utility/Instrumentation.h"
Expand Down Expand Up @@ -90,16 +89,6 @@ bool SBSaveCoreOptions::RemoveThread(lldb::SBThread thread) {
return m_opaque_up->RemoveThread(thread.GetSP());
}

lldb::SBError
SBSaveCoreOptions::AddMemoryRegionToSave(const SBMemoryRegionInfo &region) {
LLDB_INSTRUMENT_VA(this, region);
// Currently add memory region can't fail, so we always return a success
// SBerror, but because these API's live forever, this is the most future
// proof thing to do.
m_opaque_up->AddMemoryRegionToSave(region.ref());
return SBError();
}

void SBSaveCoreOptions::Clear() {
LLDB_INSTRUMENT_VA(this);
m_opaque_up->Clear();
Expand Down
1 change: 0 additions & 1 deletion lldb/source/Commands/CommandObjectProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
Expand Down
4 changes: 1 addition & 3 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6605,9 +6605,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
const uint32_t addr_byte_size = target_arch.GetAddressByteSize();
const ByteOrder byte_order = target_arch.GetByteOrder();
std::vector<llvm::MachO::segment_command_64> segment_load_commands;
for (const auto &core_range_info : core_ranges) {
// TODO: Refactor RangeDataVector to have a data iterator.
const auto &core_range = core_range_info.data;
for (const auto &core_range : core_ranges) {
uint32_t cmd_type = LC_SEGMENT_64;
uint32_t segment_size = sizeof(llvm::MachO::segment_command_64);
if (addr_byte_size == 4) {
Expand Down
1 change: 0 additions & 1 deletion lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "lldb/Core/Address.h"
#include "lldb/Host/SafeMachO.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/FileSpecList.h"
#include "lldb/Utility/RangeMap.h"
Expand Down
33 changes: 13 additions & 20 deletions lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,32 +826,25 @@ Status MinidumpFileBuilder::AddMemoryList() {
// bytes of the core file. Thread structures in minidump files can only use
// 32 bit memory descriptiors, so we emit them first to ensure the memory is
// in accessible with a 32 bit offset.
std::vector<Process::CoreFileMemoryRange> ranges_32;
std::vector<Process::CoreFileMemoryRange> ranges_64;
Process::CoreFileMemoryRanges ranges_32;
Process::CoreFileMemoryRanges ranges_64;
Process::CoreFileMemoryRanges all_core_memory_ranges;
error = m_process_sp->CalculateCoreFileSaveRanges(m_save_core_options,
all_core_memory_ranges);

std::vector<Process::CoreFileMemoryRange> all_core_memory_vec;
// Extract all the data into just a vector of data. So we can mutate this in
// place.
for (const auto &core_range : all_core_memory_ranges)
all_core_memory_vec.push_back(core_range.data);

if (error.Fail())
return error;

// Start by saving all of the stacks and ensuring they fit under the 32b
// limit.
uint64_t total_size = GetCurrentDataEndOffset();
auto iterator = all_core_memory_vec.begin();
while (iterator != all_core_memory_vec.end()) {
auto iterator = all_core_memory_ranges.begin();
while (iterator != all_core_memory_ranges.end()) {
if (m_saved_stack_ranges.count(iterator->range.start()) > 0) {
// We don't save stacks twice.
ranges_32.push_back(*iterator);
total_size +=
iterator->range.size() + sizeof(llvm::minidump::MemoryDescriptor);
iterator = all_core_memory_vec.erase(iterator);
iterator = all_core_memory_ranges.erase(iterator);
} else {
iterator++;
}
Expand All @@ -871,11 +864,11 @@ Status MinidumpFileBuilder::AddMemoryList() {
// Then anything overflow extends into 64b addressable space.
// All core memeroy ranges will either container nothing on stacks only
// or all the memory ranges including stacks
if (!all_core_memory_vec.empty())
total_size += 256 + (all_core_memory_vec.size() *
if (!all_core_memory_ranges.empty())
total_size += 256 + (all_core_memory_ranges.size() *
sizeof(llvm::minidump::MemoryDescriptor_64));

for (const auto &core_range : all_core_memory_vec) {
for (const auto &core_range : all_core_memory_ranges) {
const addr_t range_size = core_range.range.size();
// We don't need to check for stacks here because we already removed them
// from all_core_memory_ranges.
Expand Down Expand Up @@ -960,15 +953,15 @@ Status MinidumpFileBuilder::DumpDirectories() const {
}

static uint64_t
GetLargestRangeSize(const std::vector<Process::CoreFileMemoryRange> &ranges) {
GetLargestRangeSize(const Process::CoreFileMemoryRanges &ranges) {
uint64_t max_size = 0;
for (const auto &core_range : ranges)
max_size = std::max(max_size, core_range.range.size());
return max_size;
}

Status MinidumpFileBuilder::AddMemoryList_32(
std::vector<Process::CoreFileMemoryRange> &ranges) {
Status
MinidumpFileBuilder::AddMemoryList_32(Process::CoreFileMemoryRanges &ranges) {
std::vector<MemoryDescriptor> descriptors;
Status error;
if (ranges.size() == 0)
Expand Down Expand Up @@ -1042,8 +1035,8 @@ Status MinidumpFileBuilder::AddMemoryList_32(
return error;
}

Status MinidumpFileBuilder::AddMemoryList_64(
std::vector<Process::CoreFileMemoryRange> &ranges) {
Status
MinidumpFileBuilder::AddMemoryList_64(Process::CoreFileMemoryRanges &ranges) {
Status error;
if (ranges.empty())
return error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <utility>
#include <variant>

#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
Expand Down Expand Up @@ -120,10 +119,10 @@ class MinidumpFileBuilder {
// trigger a flush.
lldb_private::Status AddData(const void *data, uint64_t size);
// Add MemoryList stream, containing dumps of important memory segments
lldb_private::Status AddMemoryList_64(
std::vector<lldb_private::Process::CoreFileMemoryRange> &ranges);
lldb_private::Status AddMemoryList_32(
std::vector<lldb_private::Process::CoreFileMemoryRange> &ranges);
lldb_private::Status
AddMemoryList_64(lldb_private::Process::CoreFileMemoryRanges &ranges);
lldb_private::Status
AddMemoryList_32(lldb_private::Process::CoreFileMemoryRanges &ranges);
// Update the thread list on disk with the newly emitted stack RVAs.
lldb_private::Status FixThreadStacks();
lldb_private::Status FlushBufferToDisk();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_OBJECTFILEMINIDUMP_H

#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Utility/ArchSpec.h"

class ObjectFileMinidump : public lldb_private::PluginInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
Expand Down
1 change: 0 additions & 1 deletion lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <vector>

#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SaveCoreOptions.h"
#include "llvm/Object/COFF.h"

class ObjectFilePECOFF : public lldb_private::ObjectFile {
Expand Down
14 changes: 0 additions & 14 deletions lldb/source/Symbol/SaveCoreOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,6 @@ bool SaveCoreOptions::ShouldThreadBeSaved(lldb::tid_t tid) const {
return m_threads_to_save.count(tid) > 0;
}

bool SaveCoreOptions::HasSpecifiedThreads() const {
return !m_threads_to_save.empty();
}

void SaveCoreOptions::AddMemoryRegionToSave(
const lldb_private::MemoryRegionInfo &region) {
m_regions_to_save.Insert(region.GetRange(), /*combine=*/true);
}

const MemoryRanges &SaveCoreOptions::GetCoreFileMemoryRanges() const {
return m_regions_to_save;
}

Status SaveCoreOptions::EnsureValidConfiguration(
lldb::ProcessSP process_sp) const {
Status error;
Expand Down Expand Up @@ -144,5 +131,4 @@ void SaveCoreOptions::Clear() {
m_style = std::nullopt;
m_threads_to_save.clear();
m_process_sp.reset();
m_regions_to_save.Clear();
}
Loading