Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gdb-server-thread.h « gdb-server « wasm « debug « src « v8 « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f31756cbb38a0c325483e220b7b99c0b0a47d9f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2020 the V8 project 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 V8_DEBUG_WASM_GDB_SERVER_GDB_SERVER_THREAD_H_
#define V8_DEBUG_WASM_GDB_SERVER_GDB_SERVER_THREAD_H_

#include "src/base/platform/platform.h"
#include "src/base/platform/semaphore.h"
#include "src/debug/wasm/gdb-server/target.h"
#include "src/debug/wasm/gdb-server/transport.h"

namespace v8 {
namespace internal {
namespace wasm {
namespace gdb_server {

class GdbServer;

// class GdbServerThread spawns a thread where all communication with a debugger
// happens.
class GdbServerThread : public v8::base::Thread {
 public:
  explicit GdbServerThread(GdbServer* gdb_server);

  // base::Thread
  void Run() override;

  // Starts the GDB-server thread and waits Run() method is called on the new
  // thread and the initialization completes.
  bool StartAndInitialize();

  // Stops the GDB-server thread when the V8 process shuts down; gracefully
  // closes any active debugging session.
  void Stop();

 private:
  void CleanupThread();

  GdbServer* gdb_server_;

  // Used to block the caller on StartAndInitialize() waiting for the new thread
  // to have completed its initialization.
  // (Note that Thread::StartSynchronously() wouldn't work in this case because
  // it returns as soon as the new thread starts, but before Run() is called).
  base::Semaphore start_semaphore_;

  base::Mutex mutex_;
  // Protected by {mutex_}:
  std::unique_ptr<Transport> transport_;
  std::unique_ptr<Target> target_;

  DISALLOW_COPY_AND_ASSIGN(GdbServerThread);
};

}  // namespace gdb_server
}  // namespace wasm
}  // namespace internal
}  // namespace v8

#endif  // V8_DEBUG_WASM_GDB_SERVER_GDB_SERVER_THREAD_H_