1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5library fuchsia.crash;
6
7using fuchsia.mem;
8using zx;
9
10const uint32 MAX_COMPONENT_URL_LENGTH = 4096;
11const uint32 MAX_EXCEPTION_MSG_LENGTH = 4096;
12
13// Enumerates the languages with managed runtimes for which we might want a
14// specific handling of the thrown exceptions.
15enum ManagedRuntimeLanguage {
16    UNKNOWN_LANGUAGE = 0;
17    OTHER_LANGUAGE = 1;
18    DART = 2;
19};
20
21// Analyzes crashed processes, string exceptions from managed runtimes or
22// kernel panic crashlogs.
23[Discoverable, Layout = "Simple"]
24interface Analyzer {
25    // Requests that the crash analyzer handles the exception thrown by the
26    // given |thread| in |process|.
27    // This method is responsible for resuming or stopping the thread once the
28    // analyze is done.
29    //
30    // The behavior of this method varies depending on the implementation, but
31    // a typical implementation might print a crash dump to the system log or
32    // upload a crash report to a server.
33    //
34    // |exception_port| is the port on which the exception was delivered and
35    // can be passed to zx_task_resume_from_exception().
36    HandleNativeException(handle<process> process,
37                          handle<thread> thread,
38                          handle<port> exception_port)
39        -> (zx.status status);
40
41    // Requests that the crash analyzer handles the exception thrown in the
42    // managed runtime for the given |language|.
43    //
44    // The |language| might influenced how the exception message or stack trace
45    // are processed or parsed.
46    //
47    // The behavior of this method varies depending on the implementation, but
48    // a typical implementation might print the exception message and stack
49    // trace to the system log or upload a crash report to a server.
50    HandleManagedRuntimeException(ManagedRuntimeLanguage language,
51                                  string:MAX_COMPONENT_URL_LENGTH componentUrl,
52                                  string:MAX_EXCEPTION_MSG_LENGTH exception,
53                                  fuchsia.mem.Buffer stackTrace)
54        -> (zx.status status);
55
56    // Requests that the crash analyzer processes the kernel panic crash log.
57    //
58    // The behavior of this method varies depending on the implementation, but
59    // a typical implementation might print the crash log to the system log or
60    // upload a crash report to a server with the log as attachment.
61    ProcessKernelPanicCrashlog(fuchsia.mem.Buffer crashlog) -> (zx.status status);
62};
63