MCPcopy Create free account
hub / github.com/DFHack/dfhack / df_vectors

Function df_vectors

plugins/devel/vectors.cpp:154–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154command_result df_vectors (color_ostream &con, vector <string> & parameters)
155{
156 if (parameters.size() != 2)
157 {
158 vectorsUsage(con);
159 return CR_FAILURE;
160 }
161
162 uintptr_t start = 0, bytes = 0;
163
164 if (!hexOrDec(parameters[0], start))
165 {
166 vectorsUsage(con);
167 return CR_FAILURE;
168 }
169
170 if (!hexOrDec(parameters[1], bytes))
171 {
172 vectorsUsage(con);
173 return CR_FAILURE;
174 }
175
176 uintptr_t end = start + bytes;
177
178 // 4 byte alignment.
179 while (start % 4 != 0)
180 start++;
181
182 std::vector<t_memrange> ranges;
183
184 if (!getRanges(con, ranges))
185 {
186 return CR_FAILURE;
187 }
188
189 bool startInRange = false;
190 for (size_t i = 0; i < ranges.size(); i++)
191 {
192 t_memrange &range = ranges[i];
193
194 if (!range.isInRange((void *)start))
195 continue;
196
197 // Found the range containing the start
198 if (!range.isInRange((void *)end))
199 {
200 con.print("Scanning {} bytes would read past end of memory "
201 "range.\n", bytes);
202 size_t diff = end - (intptr_t)range.end;
203 con.print("Cutting bytes down by {}.\n", diff);
204
205 end = (uintptr_t) range.end;
206 }
207 startInRange = true;
208 break;
209 } // for (size_t i = 0; i < ranges.size(); i++)
210
211 if (!startInRange)

Callers

nothing calls this directly

Calls 9

vectorsUsageFunction · 0.85
hexOrDecFunction · 0.85
getRangesFunction · 0.85
mightBeVecFunction · 0.85
printVecFunction · 0.85
inAnyRangeFunction · 0.85
isInRangeMethod · 0.80
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected