aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Target/ProcessInfo.h
blob: 0570cfc9865101b24d828f0492d23a68e56b2a23 (plain) (blame)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_ProcessInfo_h_
#define liblldb_ProcessInfo_h_

// LLDB headers
#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Interpreter/Args.h"

namespace lldb_private
{
    //----------------------------------------------------------------------
    // ProcessInfo
    //
    // A base class for information for a process. This can be used to fill
    // out information for a process prior to launching it, or it can be
    // used for an instance of a process and can be filled in with the
    // existing values for that process.
    //----------------------------------------------------------------------
    class ProcessInfo
    {
    public:
        ProcessInfo ();

        ProcessInfo (const char *name,
                     const ArchSpec &arch,
                     lldb::pid_t pid);

        void
        Clear ();

        const char *
        GetName() const;

        size_t
        GetNameLength() const;

        FileSpec &
        GetExecutableFile ()
        {
            return m_executable;
        }

        void
        SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_first_arg);

        const FileSpec &
        GetExecutableFile () const
        {
            return m_executable;
        }

        uint32_t
        GetUserID() const
        {
            return m_uid;
        }

        uint32_t
        GetGroupID() const
        {
            return m_gid;
        }

        bool
        UserIDIsValid () const
        {
            return m_uid != UINT32_MAX;
        }

        bool
        GroupIDIsValid () const
        {
            return m_gid != UINT32_MAX;
        }

        void
        SetUserID (uint32_t uid)
        {
            m_uid = uid;
        }

        void
        SetGroupID (uint32_t gid)
        {
            m_gid = gid;
        }

        ArchSpec &
        GetArchitecture ()
        {
            return m_arch;
        }

        const ArchSpec &
        GetArchitecture () const
        {
            return m_arch;
        }

        void
        SetArchitecture (ArchSpec arch)
        {
            m_arch = arch;
        }

        lldb::pid_t
        GetProcessID () const
        {
            return m_pid;
        }

        void
        SetProcessID (lldb::pid_t pid)
        {
            m_pid = pid;
        }

        bool
        ProcessIDIsValid() const
        {
            return m_pid != LLDB_INVALID_PROCESS_ID;
        }

        void
        Dump (Stream &s, Platform *platform) const;

        Args &
        GetArguments ()
        {
            return m_arguments;
        }

        const Args &
        GetArguments () const
        {
            return m_arguments;
        }

        const char *
        GetArg0 () const;

        void
        SetArg0 (const char *arg);

        void
        SetArguments (const Args& args, bool first_arg_is_executable);

        void
        SetArguments (char const **argv, bool first_arg_is_executable);

        Args &
        GetEnvironmentEntries ()
        {
            return m_environment;
        }

        const Args &
        GetEnvironmentEntries () const
        {
            return m_environment;
        }

    protected:
        FileSpec m_executable;
        std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
        // Not all process plug-ins support specifying an argv[0]
        // that differs from the resolved platform executable
        // (which is in m_executable)
        Args m_arguments;   // All program arguments except argv[0]
        Args m_environment;
        uint32_t m_uid;
        uint32_t m_gid;
        ArchSpec m_arch;
        lldb::pid_t m_pid;
    };
}

#endif // #ifndef liblldb_ProcessInfo_h_