blob: 0faadbeaeb89c048cf011801a3d61977bed073bf [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_DEVELOPER_DEBUG_DEBUG_AGENT_ZIRCON_LIMBO_PROVIDER_H_
#define SRC_DEVELOPER_DEBUG_DEBUG_AGENT_ZIRCON_LIMBO_PROVIDER_H_
#include <fidl/fuchsia.exception/cpp/fidl.h>
#include <fidl/fuchsia.io/cpp/fidl.h>
#include <map>
#include <vector>
#include "src/developer/debug/debug_agent/limbo_provider.h"
namespace debug_agent {
// In charge of providing access to the ProcessLimbo.
//
// Fuchsia can be configured to keep processes that have excepted in a suspension state, called
// Limbo. This provides the possibility for debuggers to attach to those process way after the
// exception occurred. We call this process Just In Time Debugging (JITD).
class ZirconLimboProvider final : public LimboProvider {
public:
explicit ZirconLimboProvider(fidl::UnownedClientEnd<fuchsia_io::Directory> svc_dir);
~ZirconLimboProvider() override = default;
// LimboProvider implementation.
bool Valid() const override { return valid_; }
bool IsProcessInLimbo(zx_koid_t process_koid) const override;
const RecordMap& GetLimboRecords() const override { return limbo_; }
fit::result<debug::Status, RetrievedException> RetrieveException(zx_koid_t process_koid) override;
debug::Status ReleaseProcess(zx_koid_t process_koid) override;
private:
void WatchActive();
void WatchLimbo();
bool valid_ = false;
// Because the Process Limbo uses hanging gets (async callbacks) and this class exposes a
// synchronous inteface, we need to keep track of the current state in order to be able to
// return it immediatelly.
RecordMap limbo_;
bool is_limbo_active_ = false;
fidl::UnownedClientEnd<fuchsia_io::Directory> svc_dir_;
fidl::Client<fuchsia_exception::ProcessLimbo> connection_;
};
} // namespace debug_agent
#endif // SRC_DEVELOPER_DEBUG_DEBUG_AGENT_ZIRCON_LIMBO_PROVIDER_H_