Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: src/platform-macos.cc

Issue 18431004: Common implementation of OS::DumpBacktrace() and OS::StackWalk(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include <mach/task.h> 46 #include <mach/task.h>
47 #include <mach/vm_statistics.h> 47 #include <mach/vm_statistics.h>
48 #include <sys/time.h> 48 #include <sys/time.h>
49 #include <sys/resource.h> 49 #include <sys/resource.h>
50 #include <sys/types.h> 50 #include <sys/types.h>
51 #include <sys/sysctl.h> 51 #include <sys/sysctl.h>
52 #include <stdarg.h> 52 #include <stdarg.h>
53 #include <stdlib.h> 53 #include <stdlib.h>
54 #include <string.h> 54 #include <string.h>
55 #include <errno.h> 55 #include <errno.h>
56 #include <cxxabi.h>
56 57
57 #undef MAP_TYPE 58 #undef MAP_TYPE
58 59
59 #include "v8.h" 60 #include "v8.h"
60 61
61 #include "platform-posix.h" 62 #include "platform-posix.h"
62 #include "platform.h" 63 #include "platform.h"
63 #include "simulator.h" 64 #include "simulator.h"
64 #include "vm-state-inl.h" 65 #include "vm-state-inl.h"
65 66
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 abort(); 183 abort();
183 } 184 }
184 185
185 186
186 void OS::DebugBreak() { 187 void OS::DebugBreak() {
187 asm("int $3"); 188 asm("int $3");
188 } 189 }
189 190
190 191
191 void OS::DumpBacktrace() { 192 void OS::DumpBacktrace() {
192 // Currently unsupported. 193 // If weak link to execinfo lib has failed, ie because we are on 10.4, abort.
194 if (backtrace == NULL) return;
Dmitry Lomov (no reviews) 2013/07/12 07:46:02 This code looks a copy of the code in platform-lin
Benedikt Meurer 2013/07/12 07:54:28 It's basically a copy, yes. Where would we put thi
195 void* trace[100];
196 int size = backtrace(trace, ARRAY_SIZE(trace));
197 char** symbols = backtrace_symbols(trace, size);
198 fprintf(stderr, "\n==== C stack trace ===============================\n\n");
199 if (size == 0) {
200 fprintf(stderr, "(empty)\n");
201 } else if (symbols == NULL) {
202 fprintf(stderr, "(no symbols)\n");
203 } else {
204 for (int i = 1; i < size; ++i) {
205 fprintf(stderr, "%2d: ", i);
206 char mangled[201];
207 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT
208 int status;
209 size_t length;
210 char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
211 fprintf(stderr, "%s\n", demangled ? demangled : mangled);
212 free(demangled);
213 } else {
214 fprintf(stderr, "??\n");
215 }
216 }
217 }
218 fflush(stderr);
219 free(symbols);
193 } 220 }
194 221
195 222
196 class PosixMemoryMappedFile : public OS::MemoryMappedFile { 223 class PosixMemoryMappedFile : public OS::MemoryMappedFile {
197 public: 224 public:
198 PosixMemoryMappedFile(FILE* file, void* memory, int size) 225 PosixMemoryMappedFile(FILE* file, void* memory, int size)
199 : file_(file), memory_(memory), size_(size) { } 226 : file_(file), memory_(memory), size_(size) { }
200 virtual ~PosixMemoryMappedFile(); 227 virtual ~PosixMemoryMappedFile();
201 virtual void* memory() { return memory_; } 228 virtual void* memory() { return memory_; }
202 virtual int size() { return size_; } 229 virtual int size() { return size_; }
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 limit_mutex = CreateMutex(); 733 limit_mutex = CreateMutex();
707 } 734 }
708 735
709 736
710 void OS::TearDown() { 737 void OS::TearDown() {
711 delete limit_mutex; 738 delete limit_mutex;
712 } 739 }
713 740
714 741
715 } } // namespace v8::internal 742 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698