MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / ParseMessage

Method ParseMessage

Source/Tools/CodeSizeValidation/Main.cpp:109–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109bool CodeSizeValidation::ParseMessage(const char* Message) {
110 // std::string_view doesn't have contains until c++23.
111 std::string_view MessageView {Message};
112 if (MessageView.find(RIPMessage) != MessageView.npos) {
113 // New RIP found
114 std::string_view RIPView = std::string_view {Message + RIPMessage.size()};
115 std::from_chars(RIPView.data(), RIPView.end(), CurrentRIPParse, 16);
116 ClearStats();
117 return false;
118 }
119
120 if (MessageView.find(GuestCodeMessage) != MessageView.npos) {
121 std::string_view CodeSizeView = std::string_view {Message + GuestCodeMessage.size()};
122 std::from_chars(CodeSizeView.data(), CodeSizeView.end(), CurrentStats.first.GuestCodeInstructions);
123 return false;
124 }
125 if (MessageView.find(DisassembleBeginMessage) != MessageView.npos) {
126 ConsumingDisassembly = true;
127 // Just so the output isn't a mess.
128 return false;
129 }
130 if (MessageView.find(DisassembleEndMessage) != MessageView.npos) {
131 ConsumingDisassembly = false;
132 // Just so the output isn't a mess.
133
134 // Remove the header and tails.
135 if (HeaderSize != -1) {
136 CurrentStats.second.erase(CurrentStats.second.begin(), CurrentStats.second.begin() + HeaderSize);
137 }
138 // Find the first `udf #0x420f` and remove everything from that point onward.
139 auto EraseBegin = std::find(CurrentStats.second.begin(), CurrentStats.second.end(), "udf #0x420f");
140 CurrentStats.second.erase(EraseBegin, CurrentStats.second.end());
141 CurrentStats.first.HostCodeInstructions = CurrentStats.second.size();
142 return false;
143 }
144
145 if (MessageView.find(BlowUpMsg) != MessageView.npos) {
146 return false;
147 }
148
149 if (ConsumingDisassembly) {
150 // Currently consuming disassembly. Each line will be a single line of disassembly.
151 CurrentStats.second.push_back(fextl::string(SanitizeDisassembly(Message)));
152 return false;
153 }
154
155 return true;
156}
157
158void CodeSizeValidation::CalculateBaseStats(FEXCore::Context::Context* CTX, FEXCore::Core::InternalThreadState* Thread) {
159 SetupInfoDisabled = true;

Callers 1

MsgHandlerFunction · 0.80

Calls 5

SanitizeDisassemblyFunction · 0.85
eraseMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected