profile: Use BStackOrHeapArray to store the result arrays.
Otherwise with very large profile results we can overflow the stack.
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <StackOrHeapArray.h>
|
||||||
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
#include "ProfiledEntity.h"
|
#include "ProfiledEntity.h"
|
||||||
@@ -144,8 +145,8 @@ void
|
|||||||
BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
|
BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
|
||||||
{
|
{
|
||||||
// get hit images
|
// get hit images
|
||||||
BasicImageProfileResult* images[container->CountImages()];
|
BStackOrHeapArray<BasicImageProfileResult*, 128> images(container->CountImages());
|
||||||
int32 imageCount = GetHitImages(container, images);
|
int32 imageCount = GetHitImages(container, &*images);
|
||||||
|
|
||||||
// count symbols
|
// count symbols
|
||||||
int32 symbolCount = 0;
|
int32 symbolCount = 0;
|
||||||
@@ -156,7 +157,7 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find and sort the hit symbols
|
// find and sort the hit symbols
|
||||||
HitSymbol hitSymbols[symbolCount];
|
BStackOrHeapArray<HitSymbol, 128> hitSymbols(symbolCount);
|
||||||
int32 hitSymbolCount = 0;
|
int32 hitSymbolCount = 0;
|
||||||
|
|
||||||
for (int32 k = 0; k < imageCount; k++) {
|
for (int32 k = 0; k < imageCount; k++) {
|
||||||
@@ -177,7 +178,7 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hitSymbolCount > 1)
|
if (hitSymbolCount > 1)
|
||||||
std::sort(hitSymbols, hitSymbols + hitSymbolCount);
|
std::sort(&*hitSymbols, hitSymbols + hitSymbolCount);
|
||||||
|
|
||||||
int64 totalTicks = fTotalTicks;
|
int64 totalTicks = fTotalTicks;
|
||||||
const int64 missedTicks = fExpectedTicks - fTotalTicks;
|
const int64 missedTicks = fExpectedTicks - fTotalTicks;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <StackOrHeapArray.h>
|
||||||
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
#include "ProfiledEntity.h"
|
#include "ProfiledEntity.h"
|
||||||
@@ -221,8 +222,8 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
|
|||||||
fTotalTicks, fTotalTicks * fInterval);
|
fTotalTicks, fTotalTicks * fInterval);
|
||||||
|
|
||||||
// get hit images
|
// get hit images
|
||||||
CallgrindImageProfileResult* images[container->CountImages()];
|
BStackOrHeapArray<CallgrindImageProfileResult*, 128> images(container->CountImages());
|
||||||
int32 imageCount = GetHitImages(container, images);
|
int32 imageCount = GetHitImages(container, &*images);
|
||||||
|
|
||||||
for (int32 i = 0; i < imageCount; i++) {
|
for (int32 i = 0; i < imageCount; i++) {
|
||||||
CallgrindImageProfileResult* image = images[i];
|
CallgrindImageProfileResult* image = images[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user