Skip to content

Commit bf64859

Browse files
committed
[SharedCache] Expose cache entry name in the API
Allows us to display the user friendly name of the cache entry in the triage view
1 parent ea47d4c commit bf64859

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

view/sharedcache/api/sharedcache.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ BNSharedCacheEntry EntryToApi(const CacheEntry &entry)
7878
{
7979
BNSharedCacheEntry apiEntry {};
8080
apiEntry.path = BNAllocString(entry.path.c_str());
81+
apiEntry.name = BNAllocString(entry.name.c_str());
8182
apiEntry.entryType = entry.entryType;
8283
const auto &mappings = entry.mappings;
8384
apiEntry.mappingCount = mappings.size();
@@ -92,6 +93,7 @@ CacheEntry EntryFromApi(BNSharedCacheEntry apiEntry)
9293
{
9394
CacheEntry entry {};
9495
entry.path = apiEntry.path;
96+
entry.name = apiEntry.name;
9597
entry.entryType = apiEntry.entryType;
9698
entry.mappings.reserve(apiEntry.mappingCount);
9799
for (size_t i = 0; i < apiEntry.mappingCount; i++)

view/sharedcache/api/sharedcacheapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ namespace SharedCacheAPI {
278278
struct CacheEntry
279279
{
280280
std::string path;
281+
std::string name;
281282
BNSharedCacheEntryType entryType;
282283
std::vector<CacheMappingInfo> mappings;
283284
};

view/sharedcache/api/sharedcachecore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ extern "C"
9797

9898
typedef struct BNSharedCacheEntry {
9999
char* path;
100+
char* name;
100101
BNSharedCacheEntryType entryType;
101102
size_t mappingCount;
102103
BNSharedCacheMappingInfo* mappings;

view/sharedcache/core/ffi.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ BNSharedCacheEntry EntryToApi(const CacheEntry& entry)
134134
{
135135
BNSharedCacheEntry apiEntry;
136136
apiEntry.path = BNAllocString(entry.GetFilePath().c_str());
137+
apiEntry.name = BNAllocString(entry.GetFileName().c_str());
137138
apiEntry.entryType = EntryTypeToApi(entry.GetType());
138139
const auto& mappings = entry.GetMappings();
139140
apiEntry.mappingCount = mappings.size();
@@ -408,15 +409,15 @@ extern "C"
408409
const auto& entries = controller->object->GetCache().GetEntries();
409410
*count = entries.size();
410411
BNSharedCacheEntry* apiEntries = new BNSharedCacheEntry[*count];
411-
size_t idx = 0;
412-
for (const auto& [_, entry] : entries)
413-
apiEntries[idx++] = EntryToApi(entry);
412+
for (size_t i = 0; i < *count; i++)
413+
apiEntries[i] = EntryToApi(entries[i]);
414414
return apiEntries;
415415
}
416416

417417
void BNSharedCacheFreeEntry(BNSharedCacheEntry entry)
418418
{
419419
BNFreeString(entry.path);
420+
BNFreeString(entry.name);
420421
delete[] entry.mappings;
421422
}
422423

view/sharedcache/ui/dsctriage.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ void DSCTriageView::initCacheInfoTables()
355355
auto cacheInfoSubwidget = new QWidget;
356356

357357
auto mappingTable = new FilterableTableView(cacheInfoSubwidget);
358-
m_mappingModel = new QStandardItemModel(0, 4, mappingTable);
359-
m_mappingModel->setHorizontalHeaderLabels({"Address", "Size", "File Address", "File Path"});
358+
m_mappingModel = new QStandardItemModel(0, 5, mappingTable);
359+
m_mappingModel->setHorizontalHeaderLabels({"Address", "Size", "File Address", "File Name", "File Path"});
360360

361361
// Apply custom column styling
362362
mappingTable->setItemDelegateForColumn(0, new AddressColorDelegate(mappingTable));
@@ -366,7 +366,8 @@ void DSCTriageView::initCacheInfoTables()
366366
mappingTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
367367
mappingTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
368368
mappingTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
369-
mappingTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
369+
mappingTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
370+
mappingTable->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
370371

371372
mappingTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
372373

@@ -527,6 +528,7 @@ void DSCTriageView::RefreshData()
527528
new QStandardItem(QString("0x%1").arg(mapping.vmAddress, 0, 16)),
528529
new QStandardItem(QString("0x%1").arg(mapping.size, 0, 16)),
529530
new QStandardItem(QString("0x%1").arg(mapping.fileOffset, 0, 16)),
531+
new QStandardItem(QString::fromStdString(entry.name)),
530532
new QStandardItem(QString::fromStdString(entry.path))
531533
});
532534
}

0 commit comments

Comments
 (0)