MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / describe_ptr

Method describe_ptr

src/simulate/simulate_gc.cpp:274–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272 ptrRangeStack.pop_back();
273 }
274 bool describe_ptr ( char * pa, uint64_t tsize, bool isHandle = false ) {
275 auto ssize = (tsize + uint64_t(15)) & ~uint64_t(15);
276 bool show = !errorsOnly;
277 if ( context->stack.is_stack_ptr(pa) ) {
278 if ( show ) tp << "\tSTACK";
279 } else if ( context->isGlobalPtr(pa) ) {
280 if ( show ) tp << "\tGLOBAL";
281 } else if ( context->isSharedPtr(pa) ) {
282 if ( show ) tp << "\tSHAREDGLOBAL";
283 } else if ( context->heap->isOwnPtr(pa, ssize) ) {
284 if ( context->heap->isValidPtr(pa, ssize) ) {
285 if ( show ) tp << "\tHEAP";
286 } else {
287 tp << "\tHEAP FREE!!!";
288 show = true;
289 }
290 } else if ( context->stringHeap->isOwnPtr(pa, ssize) ) {
291 if ( context->stringHeap->isValidPtr(pa, ssize) ) {
292 if ( show ) tp << "\tSTRINGHEAP";
293 } else {
294 tp << "\tSTRINGHEAP FREE!!!";
295 show = true;
296 }
297 } else if ( context->constStringHeap->isOwnPtr(pa) ) {
298 if ( show ) tp << "\tCONSTSTRINGHEAP";
299 } else if ( context->code->isOwnPtr(pa) ) {
300 if ( show ) tp << "\tCODE";
301 } else if ( context->debugInfo->isOwnPtr(pa) ) {
302 if ( show ) tp << "\tDEBUGINFO";
303 } else if ( isHandle ) {
304 if ( show ) tp << "\tHANDLED";
305 } else {
306 tp << "UNCATEGORIZED!!!";
307 show = true;
308 }
309 if ( show ) {
310 tp << " " << tsize << " bytes, at 0x" << HEX << uint64_t(pa) << DEC << " ";
311 if ( pa==nullptr ) {
312 tp << "= NULL";
313 } else {
314 auto bpa = (uint8_t *) pa;
315 tp << HEX;
316 char tohex[] = "0123456789abcdef";
317 for ( int i=0; i<8; ++i ) {
318 auto t = bpa[i];
319 tp << " " << tohex[t>>4] << tohex[t&15];
320 }
321 tp << DEC;
322 }
323 }
324 return show;
325 }
326 void describeInfo ( TypeInfo * ti ) {
327 if ( ti->flags & (TypeInfo::flag_stringHeapGC | TypeInfo::flag_heapGC) ) tp << " ";
328 if ( ti->flags & TypeInfo::flag_stringHeapGC ) tp << "<S>";

Callers

nothing calls this directly

Calls 3

is_stack_ptrMethod · 0.80
isValidPtrMethod · 0.80
isOwnPtrMethod · 0.45

Tested by

no test coverage detected