Skip to content

Instantly share code, notes, and snippets.

@luk- luk-/monitor.cc
Created Dec 17, 2013

Embed
What would you like to do?
/*
* Copyright (c) 2013, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
void LogStackTrace(Handle<Object> obj) {
try {
Local<Value> args[] = {};
Local<Value> frameCount = obj->Get(String::New("frameCount"));
Local<Function> frameCountFunc = Local<Function>::Cast(frameCount);
Local<Value> frameCountVal = frameCountFunc->Call(obj, 0, args);
Local<Number> frameCountNum = frameCountVal->ToNumber();
cout << "Stack Trace:" << endl;
int totalFrames = frameCountNum->Value();
for(int i = 0; i < totalFrames; i++) {
Local<Value> frameNumber[] = {Number::New(i)};
Local<Value> setSelectedFrame = obj->Get(String::New("setSelectedFrame"));
Local<Function> setSelectedFrameFunc = Local<Function>::Cast(setSelectedFrame);
setSelectedFrameFunc->Call(obj, 1, frameNumber);
Local<Value> frame = obj->Get(String::New("frame"));
Local<Function> frameFunc = Local<Function>::Cast(frame);
Local<Value> frameVal = frameFunc->Call(obj, 0, args);
Local<Object> frameObj = frameVal->ToObject();
Local<Value> frameToText = frameObj->Get(String::New("toText"));
Local<Function> frameToTextFunc = Local<Function>::Cast(frameToText);
Local<Value> frameToTextVal = frameToTextFunc->Call(frameObj, 0, args);
String::Utf8Value frameText(frameToTextVal);
cout << *frameText << endl;
}
} catch(exception e) {
cerr << "Error occured while logging stack trace:" << e.what() << endl;
}
}
@luk-

This comment has been minimized.

Copy link
Owner Author

luk- commented Dec 17, 2013

luke monitr $ node-gyp configure build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.9.1
gyp info using node@0.10.22 | darwin | x64
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/luke/windjammer/monitr/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/luke/.node-gyp/0.10.22/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/luke/.node-gyp/0.10.22',
gyp info spawn args   '-Dmodule_root_dir=/Users/luke/windjammer/monitr',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/monitor/src/monitor.o
../src/monitor.cc:564:63: error: use of undeclared identifier 'e'
        cerr << "Error occured while logging stack trace:" << e.what() << endl;
                                                              ^
1 error generated.
make: *** [Release/obj.target/monitor/src/monitor.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:256:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "configure" "build"
gyp ERR! cwd /Users/luke/windjammer/monitr
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.9.1
gyp ERR! not ok
luke monitr $
@luk-

This comment has been minimized.

Copy link
Owner Author

luk- commented Dec 17, 2013

This builds fine on Linux. For some reason OS X doesn't like e.what() in the catch block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.