003 File Manager
Current Path:
/usr/src/contrib/llvm-project/lldb/source/Utility
usr
/
src
/
contrib
/
llvm-project
/
lldb
/
source
/
Utility
/
📁
..
📄
ARM64_DWARF_Registers.h
(1.68 KB)
📄
ARM64_ehframe_Registers.h
(1.74 KB)
📄
ARM_DWARF_Registers.h
(3.21 KB)
📄
ARM_ehframe_Registers.h
(907 B)
📄
ArchSpec.cpp
(51.71 KB)
📄
Args.cpp
(20.02 KB)
📄
Baton.cpp
(630 B)
📄
Broadcaster.cpp
(14.94 KB)
📄
CompletionRequest.cpp
(3.11 KB)
📄
Connection.cpp
(476 B)
📄
ConstString.cpp
(12.33 KB)
📄
DataBufferHeap.cpp
(2.28 KB)
📄
DataBufferLLVM.cpp
(1.06 KB)
📄
DataEncoder.cpp
(6.17 KB)
📄
DataExtractor.cpp
(35.43 KB)
📄
Environment.cpp
(1.44 KB)
📄
Event.cpp
(8.2 KB)
📄
FileSpec.cpp
(17.66 KB)
📄
GDBRemote.cpp
(5.03 KB)
📄
IOObject.cpp
(537 B)
📄
LLDBAssert.cpp
(1.37 KB)
📄
Listener.cpp
(16.12 KB)
📄
Log.cpp
(10.81 KB)
📄
Logging.cpp
(3.24 KB)
📄
NameMatches.cpp
(1.06 KB)
📄
PPC64LE_DWARF_Registers.h
(4.24 KB)
📄
PPC64_DWARF_Registers.h
(2.6 KB)
📄
ProcessInfo.cpp
(13.29 KB)
📄
RegisterValue.cpp
(23.92 KB)
📄
RegularExpression.cpp
(1.36 KB)
📄
Reproducer.cpp
(8.75 KB)
📄
ReproducerInstrumentation.cpp
(6.84 KB)
📄
Scalar.cpp
(36.74 KB)
📄
SelectHelper.cpp
(7.23 KB)
📄
State.cpp
(2.52 KB)
📄
Status.cpp
(8.34 KB)
📄
Stream.cpp
(11.28 KB)
📄
StreamCallback.cpp
(793 B)
📄
StreamString.cpp
(1.95 KB)
📄
StringExtractor.cpp
(10.19 KB)
📄
StringExtractorGDBRemote.cpp
(17.3 KB)
📄
StringLexer.cpp
(1.79 KB)
📄
StringList.cpp
(5.83 KB)
📄
StructuredData.cpp
(5.11 KB)
📄
TildeExpressionResolver.cpp
(2.54 KB)
📄
Timer.cpp
(4.61 KB)
📄
UUID.cpp
(2.8 KB)
📄
UriParser.cpp
(1.94 KB)
📄
UserID.cpp
(648 B)
📄
UserIDResolver.cpp
(1.34 KB)
📄
UuidCompatibility.h
(648 B)
📄
VASprintf.cpp
(1.55 KB)
📄
VMRange.cpp
(2.1 KB)
📄
XcodeSDK.cpp
(8.26 KB)
Editing: Event.cpp
//===-- Event.cpp ---------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/Utility/Event.h" #include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-enumerations.h" #include <algorithm> #include <ctype.h> using namespace lldb; using namespace lldb_private; #pragma mark - #pragma mark Event // Event functions Event::Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data) : m_broadcaster_wp(broadcaster->GetBroadcasterImpl()), m_type(event_type), m_data_sp(data) {} Event::Event(Broadcaster *broadcaster, uint32_t event_type, const EventDataSP &event_data_sp) : m_broadcaster_wp(broadcaster->GetBroadcasterImpl()), m_type(event_type), m_data_sp(event_data_sp) {} Event::Event(uint32_t event_type, EventData *data) : m_broadcaster_wp(), m_type(event_type), m_data_sp(data) {} Event::Event(uint32_t event_type, const EventDataSP &event_data_sp) : m_broadcaster_wp(), m_type(event_type), m_data_sp(event_data_sp) {} Event::~Event() = default; void Event::Dump(Stream *s) const { Broadcaster *broadcaster; Broadcaster::BroadcasterImplSP broadcaster_impl_sp(m_broadcaster_wp.lock()); if (broadcaster_impl_sp) broadcaster = broadcaster_impl_sp->GetBroadcaster(); else broadcaster = nullptr; if (broadcaster) { StreamString event_name; if (broadcaster->GetEventNames(event_name, m_type, false)) s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x (%s), data = ", static_cast<const void *>(this), static_cast<void *>(broadcaster), broadcaster->GetBroadcasterName().GetCString(), m_type, event_name.GetData()); else s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x, data = ", static_cast<const void *>(this), static_cast<void *>(broadcaster), broadcaster->GetBroadcasterName().GetCString(), m_type); } else s->Printf("%p Event: broadcaster = NULL, type = 0x%8.8x, data = ", static_cast<const void *>(this), m_type); if (m_data_sp) { s->PutChar('{'); m_data_sp->Dump(s); s->PutChar('}'); } else s->Printf("<NULL>"); } void Event::DoOnRemoval() { if (m_data_sp) m_data_sp->DoOnRemoval(this); } #pragma mark - #pragma mark EventData // EventData functions EventData::EventData() = default; EventData::~EventData() = default; void EventData::Dump(Stream *s) const { s->PutCString("Generic Event Data"); } #pragma mark - #pragma mark EventDataBytes // EventDataBytes functions EventDataBytes::EventDataBytes() : m_bytes() {} EventDataBytes::EventDataBytes(const char *cstr) : m_bytes() { SetBytesFromCString(cstr); } EventDataBytes::EventDataBytes(llvm::StringRef str) : m_bytes() { SetBytes(str.data(), str.size()); } EventDataBytes::EventDataBytes(const void *src, size_t src_len) : m_bytes() { SetBytes(src, src_len); } EventDataBytes::~EventDataBytes() = default; ConstString EventDataBytes::GetFlavorString() { static ConstString g_flavor("EventDataBytes"); return g_flavor; } ConstString EventDataBytes::GetFlavor() const { return EventDataBytes::GetFlavorString(); } void EventDataBytes::Dump(Stream *s) const { size_t num_printable_chars = std::count_if(m_bytes.begin(), m_bytes.end(), llvm::isPrint); if (num_printable_chars == m_bytes.size()) s->Format("\"{0}\"", m_bytes); else s->Format("{0:$[ ]@[x-2]}", llvm::make_range( reinterpret_cast<const uint8_t *>(m_bytes.data()), reinterpret_cast<const uint8_t *>(m_bytes.data() + m_bytes.size()))); } const void *EventDataBytes::GetBytes() const { return (m_bytes.empty() ? nullptr : m_bytes.data()); } size_t EventDataBytes::GetByteSize() const { return m_bytes.size(); } void EventDataBytes::SetBytes(const void *src, size_t src_len) { if (src != nullptr && src_len > 0) m_bytes.assign(static_cast<const char *>(src), src_len); else m_bytes.clear(); } void EventDataBytes::SetBytesFromCString(const char *cstr) { if (cstr != nullptr && cstr[0]) m_bytes.assign(cstr); else m_bytes.clear(); } const void *EventDataBytes::GetBytesFromEvent(const Event *event_ptr) { const EventDataBytes *e = GetEventDataFromEvent(event_ptr); if (e != nullptr) return e->GetBytes(); return nullptr; } size_t EventDataBytes::GetByteSizeFromEvent(const Event *event_ptr) { const EventDataBytes *e = GetEventDataFromEvent(event_ptr); if (e != nullptr) return e->GetByteSize(); return 0; } const EventDataBytes * EventDataBytes::GetEventDataFromEvent(const Event *event_ptr) { if (event_ptr != nullptr) { const EventData *event_data = event_ptr->GetData(); if (event_data && event_data->GetFlavor() == EventDataBytes::GetFlavorString()) return static_cast<const EventDataBytes *>(event_data); } return nullptr; } void EventDataBytes::SwapBytes(std::string &new_bytes) { m_bytes.swap(new_bytes); } #pragma mark - #pragma mark EventStructuredData // EventDataStructuredData definitions EventDataStructuredData::EventDataStructuredData() : EventData(), m_process_sp(), m_object_sp(), m_plugin_sp() {} EventDataStructuredData::EventDataStructuredData( const ProcessSP &process_sp, const StructuredData::ObjectSP &object_sp, const lldb::StructuredDataPluginSP &plugin_sp) : EventData(), m_process_sp(process_sp), m_object_sp(object_sp), m_plugin_sp(plugin_sp) {} EventDataStructuredData::~EventDataStructuredData() {} // EventDataStructuredData member functions ConstString EventDataStructuredData::GetFlavor() const { return EventDataStructuredData::GetFlavorString(); } void EventDataStructuredData::Dump(Stream *s) const { if (!s) return; if (m_object_sp) m_object_sp->Dump(*s); } const ProcessSP &EventDataStructuredData::GetProcess() const { return m_process_sp; } const StructuredData::ObjectSP &EventDataStructuredData::GetObject() const { return m_object_sp; } const lldb::StructuredDataPluginSP & EventDataStructuredData::GetStructuredDataPlugin() const { return m_plugin_sp; } void EventDataStructuredData::SetProcess(const ProcessSP &process_sp) { m_process_sp = process_sp; } void EventDataStructuredData::SetObject( const StructuredData::ObjectSP &object_sp) { m_object_sp = object_sp; } void EventDataStructuredData::SetStructuredDataPlugin( const lldb::StructuredDataPluginSP &plugin_sp) { m_plugin_sp = plugin_sp; } // EventDataStructuredData static functions const EventDataStructuredData * EventDataStructuredData::GetEventDataFromEvent(const Event *event_ptr) { if (event_ptr == nullptr) return nullptr; const EventData *event_data = event_ptr->GetData(); if (!event_data || event_data->GetFlavor() != EventDataStructuredData::GetFlavorString()) return nullptr; return static_cast<const EventDataStructuredData *>(event_data); } ProcessSP EventDataStructuredData::GetProcessFromEvent(const Event *event_ptr) { auto event_data = EventDataStructuredData::GetEventDataFromEvent(event_ptr); if (event_data) return event_data->GetProcess(); else return ProcessSP(); } StructuredData::ObjectSP EventDataStructuredData::GetObjectFromEvent(const Event *event_ptr) { auto event_data = EventDataStructuredData::GetEventDataFromEvent(event_ptr); if (event_data) return event_data->GetObject(); else return StructuredData::ObjectSP(); } lldb::StructuredDataPluginSP EventDataStructuredData::GetPluginFromEvent(const Event *event_ptr) { auto event_data = EventDataStructuredData::GetEventDataFromEvent(event_ptr); if (event_data) return event_data->GetStructuredDataPlugin(); else return StructuredDataPluginSP(); } ConstString EventDataStructuredData::GetFlavorString() { static ConstString s_flavor("EventDataStructuredData"); return s_flavor; }
Upload File
Create Folder