dbms: tiny improvement [#METR-10240].

This commit is contained in:
Alexey Milovidov 2014-03-07 07:58:13 +04:00
parent b04e4ccf08
commit cd2e6663a5
2 changed files with 7 additions and 6 deletions

View File

@ -3,6 +3,8 @@
#include <string>
#include <vector>
#define DBMS_STACK_TRACE_MAX_DEPTH 32
namespace DB
{
@ -19,8 +21,8 @@ public:
private:
typedef void* Frame;
typedef std::vector<Frame> Frames;
Frames frames;
Frame frames[DBMS_STACK_TRACE_MAX_DEPTH];
size_t frames_size;
};
}

View File

@ -16,13 +16,12 @@ namespace DB
StackTrace::StackTrace()
{
frames.resize(DBMS_STACK_TRACE_MAX_DEPTH);
frames.resize(backtrace(&frames[0], frames.size()));
frames_size = backtrace(frames, DBMS_STACK_TRACE_MAX_DEPTH);
}
std::string StackTrace::toString() const
{
char ** symbols = backtrace_symbols(&frames[0], frames.size());
char ** symbols = backtrace_symbols(frames, frames_size);
std::stringstream res;
if (!symbols)
@ -30,7 +29,7 @@ std::string StackTrace::toString() const
try
{
for (size_t i = 0, size = frames.size(); i < size; ++i)
for (size_t i = 0, size = frames_size; i < size; ++i)
{
/// Делаем demangling имён. Имя находится в скобках, до символа '+'.