forked from rr-debugger/rr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TargetDescription dynamically generates the "master" target description contents (target.xml), so that we only have to manage the individual concrete CPU features (like foo-sse.xml, for instance). TargetDescription will generate the xml contents that includes the used features. Removed combinatorial target.xml files These are now handled by `TargetDescription` instead. This unblocks the rr-debugger#3776 PR (AVX512 support) from getting pulled in, though that PR will need to take this PR into account.
- Loading branch information
1 parent
f7067f1
commit d1963aa
Showing
12 changed files
with
170 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#include "TargetDescription.h" | ||
#include "GdbServerConnection.h" | ||
#include "kernel_abi.h" | ||
#include <sstream> | ||
namespace rr { | ||
|
||
class FeatureStream { | ||
std::stringstream stream{}; | ||
const char* arch_prefix{nullptr}; | ||
|
||
public: | ||
std::string result() noexcept { return stream.str(); } | ||
|
||
template <typename Any> | ||
friend FeatureStream& operator<<(FeatureStream& stream, Any any) noexcept; | ||
}; | ||
|
||
template <typename Any> | ||
FeatureStream& operator<<(FeatureStream& stream, Any any) noexcept { | ||
stream.stream << any; | ||
return stream; | ||
} | ||
|
||
template <> | ||
FeatureStream& operator<<(FeatureStream& stream, | ||
rr::SupportedArch arch) noexcept { | ||
stream << "<architecture>"; | ||
switch (arch) { | ||
case rr::x86: | ||
stream << "i386"; | ||
stream.arch_prefix = "32bit-"; | ||
break; | ||
case rr::x86_64: | ||
stream << "i386:x86-64"; | ||
stream.arch_prefix = "64bit-"; | ||
break; | ||
case rr::aarch64: | ||
stream << "aarch64"; | ||
stream.arch_prefix = "aarch64-"; | ||
break; | ||
} | ||
stream << "</architecture>\n"; | ||
return stream; | ||
} | ||
|
||
template <> | ||
FeatureStream& operator<<(FeatureStream& stream, | ||
TargetFeature feature) noexcept { | ||
DEBUG_ASSERT(stream.arch_prefix != nullptr && | ||
"No architecture has been provided to description"); | ||
stream << R"( <xi:include href=")" << stream.arch_prefix; | ||
switch (feature) { | ||
case TargetFeature::Core: | ||
stream << "core.xml"; | ||
break; | ||
case TargetFeature::Linux: | ||
stream << "linux.xml"; | ||
break; | ||
case TargetFeature::SSE: | ||
stream << "sse.xml"; | ||
break; | ||
case TargetFeature::AVX: | ||
stream << "avx.xml"; | ||
break; | ||
case TargetFeature::PKeys: | ||
stream << "pkeys.xml"; | ||
break; | ||
case TargetFeature::Segment: | ||
stream << "seg.xml"; | ||
break; | ||
} | ||
stream << R"("/>)" << '\n'; | ||
return stream; | ||
} | ||
|
||
TargetDescription::TargetDescription(rr::SupportedArch arch, | ||
u32 cpu_features) noexcept | ||
: arch(arch), target_features() { | ||
|
||
// default-assumed registers per arch | ||
switch (arch) { | ||
case rr::x86: | ||
target_features.push_back(TargetFeature::Core); | ||
target_features.push_back(TargetFeature::SSE); | ||
target_features.push_back(TargetFeature::Linux); | ||
break; | ||
case rr::x86_64: | ||
target_features.push_back(TargetFeature::Core); | ||
target_features.push_back(TargetFeature::SSE); | ||
target_features.push_back(TargetFeature::Linux); | ||
target_features.push_back(TargetFeature::Segment); | ||
break; | ||
case rr::aarch64: | ||
target_features.push_back(TargetFeature::Core); | ||
break; | ||
} | ||
|
||
if (cpu_features & rr::GdbServerConnection::CPU_AVX) { | ||
DEBUG_ASSERT((arch == rr::x86 || arch == rr::x86_64) && "unexpected arch"); | ||
target_features.push_back(TargetFeature::AVX); | ||
} | ||
|
||
if (cpu_features & rr::GdbServerConnection::CPU_PKU) { | ||
DEBUG_ASSERT((arch == rr::x86 || arch == rr::x86_64) && "unexpected arch"); | ||
target_features.push_back(TargetFeature::PKeys); | ||
} | ||
} | ||
|
||
static constexpr auto Header = R"(<?xml version="1.0"?> | ||
<!DOCTYPE target SYSTEM "gdb-target.dtd"> | ||
<target> | ||
)"; | ||
|
||
std::string TargetDescription::to_xml() const noexcept { | ||
FeatureStream fs{}; | ||
fs << Header << arch << "<osabi>GNU/Linux</osabi>\n"; | ||
for (const auto feature : target_features) { | ||
fs << feature; | ||
} | ||
fs << "</target>"; | ||
|
||
return fs.result(); | ||
} | ||
} // namespace rr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include "kernel_abi.h" | ||
#include <cstdint> | ||
|
||
namespace rr { | ||
|
||
struct GdbServerRegisterValue; | ||
|
||
using u32 = std::uint32_t; | ||
|
||
enum class TargetFeature : u32 { | ||
Core = 0, | ||
SSE, | ||
Linux, | ||
Segment, | ||
AVX, | ||
PKeys | ||
}; | ||
|
||
class TargetDescription { | ||
SupportedArch arch; | ||
std::vector<TargetFeature> target_features; | ||
public: | ||
explicit TargetDescription(rr::SupportedArch arch, u32 cpu_features) noexcept; | ||
std::string to_xml() const noexcept; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.