Skip to content

Commit

Permalink
Save address in alloc tracking snapshots (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme authored Aug 26, 2020
1 parent 421c667 commit fc4ef96
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/services/alloc/AllocService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,20 @@ class AllocService
Channel* chn,
cali::Node* label_node,
const Variant& v_size,
const Variant& v_uid) {
const Variant& v_uid,
const Variant& v_addr) {
cali_id_t attr[] = {
alloc_total_size_attr.id(),
alloc_uid_attr.id()
alloc_uid_attr.id(),
alloc_addr_attr.id()
};
Variant data[] = {
v_size,
v_uid
v_uid,
v_addr
};

SnapshotRecord trigger_info(1, &label_node, 2, attr, data);
SnapshotRecord trigger_info(1, &label_node, 3, attr, data);
c->push_snapshot(chn, &trigger_info);
}

Expand Down Expand Up @@ -199,7 +202,10 @@ class AllocService
}

if (g_track_allocations)
track_mem_snapshot(c, chn, info.alloc_label_node, Variant(static_cast<int>(total_size)), info.v_uid);
track_mem_snapshot(c, chn, info.alloc_label_node,
Variant(static_cast<int>(total_size)),
info.v_uid,
Variant(CALI_TYPE_ADDR, &ptr, sizeof(void*)));

{
std::lock_guard<std::mutex>
Expand Down Expand Up @@ -242,7 +248,10 @@ class AllocService
}

if (g_track_allocations)
track_mem_snapshot(c, chn, info.free_label_node, Variant(-static_cast<int>(info.total_size)), info.v_uid);
track_mem_snapshot(c, chn, info.free_label_node,
Variant(-static_cast<int>(info.total_size)),
info.v_uid,
Variant(CALI_TYPE_ADDR, &ptr, sizeof(void*)));

{
std::lock_guard<std::mutex>
Expand Down
9 changes: 9 additions & 0 deletions test/ci_app_tests/test_allocservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def test_alloc(self):

# test allocated.0

self.assertTrue(cat.has_snapshot_with_keys(
snapshots, { 'mem.alloc', 'alloc.uid', 'alloc.address', 'alloc.total_size' }))
self.assertTrue(cat.has_snapshot_with_keys(
snapshots, { 'mem.free', 'alloc.uid', 'alloc.address', 'alloc.total_size' }))
self.assertTrue(cat.has_snapshot_with_attributes(
snapshots, { 'mem.alloc': 'test_alloc_A' }))
self.assertTrue(cat.has_snapshot_with_attributes(
snapshots, { 'mem.free': 'test_alloc_A' }))

self.assertTrue(cat.has_snapshot_with_keys(
snapshots, { 'test_alloc.allocated.0', 'ptr_in', 'ptr_out' }))

Expand Down

0 comments on commit fc4ef96

Please sign in to comment.