summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Windows/LocalDebugDelegate.h
blob: d5a15006d004126a580e5c58d7049d1efc70f992 (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
//===-- LocalDebugDelegate.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_Plugins_Process_Windows_LocalDebugDelegate_H_
#define liblldb_Plugins_Process_Windows_LocalDebugDelegate_H_

#include "IDebugDelegate.h"
#include "lldb/lldb-forward.h"

class ProcessWindows;

namespace lldb_private
{
//----------------------------------------------------------------------
// LocalDebugDelegate
//
// LocalDebugDelegate creates a connection between a ProcessWindows and the
// debug driver.  This serves to decouple ProcessWindows from the debug driver.
// It would be possible to get a similar decoupling by just having
// ProcessWindows implement this interface directly.  There are two reasons why
// we don't do this:
//
// 1) In the future when we add support for local debugging through LLGS, and we
//    go through the Native*Protocol interface, it is likely we will need the
//    additional flexibility provided by this sort of adapter pattern.
// 2) LLDB holds a shared_ptr to the ProcessWindows, and our driver thread also
//    also needs access to it as well.  To avoid a race condition, we want to
//    make sure that we're also holding onto a shared_ptr.
//    lldb_private::Process supports enable_shared_from_this, but that gives us
//    a ProcessSP (which is exactly what we are trying to decouple from the
//    driver), so this adapter serves as a way to transparently hold the
//    ProcessSP while still keeping it decoupled from the driver.
//----------------------------------------------------------------------
class LocalDebugDelegate : public IDebugDelegate
{
  public:
    explicit LocalDebugDelegate::LocalDebugDelegate(lldb::ProcessSP process);

    virtual void OnExitProcess(uint32_t exit_code) override;
    virtual void OnDebuggerConnected() override;
    virtual ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override;
    virtual void OnCreateThread(const HostThread &thread) override;
    virtual void OnExitThread(const HostThread &thread) override;
    virtual void OnLoadDll() override;
    virtual void OnUnloadDll() override;
    virtual void OnDebugString(const std::string &message) override;
    virtual void OnDebuggerError(const Error &error, uint32_t type) override;

  private:
    lldb::ProcessSP m_process;
};
}

#endif
OpenPOWER on IntegriCloud