From 880b6e9795e2a86d8f31f437c9ac7d356e7790a5 Mon Sep 17 00:00:00 2001 From: arades79 Date: Tue, 14 Feb 2023 11:33:42 -0500 Subject: use a string view to skip allocation Signed-off-by: arades79 --- src/core/debugger/gdbstub_arch.cpp | 14 ++++---------- src/core/debugger/gdbstub_arch.h | 6 +++--- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index b13c473bb..f3dd517bd 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp @@ -41,9 +41,8 @@ static void PutSIMDRegister(std::array& simd_regs, size_t offset, const // For sample XML files see the GDB source /gdb/features // This XML defines what the registers are for this specific ARM device -std::string GDBStubA64::GetTargetXML() const { - constexpr static const char* target_xml = - R"( +constexpr std::string_view GDBStubA64::GetTargetXML() const { + return R"( aarch64 @@ -178,8 +177,6 @@ std::string GDBStubA64::GetTargetXML() const { )"; - - return target_xml; } std::string GDBStubA64::RegRead(const Kernel::KThread* thread, size_t id) const { @@ -270,9 +267,8 @@ u32 GDBStubA64::BreakpointInstruction() const { return 0xd4200000; } -std::string GDBStubA32::GetTargetXML() const { - constexpr static const char* target_xml = - R"( +constexpr std::string_view GDBStubA32::GetTargetXML() const { + return R"( arm @@ -378,8 +374,6 @@ std::string GDBStubA32::GetTargetXML() const { )"; - - return target_xml; } std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const { diff --git a/src/core/debugger/gdbstub_arch.h b/src/core/debugger/gdbstub_arch.h index 2540d6456..1958fdf88 100644 --- a/src/core/debugger/gdbstub_arch.h +++ b/src/core/debugger/gdbstub_arch.h @@ -16,7 +16,7 @@ namespace Core { class GDBStubArch { public: virtual ~GDBStubArch() = default; - virtual std::string GetTargetXML() const = 0; + virtual constexpr std::string_view GetTargetXML() const = 0; virtual std::string RegRead(const Kernel::KThread* thread, size_t id) const = 0; virtual void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const = 0; virtual std::string ReadRegisters(const Kernel::KThread* thread) const = 0; @@ -27,7 +27,7 @@ public: class GDBStubA64 final : public GDBStubArch { public: - std::string GetTargetXML() const override; + constexpr std::string_view GetTargetXML() const override; std::string RegRead(const Kernel::KThread* thread, size_t id) const override; void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const override; std::string ReadRegisters(const Kernel::KThread* thread) const override; @@ -47,7 +47,7 @@ private: class GDBStubA32 final : public GDBStubArch { public: - std::string GetTargetXML() const override; + constexpr std::string_view GetTargetXML() const override; std::string RegRead(const Kernel::KThread* thread, size_t id) const override; void RegWrite(Kernel::KThread* thread, size_t id, std::string_view value) const override; std::string ReadRegisters(const Kernel::KThread* thread) const override; -- cgit v1.2.3