mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-30 10:31:07 +00:00
add lock for allocAddrMap
Signed-off-by: zyxzyx <zhangyixin19@huawei.com>
This commit is contained in:
parent
99ed570da6
commit
4f15046395
@ -160,6 +160,7 @@ private:
|
||||
int32_t pid_ {-1};
|
||||
std::mutex mtx_;
|
||||
bool isSaService_{false};
|
||||
std::mutex mtex_;
|
||||
};
|
||||
|
||||
#endif // STACK_PREPROCESS_H
|
@ -696,6 +696,7 @@ void StackPreprocess::SetHookData(RawStackPtr rawStack,
|
||||
inline bool StackPreprocess::SetFreeStatisticsData(uint64_t addr)
|
||||
{
|
||||
// through the addr lookup record
|
||||
std::lock_guard<std::mutex> guard(mtex_);
|
||||
auto addrIter = allocAddrMap_.find(addr);
|
||||
if (addrIter != allocAddrMap_.end()) {
|
||||
auto& record = addrIter->second.second;
|
||||
@ -717,6 +718,7 @@ inline void StackPreprocess::SetAllocStatisticsData(const RawStackPtr& rawStack,
|
||||
auto& record = recordIter->second;
|
||||
++record.applyCount;
|
||||
record.applySize += rawStack->stackConext->mallocSize;
|
||||
std::lock_guard<std::mutex> guard(mtex_);
|
||||
allocAddrMap_[(uint64_t)rawStack->stackConext->addr] =
|
||||
std::pair(rawStack->stackConext->mallocSize, &recordIter->second);
|
||||
statisticsPeriodData_[stackId] = &recordIter->second;
|
||||
@ -752,6 +754,7 @@ inline void StackPreprocess::SetAllocStatisticsData(const RawStackPtr& rawStack,
|
||||
}
|
||||
|
||||
auto [recordIter, stat] = recordStatisticsMap_.emplace(stackId, record);
|
||||
std::lock_guard<std::mutex> guard(mtex_);
|
||||
allocAddrMap_[(uint64_t)rawStack->stackConext->addr] =
|
||||
std::pair(rawStack->stackConext->mallocSize, &recordIter->second);
|
||||
statisticsPeriodData_[stackId] = &recordIter->second;
|
||||
|
Loading…
Reference in New Issue
Block a user