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

Side by Side Diff: include/v8.h

Issue 1694011: Adds C++ API for retrieving a stack trace without running JavaScript (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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 | include/v8-profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 class Function; 119 class Function;
120 class Date; 120 class Date;
121 class ImplementationUtilities; 121 class ImplementationUtilities;
122 class Signature; 122 class Signature;
123 template <class T> class Handle; 123 template <class T> class Handle;
124 template <class T> class Local; 124 template <class T> class Local;
125 template <class T> class Persistent; 125 template <class T> class Persistent;
126 class FunctionTemplate; 126 class FunctionTemplate;
127 class ObjectTemplate; 127 class ObjectTemplate;
128 class Data; 128 class Data;
129 class StackTrace;
130 class StackFrame;
129 131
130 namespace internal { 132 namespace internal {
131 133
132 class Arguments; 134 class Arguments;
133 class Object; 135 class Object;
134 class Top; 136 class Top;
135 137
136 } 138 }
137 139
138 140
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 int GetStartColumn() const; 686 int GetStartColumn() const;
685 687
686 /** 688 /**
687 * Returns the index within the line of the last character where 689 * Returns the index within the line of the last character where
688 * the error occurred. 690 * the error occurred.
689 */ 691 */
690 int GetEndColumn() const; 692 int GetEndColumn() const;
691 693
692 // TODO(1245381): Print to a string instead of on a FILE. 694 // TODO(1245381): Print to a string instead of on a FILE.
693 static void PrintCurrentStackTrace(FILE* out); 695 static void PrintCurrentStackTrace(FILE* out);
696
697 static const int kNoLineNumberInfo = 0;
698 static const int kNoColumnInfo = 0;
699 };
700
701
702 /**
703 * Representation of a JavaScript stack trace. The information collected is a
704 * snapshot of the execution stack and the information remains valid after
705 * execution continues.
706 */
707 class V8EXPORT StackTrace {
708 public:
709 /**
710 * Flags that determine what information is placed captured for each
711 * StackFrame when grabbing the current stack trace.
712 */
713 enum StackTraceOptions {
714 kLineNumber = 1,
715 kColumnOffset = 1 << 1 | kLineNumber,
716 kScriptName = 1 << 2,
717 kFunctionName = 1 << 3,
718 kIsEval = 1 << 4,
719 kIsConstructor = 1 << 5,
720 kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
721 kDetailed = kOverview | kIsEval | kIsConstructor
722 };
723
724 /**
725 * Returns a StackFrame at a particular index.
726 */
727 Local<StackFrame> GetFrame(uint32_t index) const;
728
729 /**
730 * Returns the number of StackFrames.
731 */
732 int GetFrameCount() const;
733
734 /**
735 * Returns StackTrace as a v8::Array that contains StackFrame objects.
736 */
737 Local<Array> AsArray();
738
739 /**
740 * Grab a snapshot of the the current JavaScript execution stack.
741 *
742 * \param frame_limit The maximum number of stack frames we want to capture.
743 * \param options Enumerates the set of things we will capture for each
744 * StackFrame.
745 */
746 static Local<StackTrace> CurrentStackTrace(
747 int frame_limit,
748 StackTraceOptions options = kOverview);
749 };
750
751
752 /**
753 * A single JavaScript stack frame.
754 */
755 class V8EXPORT StackFrame {
756 public:
757 /**
758 * Returns the number, 1-based, of the line for the associate function call.
759 * This method will return Message::kNoLineNumberInfo if it is unable to
760 * retrieve the line number, or if kLineNumber was not passed as an option
761 * when capturing the StackTrace.
762 */
763 int GetLineNumber() const;
764
765 /**
766 * Returns the 1-based column offset on the line for the associated function
767 * call.
768 * This method will return Message::kNoColumnInfo if it is unable to retrieve
769 * the column number, or if kColumnOffset was not passed as an option when
770 * capturing the StackTrace.
771 */
772 int GetColumn() const;
773
774 /**
775 * Returns the name of the resource that contains the script for the
776 * function for this StackFrame.
777 */
778 Local<String> GetScriptName() const;
779
780 /**
781 * Returns the name of the function associated with this stack frame.
782 */
783 Local<String> GetFunctionName() const;
784
785 /**
786 * Returns whether or not the associated function is compiled via a call to
787 * eval().
788 */
789 bool IsEval() const;
790
791 /**
792 * Returns whther or not the associated function is called as a
793 * constructor via "new".
794 */
795 bool IsConstructor() const;
694 }; 796 };
695 797
696 798
697 // --- V a l u e --- 799 // --- V a l u e ---
698 800
699 801
700 /** 802 /**
701 * The superclass of all JavaScript values and objects. 803 * The superclass of all JavaScript values and objects.
702 */ 804 */
703 class V8EXPORT Value : public Data { 805 class V8EXPORT Value : public Data {
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 3508
3407 } // namespace v8 3509 } // namespace v8
3408 3510
3409 3511
3410 #undef V8EXPORT 3512 #undef V8EXPORT
3411 #undef V8EXPORT_INLINE 3513 #undef V8EXPORT_INLINE
3412 #undef TYPE_CHECK 3514 #undef TYPE_CHECK
3413 3515
3414 3516
3415 #endif // V8_H_ 3517 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | include/v8-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698