Skip to content

Commit

Permalink
Merged main:6edc3fe598af into amd-gfx:d607423df52a
Browse files Browse the repository at this point in the history
Local branch amd-gfx d607423 Merged main:45ef053bd709 into amd-gfx:074de8ae48d3
Remote branch main 6edc3fe [Orc] Fix OrcV2Examples after D94690
  • Loading branch information
Sw authored and Sw committed Jan 15, 2021
2 parents d607423 + 6edc3fe commit aec8dbc
Show file tree
Hide file tree
Showing 29 changed files with 431 additions and 252 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ pythonenv*
/clang/utils/analyzer/projects/*/PatchedSource
/clang/utils/analyzer/projects/*/ScanBuildResults
/clang/utils/analyzer/projects/*/RefScanBuildResults
# automodapi puts generated documentation files here.
/lldb/docs/python_api/
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/FindSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ class DocumentOutline {
enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };

void traverseDecl(Decl *D, std::vector<DocumentSymbol> &Results) {
// Skip symbols which do not originate from the main file.
if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
return;

if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D)) {
// TemplatedDecl might be null, e.g. concepts.
if (auto *TD = Templ->getTemplatedDecl())
Expand Down
4 changes: 3 additions & 1 deletion clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,13 @@ TEST(DocumentSymbols, InHeaderFile) {
}
)cpp";
TU.Code = R"cpp(
int i; // declaration to finish preamble
#include "bar.h"
int test() {
}
)cpp";
EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
EXPECT_THAT(getSymbols(TU.build()),
ElementsAre(WithName("i"), WithName("test")));
}

TEST(DocumentSymbols, Template) {
Expand Down
71 changes: 25 additions & 46 deletions lldb/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,39 @@ if(DOXYGEN_FOUND)
)
endif()

if (LLDB_ENABLE_PYTHON)
find_program(EPYDOC_EXECUTABLE NAMES epydoc epydoc.py)
if(EPYDOC_EXECUTABLE)
message(STATUS "Found epydoc - ${EPYDOC_EXECUTABLE}")

find_program(DOT_EXECUTABLE dot)
if(DOT_EXECUTABLE)
set(EPYDOC_OPTIONS ${EPYDOC_OPTIONS} --graph all --dotpath ${DOT_EXECUTABLE})
message(STATUS "Found dot - ${DOT_EXECUTABLE}")
endif()
if (LLVM_ENABLE_SPHINX)
include(AddSphinxTarget)
endif()

# Pretend to make a python package so that we can generate the reference.
# Because we don't build liblldb, epydoc will complain that the import of
# _lldb.so failed, but that doesn't prevent it from generating the docs.
if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND)
if (${SPHINX_OUTPUT_HTML})
# Pretend that the SWIG generated API is a Python package.
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lldb)
get_target_property(lldb_bindings_dir swig_wrapper_python BINARY_DIR)
add_custom_target(lldb-python-doc-package
COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_bindings_dir}/lldb.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py"
COMMENT "Copying lldb.py to pretend package.")
COMMENT "Copying lldb.py to pretend its a Python package.")
add_dependencies(lldb-python-doc-package swig_wrapper_python)

set(DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
file(MAKE_DIRECTORY "${DOC_DIR}")
add_custom_target(lldb-python-doc
${EPYDOC_EXECUTABLE}
--html
lldb
-o ${CMAKE_CURRENT_BINARY_DIR}/python_reference
--name "LLDB python API"
--url "http://lldb.llvm.org"
${EPYDOC_OPTIONS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating LLDB Python API reference with epydoc" VERBATIM
)
add_dependencies(lldb-python-doc swig_wrapper_python lldb-python-doc-package)
else()
message(STATUS "Could NOT find epydoc")
# FIXME: Don't treat Sphinx warnings as errors. The files generated by
# automodapi are full of warnings (partly caused by SWIG, our documentation
# and probably also automodapi itself), so those warnings need to be fixed
# first before we can turn this on.
set(SPHINX_WARNINGS_AS_ERRORS Off)

# The sphinx config needs to know where the generated LLDB Python module is.
# There is no way to pass a variable into our sphinx config, so just pass
# the path to the module via the LLDB_SWIG_MODULE environment variable.
add_sphinx_target(html lldb ENV_VARS "LLDB_SWIG_MODULE=${CMAKE_CURRENT_BINARY_DIR}")
# Sphinx does not reliably update the custom CSS files, so force
# a clean rebuild of the documentation every time.
add_custom_target(clean-lldb-html COMMAND "${CMAKE_COMMAND}" -E
remove_directory ${CMAKE_CURRENT_BINARY_DIR}/html)
add_dependencies(docs-lldb-html swig_wrapper_python
lldb-python-doc-package clean-lldb-html)
endif()
endif ()

if (LLVM_ENABLE_SPHINX)
include(AddSphinxTarget)
if (SPHINX_FOUND)
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html lldb)
# Sphinx does not reliably update the custom CSS files, so force
# a clean rebuild of the documentation every time.
add_custom_target(clean-lldb-html COMMAND "${CMAKE_COMMAND}" -E
remove_directory ${CMAKE_CURRENT_BINARY_DIR}/html)
add_dependencies(docs-lldb-html clean-lldb-html)
endif()

if (${SPHINX_OUTPUT_MAN})
add_sphinx_target(man lldb)
endif()
if (${SPHINX_OUTPUT_MAN})
add_sphinx_target(man lldb)
endif()
endif()
9 changes: 9 additions & 0 deletions lldb/docs/_lldb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from unittest.mock import Mock
import sys
import types

# This package acts as a mock implementation of the native _lldb module so
# that generating the LLDB documentation doesn't actually require building all
# of LLDB.
module_name = '_lldb'
sys.modules[module_name] = Mock()
15 changes: 13 additions & 2 deletions lldb/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))

# Add the current directory that contains the mock _lldb native module which
# is imported by the `lldb` module.
sys.path.insert(0, os.path.abspath("."))
# Add the build directory that contains the `lldb` module. LLDB_SWIG_MODULE is
# set by CMake.
sys.path.insert(0, os.getenv("LLDB_SWIG_MODULE"))

# Put the generated Python API documentation in the 'python_api' folder. This
# also defines the URL these files will have in the generated website.
automodapi_toctreedirnm = 'python_api'

# -- General configuration -----------------------------------------------------

Expand All @@ -27,7 +37,8 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx',
'sphinx_automodapi.automodapi']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
2 changes: 1 addition & 1 deletion lldb/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ interesting areas to contribute to lldb.
:maxdepth: 1
:caption: Reference

Public Python API <https://lldb.llvm.org/python_reference/index.html>
Public Python API <python_api>
Public C++ API <https://lldb.llvm.org/cpp_reference/namespacelldb.html>
Private C++ API <https://lldb.llvm.org/cpp_reference/index.html>
Man Page <man/lldb>
Expand Down
98 changes: 98 additions & 0 deletions lldb/docs/python_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
LLDB Python API
================================

..
The long list of "skip" filters out several global functions that are
generated by SWIG (but which are not useful as they are only the
backend for their respective static functions in the classes).
Without this list
.. automodapi:: lldb
:no-inheritance-diagram:
:skip: SBBreakpoint_EventIsBreakpointEvent
:skip: SBBreakpoint_GetBreakpointEventTypeFromEvent
:skip: SBBreakpoint_GetBreakpointFromEvent
:skip: SBBreakpoint_GetBreakpointLocationAtIndexFromEvent
:skip: SBBreakpoint_GetNumBreakpointLocationsFromEvent
:skip: SBCommandInterpreter_EventIsCommandInterpreterEvent
:skip: SBCommandInterpreter_GetArgumentDescriptionAsCString
:skip: SBCommandInterpreter_GetArgumentTypeAsCString
:skip: SBCommandInterpreter_GetBroadcasterClass
:skip: SBCommunication_GetBroadcasterClass
:skip: SBData_CreateDataFromCString
:skip: SBData_CreateDataFromDoubleArray
:skip: SBData_CreateDataFromSInt32Array
:skip: SBData_CreateDataFromSInt64Array
:skip: SBData_CreateDataFromUInt32Array
:skip: SBData_CreateDataFromUInt64Array
:skip: SBDebugger_Create
:skip: SBDebugger_Create
:skip: SBDebugger_Destroy
:skip: SBDebugger_FindDebuggerWithID
:skip: SBDebugger_GetBuildConfiguration
:skip: SBDebugger_GetDefaultArchitecture
:skip: SBDebugger_GetInternalVariableValue
:skip: SBDebugger_GetVersionString
:skip: SBDebugger_Initialize
:skip: SBDebugger_InitializeWithErrorHandling
:skip: SBDebugger_MemoryPressureDetected
:skip: SBDebugger_SetDefaultArchitecture
:skip: SBDebugger_SetInternalVariable
:skip: SBDebugger_StateAsCString
:skip: SBDebugger_StateIsRunningState
:skip: SBDebugger_StateIsStoppedState
:skip: SBDebugger_Terminate
:skip: SBEvent_GetCStringFromEvent
:skip: SBFileSpec_ResolvePath
:skip: SBFile_MakeBorrowed
:skip: SBFile_MakeBorrowedForcingIOMethods
:skip: SBFile_MakeForcingIOMethods
:skip: SBHostOS_GetLLDBPath
:skip: SBHostOS_GetLLDBPythonPath
:skip: SBHostOS_GetProgramFileSpec
:skip: SBHostOS_GetUserHomeDirectory
:skip: SBHostOS_ThreadCancel
:skip: SBHostOS_ThreadCreate
:skip: SBHostOS_ThreadCreated
:skip: SBHostOS_ThreadDetach
:skip: SBHostOS_ThreadJoin
:skip: SBLanguageRuntime_GetLanguageTypeFromString
:skip: SBLanguageRuntime_GetNameForLanguageType
:skip: SBModuleSpecList_GetModuleSpecifications
:skip: SBModule_GarbageCollectAllocatedModules
:skip: SBModule_GetNumberAllocatedModules
:skip: SBPlatform_GetHostPlatform
:skip: SBProcess_EventIsProcessEvent
:skip: SBProcess_EventIsStructuredDataEvent
:skip: SBProcess_GetBroadcasterClassName
:skip: SBProcess_GetInterruptedFromEvent
:skip: SBProcess_GetNumRestartedReasonsFromEvent
:skip: SBProcess_GetProcessFromEvent
:skip: SBProcess_GetRestartedFromEvent
:skip: SBProcess_GetRestartedReasonAtIndexFromEvent
:skip: SBProcess_GetStateFromEvent
:skip: SBProcess_GetStructuredDataFromEvent
:skip: SBReproducer_Capture
:skip: SBReproducer_PassiveReplay
:skip: SBReproducer_SetAutoGenerate
:skip: SBReproducer_SetWorkingDirectory
:skip: SBTarget_EventIsTargetEvent
:skip: SBTarget_GetBroadcasterClassName
:skip: SBTarget_GetModuleAtIndexFromEvent
:skip: SBTarget_GetNumModulesFromEvent
:skip: SBTarget_GetTargetFromEvent
:skip: SBThread_EventIsThreadEvent
:skip: SBThread_GetBroadcasterClassName
:skip: SBThread_GetStackFrameFromEvent
:skip: SBThread_GetThreadFromEvent
:skip: SBTypeSummary_CreateWithFunctionName
:skip: SBTypeSummary_CreateWithScriptCode
:skip: SBTypeSummary_CreateWithSummaryString
:skip: SBTypeSynthetic_CreateWithClassName
:skip: SBTypeSynthetic_CreateWithScriptCode
:skip: SBWatchpoint_EventIsWatchpointEvent
:skip: SBWatchpoint_GetWatchpointEventTypeFromEvent
:skip: SBWatchpoint_GetWatchpointFromEvent
:skip: command
:skip: in_range
:skip: is_numeric_type
:skip: lldb_iter
91 changes: 53 additions & 38 deletions lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,28 +442,6 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
m_sets[set].registers = m_set_reg_nums[set].data();
}

// We are going to create a map between remote (eRegisterKindProcessPlugin)
// and local (eRegisterKindLLDB) register numbers. This map will give us
// remote register numbers in increasing order for offset calculation.
std::map<uint32_t, uint32_t> remote_to_local_regnum_map;
for (const auto &reg : m_regs)
remote_to_local_regnum_map[reg.kinds[eRegisterKindProcessPlugin]] =
reg.kinds[eRegisterKindLLDB];

// At this stage we manually calculate g/G packet offsets of all primary
// registers, only if target XML or qRegisterInfo packet did not send
// an offset explicitly.
uint32_t reg_offset = 0;
for (auto const &regnum_pair : remote_to_local_regnum_map) {
if (m_regs[regnum_pair.second].byte_offset == LLDB_INVALID_INDEX32 &&
m_regs[regnum_pair.second].value_regs == nullptr) {
m_regs[regnum_pair.second].byte_offset = reg_offset;

reg_offset = m_regs[regnum_pair.second].byte_offset +
m_regs[regnum_pair.second].byte_size;
}
}

// sort and unique all value registers and make sure each is terminated with
// LLDB_INVALID_REGNUM

Expand All @@ -485,24 +463,10 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
// Now update all value_regs with each register info as needed
const size_t num_regs = m_regs.size();
for (size_t i = 0; i < num_regs; ++i) {
if (m_value_regs_map.find(i) != m_value_regs_map.end()) {
if (m_value_regs_map.find(i) != m_value_regs_map.end())
m_regs[i].value_regs = m_value_regs_map[i].data();
// Assign a valid offset to all pseudo registers if not assigned by stub.
// Pseudo registers with value_regs list populated will share same offset
// as that of their corresponding primary register in value_regs list.
if (m_regs[i].byte_offset == LLDB_INVALID_INDEX32) {
uint32_t value_regnum = m_regs[i].value_regs[0];
if (value_regnum != LLDB_INVALID_INDEX32)
m_regs[i].byte_offset =
GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
->byte_offset;
}
} else
else
m_regs[i].value_regs = nullptr;

reg_offset = m_regs[i].byte_offset + m_regs[i].byte_size;
if (m_reg_data_byte_size < reg_offset)
m_reg_data_byte_size = reg_offset;
}

// Expand all invalidation dependencies
Expand Down Expand Up @@ -648,8 +612,59 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
break;
}
}

// At this stage call ConfigureOffsets to calculate register offsets for
// targets supporting dynamic offset calculation. It also calculates
// total byte size of register data.
ConfigureOffsets();
}

void DynamicRegisterInfo::ConfigureOffsets() {
// We are going to create a map between remote (eRegisterKindProcessPlugin)
// and local (eRegisterKindLLDB) register numbers. This map will give us
// remote register numbers in increasing order for offset calculation.
std::map<uint32_t, uint32_t> remote_to_local_regnum_map;
for (const auto &reg : m_regs)
remote_to_local_regnum_map[reg.kinds[eRegisterKindProcessPlugin]] =
reg.kinds[eRegisterKindLLDB];

// At this stage we manually calculate g/G packet offsets of all primary
// registers, only if target XML or qRegisterInfo packet did not send
// an offset explicitly.
uint32_t reg_offset = 0;
for (auto const &regnum_pair : remote_to_local_regnum_map) {
if (m_regs[regnum_pair.second].byte_offset == LLDB_INVALID_INDEX32 &&
m_regs[regnum_pair.second].value_regs == nullptr) {
m_regs[regnum_pair.second].byte_offset = reg_offset;

reg_offset = m_regs[regnum_pair.second].byte_offset +
m_regs[regnum_pair.second].byte_size;
}
}

// Now update all value_regs with each register info as needed
for (auto &reg : m_regs) {
if (reg.value_regs != nullptr) {
// Assign a valid offset to all pseudo registers if not assigned by stub.
// Pseudo registers with value_regs list populated will share same offset
// as that of their corresponding primary register in value_regs list.
if (reg.byte_offset == LLDB_INVALID_INDEX32) {
uint32_t value_regnum = reg.value_regs[0];
if (value_regnum != LLDB_INVALID_INDEX32)
reg.byte_offset =
GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
->byte_offset;
}
}

reg_offset = reg.byte_offset + reg.byte_size;
if (m_reg_data_byte_size < reg_offset)
m_reg_data_byte_size = reg_offset;
}
}

bool DynamicRegisterInfo::IsReconfigurable() { return m_is_reconfigurable; }

size_t DynamicRegisterInfo::GetNumRegisters() const { return m_regs.size(); }

size_t DynamicRegisterInfo::GetNumRegisterSets() const { return m_sets.size(); }
Expand Down
Loading

0 comments on commit aec8dbc

Please sign in to comment.