Revision f230a1cf deps/v8/src/platform-openbsd.cc

View differences:

deps/v8/src/platform-openbsd.cc
42 42
#include <sys/stat.h>   // open
43 43
#include <fcntl.h>      // open
44 44
#include <unistd.h>     // sysconf
45
#include <execinfo.h>   // backtrace, backtrace_symbols
46 45
#include <strings.h>    // index
47 46
#include <errno.h>
48 47
#include <stdarg.h>
......
51 50

  
52 51
#include "v8.h"
53 52

  
54
#include "platform-posix.h"
55 53
#include "platform.h"
56 54
#include "v8threads.h"
57 55
#include "vm-state-inl.h"
......
96 94
}
97 95

  
98 96

  
99
void OS::DumpBacktrace() {
100
  // Currently unsupported.
101
}
102

  
103

  
104 97
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
105 98
 public:
106 99
  PosixMemoryMappedFile(FILE* file, void* memory, int size)
......
231 224
}
232 225

  
233 226

  
234
int OS::StackWalk(Vector<OS::StackFrame> frames) {
235
  // backtrace is a glibc extension.
236
  int frames_size = frames.length();
237
  ScopedVector<void*> addresses(frames_size);
238

  
239
  int frames_count = backtrace(addresses.start(), frames_size);
240

  
241
  char** symbols = backtrace_symbols(addresses.start(), frames_count);
242
  if (symbols == NULL) {
243
    return kStackWalkError;
244
  }
245

  
246
  for (int i = 0; i < frames_count; i++) {
247
    frames[i].address = addresses[i];
248
    // Format a text representation of the frame based on the information
249
    // available.
250
    SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen),
251
             "%s",
252
             symbols[i]);
253
    // Make sure line termination is in place.
254
    frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
255
  }
256

  
257
  free(symbols);
258

  
259
  return frames_count;
260
}
261

  
262 227

  
263 228
// Constants used for mmap.
264 229
static const int kMmapFd = -1;

Also available in: Unified diff