Summary: This patch is the MVP version of importing the std module into the expression parser to improve C++ debugging. What happens in this patch is that we inject a `@import std` into our expression source code. We also modify our internal Clang instance for parsing this expression to work with modules and debug info at the same time (which is the main change in terms of LOC). We implicitly build the `std` module on the first use. The C++ include paths for building are extracted from the debug info, which means that this currently only works if the program is compiled with `-glldb -fmodules` and uses the std module. The C include paths are currently specified by LLDB. I enabled the tests currently only for libc++ and Linux because I could test this locally. I'll enable the tests for other platforms once this has landed and doesn't break any bots (and I implemented the platform-specific C include paths for them). With this patch we can now: * Build a libc++ as a module and import it into the expression parser. * Read from the module while also referencing declarations from the debug info. E.g. `std::abs(local_variable)`. What doesn't work (yet): * Merging debug info and C++ module declarations. E.g. `std::vector<CustomClass>` doesn't work. * Pretty much anything that involves the ASTImporter and templated code. As the ASTImporter is used for saving the result declaration, this means that we can't call yet any function that returns a non-trivial type. * Use libstdc++ for this, as it requires multiple include paths and Clang only emits one include path per module. Also libstdc++ doesn't support Clang modules without patches. Reviewers: aprantl, jingham, shafik, friss, davide, serge-sans-paille Reviewed By: aprantl Subscribers: labath, mgorny, abidh, jdoerfert, lldb-commits Tags: #c_modules_in_lldb, #lldb Differential Revision: https://reviews.llvm.org/D58125 llvm-svn: 355939
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
//===-- PlatformLinux.h -----------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef liblldb_PlatformLinux_h_
|
|
#define liblldb_PlatformLinux_h_
|
|
|
|
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
|
|
|
|
namespace lldb_private {
|
|
namespace platform_linux {
|
|
|
|
class PlatformLinux : public PlatformPOSIX {
|
|
public:
|
|
PlatformLinux(bool is_host);
|
|
|
|
~PlatformLinux() override;
|
|
|
|
static void Initialize();
|
|
|
|
static void Terminate();
|
|
|
|
//------------------------------------------------------------
|
|
// lldb_private::PluginInterface functions
|
|
//------------------------------------------------------------
|
|
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
|
|
|
|
static ConstString GetPluginNameStatic(bool is_host);
|
|
|
|
static const char *GetPluginDescriptionStatic(bool is_host);
|
|
|
|
ConstString GetPluginName() override;
|
|
|
|
uint32_t GetPluginVersion() override { return 1; }
|
|
|
|
//------------------------------------------------------------
|
|
// lldb_private::Platform functions
|
|
//------------------------------------------------------------
|
|
const char *GetDescription() override {
|
|
return GetPluginDescriptionStatic(IsHost());
|
|
}
|
|
|
|
void GetStatus(Stream &strm) override;
|
|
|
|
bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
|
|
|
|
int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
|
|
|
|
bool CanDebugProcess() override;
|
|
|
|
std::vector<std::string>
|
|
GetSystemIncludeDirectories(lldb::LanguageType lang) override;
|
|
|
|
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
|
|
Debugger &debugger, Target *target,
|
|
Status &error) override;
|
|
|
|
void CalculateTrapHandlerSymbolNames() override;
|
|
|
|
MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr,
|
|
lldb::addr_t length, unsigned prot,
|
|
unsigned flags, lldb::addr_t fd,
|
|
lldb::addr_t offset) override;
|
|
|
|
private:
|
|
DISALLOW_COPY_AND_ASSIGN(PlatformLinux);
|
|
};
|
|
|
|
} // namespace platform_linux
|
|
} // namespace lldb_private
|
|
|
|
#endif // liblldb_PlatformLinux_h_
|