DebugServer2
Loading...
Searching...
No Matches
ProcessLaunchMixin.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/GDBRemote/DummySessionDelegateImpl.h"
14#include "DebugServer2/Host/File.h"
15#include "DebugServer2/Host/Platform.h"
16#include "DebugServer2/Host/ProcessSpawner.h"
17#include "DebugServer2/Target/Process.h"
18#include "DebugServer2/Target/Thread.h"
19
20#include <utility>
21
23
24namespace ds2 {
25namespace GDBRemote {
26
27template <typename T> class ProcessLaunchMixin : public T {
28protected:
29 typedef std::map<std::string, std::string> EnvironmentMap;
30
31protected:
32 bool _disableASLR;
33 std::string _workingDirectory;
34 EnvironmentMap _environment;
35 std::string _stdFile[3];
36 StringCollection _arguments;
37 std::vector<ProcessId> _processList;
38 ErrorCode _lastLaunchResult;
39
40public:
41 template <typename... Args>
42 explicit ProcessLaunchMixin(Args &&... args)
43 : T(std::forward<Args>(args)...), _disableASLR(false),
44 _workingDirectory(Platform::GetWorkingDirectory()),
45 _lastLaunchResult(kSuccess) {}
46
47public:
48 ErrorCode onDisableASLR(Session &session, bool disable) override;
49 ErrorCode onSetArchitecture(Session &session,
50 std::string const &architecture) override;
51 ErrorCode onSetWorkingDirectory(Session &session,
52 std::string const &path) override;
53 ErrorCode onQueryWorkingDirectory(Session &session,
54 std::string &workingDir) const override;
55 ErrorCode onSetEnvironmentVariable(Session &session, std::string const &name,
56 std::string const &value) override;
57 ErrorCode onSetStdFile(Session &session, int fileno,
58 std::string const &path) override;
59 ErrorCode onSetProgramArguments(Session &session,
60 StringCollection const &args) override;
61 ErrorCode onQueryLaunchSuccess(Session &session,
62 ProcessId pid) const override;
63 ErrorCode onQueryProcessInfo(Session &session,
64 ProcessInfo &info) const override;
65 ErrorCode onTerminate(Session &session, ProcessThreadId const &ptid,
66 StopInfo &stop) override;
67
68private:
69 ErrorCode spawnProcess();
70 static bool isDebugServer(StringCollection const &args);
71};
72} // namespace GDBRemote
73} // namespace ds2
74
75#include "../Sources/GDBRemote/Mixins/ProcessLaunchMixin.hpp"
Definition ProcessLaunchMixin.h:27
Definition Session.h:22
Definition Platform.h:24
Definition Types.h:179
Definition Types.h:23
Definition Types.h:38