blob: 13e28d5a3bc28a52cd1baafc5db5f3b2153ef046 [file] [log] [blame]
// Copyright 2021 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.
#include <gtest/gtest.h>
#include "src/developer/debug/zxdb/client/mock_remote_api.h"
#include "src/developer/debug/zxdb/debug_adapter/context_test.h"
namespace zxdb {
namespace {
using RequestStepInTest = DebugAdapterContextTest;
} // namespace
TEST_F(RequestStepInTest, StepInSuccess) {
InitializeDebugging();
InjectProcess(kProcessKoid);
// Run client to receive process started event.
RunClient();
InjectThread(kProcessKoid, kThreadKoid);
// Run client to receive threads started event.
RunClient();
constexpr uint64_t kAddress = 0x12345678;
constexpr uint64_t kStack = 0x7890;
// Notify of thread stop.
debug_ipc::NotifyException break_notification;
break_notification.type = debug_ipc::ExceptionType::kSoftwareBreakpoint;
break_notification.thread.id = {.process = kProcessKoid, .thread = kThreadKoid};
break_notification.thread.state = debug_ipc::ThreadRecord::State::kBlocked;
break_notification.thread.frames.emplace_back(kAddress, kStack, kStack);
InjectException(break_notification);
// Receive thread stopped event in client.
RunClient();
// Send request from the client.
dap::StepInRequest request = {};
request.threadId = kThreadKoid;
auto response = client().send(request);
// Read request and process it in server.
context().OnStreamReadable();
loop().RunUntilNoTasks();
EXPECT_EQ(1, mock_remote_api()->GetAndResetResumeCount());
// Run client to receive response.
RunClient();
auto got = response.get();
EXPECT_FALSE(got.error);
}
} // namespace zxdb