MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / ComputeCallStackId

Method ComputeCallStackId

src/hx/Telemetry.cpp:401–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401int hx::Telemetry::ComputeCallStackId() {
402 std::vector<int> callstack;
403 int stackId;
404
405 push_callstack_ids_into(&callstack);
406 int size = callstack.size();
407
408 AllocStackIdMapEntry *asime = &allocStackIdMapRoot;
409
410 int i=0;
411 while (i<size) {
412 int name_id = callstack.at(i++);
413 //printf("Finding child with id=%d, asime now %#010x\n", name_id, asime);
414 std::map<int, AllocStackIdMapEntry*>::iterator lb = asime->children.lower_bound(name_id);
415
416 if (lb != asime->children.end() && !(asime->children.key_comp()(name_id, lb->first)))
417 { // key already exists
418 asime = lb->second;
419 } else {
420 // the key does not exist in the map, add it
421 AllocStackIdMapEntry *newEntry = new AllocStackIdMapEntry();
422 newEntry->terminationStackId = -1;
423 asime->children.insert(lb, std::map<int, AllocStackIdMapEntry*>::value_type(name_id, newEntry));
424 asime = newEntry;
425 }
426 }
427
428 if (asime->terminationStackId == -1) {
429 // This is a new stackId, store call stack id's in allocStacks
430 stackId = asime->terminationStackId = allocStackIdNext;
431 allocStacks.push_back(size);
432 int i = size-1;
433 while (i>=0) allocStacks.push_back(callstack.at(i--));
434 //printf("new callstackid %d\n", allocStackIdNext);
435 allocStackIdNext++;
436 } else {
437 stackId = asime->terminationStackId;
438 //printf("existing callstackid %d\n", stackId);
439 }
440
441 return stackId;
442}
443
444void hx::Telemetry::StackUpdate(StackFrame *pushed_frame)
445{

Callers

nothing calls this directly

Calls 2

atMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected