| Index: runtime/vm/dart_api_impl.cc
|
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
|
| index 32fc7bfa6c8ff835d0b6b9b0d5a27cfe12b1aa3f..33be4857eaebbdfa549eefd6adaa96f39a9e0c50 100644
|
| --- a/runtime/vm/dart_api_impl.cc
|
| +++ b/runtime/vm/dart_api_impl.cc
|
| @@ -387,6 +387,70 @@ DART_EXPORT Dart_Handle Dart_ErrorGetStacktrace(Dart_Handle handle) {
|
| }
|
| }
|
|
|
| +DART_EXPORT Dart_Handle Dart_StacktraceLength(Dart_Handle handle,
|
| + intptr_t* length) {
|
| + Isolate* isolate = Isolate::Current();
|
| + DARTSCOPE(isolate);
|
| + const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
|
| + if (obj.IsStacktrace()) {
|
| + const Stacktrace& stacktrace = Stacktrace::Cast(obj);
|
| + if (length != NULL) {
|
| + *length = stacktrace.VisibleLength();
|
| + }
|
| + return Api::Success();
|
| + } else {
|
| + return Api::NewError(
|
| + "%s expects argument 'handle' to be a stacktrace handle.",
|
| + CURRENT_FUNC);
|
| + }
|
| +}
|
| +
|
| +DART_EXPORT Dart_Handle Dart_StacktraceFrameInfo(
|
| + Dart_Handle handle,
|
| + intptr_t frame_index,
|
| + Dart_Handle* function_name,
|
| + Dart_Handle* script_url,
|
| + intptr_t* line_number,
|
| + intptr_t* col_number) {
|
| + Isolate* isolate = Isolate::Current();
|
| + DARTSCOPE(isolate);
|
| + Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
|
| + if (obj.IsStacktrace()) {
|
| + const Stacktrace& stacktrace = Stacktrace::Cast(obj);
|
| + String& internal_function_name = String::Handle();
|
| + String& internal_script_url = String::Handle();
|
| + intptr_t internal_line_number = 0;
|
| + intptr_t internal_col_num = 0;
|
| + bool in_bounds = stacktrace.VisibleFrameInfoAt(frame_index,
|
| + &internal_function_name,
|
| + &internal_script_url,
|
| + &internal_line_number,
|
| + &internal_col_num);
|
| + if (!in_bounds) {
|
| + return Api::NewError(
|
| + "%s: frame index was out of bounds (%" Pd ")",
|
| + CURRENT_FUNC, frame_index);
|
| + }
|
| + if (function_name != NULL) {
|
| + *function_name = Api::NewHandle(isolate, internal_function_name.raw());
|
| + }
|
| + if (script_url != NULL) {
|
| + *script_url = Api::NewHandle(isolate, internal_script_url.raw());
|
| + }
|
| + if (line_number != NULL) {
|
| + *line_number = internal_line_number;
|
| + }
|
| + if (col_number != NULL) {
|
| + *col_number = internal_col_num;
|
| + }
|
| + return Api::Success();
|
| + } else {
|
| + return Api::NewError(
|
| + "%s expects argument 'handle' to be a stacktrace handle.",
|
| + CURRENT_FUNC);
|
| + }
|
| +}
|
| +
|
|
|
| // TODO(turnidge): This clones Api::NewError. I need to use va_copy to
|
| // fix this but not sure if it available on all of our builds.
|
|
|