mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 22:00:10 +00:00
[gdb-remote] Sort entries in QEnvironment*
Similar to ae316ac66f
for
QEMU_(UN)SET_ENV.
The iteration order of StringMap is not guaranteed to be deterministic.
Sort the entries to give deterministic packets for the tests added by
D108018.
This commit is contained in:
parent
4c73549ebf
commit
5d66f9fd8e
@ -35,6 +35,7 @@
|
||||
#include "lldb/Host/Config.h"
|
||||
#include "lldb/Utility/StringExtractorGDBRemote.h"
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Support/JSON.h"
|
||||
|
||||
@ -826,8 +827,12 @@ llvm::Error GDBRemoteCommunicationClient::LaunchProcess(const Args &args) {
|
||||
}
|
||||
|
||||
int GDBRemoteCommunicationClient::SendEnvironment(const Environment &env) {
|
||||
for (const auto &KV : env) {
|
||||
int r = SendEnvironmentPacket(Environment::compose(KV).c_str());
|
||||
llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 0> vec;
|
||||
for (const auto &kv : env)
|
||||
vec.emplace_back(kv.first(), kv.second);
|
||||
llvm::sort(vec, llvm::less_first());
|
||||
for (const auto &[k, v] : vec) {
|
||||
int r = SendEnvironmentPacket((k + "=" + v).str().c_str());
|
||||
if (r != 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -371,12 +371,12 @@ class TestGDBRemoteClient(GDBRemoteTestBase):
|
||||
|
||||
self.assertPacketLogContains(
|
||||
[
|
||||
"QEnvironment:EQUALS=foo=bar",
|
||||
"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43333d66726f7d62",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43343d6623726f62",
|
||||
"QEnvironment:PLAIN=foo",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
|
||||
"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
|
||||
"QEnvironment:EQUALS=foo=bar",
|
||||
]
|
||||
)
|
||||
|
||||
@ -425,12 +425,12 @@ class TestGDBRemoteClient(GDBRemoteTestBase):
|
||||
|
||||
self.assertPacketLogContains(
|
||||
[
|
||||
"QEnvironmentHexEncoded:455155414c533d666f6f3d626172",
|
||||
"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43333d66726f7d62",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43343d6623726f62",
|
||||
"QEnvironmentHexEncoded:504c41494e3d666f6f",
|
||||
"QEnvironmentHexEncoded:4e45454453454e43323d66722a6f62",
|
||||
"QEnvironmentHexEncoded:4e45454453454e433d66726f6224",
|
||||
"QEnvironmentHexEncoded:455155414c533d666f6f3d626172",
|
||||
]
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user