diff --git a/CMakeLists.txt b/CMakeLists.txt index 75d3a7e9dfb5..fa579d264aa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ include(LLDBConfig) include(AddLLDB) # BEGIN - Swift Mods -if(NOT LLDB_BUILT_STANDALONE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../swift) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../swift) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../swift/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/../swift/cmake/modules") @@ -26,15 +26,6 @@ else() add_definitions( -DLLDB_CONFIGURATION_RELEASE ) endif() -if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android") - set(LLDB_DEFAULT_DISABLE_LIBEDIT 1) -else() - set(LLDB_DEFAULT_DISABLE_LIBEDIT 0) -endif () - -# We need libedit support to go down both the source and -# the scripts directories. -set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.") if (LLDB_DISABLE_LIBEDIT) add_definitions( -DLLDB_DISABLE_LIBEDIT ) else() @@ -45,66 +36,22 @@ if(APPLE) add_definitions(-DLLDB_USE_OS_LOG) endif() -# lldb-suite is a dummy target that encompasses all the necessary tools and -# libraries for building a fully-functioning liblldb. -add_custom_target(lldb-suite) -set(LLDB_SUITE_TARGET lldb-suite) - -option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off) -if(LLDB_BUILD_FRAMEWORK) - if (CMAKE_VERSION VERSION_LESS 3.7) - message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7") - endif() - if (NOT APPLE) - message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms") - endif() - - add_custom_target(lldb-framework) - # These are used to fill out LLDB-Info.plist. These are relevant when building - # the framework, and must be defined before building liblldb. - set(PRODUCT_NAME "LLDB") - set(EXECUTABLE_NAME "LLDB") - set(CURRENT_PROJECT_VERSION "360.99.0") - set(LLDB_SUITE_TARGET lldb-framework) - - set(LLDB_FRAMEWORK_DIR - ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR}) - include(LLDBFramework) -endif() - add_subdirectory(docs) if (NOT LLDB_DISABLE_PYTHON) - if(LLDB_USE_SYSTEM_SIX) - set(SIX_EXTRA_ARGS "--useSystemSix") - endif() - - set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts) - set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp) - if(LLDB_BUILD_FRAMEWORK) - set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_DIR}) - set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp) - else() - # Don't set -m when building the framework. - set(FINISH_EXTRA_ARGS "-m") - endif() - - add_subdirectory(scripts) endif () - add_subdirectory(source) add_subdirectory(tools) -option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." - ${LLVM_INCLUDE_TESTS}) +option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS}) option(LLDB_TEST_USE_CUSTOM_C_COMPILER "Use the C compiler provided via LLDB_TEST_C_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF) option(LLDB_TEST_USE_CUSTOM_CXX_COMPILER "Use the C++ compiler provided via LLDB_TEST_CXX_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF) if(LLDB_INCLUDE_TESTS) - # The difference between the following two paths is significant. The path to - # LLDB will point to LLDB's binary directory, while the other will point to - # LLVM's binary directory in case the two differ. + # Set the path to the default lldb test executable. set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}") + + # Set the paths to default llvm tools. set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}") set(LLDB_DEFAULT_TEST_FILECHECK "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck${CMAKE_EXECUTABLE_SUFFIX}") @@ -136,9 +83,7 @@ if(LLDB_INCLUDE_TESTS) endif() if(TARGET debugserver) - if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY) - list(APPEND LLDB_TEST_DEPS debugserver) - endif() + list(APPEND LLDB_TEST_DEPS debugserver) endif() if(TARGET lldb-mi) @@ -153,73 +98,99 @@ if(LLDB_INCLUDE_TESTS) list(APPEND LLDB_TEST_DEPS liblldb) endif() + # Add dependencies if we test with the in-tree clang. + # This works with standalone builds as they import the clang target. if(TARGET clang) list(APPEND LLDB_TEST_DEPS clang) + if(APPLE) + # If we build clang, we should build libcxx. + # FIXME: Standalone builds should import the cxx target as well. + if(LLDB_BUILT_STANDALONE) + # For now check that the include directory exists. + set(cxx_dir "${LLVM_BINARY_DIR}/include/c++") + if(NOT EXISTS ${cxx_dir}) + message(WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}") + endif() + else() + list(APPEND LLDB_TEST_DEPS cxx) + endif() + endif() endif() if(TARGET dsymutil) list(APPEND LLDB_TEST_DEPS dsymutil) endif() + add_custom_target(lldb-test-deps DEPENDS ${LLDB_TEST_DEPS}) + add_subdirectory(test) add_subdirectory(unittests) add_subdirectory(lit) add_subdirectory(utils/lldb-dotest) endif() - if (NOT LLDB_DISABLE_PYTHON) + if(NOT LLDB_BUILD_FRAMEWORK) + set(use_python_wrapper_from_src_dir -m) + endif() + if(LLDB_USE_SYSTEM_SIX) + set(use_six_py_from_system --useSystemSix) + endif() + get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR) + get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY) + # Add a Post-Build Event to copy over Python files and create the symlink # to liblldb.so for the Python API(hardlink on Windows) if (APPLE) - # FIXME. This replicates the xcode project. We should probably - # get rid of this special path and use the same script that - # every other platform is using. + # FIXME: This replicates the Xcode project. It was the original way of + # finalizing the swig generator step. We should get rid of this special + # path and use the same script that every other platform is using. For + # the time being, the arguments are: + # 1) path to lldb source tree + # 2) path to lldb framework/shared library + # 3) path to lldb.py + # 4) not relevant on Darwin + # 5) additional flags add_custom_target(finish_swig ALL COMMAND - ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finish-swig-wrapper-classes.sh + ${LLDB_SOURCE_DIR}/scripts/finish-swig-wrapper-classes.sh ${LLDB_SOURCE_DIR} - ${LLDB_PYTHON_TARGET_DIR} - ${LLDB_PYTHON_TARGET_DIR} + ${liblldb_build_dir} + ${lldb_scripts_dir} "" + ${use_python_wrapper_from_src_dir} VERBATIM - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py - DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py + DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py + DEPENDS ${lldb_scripts_dir}/lldb.py COMMENT "Python script sym-linking LLDB Python API") else() add_custom_target(finish_swig ALL COMMAND - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py + ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py --srcRoot=${LLDB_SOURCE_DIR} - --targetDir=${LLDB_PYTHON_TARGET_DIR} - --cfgBldDir=${LLDB_PYTHON_TARGET_DIR} + --targetDir=${liblldb_build_dir} + --cfgBldDir=${lldb_scripts_dir} --prefix=${CMAKE_BINARY_DIR} --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR} --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX} - ${SIX_EXTRA_ARGS} - ${FINISH_EXTRA_ARGS} + ${use_python_wrapper_from_src_dir} + ${use_six_py_from_system} VERBATIM - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py - DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py + DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py + DEPENDS ${lldb_scripts_dir}/lldb.py COMMENT "Python script sym-linking LLDB Python API") endif() - # We depend on liblldb and lldb-argdumper being built before we can do this step. - add_dependencies(finish_swig ${LLDB_SUITE_TARGET}) - - # If we build the readline module, we depend on that happening - # first. if (TARGET readline) - add_dependencies(finish_swig readline) + set(readline_dep readline) endif() + add_dependencies(finish_swig swig_wrapper liblldb lldb-argdumper ${readline_dep}) # Ensure we do the python post-build step when building lldb. add_dependencies(lldb finish_swig) - if (LLDB_BUILD_FRAMEWORK) - # The target to install libLLDB needs to depend on finish_swig so that the - # framework build properly copies over the Python files. - add_dependencies(install-liblldb finish_swig) + if(LLDB_BUILD_FRAMEWORK) + add_dependencies(lldb-framework finish_swig) endif() # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching diff --git a/LICENSE.TXT b/LICENSE.TXT index 1f0309419d78..029b1d9aae1d 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,3 +1,241 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== University of Illinois/NCSA Open Source License diff --git a/cmake/modules/AddLLDB.cmake b/cmake/modules/AddLLDB.cmake index a0379a047a91..3f710701d4df 100644 --- a/cmake/modules/AddLLDB.cmake +++ b/cmake/modules/AddLLDB.cmake @@ -3,7 +3,7 @@ function(add_lldb_library name) # MODULE;SHARED;STATIC library type and source files cmake_parse_arguments(PARAM "MODULE;SHARED;STATIC;OBJECT;PLUGIN" - "" + "ENTITLEMENTS" "EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS" ${ARGN}) llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS}) @@ -44,26 +44,37 @@ function(add_lldb_library name) if (PARAM_OBJECT) add_library(${name} ${libkind} ${srcs}) else() - llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS - ${PARAM_LINK_LIBS} - DEPENDS ${PARAM_DEPENDS}) + if(PARAM_ENTITLEMENTS) + set(pass_ENTITLEMENTS ENTITLEMENTS ${PARAM_ENTITLEMENTS}) + endif() + + if(LLDB_NO_INSTALL_DEFAULT_RPATH) + set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH) + endif() + + llvm_add_library(${name} ${libkind} ${srcs} + LINK_LIBS ${PARAM_LINK_LIBS} + DEPENDS ${PARAM_DEPENDS} + ${pass_ENTITLEMENTS} + ${pass_NO_INSTALL_RPATH} + ) if (${name} STREQUAL "liblldb") if (PARAM_SHARED) - set(out_dir lib${LLVM_LIBDIR_SUFFIX}) if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK) - set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) - # The framework that is generated will install with install-liblldb - # because we enable CMake's framework support. CMake will copy all the - # headers and resources for us. - add_dependencies(install-lldb-framework install-${name}) - add_dependencies(install-lldb-framework-stripped install-${name}-stripped) + if(LLDB_FRAMEWORK_INSTALL_DIR) + set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR}) + else() + set(install_dir ".") + endif() + else() + set(install_dir lib${LLVM_LIBDIR_SUFFIX}) endif() install(TARGETS ${name} COMPONENT ${name} RUNTIME DESTINATION bin - LIBRARY DESTINATION ${out_dir} - ARCHIVE DESTINATION ${out_dir}) + LIBRARY DESTINATION ${install_dir} + ARCHIVE DESTINATION ${install_dir}) else() install(TARGETS ${name} COMPONENT ${name} @@ -74,13 +85,6 @@ function(add_lldb_library name) add_llvm_install_targets(install-${name} DEPENDS $ COMPONENT ${name}) - - # install-liblldb{,-stripped} is the actual target that will install the - # framework, so it must rely on the framework being fully built first. - if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb") - add_dependencies(install-${name} lldb-framework) - add_dependencies(install-lldb-framework-stripped lldb-framework) - endif() endif() endif() endif() @@ -89,7 +93,9 @@ function(add_lldb_library name) # Hack: only some LLDB libraries depend on the clang autogenerated headers, # but it is simple enough to make all of LLDB depend on some of those # headers without negatively impacting much of anything. - add_dependencies(${name} clang-tablegen-targets) + if(NOT LLDB_BUILT_STANDALONE) + add_dependencies(${name} clang-tablegen-targets) + endif() # Add in any extra C++ compilation flags for this library. target_compile_options(${name} PRIVATE ${PARAM_EXTRA_CXXFLAGS}) @@ -99,63 +105,40 @@ endfunction(add_lldb_library) function(add_lldb_executable name) cmake_parse_arguments(ARG - "INCLUDE_IN_SUITE;GENERATE_INSTALL" - "" + "GENERATE_INSTALL" + "ENTITLEMENTS" "LINK_LIBS;LINK_COMPONENTS" ${ARGN} ) - list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS}) - add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}) - - target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS}) - set_target_properties(${name} PROPERTIES - FOLDER "lldb executables") - - if(ARG_INCLUDE_IN_SUITE) - add_dependencies(lldb-suite ${name}) - if(LLDB_BUILD_FRAMEWORK) - if(NOT IOS) - set(resource_dir "/Resources") - set(resource_dots "../") - endif() - string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR}) - set_target_properties(${name} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY $${resource_dir} - BUILD_WITH_INSTALL_RPATH On - INSTALL_RPATH "@loader_path/../../../${resource_dots}${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}") - endif() + if(ARG_ENTITLEMENTS) + set(pass_ENTITLEMENTS ENTITLEMENTS ${ARG_ENTITLEMENTS}) endif() - if(LLDB_BUILD_FRAMEWORK AND NOT ARG_INCLUDE_IN_SUITE) - set_target_properties(${name} PROPERTIES - BUILD_WITH_INSTALL_RPATH On - INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}") + if(LLDB_NO_INSTALL_DEFAULT_RPATH) + set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH) endif() + list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS}) + add_llvm_executable(${name} + ${pass_ENTITLEMENTS} + ${pass_NO_INSTALL_RPATH} + ${ARG_UNPARSED_ARGUMENTS} + ) + + target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS}) + set_target_properties(${name} PROPERTIES FOLDER "lldb executables") + if(ARG_GENERATE_INSTALL) - set(out_dir "bin") - if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE) - set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}) - # While install-liblldb-stripped will handle copying the tools, it will - # not strip them. We depend on this target to guarantee a stripped version - # will get installed in the framework. - add_dependencies(install-lldb-framework-stripped install-${name}-stripped) - endif() install(TARGETS ${name} - COMPONENT ${name} - RUNTIME DESTINATION ${out_dir}) + COMPONENT ${name} + RUNTIME DESTINATION bin) if (NOT CMAKE_CONFIGURATION_TYPES) add_llvm_install_targets(install-${name} DEPENDS ${name} COMPONENT ${name}) endif() endif() - - if(ARG_INCLUDE_IN_SUITE AND LLDB_BUILD_FRAMEWORK) - add_llvm_tool_symlink(${name} ${name} ALWAYS_GENERATE SKIP_INSTALL - OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) - endif() endfunction(add_lldb_executable) function(add_lldb_tool name) @@ -177,3 +160,40 @@ function(lldb_append_link_flags target_name new_link_flags) # Now set them onto the target. set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags}) endfunction() + +# For tools that depend on liblldb, account for varying directory structures in +# which LLDB.framework can be used and distributed: In the build-tree we find it +# by its absolute target path. This is only relevant for running the test suite. +# In the install step CMake will remove this entry and insert the final RPATHs. +# These are relative to the file path from where the tool will be loaded on the +# enduser system. +# +# Note that the LLVM install-tree doesn't match the enduser system structure +# for LLDB.framework, so by default dependent tools will not be functional in +# their install location. The LLDB_FRAMEWORK_INSTALL_DIR variable allows to fix +# this. If specified, it causes the install-tree location of the framework to be +# added as an extra RPATH below. +# +function(lldb_setup_framework_rpaths_in_tool name) + # In the build-tree, we know the exact path to the binary in the framework. + set(rpath_build_tree "$") + + # The installed framework is relocatable and can be in different locations. + set(rpaths_install_tree "@loader_path/../../../SharedFrameworks") + list(APPEND rpaths_install_tree "@loader_path/../../System/Library/PrivateFrameworks") + list(APPEND rpaths_install_tree "@loader_path/../../Library/PrivateFrameworks") + + if(LLDB_FRAMEWORK_INSTALL_DIR) + set(rpaths_install_tree "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}") + endif() + + # If LLDB_NO_INSTALL_DEFAULT_RPATH was NOT enabled (default), this overwrites + # the default settings from llvm_setup_rpath(). + set_target_properties(${name} PROPERTIES + BUILD_WITH_INSTALL_RPATH OFF + BUILD_RPATH "${rpath_build_tree}" + INSTALL_RPATH "${rpaths_install_tree}" + ) + + add_dependencies(${name} lldb-framework) +endfunction() diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake index 9effa1bba42c..0ea5b4fd12bd 100644 --- a/cmake/modules/LLDBConfig.cmake +++ b/cmake/modules/LLDBConfig.cmake @@ -1,39 +1,111 @@ include(CheckCXXSymbolExists) +# BEGIN Swift Mods +# We want this in a cmake cache +list(APPEND swift_lldb_framework_tools + darwin-debug + lldb-argdumper + lldb-server + repl_swift +) + +set(LLVM_ENABLE_MODULES ON CACHE BOOL "" FORCE) +set(LLVM_EXTERNALIZE_DEBUGINFO OFF CACHE BOOL "" FORCE) +set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "" FORCE) + +set(LLDB_VERSION_MAJOR 992 CACHE STRING "" FORCE) +set(LLDB_VERSION_MINOR 8 CACHE STRING "" FORCE) +set(LLDB_VERSION_PATCH 1 CACHE STRING "" FORCE) +set(LLDB_VERSION_SUFFIX svn CACHE STRING "" FORCE) + +if(APPLE) + set(LLDB_USE_SYSTEM_DEBUGSERVER ON CACHE BOOL "" FORCE) + set(LLDB_BUILD_FRAMEWORK ON CACHE BOOL "" FORCE) + set(LLDB_FRAMEWORK_TOOLS ${swift_lldb_framework_tools} CACHE STRING "" FORCE) +endif() + +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(LLDB_ALLOW_STATIC_BINDINGS ON CACHE BOOL "" FORCE) +endif() +# END Swift Mods + set(LLDB_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/source") set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include") +set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message(FATAL_ERROR + "In-source builds are not allowed. CMake would overwrite the makefiles " + "distributed with LLDB. Please create a directory and run cmake from " + "there, passing the path to this source directory as the last argument. " + "This process created the file `CMakeCache.txt' and the directory " + "`CMakeFiles'. Please delete them.") +endif() + set(LLDB_LINKER_SUPPORTS_GROUPS OFF) if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") # The Darwin linker doesn't understand --start-group/--end-group. set(LLDB_LINKER_SUPPORTS_GROUPS ON) endif() -set(LLDB_DEFAULT_DISABLE_PYTHON 0) -set(LLDB_DEFAULT_DISABLE_CURSES 0) +set(default_disable_python OFF) +set(default_disable_curses OFF) +set(default_disable_libedit OFF) -if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) - set(LLDB_DEFAULT_DISABLE_CURSES 1) -elseif (CMAKE_SYSTEM_NAME MATCHES "Android" ) - set(LLDB_DEFAULT_DISABLE_PYTHON 1) - set(LLDB_DEFAULT_DISABLE_CURSES 1) -elseif(IOS) - set(LLDB_DEFAULT_DISABLE_PYTHON 1) +if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT) + set(default_disable_libedit ON) endif() -set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL - "Disables the Python scripting integration.") -set(LLDB_ALLOW_STATIC_BINDINGS FALSE CACHE BOOL - "Enable using static/baked language bindings if swig is not present.") -set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL - "Disables the Curses integration.") +if(CMAKE_SYSTEM_NAME MATCHES "Windows") + set(default_disable_curses ON) + set(default_disable_libedit ON) +elseif(CMAKE_SYSTEM_NAME MATCHES "Android") + set(default_disable_python ON) + set(default_disable_curses ON) + set(default_disable_libedit ON) +elseif(IOS) + set(default_disable_python ON) +endif() -set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL - "Causes LLDB to use the PYTHONHOME environment variable to locate Python.") +option(LLDB_DISABLE_PYTHON "Disable Python scripting integration." ${default_disable_python}) +option(LLDB_DISABLE_CURSES "Disable Curses integration." ${default_disable_curses}) +option(LLDB_DISABLE_LIBEDIT "Disable the use of editline." ${default_disable_libedit}) +option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF) +option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF) +option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON) +option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF) +option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries" OFF) + +# BEGIN SWIFT CODE +option(LLDB_ALLOW_STATIC_BINDINGS "Enable using static/baked language bindings if swig is not present." OFF) +# END SWIFT CODE + +if(LLDB_BUILD_FRAMEWORK) + if(NOT APPLE) + message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms") + endif() + # CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework targets + if(CMAKE_VERSION VERSION_LESS 3.7) + message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7") + endif() -set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL - "Use six.py shipped with system and do not install a copy of it") + set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)") + set(LLDB_FRAMEWORK_BUILD_DIR bin CACHE STRING "Output directory for LLDB.framework") + set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Install directory for LLDB.framework") + set(LLDB_FRAMEWORK_RESOURCE_DIR Versions/${LLDB_FRAMEWORK_VERSION}/Resources) + set(LLDB_FRAMEWORK_TOOLS darwin-debug;debugserver;lldb-argdumper;lldb-server CACHE STRING + "List of tools to include in LLDB.framework/Resources") + + # Set designated directory for all dSYMs. Essentially, this emits the + # framework's dSYM outside of the framework directory. + if(LLVM_EXTERNALIZE_DEBUGINFO) + set(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin CACHE STRING + "Directory to emit dSYM files stripped from executables and libraries (Darwin Only)") + endif() +endif() if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL @@ -182,7 +254,7 @@ if (NOT LLDB_DISABLE_PYTHON) else() find_package(PythonLibs REQUIRED) endif() - + if (PYTHON_INCLUDE_DIRS) include_directories(${PYTHON_INCLUDE_DIRS}) endif() @@ -208,6 +280,8 @@ if(NOT LLDB_BUILT_STANDALONE) include_directories(${CMAKE_SOURCE_DIR}/tools/swift/include) endif () include_directories("${CMAKE_CURRENT_BINARY_DIR}/../swift/include") +else () + include_directories("${LLDB_PATH_TO_SWIFT_BUILD}/include") endif() # Disable GCC warnings @@ -254,6 +328,7 @@ if( MSVC ) -wd4018 # Suppress 'warning C4018: '>=' : signed/unsigned mismatch' -wd4068 # Suppress 'warning C4068: unknown pragma' -wd4150 # Suppress 'warning C4150: deletion of pointer to incomplete type' + -wd4201 # Suppress 'warning C4201: nonstandard extension used: nameless struct/union' -wd4251 # Suppress 'warning C4251: T must have dll-interface to be used by clients of class U.' -wd4521 # Suppress 'warning C4521: 'type' : multiple copy constructors specified' -wd4530 # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.' @@ -265,20 +340,20 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions( -D_UNICODE -DUNICODE ) endif() -set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) - -if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) - message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite " -"the makefiles distributed with LLDB. Please create a directory and run cmake " -"from there, passing the path to this source directory as the last argument. " -"This process created the file `CMakeCache.txt' and the directory " -"`CMakeFiles'. Please delete them.") +# If LLDB_VERSION_* is specified, use it, if not use LLVM_VERSION_*. +if(NOT DEFINED LLDB_VERSION_MAJOR) + set(LLDB_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) endif() - -# Compute the LLDB version from the LLVM version. -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLDB_VERSION - ${PACKAGE_VERSION}) +if(NOT DEFINED LLDB_VERSION_MINOR) + set(LLDB_VERSION_MINOR ${LLVM_VERSION_MINOR}) +endif() +if(NOT DEFINED LLDB_VERSION_PATCH) + set(LLDB_VERSION_PATCH ${LLVM_VERSION_PATCH}) +endif() +if(NOT DEFINED LLDB_VERSION_SUFFIX) + set(LLDB_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) +endif() +set(LLDB_VERSION "${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}${LLDB_VERSION_SUFFIX}") message(STATUS "LLDB version: ${LLDB_VERSION}") include_directories(BEFORE @@ -315,11 +390,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) endif() endif() -if (NOT LIBXML2_FOUND AND NOT (CMAKE_SYSTEM_NAME MATCHES "Windows")) - # Skip Libxml2 on Windows. In CMake 3.4 and higher, the algorithm for - # finding libxml2 got "smarter", and it can now locate the version which is - # in gnuwin32, even though that version does not contain the headers that - # LLDB uses. +if (NOT LIBXML2_FOUND) find_package(LibXml2) endif() @@ -334,11 +405,6 @@ if (APPLE) find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) find_library(SECURITY_LIBRARY Security) - set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Output directory for LLDB.framework") - set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)") - set(LLDB_FRAMEWORK_RESOURCE_DIR - LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources) - add_definitions( -DLIBXML2_DEFINED ) list(APPEND system_libs xml2 ${CURSES_LIBRARIES} @@ -347,15 +413,11 @@ if (APPLE) ${CORE_SERVICES_LIBRARY} ${SECURITY_LIBRARY} ${DEBUG_SYMBOLS_LIBRARY}) - include_directories(AFTER "${CMAKE_OSX_SYSROOT}/usr/include/libxml2") -else() - if (LIBXML2_FOUND) - add_definitions( -DLIBXML2_DEFINED ) - list(APPEND system_libs ${LIBXML2_LIBRARIES}) - include_directories(${LIBXML2_INCLUDE_DIR}) - endif() - +elseif(LIBXML2_FOUND AND LIBXML2_VERSION_STRING VERSION_GREATER 2.8) + add_definitions( -DLIBXML2_DEFINED ) + list(APPEND system_libs ${LIBXML2_LIBRARIES}) + include_directories(${LIBXML2_INCLUDE_DIR}) endif() if( WIN32 AND NOT CYGWIN ) @@ -370,6 +432,8 @@ endif() list(APPEND system_libs ${CMAKE_DL_LIBS}) +SET(SKIP_LLDB_SERVER_BUILD OFF CACHE BOOL "Skip building lldb-server") + # Figure out if lldb could use lldb-server. If so, then we'll # ensure we build lldb-server when an lldb target is being built. if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD") diff --git a/cmake/modules/LLDBFramework.cmake b/cmake/modules/LLDBFramework.cmake index 3bee5af82059..40c185986f33 100644 --- a/cmake/modules/LLDBFramework.cmake +++ b/cmake/modules/LLDBFramework.cmake @@ -1,40 +1,106 @@ +# Path relative to the root binary directory +get_filename_component( + framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE + BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR} +) + +message(STATUS "LLDB.framework: build path is '${framework_target_dir}'") +message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'") +message(STATUS "LLDB.framework: resources subdirectory is '${LLDB_FRAMEWORK_RESOURCE_DIR}'") + +# Configure liblldb as a framework bundle +set_target_properties(liblldb PROPERTIES + FRAMEWORK ON + FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} + + OUTPUT_NAME LLDB + VERSION ${LLDB_VERSION} + LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir} + + # Compatibility version + SOVERSION "1.0.0" + + MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework + MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION} + MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in +) + +# Affects the layout of the framework bundle (default is macOS layout). +if(IOS) + set_target_properties(liblldb PROPERTIES + XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONEOS_DEPLOYMENT_TARGET}") +else() + set_target_properties(liblldb PROPERTIES + XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") +endif() + +# Target to capture extra steps for a fully functional framework bundle. +add_custom_target(lldb-framework) +add_dependencies(lldb-framework liblldb) + +# Dependencies are defined once tools are added (see AddLLDB.cmake) +if(LLDB_FRAMEWORK_TOOLS) + message(STATUS "LLDB.framework: adding tools ${LLDB_FRAMEWORK_TOOLS}") + foreach(tool ${LLDB_FRAMEWORK_TOOLS}) + add_custom_command(TARGET lldb-framework POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $/Resources + COMMENT "LLDB.framework: copy additional tool ${tool}" + ) + endforeach() +else() + message(WARNING "LLDB.framework: no additional tools configured (set via LLDB_FRAMEWORK_TOOLS)") +endif() + +# Apart from this one, CMake creates all required symlinks in the framework bundle. +add_custom_command(TARGET lldb-framework POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink + Versions/Current/Headers + ${framework_target_dir}/LLDB.framework/Headers + COMMENT "LLDB.framework: create Headers symlink" +) + +# At configuration time, collect headers for the framework bundle and copy them +# into a staging directory. Later we can copy over the entire folder. file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h) file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h) list(REMOVE_ITEM root_public_headers ${root_private_headers}) + +set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders) foreach(header ${public_headers} ${root_public_headers} ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h) + get_filename_component(basename ${header} NAME) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename} - DEPENDS ${header} - COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) - list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}) + set(staged_header ${lldb_header_staging}/${basename}) + + add_custom_command( + DEPENDS ${header} OUTPUT ${staged_header} + COMMAND ${CMAKE_COMMAND} -E copy ${header} ${staged_header} + COMMENT "LLDB.framework: collect framework header") + + list(APPEND lldb_staged_headers ${staged_header}) endforeach() -add_custom_target(lldb-framework-headers DEPENDS ${framework_headers}) +# Wrap output in a target, so lldb-framework can depend on it. +add_custom_target(lldb-framework-headers DEPENDS ${lldb_staged_headers}) +add_dependencies(lldb-framework lldb-framework-headers) -add_custom_command(TARGET lldb-framework POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $/Headers +# At build time, copy the staged headers into the framework bundle (and do +# some post-processing in-place). +add_custom_command(TARGET lldb-framework-headers POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${lldb_header_staging} $/Headers COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh $/Headers ${LLDB_VERSION} + COMMENT "LLDB.framework: copy framework headers" ) -if (NOT IOS) - if (NOT LLDB_BUILT_STANDALONE) - add_dependencies(lldb-framework clang-headers) - endif() - add_custom_command(TARGET lldb-framework POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${LLDB_FRAMEWORK_DIR}/LLDB.framework/Headers - COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${LLDB_FRAMEWORK_DIR}/LLDB.framework/Versions/Current +# Copy vendor-specific headers from clang (without staging). +if(NOT IOS) + add_custom_command(TARGET lldb-framework-headers POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${LLDB_PATH_TO_SWIFT_BUILD}/lib/swift/clang/ $/Resources/Clang COMMAND ${CMAKE_COMMAND} -E copy_directory ${LLDB_PATH_TO_SWIFT_BUILD}/lib/swift $/Resources/Swift + COMMENT "LLDB.framework: copy clang vendor-specific headers" ) endif() - -add_dependencies(lldb-framework - lldb-framework-headers - lldb-suite) - -add_custom_target(install-lldb-framework) -add_custom_target(install-lldb-framework-stripped) diff --git a/cmake/modules/LLDBStandalone.cmake b/cmake/modules/LLDBStandalone.cmake index f1dc5ea86f5e..222d10cd4c02 100644 --- a/cmake/modules/LLDBStandalone.cmake +++ b/cmake/modules/LLDBStandalone.cmake @@ -13,11 +13,12 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) file(TO_CMAKE_PATH "${LLDB_PATH_TO_SWIFT_BUILD}" LLDB_PATH_TO_SWIFT_BUILD) file(TO_CMAKE_PATH "${LLDB_PATH_TO_SWIFT_SOURCE}" LLDB_PATH_TO_SWIFT_SOURCE) + # END Swift Mods find_package(LLVM REQUIRED CONFIG HINTS "${LLDB_PATH_TO_LLVM_BUILD}" NO_CMAKE_FIND_ROOT_PATH) - find_package(Clang REQUIRED CONFIG - HINTS "${LLDB_PATH_TO_CLANG_BUILD}" NO_CMAKE_FIND_ROOT_PATH) + #find_package(Clang REQUIRED CONFIG + # HINTS "${LLDB_PATH_TO_CLANG_BUILD}" NO_CMAKE_FIND_ROOT_PATH) # We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules") @@ -26,7 +27,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(LLVM_MAIN_INCLUDE_DIR ${LLVM_BUILD_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_LIBRARY_DIR ${LLVM_BUILD_LIBRARY_DIR} CACHE PATH "Path to llvm/lib") set(LLVM_BINARY_DIR ${LLVM_BUILD_BINARY_DIR} CACHE PATH "Path to LLVM build tree") - set(LLVM_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH "Path to llvm-lit") + set(LLVM_DEFAULT_EXTERNAL_LIT ${LLVM_TOOLS_BINARY_DIR}/llvm-lit CACHE PATH "Path to llvm-lit") if(CMAKE_CROSSCOMPILING) set(LLVM_NATIVE_BUILD "${LLDB_PATH_TO_LLVM_BUILD}/NATIVE") @@ -67,8 +68,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) # We append the directory in which LLVMConfig.cmake lives. We expect LLVM's # CMake modules to be in that directory as well. list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}") - list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_SWIFT_SOURCE}/cmake/modules") include(AddLLVM) + include(TableGen) include(HandleLLVMOptions) include(CheckAtomic) @@ -86,6 +87,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() # Start Swift Mods + find_package(Clang REQUIRED CONFIG + HINTS "${LLDB_PATH_TO_CLANG_BUILD}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) find_package(Swift REQUIRED CONFIG HINTS "${LLDB_PATH_TO_SWIFT_BUILD}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) # End Swift Mods diff --git a/cmake/modules/debugserverConfig.cmake b/cmake/modules/debugserverConfig.cmake new file mode 100644 index 000000000000..3b716ca87716 --- /dev/null +++ b/cmake/modules/debugserverConfig.cmake @@ -0,0 +1,3 @@ +# Duplicate options from LLDBConfig that are relevant for debugserver Standalone builds. + +option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 045e816b727c..b31eb52b19af 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,4 +1,3 @@ - include(FindDoxygen) if(DOXYGEN_FOUND) @@ -39,3 +38,12 @@ if(EPYDOC_EXECUTABLE) COMMENT "Generating LLDB Python API reference with epydoc" VERBATIM ) endif(EPYDOC_EXECUTABLE) + +if (LLVM_ENABLE_SPHINX) + include(AddSphinxTarget) + if (SPHINX_FOUND) + if (${SPHINX_OUTPUT_HTML}) + add_sphinx_target(html lldb) + endif() + endif() +endif() diff --git a/docs/_static/lldb.css b/docs/_static/lldb.css new file mode 100644 index 000000000000..ddc138aeccdc --- /dev/null +++ b/docs/_static/lldb.css @@ -0,0 +1,26 @@ +table.mapping { + width: 100%; +} + +table.mapping td { + width: 50%; + padding: 5px; +} + +table.mapping td.hed { + background: #606060; + color: white; + text-align: left; + border-bottom: 2px #fff solid; + font-weight: bold; +} + +table.mapping td.header { + background: #eee; +} + +table.mapping td.content { + font-family: monospace; + padding-bottom: 15px; +} + diff --git a/docs/building-with-debug-llvm.txt b/docs/building-with-debug-llvm.txt deleted file mode 100644 index f59ca410edb0..000000000000 --- a/docs/building-with-debug-llvm.txt +++ /dev/null @@ -1,50 +0,0 @@ -This document describes how to build a debug version of LLVM for use with -LLDB, and how to make LLDB use it. - -It assumes that you are using the Xcode 3 series (I used 3.2.4) to build -LLDB. It also assumes that your shell is /bin/bash, and that you are -currently at a shell prompt in a checked-out LLDB repository. - -1. Check out LLVM and Clang from their repositories. To determine - the revision to use, consult scripts/build-llvm.pl (this is done - in the first command line below). !!! WARNING Do not use the - name "llvm" for your checkout, for reasons described in part 3 - below. - - $ export CLANG_REVISION=`cat scripts/build-llvm.pl | grep ^our.*llvm_revision | cut -d \' -f 2,2` - $ svn co -r $CLANG_REVISION http://llvm.org/svn/llvm-project/llvm/trunk llvm.checkout - $ svn co -r $CLANG_REVISION http://llvm.org/svn/llvm-project/cfe/trunk llvm.checkout/tools/clang - -2. Configure LLVM/Clang with the proper options and compilers. I use: - - $ cd llvm.checkout - $ CC="cc -g -O0" CXX="c++ -g -O0" ./configure --disable-optimized --enable-assertions --enable-targets=x86_64,arm - $ CC="cc -g -O0" CXX="c++ -g -O0" make -j 2 - $ cd .. - -3. Create a link to the built LLVM. !!! WARNING: Do not rename the - directory! The LLVM builder script that runs as part of the Xcode - build keys off the fact that llvm/ is a symlink to recognize that - we are building with a custom debug build. - - $ ln -sf llvm.checkout llvm - -4. Make sure that your Xcode project is set up correctly. Open - lldb.xcodeproj and do the following: - - Under "Targets" in the Groups & Files navigator, double-click - lldb-tool. In the resulting window, select "Debug" from the - "Configuration:" drop-down. Then, make sure that the setting - "Build Active Architecture Only" is enabled. Close the window. - - Under "Targets" in the Groups & Files navigator, double-click - LLDB. In the resulting window, select "Debug" from the - "Configuration:" drop-down. Then, make sure that the setting - "Build Active Architecture Only" is enabled. Close the window. - -5. Ensure that Xcode is building the lldb-tool target in Debug - configuration for your architecture (typically x86_64). You - can usually pick these options from the Overview drop-down at - the top left of the Xcode window. - -6. Build lldb.xcodeproj. diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000000..bc1c99745add --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,247 @@ +# -*- coding: utf-8 -*- +# +# LLDB documentation build configuration file, created by +# sphinx-quickstart on Sun Dec 9 20:01:55 2012. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os +from datetime import date + +# 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('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# 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'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'LLDB' +copyright = u'2007-%d, The LLDB Team' % date.today().year + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short version. +version = '8' +# The full version, including alpha/beta/rc tags. +release = '8' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build', 'analyzer'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'friendly' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'haiku' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +html_context = { + 'css_files': [ + '_static/lldb.css' + ], + } + + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'LLDBdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'LLDB.tex', u'LLDB Documentation', + u'The LLDB Team', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'LLDB', u'LLDB Documentation', + u'The LLDB Team', 'LLDB', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000000..c95269824ea7 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,63 @@ +.. title:: Welcome to LLDB's documentation! + +LLDB +==== + +LLDB is a next generation, high-performance debugger. It is built as a set of +reusable components which highly leverage existing libraries in the larger LLVM +Project, such as the Clang expression parser and LLVM disassembler. + +LLDB is the default debugger in Xcode on Mac OS X and supports debugging C, +Objective-C and C++ on the desktop and iOS devices and simulator. + +All of the code in the LLDB project is available under the standard +`LLVM License `__, +an open source "BSD-style" license. + + +Goals & Status +============== + +.. toctree:: + :maxdepth: 1 + + status/about + status/goals + status/features + status/status + status/projects + +Use & Extension +=============== + +.. toctree:: + :maxdepth: 1 + + use/tutorial + use/map + use/formatting + use/variable + use/symbolication + use/symbols + use/python + use/remote + use/troubleshooting + use/architecture + +Resources +========= + +.. toctree:: + :maxdepth: 1 + + resources/download + resources/build + resources/test + resources/sbapi + resources/external + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` diff --git a/docs/lldb-platform-packets.txt b/docs/lldb-platform-packets.txt new file mode 100644 index 000000000000..3258e4c0dd88 --- /dev/null +++ b/docs/lldb-platform-packets.txt @@ -0,0 +1,404 @@ +Here is a brief overview of the packets that an lldb platform server +needs to implement for the lldb testsuite to be run on a remote +target device/system. + +These are almost all lldb extensions to the gdb-remote serial +protocol. Many of the vFile: packets are described to the "Host +I/O Packets" detailed in the gdb-remote protocol documentation, +although the lldb platform extensions include packets that are not +defined there (vFile:size:, vFile:mode:, vFile:symlink, vFile:chmod:). +Most importantly, the flags that lldb passes to vFile:open: are +incompatible with the flags that gdb specifies. + + +//---------------------------------------------------------------------- +// QStartNoAckMode +// +// BRIEF +// A request to stop sending ACK packets for each properly formatted packet. +// +// EXAMPLE +// A platform session will typically start like this: +// +// receive: +$QStartNoAckMode#b0 +// send: + <-- ACKing the properly formatted QStartNoAckMode packet +// send: $OK#9a +// receive: + <-- Our OK packet getting ACKed +// +// ACK mode is now disabled. + +//---------------------------------------------------------------------- +// qHostInfo +// +// BRIEF +// Describe the hardware and OS of the target system +// +// EXAMPLE +// +// receive: qHostInfo +// send: cputype:16777228;cpusubtype:1;ostype:ios;watchpoint_exceptions_received:before;os_version:12.1;vendor:apple;default_packet_timeout:5; +// +// All numbers are base 10, os_version is a string that will be parsed as major.minor.patch. + +//---------------------------------------------------------------------- +// qModuleInfo +// +// BRIEF +// Report information about a binary on the target system +// +// EXAMPLE +// receive: qModuleInfo:2f62696e2f6c73; +// +// FIXME finish this packet description, v. GDBRemoteCommunicationServerCommon::Handle_qModuleInfo + + +//---------------------------------------------------------------------- +// qGetWorkingDir +// +// BRIEF +// Get the current working directory of the platform stub in +// ASCII hex encoding. +// +// EXAMPLE +// +// receive: qGetWorkingDir +// send: 2f4170706c65496e7465726e616c2f6c6c64622f73657474696e67732f342f5465737453657474696e67732e746573745f646973617373656d626c65725f73657474696e6773 + + + +//---------------------------------------------------------------------- +// QSetWorkingDir: +// +// BRIEF +// Set the current working directory of the platform stub in +// ASCII hex encoding. +// +// EXAMPLE +// +// receive: QSetWorkingDir:2f4170706c65496e7465726e616c2f6c6c64622f73657474696e67732f342f5465737453657474696e67732e746573745f646973617373656d626c65725f73657474696e6773 +// send: OK + +//---------------------------------------------------------------------- +// qPlatform_mkdir: +// +// BRIEF +// Create a directory on the target system. +// +// EXAMPLE +// +// receive: qPlatform_mkdir:000001fd,2f746d702f6131 +// send: F0 +// +// request packet has the fields: +// 1. mode bits in base 16 +// 2. file path in ascii-hex encoding +// +// response is F followed by the return value of the mkdir() call, +// base 10 encoded. + +//---------------------------------------------------------------------- +// qPlatform_shell: +// +// BRIEF +// Run a shell command on the target system, return the output. +// +// EXAMPLE +// +// receive: qPlatform_shell:6c73202f746d702f,0000000a +// send: F,0,0, +// +// request packet has the fields: +// 1. shell command ascii-hex encoded +// 2. timeout +// 3. {optional} working directory ascii-hex encoded +// +// Response is F followed by the return value of the command (base 16), +// followed by a another number, followed by the output of the command +/ in binary-escaped-data encoding. + +//---------------------------------------------------------------------- +// qLaunchGDBServer +// +// BRIEF +// Start a gdbserver process (gdbserver, debugserver, lldb-server) +// on the target system. +// +// EXAMPLE +// +// receive: qLaunchGDBServer;host:; +// send: pid:1337;port:43001; +// +// request packet hostname field is not ascii-hex encoded. Hostnames +// don't have $ or # characters in them. +// +// response to the packet is the pid of the newly launched gdbserver, +// and the port it is listening for a connection on. +// +// When the testsuite is running, lldb may use the pid to kill off a +// debugserver that doesn't seem to be responding, etc. + +//---------------------------------------------------------------------- +// qKillSpawnedProcess: +// +// BRIEF +// Kill a process running on the target system. +// +// EXAMPLE +// +// receive: qKillSpawnedProcess:1337 +// send: OK +// +// The request packet has the process ID in base 10. + +//---------------------------------------------------------------------- +// qProcessInfoPID: +// +// BRIEF +// Gather information about a process running on the target +// +// EXAMPLE +// +// receive: qProcessInfoPID:71964 +// send: pid:71964;name:612e6f7574; +// +// The request packet has the pid encoded in base 10. +// +// The reply has semicolon-separated name:value fields, two are +// shown here. pid is base 10 encoded. name is ascii hex encoded. +// lldb-server can reply with many additional fields, but I think +// this is enough for the testsuite. + +//---------------------------------------------------------------------- +// qfProcessInfo: +// +// BRIEF +// Search the process table for processes matching criteria, +// respond with them in multiple packets. +// +// EXAMPLE +// +// receive: qfProcessInfo:name_match:equals;name:6e6f70726f6365737365786973747377697468746869736e616d65; +// send: pid:3500;name:612e6f7574; +// +// The request packet has a criteria to search for, followed by +// a specific name. Other name_match: values include +// starts_with, ends_with, contains, regex. You can specify a pid +// to search for, a uid, all_users, triple, etc etc. The testsuite +// only ever searches for name_match:equals. +// +// The response should include any information about the process that +// can be retrieved in semicolon-separated name:value fields. +// In this example, pid is base 10, name is ascii-hex encoded. +// The testsuite seems to only require these two. +// +// This packet only responds with one process. To get further matches to +// the search, qsProcessInfo should be sent. +// +// If no process match is found, Exx should be returned. + +//---------------------------------------------------------------------- +// qsProcessInfo +// +// BRIEF +// Return the next process info found by the most recent qfProcessInfo: +// packet. +// +// EXAMPLE +// +// Continues to return the results of the qfProcessInfo. Once all matches +// have been sent, Exx is returned to indicate end of matches. + +//---------------------------------------------------------------------- +// vFile:size: +// +// BRIEF +// Get the size of a file on the target system, filename in ASCII hex. +// +// EXAMPLE +// +// receive: vFile:size:2f746d702f61 +// send: Fc008 +// +// response is "F" followed by the file size in base 16. +// "F-1,errno" with the errno if an error occurs. + + +//---------------------------------------------------------------------- +// vFile:mode: +// +// BRIEF +// Get the mode bits of a file on the target system, filename in ASCII hex. +// +// EXAMPLE +// +// receive: vFile:mode:2f746d702f61 +// send: F1ed +// +// response is "F" followed by the mode bits in base 16, this 0x1ed would +// correspond to 0755 in octal. +// "F-1,errno" with the errno if an error occurs. + +//---------------------------------------------------------------------- +// vFile:unlink: +// +// BRIEF +// Remove a file on the target system. +// +// EXAMPLE +// +// receive: vFile:unlink:2f746d702f61 +// send: F0 +// +// Argument is a file path in ascii-hex encoding. +// Response is "F" plus the return value of unlink(), base 10 encoding. + +//---------------------------------------------------------------------- +// vFile:symlink: +// +// BRIEF +// Create a symbolic link (symlink, soft-link) on the target system. +// +// EXAMPLE +// +// receive: vFile:symlink:, +// send: F0,0 +// +// Argument file paths are in ascii-hex encoding. +// Response is "F" plus the return value of symlink(), base 10 encoding, twice. + +//---------------------------------------------------------------------- +// vFile:chmod: +// qPlatform_chmod: +// +// BRIEF +// Change the permission mode bits on a file on the target +// +// EXAMPLE +// +// receive: vFile:chmod:180,2f746d702f61 +// send: F0 +// +// Arguments are the mode bits to set, base 16, and a file path in +// ascii-hex encoding. +// Response is "F" plus the return value of chmod(), base 10 encoding. +// +// I don't know why there are two packets for the same thing, v. +// vFile:chmod:. + +//---------------------------------------------------------------------- +// vFile:chmod: +// +// BRIEF +// Change the permission mode bits on a file on the target +// +// EXAMPLE +// +// receive: vFile:chmod:180,2f746d702f61 +// send: F0 +// +// Arguments are the mode bits to set, base 16, and a file path in +// ascii-hex encoding. +// Response is "F" plus the return value of chmod(), base 10 encoding. + + +//---------------------------------------------------------------------- +// vFile:open: +// +// BRIEF +// Open a file on the remote system and return the file descriptor of it. +// +// EXAMPLE +// +// receive: vFile:open:2f746d702f61,00000001,00000180 +// send: F8 +// +// request packet has the fields: +// 1. ASCII hex encoded filename +// 2. flags passed to the open call, base 16. +// Note that these are not the oflags that open(2) takes, but +// are the constant values in enum OpenOptions from lldb's File.h +// 3. mode bits, base 16 +// +// response is F followed by the opened file descriptor in base 10. +// "F-1,errno" with the errno if an error occurs. +// +// COMPATABILITY +// The gdb-remote serial protocol documentatio defines a vFile:open: +// packet which uses incompatible flag values, e.g. 1 means O_WRONLY +// in gdb's vFile:open:, but it means eOpenOptionRead to lldb's +// implementation. + +//---------------------------------------------------------------------- +// vFile:close: +// +// BRIEF +// Close a previously opened file descriptor. +// +// EXAMPLE +// +// receive: vFile:close:7 +// send: F0 +// +// File descriptor is in base 10. +// "F-1,errno" with the errno if an error occurs. + + +//---------------------------------------------------------------------- +// vFile:pread: +// +// BRIEF +// Read data from an opened file descriptor. +// +// EXAMPLE +// +// receive: vFile:pread:7,1024,0 +// send: F4;a'b\00 +// +// request packet has the fields: +// 1. file descriptor, base 10 +// 2. number of bytes to be read, base 10 +// 3. offset into file to start from, base 10 +// +// Response is F, followed by the number of bytes read (base 10), a +// semicolon, followed by the data in the binary-escaped-data encoding. + + +//---------------------------------------------------------------------- +// vFile:pwrite: +// +// BRIEF +// Write data to a previously opened file descriptor. +// +// EXAMPLE +// +// receive: vFile:pwrite:8,0,\cf\fa\ed\fe\0c\00\00 +// send: F1024 +// +// request packet has the fields: +// 1. file descriptor, base 10 +// 2. offset into file to start from, base 10 +// 3. binary-escaped-data to be written +// +// Response is F, followed by the number of bytes written (base 10) + + + + + + +Finally, the platform must be able to launch processes so that debugserver +can attach to them. To do this, the following packets should be handled: + +QSetDisableASLR +QSetDetachOnError +QSetSTDOUT +QSetSTDERR +QSetSTDIN +QEnvironment +QEnvironmentHexEncoded +A +qLaunchSuccess +qProcessInfo + +Most of these are documented in the standard gdb-remote protocol +and/or the lldb-gdb-remote.txt documentation. diff --git a/docs/resources/build.rst b/docs/resources/build.rst new file mode 100644 index 000000000000..5628a32abe5f --- /dev/null +++ b/docs/resources/build.rst @@ -0,0 +1,516 @@ +Build +===== + +.. contents:: + :local: + +Building LLDB on Windows +------------------------ + +**Required Dependencies** + +* Visual Studio 2015 or greater +* Windows SDK 8.0 or higher. In general it is best to use the latest available version. +* `Python 3.5 or higher `_ or + higher. Earlier versions of Python can be made to work by compiling your own + distribution from source, but this workflow is unsupported and you are own + your own. +* `Ninja build tool `_ (strongly recommended) +* `GnuWin32 `_ +* `SWIG for Windows `_ (version 3+) + + +**Optional Dependencies** + +* `Python Tools for Visual Studio + `_. If you plan to debug test + failures or even write new tests at all, PTVS is an indispensable debugging + extension to VS that enables full editing and debugging support for Python + (including mixed native/managed debugging) + +**Preliminaries** + +This section describes how to set up your system and install the required +dependencies such that they can be found when needed during the build process. +The steps outlined here only need to be performed once. + +#. Install Visual Studio and the Windows SDK. +#. Install GnuWin32, making sure ``\bin`` is added to + your PATH environment variable. +#. Install SWIG for Windows, making sure ```` is added to + your PATH environment variable. + +**Building LLDB** + +Any command prompt from which you build LLDB should have a valid Visual Studio +environment setup. This means you should run ``vcvarsall.bat`` or open an +appropriate Visual Studio Command Prompt corresponding to the version you wish +to use. + + +Finally, when you are ready to build LLDB, generate CMake with the following +command line: + +:: + + cmake -G Ninja + + +and run ``ninja`` to build LLDB. Information about running the LLDB test suite +can be found on the test page. + + +Following is a description of some of the most important CMake variables which +you are likely to encounter. A variable FOO is set by adding ``-DFOO=value`` to +the CMake command line. + +* ``LLDB_TEST_DEBUG_TEST_CRASHES`` (Default=0): If set to 1, will cause Windows + to generate a crash dialog whenever lldb.exe or the python extension module + crashes while running the test suite. If set to 0, LLDB will silently crash. + Setting to 1 allows a developer to attach a JIT debugger at the time of a + crash, rather than having to reproduce a failure or use a crash dump. +* ``PYTHON_HOME`` (Required): Path to the folder where the Python distribution + is installed. For example, ``C:\Python35``. +* ``LLDB_RELOCATABLE_PYTHON`` (Default=0): When this is 0, LLDB will bind + statically to the location specified in the ``PYTHON_HOME`` CMake variable, + ignoring any value of ``PYTHONHOME`` set in the environment. This is most + useful for developers who simply want to run LLDB after they build it. If you + wish to move a build of LLDB to a different machine where Python will be in a + different location, setting ``LLDB_RELOCATABLE_PYTHON`` to 1 will cause + Python to use its default mechanism for finding the python installation at + runtime (looking for installed Pythons, or using the ``PYTHONHOME`` + environment variable if it is specified). +* ``LLDB_TEST_C_COMPILER`` or ``LLDB_TEST_CXX_COMPILER``: The test suite needs + to be able to find a copy of clang.exe that it can use to compile inferior + programs. Note that MSVC is not supported here, it must be a path to a clang + executable. Note that using a release clang.exe is strongly recommended here, + as it will make the test suite run much faster. This can be a path to any + recent clang.exe, including one you built yourself. These variables are + ignored unless the respective ``LLDB_TEST_USE_CUSTOM_C_COMPILER`` and + ``LLDB_TEST_USE_CUSTOM_CXX_COMPILER`` are set to ON. + +Sample command line: + +:: + + cmake -G Ninja -DLLDB_TEST_DEBUG_TEST_CRASHES=1 -DPYTHON_HOME=C:\Python35 -DLLDB_TEST_USE_CUSTOM_C_COMPILER=ON -DLLDB_TEST_C_COMPILER=d:\src\llvmbuild\ninja_release\bin\clang.exe ..\..\llvm + + +**Working with both Ninja and MSVC** + +Compiling with ninja is both faster and simpler than compiling with MSVC, but +chances are you still want to debug LLDB with MSVC (at least until we can debug +LLDB on Windows with LLDB!). One solution to this is to run cmake twice and +generate the output into two different folders. One for compiling (the ninja +folder), and one for editing / browsing / debugging (the MSVC folder). + +To do this, simply run ``cmake -G Ninja `` from one folder, and +``cmake -G "Visual Studio 14 2015" `` in another folder. Then you +can open the .sln file in Visual Studio, set lldb as the startup project, and +use F5 to run it. You need only edit the project settings to set the executable +and the working directory to point to binaries inside of the ninja tree. + +Building LLDB on macOS +---------------------- + +There are two ways to build LLDB on Mac OS X: Using Xcode and using CMake + +**Preliminaries** + +* Xcode 4.3 or newer requires the "Command Line Tools" component (XCode->Preferences->Downloads->Components). +* Mac OS X Lion or newer requires installing `Swig `_. + +**Building LLDB with Xcode** + +Building on Mac OS X with Xcode is as easy as downloading the code and building +the Xcode project or workspace: + +* Download the lldb sources. +* Follow the code signing instructions in ``lldb/docs/code-signing.txt``. +* In Xcode 3.x: ``lldb/lldb.xcodeproj``, select the lldb-tool target, and build. +* In Xcode 4.x: ``lldb/lldb.xcworkspace``, select the lldb-tool scheme, and build. + +**Building LLDB with CMake** + +First download the LLVM, Clang, libc++ and LLDB sources. Refer to this page for +precise instructions on this step. + +Refer to the code signing instructions in ``lldb/docs/code-signing.txt`` for +info on codesigning debugserver during the build. + +Using CMake is documented on the `Building LLVM with CMake +`_ page. Ninja is the recommended generator to +use when building LLDB with CMake. + +:: + + > cmake $PATH_TO_LLVM -G Ninja + > ninja lldb + +As noted in the "Building LLVM with CMake" page mentioned above, you can pass +variables to cmake to change build behavior. If LLDB is built as a part of +LLVM, then you can pass LLVM-specific CMake variables to cmake when building +LLDB. + + +Here are some commonly used LLDB-specific CMake variables: + +* ``LLDB_EXPORT_ALL_SYMBOLS:BOOL`` : Exports all symbols. Useful in conjunction + with CMAKE_BUILD_TYPE=Debug. +* ``LLDB_BUILD_FRAMEWORK:BOOL`` : Builds LLDB.framework as Xcode would +* ``LLDB_CODESIGN_IDENTITY:STRING`` : Determines the codesign identity to use. + An empty string means skip building debugserver to avoid codesigning. + +Building LLDB on Linux, FreeBSD and NetBSD +------------------------------------------ + +This document describes the steps needed to compile LLDB on most Linux systems, +FreeBSD and NetBSD. + +**Preliminaries** + +LLDB relies on many of the technologies developed by the larger LLVM project. +In particular, it requires both Clang and LLVM itself in order to build. Due to +this tight integration the Getting Started guides for both of these projects +come as prerequisite reading: + +* `LLVM `_ +* `Clang `_ + +Supported compilers for building LLDB on Linux include: + +* Clang 3.2 +* GCC 4.6.2 (later versions should work as well) + +It is recommended to use libstdc++ 4.6 (or higher) to build LLDB on Linux, but +using libc++ is also known to work. + +On FreeBSD the base system Clang and libc++ may be used to build LLDB, or the +GCC port or package. + +On NetBSD the base system GCC and libstdc++ are used to build LLDB, Clang/LLVM +and libc++ should also work. + +In addition to any dependencies required by LLVM and Clang, LLDB needs a few +development packages that may also need to be installed depending on your +system. The current list of dependencies are: + +* `Swig `_ +* `libedit (Linux only) `_ +* `Python `_ + + +So for example, on a Fedora system one might run: + +:: + + > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig + +On a Debian or Ubuntu system one might run: + +:: + + > sudo apt-get install build-essential subversion swig python2.7-dev libedit-dev libncurses5-dev + +or + +:: + + > sudo apt-get build-dep lldb-3.3 # or lldb-3.4 + + +On FreeBSD one might run: + +:: + + > pkg install swig python + +On NetBSD one might run: + +:: + + > pkgin install swig python27 cmake ninja-build + + +If you wish to build the optional reference documentation, additional dependencies are required: + +* Graphviz (for the 'dot' tool). +* doxygen (only if you wish to build the C++ API reference) +* epydoc (only if you wish to build the Python API reference) + + +To install the prerequisites for building the documentation (on Debian/Ubuntu) do: + +:: + + > sudo apt-get install doxygen graphviz + > sudo pip install epydoc # or install package python-epydoc + + +**Building LLDB** + +We first need to checkout the source trees into the appropriate locations. Both +Clang and LLDB build as subprojects of LLVM. This means we will be checking out +the source for both Clang and LLDB into the tools subdirectory of LLVM. We will +be setting up a directory hierarchy looking something like this: + +:: + + llvm + | + `-- tools + | + +-- clang + | + `-- lldb + +For reference, we will call the root of the LLVM project tree $llvm, and the +roots of the Clang and LLDB source trees $clang and $lldb respectively. + +Change to the directory where you want to do development work and checkout +LLVM: + +:: + + > svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm + + +Now switch to LLVM’s tools subdirectory and checkout both Clang and LLDB: + +:: + + > cd $llvm/tools + > svn co http://llvm.org/svn/llvm-project/cfe/trunk clang + > svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb + +In general, building the LLDB trunk revision requires trunk revisions of both +LLVM and Clang. + +It is highly recommended that you build the system out of tree. Create a second +build directory and configure the LLVM project tree to your specifications as +outlined in LLVM’s Getting Started Guide. A typical build procedure might be: + +:: + + > cd $llvm/.. + > mkdir build + > cd build + +**To build with CMake** + + +Using CMake is documented on the `Building LLVM with CMake +`_ page. Building LLDB is possible using one +of the following generators: + +* Ninja +* Unix Makefiles + +**Using CMake + Ninja** + +Ninja is the fastest way to build LLDB! In order to use ninja, you need to have +recent versions of CMake and ninja on your system. To build using ninja: + +:: + + > cmake ../llvm -G Ninja + > ninja lldb + > ninja check-lldb + + +If you want to debug the lldb that you're building -- that is, build it with +debug info enabled -- pass two additional arguments to cmake before running +ninja: + +:: + + > cmake ../llvm -G Ninja -DLLDB_EXPORT_ALL_SYMBOLS=1 -DCMAKE_BUILD_TYPE=Debug + + +**Using CMake + Unix Makefiles** + +If you do not have Ninja, you can still use CMake to generate Unix Makefiles that build LLDB: + +:: + + > cmake .. + > make + > make check-lldb + + +**Building API reference documentation** + +LLDB exposes a C++ as well as a Python API. To build the reference +documentation for these two APIs, ensure you have the required dependencies +installed, and build the ``lldb-python-doc`` and ``lldb-cpp-doc`` CMake +targets. + +The output HTML reference documentation can be found in +``/tools/lldb/docs/``. + +**Additional Notes** + +LLDB has a Python scripting capability and supplies its own Python module named +lldb. If a script is run inside the command line lldb application, the Python +module is made available automatically. However, if a script is to be run by a +Python interpreter outside the command line application, the ``PYTHONPATH`` +environment variable can be used to let the Python interpreter find the lldb +module. + +Current stable NetBSD release doesn't ship with libpanel(3), therefore it's +required to disable curses(3) support with the +``-DLLDB_DISABLE_CURSES:BOOL=TRUE`` option. To make sure check if +``/usr/include/panel.h`` exists in your system. + +The correct path can be obtained by invoking the command line lldb tool with +the -P flag: + +:: + + > export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P` + +If you used a different build directory or made a release build, you may need +to adjust the above to suit your needs. To test that the lldb Python module is +built correctly and is available to the default Python interpreter, run: + +:: + + > python -c 'import lldb' + +**Cross-compiling LLDB** + + +In order to debug remote targets running different architectures than your +host, you will need to compile LLDB (or at least the server component) for the +target. While the easiest solution is to just compile it locally on the target, +this is often not feasible, and in these cases you will need to cross-compile +LLDB on your host. + +Cross-compilation is often a daunting task and has a lot of quirks which depend +on the exact host and target architectures, so it is not possible to give a +universal guide which will work on all platforms. However, here we try to +provide an overview of the cross-compilation process along with the main things +you should look out for. + +First, you will need a working toolchain which is capable of producing binaries +for the target architecture. Since you already have a checkout of clang and +lldb, you can compile a host version of clang in a separate folder and use +that. Alternatively you can use system clang or even cross-gcc if your +distribution provides such packages (e.g., ``g++-aarch64-linux-gnu`` on +Ubuntu). + +Next, you will need a copy of the required target headers and libraries on your +host. The libraries can be usually obtained by copying from the target machine, +however the headers are often not found there, especially in case of embedded +platforms. In this case, you will need to obtain them from another source, +either a cross-package if one is available, or cross-compiling the respective +library from source. Fortunately the list of LLDB dependencies is not big and +if you are only interested in the server component, you can reduce this even +further by passing the appropriate cmake options, such as: + +:: + + -DLLDB_DISABLE_LIBEDIT=1 + -DLLDB_DISABLE_CURSES=1 + -DLLDB_DISABLE_PYTHON=1 + -DLLVM_ENABLE_TERMINFO=0 + +In this case you, will often not need anything other than the standard C and +C++ libraries. + +Once all of the dependencies are in place, it's just a matter of configuring +the build system with the locations and arguments of all the necessary tools. +The most important cmake options here are: + +* ``CMAKE_CROSSCOMPILING`` : Set to 1 to enable cross-compilation. +* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking + for libraries. You may need to set this to your architecture triple if you do + not specify all your include and library paths explicitly. +* ``CMAKE_C_COMPILER``, ``CMAKE_CXX_COMPILER`` : C and C++ compilers for the + target architecture +* ``CMAKE_C_FLAGS``, ``CMAKE_CXX_FLAGS`` : The flags for the C and C++ target + compilers. You may need to specify the exact target cpu and abi besides the + include paths for the target headers. +* ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually + just a list of library search paths referencing the target libraries. +* ``LLVM_TABLEGEN``, ``CLANG_TABLEGEN`` : Paths to llvm-tblgen and clang-tblgen + for the host architecture. If you already have built clang for the host, you + can point these variables to the executables in your build directory. If not, + you will need to build the llvm-tblgen and clang-tblgen host targets at + least. +* ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server) + will run on. Not setting this (or setting it incorrectly) can cause a lot of + issues with remote debugging as a lot of the choices lldb makes depend on the + triple reported by the remote platform. + +You can of course also specify the usual cmake options like +``CMAKE_BUILD_TYPE``, etc. + +**Example 1: Cross-compiling for linux arm64 on Ubuntu host** + +Ubuntu already provides the packages necessary to cross-compile LLDB for arm64. +It is sufficient to install packages ``gcc-aarch64-linux-gnu``, +``g++-aarch64-linux-gnu``, ``binutils-aarch64-linux-gnu``. Then it is possible +to prepare the cmake build with the following parameters: + +:: + + -DCMAKE_CROSSCOMPILING=1 \ + -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ + -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \ + -DLLVM_TABLEGEN=/bin/llvm-tblgen \ + -DCLANG_TABLEGEN=/bin/clang-tblgen \ + -DLLDB_DISABLE_PYTHON=1 \ + -DLLDB_DISABLE_LIBEDIT=1 \ + -DLLDB_DISABLE_CURSES=1 + +An alternative (and recommended) way to compile LLDB is with clang. +Unfortunately, clang is not able to find all the include paths necessary for a +successful cross-compile, so we need to help it with a couple of CFLAGS +options. In my case it was sufficient to add the following arguments to +``CMAKE_C_FLAGS`` and ``CMAKE_CXX_FLAGS`` (in addition to changing +``CMAKE_C(XX)_COMPILER`` to point to clang compilers): + +:: + + -target aarch64-linux-gnu \ + -I /usr/aarch64-linux-gnu/include/c++/4.8.2/aarch64-linux-gnu \ + -I /usr/aarch64-linux-gnu/include + +If you wanted to build a full version of LLDB and avoid passing +``-DLLDB_DISABLE_PYTHON`` and other options, you would need to obtain the +target versions of the respective libraries. The easiest way to achieve this is +to use the qemu-debootstrap utility, which can prepare a system image using +qemu and chroot to simulate the target environment. Then you can install the +necessary packages in this environment (python-dev, libedit-dev, etc.) and +point your compiler to use them using the correct -I and -L arguments. + +**Example 2: Cross-compiling for Android on Linux** + +In the case of Android, the toolchain and all required headers and libraries +are available in the Android NDK. + +The NDK also contains a cmake toolchain file, which makes configuring the build +much simpler. The compiler, include and library paths will be configured by the +toolchain file and all you need to do is to select the architecture +(ANDROID_ABI) and platform level (``ANDROID_PLATFORM``, should be at least 21). +You will also need to set ``ANDROID_ALLOW_UNDEFINED_SYMBOLS=On``, as the +toolchain file defaults to "no undefined symbols in shared libraries", which is +not compatible with some llvm libraries. The first version of NDK which +supports this approach is r14. + +For example, the following arguments are sufficient to configure an android +arm64 build: + +:: + + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ + -DANDROID_ABI=arm64-v8a \ + -DANDROID_PLATFORM=android-21 \ + -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On \ + -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android \ + -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_C_COMPILER=cc;-DCMAKE_CXX_COMPILER=c++' + +Note that currently only lldb-server is functional on android. The lldb client +is not supported and unlikely to work. diff --git a/docs/resources/download.rst b/docs/resources/download.rst new file mode 100644 index 000000000000..37fcb35f06ff --- /dev/null +++ b/docs/resources/download.rst @@ -0,0 +1,34 @@ +Download +======== + +Nightly Builds +-------------- + +Nightly builds of LLDB are packaged and tested from trunk: + +Debian and Ubuntu: llvm.org/apt + +The pkgsrc framework offers a package with recent LLDB in the wip repository: + +:: + + cd pkgsrc/wip/lldb-git + make install clean + +Releases +-------- + +Debian packages are available for LLDB 3.5 and later. + +* `Jessie - LLDB 3.5 `_ +* `Stretch - LLDB 3.8 `_ +* `Buster - LLDB 6.0 `_ +* `Sid - LLDB 6.0 `_ + +Ubuntu packages are available for LLDB 3.8 and later. + +* `Ubuntu 16.04LTS - LLDB 3.8 `_ +* `Ubuntu 18.04LTS - LLDB 6.0 `_ + +Arch Linux packages the latest `LLDB 6.0 +`_. diff --git a/docs/resources/external.rst b/docs/resources/external.rst new file mode 100644 index 000000000000..ab7e54c6d73f --- /dev/null +++ b/docs/resources/external.rst @@ -0,0 +1,19 @@ +External Resources +================== + +Documentation +------------- + +* `Python API Documentation `_ +* `C++ API Documentation `_ + +Bugs +---- + +* `Bug Reports `_ + +Source +------ + +* `Browse SVN `_ +* `Browse ViewVNC `_ diff --git a/docs/resources/sbapi.rst b/docs/resources/sbapi.rst new file mode 100644 index 000000000000..20c332990c1f --- /dev/null +++ b/docs/resources/sbapi.rst @@ -0,0 +1,55 @@ +The SB API Coding Rules +======================= + +The SB APIs constitute the stable C++ API that lldb presents to external +clients, and which get processed by SWIG to produce the Python bindings to +lldb. As such it is important that they not suffer from the binary +incompatibilities that C++ is so susceptible to. We've established a few rules +to ensure that this happens. + +The classes in the SB API's are all called SB, where SomeName is in +CamelCase starting with an upper case letter. The method names are all +CamelCase with initial capital letter as well. + +All the SB API classes are non-virtual, single inheritance classes. They should +only include SBDefines.h or other SB headers as needed. There should be no +inlined method implementations in the header files, they should all be in the +implementation files. And there should be no direct ivar access. + +You also need to choose the ivars for the class with care, since you can't add +or remove ivars without breaking binary compatibility. In some cases, the SB +class is a thin wrapper around an internal lldb_private object. In that case, +the class can have a single ivar, which is either a pointer, shared_ptr or +unique_ptr to the object in the lldb_private API. All the lldb_private classes +that get used this way are declared as opaque classes in lldb_forward.h, which +is included in SBDefines.h. So if you need an SB class to wrap an lldb_private +class that isn't in lldb_forward.h, add it there rather than making a direct +opaque declaration in the SB classes .h file. + +If the SB Class needs some state of its own, as well as the backing object, +don't include that as a direct ivar in the SB Class. Instead, make an Impl +class in the SB's .cpp file, and then make the SB object hold a shared or +unique pointer to the Impl object. The theory behind this is that if you need +more state in the SB object, those needs are likely to change over time, and +this way the Impl class can pick up members without changing the size of the +object. An example of this is the SBValue class. Please note that you should +not put this Impl class in the lldb namespace. Failure to do so leads to +leakage of weak-linked symbols in the SBAPI. + +In order to fit into the Python API's, we need to be able to default construct +all the SB objects. Since the ivars of the classes are all pointers of one sort +or other, this can easily be done, but it means all the methods must be +prepared to handle their opaque implementation pointer being empty, and doing +something reasonable. We also always have an "IsValid" method on all the SB +classes to report whether the object is empty or not. + +Another piece of the SB API infrastructure is the Python (or other script +interpreter) customization. SWIG allows you to add property access, iterators +and documentation to classes, but to do that you have to use a Swig interface +file in place of the .h file. Those files have a different format than a +straight C++ header file. These files are called SB.i, and live in +"scripts/interface". They are constructed by starting with the associated .h +file, and adding documentation and the Python decorations, etc. We do this in a +decidedly low-tech way, by maintaining the two files in parallel. That +simplifies the build process, but it does mean that if you add a method to the +C++ API's for an SB class, you have to copy the interface to the .i file. diff --git a/docs/resources/test.rst b/docs/resources/test.rst new file mode 100644 index 000000000000..67cebd717590 --- /dev/null +++ b/docs/resources/test.rst @@ -0,0 +1,164 @@ +Testing LLDB +============ + +The LLDB test suite consists of Python scripts located under the test +directory. Each script contains a number of test cases and is usually +accompanied by a C (C++, ObjC, etc.) source file. Each test first compiles the +source file and then uses LLDB to debug the resulting executable. The tests +verify both the LLDB command line interface and the scripting API. + +.. contents:: + :local: + +Running the Full Test Suite +--------------------------- + +**Windows Note**: In the examples that follow, any invocations of python should +be replaced with python_d, the debug interpreter, when running the test suite +against a debug version of LLDB. + +The easiest way to run the LLDB test suite is to use the ``check-lldb`` build +target. By default, the ``check-lldb`` target builds the test programs with the +same compiler that was used to build LLDB. To build the tests with a different +compiler, you can set the ``LLDB_TEST_C_COMPILER`` or the ``LLDB_TEST_CXX_COMPILER`` +CMake variables. These variables are ignored unless the respective +``LLDB_TEST_USE_CUSTOM_C_COMPILER`` and ``LLDB_TEST_USE_CUSTOM_CXX_COMPILER`` are set +to ``ON``. + +It is possible to customize the architecture of the test binaries and compiler +used by appending ``-A`` and ``-C`` options respectively to the CMake variable +``LLDB_TEST_USER_ARGS``. For example, to test LLDB against 32-bit binaries +built with a custom version of clang, do: + +:: + + > cmake -DLLDB_TEST_USER_ARGS="-A i386 -C /path/to/custom/clang" -G Ninja + > ninja check-lldb + +Note that multiple ``-A`` and ``-C`` flags can be specified to +``LLDB_TEST_USER_ARGS``. + +Note that on NetBSD you must export ``LD_LIBRARY_PATH=$PWD/lib`` in your +environment. This is due to lack of the ``$ORIGIN`` linker feature. + +Running a Specific Test or Set of Tests +--------------------------------------- + +In addition to running all the LLDB test suites with the "check-lldb" CMake target above, it is possible to run individual LLDB tests. For example, to run the test cases defined in TestInferiorCrashing.py, run: + +:: + + > cd $lldb/test + > python dotest.py --executable -p TestInferiorCrashing.py ../packages/Python/lldbsuite/test + +If the test is not specified by name (e.g. if you leave the -p argument off), LLDB will run all tests in that directory: + +:: + + > python dotest.py --executable functionalities/data-formatter + +Many more options that are available. To see a list of all of them, run: + +:: + + > python dotest.py -h + +The ``dotest.py`` script runs tests in parallel by default. To disable the parallel +test running feature, use the ``--no-multiprocess`` flag. The number of concurrent +tests is controlled by the ``LLDB_TEST_THREADS`` environment variable or the +``--threads command`` line parameter. The default value is the number of CPU cores +on your system. + +The parallel test running feature will handle an additional ``--test-subdir +SUBDIR`` arg. When specified, ``SUBDIR`` is relative to the root test directory +and will limit all parallel test running to that subdirectory's tree of tests. + +The parallel test runner will run all tests within a given directory serially, +but will run multiple directories concurrently. Thus, as a test writer, we +provide serialized test run semantics within a directory. Note child +directories are considered entirely separate, so two child directories could be +running in parallel with a parent directory. + +Running the Test Suite Remotely +------------------------------- + +Running the test-suite remotely is similar to the process of running a local +test suite, but there are two things to have in mind: + +1. You must have the lldb-server running on the remote system, ready to accept + multiple connections. For more information on how to setup remote debugging + see the Remote debugging page. +2. You must tell the test-suite how to connect to the remote system. This is + achieved using the ``--platform-name``, ``--platform-url`` and + ``--platform-working-dir`` parameters to ``dotest.py``. These parameters + correspond to the platform select and platform connect LLDB commands. You + will usually also need to specify the compiler and architecture for the + remote system. + +Currently, running the remote test suite is supported only with ``dotest.py`` (or +dosep.py with a single thread), but we expect this issue to be addressed in the +near future. + +Debugging Test Failures +----------------------- + +On non-Windows platforms, you can use the ``-d`` option to ``dotest.py`` which +will cause the script to wait for a while until a debugger is attached. + +Debugging Test Failures on Windows +---------------------------------- + +On Windows, it is strongly recommended to use Python Tools for Visual Studio +for debugging test failures. It can seamlessly step between native and managed +code, which is very helpful when you need to step through the test itself, and +then into the LLDB code that backs the operations the test is performing. + +A quick guide to getting started with PTVS is as follows: + +#. Install PTVS +#. Create a Visual Studio Project for the Python code. + #. Go to File -> New -> Project -> Python -> From Existing Python Code. + #. Choose llvm/tools/lldb as the directory containing the Python code. + #. When asked where to save the .pyproj file, choose the folder ``llvm/tools/lldb/pyproj``. This is a special folder that is ignored by the ``.gitignore`` file, since it is not checked in. +#. Set test/dotest.py as the startup file +#. Make sure there is a Python Environment installed for your distribution. For example, if you installed Python to ``C:\Python35``, PTVS needs to know that this is the interpreter you want to use for running the test suite. + #. Go to Tools -> Options -> Python Tools -> Environment Options + #. Click Add Environment, and enter Python 3.5 Debug for the name. Fill out the values correctly. +#. Configure the project to use this debug interpreter. + #. Right click the Project node in Solution Explorer. + #. In the General tab, Make sure Python 3.5 Debug is the selected Interpreter. + #. In Debug/Search Paths, enter the path to your ninja/lib/site-packages directory. + #. In Debug/Environment Variables, enter ``VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\``. + #. If you want to enabled mixed mode debugging, check Enable native code debugging (this slows down debugging, so enable it only on an as-needed basis.) +#. Set the command line for the test suite to run. + #. Right click the project in solution explorer and choose the Debug tab. + #. Enter the arguments to dotest.py. Note you must add --no-multiprocess + #. Example command options: + +:: + + # quiet mode + -q + --arch=i686 + # Path to debug lldb.exe + --executable D:/src/llvmbuild/ninja/bin/lldb.exe + # Directory to store log files + -s D:/src/llvmbuild/ninja/lldb-test-traces + -u CXXFLAGS -u CFLAGS + # If a test crashes, show JIT debugging dialog. + --enable-crash-dialog + # Path to release clang.exe + -C d:\src\llvmbuild\ninja_release\bin\clang.exe + # Path to the particular test you want to debug. + -p TestPaths.py + # Root of test tree + D:\src\llvm\tools\lldb\packages\Python\lldbsuite\test + # Required in order to be able to debug the test. + --no-multiprocess + +:: + + -q --arch=i686 --executable D:/src/llvmbuild/ninja/bin/lldb.exe -s D:/src/llvmbuild/ninja/lldb-test-traces -u CXXFLAGS -u CFLAGS --enable-crash-dialog -C d:\src\llvmbuild\ninja_release\bin\clang.exe -p TestPaths.py D:\src\llvm\tools\lldb\packages\Python\lldbsuite\test --no-multiprocess + + + diff --git a/docs/status/about.rst b/docs/status/about.rst new file mode 100644 index 000000000000..0a7ea230d2da --- /dev/null +++ b/docs/status/about.rst @@ -0,0 +1,90 @@ +About +===== + +.. contents:: + :local: + +Why a New Debugger? +------------------- + +In order to achieve our goals we decided to start with a fresh architecture +that would support modern multi-threaded programs, handle debugging symbols in +an efficient manner, use compiler based code knowledge and have plug-in support +for functionality and extensions. Additionally we want the debugger +capabilities to be available to other analysis tools, be they scripts or +compiled programs, without requiring them to be GPL. + +Compiler Integration Benefits +----------------------------- + +LLDB currently converts debug information into clang types so that it can +leverage the clang compiler infrastructure. This allows LLDB to support the +latest C, C++, Objective-C and Objective-C++ language features and runtimes in +expressions without having to reimplement any of this functionality. It also +leverages the compiler to take care of all ABI details when making functions +calls for expressions, when disassembling instructions and extracting +instruction details, and much more. + +The major benefits include: + +- Up to date language support for C, C++, Objective-C +- Multi-line expressions that can declare local variables and types +- Utilize the JIT for expressions when supported +- Evaluate expression Intermediate Representation (IR) when JIT can't be used + +Reusability +----------- + +The LLDB debugger APIs are exposed as a C++ object oriented interface in a +shared library. The lldb command line tool links to, and uses this public API. +On Mac OS X the shared library is exposed as a framework named LLDB.framework, +and unix systems expose it as lldb.so. The entire API is also then exposed +through Python script bindings which allow the API to be used within the LLDB +embedded script interpreter, and also in any python script that loads the +lldb.py module in standard python script files. See the Python Reference page +for more details on how and where Python can be used with the LLDB API. + +Sharing the LLDB API allows LLDB to not only be used for debugging, but also +for symbolication, disassembly, object and symbol file introspection, and much +more. + +Platform Support +---------------- + +LLDB is known to work on the following platforms, but ports to new platforms +are welcome: + +* Mac OS X desktop user space debugging for i386 and x86-64 +* iOS simulator debugging on i386 +* iOS device debugging on ARM +* Linux local user-space debugging for i386, x86-64 and PPC64le +* FreeBSD local user-space debugging for i386 and x86-64 +* Windows local user-space debugging for i386 (*) + +(*) Support for Windows is under active development. Basic functionality is +expected to work, with functionality improving rapidly. + +Get Involved +------------ + +To check out the code, use: + +svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb + +Note that LLDB generally builds from top-of-trunk + +* On macOS with Xcode +* On Linux and FreeBSD (with clang and libstdc++/libc++) +* On NetBSD (with GCC and clang and libstdc++/libc++) +* On Windows with VS 2012 or higher using CMake + +See the LLDB Build Page for platform-specific build instructions. + +Discussions about LLDB should go to the `lldb-dev +`__ mailing list. Commit +messages for the lldb SVN module are automatically sent to the `lldb-commits +`__ mailing list , and +this is also the preferred mailing list for patch submissions. + +See the Projects page if you are looking for some interesting areas to +contribute to lldb. diff --git a/docs/status/features.rst b/docs/status/features.rst new file mode 100644 index 000000000000..43eb7408b01c --- /dev/null +++ b/docs/status/features.rst @@ -0,0 +1,18 @@ +Features +======== + +LLDB supports a broad variety of basic debugging features such as reading DWARF, supporting step, next, finish, backtraces, etc. Some more interested bits are: + +* Plug-in architecture for portability and extensibility: + + * Object file parsers for executable file formats. Support currently includes Mach-O (32 and 64-bit) & ELF (32-bit). + * Object container parsers to extract object files contained within a file. Support currently includes universal Mach-O files & BSD Archives. + * Debug symbol file parsers to incrementally extract debug information from object files. Support currently includes DWARF & Mach-O symbol tables. + * Symbol vendor plug-ins collect data from a variety of different sources for an executable object. + * Disassembly plug-ins for each architecture. Support currently includes an LLVM disassembler for i386, x86-64 , ARM/Thumb, and PPC64le + * Debugger plug-ins implement the host and target specific functions required to debug. + +* SWIG-generated script bridging allows Python to access and control the public API of the debugger library. +* A remote protocol server, debugserver, implements Mac OS X debugging on i386 and x86-64. +* A command line debugger - the lldb executable itself. +* A framework API to the library. diff --git a/docs/status/goals.rst b/docs/status/goals.rst new file mode 100644 index 000000000000..e25b945df226 --- /dev/null +++ b/docs/status/goals.rst @@ -0,0 +1,33 @@ +Goals +===== + +The current state of the art in open source debuggers are that they work in the +common cases for C applications, but don't handle many "hard cases" properly. +For example, C++ expression parsing, handling overloading, templates, +multi-threading, and other non-trivial scenarios all work in some base cases, +but don't work reliably. + +The goal of LLDB is to provide an amazing debugging experience that "just +works". We aim to solve these long-standing problems where debuggers get +confused, so that you can think about debugging your problem, not about +deficiencies in the debugger. + +With a long view, there is no good reason for a debugger to reinvent its own +C/C++ parser, type system, know all the target calling convention details, +implement its own disassembler, etc. By using the existing libraries vended by +the LLVM project, we believe that many of these problems will be defined away, +and the debugger can focus on important issues like process control, efficient +symbol reading and indexing, thread management, and other debugger-specific +problems. + +Some more specific goals include: + +* Build libraries for inclusion in IDEs, command line tools, and other analysis + tools +* High performance and efficient memory use +* Extensible: Python scriptable and use a plug-in architecture +* Reuse existing compiler technology where it makes sense +* Excellent multi-threaded debugging support +* Great support for C, Objective-C and C++ +* Retargetable to support multiple platforms +* Provide a base for debugger research and other innovation diff --git a/docs/status/projects.rst b/docs/status/projects.rst new file mode 100644 index 000000000000..5fdea58509e9 --- /dev/null +++ b/docs/status/projects.rst @@ -0,0 +1,396 @@ +Projects +======== + +The following is a mostly unordered set of the ideas for improvements to the +LLDB debugger. Some are fairly deep, some would require less effort. + +.. contents:: + :local: + +Speed up type realization in lldb +--------------------------------- + +The type of problem I'm addressing here is the situation where you are +debugging a large program (lldb built with debug clang/swift will do) and you +go to print a simple expression, and lldb goes away for 30 seconds. When you +sample it, it is always busily churning through all the CU's in the world +looking for something. The problem isn't that looking for something in +particular is slow, but rather that we somehow turned an bounded search (maybe +a subtype of "std::string" into an unbounded search (all things with the name +of that subtype.) Or didn't stop when we got a reasonable answer proximate to +the context of the search, but let the search leak out globally. And quite +likely there are other issues that I haven't guessed yet. But if you end up +churning though 3 or 4 Gig of debug info, that's going to be slow no matter how +well written your debug reader is... + +My guess is the work will be more in the general symbol lookup than in the +DWARF parser in particular, but it may be a combination of both. + +As a user debugging a largish program, this is the most obvious lameness of +lldb. + +Symbol name completion in the expression parser +----------------------------------------------- + +This is the other obvious lameness of lldb. You can do: + +:: + + (lldb) frame var foo.b + +and we will tell you it is "foo.bar". But you can't do that in the expression +parser. This will require collaboration with the clang/swift folks to get the +right extension points in the compiler. And whatever they are, lldb will need +use them to tell the compiler about what names are available. It will be +important to avoid the pitfalls of #1 where we wander into the entire DWARF +world. + +Make a high speed asynchronous communication channel +---------------------------------------------------- + +All lldb debugging nowadays is done by talking to a debug agent. We used the +gdb-remote protocol because that is universal, and good enough, and you have to +support it anyway since so many little devices & JTAG's and VM's etc support +it. But it is really old, not terribly high performance, and can't really +handle sending or receiving messages while the process is supposedly running. +It should have compression built in, remove the hand-built checksums and rely +on the robust communication protocols we always have nowadays, allow for +out-of-order requests/replies, allow for reconnecting to a temporarily +disconnected debug session, regularize all of the packet formatting into JSON +or BSON or whatever while including a way to do large binary transfers. It must +be possible to come up with something faster, and better tunable for the many +communications pathways we end up supporting. + +Fix local variable lookup in the lldb expression parser +------------------------------------------------------- + +The injection of local variables into the clang expression parser is +currently done incorrectly - it happens too late in the lookup. This results +in namespace variables & functions, same named types and ivars shadowing +locals when it should be the other way around. An attempt was made to fix +this by manually inserting all the visible local variables into wrapper +function in the expression text. This mostly gets the job done but that +method means you have to realize all the types and locations of all local +variables for even the simplest of expressions, and when run on large +programs (e.g. lldb) it would cause unacceptable delays. And it was very +fragile since an error in realizing any of the locals would cause all +expressions run in that context to fail. We need to fix this by adjusting +the points where name lookup calls out to lldb in clang. + +Support calling SB & commands everywhere and support non-stop debugging +----------------------------------------------------------------------- + +There is a fairly ad-hoc system to handle when it is safe to run SB API's and +command line commands. This is actually a bit of a tricky problem, since we +allow access to the command line and SB API from some funky places in lldb. The +Operating System plugins are the most obvious instance, since they get run +right after lldb is told by debugserver that the process has stopped, but +before it has finished collating the information from the stop for presentation +to the higher levels. But breakpoint callbacks have some of the same problems, +and other things like the scripted stepping operations and any fancier +extension points we want to add to the debugger are going to be hard to +implement robustly till we work on a finer-grained and more explicit control +over who gets to control the process state. + +We also won't have any chance of supporting non-stop debugging - which is a +useful mode for programs that have a lot of high-priority or real-time worker +threads - until we get this sorted out. + +Finish the language abstraction and remove all the unnecessary API's +-------------------------------------------------------------------- + +An important part of making lldb a more useful "debugger toolkit" as opposed to +a C/C++/ObjC/Swift debugger is to have a clean abstraction for language +support. We did most, but not all, of the physical separation. We need to +finish that. And then by force of necessity the API's really look like the +interface to a C++ type system with a few swift bits added on. How you would +go about adding a new language is unclear and much more trouble than it is +worth at present. But if we made this nice, we could add a lot of value to +other language projects. + +Add some syntax to generate data formatters from type definitions +----------------------------------------------------------------- + +Uses of the data formatters fall into two types. There are data formatters for +types where the structure elements pretty much tell you how to present the +data, you just need a little expression language to express how to turn them +into what the user expects to see. Then there are the ones (like pretty much +all our Foundation/AppKit/UIKit formatters) that use deep magic to figure out +how the type is actually laid out. The latter are pretty much always going to +have to be done by hand. + +But for the ones where the information is expressed in the fields, it would be +great to have a way to express the instructions to produce summaries and +children in some form you could embed next to the types and have the compiler +produce a byte code form of the instructions and then make that available to +lldb along with the library. This isn't as simple as having clang run over the +headers and produce something from the types directly. After all, clang has no +way of knowing that the interesting thing about a std::vector is the elements +that you get by calling size (for the summary) and [] for the elements. But it +shouldn't be hard to come up with a generic markup to express this. + +Allow the expression parser to access dynamic type/data formatter information +----------------------------------------------------------------------------- + +This seems like a smaller one. The symptom is your object is Foo child of +Bar, and in the Locals view you see all the fields of Foo, but because the +static type of the object is Bar, you can't see any of the fields of Foo. +But if you could get this working, you could hijack the mechanism to make +the results of the value object summaries/synthetic children available to +expressions. And if you can do that, you could add other properties to an +object externally (through Python or some other extension point) and then +have these also available in the expression parser. You could use this to +express invariants for data structures, or other more advanced uses of types +in the debugger. + +Another version of this is to allow access to synthetic children in the +expression parser. Otherwise you end up in situations like: + +:: + + (lldb) print return_a_foo() + (SomeVectorLikeType) $1 = { + [0] = 0 + [1] = 1 + [2] = 2 + [3] = 3 + [4] = 4 + } + +That's good but: + +:: + + (lldb) print return_a_foo()[2] + +fails because the expression parser doesn't know anything about the +array-like nature of SomeVectorLikeType that it gets from the synthetic +children. + +Recover thread information lazily +--------------------------------- + +LLDB stores all the user intentions for a thread in the ThreadPlans stored in +the Thread class. That allows us to reliably implement a very natural model for +users moving through a debug session. For example, if step-over stops at a +breakpoint in an function in a younger region of the stack, continue will +complete the step-over rather than having to manually step out. But that means +that it is important that the Thread objects live as long as the Threads they +represent. For programs with many threads, but only one that you are debugging, +that makes stepping less efficient, since now you have to fetch the thread list +on every step or stepping doesn't work correctly. This is especially an issue +when the threads are provided by an Operating System plugin, where it may take +non-trivial work to reconstruct the thread list. It would be better to fetch +threads lazily but keep "unseen" threads in a holding area, and only retire +them when we know we've fetched the whole thread list and ensured they are no +longer alive. + +Add an extension point in the breakpoint search machinery +--------------------------------------------------------- + +This would allow highly customizable, algorithmic breakpoint types, like "break +on every use of some particular instruction, or instruction pattern, etc." + +Make Python-backed commands first class citizens +------------------------------------------------ + +As it stands, Python commands have no way to advertise their options. They are +required to parse their arguments by hand. That leads to inconsistency, and +more importantly means they can't take advantage of auto-generated help and +command completion. This leaves python-backed commands feeling worse than +built-in ones. + +As part of this job, it would also be great to hook automatically hook the +"type" of an option value or argument (e.g. eArgTypeShlibName) to sensible +default completers. You need to be able to over-ride this in more complicated +scenarios (like in "break set" where the presence of a "-s" option limits the +search for completion of a "-n" option.) But in common cases it is unnecessary +busy-work to have to supply the completer AND the type. If this worked, then it +would be easier for Python commands to also get correct completers. + +Reimplement the command interpreter commands using the SB API +------------------------------------------------------------- + +Currently, all the CommandObject::DoExecute methods are implemented using the +lldb_private API's. That generally means that there's code that gets duplicated +between the CommandObject and the SB API that does roughly the same thing. We +would reduce this code duplication, present a single coherent face to the users +of lldb, and keep ourselves more honest about what we need in the SB API's if +we implemented the CommandObjects::DoExecute methods using the SB API's. + +BTW, it is only the way it was much easier to develop lldb if it had a +functioning command-line early on. So we did that first, and developed the SB +API's when lldb was more mature. There's no good technical reason to have the +commands use the lldb_private API's. + +Documentation and better examples +--------------------------------- + +We need to put the lldb syntax docs in the tutorial somewhere that is more +easily accessible. On suggestion is to add non-command based help to the help +system, and then have a "help lldb" or "help syntax" type command with this +info. Be nice if the non-command based help could be hierarchical so you could +make topics. + +There's a fair bit of docs about the SB API's, but it is spotty. Some classes +are well documented in the Python "help (lldb.SBWhatever)" and some are not. + +We need more conceptual docs. And we need more examples. And we could provide a +clean pluggable example for using LLDB standalone from Python. The +process_events.py is a start of this, but it just handles process events, and +it is really a quick sketch not a polished expandable proto-tool. + +Make a more accessible plugin architecture for lldb +--------------------------------------------------- + +Right now, you can only use the Python or SB API's to extend an extant lldb. +You can't implement any of the actual lldb Plugins as plugins. That means +anybody that wants to add new Object file/Process/Language etc support has to +build and distribute their own lldb. This is tricky because the API's the +plugins use are currently not stable (and recently have been changing quite a +lot.) We would have to define a subset of lldb_private that you could use, and +some way of telling whether the plugins were compatible with the lldb. But +long-term, making this sort of extension possible will make lldb more appealing +for research and 3rd party uses. + +Use instruction emulation to reduce the overhead for breakpoints +---------------------------------------------------------------- + +At present, breakpoints are implemented by inserting a trap instruction, then +when the trap is hit, replace the trap with the actual instruction and single +step. Then swap back and continue. This causes problems for read only text, and +also means that no-stop debugging ust either stop all threads briefly to handle +this two-step or risk missing some breakpoint hits. If you emulated the +instruction and wrote back the results, you wouldn't have these problems, and +it would also save a stop per breakpoint hit. Since we use breakpoints to +implement stepping, this savings could be significant on slow connections. + +Use the JIT to speed up conditional breakpoint evaluation +--------------------------------------------------------- + +We already JIT and cache the conditional expressions for breakpoints for the C +family of languages, so we aren't re-compiling every time you hit the +breakpoint. And if we couldn't IR interpret the expression, we leave the JIT'ed +code in place for reuse. But it would be even better if we could also insert +the "stop or not" decision into the code at the breakpoint, so you would only +actually stop the process when the condition was true. Greg's idea was that if +you had a conditional breakpoint set when you started the debug session, Xcode +could rebuild and insert enough no-ops that we could instrument the breakpoint +site and call the conditional expression, and only trap if the conditional was +true. + +Broaden the idea in "target stop-hook" to cover more events in the debugger +--------------------------------------------------------------------------- + +Shared library loads, command execution, User directed memory/register reads +and writes are all places where you would reasonably want to hook into the +debugger. + +Mock classes for testing +------------------------ + +We need "ProcessMock" and "ObjectFileMock" and the like. These would be real +plugin implementations for their underlying lldb classes, with the addition +that you can prime them from some sort of text based input files. For classes +that manage changes over time (like process) you would need to program the +state at StopPoint 0, StopPoint 1, etc. These could then be used for testing +reactions to complex threading problems & the like, and also for simulating +hard-to-test environments (like bare board debugging). + +A Bug-Trapper infrastructure +---------------------------- + +We very often have bugs that can't be reproduced locally. So having a +bug-report-trapper that can gather enough information from the surroundings of +a bug so that we can replay the session locally would be a big help tracking +down issues in this situation. This is tricky because you can't necessarily +require folks to leak information about their code in order to file bug +reports. So not only will you have to figure out what state to gather, you're +also going to have to anonymize it somehow. But we very often have bugs from +people that can't reduce the problem to a simple test case and can't give us +our code, and we often just can't help them as things stand now. Note that +adding the ProcessMock would be a good first stage towards this, since you +could make a ProcessMock creator/serializer from the current lldb state. + +Expression parser needs syntax for "{symbol,type} A in CU B.cpp" +---------------------------------------------------------------- + +Sometimes you need to specify non-visible or ambiguous types to the expression +parser. We were planning to do $b_dot_cpp$A or something like. You might want +to specify a static in a function, in a source file, or in a shared library. So +the syntax should support all these. + +Add a "testButDontAbort" style test to the UnitTest framework +------------------------------------------------------------- + +The way we use unittest now (maybe this is the only way it can work, I don't +know) you can't report a real failure and continue with the test. That is +appropriate in some cases: if I'm supposed to hit breakpoint A before I +evaluate an expression, and don't hit breakpoint A, the test should fail. But +it means that if I want to test five different expressions, I can either do it +in one test, which is good because it means I only have to fire up one process, +attach to it, and get it to a certain point. But it also means if the first +test fails, the other four don't even get run. So though at first we wrote a +bunch of test like this, as time went on we switched more to writing "one at a +time" tests because they were more robust against a single failure. That makes +the test suite run much more slowly. It would be great to add a +"test_but_dont_abort" variant of the tests, then we could gang tests that all +drive to the same place and do similar things. As an added benefit, it would +allow us to be more thorough in writing tests, since each test would have lower +costs. + +Convert the dotest style tests to use lldbutil.run_to_source_breakpoint +----------------------------------------------------------------------- + +run_to_source_breakpoint & run_to_name_breakpoint provide a compact API that +does in one line what the first 10 or 20 lines of most of the old tests now do +by hand. Using these functions makes tests much more readable, and by +centralizing common functionality will make maintaining the testsuites easier +in the future. This is more of a finger exercise, and perhaps best implemented +by a rule like: "If you touch a test case, and it isn't using +run_to_source_breakpoint, please make it do so". + +Unify Watchpoint's & Breakpoints +-------------------------------- + +Option handling isn't shared, and more importantly the PerformAction's have a +lot of duplicated common code, most of which works less well on the Watchpoint +side. + +Reverse debugging +----------------- + +This is kind of a holy grail, it's hard to support for complex apps (many +threads, shared memory, etc.) But it would be SO nice to have... + +Non-stop debugging +------------------ + +By this I mean allowing some threads in the target program to run while +stopping other threads. This is supported in name in lldb at present, but lldb +makes the assumption "If I get a stop, I won't get another stop unless I +actually run the program." in a bunch of places so getting it to work reliably +will be some a good bit of work. And figuring out how to present this in the UI +will also be tricky. + +Fix and continue +---------------- + +We did this in gdb without a real JIT. The implementation shouldn't be that +hard, especially if you can build the executable for fix and continue. The +tricky part is how to verify that the user can only do the kinds of fixes that +are safe to do. No changing object sizes is easy to detect, but there were many +more subtle changes (function you are fixing is on the stack...) that take more +work to prevent. And then you have to explain these conditions the user in some +helpful way. + +Unified IR interpreter +---------------------- + +Currently IRInterpreter implements a portion of the LLVM IR, but it doesn't +handle vector data types and there are plenty of instructions it also doesn't +support. Conversely, lli supports most of LLVM's IR but it doesn't handle +remote memory and its function calling support is very rudimentary. It would be +useful to unify these and make the IR interpreter -- both for LLVM and LLDB -- +better. An alternate strategy would be simply to JIT into the current process +but have callbacks for non-stack memory access. diff --git a/docs/status/status.rst b/docs/status/status.rst new file mode 100644 index 000000000000..b114bdd9743f --- /dev/null +++ b/docs/status/status.rst @@ -0,0 +1,65 @@ +Status +====== + +macOS +----- + +LLDB has matured a lot in the last year and can be used for C, C++ and +Objective-C development for x86_64, i386 and ARM debugging. The entire public +API is exposed though a framework on Mac OS X which is used by Xcode, the lldb +command line tool, and can also be used by Python. The entire public API is +exposed through script bridging which allows LLDB to use an embedded Python +script interpreter, as well as having a Python module named "lldb" which can be +used from Python on the command line. This allows debug sessions to be +scripted. It also allows powerful debugging actions to be created and attached +to a variety of debugging workflows. + +Linux +----- + +LLDB is improving on Linux. While the debugserver has not been ported (to +enable remote debugging) Linux is nearing feature completeness with Darwin to +debug x86_64 programs, and is partially working with i386 programs. ARM +architectures on Linux are untested. For more details, see the Features by OS +section below. + +FreeBSD +------- + +LLDB on FreeBSD lags behind the Linux implementation but is improving rapidly. +For more details, see the Features by OS section below. + +Windows +------- + +LLDB on Windows is still under development, but already useful for i386 +programs (x86_64 untested) built with DWARF debug information, including +postmortem analysis of minidumps. For more details, see the Features by OS +section below. + +Features Matrix +--------------- ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Feature | FreeBSD | Linux | Mac OS X (i386/x86_64 and ARM/Thumb) | Windows (i386) | +| | (x86_64) | (x86_64 and PPC64le) | | | ++================================+============+=========================+======================================+======================+ +| Backtracing | OK | OK | OK | OK | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Breakpoints | OK | OK | OK | OK | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| C++11: | OK | OK | OK | Unknown | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Commandline lldb tool | OK | OK | OK | OK | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Core file debugging | OK (ELF) | OK (ELF) | OK (MachO) | OK (Minidump) | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Debugserver (remote debugging) | Not ported | Not ported | OK | Not ported | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Disassembly | OK | OK | OK | OK | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Expression evaluation | Unknown | Works with some bugs | OK | Works with some bugs | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| JIT debugging | Unknown | Symbolic debugging only | Untested | No | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ +| Objective-C 2.0: | Unknown | Not applicable | OK | Not applicable | ++--------------------------------+------------+-------------------------+--------------------------------------+----------------------+ diff --git a/docs/use/architecture.rst b/docs/use/architecture.rst new file mode 100644 index 000000000000..e87d1248d401 --- /dev/null +++ b/docs/use/architecture.rst @@ -0,0 +1,192 @@ +Architecture +============ + +LLDB is a large and complex codebase. This section will help you become more +familiar with the pieces that make up LLDB and give a general overview of the +general architecture. + +LLDB has many code groupings that makeup the source base: + +.. contents:: + :local: + +API +--- + +The API folder contains the public interface to LLDB. + +We are currently vending a C++ API. In order to be able to add methods to this +API and allow people to link to our classes, we have certain rules that we must +follow: + +- Classes can't inherit from any other classes. +- Classes can't contain virtual methods. +- Classes should be compatible with script bridging utilities like swig. +- Classes should be lightweight and be backed by a single member. Pointers (or + shared pointers) are the preferred choice since they allow changing the + contents of the backend without affecting the public object layout. +- The interface should be as minimal as possible in order to give a complete + API. + +By adhering to these rules we should be able to continue to vend a C++ API, and +make changes to the API as any additional methods added to these classes will +just be a dynamic loader lookup and they won't affect the class layout (since +they aren't virtual methods, and no members can be added to the class). + +Breakpoint +---------- + +A collection of classes that implement our breakpoint classes. Breakpoints are +resolved symbolically and always continue to resolve themselves as your program +runs. Whether settings breakpoints by file and line, by symbol name, by symbol +regular expression, or by address, breakpoints will keep trying to resolve new +locations each time shared libraries are loaded. Breakpoints will of course +unresolve themselves when shared libraries are unloaded. Breakpoints can also +be scoped to be set only in a specific shared library. By default, breakpoints +can be set in any shared library and will continue to attempt to be resolved +with each shared library load. + +Breakpoint options can be set on the breakpoint, or on the individual +locations. This allows flexibility when dealing with breakpoints and allows us +to do what the user wants. + +Commands +-------- + +The command source files represent objects that implement the functionality for +all textual commands available in our command line interface. + +Every command is backed by a ``lldb_private::CommandObject`` or +``lldb_private::CommandObjectMultiword`` object. + +``lldb_private::CommandObjectMultiword`` are commands that have subcommands and +allow command line commands to be logically grouped into a hierarchy. + +``lldb_private::CommandObject`` command line commands are the objects that +implement the functionality of the command. They can optionally define options +for themselves, as well as group those options into logical groups that can go +together. The help system is tied into these objects and can extract the syntax +and option groupings to display appropriate help for each command. + +Core +---- + +The Core source files contain basic functionality that is required in the +debugger as well as the class represeting the debugger it self (Debugger). A +wide variety of classes are implemented: + +- Address (section offset addressing) +- AddressRange +- Broadcaster / Event / Listener +- Communication classes that use Connection objects +- Mangled names +- Source manager +- Value objects + +Dataformatters +-------------- + +A collection of classes that implement the data formatters subsystem. + +Data formatters provide a set of user-tweakable hooks in the ValueObjects world +that allow to customize presentation aspects of variables. While users interact +with formatters mostly through the type command, inside LLDB there are a few +layers to the implementation: DataVisualization at the highest end of the +spectrum, backed by classes implementing individual formatters, matching rules, +etc. + +For a general user-level introduction to data formatters, you can look here. + +More details on the architecture are to be found here. + +Expression +---------- + +Expression parsing files cover everything from evaluating DWARF expressions, to +evaluating expressions using Clang. + +The DWARF expression parser has been heavily modified to support type +promotion, new opcodes needed for evaluating expressions with symbolic variable +references (expression local variables, program variables), and other operators +required by typical expressions such as assign, address of, float/double/long +double floating point values, casting, and more. The DWARF expression parser +uses a stack of lldb_private::Value objects. These objects know how to do the +standard C type promotion, and allow for symbolic references to variables in +the program and in the LLDB process (expression local and expression global +variables). + +The expression parser uses a full instance of the Clang compiler in order to +accurately evaluate expressions. Hooks have been put into Clang so that the +compiler knows to ask about identifiers it doesn't know about. Once expressions +have be compiled into an AST, we can then traverse this AST and either generate +a DWARF expression that contains simple opcodes that can be quickly +re-evaluated each time an expression needs to be evaluated, or JIT'ed up into +code that can be run on the process being debugged. + +Host +---- + +LLDB tries to abstract itself from the host upon which it is currently running +by providing a host abstraction layer. This layer includes functionality, whose +implementation varies wildly from host to host. + +Host functionality includes abstraction layers for: + +- Information about the host system (triple, list of running processes, etc.) +- Launching processes +- Various OS primitives like pipes and sockets + +It also includes the base classes of the NativeProcess/Thread hierarchy, which +is used by lldb-server. + +Interpreter +----------- + +The interpreter classes are the classes responsible for being the base classes +needed for each command object, and is responsible for tracking and running +command line commands. + +Symbol +------ + +Symbol classes involve everything needed in order to parse object files and +debug symbols. All the needed classes for compilation units (code and debug +info for a source file), functions, lexical blocks within functions, inlined +functions, types, declaration locations, and variables are in this section. + +Target +------ + +Classes that are related to a debug target include: + +- Target +- Process +- Thread +- Stack frames +- Stack frame registers +- ABI for function calling in process being debugged +- Execution context batons + +Utility +------- + +This module contains the lowest layers of LLDB. A lot of these classes don't +really have anything to do with debugging -- they are just there because the +higher layers of the debugger use these clasess to implement their +functionality. Others are data structures used in many other parts of the +debugger (TraceOptions). Most of the functionality in this module could be +useful in an application that is not a debugger; however, providing a general +purpose C++ library is an explicit non-goal of this module. + +This module provides following functionality: + +- Abstract path manipulation (FileSpec) +- Architecture specification +- Data buffers (DataBuffer, DataEncoder, DataExtractor) +- Logging +- Structured data manipulation (JSON) +- Streams +- Timers + +For historic reasons, some of this functionality overlaps that which is +provided by the LLVM support library. diff --git a/docs/use/formatting.rst b/docs/use/formatting.rst new file mode 100644 index 000000000000..7eeda059cc8e --- /dev/null +++ b/docs/use/formatting.rst @@ -0,0 +1,297 @@ +Stack Frame and Thread Format +============================= + +.. contents:: + :local: + +LLDB has a facility to allow users to define the format of the information that +generates the descriptions for threads and stack frames. Typically when your +program stops at a breakpoint you will get two lines that describes why your +thread stopped and where: + +:: + + * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 + frame #0: test`main at test.c:5 + +Stack backtraces frames also have a similar information line: + +:: + + (lldb) thread backtrace + * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 + frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 + frame #1: 0x0000000100000e40 a.out`start + 52 + +The two format strings that govern the printing in these output forms can +currently be set using the settings set command: + +:: + + (lldb) settings set thread-stop-format STRING + (lldb) settings set frame-format STRING + +The first of these is an abbreviated thread output, that just contains data +about the thread, and not the stop frame. It will always get used in situations +where the frame output follows immediately, so that information would be +redundant. The second is the frame printing. + +There is another thread format used for commands like thread list where the +thread information isn't followed by frame info. In that case, it is convenient +to have frame zero information in the thread output. That format is set by: + +:: + + (lldb) settings set thread-format STRING + + +Format Strings +-------------- + +So what is the format of the format strings? Format strings can contain plain +text, control characters and variables that have access to the current program +state. + +Normal characters are any text that doesn't contain a ``{``, ``}``, ``$``, or +``\`` character. + +Variable names are found in between a ``${`` prefix, and end with a ``}`` +suffix. In other words, a variable looks like ``${frame.pc}``. + +Variables +--------- + +A complete list of currently supported format string variables is listed below: + ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| **Variable Name** | **Description** | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``file.basename`` | The current compile unit file basename for the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``file.fullpath`` | The current compile unit file fullpath for the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``language`` | The current compile unit language for the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.index`` | The frame index (0, 1, 2, 3...) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.no-debug`` | Evaluates to true if the frame has no debug info. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.pc`` | The generic frame register for the program counter. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.sp`` | The generic frame register for the stack pointer. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.fp`` | The generic frame register for the frame pointer. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.flags`` | The generic frame register for the flags register. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``frame.reg.NAME`` | Access to any platform specific register by name (replace ``NAME`` with the name of the desired register). | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.name`` | The name of the current function or symbol. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.name-with-args`` | The name of the current function with arguments and values or the symbol name. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.name-without-args`` | The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.pc-offset`` | The program counter offset within the current function or symbol | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.addr-offset`` | The offset in bytes of the current function, formatted as " + dddd" | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.concrete-only-addr-offset-no-padding`` | Similar to ``function.addr-offset`` except that there are no spaces in the output (e.g. "+dddd") and the offset is computed from the nearest concrete function -- inlined functions are not included | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.changed`` | Will evaluate to true when the line being formatted is a different symbol context from the previous line (may be used in ``disassembly-format`` to print the new function name on a line by itself at the start of a new function). Inlined functions are not considered for this variable | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``function.initial-function`` | Will evaluate to true if this is the start of the first function, as opposed to a change of functions (may be used in ``disassembly-format`` to print the function name for the first function being disassembled) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``line.file.basename`` | The line table entry basename to the file for the current line entry in the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``line.file.fullpath`` | The line table entry fullpath to the file for the current line entry in the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``line.number`` | The line table entry line number for the current line entry in the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``line.start-addr`` | The line table entry start address for the current line entry in the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``line.end-addr`` | The line table entry end address for the current line entry in the current frame. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``module.file.basename`` | The basename of the current module (shared library or executable) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``module.file.fullpath`` | The basename of the current module (shared library or executable) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``process.file.basename`` | The basename of the file for the process | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``process.file.fullpath`` | The fullname of the file for the process | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``process.id`` | The process ID native to the system on which the inferior runs. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``process.name`` | The name of the process at runtime | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.id`` | The thread identifier for the current thread | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.index`` | The unique one based thread index ID which is guaranteed to be unique as threads come and go. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.name`` | The name of the thread if the target OS supports naming threads | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.queue`` | The queue name of the thread if the target OS supports dispatch queues | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.stop-reason`` | A textual reason each thread stopped | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.return-value`` | The return value of the latest step operation (currently only for step-out.) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``thread.completed-expression`` | The expression result for a thread that just finished an interrupted expression evaluation. | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``target.arch`` | The architecture of the current target | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``script.target:python_func`` | Use a Python function to generate a piece of textual output | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``script.process:python_func`` | Use a Python function to generate a piece of textual output | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``script.thread:python_func`` | Use a Python function to generate a piece of textual output | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``script.frame:python_func`` | Use a Python function to generate a piece of textual output | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``current-pc-arrow`` | Prints either ``->`` or `` `` if the current pc value is matched (used in ``disassembly-format``) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ``addr-file-or-load`` | Formats an address either as a load address, or if process has not yet been launched, as a load address (used in ``disassembly-format``) | ++---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Control Characters +------------------ + +Control characters include ``{``, ``}``, and ``\``. + +The ``{`` and ``}`` are used for scoping blocks, and the ``\`` character allows +you to desensitize control characters and also emit non-printable characters. + +Desensitizing Characters in the Format String +--------------------------------------------- + +The backslash control character allows your to enter the typical ``\a``, +``\b``, ``\f``, ``\n``, ``\r``, ``\t``, ``\v``, ``\\``, characters and along +with the standard octal representation ``\0123`` and hex ``\xAB`` characters. +This allows you to enter escape characters into your format strings and will +allow colorized output for terminals that support color. + +Scoping +------- + +Many times the information that you might have in your prompt might not be +available and you won``t want it to print out if it isn``t valid. To take care +of this you can enclose everything that must resolve into a scope. A scope is +starts with ``{`` and ends with ``}``. For example in order to only display the +current frame line table entry basename and line number when the information is +available for the current frame: + +:: + + "{ at {$line.file.basename}:${line.number}}" + + +Broken down this is: + +- The start the scope: ``{`` , +- format whose content will only be displayed if all information is available: ``at {$line.file.basename}:${line.number}`` +- end the scope: ``}`` + +Making the Frame Format +----------------------- + +The information that we see when stopped in a frame: + +:: + + frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 + +can be displayed with the following format: + +:: + + "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n" + +This breaks down to: + +- Always print the frame index and frame PC: ``frame #${frame.index}: ${frame.pc}``, +- only print the module followed by a tick if there is a valid module for the current frame: ``{ ${module.file.basename}`}``, +- print the function name with optional offset: ``{${function.name}{${function.pc-offset}}}``, +- print the line info if it is available: ``{ at ${line.file.basename}:${line.number}}``, +- then finish off with a newline: ``\n``. + +Making Your own Formats +----------------------- + +When modifying your own format strings, it is useful to start with the default +values for the frame and thread format strings. These can be accessed with the +``settings show`` command: + +:: + + (lldb) settings show thread-format + thread-format (format-string) = "thread #${thread.index}: tid = ${thread.id%tid}{, ${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${line.file.basename}:${line.number}}{, name = '${thread.name}'}{, queue = '${thread.queue}'}{, activity = '${thread.info.activity.name}'}{, ${thread.info.trace_messages} messages}{, stop reason = ${thread.stop-reason}}{\nReturn value: ${thread.return-value}}{\nCompleted expression: ${thread.completed-expression}}\n" + (lldb) settings show frame-format + frame-format (format-string) = "frame #${frame.index}:{ ${frame.no-debug}${frame.pc}}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${line.file.basename}:${line.number}}{${function.is-optimized} [opt]}\n" + +When making thread formats, you will need surround any of the information that +comes from a stack frame with scopes ({ frame-content }) as the thread format +doesn't always want to show frame information. When displaying the backtrace +for a thread, we don't need to duplicate the information for frame zero in the +thread information: + +:: + + (lldb) thread backtrace + thread #1: tid = 0x2e03, stop reason = breakpoint 1.1 2.1 + frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 + frame #1: 0x0000000100000e40 a.out`start + 52 + +The frame related variables are: + +- ``${file.*}`` +- ``${frame.*}`` +- ``${function.*}`` +- ``${line.*}`` +- ``${module.*}`` + + +Looking at the default format for the thread, and underlining the frame +information: + +:: + + thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n + + +We can see that all frame information is contained in scopes so that when the +thread information is displayed in a context where we only want to show thread +information, we can do so. + +For both thread and frame formats, you can use ${script.target:python_func}, +${script.process:python_func} and ${script.thread:python_func} (and of course +${script.frame:python_func} for frame formats) In all cases, the signature of +python_func is expected to be: + +:: + + def python_func(object,unused): + ... + return string + +Where object is an instance of the SB class associated to the keyword you are +using. + +e.g. Assuming your function looks like: + +:: + + def thread_printer_func (thread,unused): + return "Thread %s has %d frames\n" % (thread.name, thread.num_frames) + +And you set it up with: + +:: + + (lldb) settings set thread-format "${script.thread:thread_printer_func}" + +you would see output like: + +:: + + * Thread main has 21 frames + diff --git a/docs/use/map.rst b/docs/use/map.rst new file mode 100644 index 000000000000..a20277c8ecdd --- /dev/null +++ b/docs/use/map.rst @@ -0,0 +1,1777 @@ +GDB to LLDB command map +======================= + +Below is a table of GDB commands with the LLDB counterparts. The built in +GDB-compatibility aliases in LLDB are also listed. The full lldb command names +are often long, but any unique short form can be used. Instead of "**breakpoint +set**", "**br se**" is also acceptable. + +.. contents:: + :local: + +Execution Commands +------------------ + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
Launch a process no arguments.
+ (gdb) run +
+ (gdb) r +
+ (lldb) process launch +
+ (lldb) run +
+ (lldb) r +
Launch a process with arguments <args>.
+ (gdb) run <args> +
+ (gdb) r <args> +
+ (lldb) process launch -- <args> +
+ (lldb) r <args> +
Launch a process for with arguments a.out 1 2 3 without having to supply the args every time.
+ % gdb --args a.out 1 2 3 +
+ (gdb) run +
... +
+ (gdb) run +
... +
+
+ % lldb -- a.out 1 2 3 +
+ (lldb) run +
... +
+ (lldb) run +
... +
+
Or:
+ (gdb) set args 1 2 3 +
+ (gdb) run +
... +
+ (gdb) run +
... +
+
+ (lldb) settings set target.run-args 1 2 3 +
+ (lldb) run +
... +
+ (lldb) run +
... +
+
Launch a process with arguments in new terminal window (Mac OS X only).
+ + (lldb) process launch --tty -- <args> +
+ (lldb) pro la -t -- <args> +
+
Launch a process with arguments in existing terminal + /dev/ttys006 (Mac OS X only). +
+ + (lldb) process launch --tty=/dev/ttys006 -- <args> +
+ (lldb) pro la -t/dev/ttys006 -- <args> +
+
Set environment variables for process before launching.
+ (gdb) set env DEBUG 1 +
+
+ (lldb) settings set target.env-vars DEBUG=1 +
+ (lldb) set se target.env-vars DEBUG=1 +
+ (lldb) env DEBUG=1 +
+
Unset environment variables for process before launching.
+ (gdb) unset env DEBUG +
+
+ (lldb) settings remove target.env-vars DEBUG +
+ (lldb) set rem target.env-vars DEBUG +
+
Show the arguments that will be or were passed to the program when run.
+ (gdb) show args +
Argument list to give program being debugged when it is started is "1 2 3". +
+
+ (lldb) settings show target.run-args +
target.run-args (array of strings) = +
[0]: "1" +
[1]: "2" +
[2]: "3" +
+
Set environment variables for process and launch process in one command.
+ + (lldb) process launch -v DEBUG=1 +
+
Attach to a process with process ID 123.
+ (gdb) attach 123 + + (lldb) process attach --pid 123 +
+ (lldb) attach -p 123 +
Attach to a process named "a.out".
+ (gdb) attach a.out + + (lldb) process attach --name a.out +
+ (lldb) pro at -n a.out +
Wait for a process named "a.out" to launch and attach.
+ (gdb) attach -waitfor a.out + + (lldb) process attach --name a.out --waitfor +
+ (lldb) pro at -n a.out -w +
Attach to a remote gdb protocol server running on system "eorgadd", port 8000.
+ (gdb) target remote eorgadd:8000 + + (lldb) gdb-remote eorgadd:8000 +
Attach to a remote gdb protocol server running on the local system, port 8000.
+ (gdb) target remote localhost:8000 + + (lldb) gdb-remote 8000 +
Attach to a Darwin kernel in kdp mode on system "eorgadd".
+ (gdb) kdp-reattach eorgadd + + (lldb) kdp-remote eorgadd +
Do a source level single step in the currently selected thread.
+ (gdb) step +
+ (gdb) s +
+ (lldb) thread step-in +
+ (lldb) step +
+ (lldb) s +
Do a source level single step over in the currently selected thread.
+ (gdb) next +
+ (gdb) n +
+ (lldb) thread step-over +
+ (lldb) next +
+ (lldb) n +
+
Do an instruction level single step in the currently selected thread.
+ (gdb) stepi +
+ (gdb) si +
+ (lldb) thread step-inst +
+ (lldb) si +
+
Do an instruction level single step over in the currently selected thread.
+ (gdb) nexti +
+ (gdb) ni +
+ (lldb) thread step-inst-over +
+ (lldb) ni +
Step out of the currently selected frame.
+ (gdb) finish +
+
+ (lldb) thread step-out +
+ (lldb) finish +
+
Return immediately from the currently selected frame, with an optional return value.
+ (gdb) return <RETURN EXPRESSION> +
+
+ (lldb) thread return <RETURN EXPRESSION> +
+
Backtrace and disassemble every time you stop.
+ + (lldb) target stop-hook add +
Enter your stop hook command(s). Type 'DONE' to end. +
> bt +
> disassemble --pc +
> DONE +
Stop hook #1 added. +
+
Run until we hit line 12 or control leaves the current function.
+ (gdb) until 12 + + (lldb) thread until 12 +
+ + +Breakpoint Commands +------------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
Set a breakpoint at all functions named main.
+ (gdb) break main + + (lldb) breakpoint set --name main +
+ (lldb) br s -n main +
+ (lldb) b main +
Set a breakpoint in file test.c at line 12.
+ (gdb) break test.c:12 + + (lldb) breakpoint set --file test.c --line 12 +
+ (lldb) br s -f test.c -l 12 +
+ (lldb) b test.c:12 +
Set a breakpoint at all C++ methods whose basename is main.
+ (gdb) break main +
+ (Hope that there are no C functions named main). +
+ (lldb) breakpoint set --method main +
+ (lldb) br s -M main +
+
Set a breakpoint at and object C function: -[NSString stringWithFormat:].
+ (gdb) break -[NSString stringWithFormat:] +
+
+ (lldb) breakpoint set --name "-[NSString stringWithFormat:]" +
+ (lldb) b -[NSString stringWithFormat:] +
+
Set a breakpoint at all Objective-C methods whose selector is count.
+ (gdb) break count +
+ (Hope that there are no C or C++ functions named count). +
+ (lldb) breakpoint set --selector count +
+ (lldb) br s -S count +
+
Set a breakpoint by regular expression on function name.
+ (gdb) rbreak regular-expression +
+
+ (lldb) breakpoint set --func-regex regular-expression +
+ (lldb) br s -r regular-expression +
+
Ensure that breakpoints by file and line work for #included .c/.cpp/.m files.
+ (gdb) b foo.c:12 +
+
+ (lldb) settings set target.inline-breakpoint-strategy always +
+ (lldb) br s -f foo.c -l 12 +
+
Set a breakpoint by regular expression on source file contents.
+ (gdb) shell grep -e -n pattern source-file +
+ (gdb) break source-file:CopyLineNumbers +
+
+ (lldb) breakpoint set --source-pattern regular-expression --file SourceFile +
+ (lldb) br s -p regular-expression -f file +
+
Set a conditional breakpoint
+ (gdb) break foo if strcmp(y,"hello") == 0 +
+
+ (lldb) breakpoint set --name foo --condition '(int)strcmp(y,"hello") == 0' +
+ (lldb) br s -n foo -c '(int)strcmp(y,"hello") == 0' +
+
List all breakpoints.
+ (gdb) info break +
+
+ (lldb) breakpoint list +
+ (lldb) br l +
+
Delete a breakpoint.
+ (gdb) delete 1 +
+
+ (lldb) breakpoint delete 1 +
+ (lldb) br del 1 +
+
+ + +Watchpoint Commands +------------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
Set a watchpoint on a variable when it is written to.
+ (gdb) watch global_var + + (lldb) watchpoint set variable global_var +
+ (lldb) wa s v global_var +
+
Set a watchpoint on a memory location when it is written into. The size of the region to watch for defaults to the pointer size if no '-x byte_size' is specified. This command takes raw input, evaluated as an expression returning an unsigned integer pointing to the start of the region, after the '--' option terminator.
+ (gdb) watch -location g_char_ptr + + (lldb) watchpoint set expression -- my_ptr +
+ (lldb) wa s e -- my_ptr +
+
Set a condition on a watchpoint.
+ + (lldb) watch set var global +
+ (lldb) watchpoint modify -c '(global==5)' +
+ (lldb) c +
... +
+ (lldb) bt +
* thread #1: tid = 0x1c03, 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16, stop reason = watchpoint 1 +
frame #0: 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16 +
frame #1: 0x0000000100000eac a.out`main + 108 at main.cpp:25 +
frame #2: 0x00007fff8ac9c7e1 libdyld.dylib`start + 1 +
+ (lldb) frame var global +
(int32_t) global = 5 +
+
List all watchpoints.
+ (gdb) info break +
+
+ (lldb) watchpoint list +
+ (lldb) watch l +
+
Delete a watchpoint.
+ (gdb) delete 1 +
+
+ (lldb) watchpoint delete 1 +
+ (lldb) watch del 1 +
+
+ + +Examining Variables +------------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
Show the arguments and local variables for the current frame.
+ (gdb) info args +
and +
+ (gdb) info locals +
+
+ (lldb) frame variable +
+ (lldb) fr v +
+
Show the local variables for the current frame.
+ (gdb) info locals +
+
+ (lldb) frame variable --no-args +
+ (lldb) fr v -a +
+
Show the contents of local variable "bar".
+ (gdb) p bar +
+
+ (lldb) frame variable bar +
+ (lldb) fr v bar +
+ (lldb) p bar +
+
Show the contents of local variable "bar" formatted as hex.
+ (gdb) p/x bar +
+
+ (lldb) frame variable --format x bar +
+ (lldb) fr v -f x bar +
+
Show the contents of global variable "baz".
+ (gdb) p baz +
+
+ (lldb) target variable baz +
+ (lldb) ta v baz +
+
Show the global/static variables defined in the current source file.
+ n/a +
+
+ (lldb) target variable +
+ (lldb) ta v +
+
Display the variables "argc" and "argv" every time you stop.
+ (gdb) display argc +
+ (gdb) display argv +
+
+ (lldb) target stop-hook add --one-liner "frame variable argc argv" +
+ (lldb) ta st a -o "fr v argc argv" +
+ (lldb) display argc +
+ (lldb) display argv +
+
Display the variables "argc" and "argv" only when you stop in the function named main.
+ + (lldb) target stop-hook add --name main --one-liner "frame variable argc argv" +
+ (lldb) ta st a -n main -o "fr v argc argv" +
+
Display the variable "*this" only when you stop in c class named MyClass.
+ + (lldb) target stop-hook add --classname MyClass --one-liner "frame variable *this" +
+ (lldb) ta st a -c MyClass -o "fr v *this" +
+
+ +Evaluating Expressions +---------------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
Evaluating a generalized expression in the current frame.
+ (gdb) print (int) printf ("Print nine: %d.", 4 + 5) +
or if you don't want to see void returns: +
+ (gdb) call (int) printf ("Print nine: %d.", 4 + 5) +
+
+ (lldb) expr (int) printf ("Print nine: %d.", 4 + 5) +
or using the print alias: +
+ (lldb) print (int) printf ("Print nine: %d.", 4 + 5) +
+
Creating and assigning a value to a convenience variable.
+ (gdb) set $foo = 5 +
+ (gdb) set variable $foo = 5 +
or using the print command +
+ (gdb) print $foo = 5 +
or using the call command +
+ (gdb) call $foo = 5 +
and if you want to specify the type of the variable: + (gdb) set $foo = (unsigned int) 5 +
+ +
+ In lldb you evaluate a variable declaration expression as you would write it in C: +
+ (lldb) expr unsigned int $foo = 5 +
+
Printing the ObjC "description" of an object.
+ (gdb) po [SomeClass returnAnObject] +
+
+ (lldb) expr -o -- [SomeClass returnAnObject] +
or using the po alias: +
+ (lldb) po [SomeClass returnAnObject] +
+
Print the dynamic type of the result of an expression.
+ (gdb) set print object 1 +
+ (gdb) p someCPPObjectPtrOrReference +
only works for C++ objects. +
+
+ (lldb) expr -d 1 -- [SomeClass returnAnObject] +
+ (lldb) expr -d 1 -- someCPPObjectPtrOrReference +
or set dynamic type printing to be the default: + (lldb) settings set target.prefer-dynamic run-target +
+
Calling a function so you can stop at a breakpoint in the function.
+ (gdb) set unwindonsignal 0 +
+ (gdb) p function_with_a_breakpoint() +
+
+ (lldb) expr -i 0 -- function_with_a_breakpoint() +
+
Calling a function that crashes, and stopping when the function crashes.
+ (gdb) set unwindonsignal 0 +
+ (gdb) p function_which_crashes() +
+
+ (lldb) expr -u 0 -- function_which_crashes() +
+
+ +Examining Thread State +---------------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
List the threads in your program.
+ (gdb) info threads +
+
+ (lldb) thread list +
+
Select thread 1 as the default thread for subsequent commands.
+ (gdb) thread 1 +
+
+ (lldb) thread select 1 +
+ (lldb) t 1 +
+
Show the stack backtrace for the current thread.
+ (gdb) bt +
+
+ (lldb) thread backtrace +
+ (lldb) bt +
+
Show the stack backtraces for all threads.
+ (gdb) thread apply all bt + + (lldb) thread backtrace all +
+ (lldb) bt all +
Backtrace the first five frames of the current thread.
+ (gdb) bt 5 + + (lldb) thread backtrace -c 5 +
+ (lldb) bt 5 (lldb-169 and later) +
+ (lldb) bt -c 5 (lldb-168 and earlier) +
Select a different stack frame by index for the current thread.
+ (gdb) frame 12 + + (lldb) frame select 12 +
+ (lldb) fr s 12 +
+ (lldb) f 12 +
+
List information about the currently selected frame in the current thread.
+ + (lldb) frame info +
+
Select the stack frame that called the current stack frame.
+ (gdb) up + + (lldb) up +
+ (lldb) frame select --relative=1 +
+
Select the stack frame that is called by the current stack frame.
+ (gdb) down + + (lldb) down +
+ (lldb) frame select --relative=-1 +
+ (lldb) fr s -r-1 +
+
Select a different stack frame using a relative offset.
+ (gdb) up 2 +
+ (gdb) down 3 +
+
+ (lldb) frame select --relative 2 +
+ (lldb) fr s -r2 +
+
+ (lldb) frame select --relative -3 +
+ (lldb) fr s -r-3 +
+
Show the general purpose registers for the current thread.
+ (gdb) info registers +
+
+ (lldb) register read +
+
Write a new decimal value '123' to the current thread register 'rax'.
+ (gdb) p $rax = 123 +
+
+ (lldb) register write rax 123 +
+
Skip 8 bytes ahead of the current program counter (instruction pointer). Note that we use backticks to evaluate an expression and insert the scalar result in LLDB.
+ (gdb) jump *$pc+8 +
+
+ (lldb) register write pc `$pc+8` +
+
Show the general purpose registers for the current thread formatted as signed decimal. LLDB tries to use the same format characters as printf(3) when possible. Type "help format" to see the full list of format specifiers.
+ + (lldb) register read --format i +
+ (lldb) re r -f i +
+
+ LLDB now supports the GDB shorthand format syntax but there can't be space after the command: +
+ (lldb) register read/d +
+
Show all registers in all register sets for the current thread.
+ (gdb) info all-registers +
+
+ (lldb) register read --all +
+ (lldb) re r -a +
+
Show the values for the registers named "rax", "rsp" and "rbp" in the current thread.
+ (gdb) info all-registers rax rsp rbp +
+
+ (lldb) register read rax rsp rbp +
+
Show the values for the register named "rax" in the current thread formatted as binary.
+ (gdb) p/t $rax +
+
+ (lldb) register read --format binary rax +
+ (lldb) re r -f b rax +
+
+ LLDB now supports the GDB shorthand format syntax but there can't be space after the command: +
+ (lldb) register read/t rax +
+ (lldb) p/t $rax +
+
Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.
+ (gdb) x/4xw 0xbffff3c0 +
+
+ (lldb) memory read --size 4 --format x --count 4 0xbffff3c0 +
+ (lldb) me r -s4 -fx -c4 0xbffff3c0 +
+ (lldb) x -s4 -fx -c4 0xbffff3c0 +
+
+ LLDB now supports the GDB shorthand format syntax but there can't be space after the command: +
+ (lldb) memory read/4xw 0xbffff3c0 +
+ (lldb) x/4xw 0xbffff3c0 +
+ (lldb) memory read --gdb-format 4xw 0xbffff3c0 +
+
Read memory starting at the expression "argv[0]".
+ (gdb) x argv[0] +
+
+ (lldb) memory read `argv[0]` +
+ NOTE: any command can inline a scalar expression result (as long as the target is stopped) using backticks around any expression: +
+ (lldb) memory read --size `sizeof(int)` `argv[0]` +
+
Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as text.
+ (gdb) set logging on +
+ (gdb) set logging file /tmp/mem.txt +
+ (gdb) x/512bx 0xbffff3c0 +
+ (gdb) set logging off +
+
+ (lldb) memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0 +
+ (lldb) me r -o/tmp/mem.txt -c512 0xbffff3c0 +
+ (lldb) x/512bx -o/tmp/mem.txt 0xbffff3c0 +
+
Save binary memory data starting at 0x1000 and ending at 0x2000 to a file.
+ (gdb) dump memory /tmp/mem.bin 0x1000 0x2000 + + (lldb) memory read --outfile /tmp/mem.bin --binary 0x1000 0x2000 +
+ (lldb) me r -o /tmp/mem.bin -b 0x1000 0x2000 +
+
Get information about a specific heap allocation (available on Mac OS X only).
+ (gdb) info malloc 0x10010d680 + + (lldb) command script import lldb.macosx.heap +
+ (lldb) process launch --environment MallocStackLogging=1 -- [ARGS] +
+ (lldb) malloc_info --stack-history 0x10010d680 +
+
Get information about a specific heap allocation and cast the result to any dynamic type that can be deduced (available on Mac OS X only)
+ + (lldb) command script import lldb.macosx.heap +
+ (lldb) malloc_info --type 0x10010d680 +
+
Find all heap blocks that contain a pointer specified by an expression EXPR (available on Mac OS X only).
+ + (lldb) command script import lldb.macosx.heap +
+ (lldb) ptr_refs EXPR +
+
Find all heap blocks that contain a C string anywhere in the block (available on Mac OS X only).
+ + (lldb) command script import lldb.macosx.heap +
+ (lldb) cstr_refs CSTRING +
+
Disassemble the current function for the current frame.
+ (gdb) disassemble + + (lldb) disassemble --frame +
+ (lldb) di -f +
Disassemble any functions named main.
+ (gdb) disassemble main + + (lldb) disassemble --name main +
+ (lldb) di -n main +
Disassemble an address range.
+ (gdb) disassemble 0x1eb8 0x1ec3 + + (lldb) disassemble --start-address 0x1eb8 --end-address 0x1ec3 +
+ (lldb) di -s 0x1eb8 -e 0x1ec3 +
+
Disassemble 20 instructions from a given address.
+ (gdb) x/20i 0x1eb8 + + (lldb) disassemble --start-address 0x1eb8 --count 20 +
+ (lldb) di -s 0x1eb8 -c 20 +
+
Show mixed source and disassembly for the current function for the current frame.
+ n/a + + (lldb) disassemble --frame --mixed +
+ (lldb) di -f -m +
Disassemble the current function for the current frame and show the opcode bytes.
+ n/a + + (lldb) disassemble --frame --bytes +
+ (lldb) di -f -b +
Disassemble the current source line for the current frame.
+ n/a + + (lldb) disassemble --line +
+ (lldb) di -l +
+ +Executable and Shared Library Query Commands +-------------------------------------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
List the main executable and all dependent shared libraries.
+ (gdb) info shared +
+
+ (lldb) image list +
+
Look up information for a raw address in the executable or any shared libraries.
+ (gdb) info symbol 0x1ec4 +
+
+ (lldb) image lookup --address 0x1ec4 +
+ (lldb) im loo -a 0x1ec4 +
+
Look up functions matching a regular expression in a binary.
+ (gdb) info function <FUNC_REGEX> +
+
+ This one finds debug symbols: +
+ (lldb) image lookup -r -n <FUNC_REGEX> +
+
This one finds non-debug symbols: +
+ (lldb) image lookup -r -s <FUNC_REGEX> +
+
Provide a list of binaries as arguments to limit the search. +
Find full source line information.
+ (gdb) info line 0x1ec4 +
+
+ This one is a bit messy at present. Do: +
+
+ (lldb) image lookup -v --address 0x1ec4 +
+
and look for the LineEntry line, which will have the full source path and line range information. +
+
Look up information for an address in a.out only.
+ + (lldb) image lookup --address 0x1ec4 a.out +
+ (lldb) im loo -a 0x1ec4 a.out +
+
Look up information for for a type Point by name.
+ (gdb) ptype Point +
+
+ (lldb) image lookup --type Point +
+ (lldb) im loo -t Point +
+
Dump all sections from the main executable and any shared libraries.
+ (gdb) maintenance info sections +
+
+ (lldb) image dump sections +
+
Dump all sections in the a.out module.
+ + (lldb) image dump sections a.out +
+
Dump all symbols from the main executable and any shared libraries.
+ + (lldb) image dump symtab +
+
Dump all symbols in a.out and liba.so.
+ + (lldb) image dump symtab a.out liba.so +
+
+ +Miscellaneous +------------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GDBLLDB
Search command help for a keyword.
+ (gdb) apropos keyword +
+
+ (lldb) apropos keyword +
+
Echo text to the screen.
+ (gdb) echo Here is some text\n +
+
+ (lldb) script print "Here is some text" +
+
Remap source file pathnames for the debug session. If your source files are no longer located in the same location as when the program was built --- maybe the program was built on a different computer --- you need to tell the debugger how to find the sources at their local file path instead of the build system's file path.
+ (gdb) set pathname-substitutions /buildbot/path /my/path +
+
+ (lldb) settings set target.source-map /buildbot/path /my/path +
+
Supply a catchall directory to search for source files in.
+ (gdb) directory /my/path +
+
+ (No equivalent command - use the source-map instead.) +
+
diff --git a/docs/use/python.rst b/docs/use/python.rst new file mode 100644 index 000000000000..6b2125705086 --- /dev/null +++ b/docs/use/python.rst @@ -0,0 +1,801 @@ +Python Scripting +================ + +LLDB has been structured from the beginning to be scriptable in two +ways -- a Unix Python session can initiate/run a debug session +non-interactively using LLDB; and within the LLDB debugger tool, Python +scripts can be used to help with many tasks, including inspecting +program data, iterating over containers and determining if a breakpoint +should stop execution or continue. This document will show how to do +some of these things by going through an example, explaining how to use +Python scripting to find a bug in a program that searches for text in a +large binary tree. + +.. contents:: + :local: + +The Test Program and Input +-------------------------- + +We have a simple C program (dictionary.c) that reads in a text file, +and stores all the words from the file in a Binary Search Tree, sorted +alphabetically. It then enters a loop prompting the user for a word, +searching for the word in the tree (using Binary Search), and reporting +to the user whether or not it found the word in the tree. + +The input text file we are using to test our program contains the text +for William Shakespeare's famous tragedy "Romeo and Juliet". + +The Bug +------- + +When we try running our program, we find there is a problem. While it +successfully finds some of the words we would expect to find, such as +"love" or "sun", it fails to find the word "Romeo", which MUST be in +the input text file: + +:: + + % ./dictionary Romeo-and-Juliet.txt + Dictionary loaded. + Enter search word: love + Yes! + Enter search word: sun + Yes! + Enter search word: Romeo + No! + Enter search word: ^D + % + +Using Depth First Search +------------------------ + +Our first job is to determine if the word "Romeo" actually got inserted +into the tree or not. Since "Romeo and Juliet" has thousands of words, +trying to examine our binary search tree by hand is completely +impractical. Therefore we will write a Python script to search the tree +for us. We will write a recursive Depth First Search function that +traverses the entire tree searching for a word, and maintaining +information about the path from the root of the tree to the current +node. If it finds the word in the tree, it returns the path from the +root to the node containing the word. This is what our DFS function in +Python would look like, with line numbers added for easy reference in +later explanations: + +:: + + 1: def DFS (root, word, cur_path): + 2: root_word_ptr = root.GetChildMemberWithName ("word") + 3: left_child_ptr = root.GetChildMemberWithName ("left") + 4: right_child_ptr = root.GetChildMemberWithName ("right") + 5: root_word = root_word_ptr.GetSummary() + 6: end = len (root_word) - 1 + 7: if root_word[0] == '"' and root_word[end] == '"': + 8: root_word = root_word[1:end] + 9: end = len (root_word) - 1 + 10: if root_word[0] == '\'' and root_word[end] == '\'': + 11: root_word = root_word[1:end] + 12: if root_word == word: + 13: return cur_path + 14: elif word < root_word: + 15: if left_child_ptr.GetValue() == None: + 16: return "" + 17: else: + 18: cur_path = cur_path + "L" + 19: return DFS (left_child_ptr, word, cur_path) + 20: else: + 21: if right_child_ptr.GetValue() == None: + 22: return "" + 23: else: + 24: cur_path = cur_path + "R" + 25: return DFS (right_child_ptr, word, cur_path) + + +Accessing & Manipulating Program Variables +------------------------------------------ + +Before we can call any Python function on any of our program's +variables, we need to get the variable into a form that Python can +access. To show you how to do this we will look at the parameters for +the DFS function. The first parameter is going to be a node in our +binary search tree, put into a Python variable. The second parameter is +the word we are searching for (a string), and the third parameter is a +string representing the path from the root of the tree to our current +node. + +The most interesting parameter is the first one, the Python variable +that needs to contain a node in our search tree. How can we take a +variable out of our program and put it into a Python variable? What +kind of Python variable will it be? The answers are to use the LLDB API +functions, provided as part of the LLDB Python module. Running Python +from inside LLDB, LLDB will automatically give us our current frame +object as a Python variable, "lldb.frame". This variable has the type +"SBFrame" (see the LLDB API for more information about SBFrame +objects). One of the things we can do with a frame object, is to ask it +to find and return its local variable. We will call the API function +"FindVariable" on the lldb.frame object to give us our dictionary +variable as a Python variable: + +:: + + root = lldb.frame.FindVariable ("dictionary") + +The line above, executed in the Python script interpreter in LLDB, asks the +current frame to find the variable named "dictionary" and return it. We then +store the returned value in the Python variable named "root". This answers the +question of HOW to get the variable, but it still doesn't explain WHAT actually +gets put into "root". If you examine the LLDB API, you will find that the +SBFrame method "FindVariable" returns an object of type SBValue. SBValue +objects are used, among other things, to wrap up program variables and values. +There are many useful methods defined in the SBValue class to allow you to get +information or children values out of SBValues. For complete information, see +the header file SBValue.h. The SBValue methods that we use in our DFS function +are ``GetChildMemberWithName()``, ``GetSummary()``, and ``GetValue()``. + + +Explaining DFS Script in Detail +------------------------------- + +Before diving into the details of this code, it would be best to give a +high-level overview of what it does. The nodes in our binary search tree were +defined to have type ``tree_node *``, which is defined as: + +:: + + typedef struct tree_node + { + const char *word; + struct tree_node *left; + struct tree_node *right; + } tree_node; + +Lines 2-11 of DFS are getting data out of the current tree node and getting +ready to do the actual search; lines 12-25 are the actual depth-first search. +Lines 2-4 of our DFS function get the word, left and right fields out of the +current node and store them in Python variables. Since root_word_ptr is a +pointer to our word, and we want the actual word, line 5 calls GetSummary() to +get a string containing the value out of the pointer. Since GetSummary() adds +quotes around its result, lines 6-11 strip surrounding quotes off the word. + +Line 12 checks to see if the word in the current node is the one we are +searching for. If so, we are done, and line 13 returns the current path. +Otherwise, line 14 checks to see if we should go left (search word comes before +the current word). If we decide to go left, line 15 checks to see if the left +pointer child is NULL ("None" is the Python equivalent of NULL). If the left +pointer is NULL, then the word is not in this tree and we return an empty path +(line 16). Otherwise, we add an "L" to the end of our current path string, to +indicate we are going left (line 18), and then recurse on the left child (line +19). Lines 20-25 are the same as lines 14-19, except for going right rather +than going left. + +One other note: Typing something as long as our DFS function directly into the +interpreter can be difficult, as making a single typing mistake means having to +start all over. Therefore we recommend doing as we have done: Writing your +longer, more complicated script functions in a separate file (in this case +tree_utils.py) and then importing it into your LLDB Python interpreter. + + +The DFS Script in Action +------------------------ + +At this point we are ready to use the DFS function to see if the word "Romeo" +is in our tree or not. To actually use it in LLDB on our dictionary program, +you would do something like this: + +:: + + % lldb + (lldb) process attach -n "dictionary" + Architecture set to: x86_64. + Process 521 stopped + * thread #1: tid = 0x2c03, 0x00007fff86c8bea0 libSystem.B.dylib`read$NOCANCEL + 8, stop reason = signal SIGSTOP + frame #0: 0x00007fff86c8bea0 libSystem.B.dylib`read$NOCANCEL + 8 + (lldb) breakpoint set -n find_word + Breakpoint created: 1: name = 'find_word', locations = 1, resolved = 1 + (lldb) continue + Process 521 resuming + Process 521 stopped + * thread #1: tid = 0x2c03, 0x0000000100001830 dictionary`find_word + 16 + at dictionary.c:105, stop reason = breakpoint 1.1 + frame #0: 0x0000000100001830 dictionary`find_word + 16 at dictionary.c:105 + 102 int + 103 find_word (tree_node *dictionary, char *word) + 104 { + -> 105 if (!word || !dictionary) + 106 return 0; + 107 + 108 int compare_value = strcmp (word, dictionary->word); + (lldb) script + Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. + >>> import tree_utils + >>> root = lldb.frame.FindVariable ("dictionary") + >>> current_path = "" + >>> path = tree_utils.DFS (root, "Romeo", current_path) + >>> print path + LLRRL + >>> ^D + (lldb) + +The first bit of code above shows starting lldb, attaching to the dictionary +program, and getting to the find_word function in LLDB. The interesting part +(as far as this example is concerned) begins when we enter the script command +and drop into the embedded interactive Python interpreter. We will go over this +Python code line by line. The first line + +:: + + import tree_utils + + +imports the file where we wrote our DFS function, tree_utils.py, into Python. +Notice that to import the file we leave off the ".py" extension. We can now +call any function in that file, giving it the prefix "tree_utils.", so that +Python knows where to look for the function. The line + +:: + + root = lldb.frame.FindVariable ("dictionary") + + +gets our program variable "dictionary" (which contains the binary search tree) +and puts it into the Python variable "root". See Accessing & Manipulating +Program Variables in Python above for more details about how this works. The +next line is + +:: + + current_path = "" + +This line initializes the current_path from the root of the tree to our current +node. Since we are starting at the root of the tree, our current path starts as +an empty string. As we go right and left through the tree, the DFS function +will append an 'R' or an 'L' to the current path, as appropriate. The line + +:: + + path = tree_utils.DFS (root, "Romeo", current_path) + +calls our DFS function (prefixing it with the module name so that Python can +find it). We pass in our binary tree stored in the variable root, the word we +are searching for, and our current path. We assign whatever path the DFS +function returns to the Python variable path. + +Finally, we want to see if the word was found or not, and if so we want to see +the path through the tree to the word. So we do + +:: + + print path + +From this we can see that the word "Romeo" was indeed found in the tree, and +the path from the root of the tree to the node containing "Romeo" is +left-left-right-right-left. + +Using Breakpoint Command Scripts +-------------------------------- + +We are halfway to figuring out what the problem is. We know the word we are +looking for is in the binary tree, and we know exactly where it is in the +binary tree. Now we need to figure out why our binary search algorithm is not +finding the word. We will do this using breakpoint command scripts. + +The idea is as follows. The binary search algorithm has two main decision +points: the decision to follow the right branch; and, the decision to follow +the left branch. We will set a breakpoint at each of these decision points, and +attach a Python breakpoint command script to each breakpoint. The breakpoint +commands will use the global path Python variable that we got from our DFS +function. Each time one of these decision breakpoints is hit, the script will +compare the actual decision with the decision the front of the path variable +says should be made (the first character of the path). If the actual decision +and the path agree, then the front character is stripped off the path, and +execution is resumed. In this case the user never even sees the breakpoint +being hit. But if the decision differs from what the path says it should be, +then the script prints out a message and does NOT resume execution, leaving the +user sitting at the first point where a wrong decision is being made. + +Python Breakpoint Command Scripts Are Not What They Seem +-------------------------------------------------------- + +What do we mean by that? When you enter a Python breakpoint command in LLDB, it +appears that you are entering one or more plain lines of Python. BUT LLDB then +takes what you entered and wraps it into a Python FUNCTION (just like using the +"def" Python command). It automatically gives the function an obscure, unique, +hard-to-stumble-across function name, and gives it two parameters: frame and +bp_loc. When the breakpoint gets hit, LLDB wraps up the frame object where the +breakpoint was hit, and the breakpoint location object for the breakpoint that +was hit, and puts them into Python variables for you. It then calls the Python +function that was created for the breakpoint command, and passes in the frame +and breakpoint location objects. + +So, being practical, what does this mean for you when you write your Python +breakpoint commands? It means that there are two things you need to keep in +mind: 1. If you want to access any Python variables created outside your +script, you must declare such variables to be global. If you do not declare +them as global, then the Python function will treat them as local variables, +and you will get unexpected behavior. 2. All Python breakpoint command scripts +automatically have a frame and a bp_loc variable. The variables are pre-loaded +by LLDB with the correct context for the breakpoint. You do not have to use +these variables, but they are there if you want them. + +The Decision Point Breakpoint Commands +-------------------------------------- + +This is what the Python breakpoint command script would look like for the +decision to go right: + +:: + + global path + if path[0] == 'R': + path = path[1:] + thread = frame.GetThread() + process = thread.GetProcess() + process.Continue() + else: + print "Here is the problem; going right, should go left!" + Just as a reminder, LLDB is going to take this script and wrap it up in a function, like this: + + + def some_unique_and_obscure_function_name (frame, bp_loc): + global path + if path[0] == 'R': + path = path[1:] + thread = frame.GetThread() + process = thread.GetProcess() + process.Continue() + else: + print "Here is the problem; going right, should go left!" + +LLDB will call the function, passing in the correct frame and breakpoint +location whenever the breakpoint gets hit. There are several things to notice +about this function. The first one is that we are accessing and updating a +piece of state (the path variable), and actually conditioning our behavior +based upon this variable. Since the variable was defined outside of our script +(and therefore outside of the corresponding function) we need to tell Python +that we are accessing a global variable. That is what the first line of the +script does. Next we check where the path says we should go and compare it to +our decision (recall that we are at the breakpoint for the decision to go +right). If the path agrees with our decision, then we strip the first character +off of the path. + +Since the decision matched the path, we want to resume execution. To do this we +make use of the frame parameter that LLDB guarantees will be there for us. We +use LLDB API functions to get the current thread from the current frame, and +then to get the process from the thread. Once we have the process, we tell it +to resume execution (using the Continue() API function). + +If the decision to go right does not agree with the path, then we do not resume +execution. We allow the breakpoint to remain stopped (by doing nothing), and we +print an informational message telling the user we have found the problem, and +what the problem is. + +Actually Using The Breakpoint Commands +-------------------------------------- + +Now we will look at what happens when we actually use these breakpoint commands +on our program. Doing a source list -n find_word shows us the function +containing our two decision points. Looking at the code below, we see that we +want to set our breakpoints on lines 113 and 115: + +:: + + (lldb) source list -n find_word + File: /Volumes/Data/HD2/carolinetice/Desktop/LLDB-Web-Examples/dictionary.c. + 101 + 102 int + 103 find_word (tree_node *dictionary, char *word) + 104 { + 105 if (!word || !dictionary) + 106 return 0; + 107 + 108 int compare_value = strcmp (word, dictionary->word); + 109 + 110 if (compare_value == 0) + 111 return 1; + 112 else if (compare_value < 0) + 113 return find_word (dictionary->left, word); + 114 else + 115 return find_word (dictionary->right, word); + 116 } + 117 + + +So, we set our breakpoints, enter our breakpoint command scripts, and see what happens: + +:: + + (lldb) breakpoint set -l 113 + Breakpoint created: 2: file ='dictionary.c', line = 113, locations = 1, resolved = 1 + (lldb) breakpoint set -l 115 + Breakpoint created: 3: file ='dictionary.c', line = 115, locations = 1, resolved = 1 + (lldb) breakpoint command add -s python 2 + Enter your Python command(s). Type 'DONE' to end. + > global path + > if (path[0] == 'L'): + > path = path[1:] + > thread = frame.GetThread() + > process = thread.GetProcess() + > process.Continue() + > else: + > print "Here is the problem. Going left, should go right!" + > DONE + (lldb) breakpoint command add -s python 3 + Enter your Python command(s). Type 'DONE' to end. + > global path + > if (path[0] == 'R'): + > path = path[1:] + > thread = frame.GetThread() + > process = thread.GetProcess() + > process.Continue() + > else: + > print "Here is the problem. Going right, should go left!" + > DONE + (lldb) continue + Process 696 resuming + Here is the problem. Going right, should go left! + Process 696 stopped + * thread #1: tid = 0x2d03, 0x000000010000189f dictionary`find_word + 127 at dictionary.c:115, stop reason = breakpoint 3.1 + frame #0: 0x000000010000189f dictionary`find_word + 127 at dictionary.c:115 + 112 else if (compare_value < 0) + 113 return find_word (dictionary->left, word); + 114 else + -> 115 return find_word (dictionary->right, word); + 116 } + 117 + 118 void + (lldb) + + +After setting our breakpoints, adding our breakpoint commands and continuing, +we run for a little bit and then hit one of our breakpoints, printing out the +error message from the breakpoint command. Apparently at this point in the +tree, our search algorithm decided to go right, but our path says the node we +want is to the left. Examining the word at the node where we stopped, and our +search word, we see: + +:: + + (lldb) expr dictionary->word + (const char *) $1 = 0x0000000100100080 "dramatis" + (lldb) expr word + (char *) $2 = 0x00007fff5fbff108 "romeo" + +So the word at our current node is "dramatis", and the word we are searching +for is "romeo". "romeo" comes after "dramatis" alphabetically, so it seems like +going right would be the correct decision. Let's ask Python what it thinks the +path from the current node to our word is: + +:: + + (lldb) script print path + LLRRL + +According to Python we need to go left-left-right-right-left from our current +node to find the word we are looking for. Let's double check our tree, and see +what word it has at that node: + +:: + + (lldb) expr dictionary->left->left->right->right->left->word + (const char *) $4 = 0x0000000100100880 "Romeo" + +So the word we are searching for is "romeo" and the word at our DFS location is +"Romeo". Aha! One is uppercase and the other is lowercase: We seem to have a +case conversion problem somewhere in our program (we do). + +This is the end of our example on how you might use Python scripting in LLDB to +help you find bugs in your program. + +Source Files for The Example +---------------------------- + +The complete code for the Dictionary program (with case-conversion bug), the +DFS function and other Python script examples (tree_utils.py) used for this +example are available below. + +tree_utils.py - Example Python functions using LLDB's API, including DFS + +:: + + """ + # ===-- tree_utils.py ---------------------------------------*- Python -*-===// + # + # The LLVM Compiler Infrastructure + # + # This file is distributed under the University of Illinois Open Source + # License. See LICENSE.TXT for details. + # + # ===---------------------------------------------------------------------===// + + tree_utils.py - A set of functions for examining binary + search trees, based on the example search tree defined in + dictionary.c. These functions contain calls to LLDB API + functions, and assume that the LLDB Python module has been + imported. + + For a thorough explanation of how the DFS function works, and + for more information about dictionary.c go to + http://lldb.llvm.org/scripting.html + """ + + + def DFS(root, word, cur_path): + """ + Recursively traverse a binary search tree containing + words sorted alphabetically, searching for a particular + word in the tree. Also maintains a string representing + the path from the root of the tree to the current node. + If the word is found in the tree, return the path string. + Otherwise return an empty string. + + This function assumes the binary search tree is + the one defined in dictionary.c It uses LLDB API + functions to examine and traverse the tree nodes. + """ + + # Get pointer field values out of node 'root' + + root_word_ptr = root.GetChildMemberWithName("word") + left_child_ptr = root.GetChildMemberWithName("left") + right_child_ptr = root.GetChildMemberWithName("right") + + # Get the word out of the word pointer and strip off + # surrounding quotes (added by call to GetSummary). + + root_word = root_word_ptr.GetSummary() + end = len(root_word) - 1 + if root_word[0] == '"' and root_word[end] == '"': + root_word = root_word[1:end] + end = len(root_word) - 1 + if root_word[0] == '\'' and root_word[end] == '\'': + root_word = root_word[1:end] + + # Main depth first search + + if root_word == word: + return cur_path + elif word < root_word: + + # Check to see if left child is NULL + + if left_child_ptr.GetValue() is None: + return "" + else: + cur_path = cur_path + "L" + return DFS(left_child_ptr, word, cur_path) + else: + + # Check to see if right child is NULL + + if right_child_ptr.GetValue() is None: + return "" + else: + cur_path = cur_path + "R" + return DFS(right_child_ptr, word, cur_path) + + + def tree_size(root): + """ + Recursively traverse a binary search tree, counting + the nodes in the tree. Returns the final count. + + This function assumes the binary search tree is + the one defined in dictionary.c It uses LLDB API + functions to examine and traverse the tree nodes. + """ + if (root.GetValue is None): + return 0 + + if (int(root.GetValue(), 16) == 0): + return 0 + + left_size = tree_size(root.GetChildAtIndex(1)) + right_size = tree_size(root.GetChildAtIndex(2)) + + total_size = left_size + right_size + 1 + return total_size + + + def print_tree(root): + """ + Recursively traverse a binary search tree, printing out + the words at the nodes in alphabetical order (the + search order for the binary tree). + + This function assumes the binary search tree is + the one defined in dictionary.c It uses LLDB API + functions to examine and traverse the tree nodes. + """ + if (root.GetChildAtIndex(1).GetValue() is not None) and ( + int(root.GetChildAtIndex(1).GetValue(), 16) != 0): + print_tree(root.GetChildAtIndex(1)) + + print root.GetChildAtIndex(0).GetSummary() + + if (root.GetChildAtIndex(2).GetValue() is not None) and ( + int(root.GetChildAtIndex(2).GetValue(), 16) != 0): + print_tree(root.GetChildAtIndex(2)) + + +dictionary.c - Sample dictionary program, with bug + +:: + + //===-- dictionary.c ---------------------------------------------*- C -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file is distributed under the University of Illinois Open Source + // License. See LICENSE.TXT for details. + // + //===---------------------------------------------------------------------===// + #include + #include + #include + #include + + typedef struct tree_node { + const char *word; + struct tree_node *left; + struct tree_node *right; + } tree_node; + + /* Given a char*, returns a substring that starts at the first + alphabet character and ends at the last alphabet character, i.e. it + strips off beginning or ending quotes, punctuation, etc. */ + + char *strip(char **word) { + char *start = *word; + int len = strlen(start); + char *end = start + len - 1; + + while ((start < end) && (!isalpha(start[0]))) + start++; + + while ((end > start) && (!isalpha(end[0]))) + end--; + + if (start > end) + return NULL; + + end[1] = '\0'; + *word = start; + + return start; + } + + /* Given a binary search tree (sorted alphabetically by the word at + each node), and a new word, inserts the word at the appropriate + place in the tree. */ + + void insert(tree_node *root, char *word) { + if (root == NULL) + return; + + int compare_value = strcmp(word, root->word); + + if (compare_value == 0) + return; + + if (compare_value < 0) { + if (root->left != NULL) + insert(root->left, word); + else { + tree_node *new_node = (tree_node *)malloc(sizeof(tree_node)); + new_node->word = strdup(word); + new_node->left = NULL; + new_node->right = NULL; + root->left = new_node; + } + } else { + if (root->right != NULL) + insert(root->right, word); + else { + tree_node *new_node = (tree_node *)malloc(sizeof(tree_node)); + new_node->word = strdup(word); + new_node->left = NULL; + new_node->right = NULL; + root->right = new_node; + } + } + } + + /* Read in a text file and storea all the words from the file in a + binary search tree. */ + + void populate_dictionary(tree_node **dictionary, char *filename) { + FILE *in_file; + char word[1024]; + + in_file = fopen(filename, "r"); + if (in_file) { + while (fscanf(in_file, "%s", word) == 1) { + char *new_word = (strdup(word)); + new_word = strip(&new_word); + if (*dictionary == NULL) { + tree_node *new_node = (tree_node *)malloc(sizeof(tree_node)); + new_node->word = new_word; + new_node->left = NULL; + new_node->right = NULL; + *dictionary = new_node; + } else + insert(*dictionary, new_word); + } + } + } + + /* Given a binary search tree and a word, search for the word + in the binary search tree. */ + + int find_word(tree_node *dictionary, char *word) { + if (!word || !dictionary) + return 0; + + int compare_value = strcmp(word, dictionary->word); + + if (compare_value == 0) + return 1; + else if (compare_value < 0) + return find_word(dictionary->left, word); + else + return find_word(dictionary->right, word); + } + + /* Print out the words in the binary search tree, in sorted order. */ + + void print_tree(tree_node *dictionary) { + if (!dictionary) + return; + + if (dictionary->left) + print_tree(dictionary->left); + + printf("%s\n", dictionary->word); + + if (dictionary->right) + print_tree(dictionary->right); + } + + int main(int argc, char **argv) { + tree_node *dictionary = NULL; + char buffer[1024]; + char *filename; + int done = 0; + + if (argc == 2) + filename = argv[1]; + + if (!filename) + return -1; + + populate_dictionary(&dictionary, filename); + fprintf(stdout, "Dictionary loaded.\nEnter search word: "); + while (!done && fgets(buffer, sizeof(buffer), stdin)) { + char *word = buffer; + int len = strlen(word); + int i; + + for (i = 0; i < len; ++i) + word[i] = tolower(word[i]); + + if ((len > 0) && (word[len - 1] == '\n')) { + word[len - 1] = '\0'; + len = len - 1; + } + + if (find_word(dictionary, word)) + fprintf(stdout, "Yes!\n"); + else + fprintf(stdout, "No!\n"); + + fprintf(stdout, "Enter search word: "); + } + + fprintf(stdout, "\n"); + return 0; + } + + +The text for "Romeo and Juliet" can be obtained from the Gutenberg Project +(http://www.gutenberg.org). + diff --git a/docs/use/remote.rst b/docs/use/remote.rst new file mode 100644 index 000000000000..c0efae08fe0c --- /dev/null +++ b/docs/use/remote.rst @@ -0,0 +1,222 @@ +Remote Debugging +================ + +Remote debugging refers to the act of debugging a process which is running on a +different system, than the debugger itself. We shall refer to the system +running the debugger as the local system, while the system running the debugged +process will be the remote system. + +To enable remote debugging, LLDB employs a client-server architecture. The +client part runs on the local system and the remote system runs the server. The +client and server communicate using the gdb-remote protocol, usually +transported over TCP/IP. More information on the protocol can be found here and +the LLDB-specific extensions are documented in docs/lldb-gdb-remote.txt file +inside LLDB source repository. Besides the gdb-remote stub, the server part of +LLDB also consists of a platform binary, which is responsible for performing +advanced debugging operations, like copying files from/to the remote system and +can be used to execute arbitrary shell commands on the remote system. + +In order to reduce code complexity and improve remote debugging experience LLDB +on Linux and OSX uses the remote debugging stub even when debugging a process +locally. This is achieved by spawning a remote stub process locally and +communicating with it over the loopback interface. In the case of local +debugging this whole process is transparent to the user. The platform binary is +not used in this case, since no file transfers are needed. + +Preparation for Remote Debugging +-------------------------------- + +While the process of actual debugging (stepping, backtraces, evaluating +expressions) is same as in the local case, in the case of remote debugging, +more preparation is needed as the required binaries cannot started on the +remote system automatically. Also, if the remote system runs a different OS or +architecture, the server component needs to be compiled separately. + +**Remote system** + +On Linux and Android, all required remote functionality is contained in the +lldb-server binary. This binary combines the functionality of the platform and +gdb-remote stub. A single binary facilitates deployment and reduces code size, +since the two functions share a lot of code. The lldb-server binary is also +statically linked with the rest of LLDB (unlike lldb, which dynamically links +to liblldb.so by default), so it does not have any dependencies on the rest of +lldb. On Mac OSX and iOS, the remote-gdb functionality is implemented by the +debugserver binary, which you will need to deploy alongside lldb-server. + +The binaries mentioned above need to be present on the remote system to enable +remote debugging. You can either compile on the remote system directly or copy +them from the local machine. If compiling locally and the remote architecture +differs from the local one, you will need to cross-compile the correct version +of the binaries. More information on cross-compiling LLDB can be found on the +build page. + +Once the binaries are in place, you just need to run the lldb-server in +platform mode and specify the port it should listen on. For example, the +command + +:: + + remote% lldb-server platform --listen "*:1234" --server + +will start the LLDB platform and wait for incoming connections from any address +to port 1234. Specifying an address instead of * will only allow connections +originating from that address. Adding a --server parameter to the command line +will fork off a new process for every incoming connection, allowing multiple +parallel debug sessions. + +**Local system** + +On the local system, you need to let LLDB know that you intend to do remote +debugging. This is achieved through the platform command and its sub-commands. +As a first step you need to choose the correct platform plug-in for your remote +system. A list of available plug-ins can be obtained through platform list. + +:: + + local% lldb + (lldb) platform list + Available platforms: + host: Local Mac OS X user platform plug-in. + remote-freebsd: Remote FreeBSD user platform plug-in. + remote-linux: Remote Linux user platform plug-in. + remote-netbsd: Remote NetBSD user platform plug-in. + remote-windows: Remote Windows user platform plug-in. + remote-android: Remote Android user platform plug-in. + remote-ios: Remote iOS platform plug-in. + remote-macosx: Remote Mac OS X user platform plug-in. + ios-simulator: iOS simulator platform plug-in. + darwin-kernel: Darwin Kernel platform plug-in. + tvos-simulator: Apple TV simulator platform plug-in. + watchos-simulator: Apple Watch simulator platform plug-in. + remote-tvos: Remote Apple TV platform plug-in. + remote-watchos: Remote Apple Watch platform plug-in. + remote-gdb-server: A platform that uses the GDB remote protocol as the communication transport. + +The default platform is the platform host which is used for local debugging. +Apart from this, the list should contain a number of plug-ins, for debugging +different kinds of systems. The remote plug-ins are prefixed with "remote-". +For example, to debug a remote Linux application: + +:: + + (lldb) platform select remote-linux + +After selecting the platform plug-in, you should receive a prompt which +confirms the selected platform, and states that you are not connected. This is +because remote plug-ins need to be connected to their remote platform +counterpart to operate. This is achieved using the platform connect command. +This command takes a number of arguments (as always, use the help command to +find out more), but normally you only need to specify the address to connect +to, e.g.: + +:: + + (lldb) platform connect connect://remote:1234 + Platform: remote-linux + Triple: x86_64-gnu-linux + Hostname: remote + Connected: yes + WorkingDir: /tmp + +Note that the platform has a working directory of /tmp. This directory will be +used as the directory that executables will be uploaded to by default when +launching a process from local. + +After this, you should be able to debug normally. You can use the process +attach to attach to an existing remote process or target create, process launch +to start a new one. The platform plugin will transparently take care of +uploading or downloading the executable in order to be able to debug. If your +application needs additional files, you can transfer them using the platform +commands: get-file, put-file, mkdir, etc. The environment can be prepared +further using the platform shell command. + +**Launching a locally built process on the remote machine** + +*Install and run in the platform working directory* + +To launch a locally built process on the remote system in the platform working +directory: + +:: + + (lldb) file a.out + (lldb) run + +This will cause LLDB to create a target with the "a.out" executable that you +cross built. The "run" command will cause LLDB to upload "a.out" to the +platform's current working directory only if the file has changed. The platform +connection allows us to transfer files, but also allows us to get the MD5 +checksum of the file on the other end and only upload the file if it has +changed. LLDB will automatically launch a lldb-server in gdbremote mode to +allow you to debug this executable, connect to it and start your debug session +for you. + +*Changing the platform working directory* + +You can change the platform working directory while connected to the platform +with: + +:: + + (lldb) platform settings -w /usr/local/bin + +And you can verify it worked using "platform status": + +:: + + (lldb) platform status + Platform: remote-linux + Triple: x86_64-gnu-linux + Hostname: remote + Connected: yes + WorkingDir: /usr/local/bin + +If we run again, the program will be installed into ``/usr/local/bin``. + +*Install and run by specifying a remote install path* + +If you want the "a.out" executable to be installed into "/bin/a.out" instead of +the platform's current working directory, we can set the platform file +specification using python: + +:: + + (lldb) file a.out + (lldb) script lldb.target.module['a.out'].SetPlatformFileSpec("/bin/a.out") + (lldb) run + +Now when you run your program, the program will be uploaded to "/bin/a.out" +instead of the platform current working directory. Only the main executable is +uploaded to the remote system by default when launching the application. If you +have shared libraries that should also be uploaded, then you can add the +locally build shared library to the current target and set its platform file +specification: + +:: + + (lldb) file a.out + (lldb) target module add /local/build/libfoo.so + (lldb) target module add /local/build/libbar.so + (lldb) script lldb.target.module['libfoo.so'].SetPlatformFileSpec("/usr/lib/libfoo.so") + (lldb) script lldb.target.module['libbar.so'].SetPlatformFileSpec("/usr/local/lib/libbar.so") + (lldb) run + +*Attaching to a remote process* + +If you want to attach to a remote process, you can first list the processes on +the remote system: + +:: + + (lldb) platform process list + 223 matching processes were found on "remote-linux" + PID PARENT USER TRIPLE NAME + ====== ====== ========== ======================== ============================ + 68639 90652 x86_64-apple-macosx lldb + ... + +Then attaching is as simple as specifying the remote process ID: + +:: + + (lldb) attach 68639 diff --git a/docs/use/symbolication.rst b/docs/use/symbolication.rst new file mode 100644 index 000000000000..9724628fa1a5 --- /dev/null +++ b/docs/use/symbolication.rst @@ -0,0 +1,406 @@ +Symbolication +============= + +.. contents:: + :local: + + +LLDB is separated into a shared library that contains the core of the debugger, +and a driver that implements debugging and a command interpreter. LLDB can be +used to symbolicate your crash logs and can often provide more information than +other symbolication programs: + +- Inlined functions +- Variables that are in scope for an address, along with their locations + +The simplest form of symbolication is to load an executable: + +:: + + (lldb) target create --no-dependents --arch x86_64 /tmp/a.out + +We use the ``--no-dependents`` flag with the ``target create`` command so that +we don't load all of the dependent shared libraries from the current system. +When we symbolicate, we are often symbolicating a binary that was running on +another system, and even though the main executable might reference shared +libraries in ``/usr/lib``, we often don't want to load the versions on the +current computer. + +Using the ``image list`` command will show us a list of all shared libraries +associated with the current target. As expected, we currently only have a +single binary: + +:: + + (lldb) image list + [ 0] 73431214-6B76-3489-9557-5075F03E36B4 0x0000000100000000 /tmp/a.out + /tmp/a.out.dSYM/Contents/Resources/DWARF/a.out + +Now we can look up an address: + +:: + + (lldb) image lookup --address 0x100000aa3 + Address: a.out[0x0000000100000aa3] (a.out.__TEXT.__text + 131) + Summary: a.out`main + 67 at main.c:13 + +Since we haven't specified a slide or any load addresses for individual +sections in the binary, the address that we use here is a file address. A file +address refers to a virtual address as defined by each object file. + +If we didn't use the ``--no-dependents`` option with ``target create``, we +would have loaded all dependent shared libraries: + +:: + + (lldb) image list + [ 0] 73431214-6B76-3489-9557-5075F03E36B4 0x0000000100000000 /tmp/a.out + /tmp/a.out.dSYM/Contents/Resources/DWARF/a.out + [ 1] 8CBCF9B9-EBB7-365E-A3FF-2F3850763C6B 0x0000000000000000 /usr/lib/system/libsystem_c.dylib + [ 2] 62AA0B84-188A-348B-8F9E-3E2DB08DB93C 0x0000000000000000 /usr/lib/system/libsystem_dnssd.dylib + [ 3] C0535565-35D1-31A7-A744-63D9F10F12A4 0x0000000000000000 /usr/lib/system/libsystem_kernel.dylib + ... + +Now if we do a lookup using a file address, this can result in multiple matches +since most shared libraries have a virtual address space that starts at zero: + +:: + + (lldb) image lookup -a 0x1000 + Address: a.out[0x0000000000001000] (a.out.__PAGEZERO + 4096) + + Address: libsystem_c.dylib[0x0000000000001000] (libsystem_c.dylib.__TEXT.__text + 928) + Summary: libsystem_c.dylib`mcount + 9 + + Address: libsystem_dnssd.dylib[0x0000000000001000] (libsystem_dnssd.dylib.__TEXT.__text + 456) + Summary: libsystem_dnssd.dylib`ConvertHeaderBytes + 38 + + Address: libsystem_kernel.dylib[0x0000000000001000] (libsystem_kernel.dylib.__TEXT.__text + 1116) + Summary: libsystem_kernel.dylib`clock_get_time + 102 + ... + +To avoid getting multiple file address matches, you can specify the name of the +shared library to limit the search: + +:: + + (lldb) image lookup -a 0x1000 a.out + Address: a.out[0x0000000000001000] (a.out.__PAGEZERO + 4096) + +Defining Load Addresses for Sections +------------------------------------ + +When symbolicating your crash logs, it can be tedious if you always have to +adjust your crashlog-addresses into file addresses. To avoid having to do any +conversion, you can set the load address for the sections of the modules in +your target. Once you set any section load address, lookups will switch to +using load addresses. You can slide all sections in the executable by the same +amount, or set the load address for individual sections. The ``target modules +load --slide`` command allows us to set the load address for all sections. + +Below is an example of sliding all sections in a.out by adding 0x123000 to each +section's file address: + +:: + + (lldb) target create --no-dependents --arch x86_64 /tmp/a.out + (lldb) target modules load --file a.out --slide 0x123000 + + +It is often much easier to specify the actual load location of each section by +name. Crash logs on Mac OS X have a Binary Images section that specifies that +address of the __TEXT segment for each binary. Specifying a slide requires +requires that you first find the original (file) address for the __TEXT +segment, and subtract the two values. If you specify the address of the __TEXT +segment with ``target modules load section address``, you don't need to do any +calculations. To specify the load addresses of sections we can specify one or +more section name + address pairs in the ``target modules load`` command: + +:: + + (lldb) target create --no-dependents --arch x86_64 /tmp/a.out + (lldb) target modules load --file a.out __TEXT 0x100123000 + +We specified that the __TEXT section is loaded at 0x100123000. Now that we have +defined where sections have been loaded in our target, any lookups we do will +now use load addresses so we don't have to do any math on the addresses in the +crashlog backtraces, we can just use the raw addresses: + +:: + + (lldb) image lookup --address 0x100123aa3 + Address: a.out[0x0000000100000aa3] (a.out.__TEXT.__text + 131) + Summary: a.out`main + 67 at main.c:13 + +Loading Multiple Executables +---------------------------- + +You often have more than one executable involved when you need to symbolicate a +crash log. When this happens, you create a target for the main executable or +one of the shared libraries, then add more modules to the target using the +``target modules add`` command. + +Lets say we have a Darwin crash log that contains the following images: + +:: + + Binary Images: + 0x100000000 - 0x100000ff7 /tmp/a.out + 0x7fff83f32000 - 0x7fff83ffefe7 <8CBCF9B9-EBB7-365E-A3FF-2F3850763C6B> /usr/lib/system/libsystem_c.dylib + 0x7fff883db000 - 0x7fff883e3ff7 <62AA0B84-188A-348B-8F9E-3E2DB08DB93C> /usr/lib/system/libsystem_dnssd.dylib + 0x7fff8c0dc000 - 0x7fff8c0f7ff7 /usr/lib/system/libsystem_kernel.dylib + +First we create the target using the main executable and then add any extra +shared libraries we want: + +:: + + (lldb) target create --no-dependents --arch x86_64 /tmp/a.out + (lldb) target modules add /usr/lib/system/libsystem_c.dylib + (lldb) target modules add /usr/lib/system/libsystem_dnssd.dylib + (lldb) target modules add /usr/lib/system/libsystem_kernel.dylib + + +If you have debug symbols in standalone files, such as dSYM files on Mac OS X, +you can specify their paths using the --symfile option for the ``target create`` +(recent LLDB releases only) and ``target modules add`` commands: + +:: + + (lldb) target create --no-dependents --arch x86_64 /tmp/a.out --symfile /tmp/a.out.dSYM + (lldb) target modules add /usr/lib/system/libsystem_c.dylib --symfile /build/server/a/libsystem_c.dylib.dSYM + (lldb) target modules add /usr/lib/system/libsystem_dnssd.dylib --symfile /build/server/b/libsystem_dnssd.dylib.dSYM + (lldb) target modules add /usr/lib/system/libsystem_kernel.dylib --symfile /build/server/c/libsystem_kernel.dylib.dSYM + +Then we set the load addresses for each __TEXT section (note the colors of the +load addresses above and below) using the first address from the Binary Images +section for each image: + +:: + + (lldb) target modules load --file a.out 0x100000000 + (lldb) target modules load --file libsystem_c.dylib 0x7fff83f32000 + (lldb) target modules load --file libsystem_dnssd.dylib 0x7fff883db000 + (lldb) target modules load --file libsystem_kernel.dylib 0x7fff8c0dc000 + + +Now any stack backtraces that haven't been symbolicated can be symbolicated +using ``image lookup`` with the raw backtrace addresses. + +Given the following raw backtrace: + +:: + + Thread 0 Crashed:: Dispatch queue: com.apple.main-thread + 0 libsystem_kernel.dylib 0x00007fff8a1e6d46 __kill + 10 + 1 libsystem_c.dylib 0x00007fff84597df0 abort + 177 + 2 libsystem_c.dylib 0x00007fff84598e2a __assert_rtn + 146 + 3 a.out 0x0000000100000f46 main + 70 + 4 libdyld.dylib 0x00007fff8c4197e1 start + 1 + +We can now symbolicate the load addresses: + +:: + + (lldb) image lookup -a 0x00007fff8a1e6d46 + (lldb) image lookup -a 0x00007fff84597df0 + (lldb) image lookup -a 0x00007fff84598e2a + (lldb) image lookup -a 0x0000000100000f46 + + +Getting Variable Information +---------------------------- + +If you add the --verbose flag to the ``image lookup --address`` command, you +can get verbose information which can often include the locations of some of +your local variables: + +:: + + + (lldb) image lookup --address 0x100123aa3 --verbose + Address: a.out[0x0000000100000aa3] (a.out.__TEXT.__text + 110) + Summary: a.out`main + 50 at main.c:13 + Module: file = "/tmp/a.out", arch = "x86_64" + CompileUnit: id = {0x00000000}, file = "/tmp/main.c", language = "ISO C:1999" + Function: id = {0x0000004f}, name = "main", range = [0x0000000100000bc0-0x0000000100000dc9) + FuncType: id = {0x0000004f}, decl = main.c:9, compiler_type = "int (int, const char **, const char **, const char **)" + Blocks: id = {0x0000004f}, range = [0x100000bc0-0x100000dc9) + id = {0x000000ae}, range = [0x100000bf2-0x100000dc4) + LineEntry: [0x0000000100000bf2-0x0000000100000bfa): /tmp/main.c:13:23 + Symbol: id = {0x00000004}, range = [0x0000000100000bc0-0x0000000100000dc9), name="main" + Variable: id = {0x000000bf}, name = "path", type= "char [1024]", location = DW_OP_fbreg(-1072), decl = main.c:28 + Variable: id = {0x00000072}, name = "argc", type= "int", location = r13, decl = main.c:8 + Variable: id = {0x00000081}, name = "argv", type= "const char **", location = r12, decl = main.c:8 + Variable: id = {0x00000090}, name = "envp", type= "const char **", location = r15, decl = main.c:8 + Variable: id = {0x0000009f}, name = "aapl", type= "const char **", location = rbx, decl = main.c:8 + +The interesting part is the variables that are listed. The variables are the +parameters and local variables that are in scope for the address that was +specified. These variable entries have locations which are shown in bold above. +Crash logs often have register information for the first frame in each stack, +and being able to reconstruct one or more local variables can often help you +decipher more information from a crash log than you normally would be able to. +Note that this is really only useful for the first frame, and only if your +crash logs have register information for your threads. + +Using Python API to Symbolicate +------------------------------- + +All of the commands above can be done through the python script bridge. The +code below will recreate the target and add the three shared libraries that we +added in the darwin crash log example above: + +:: + + triple = "x86_64-apple-macosx" + platform_name = None + add_dependents = False + target = lldb.debugger.CreateTarget("/tmp/a.out", triple, platform_name, add_dependents, lldb.SBError()) + if target: + # Get the executable module + module = target.GetModuleAtIndex(0) + target.SetSectionLoadAddress(module.FindSection("__TEXT"), 0x100000000) + module = target.AddModule ("/usr/lib/system/libsystem_c.dylib", triple, None, "/build/server/a/libsystem_c.dylib.dSYM") + target.SetSectionLoadAddress(module.FindSection("__TEXT"), 0x7fff83f32000) + module = target.AddModule ("/usr/lib/system/libsystem_dnssd.dylib", triple, None, "/build/server/b/libsystem_dnssd.dylib.dSYM") + target.SetSectionLoadAddress(module.FindSection("__TEXT"), 0x7fff883db000) + module = target.AddModule ("/usr/lib/system/libsystem_kernel.dylib", triple, None, "/build/server/c/libsystem_kernel.dylib.dSYM") + target.SetSectionLoadAddress(module.FindSection("__TEXT"), 0x7fff8c0dc000) + + load_addr = 0x00007fff8a1e6d46 + # so_addr is a section offset address, or a lldb.SBAddress object + so_addr = target.ResolveLoadAddress (load_addr) + # Get a symbol context for the section offset address which includes + # a module, compile unit, function, block, line entry, and symbol + sym_ctx = so_addr.GetSymbolContext (lldb.eSymbolContextEverything) + print sym_ctx + + +Use Builtin Python Module to Symbolicate +---------------------------------------- + +LLDB includes a module in the lldb package named lldb.utils.symbolication. This module contains a lot of symbolication functions that simplify the symbolication process by allowing you to create objects that represent symbolication class objects such as: + +- lldb.utils.symbolication.Address +- lldb.utils.symbolication.Section +- lldb.utils.symbolication.Image +- lldb.utils.symbolication.Symbolicator + + +**lldb.utils.symbolication.Address** + +This class represents an address that will be symbolicated. It will cache any +information that has been looked up: module, compile unit, function, block, +line entry, symbol. It does this by having a lldb.SBSymbolContext as a member +variable. + +**lldb.utils.symbolication.Section** + +This class represents a section that might get loaded in a +lldb.utils.symbolication.Image. It has helper functions that allow you to set +it from text that might have been extracted from a crash log file. + +**lldb.utils.symbolication.Image** + +This class represents a module that might get loaded into the target we use for +symbolication. This class contains the executable path, optional symbol file +path, the triple, and the list of sections that will need to be loaded if we +choose the ask the target to load this image. Many of these objects will never +be loaded into the target unless they are needed by symbolication. You often +have a crash log that has 100 to 200 different shared libraries loaded, but +your crash log stack backtraces only use a few of these shared libraries. Only +the images that contain stack backtrace addresses need to be loaded in the +target in order to symbolicate. + +Subclasses of this class will want to override the +locate_module_and_debug_symbols method: + +:: + + class CustomImage(lldb.utils.symbolication.Image): + def locate_module_and_debug_symbols (self): + # Locate the module and symbol given the info found in the crash log + +Overriding this function allows clients to find the correct executable module +and symbol files as they might reside on a build server. + +**lldb.utils.symbolication.Symbolicator** + +This class coordinates the symbolication process by loading only the +lldb.utils.symbolication.Image instances that need to be loaded in order to +symbolicate an supplied address. + +**lldb.macosx.crashlog** + +lldb.macosx.crashlog is a package that is distributed on Mac OS X builds that +subclasses the above classes. This module parses the information in the Darwin +crash logs and creates symbolication objects that represent the images, the +sections and the thread frames for the backtraces. It then uses the functions +in the lldb.utils.symbolication to symbolicate the crash logs. + +This module installs a new ``crashlog`` command into the lldb command +interpreter so that you can use it to parse and symbolicate Mac OS X crash +logs: + +:: + + (lldb) command script import lldb.macosx.crashlog + "crashlog" and "save_crashlog" command installed, use the "--help" option for detailed help + (lldb) crashlog /tmp/crash.log + ... + +The command that is installed has built in help that shows the options that can +be used when symbolicating: + +:: + + (lldb) crashlog --help + Usage: crashlog [options] [FILE ...] + +Symbolicate one or more darwin crash log files to provide source file and line +information, inlined stack frames back to the concrete functions, and +disassemble the location of the crash for the first frame of the crashed +thread. If this script is imported into the LLDB command interpreter, a +``crashlog`` command will be added to the interpreter for use at the LLDB +command line. After a crash log has been parsed and symbolicated, a target will +have been created that has all of the shared libraries loaded at the load +addresses found in the crash log file. This allows you to explore the program +as if it were stopped at the locations described in the crash log and functions +can be disassembled and lookups can be performed using the addresses found in +the crash log. + +:: + + Options: + -h, --help show this help message and exit + -v, --verbose display verbose debug info + -g, --debug display verbose debug logging + -a, --load-all load all executable images, not just the images found + in the crashed stack frames + --images show image list + --debug-delay=NSEC pause for NSEC seconds for debugger + -c, --crashed-only only symbolicate the crashed thread + -d DISASSEMBLE_DEPTH, --disasm-depth=DISASSEMBLE_DEPTH + set the depth in stack frames that should be + disassembled (default is 1) + -D, --disasm-all enabled disassembly of frames on all threads (not just + the crashed thread) + -B DISASSEMBLE_BEFORE, --disasm-before=DISASSEMBLE_BEFORE + the number of instructions to disassemble before the + frame PC + -A DISASSEMBLE_AFTER, --disasm-after=DISASSEMBLE_AFTER + the number of instructions to disassemble after the + frame PC + -C NLINES, --source-context=NLINES + show NLINES source lines of source context (default = + 4) + --source-frames=NFRAMES + show source for NFRAMES (default = 4) + --source-all show source for all threads, not just the crashed + thread + -i, --interactive parse all crash logs and enter interactive mode + + +The source for the "symbolication" and "crashlog" modules are available in SVN. + diff --git a/docs/use/symbols.rst b/docs/use/symbols.rst new file mode 100644 index 000000000000..fe79782959a3 --- /dev/null +++ b/docs/use/symbols.rst @@ -0,0 +1,317 @@ +Symbols on macOS +================ + +.. contents:: + :local: + +On macOS, debug symbols are often in stand alone bundles called **dSYM** files. +These are bundles that contain DWARF debug information and other resources +related to builds and debug info. + +The DebugSymbols.framework framework helps locate dSYM files when given a UUID. +It can locate the symbols using a variety of methods: + +- Spotlight +- Explicit search paths +- Implicit search paths +- File mapped UUID paths +- Running one or more shell scripts + +DebugSymbols.framework also has global defaults that can be modified to allow +all of the debug tools (lldb, gdb, sample, CoreSymbolication.framework) to +easily find important debug symbols. The domain for the DebugSymbols.framework +defaults is **com.apple.DebugSymbols**, and the defaults can be read, written +or modified using the **defaults** shell command: + +:: + + % defaults read com.apple.DebugSymbols + % defaults write com.apple.DebugSymbols KEY ... + % defaults delete com.apple.DebugSymbols KEY + +The following is a list of the defaults key value setting pairs that can +be used to enhance symbol location: + +**DBGFileMappedPaths** + +This default can be specified as a single string, or an array of +strings. Each string represents a directory that contains file mapped +UUID values that point to dSYM files. See the "File Mapped UUID +Directories" section below for more details. Whenever +DebugSymbols.framework is asked to lookup a dSYM file, it will first +look in any file mapped UUID directories for a quick match. + +:: + + % defaults write com.apple.DebugSymbols DBGFileMappedPaths -string /path/to/uuidmap1 + % defaults write com.apple.DebugSymbols DBGFileMappedPaths -array /path/to/uuidmap1 + /path/to/uuidmap2 + +**DBGShellCommands** + +This default can be specified as a single string, or an array of +strings. Specifies a shell script that will get run in order to find the +dSYM. The shell script will be run given a single UUID value as the +shell command arguments and the shell command is expected to return a +property list. See the property list format defined below. + +:: + + % defaults write com.apple.DebugSymbols DBGShellCommands -string /path/to/script1 + % defaults write com.apple.DebugSymbols DBGShellCommands -array /path/to/script1 + /path/to/script2 + +**DBGSpotlightPaths** + +Specifies the directories to limit spotlight searches to as a string or +array of strings. When any other defaults are supplied to +**com.apple.DebugSymbols**, spotlight searches will be disabled unless +this default is set to an empty array: + +:: + + # Specify an empty array to keep Spotlight searches enabled in all locations + % defaults write com.apple.DebugSymbols DBGSpotlightPaths -array + + # Specify an array of paths to limit spotlight searches to certain directories + % defaults write com.apple.DebugSymbols DBGSpotlightPaths -array /path/dir1 /path/dir2 + +Shell Script Property List Format +--------------------------------- + +Shell scripts that are specified with the **DBGShellCommands** defaults key +will be run in the order in which they are specified until a match is found. +The shell script will be invoked with a single UUID string value like +"23516BE4-29BE-350C-91C9-F36E7999F0F1". The shell script must respond with a +property list being written to STDOUT. The property list returned must contain +UUID string values as the root key values, with a dictionary for each UUID. The +dictionaries can contain one or more of the following keys: + ++-----------------------------------+-----------------------------------+ +| Key | Description | ++-----------------------------------+-----------------------------------+ +| **DBGArchitecture** | A textual architecture or target | +| | triple like "x86_64", "i386", or | +| | "x86_64-apple-macosx". | ++-----------------------------------+-----------------------------------+ +| **DBGBuildSourcePath** | A path prefix that was used when | +| | building the dSYM file. The debug | +| | information will contain paths | +| | with this prefix. | ++-----------------------------------+-----------------------------------+ +| **DBGSourcePath** | A path prefix for where the | +| | sources exist after the build has | +| | completed. Often when building | +| | projects, build machines will | +| | host the sources in a temporary | +| | directory while building, then | +| | move the sources to another | +| | location for archiving. If the | +| | paths in the debug info don't | +| | match where the sources are | +| | currently hosted, then specifying | +| | this path along with the | +| | **DBGBuildSourcePath** will help | +| | the developer tools always show | +| | you sources when debugging or | +| | symbolicating. | ++-----------------------------------+-----------------------------------+ +| **DBGDSYMPath** | A path to the dSYM mach-o file | +| | inside the dSYM bundle. | ++-----------------------------------+-----------------------------------+ +| **DBGSymbolRichExecutable** | A path to the symbol rich | +| | executable. Binaries are often | +| | stripped after being built and | +| | packaged into a release. If your | +| | build systems saves an unstripped | +| | executable a path to this | +| | executable can be provided. | ++-----------------------------------+-----------------------------------+ +| **DBGError** | If a binary can not be located | +| | for the supplied UUID, a user | +| | readable error can be returned. | ++-----------------------------------+-----------------------------------+ + +Below is a sample shell script output for a binary that contains two +architectures: + +:: + + + + + + 23516BE4-29BE-350C-91C9-F36E7999F0F1 + + DBGArchitecture + i386 + DBGBuildSourcePath + /path/to/build/sources + DBGSourcePath + /path/to/actual/sources + DBGDSYMPath + /path/to/foo.dSYM/Contents/Resources/DWARF/foo + DBGSymbolRichExecutable + /path/to/unstripped/executable + + A40597AA-5529-3337-8C09-D8A014EB1578 + + DBGArchitecture + x86_64 + DBGBuildSourcePath + /path/to/build/sources + DBGSourcePath + /path/to/actual/sources + DBGDSYMPath + /path/to/foo.dSYM/Contents/Resources/DWARF/foo + DBGSymbolRichExecutable + /path/to/unstripped/executable + + + + +There is no timeout imposed on a shell script when is it asked to locate a dSYM +file, so be careful to not make a shell script that has high latency or takes a +long time to download unless this is really what you want. This can slow down +debug sessions in LLDB and GDB, symbolication with CoreSymbolication or Report +Crash, with no visible feedback to the user. You can quickly return a plist +with a single **DBGError** key that indicates a timeout has been reached. You +might also want to exec new processes to do the downloads so that if you return +an error that indicates a timeout, your download can still proceed after your +shell script has exited so subsequent debug sessions can use the cached files. +It is also important to track when a current download is in progress in case +you get multiple requests for the same UUID so that you don't end up +downloading the same file simultaneously. Also you will want to verify the +download was successful and then and only then place the file into the cache +for tools that will cache files locally. + +Embedding UUID property lists inside the dSYM bundles +----------------------------------------------------- + +Since dSYM files are bundles, you can also place UUID info plists files inside +your dSYM bundles in the **Contents/Resources** directory. One of the main +reasons to create the UUID plists inside the dSYM bundles is that it will help +LLDB and other developer tools show you source. LLDB currently knows how to +check for these plist files so it can automatically remap the source location +information in the debug info. + +If we take the two UUID values from the returns plist above, we can split them +out and save then in the dSYM bundle: + +:: + + % ls /path/to/foo.dSYM/Contents/Resources + 23516BE4-29BE-350C-91C9-F36E7999F0F1.plist + A40597AA-5529-3337-8C09-D8A014EB1578.plist + + % cat /path/to/foo.dSYM/Contents/Resources/23516BE4-29BE-350C-91C9-F36E7999F0F1.plist + + + + + DBGArchitecture + i386 + DBGBuildSourcePath + /path/to/build/sources + DBGSourcePath + /path/to/actual/sources + DBGDSYMPath + /path/to/foo.dSYM/Contents/Resources/DWARF/foo + DBGSymbolRichExecutable + /path/to/unstripped/executable + DBGVersion + 3 + DBGSourcePathRemapping + + /path/to/build/time/src/location1 + /path/to/debug/time/src/location + /path/to/build/time/src/location2 + /path/to/debug/time/src/location + + DBGSymbolRichExecutable + /path/to/unstripped/executable + + + +Note that the output is very close to what is needed by shell script output, so +making the results of your shell script will be very easy to create by +combining two plists into a single one where you take the UUID and use it a +string key, and the value is the contents of the plist. + +LLDB will read the following entries from the per-UUID plist file in the dSYM +bundle: **DBGSymbolRichExecutable**, **DBGBuildSourcePath** and +**DBGSourcePath**, and **DBGSourcePathRemapping** if **DBGVersion** is 3 or +higher. **DBGBuildSourcePath** and **DBGSourcePath** are for remapping a single +file path. For instance, the files may be in /BuildDir/SheetApp/SheetApp-37 +when built, but they are in /SourceDir/SheetApp/SheetApp-37 at debug time, +those two paths could be listed in those keys. If there are multiple source +path remappings, the **DBGSourcePathRemapping** dictionary can be used, where +an arbitrary number of entries may be present. **DBGVersion** should be 3 or +**DBGSourcePathRemapping** will not be read. If both **DBGSourcePathRemapping** +AND **DBGBuildSourcePath**/**DBGSourcePath** are present in the plist, the +**DBGSourcePathRemapping** entries will be used for path remapping first. This +may allow for more specific remappings in the **DBGSourcePathRemapping** +dictionary and a less specific remapping in the +**DBGBuildSourcePath**/**DBGSourcePath** pair as a last resort. + +File Mapped UUID Directories +---------------------------- + +File Mapped directories can be used for efficient dSYM file lookups for local +or remote dSYM files. The UUID is broken up by splitting the first 20 hex +digits into 4 character chunks, and a directory is created for each chunk, and +each subsequent directory is created inside the previous one. A symlink is then +created whose name is the last 12 hex digits in the deepest directory. The +symlinks value is a full path to the mach-o files inside the dSYM bundle which +contains the DWARF. Whenever DebugSymbols.framework is asked to lookup a dSYM +file, it will first look in any file mapped UUID directories for a quick match +if the defaults are appropriately set. + +For example, if we take the sample UUID plist inforamtion from above, we can +create a File Mapped UUID directory cache in +**~/Library/SymbolCache/dsyms/uuids**. We can easily see how things are laid +out: + +:: + + % find ~/Library/SymbolCache/dsyms/uuids -type l + ~/Library/SymbolCache/dsyms/uuids/2351/6BE4/29BE/350C/91C9/F36E7999F0F1 + ~/Library/SymbolCache/dsyms/uuids/A405/97AA/5529/3337/8C09/D8A014EB1578 + +The last entries in these file mapped directories are symlinks to the actual +dsym mach file in the dsym bundle: + +:: + + % ls -lAF ~/Library/SymbolCache/dsyms/uuids/2351/6BE4/29BE/350C/91C9/F36E7999F0F1 + ~/Library/SymbolCache/dsyms/uuids/2351/6BE4/29BE/350C/91C9/F36E7999F0F1@ -> ../../../../../../dsyms/foo.dSYM/Contents/Resources/DWARF/foo + +Then you can also tell DebugSymbols to check this UUID file map cache using: + +:: + + % defaults write com.apple.DebugSymbols DBGFileMappedPaths ~/Library/SymbolCache/dsyms/uuids + +dSYM Locating Shell Script Tips +------------------------------- + +One possible implementation of a dSYM finding shell script is to have the +script download and cache files locally in a known location. Then create a UUID +map for each UUID value that was found in a local UUID File Map cache so the +next query for the dSYM file will be able to use the cached version. So the +shell script is used to initially download and cache the file, and subsequent +accesses will use the cache and avoid calling the shell script. + +Then the defaults for DebugSymbols.framework will entail enabling your shell +script, enabling the file mapped path setting so that already downloaded dSYMS +fill quickly be found without needing to run the shell script every time, and +also leaving spotlight enabled so that other normal dSYM files are still found: + +:: + + % defaults write com.apple.DebugSymbols DBGShellCommands /path/to/shellscript + % defaults write com.apple.DebugSymbols DBGFileMappedPaths ~/Library/SymbolCache/dsyms/uuids + % defaults write com.apple.DebugSymbols DBGSpotlightPaths -array + +Hopefully this helps explain how DebugSymbols.framework can help any company +implement a smart symbol finding and caching with minimal overhead. diff --git a/docs/use/troubleshooting.rst b/docs/use/troubleshooting.rst new file mode 100644 index 000000000000..647b8795c3e5 --- /dev/null +++ b/docs/use/troubleshooting.rst @@ -0,0 +1,102 @@ +Troubleshooting +=============== + +.. contents:: + :local: + +File and Line Breakpoints Are Not Getting Hit +--------------------------------------------- + +First you must make sure that your source files were compiled with debug +information. Typically this means passing -g to the compiler when compiling +your source file. + +When setting breakpoints in implementation source files (.c, cpp, cxx, .m, .mm, +etc), LLDB by default will only search for compile units whose filename +matches. If your code does tricky things like using #include to include source +files: + +:: + + % cat foo.c + #include "bar.c" + #include "baz.c" + ... + +This will cause breakpoints in "bar.c" to be inlined into the compile unit for +"foo.c". If your code does this, or if your build system combines multiple +files in some way such that breakpoints from one implementation file will be +compiled into another implementation file, you will need to tell LLDB to always +search for inlined breakpoint locations by adding the following line to your +~/.lldbinit file: + +:: + + % echo "settings set target.inline-breakpoint-strategy always" >> ~/.lldbinit + +This tells LLDB to always look in all compile units and search for breakpoint +locations by file and line even if the implementation file doesn't match. +Setting breakpoints in header files always searches all compile units because +inline functions are commonly defined in header files and often cause multiple +breakpoints to have source line information that matches many header file +paths. + +If you set a file and line breakpoint using a full path to the source file, +like Xcode does when setting a breakpoint in its GUI on Mac OS X when you click +in the gutter of the source view, this path must match the full paths in the +debug information. If the paths mismatch, possibly due to passing in a resolved +source file path that doesn't match an unresolved path in the debug +information, this can cause breakpoints to not be resolved. Try setting +breakpoints using the file basename only. + +If you are using an IDE and you move your project in your file system and build +again, sometimes doing a clean then build will solve the issue.This will fix +the issue if some .o files didn't get rebuilt after the move as the .o files in +the build folder might still contain stale debug information with the old +source locations. + +How Do I Check If I Have Debug Symbols? +--------------------------------------- + +Checking if a module has any compile units (source files) is a good way to +check if there is debug information in a module: + +:: + + (lldb) file /tmp/a.out + (lldb) image list + [ 0] 71E5A649-8FEF-3887-9CED-D3EF8FC2FD6E 0x0000000100000000 /tmp/a.out + /tmp/a.out.dSYM/Contents/Resources/DWARF/a.out + [ 1] 6900F2BA-DB48-3B78-B668-58FC0CF6BCB8 0x00007fff5fc00000 /usr/lib/dyld + .... + (lldb) script lldb.target.module['/tmp/a.out'].GetNumCompileUnits() + 1 + (lldb) script lldb.target.module['/usr/lib/dyld'].GetNumCompileUnits() + 0 + +Above we can see that "/tmp/a.out" does have a compile unit, and +"/usr/lib/dyld" does not. + +We can also list the full paths to all compile units for a module using python: + +:: + + (lldb) script + Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. + >>> m = lldb.target.module['a.out'] + >>> for i in range(m.GetNumCompileUnits()): + ... cu = m.GetCompileUnitAtIndex(i).file.fullpath + /tmp/main.c + /tmp/foo.c + /tmp/bar.c + >>> + +This can help to show the actual full path to the source files. Sometimes IDEs +will set breakpoints by full paths where the path doesn't match the full path +in the debug info and this can cause LLDB to not resolve breakpoints. You can +use the breakpoint list command with the --verbose option to see the full paths +for any source file and line breakpoints that the IDE set using: + +:: + + (lldb) breakpoint list --verbose diff --git a/docs/use/tutorial.rst b/docs/use/tutorial.rst new file mode 100644 index 000000000000..fc41a7ab6a70 --- /dev/null +++ b/docs/use/tutorial.rst @@ -0,0 +1,673 @@ +Tutorial +======== + +Here's a short precis of how to run lldb if you are familiar with the gdb +command set. We will start with some details on lldb command structure and +syntax to help orient you. + +.. contents:: + :local: + +Command Structure +----------------- + +Unlike gdb's command set, which is rather free-form, we tried to make the lldb command syntax fairly structured. The commands are all of the form: + +:: + + [-options [option-value]] [argument [argument...]] + +The command line parsing is done before command execution, so it is uniform +across all the commands. The command syntax for basic commands is very simple, +arguments, options and option values are all white-space separated, and +double-quotes are used to protect white-spaces in an argument. If you need to +put a backslash or double-quote character in an argument you back-slash it in +the argument. That makes the command syntax more regular, but it also means you +may have to quote some arguments in lldb that you wouldn't in gdb. + + +Options can be placed anywhere on the command line, but if the arguments begin +with a "-" then you have to tell lldb that you're done with options for the +current command by adding an option termination: "--" So for instance if you +want to launch a process and give the "process launch" command the +"--stop-at-entry" option, yet you want the process you are about to launch to +be launched with the arguments "-program_arg value", you would type: + +:: + + (lldb) process launch --stop-at-entry -- -program_arg value + +We also tried to reduce the number of special purpose argument parsers, which +sometimes forces the user to be a little more explicit about stating their +intentions. The first instance you'll note of this is the breakpoint command. +In gdb, to set a breakpoint, you might enter + +:: + + (gdb) break foo.c:12 + +to break at line 12 of foo.c, and: + +:: + + (gdb) break foo + +to break at the function foo. As time went on, the parser that tells foo.c:12 +from foo from foo.c::foo (which means the function foo in the file foo.c) got +more and more complex and bizarre, and especially in C++ there are times where +there's really no way to specify the function you want to break on. The lldb +commands are more verbose but also more precise and allow for intelligent auto +completion. + +To set the same file and line breakpoint in LLDB you can enter either of: + +:: + + (lldb) breakpoint set --file foo.c --line 12 + (lldb) breakpoint set -f foo.c -l 12 + +To set a breakpoint on a function named foo in LLDB you can enter either of: + +:: + + (lldb) breakpoint set --name foo + (lldb) breakpoint set -n foo + +You can use the --name option multiple times to make a breakpoint on a set of +functions as well. This is convenient since it allows you to set common +conditions or commands without having to specify them multiple times: + +:: + + (lldb) breakpoint set --name foo --name bar + +Setting breakpoints by name is even more specialized in LLDB as you can specify +that you want to set a breakpoint at a function by method name. To set a +breakpoint on all C++ methods named foo you can enter either of: + +:: + + (lldb) breakpoint set --method foo + (lldb) breakpoint set -M foo + + +To set a breakpoint Objective-C selectors named alignLeftEdges: you can enter either of: + +:: + + (lldb) breakpoint set --selector alignLeftEdges: + (lldb) breakpoint set -S alignLeftEdges: + +You can limit any breakpoints to a specific executable image by using the +"--shlib " ("-s " for short): + +:: + + (lldb) breakpoint set --shlib foo.dylib --name foo + (lldb) breakpoint set -s foo.dylib -n foo + +The --shlib option can also be repeated to specify several shared libraries. + +Suggestions on more interesting primitives of this sort are also very welcome. + +Just like gdb, the lldb command interpreter does a shortest unique string match +on command names, so the following two commands will both execute the same +command: + +:: + + (lldb) breakpoint set -n "-[SKTGraphicView alignLeftEdges:]" + (lldb) br s -n "-[SKTGraphicView alignLeftEdges:]" + +lldb also supports command completion for source file names, symbol names, file +names, etc. Completion is initiated by a hitting a TAB. Individual options in a +command can have different completers, so for instance the "--file " +option in "breakpoint" completes to source files, the "--shlib " option +to currently loaded shared libraries, etc. We can even do things like if you +specify "--shlib ", and are completing on "--file ", we will only +list source files in the shared library specified by "--shlib ". + +The individual commands are pretty extensively documented. You can use the help +command to get an overview of which commands are available or to obtain details +about specific commands. There is also an apropos command that will search the +help text for all commands for a particular word and dump a summary help string +for each matching command. + +Finally, there is a mechanism to construct aliases for commonly used commands. +So for instance if you get annoyed typing: + +:: + + (lldb) breakpoint set --file foo.c --line 12 + +you can do: + +:: + + (lldb) command alias bfl breakpoint set -f %1 -l %2 + (lldb) bfl foo.c 12 + +We have added a few aliases for commonly used commands (e.g. "step", "next" and +"continue") but we haven't tried to be exhaustive because in our experience it +is more convenient to make the basic commands unique down to a letter or two, +and then learn these sequences than to fill the namespace with lots of aliases, +and then have to type them all the way out. + +However, users are free to customize lldb's command set however they like, and +since lldb reads the file ~/.lldbinit at startup, you can store all your +aliases there and they will be generally available to you. Your aliases are +also documented in the help command so you can remind yourself of what you've +set up. + +One alias of note that we do include by popular demand is a weak emulator of +gdb's "break" command. It doesn't try to do everything that gdb's break command +does (for instance, it doesn't handle foo.c::bar. But it mostly works, and +makes the transition easier. Also by popular demand, it is aliased to b. If you +actually want to learn the lldb command set natively, that means it will get in +the way of the rest of the breakpoint commands. Fortunately, if you don't like +one of our aliases, you an easily get rid of it by running (for example): + +:: + + (lldb) command unalias b + +I actually also do: + +:: + + (lldb) command alias b breakpoint + +so I can run the native lldb breakpoint command with just b + +The lldb command parser also supports "raw" commands, where, after command +options are stripped off, the rest of the command string is passed +uninterpreted to the command. This is convenient for commands whose arguments +might be some complex expression that would be painful to backslash protect. +For instance the "expression" command is a "raw" command for obvious reasons. +The "help" output for a command will tell you if it is "raw" or not, so you +know what to expect. The one thing you have to watch out for is that since raw +commands still can have options, if your command string has dashes in it, +you'll have to indicate these are not option markers by putting "--" after the +command name, but before your command string. + +lldb also has a built-in Python interpreter, which is accessible by the +"script" command. All the functionality of the debugger is available as classes +in the Python interpreter, so the more complex commands that in gdb you would +introduce with the "define" command can be done by writing Python functions +using the lldb-Python library, then loading the scripts into your running +session and accessing them with the "script" command. + +Having given an overview of lldb's command syntax, we proceed to lay out the +stages of a standard debug session. + + +Loading a Program into lldb +--------------------------- + +First we need to set the program to debug. As with gdb, you can start lldb and specify the file you wish to debug on the command line: + +:: + + $ lldb /Projects/Sketch/build/Debug/Sketch.app + Current executable set to '/Projects/Sketch/build/Debug/Sketch.app' (x86_64). + +or you can specify it after the fact with the "file" command: + +:: + + $ lldb + (lldb) file /Projects/Sketch/build/Debug/Sketch.app + Current executable set to '/Projects/Sketch/build/Debug/Sketch.app' (x86_64). + +Setting Breakpoints +------------------- + +We've discussed how to set breakpoints above. You can use help breakpoint set +to see all the options for breakpoint setting. For instance, we might do: + +:: + + (lldb) breakpoint set --selector alignLeftEdges: + Breakpoint created: 1: name = 'alignLeftEdges:', locations = 1, resolved = 1 + +You can find out about the breakpoints you've set with: + +:: + + (lldb) breakpoint list + Current breakpoints: + 1: name = 'alignLeftEdges:', locations = 1, resolved = 1 + 1.1: where = Sketch`-[SKTGraphicView alignLeftEdges:] + 33 at /Projects/Sketch/SKTGraphicView.m:1405, address = 0x0000000100010d5b, resolved, hit count = 0 + + +Note that setting a breakpoint creates a logical breakpoint, which could +resolve to one or more locations. For instance, break by selector would set a +breakpoint on all the methods that implement that selector in the classes in +your program. Similarly, a file and line breakpoint might result in multiple +locations if that file and line were inlined in different places in your code. + +The logical breakpoint has an integer id, and it's locations have an id within +their parent breakpoint (the two are joined by a ".", e.g. 1.1 in the example +above.) + +Also the logical breakpoints remain live so that if another shared library were +to be loaded that had another implementation of the "alignLeftEdges:" selector, +the new location would be added to breakpoint 1 (e.g. a "1.2" breakpoint would +be set on the newly loaded selector). + +The other piece of information in the breakpoint listing is whether the +breakpoint location was resolved or not. A location gets resolved when the file +address it corresponds to gets loaded into the program you are debugging. For +instance if you set a breakpoint in a shared library that then gets unloaded, +that breakpoint location will remain, but it will no longer be resolved. + + +One other thing to note for gdb users is that lldb acts like gdb with: + +:: + + (gdb) set breakpoint pending on + +That is, lldb will always make a breakpoint from your specification, even if it +couldn't find any locations that match the specification. You can tell whether +the expression was resolved or not by checking the locations field in +"breakpoint list", and we report the breakpoint as "pending" when you set it so +you can tell you've made a typo more easily, if that was indeed the reason no +locations were found: + + +:: + + (lldb) breakpoint set --file foo.c --line 12 + Breakpoint created: 2: file ='foo.c', line = 12, locations = 0 (pending) + WARNING: Unable to resolve breakpoint to any actual locations. + +You can delete, disable, set conditions and ignore counts either on all the +locations generated by your logical breakpoint, or on any one of the particular +locations your specification resolved to. For instance if we wanted to add a +command to print a backtrace when we hit this breakpoint we could do: + +:: + + (lldb) breakpoint command add 1.1 + Enter your debugger command(s). Type 'DONE' to end. + > bt + > DONE + +By default, the breakpoint command add command takes lldb command line +commands. You can also specify this explicitly by passing the "--command" +option. Use "--script" if you want to implement your breakpoint command using +the Python script instead. + +This is an convenient point to bring up another feature of the lldb command +help. Do: + +:: + + (lldb) help break command add + Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit. + + Syntax: breakpoint command add + etc... + +When you see arguments to commands specified in the Syntax in angle brackets +like , that indicates that that is some common argument type that +you can get further help on from the command system. So in this case you could +do: + +:: + + (lldb) help -- Breakpoint ID's consist major and + minor numbers; the major etc... + + +Breakpoint Names +---------------- + +Breakpoints carry two orthognal sets of information: one specifies where to set the breakpoint, and the other how to react when the breakpoint is hit. The latter set of information (e.g. commands, conditions, hit-count, auto-continue...) we call breakpoint options. + +It is fairly common to want to apply one set of options to a number of breakpoints. For instance, you might want to check that self == nil and if it is, print a backtrace and continue, on a number of methods. One convenient way to do that would be to make all the breakpoints, then configure the options with: + +:: + + (lldb) breakpoint modify -c "self == nil" -C bt --auto-continue 1 2 3 + +That's not too bad, but you have to repeat this for every new breakpoint you make, and if you wanted to change the options, you have to remember all the ones you are using this way. + +Breakpoint names provide a convenient solution to this problem. The simple solution would be to use the name to gather the breakpoints you want to affect this way into a group. So when you make the breakpoint you would do: + +:: + + (lldb) breakpoint set -N SelfNil + +Then when you've made all your breakpoints, you can set up or modify the options using the name to collect all the relevant breakpoints. + +:: + + (lldb) breakpoint modify -c "self == nil" -C bt --auto-continue SelfNil + +That is better, but suffers from the problem that when new breakpoints get +added, they don't pick up these modifications, and the options only exist in +the context of actual breakpoints, so they are hard to store & reuse. + +A even better solution is to make a fully configured breakpoint name: + +:: + + (lldb) breakpoint name configure -c "self == nil" -C bt --auto-continue SelfNil + +Then you can apply the name to your breakpoints, and they will all pick up +these options. The connection from name to breakpoints remains live, so when +you change the options configured on the name, all the breakpoints pick up +those changes. This makes it easy to use configured names to experiment with +your options. + +You can make breakpoint names in your .lldbinit file, so you can use them to +can behaviors that you have found useful and reapply them in future sessions. + +You can also make a breakpoint name from the options set on a breakpoint: + +:: + + (lldb) breakpoint name configure -B 1 SelfNil + +which makes it easy to copy behavior from one breakpoint to a set of others. + +Setting Watchpoints +------------------- + +In addition to breakpoints, you can use help watchpoint to see all the commands +for watchpoint manipulations. For instance, we might do the following to watch +a variable called 'global' for write operation, but only stop if the condition +'(global==5)' is true: + +:: + + (lldb) watch set var global + Watchpoint created: Watchpoint 1: addr = 0x100001018 size = 4 state = enabled type = w + declare @ '/Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp:12' + (lldb) watch modify -c '(global==5)' + (lldb) watch list + Current watchpoints: + Watchpoint 1: addr = 0x100001018 size = 4 state = enabled type = w + declare @ '/Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp:12' + condition = '(global==5)' + (lldb) c + Process 15562 resuming + (lldb) about to write to 'global'... + Process 15562 stopped and was programmatically restarted. + Process 15562 stopped and was programmatically restarted. + Process 15562 stopped and was programmatically restarted. + Process 15562 stopped and was programmatically restarted. + Process 15562 stopped + * thread #1: tid = 0x1c03, 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16, stop reason = watchpoint 1 + frame #0: 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16 + 13 + 14 static void modify(int32_t &var) { + 15 ++var; + -> 16 } + 17 + 18 int main(int argc, char** argv) { + 19 int local = 0; + (lldb) bt + * thread #1: tid = 0x1c03, 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16, stop reason = watchpoint 1 + frame #0: 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16 + frame #1: 0x0000000100000eac a.out`main + 108 at main.cpp:25 + frame #2: 0x00007fff8ac9c7e1 libdyld.dylib`start + 1 + (lldb) frame var global + (int32_t) global = 5 + (lldb) watch list -v + Current watchpoints: + Watchpoint 1: addr = 0x100001018 size = 4 state = enabled type = w + declare @ '/Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp:12' + condition = '(global==5)' + hw_index = 0 hit_count = 5 ignore_count = 0 + (lldb) + +Starting or Attaching to Your Program +------------------------------------- + +To launch a program in lldb we use the "process launch" command or one of its built in aliases: + +:: + + (lldb) process launch + (lldb) run + (lldb) r + +You can also attach to a process by process ID or process name. When attaching +to a process by name, lldb also supports the "--waitfor" option which waits for +the next process that has that name to show up, and attaches to it + +:: + + (lldb) process attach --pid 123 + (lldb) process attach --name Sketch + (lldb) process attach --name Sketch --waitfor + +After you launch or attach to a process, your process might stop somewhere: + +:: + + (lldb) process attach -p 12345 + Process 46915 Attaching + Process 46915 Stopped + 1 of 3 threads stopped with reasons: + * thread #1: tid = 0x2c03, 0x00007fff85cac76a, where = libSystem.B.dylib`__getdirentries64 + 10, stop reason = signal = SIGSTOP, queue = com.apple.main-thread + +Note the line that says "1 of 3 threads stopped with reasons:" and the lines +that follow it. In a multi-threaded environment it is very common for more than +one thread to hit your breakpoint(s) before the kernel actually returns control +to the debugger. In that case, you will see all the threads that stopped for +some interesting reason listed in the stop message. + +Controlling Your Program +------------------------ + +After launching, we can continue until we hit our breakpoint. The primitive commands for process control all exist under the "thread" command: + +:: + + (lldb) thread continue + Resuming thread 0x2c03 in process 46915 + Resuming process 46915 + (lldb) + +At present you can only operate on one thread at a time, but the design will ultimately support saying "step over the function in Thread 1, and step into the function in Thread 2, and continue Thread 3" etc. When we eventually support keeping some threads running while others are stopped this will be particularly important. For convenience, however, all the stepping commands have easy aliases. So "thread continue" is just "c", etc. + +The other program stepping commands are pretty much the same as in gdb. You've got: + +:: + + (lldb) thread step-in // The same as gdb's "step" or "s" + (lldb) thread step-over // The same as gdb's "next" or "n" + (lldb) thread step-out // The same as gdb's "finish" or "f" + +By default, lldb does defined aliases to all common gdb process control commands ("s", "step", "n", "next", "finish"). If we have missed any, please add them to your ~/.lldbinit file using the "command alias" command. + +lldb also supported the step by instruction versions: + +:: + + + (lldb) thread step-inst // The same as gdb's "stepi" / "si" + (lldb) thread step-over-inst // The same as gdb's "nexti" / "ni" + +Finally, lldb has a run until line or frame exit stepping mode: + +:: + + (lldb) thread until 100 + +This command will run the thread in the current frame till it reaches line 100 +in this frame or stops if it leaves the current frame. This is a pretty close +equivalent to gdb's "until" command. + +A process, by default, will share the lldb terminal with the inferior process. +When in this mode, much like when debugging with gdb, when the process is +running anything you type will go to the STDIN of the inferior process. To +interrupt your inferior program, type CTRL+C. + +If you attach to a process, or launch a process with the "--no-stdin" option, +the command interpreter is always available to enter commands. This might be a +little disconcerting to gdb users when always have an (lldb) prompt. This +allows you to set a breakpoint, etc without having to explicitly interrupt the +program you are debugging: + +:: + + (lldb) process continue + (lldb) breakpoint set --name stop_here + +There are many commands that won't work while running, and the command +interpreter should do a good job of letting you know when this is the case. If +you find any instances where the command interpreter isn't doing its job, +please file a bug. This way of operation will set us up for a future debugging +mode called thread centric debugging. This mode will allow us to run all +threads and only stop the threads that are at breakpoints or have exceptions or +signals. + +The commands that currently work while running include interrupting the process +to halt execution ("process interrupt"), getting the process status ("process +status"), breakpoint setting and clearing (" breakpoint +[set|clear|enable|disable|list] ..."), and memory reading and writing (" memory +[read|write] ..."). + +The question of disabling stdio when running brings up a good opportunity to +show how to set debugger properties in general. If you always want to run in +the --no-stdin mode, you can set this as a generic process property using the +lldb "settings" command, which is equivalent to gdb's "set" command. For +instance, in this case you would say: + +:: + + (lldb) settings set target.process.disable-stdio true + +Over time, gdb's "set command became a wilderness of disordered options, so +that there were useful options that even experienced gdb users didn't know +about because they were too hard to find. We tried to organize the settings +hierarchically using the structure of the basic entities in the debugger. For +the most part anywhere you can specify a setting on a generic entity (threads, +for example) you can also apply the option to a particular instance, which can +also be convenient at times. You can view the available settings with "settings +list" and there is help on the settings command explaining how it works more +generally. + +Examining Thread State +---------------------- + +Once you've stopped, lldb will choose a current thread, usually the one that +stopped "for a reason", and a current frame in that thread (on stop this is +always the bottom-most frame). Many the commands for inspecting state work on +this current thread/frame. + +To inspect the current state of your process, you can start with the threads: + +:: + + (lldb) thread list + Process 46915 state is Stopped + * thread #1: tid = 0x2c03, 0x00007fff85cac76a, where = libSystem.B.dylib`__getdirentries64 + 10, stop reason = signal = SIGSTOP, queue = com.apple.main-thread + thread #2: tid = 0x2e03, 0x00007fff85cbb08a, where = libSystem.B.dylib`kevent + 10, queue = com.apple.libdispatch-manager + thread #3: tid = 0x2f03, 0x00007fff85cbbeaa, where = libSystem.B.dylib`__workq_kernreturn + 10 + +The ``*`` indicates that Thread 1 is the current thread. To get a backtrace for +that thread, do: + +:: + + (lldb) thread backtrace + thread #1: tid = 0x2c03, stop reason = breakpoint 1.1, queue = com.apple.main-thread + frame #0: 0x0000000100010d5b, where = Sketch`-[SKTGraphicView alignLeftEdges:] + 33 at /Projects/Sketch/SKTGraphicView.m:1405 + frame #1: 0x00007fff8602d152, where = AppKit`-[NSApplication sendAction:to:from:] + 95 + frame #2: 0x00007fff860516be, where = AppKit`-[NSMenuItem _corePerformAction] + 365 + frame #3: 0x00007fff86051428, where = AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 121 + frame #4: 0x00007fff860370c1, where = AppKit`-[NSMenu performKeyEquivalent:] + 272 + frame #5: 0x00007fff86035e69, where = AppKit`-[NSApplication _handleKeyEquivalent:] + 559 + frame #6: 0x00007fff85f06aa1, where = AppKit`-[NSApplication sendEvent:] + 3630 + frame #7: 0x00007fff85e9d922, where = AppKit`-[NSApplication run] + 474 + frame #8: 0x00007fff85e965f8, where = AppKit`NSApplicationMain + 364 + frame #9: 0x0000000100015ae3, where = Sketch`main + 33 at /Projects/Sketch/SKTMain.m:11 + frame #10: 0x0000000100000f20, where = Sketch`start + 52 + +You can also provide a list of threads to backtrace, or the keyword "all" to see all threads: + +:: + + (lldb) thread backtrace all + +You can select the current thread, which will be used by default in all the +commands in the next section, with the "thread select" command: + +:: + + (lldb) thread select 2 + +where the thread index is just the one shown in the "thread list" listing. + + +Examining Stack Frame State +--------------------------- + +The most convenient way to inspect a frame's arguments and local variables is +to use the "frame variable" command: + +:: + + (lldb) frame variable + self = (SKTGraphicView *) 0x0000000100208b40 + _cmd = (struct objc_selector *) 0x000000010001bae1 + sender = (id) 0x00000001001264e0 + selection = (NSArray *) 0x00000001001264e0 + i = (NSUInteger) 0x00000001001264e0 + c = (NSUInteger) 0x00000001001253b0 + +As you see above, if you don't specify any variable names, all arguments and +locals will be shown. If you call "frame variable" passing in the names of a +particular local(s), only those variables will be printed. For instance: + +:: + + (lldb) frame variable self + (SKTGraphicView *) self = 0x0000000100208b40 + +You can also pass in a path to some subelement of one of the available locals, +and that sub-element will be printed. For instance: + +:: + + (lldb) frame variable self.isa + (struct objc_class *) self.isa = 0x0000000100023730 + +The "frame variable" command is not a full expression parser but it does +support a few simple operations like ``&``, ``*``, ``->``, ``[]`` (no +overloaded operators). The array brackets can be used on pointers to treat +pointers as arrays: + +:: + + (lldb) frame variable *self + (SKTGraphicView *) self = 0x0000000100208b40 + (NSView) NSView = { + (NSResponder) NSResponder = { + ... + + (lldb) frame variable &self + (SKTGraphicView **) &self = 0x0000000100304ab + + (lldb) frame variable argv[0] + (char const *) argv[0] = 0x00007fff5fbffaf8 "/Projects/Sketch/build/Debug/Sketch.app/Contents/MacOS/Sketch" + +The frame variable command will also perform "object printing" operations on +variables (currently we only support ObjC printing, using the object's +"description" method. Turn this on by passing the -o flag to frame variable: + +:: + + (lldb) frame variable -o self (SKTGraphicView *) self = 0x0000000100208b40 + You can select another frame to view with the "frame select" command + + (lldb) frame select 9 + frame #9: 0x0000000100015ae3, where = Sketch`function1 + 33 at /Projects/Sketch/SKTFunctions.m:11 + +You can also move up and down the stack by passing the "--relative" ("-r") option. And we have built-in aliases "u" and "d" which behave like their gdb equivalents. diff --git a/docs/use/variable.rst b/docs/use/variable.rst new file mode 100644 index 000000000000..7d496c37bd4d --- /dev/null +++ b/docs/use/variable.rst @@ -0,0 +1,1135 @@ +Variable Formatting +=================== + +.. contents:: + :local: + +LLDB has a data formatters subsystem that allows users to define custom display +options for their variables. + +Usually, when you type frame variable or run some expression LLDB will +automatically choose the way to display your results on a per-type basis, as in +the following example: + +:: + + (lldb) frame variable + (uint8_t) x = 'a' + (intptr_t) y = 124752287 + +However, in certain cases, you may want to associate a different style to the display for certain datatypes. To do so, you need to give hints to the debugger +as to how variables should be displayed. The LLDB type command allows you to do +just that. + +Using it you can change your visualization to look like this: + +:: + + (lldb) frame variable + (uint8_t) x = chr='a' dec=65 hex=0x41 + (intptr_t) y = 0x76f919f + +There are several features related to data visualization: formats, summaries, +filters, synthetic children. + +To reflect this, the type command has five subcommands: + +:: + + type format + type summary + type filter + type synthetic + type category + +These commands are meant to bind printing options to types. When variables are +printed, LLDB will first check if custom printing options have been associated +to a variable's type and, if so, use them instead of picking the default +choices. + +Each of the commands (except ``type category``) has four subcommands available: + +- ``add``: associates a new printing option to one or more types +- ``delete``: deletes an existing association +- ``list``: provides a listing of all associations +- ``clear``: deletes all associations + +Type Format +----------- + +Type formats enable you to quickly override the default format for displaying +primitive types (the usual basic C/C++/ObjC types: int, float, char, ...). + +If for some reason you want all int variables in your program to print out as +hex, you can add a format to the int type. + +This is done by typing + +:: + + (lldb) type format add --format hex int + +at the LLDB command line. + +The ``--format`` (which you can shorten to -f) option accepts a :doc:`format +name`. Then, you provide one or more types to which you want the +new format applied. + +A frequent scenario is that your program has a typedef for a numeric type that +you know represents something that must be printed in a certain way. Again, you +can add a format just to that typedef by using type format add with the name +alias. + +But things can quickly get hierarchical. Let's say you have a situation like +the following: + +:: + + typedef int A; + typedef A B; + typedef B C; + typedef C D; + +and you want to show all A's as hex, all C's as byte arrays and leave the +defaults untouched for other types (albeit its contrived look, the example is +far from unrealistic in large software systems). + +If you simply type + +:: + + (lldb) type format add -f hex A + (lldb) type format add -f uint8_t[] C + +values of type B will be shown as hex and values of type D as byte arrays, as in: + +:: + + (lldb) frame variable -T + (A) a = 0x00000001 + (B) b = 0x00000002 + (C) c = {0x03 0x00 0x00 0x00} + (D) d = {0x04 0x00 0x00 0x00} + +This is because by default LLDB cascades formats through typedef chains. In +order to avoid that you can use the option -C no to prevent cascading, thus +making the two commands required to achieve your goal: + +:: + + (lldb) type format add -C no -f hex A + (lldb) type format add -C no -f uint8_t[] C + + +which provides the desired output: + +:: + + (lldb) frame variable -T + (A) a = 0x00000001 + (B) b = 2 + (C) c = {0x03 0x00 0x00 0x00} + (D) d = 4 + +Two additional options that you will want to look at are --skip-pointers (-p) +and --skip-references (-r). These two options prevent LLDB from applying a +format for type T to values of type T* and T& respectively. + +:: + + (lldb) type format add -f float32[] int + (lldb) frame variable pointer *pointer -T + (int *) pointer = {1.46991e-39 1.4013e-45} + (int) *pointer = {1.53302e-42} + (lldb) type format add -f float32[] int -p + (lldb) frame variable pointer *pointer -T + (int *) pointer = 0x0000000100100180 + (int) *pointer = {1.53302e-42} + +While they can be applied to pointers and references, formats will make no +attempt to dereference the pointer and extract the value before applying the +format, which means you are effectively formatting the address stored in the +pointer rather than the pointee value. For this reason, you may want to use the +-p option when defining formats. + +If you need to delete a custom format simply type type format delete followed +by the name of the type to which the format applies.Even if you defined the +same format for multiple types on the same command, type format delete will +only remove the format for the type name passed as argument. + +To delete ALL formats, use ``type format clear``. To see all the formats +defined, use type format list. + +If all you need to do, however, is display one variable in a custom format, +while leaving the others of the same type untouched, you can simply type: + +:: + + (lldb) frame variable counter -f hex + +This has the effect of displaying the value of counter as an hexadecimal +number, and will keep showing it this way until you either pick a different +format or till you let your program run again. + +Finally, this is a list of formatting options available out of which you can +pick: + ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| **Format name** | **Abbreviation** | **Description** | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``default`` | | the default LLDB algorithm is used to pick a format | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``boolean`` | B | show this as a true/false boolean, using the customary rule that 0 is | +| | | false and everything else is true | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``binary`` | b | show this as a sequence of bits | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``bytes`` | y | show the bytes one after the other | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``bytes with ASCII`` | Y | show the bytes, but try to display them as ASCII characters as well | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``character`` | c | show the bytes as ASCII characters | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``printable character`` | C | show the bytes as printable ASCII characters | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``complex float`` | F | interpret this value as the real and imaginary part of a complex | +| | | floating-point number | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``c-string`` | s | show this as a 0-terminated C string | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``decimal`` | i | show this as a signed integer number (this does not perform a cast, it | +| | | simply shows the bytes as an integer with sign) | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``enumeration`` | E | show this as an enumeration, printing the | +| | | value's name if available or the integer value otherwise | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``hex`` | x | show this as in hexadecimal notation (this does | +| | | not perform a cast, it simply shows the bytes as hex) | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``float`` | f | show this as a floating-point number (this does not perform a cast, it | +| | | simply interprets the bytes as an IEEE754 floating-point value) | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``octal`` | o | show this in octal notation | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``OSType`` | O | show this as a MacOS OSType | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``unicode16`` | U | show this as UTF-16 characters | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``unicode32`` | | show this as UTF-32 characters | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``unsigned decimal`` | u | show this as an unsigned integer number (this does not perform a cast, | +| | | it simply shows the bytes as unsigned integer) | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``pointer`` | p | show this as a native pointer (unless this is really a pointer, the | +| | | resulting address will probably be invalid) | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``char[]`` | | show this as an array of characters | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``int8_t[], uint8_t[]`` | | show this as an array of the corresponding integer type | +| ``int16_t[], uint16_t[]`` | | | +| ``int32_t[], uint32_t[]`` | | | +| ``int64_t[], uint64_t[]`` | | | +| ``uint128_t[]`` | | | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``float32[], float64[]`` | | show this as an array of the corresponding | +| | | floating-point type | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``complex integer`` | I | interpret this value as the real and imaginary part of a complex integer | +| | | number | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ +| ``character array`` | a | show this as a character array | ++-----------------------------------------------+------------------+--------------------------------------------------------------------------+ + +Type Summary +------------ + +Type formats work by showing a different kind of display for the value of a +variable. However, they only work for basic types. When you want to display a +class or struct in a custom format, you cannot do that using formats. + +A different feature, type summaries, works by extracting information from +classes, structures, ... (aggregate types) and arranging it in a user-defined +format, as in the following example: + +before adding a summary... + +:: + + (lldb) frame variable -T one + (i_am_cool) one = { + (int) x = 3 + (float) y = 3.14159 + (char) z = 'E' + } + +after adding a summary... + +:: + + (lldb) frame variable one + (i_am_cool) one = int = 3, float = 3.14159, char = 69 + +There are two ways to use type summaries: the first one is to bind a summary +string to the type; the second is to write a Python script that returns the +string to be used as summary. Both options are enabled by the type summary add +command. + +The command to obtain the output shown in the example is: + +:: + +(lldb) type summary add --summary-string "int = ${var.x}, float = ${var.y}, char = ${var.z%u}" i_am_cool + +Initially, we will focus on summary strings, and then describe the Python +binding mechanism. + +Summary Strings +--------------- + +Summary strings are written using a simple control language, exemplified by the +snippet above. A summary string contains a sequence of tokens that are +processed by LLDB to generate the summary. + +Summary strings can contain plain text, control characters and special +variables that have access to information about the current object and the +overall program state. + +Plain text is any sequence of characters that doesn't contain a ``{``, ``}``, ``$``, +or ``\`` character, which are the syntax control characters. + +The special variables are found in between a "${" prefix, and end with a "}" +suffix. Variables can be a simple name or they can refer to complex objects +that have subitems themselves. In other words, a variable looks like +``${object}`` or ``${object.child.otherchild}``. A variable can also be +prefixed or suffixed with other symbols meant to change the way its value is +handled. An example is ``${*var.int_pointer[0-3]}``. + +Basically, the syntax is the same one described Frame and Thread Formatting +plus additional symbols specific for summary strings. The main of them is +${var, which is used refer to the variable that a summary is being created for. + +The simplest thing you can do is grab a member variable of a class or structure +by typing its expression path. In the previous example, the expression path for +the field float y is simply .y. Thus, to ask the summary string to display y +you would type ${var.y}. + +If you have code like the following: + +:: + + struct A { + int x; + int y; + }; + struct B { + A x; + A y; + int *z; + }; + +the expression path for the y member of the x member of an object of type B +would be .x.y and you would type ``${var.x.y}`` to display it in a summary +string for type B. + +By default, a summary defined for type T, also works for types T* and T& (you +can disable this behavior if desired). For this reason, expression paths do not +differentiate between . and ->, and the above expression path .x.y would be +just as good if you were displaying a B*, or even if the actual definition of B +were: + +:: + + struct B { + A *x; + A y; + int *z; + }; + +This is unlike the behavior of frame variable which, on the contrary, will +enforce the distinction. As hinted above, the rationale for this choice is that +waiving this distinction enables you to write a summary string once for type T +and use it for both T and T* instances. As a summary string is mostly about +extracting nested members' information, a pointer to an object is just as good +as the object itself for the purpose. + +If you need to access the value of the integer pointed to by B::z, you cannot +simply say ${var.z} because that symbol refers to the pointer z. In order to +dereference it and get the pointed value, you should say ``${*var.z}``. The +``${*var`` tells LLDB to get the object that the expression paths leads to, and +then dereference it. In this example is it equivalent to ``*(bObject.z)`` in +C/C++ syntax. Because . and -> operators can both be used, there is no need to +have dereferences in the middle of an expression path (e.g. you do not need to +type ``${*(var.x).x}``) to read A::x as contained in ``*(B::x)``. To achieve +that effect you can simply write ``${var.x->x}``, or even ``${var.x.x}``. The +``*`` operator only binds to the result of the whole expression path, rather +than piecewise, and there is no way to use parentheses to change that behavior. + +Of course, a summary string can contain more than one ${var specifier, and can +use ``${var`` and ``${*var`` specifiers together. + +Formatting Summary Elements +--------------------------- + +An expression path can include formatting codes. Much like the type formats +discussed previously, you can also customize the way variables are displayed in +summary strings, regardless of the format they have applied to their types. To +do that, you can use %format inside an expression path, as in ${var.x->x%u}, +which would display the value of x as an unsigned integer. + +You can also use some other special format markers, not available for formats +themselves, but which carry a special meaning when used in this context: + ++------------+--------------------------------------------------------------------------+ +| **Symbol** | **Description** | ++------------+--------------------------------------------------------------------------+ +| ``Symbol`` | ``Description`` | ++------------+--------------------------------------------------------------------------+ +| ``%S`` | Use this object's summary (the default for aggregate types) | ++------------+--------------------------------------------------------------------------+ +| ``%V`` | Use this object's value (the default for non-aggregate types) | ++------------+--------------------------------------------------------------------------+ +| ``%@`` | Use a language-runtime specific description (for C++ this does nothing, | +| | for Objective-C it calls the NSPrintForDebugger API) | ++------------+--------------------------------------------------------------------------+ +| ``%L`` | Use this object's location (memory address, register name, ...) | ++------------+--------------------------------------------------------------------------+ +| ``%#`` | Use the count of the children of this object | ++------------+--------------------------------------------------------------------------+ +| ``%T`` | Use this object's datatype name | ++------------+--------------------------------------------------------------------------+ +| ``%N`` | Print the variable's basename | ++------------+--------------------------------------------------------------------------+ +| ``%>`` | Print the expression path for this item | ++------------+--------------------------------------------------------------------------+ + +Starting with SVN r228207, you can also specify +``${script.var:pythonFuncName}``. Previously, back to r220821, this was +specified with a different syntax: ``${var.script:pythonFuncName}``. + +It is expected that the function name you use specifies a function whose +signature is the same as a Python summary function. The return string from the +function will be placed verbatim in the output. + +You cannot use element access, or formatting symbols, in combination with this +syntax. For example the following: + +:: + + ${script.var.element[0]:myFunctionName%@} + +is not valid and will cause the summary to fail to evaluate. + + +Element Inlining +---------------- + +Option --inline-children (-c) to type summary add tells LLDB not to look for a summary string, but instead to just print a listing of all the object's children on one line. + +As an example, given a type pair: + +:: + + (lldb) frame variable --show-types a_pair + (pair) a_pair = { + (int) first = 1; + (int) second = 2; + } + +If one types the following commands: + +:: + + (lldb) type summary add --inline-children pair + +the output becomes: + +:: + + (lldb) frame variable a_pair + (pair) a_pair = (first=1, second=2) + + +Of course, one can obtain the same effect by typing + +:: + + (lldb) type summary add pair --summary-string "(first=${var.first}, second=${var.second})" + +While the final result is the same, using --inline-children can often save +time. If one does not need to see the names of the variables, but just their +values, the option --omit-names (-O, uppercase letter o), can be combined with +--inline-children to obtain: + +:: + + (lldb) frame variable a_pair + (pair) a_pair = (1, 2) + +which is of course the same as typing + +:: + + (lldb) type summary add pair --summary-string "(${var.first}, ${var.second})" + +Bitfields And Array Syntax +-------------------------- + +Sometimes, a basic type's value actually represents several different values +packed together in a bitfield. + +With the classical view, there is no way to look at them. Hexadecimal display +can help, but if the bits actually span nibble boundaries, the help is limited. + +Binary view would show it all without ambiguity, but is often too detailed and +hard to read for real-life scenarios. + +To cope with the issue, LLDB supports native bitfield formatting in summary +strings. If your expression paths leads to a so-called scalar type (the usual +int, float, char, double, short, long, long long, double, long double and +unsigned variants), you can ask LLDB to only grab some bits out of the value +and display them in any format you like. If you only need one bit you can use +the [n], just like indexing an array. To extract multiple bits, you can use a +slice-like syntax: [n-m], e.g. + +:: + + (lldb) frame variable float_point + (float) float_point = -3.14159 + +:: + + (lldb) type summary add --summary-string "Sign: ${var[31]%B} Exponent: ${var[30-23]%x} Mantissa: ${var[0-22]%u}" float + (lldb) frame variable float_point + (float) float_point = -3.14159 Sign: true Exponent: 0x00000080 Mantissa: 4788184 + +In this example, LLDB shows the internal representation of a float variable by +extracting bitfields out of a float object. + +When typing a range, the extremes n and m are always included, and the order of +the indices is irrelevant. + +LLDB also allows to use a similar syntax to display array members inside a summary string. For instance, you may want to display all arrays of a given type using a more compact notation than the default, and then just delve into individual array members that prove interesting to your debugging task. You can tell LLDB to format arrays in special ways, possibly independent of the way the array members' datatype is formatted. +e.g. + +:: + + (lldb) frame variable sarray + (Simple [3]) sarray = { + [0] = { + x = 1 + y = 2 + z = '\x03' + } + [1] = { + x = 4 + y = 5 + z = '\x06' + } + [2] = { + x = 7 + y = 8 + z = '\t' + } + } + + (lldb) type summary add --summary-string "${var[].x}" "Simple [3]" + + (lldb) frame variable sarray + (Simple [3]) sarray = [1,4,7] + +The [] symbol amounts to: if var is an array and I know its size, apply this summary string to every element of the array. Here, we are asking LLDB to display .x for every element of the array, and in fact this is what happens. If you find some of those integers anomalous, you can then inspect that one item in greater detail, without the array format getting in the way: + +:: + + (lldb) frame variable sarray[1] + (Simple) sarray[1] = { + x = 4 + y = 5 + z = '\x06' + } + +You can also ask LLDB to only print a subset of the array range by using the +same syntax used to extract bit for bitfields: + +:: + + (lldb) type summary add --summary-string "${var[1-2].x}" "Simple [3]" + + (lldb) frame variable sarray + (Simple [3]) sarray = [4,7] + +If you are dealing with a pointer that you know is an array, you can use this +syntax to display the elements contained in the pointed array instead of just +the pointer value. However, because pointers have no notion of their size, the +empty brackets [] operator does not work, and you must explicitly provide +higher and lower bounds. + +In general, LLDB needs the square brackets operator [] in order to handle +arrays and pointers correctly, and for pointers it also needs a range. However, +a few special cases are defined to make your life easier: + +you can print a 0-terminated string (C-string) using the %s format, omitting +square brackets, as in: + +:: + + (lldb) type summary add --summary-string "${var%s}" "char *" + +This syntax works for char* as well as for char[] because LLDB can rely on the +final \0 terminator to know when the string has ended. + +LLDB has default summary strings for char* and char[] that use this special +case. On debugger startup, the following are defined automatically: + +:: + + (lldb) type summary add --summary-string "${var%s}" "char *" + (lldb) type summary add --summary-string "${var%s}" -x "char \[[0-9]+]" + +any of the array formats (int8_t[], float32{}, ...), and the y, Y and a formats +work to print an array of a non-aggregate type, even if square brackets are +omitted. + +:: + + (lldb) type summary add --summary-string "${var%int32_t[]}" "int [10]" + +This feature, however, is not enabled for pointers because there is no way for +LLDB to detect the end of the pointed data. + +This also does not work for other formats (e.g. boolean), and you must specify +the square brackets operator to get the expected output. + +Python Scripting +---------------- + +Most of the times, summary strings prove good enough for the job of summarizing +the contents of a variable. However, as soon as you need to do more than +picking some values and rearranging them for display, summary strings stop +being an effective tool. This is because summary strings lack the power to +actually perform any kind of computation on the value of variables. + +To solve this issue, you can bind some Python scripting code as a summary for +your datatype, and that script has the ability to both extract children +variables as the summary strings do and to perform active computation on the +extracted values. As a small example, let's say we have a Rectangle class: + +:: + + + class Rectangle + { + private: + int height; + int width; + public: + Rectangle() : height(3), width(5) {} + Rectangle(int H) : height(H), width(H*2-1) {} + Rectangle(int H, int W) : height(H), width(W) {} + int GetHeight() { return height; } + int GetWidth() { return width; } + }; + +Summary strings are effective to reduce the screen real estate used by the +default viewing mode, but are not effective if we want to display the area and +perimeter of Rectangle objects + +To obtain this, we can simply attach a small Python script to the Rectangle +class, as shown in this example: + +:: + + (lldb) type summary add -P Rectangle + Enter your Python command(s). Type 'DONE' to end. + def function (valobj,internal_dict): + height_val = valobj.GetChildMemberWithName('height') + width_val = valobj.GetChildMemberWithName('width') + height = height_val.GetValueAsUnsigned(0) + width = width_val.GetValueAsUnsigned(0) + area = height*width + perimeter = 2*(height + width) + return 'Area: ' + str(area) + ', Perimeter: ' + str(perimeter) + DONE + (lldb) frame variable + (Rectangle) r1 = Area: 20, Perimeter: 18 + (Rectangle) r2 = Area: 72, Perimeter: 36 + (Rectangle) r3 = Area: 16, Perimeter: 16 + +In order to write effective summary scripts, you need to know the LLDB public +API, which is the way Python code can access the LLDB object model. For further +details on the API you should look at the LLDB API reference documentation. + + +As a brief introduction, your script is encapsulated into a function that is +passed two parameters: ``valobj`` and ``internal_dict``. + +``internal_dict`` is an internal support parameter used by LLDB and you should +not touch it. + +``valobj`` is the object encapsulating the actual variable being displayed, and +its type is SBValue. Out of the many possible operations on an SBValue, the +basic one is retrieve the children objects it contains (essentially, the fields +of the object wrapped by it), by calling ``GetChildMemberWithName()``, passing +it the child's name as a string. + +If the variable has a value, you can ask for it, and return it as a string +using ``GetValue()``, or as a signed/unsigned number using +``GetValueAsSigned()``, ``GetValueAsUnsigned()``. It is also possible to +retrieve an SBData object by calling ``GetData()`` and then read the object's +contents out of the SBData. + +If you need to delve into several levels of hierarchy, as you can do with +summary strings, you can use the method ``GetValueForExpressionPath()``, +passing it an expression path just like those you could use for summary strings +(one of the differences is that dereferencing a pointer does not occur by +prefixing the path with a ``*```, but by calling the ``Dereference()`` method +on the returned SBValue). If you need to access array slices, you cannot do +that (yet) via this method call, and you must use ``GetChildAtIndex()`` +querying it for the array items one by one. Also, handling custom formats is +something you have to deal with on your own. + +Other than interactively typing a Python script there are two other ways for +you to input a Python script as a summary: + +- using the --python-script option to type summary add and typing the script + code as an option argument; as in: + +:: + + (lldb) type summary add --python-script "height = valobj.GetChildMemberWithName('height').GetValueAsUnsigned(0);width = valobj.GetChildMemberWithName('width').GetValueAsUnsigned(0); return 'Area: %d' % (height*width)" Rectangle + + +- using the --python-function (-F) option to type summary add and giving the + name of a Python function with the correct prototype. Most probably, you will + define (or have already defined) the function in the interactive interpreter, + or somehow loaded it from a file, using the command script import command. + LLDB will emit a warning if it is unable to find the function you passed, but + will still register the binding. + +Starting in SVN r222593, Python summary formatters can optionally define a +third argument: options + +This is an object of type ``lldb.SBTypeSummaryOptions`` that can be passed into +the formatter, allowing for a few customizations of the result. The decision to +adopt or not this third argument - and the meaning of options thereof - is +within the individual formatters' writer. + +Regular Expression Typenames +---------------------------- + +As you noticed, in order to associate the custom summary string to the array +types, one must give the array size as part of the typename. This can long +become tiresome when using arrays of different sizes, Simple [3], Simple [9], +Simple [12], ... + +If you use the -x option, type names are treated as regular expressions instead +of type names. This would let you rephrase the above example for arrays of type +Simple [3] as: + +:: + (lldb) type summary add --summary-string "${var[].x}" -x "Simple \[[0-9]+\]" + (lldb) frame variable + (Simple [3]) sarray = [1,4,7] + (Simple [2]) sother = [3,6] + +The above scenario works for Simple [3] as well as for any other array of +Simple objects. + +While this feature is mostly useful for arrays, you could also use regular +expressions to catch other type sets grouped by name. However, as regular +expression matching is slower than normal name matching, LLDB will first try to +match by name in any way it can, and only when this fails, will it resort to +regular expression matching. + +One of the ways LLDB uses this feature internally, is to match the names of STL +container classes, regardless of the template arguments provided. The details +for this are found at FormatManager.cpp + +The regular expression language used by LLDB is the POSIX extended language, as +defined by the Single UNIX Specification, of which Mac OS X is a compliant +implementation. + +Names Summaries +--------------- + +For a given type, there may be different meaningful summary representations. +However, currently, only one summary can be associated to a type at each +moment. If you need to temporarily override the association for a variable, +without changing the summary string for to its type, you can use named +summaries. + +Named summaries work by attaching a name to a summary when creating it. Then, +when there is a need to attach the summary to a variable, the frame variable +command, supports a --summary option that tells LLDB to use the named summary +given instead of the default one. + +:: + (lldb) type summary add --summary-string "x=${var.integer}" --name NamedSummary + (lldb) frame variable one + (i_am_cool) one = int = 3, float = 3.14159, char = 69 + (lldb) frame variable one --summary NamedSummary + (i_am_cool) one = x=3 + +When defining a named summary, binding it to one or more types becomes +optional. Even if you bind the named summary to a type, and later change the +summary string for that type, the named summary will not be changed by that. +You can delete named summaries by using the type summary delete command, as if +the summary name was the datatype that the summary is applied to + +A summary attached to a variable using the --summary option, has the same +semantics that a custom format attached using the -f option has: it stays +attached till you attach a new one, or till you let your program run again. + +Synthetic Children +------------------ + +Summaries work well when one is able to navigate through an expression path. In +order for LLDB to do so, appropriate debugging information must be available. + +Some types are opaque, i.e. no knowledge of their internals is provided. When +that's the case, expression paths do not work correctly. + +In other cases, the internals are available to use in expression paths, but +they do not provide a user-friendly representation of the object's value. + +For instance, consider an STL vector, as implemented by the GNU C++ Library: + +:: + + (lldb) frame variable numbers -T + (std::vector) numbers = { + (std::_Vector_base >) std::_Vector_base > = { + (std::_Vector_base >::_Vector_impl) _M_impl = { + (int *) _M_start = 0x00000001001008a0 + (int *) _M_finish = 0x00000001001008a8 + (int *) _M_end_of_storage = 0x00000001001008a8 + } + } + } + +Here, you can see how the type is implemented, and you can write a summary for +that implementation but that is not going to help you infer what items are +actually stored in the vector. + +What you would like to see is probably something like: + +:: + + (lldb) frame variable numbers -T + (std::vector) numbers = { + (int) [0] = 1 + (int) [1] = 12 + (int) [2] = 123 + (int) [3] = 1234 + } + +Synthetic children are a way to get that result. + +The feature is based upon the idea of providing a new set of children for a +variable that replaces the ones available by default through the debug +information. In the example, we can use synthetic children to provide the +vector items as children for the std::vector object. + +In order to create synthetic children, you need to provide a Python class that +adheres to a given interface (the word is italicized because Python has no +explicit notion of interface, by that word we mean a given set of methods must +be implemented by the Python class): + +:: + + class SyntheticChildrenProvider: + def __init__(self, valobj, internal_dict): + this call should initialize the Python object using valobj as the variable to provide synthetic children for + def num_children(self): + this call should return the number of children that you want your object to have + def get_child_index(self,name): + this call should return the index of the synthetic child whose name is given as argument + def get_child_at_index(self,index): + this call should return a new LLDB SBValue object representing the child at the index given as argument + def update(self): + this call should be used to update the internal state of this Python object whenever the state of the variables in LLDB changes.[1] + def has_children(self): + this call should return True if this object might have children, and False if this object can be guaranteed not to have children.[2] + def get_value(self): + this call can return an SBValue to be presented as the value of the synthetic value under consideration.[3] + +[1] This method is optional. Also, it may optionally choose to return a value +(starting with SVN rev153061/LLDB-134). If it returns a value, and that value +is True, LLDB will be allowed to cache the children and the children count it +previously obtained, and will not return to the provider class to ask. If +nothing, None, or anything other than True is returned, LLDB will discard the +cached information and ask. Regardless, whenever necessary LLDB will call +update. + +[2] This method is optional (starting with SVN rev166495/LLDB-175). While +implementing it in terms of num_children is acceptable, implementors are +encouraged to look for optimized coding alternatives whenever reasonable. + +[3] This method is optional (starting with SVN revision 219330). The SBValue +you return here will most likely be a numeric type (int, float, ...) as its +value bytes will be used as-if they were the value of the root SBValue proper. +As a shortcut for this, you can inherit from lldb.SBSyntheticValueProvider, and +just define get_value as other methods are defaulted in the superclass as +returning default no-children responses. + +If a synthetic child provider supplies a special child named $$dereference$$ +then it will be used when evaluating opertaor* and operator-> in the frame +variable command and related SB API functions. + +For examples of how synthetic children are created, you are encouraged to look +at examples/synthetic in the LLDB trunk. Please, be aware that the code in +those files (except bitfield/) is legacy code and is not maintained. You may +especially want to begin looking at this example to get a feel for this +feature, as it is a very easy and well commented example. + +The design pattern consistently used in synthetic providers shipping with LLDB +is to use the __init__ to store the SBValue instance as a part of self. The +update function is then used to perform the actual initialization. Once a +synthetic children provider is written, one must load it into LLDB before it +can be used. Currently, one can use the LLDB script command to type Python code +interactively, or use the command script import fileName command to load Python +code from a Python module (ordinary rules apply to importing modules this way). +A third option is to type the code for the provider class interactively while +adding it. + +For example, let's pretend we have a class Foo for which a synthetic children +provider class Foo_Provider is available, in a Python module contained in file +~/Foo_Tools.py. The following interaction sets Foo_Provider as a synthetic +children provider in LLDB: + +:: + + (lldb) command script import ~/Foo_Tools.py + (lldb) type synthetic add Foo --python-class Foo_Tools.Foo_Provider + (lldb) frame variable a_foo + (Foo) a_foo = { + x = 1 + y = "Hello world" + } + +LLDB has synthetic children providers for a core subset of STL classes, both in +the version provided by libstdcpp and by libcxx, as well as for several +Foundation classes. + +Synthetic children extend summary strings by enabling a new special variable: +``${svar``. + +This symbol tells LLDB to refer expression paths to the synthetic children +instead of the real ones. For instance, + +:: + + (lldb) type summary add --expand -x "std::vector<" --summary-string "${svar%#} items" + (lldb) frame variable numbers + (std::vector) numbers = 4 items { + (int) [0] = 1 + (int) [1] = 12 + (int) [2] = 123 + (int) [3] = 1234 + } + +In some cases, if LLDB is unable to use the real object to get a child +specified in an expression path, it will automatically refer to the synthetic +children. While in summaries it is best to always use ${svar to make your +intentions clearer, interactive debugging can benefit from this behavior, as +in: + +:: + + (lldb) frame variable numbers[0] numbers[1] + (int) numbers[0] = 1 + (int) numbers[1] = 12 + +Unlike many other visualization features, however, the access to synthetic +children only works when using frame variable, and is not supported in +expression: + +:: + + (lldb) expression numbers[0] + Error [IRForTarget]: Call to a function '_ZNSt33vector >ixEm' that is not present in the target + error: Couldn't convert the expression to DWARF + +The reason for this is that classes might have an overloaded operator [], or +other special provisions and the expression command chooses to ignore synthetic +children in the interest of equivalency with code you asked to have compiled +from source. + +Filters +------- + +Filters are a solution to the display of complex classes. At times, classes +have many member variables but not all of these are actually necessary for the +user to see. + +A filter will solve this issue by only letting the user see those member +variables he cares about. Of course, the equivalent of a filter can be +implemented easily using synthetic children, but a filter lets you get the job +done without having to write Python code. + +For instance, if your class Foobar has member variables named A thru Z, but you +only need to see the ones named B, H and Q, you can define a filter: + +:: + + (lldb) type filter add Foobar --child B --child H --child Q + (lldb) frame variable a_foobar + (Foobar) a_foobar = { + (int) B = 1 + (char) H = 'H' + (std::string) Q = "Hello world" + } + +Objective-C Dynamic Type Discovery +---------------------------------- + +When doing Objective-C development, you may notice that some of your variables +come out as of type id (for instance, items extracted from NSArray). By +default, LLDB will not show you the real type of the object. it can actually +dynamically discover the type of an Objective-C variable, much like the runtime +itself does when invoking a selector. In order to be shown the result of that +discovery that, however, a special option to frame variable or expression is +required: ``--dynamic-type``. + + +``--dynamic-type`` can have one of three values: + +- ``no-dynamic-values``: the default, prevents dynamic type discovery +- ``no-run-target``: enables dynamic type discovery as long as running code on + the target is not required +- ``run-target``: enables code execution on the target in order to perform + dynamic type discovery + +If you specify a value of either no-run-target or run-target, LLDB will detect +the dynamic type of your variables and show the appropriate formatters for +them. As an example: + +:: + + (lldb) expr @"Hello" + (NSString *) $0 = 0x00000001048000b0 @"Hello" + (lldb) expr -d no-run @"Hello" + (__NSCFString *) $1 = 0x00000001048000b0 @"Hello" + +Because LLDB uses a detection algorithm that does not need to invoke any +functions on the target process, no-run-target is enough for this to work. + +As a side note, the summary for NSString shown in the example is built right +into LLDB. It was initially implemented through Python (the code is still +available for reference at CFString.py). However, this is out of sync with the +current implementation of the NSString formatter (which is a C++ function +compiled into the LLDB core). + +Categories +---------- + +Categories are a way to group related formatters. For instance, LLDB itself +groups the formatters for the libstdc++ types in a category named +gnu-libstdc++. Basically, categories act like containers in which to store +formatters for a same library or OS release. + +By default, several categories are created in LLDB: + +- default: this is the category where every formatter ends up, unless another category is specified +- objc: formatters for basic and common Objective-C types that do not specifically depend on Mac OS X +- gnu-libstdc++: formatters for std::string, std::vector, std::list and std::map as implemented by libstdcpp +- libcxx: formatters for std::string, std::vector, std::list and std::map as implemented by libcxx +- system: truly basic types for which a formatter is required +- AppKit: Cocoa classes +- CoreFoundation: CF classes +- CoreGraphics: CG classes +- CoreServices: CS classes +- VectorTypes: compact display for several vector types + +If you want to use a custom category for your formatters, all the type ... add +provide a --category (-w) option, that names the category to add the formatter +to. To delete the formatter, you then have to specify the correct category. + +Categories can be in one of two states: enabled and disabled. A category is +initially disabled, and can be enabled using the type category enable command. +To disable an enabled category, the command to use is type category disable. + +The order in which categories are enabled or disabled is significant, in that +LLDB uses that order when looking for formatters. Therefore, when you enable a +category, it becomes the second one to be searched (after default, which always +stays on top of the list). The default categories are enabled in such a way +that the search order is: + +- default +- objc +- CoreFoundation +- AppKit +- CoreServices +- CoreGraphics +- gnu-libstdc++ +- libcxx +- VectorTypes +- system + +As said, gnu-libstdc++ and libcxx contain formatters for C++ STL data types. +system contains formatters for char* and char[], which reflect the behavior of +older versions of LLDB which had built-in formatters for these types. Because +now these are formatters, you can even replace them with your own if so you +wish. + +There is no special command to create a category. When you place a formatter in +a category, if that category does not exist, it is automatically created. For +instance, + +:: + + (lldb) type summary add Foobar --summary-string "a foobar" --category newcategory + +automatically creates a (disabled) category named newcategory. + +Another way to create a new (empty) category, is to enable it, as in: + +:: + + (lldb) type category enable newcategory + +However, in this case LLDB warns you that enabling an empty category has no +effect. If you add formatters to the category after enabling it, they will be +honored. But an empty category per se does not change the way any type is +displayed. The reason the debugger warns you is that enabling an empty category +might be a typo, and you effectively wanted to enable a similarly-named but +not-empty category. + +Finding Formatters 101 +---------------------- + +Searching for a formatter (including formats, starting in SVN rev r192217) +given a variable goes through a rather intricate set of rules. Namely, what +happens is that LLDB starts looking in each enabled category, according to the +order in which they were enabled (latest enabled first). In each category, LLDB +does the following: + +- If there is a formatter for the type of the variable, use it +- If this object is a pointer, and there is a formatter for the pointee type + that does not skip pointers, use it +- If this object is a reference, and there is a formatter for the referred type + that does not skip references, use it +- If this object is an Objective-C class and dynamic types are enabled, look + for a formatter for the dynamic type of the object. If dynamic types are + disabled, or the search failed, look for a formatter for the declared type of + the object +- If this object's type is a typedef, go through typedef hierarchy (LLDB might + not be able to do this if the compiler has not emitted enough information. If + the required information to traverse typedef hierarchies is missing, type + cascading will not work. The clang compiler, part of the LLVM project, emits + the correct debugging information for LLDB to cascade). If at any level of + the hierarchy there is a valid formatter that can cascade, use it. +- If everything has failed, repeat the above search, looking for regular + expressions instead of exact matches + +If any of those attempts returned a valid formatter to be used, that one is +used, and the search is terminated (without going to look in other categories). +If nothing was found in the current category, the next enabled category is +scanned according to the same algorithm. If there are no more enabled +categories, the search has failed. + +**Warning**: previous versions of LLDB defined cascading to mean not only going +through typedef chains, but also through inheritance chains. This feature has +been removed since it significantly degrades performance. You need to set up +your formatters for every type in inheritance chains to which you want the +formatter to apply. diff --git a/examples/darwin/heap_find/heap/heap_find.cpp b/examples/darwin/heap_find/heap/heap_find.cpp index b63d18b712bd..ce1bbee09cf7 100644 --- a/examples/darwin/heap_find/heap/heap_find.cpp +++ b/examples/darwin/heap_find/heap/heap_find.cpp @@ -1,9 +1,8 @@ //===-- heap_find.c ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/examples/functions/main.cpp b/examples/functions/main.cpp index bf02223340e8..cf33f37479e8 100644 --- a/examples/functions/main.cpp +++ b/examples/functions/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/examples/interposing/darwin/fd_interposing/FDInterposing.cpp b/examples/interposing/darwin/fd_interposing/FDInterposing.cpp index 105251c95748..0cc40909b500 100644 --- a/examples/interposing/darwin/fd_interposing/FDInterposing.cpp +++ b/examples/interposing/darwin/fd_interposing/FDInterposing.cpp @@ -1,9 +1,8 @@ //===-- FDInterposing.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -65,7 +64,7 @@ #include #include #include -#include // for std::tr1::shared_ptr +#include #include #include diff --git a/examples/lookup/main.cpp b/examples/lookup/main.cpp index f2a3386ac638..55d0647269f4 100644 --- a/examples/lookup/main.cpp +++ b/examples/lookup/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/examples/plugins/commands/fooplugin.cpp b/examples/plugins/commands/fooplugin.cpp index ae11cd75996c..e65fa164f048 100644 --- a/examples/plugins/commands/fooplugin.cpp +++ b/examples/plugins/commands/fooplugin.cpp @@ -1,9 +1,8 @@ //===-- fooplugin.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/examples/python/bsd.py b/examples/python/bsd.py index 8218f4ae6323..3e9528c65845 100755 --- a/examples/python/bsd.py +++ b/examples/python/bsd.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import cmd import optparse import os import shlex @@ -76,6 +77,22 @@ def get_bytes(self): self.file.seek(saved_pos, 0) return bytes + def save(self, path=None, overwrite=False): + ''' + Save the contents of the object to disk using 'path' argument as + the path, or save it to the current working directory using the + object name. + ''' + + if path is None: + path = self.name + if not overwrite and os.path.exists(path): + print('error: outfile "%s" already exists' % (path)) + return + print('Saving "%s" to "%s"...' % (self.name, path)) + with open(path, 'w') as f: + f.write(self.get_bytes()) + class StringTable(object): def __init__(self, bytes): @@ -186,6 +203,67 @@ def dump(self, f=sys.stdout, flat=True): for obj in self.objects: obj.dump(f=f, flat=flat) +class Interactive(cmd.Cmd): + '''Interactive prompt for exploring contents of BSD archive files, type + "help" to see a list of supported commands.''' + image_option_parser = None + + def __init__(self, archives): + cmd.Cmd.__init__(self) + self.use_rawinput = False + self.intro = ('Interactive BSD archive prompt, type "help" to see a ' + 'list of supported commands.') + self.archives = archives + self.prompt = '% ' + + def default(self, line): + '''Catch all for unknown command, which will exit the interpreter.''' + print("unknown command: %s" % line) + return True + + def do_q(self, line): + '''Quit command''' + return True + + def do_quit(self, line): + '''Quit command''' + return True + + def do_extract(self, line): + args = shlex.split(line) + if args: + extracted = False + for object_name in args: + for archive in self.archives: + matches = archive.find(object_name) + if matches: + for object in matches: + object.save(overwrite=False) + extracted = True + if not extracted: + print('error: no object matches "%s" in any archives' % ( + object_name)) + else: + print('error: must specify the name of an object to extract') + + def do_ls(self, line): + args = shlex.split(line) + if args: + for object_name in args: + for archive in self.archives: + matches = archive.find(object_name) + if matches: + for object in matches: + object.dump(flat=False) + else: + print('error: no object matches "%s" in "%s"' % ( + object_name, archive.path)) + else: + for archive in self.archives: + archive.dump(flat=True) + print('') + + def main(): parser = optparse.OptionParser( @@ -243,9 +321,24 @@ def main(): 'then the extracted object file will be extracted into the ' 'current working directory if a file doesn\'t already exist ' 'with that name.')) + parser.add_option( + '-i', '--interactive', + action='store_true', + dest='interactive', + default=False, + help=('Enter an interactive shell that allows users to interactively ' + 'explore contents of .a files.')) (options, args) = parser.parse_args(sys.argv[1:]) + if options.interactive: + archives = [] + for path in args: + archives.append(Archive(path)) + interpreter = Interactive(archives) + interpreter.cmdloop() + return + for path in args: archive = Archive(path) if options.object_name: @@ -256,17 +349,7 @@ def main(): if options.extract: if len(matches) == 1: dump_all = False - if options.outfile is None: - outfile_path = matches[0].name - else: - outfile_path = options.outfile - if os.path.exists(outfile_path): - print('error: outfile "%s" already exists' % ( - outfile_path)) - else: - print('Saving file to "%s"...' % (outfile_path)) - with open(outfile_path, 'w') as outfile: - outfile.write(matches[0].get_bytes()) + matches[0].save(path=options.outfile, overwrite=False) else: print('error: multiple objects match "%s". Specify ' 'the modification time using --mtime.' % ( diff --git a/examples/python/gdbremote.py b/examples/python/gdbremote.py index a6ff3f5978e4..4ca8a1b82e84 100755 --- a/examples/python/gdbremote.py +++ b/examples/python/gdbremote.py @@ -685,32 +685,33 @@ def rsp_qXfer(options, cmd, cmd_args, rsp): if extension == '.xml': response = Packet(rsp) xml_string = response.get_hex_ascii_str() - ch = xml_string[0] - if ch == 'l': - xml_string = xml_string[1:] - xml_root = ET.fromstring(xml_string) - for reg_element in xml_root.findall("./feature/reg"): - if not 'value_regnums' in reg_element.attrib: - reg_info = RegisterInfo([]) - if 'name' in reg_element.attrib: - reg_info.info[ - 'name'] = reg_element.attrib['name'] - else: - reg_info.info['name'] = 'unspecified' - if 'encoding' in reg_element.attrib: - reg_info.info['encoding'] = reg_element.attrib[ - 'encoding'] - else: - reg_info.info['encoding'] = 'uint' - if 'offset' in reg_element.attrib: - reg_info.info[ - 'offset'] = reg_element.attrib['offset'] - if 'bitsize' in reg_element.attrib: - reg_info.info[ - 'bitsize'] = reg_element.attrib['bitsize'] - g_register_infos.append(reg_info) - print 'XML for "%s":' % (data[2]) - ET.dump(xml_root) + if xml_string: + ch = xml_string[0] + if ch == 'l': + xml_string = xml_string[1:] + xml_root = ET.fromstring(xml_string) + for reg_element in xml_root.findall("./feature/reg"): + if not 'value_regnums' in reg_element.attrib: + reg_info = RegisterInfo([]) + if 'name' in reg_element.attrib: + reg_info.info[ + 'name'] = reg_element.attrib['name'] + else: + reg_info.info['name'] = 'unspecified' + if 'encoding' in reg_element.attrib: + reg_info.info['encoding'] = reg_element.attrib[ + 'encoding'] + else: + reg_info.info['encoding'] = 'uint' + if 'offset' in reg_element.attrib: + reg_info.info[ + 'offset'] = reg_element.attrib['offset'] + if 'bitsize' in reg_element.attrib: + reg_info.info[ + 'bitsize'] = reg_element.attrib['bitsize'] + g_register_infos.append(reg_info) + print 'XML for "%s":' % (data[2]) + ET.dump(xml_root) def cmd_A(options, cmd, args): @@ -810,6 +811,14 @@ def cmd_s(options, cmd, args): return False +def cmd_qSpeedTest(options, cmd, args): + print("qSpeedTest: cmd='%s', args='%s'" % (cmd, args)) + + +def rsp_qSpeedTest(options, cmd, cmd_args, rsp): + print("qSpeedTest: rsp='%s' cmd='%s', args='%s'" % (rsp, cmd, args)) + + def cmd_vCont(options, cmd, args): if args == '?': print "%s: get supported extended continue modes" % (cmd) @@ -861,8 +870,10 @@ def rsp_vCont(options, cmd, cmd_args, rsp): s += 'step' elif mode == 'S': s += 'step with signal' - else: - s += 'unrecognized vCont mode: ', mode + elif mode == 't': + s += 'stop' + # else: + # s += 'unrecognized vCont mode: ', str(mode) print s elif rsp: if rsp[0] == 'T' or rsp[0] == 'S' or rsp[0] == 'W' or rsp[0] == 'X': @@ -933,7 +944,7 @@ def rsp_qThreadInfo(options, cmd, cmd_args, rsp): def rsp_hex_big_endian(options, cmd, cmd_args, rsp): if rsp == '': print "%s%s is not supported" % (cmd, cmd_args) - else: + else: packet = Packet(rsp) uval = packet.get_hex_uint('big') print '%s: 0x%x' % (cmd, uval) @@ -1225,6 +1236,7 @@ def rsp_jGetLoadedDynamicLibrariesInfos(options, cmd, cmd_args, rsp): 'qHostInfo': {'cmd': cmd_query_packet, 'rsp': rsp_dump_key_value_pairs, 'name': "get host information"}, 'qC': {'cmd': cmd_qC, 'rsp': rsp_qC, 'name': "return the current thread ID"}, 'vCont': {'cmd': cmd_vCont, 'rsp': rsp_vCont, 'name': "extended continue command"}, + 'qSpeedTest': {'cmd':cmd_qSpeedTest, 'rsp': rsp_qSpeedTest, 'name': 'speed test packdet'}, 'vAttach': {'cmd': cmd_vAttach, 'rsp': rsp_stop_reply, 'name': "attach to process"}, 'c': {'cmd': cmd_c, 'rsp': rsp_stop_reply, 'name': "continue"}, 's': {'cmd': cmd_s, 'rsp': rsp_stop_reply, 'name': "step"}, @@ -1283,6 +1295,49 @@ def parse_gdb_log_file(path, options): f.close() +def round_up(n, incr): + return float(((int(n) + incr) / incr) * incr) + + +def plot_latencies(sec_times): + # import numpy as np + import matplotlib.pyplot as plt + + for (i, name) in enumerate(sec_times.keys()): + times = sec_times[name] + if len(times) <= 1: + continue + plt.subplot(2, 1, 1) + plt.title('Packet "%s" Times' % (name)) + plt.xlabel('Packet') + units = 'ms' + adj_times = [] + max_time = 0.0 + for time in times: + time = time * 1000.0 + adj_times.append(time) + if time > max_time: + max_time = time + if max_time < 1.0: + units = 'us' + max_time = 0.0 + for i in range(len(adj_times)): + adj_times[i] *= 1000.0 + if adj_times[i] > max_time: + max_time = adj_times[i] + plt.ylabel('Time (%s)' % (units)) + max_y = None + for i in [5.0, 10.0, 25.0, 50.0]: + if max_time < i: + max_y = round_up(max_time, i) + break + if max_y is None: + max_y = round_up(max_time, 100.0) + plt.ylim(0.0, max_y) + plt.plot(adj_times, 'o-') + plt.show() + + def parse_gdb_log(file, options): '''Parse a GDB log file that was generated by enabling logging with: (lldb) log enable --threadsafe --timestamp --file gdb-remote packets @@ -1306,10 +1361,11 @@ def parse_gdb_log(file, options): base_time = 0.0 last_time = 0.0 - packet_send_time = 0.0 + min_time = 100000000.0 packet_total_times = {} - packet_times = [] - packet_count = {} + all_packet_times = [] + packet_times = {} + packet_counts = {} lines = file.read().splitlines() last_command = None last_command_args = None @@ -1412,32 +1468,39 @@ def parse_gdb_log(file, options): curr_time = float(match.group(2)) if last_time and not is_command: delta = curr_time - last_time - packet_times.append(delta) + all_packet_times.append(delta) delta = 0.0 if base_time: delta = curr_time - last_time else: base_time = curr_time - if is_command: - packet_send_time = curr_time - elif line.find('read packet: $') >= 0 and packet_name: - if packet_name in packet_total_times: - packet_total_times[packet_name] += delta - packet_count[packet_name] += 1 - else: - packet_total_times[packet_name] = delta - packet_count[packet_name] = 1 - packet_name = None + if not is_command: + if line.find('read packet: $') >= 0 and packet_name: + if packet_name in packet_total_times: + packet_total_times[packet_name] += delta + packet_counts[packet_name] += 1 + else: + packet_total_times[packet_name] = delta + packet_counts[packet_name] = 1 + if packet_name not in packet_times: + packet_times[packet_name] = [] + packet_times[packet_name].append(delta) + packet_name = None + if min_time > delta: + min_time = delta if not options or not options.quiet: - print '%s%.6f %+.6f%s' % (match.group(1), curr_time - base_time, delta, match.group(3)) + print '%s%.6f %+.6f%s' % (match.group(1), + curr_time - base_time, + delta, + match.group(3)) last_time = curr_time # else: # print line - (average, std_dev) = calculate_mean_and_standard_deviation(packet_times) + (average, std_dev) = calculate_mean_and_standard_deviation(all_packet_times) if average and std_dev: - print '%u packets with average packet time of %f and standard deviation of %f' % (len(packet_times), average, std_dev) + print '%u packets with average packet time of %f and standard deviation of %f' % (len(all_packet_times), average, std_dev) if packet_total_times: total_packet_time = 0.0 total_packet_count = 0 @@ -1446,19 +1509,21 @@ def parse_gdb_log(file, options): # print 'value = (%s) %s' % (type(vvv), vvv) # if type(vvv) == 'float': total_packet_time += vvv - for key, vvv in packet_count.items(): + for key, vvv in packet_counts.items(): total_packet_count += vvv - print '#---------------------------------------------------' + print '#------------------------------------------------------------' print '# Packet timing summary:' - print '# Totals: time = %6f, count = %6d' % (total_packet_time, total_packet_count) - print '#---------------------------------------------------' - print '# Packet Time (sec) Percent Count ' - print '#------------------------- ---------- ------- ------' + print '# Totals: time = %6f, count = %6d' % (total_packet_time, + total_packet_count) + print '# Min packet time: time = %6f' % (min_time) + print '#------------------------------------------------------------' + print '# Packet Time (sec) Percent Count Latency' + print '#------------------------- ----------- ------- ------ -------' if options and options.sort_count: res = sorted( - packet_count, - key=packet_count.__getitem__, + packet_counts, + key=packet_counts.__getitem__, reverse=True) else: res = sorted( @@ -1471,11 +1536,12 @@ def parse_gdb_log(file, options): packet_total_time = packet_total_times[item] packet_percent = ( packet_total_time / total_packet_time) * 100.0 - if packet_percent >= 10.0: - print " %24s %.6f %.2f%% %6d" % (item, packet_total_time, packet_percent, packet_count[item]) - else: - print " %24s %.6f %.2f%% %6d" % (item, packet_total_time, packet_percent, packet_count[item]) - + packet_count = packet_counts[item] + print " %24s %11.6f %5.2f%% %6d %9.6f" % ( + item, packet_total_time, packet_percent, packet_count, + float(packet_total_time) / float(packet_count)) + if options.plot: + plot_latencies(packet_times) if __name__ == '__main__': usage = "usage: gdbremote [options]" @@ -1491,6 +1557,12 @@ def parse_gdb_log(file, options): dest='verbose', help='display verbose debug info', default=False) + parser.add_option( + '--plot', + action='store_true', + dest='plot', + help='plot packet latencies by packet type', + default=False) parser.add_option( '-q', '--quiet', diff --git a/examples/python/x86_64_linux_target_definition.py b/examples/python/x86_64_linux_target_definition.py index 9417b21abd66..7f03da264203 100644 --- a/examples/python/x86_64_linux_target_definition.py +++ b/examples/python/x86_64_linux_target_definition.py @@ -1,10 +1,9 @@ #!/usr/bin/python #===-- x86_64_linux_target_definition.py -----------------------------*- C++ -*-===// # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# 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 # #===----------------------------------------------------------------------===// diff --git a/examples/python/x86_64_qemu_target_definition.py b/examples/python/x86_64_qemu_target_definition.py index 5b4ea480ccf3..015340fa35f5 100644 --- a/examples/python/x86_64_qemu_target_definition.py +++ b/examples/python/x86_64_qemu_target_definition.py @@ -1,10 +1,9 @@ #!/usr/bin/python #===-- x86_64_qemu_target_definition.py -----------------------------*- C++ -*-===// # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# 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 # #===----------------------------------------------------------------------===// diff --git a/examples/python/x86_64_target_definition.py b/examples/python/x86_64_target_definition.py index 03411cf07c20..741e4ef7b9fd 100644 --- a/examples/python/x86_64_target_definition.py +++ b/examples/python/x86_64_target_definition.py @@ -1,10 +1,9 @@ #!/usr/bin/python #===-- x86_64_target_definition.py -----------------------------*- C++ -*-===// # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# 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 # #===----------------------------------------------------------------------===// diff --git a/examples/scripting/dictionary.c b/examples/scripting/dictionary.c index 260eab486e1b..5b865b97b1b2 100644 --- a/examples/scripting/dictionary.c +++ b/examples/scripting/dictionary.c @@ -1,9 +1,8 @@ //===-- dictionary.c ---------------------------------------------*- C -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// #include diff --git a/examples/scripting/tree_utils.py b/examples/scripting/tree_utils.py index a4d1645d7350..f5f251e05608 100755 --- a/examples/scripting/tree_utils.py +++ b/examples/scripting/tree_utils.py @@ -1,10 +1,9 @@ """ # ===-- tree_utils.py ---------------------------------------*- Python -*-===// # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# 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 # # ===---------------------------------------------------------------------===// diff --git a/examples/summaries/cocoa/CFArray.py b/examples/summaries/cocoa/CFArray.py index 6fc97081bad5..c1b96d8a492f 100644 --- a/examples/summaries/cocoa/CFArray.py +++ b/examples/summaries/cocoa/CFArray.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSArray # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/CFBag.py b/examples/summaries/cocoa/CFBag.py index d9a18996e78b..6bc13d5c465b 100644 --- a/examples/summaries/cocoa/CFBag.py +++ b/examples/summaries/cocoa/CFBag.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for CFBag # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/CFBinaryHeap.py b/examples/summaries/cocoa/CFBinaryHeap.py index b22f2c5d4f7c..e669b79ff1cf 100644 --- a/examples/summaries/cocoa/CFBinaryHeap.py +++ b/examples/summaries/cocoa/CFBinaryHeap.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for CFBinaryHeap # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/CFBitVector.py b/examples/summaries/cocoa/CFBitVector.py index e788e625b0d8..3f477e82a8ae 100644 --- a/examples/summaries/cocoa/CFBitVector.py +++ b/examples/summaries/cocoa/CFBitVector.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # summary provider for CF(Mutable)BitVector import lldb diff --git a/examples/summaries/cocoa/CFDictionary.py b/examples/summaries/cocoa/CFDictionary.py index 92d8048470c0..4a5d3943cc41 100644 --- a/examples/summaries/cocoa/CFDictionary.py +++ b/examples/summaries/cocoa/CFDictionary.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSDictionary # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/CFString.py b/examples/summaries/cocoa/CFString.py index 109d918a9de2..2743702271c7 100644 --- a/examples/summaries/cocoa/CFString.py +++ b/examples/summaries/cocoa/CFString.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example synthetic children and summary provider for CFString (and related NSString class) # the real code is part of the LLDB core diff --git a/examples/summaries/cocoa/Class.py b/examples/summaries/cocoa/Class.py index 1c97ed8965f5..4021f9369602 100644 --- a/examples/summaries/cocoa/Class.py +++ b/examples/summaries/cocoa/Class.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ import lldb import lldb.runtime.objc.objc_runtime diff --git a/examples/summaries/cocoa/NSBundle.py b/examples/summaries/cocoa/NSBundle.py index 298150e6cc0a..3545d3d9c963 100644 --- a/examples/summaries/cocoa/NSBundle.py +++ b/examples/summaries/cocoa/NSBundle.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSBundle # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSData.py b/examples/summaries/cocoa/NSData.py index bf4f2c6bbb7c..c8e404358607 100644 --- a/examples/summaries/cocoa/NSData.py +++ b/examples/summaries/cocoa/NSData.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSData # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSDate.py b/examples/summaries/cocoa/NSDate.py index 4efe76eca598..d12f835cc9ae 100644 --- a/examples/summaries/cocoa/NSDate.py +++ b/examples/summaries/cocoa/NSDate.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSDate # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSException.py b/examples/summaries/cocoa/NSException.py index 826871d70c21..8d5cd02bb272 100644 --- a/examples/summaries/cocoa/NSException.py +++ b/examples/summaries/cocoa/NSException.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # summary provider for class NSException import lldb.runtime.objc.objc_runtime diff --git a/examples/summaries/cocoa/NSIndexSet.py b/examples/summaries/cocoa/NSIndexSet.py index ca9906158a90..3774a3904663 100644 --- a/examples/summaries/cocoa/NSIndexSet.py +++ b/examples/summaries/cocoa/NSIndexSet.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NS(Mutable)IndexSet # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSMachPort.py b/examples/summaries/cocoa/NSMachPort.py index 6eea6ca66816..0425f853a98e 100644 --- a/examples/summaries/cocoa/NSMachPort.py +++ b/examples/summaries/cocoa/NSMachPort.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSMachPort # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSNotification.py b/examples/summaries/cocoa/NSNotification.py index 319d7561e552..160d85d945d0 100644 --- a/examples/summaries/cocoa/NSNotification.py +++ b/examples/summaries/cocoa/NSNotification.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSNotification # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSNumber.py b/examples/summaries/cocoa/NSNumber.py index 3225ea95ded6..fb2816d84a92 100644 --- a/examples/summaries/cocoa/NSNumber.py +++ b/examples/summaries/cocoa/NSNumber.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # example summary provider for NSNumber # the real summary is now C++ code built into LLDB diff --git a/examples/summaries/cocoa/NSSet.py b/examples/summaries/cocoa/NSSet.py index a6c7768671aa..4e3e77f93db7 100644 --- a/examples/summaries/cocoa/NSSet.py +++ b/examples/summaries/cocoa/NSSet.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # summary provider for NSSet import lldb diff --git a/examples/summaries/cocoa/NSURL.py b/examples/summaries/cocoa/NSURL.py index ad28849a44d6..c1c533ddf182 100644 --- a/examples/summaries/cocoa/NSURL.py +++ b/examples/summaries/cocoa/NSURL.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ # summary provider for NSURL import lldb diff --git a/examples/summaries/cocoa/Selector.py b/examples/summaries/cocoa/Selector.py index 05a19606505e..06c79f7f1e8e 100644 --- a/examples/summaries/cocoa/Selector.py +++ b/examples/summaries/cocoa/Selector.py @@ -1,9 +1,9 @@ """ LLDB AppKit formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ import lldb diff --git a/examples/summaries/cocoa/attrib_fromdict.py b/examples/summaries/cocoa/attrib_fromdict.py index 39abe6bda478..3b4597398f97 100644 --- a/examples/summaries/cocoa/attrib_fromdict.py +++ b/examples/summaries/cocoa/attrib_fromdict.py @@ -1,9 +1,9 @@ """ Objective-C runtime wrapper for use by LLDB Python formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ diff --git a/examples/summaries/cocoa/cache.py b/examples/summaries/cocoa/cache.py index 63915cc66338..13db3ad502ea 100644 --- a/examples/summaries/cocoa/cache.py +++ b/examples/summaries/cocoa/cache.py @@ -1,9 +1,9 @@ """ Objective-C runtime wrapper for use by LLDB Python formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ import lldb.formatters.metrics diff --git a/examples/summaries/cocoa/metrics.py b/examples/summaries/cocoa/metrics.py index 6a73a7344b95..e7fe88e69032 100644 --- a/examples/summaries/cocoa/metrics.py +++ b/examples/summaries/cocoa/metrics.py @@ -1,9 +1,9 @@ """ Objective-C runtime wrapper for use by LLDB Python formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ import lldb import time diff --git a/examples/summaries/cocoa/objc_runtime.py b/examples/summaries/cocoa/objc_runtime.py index 14ef1b42bf13..fe94b261e9de 100644 --- a/examples/summaries/cocoa/objc_runtime.py +++ b/examples/summaries/cocoa/objc_runtime.py @@ -1,9 +1,9 @@ """ Objective-C runtime wrapper for use by LLDB Python formatters -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ import lldb import lldb.formatters.cache diff --git a/examples/summaries/lldb b/examples/summaries/lldb index b6b2bf3d41c5..10eaaf0db7e0 100644 --- a/examples/summaries/lldb +++ b/examples/summaries/lldb @@ -11,7 +11,7 @@ type summary add -w lldb lldb_private::CommandObject - type summary add -w lldb lldb_private::Variable -s "${var.m_type.m_name} ${var.m_name}" type summary add -w lldb lldb_private::StopInfo -s "ID: ${var.m_stop_id}, ${var.m_description}" type summary add -w lldb lldb_private::FileSpec -s "file: ${var.m_filename%S} dir: ${var.m_directory%S}" -type summary add -w -v lldb lldb::ConnectionStatus -s "[enum=${var%E} val=${var%i}]" +type summary add -v -w lldb lldb::ConnectionStatus -s "[enum=${var%E} val=${var%i}]" # Where '-v' tells type summary not to show the value itself, but just use the summary format. type summary add -w lldb "lldb_private::ThreadSafeValue" -s "${var.m_value}" diff --git a/examples/summaries/sp_cp.py b/examples/summaries/sp_cp.py index e2ef18bfea44..a43ac5545ffc 100644 --- a/examples/summaries/sp_cp.py +++ b/examples/summaries/sp_cp.py @@ -1,9 +1,9 @@ """ Summary and synthetic providers for LLDB-specific shared pointers -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ diff --git a/examples/summaries/unicode_strings.py b/examples/summaries/unicode_strings.py index a9ba15a10256..8c382df5abf3 100644 --- a/examples/summaries/unicode_strings.py +++ b/examples/summaries/unicode_strings.py @@ -5,9 +5,9 @@ To use in your projects, tweak the children names as appropriate for your data structures and use as summaries for your data types -part of The LLVM Compiler Infrastructure -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ import lldb diff --git a/examples/synthetic/bitfield/program.cpp b/examples/synthetic/bitfield/program.cpp index 1db4aa4e719e..d14edda30515 100644 --- a/examples/synthetic/bitfield/program.cpp +++ b/examples/synthetic/bitfield/program.cpp @@ -53,4 +53,4 @@ int main() { MaskedData data_5(data_4.apply(), 0xFFAC, eMaskingOperatorNor); MaskedData data_6(data_5.apply(), 0x0000BEEF, eMaskingOperatorAnd); return data_6.apply(); // <-- what comes out of here? -} \ No newline at end of file +} diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h index c51ced893d7a..5f722c9e7017 100644 --- a/include/lldb/API/LLDB.h +++ b/include/lldb/API/LLDB.h @@ -1,19 +1,14 @@ //===-- LLDB.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_LLDB_h_ #define LLDB_LLDB_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h index 891324254cd6..e5db9d5e1c04 100644 --- a/include/lldb/API/SBAddress.h +++ b/include/lldb/API/SBAddress.h @@ -1,9 +1,8 @@ //===-- SBAddress.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h index 7ae006908ccc..a89d6cba92bf 100644 --- a/include/lldb/API/SBAttachInfo.h +++ b/include/lldb/API/SBAttachInfo.h @@ -1,9 +1,8 @@ //===-- SBAttachInfo.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBBlock.h b/include/lldb/API/SBBlock.h index 112de9673423..0acd8156af35 100644 --- a/include/lldb/API/SBBlock.h +++ b/include/lldb/API/SBBlock.h @@ -1,9 +1,8 @@ //===-- SBBlock.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h index 2c93bf103e3e..6acfe5aa1ecd 100644 --- a/include/lldb/API/SBBreakpoint.h +++ b/include/lldb/API/SBBreakpoint.h @@ -1,9 +1,8 @@ //===-- SBBreakpoint.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h index 4b34bcbf1f28..8552e4d4dad7 100644 --- a/include/lldb/API/SBBreakpointLocation.h +++ b/include/lldb/API/SBBreakpointLocation.h @@ -1,9 +1,8 @@ //===-- SBBreakpointLocation.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBBreakpointName.h b/include/lldb/API/SBBreakpointName.h index 321f0d784d6f..19e1608adc8c 100644 --- a/include/lldb/API/SBBreakpointName.h +++ b/include/lldb/API/SBBreakpointName.h @@ -1,9 +1,8 @@ //===-- SBBreakpointName.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBBroadcaster.h b/include/lldb/API/SBBroadcaster.h index dc6c50ec0a8a..4a5d972003ab 100644 --- a/include/lldb/API/SBBroadcaster.h +++ b/include/lldb/API/SBBroadcaster.h @@ -1,9 +1,8 @@ //===-- SBBroadcaster.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h index c7aecfd1f2f0..eb0bb78a0859 100644 --- a/include/lldb/API/SBCommandInterpreter.h +++ b/include/lldb/API/SBCommandInterpreter.h @@ -1,21 +1,16 @@ //===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_SBCommandInterpreter_h_ #define LLDB_SBCommandInterpreter_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" @@ -166,6 +161,20 @@ class SBCommandInterpreter { int match_start_point, int max_return_elements, lldb::SBStringList &matches); + // Same as HandleCompletion, but also fills out `descriptions` with + // descriptions for each match. + int HandleCompletionWithDescriptions( + const char *current_line, const char *cursor, const char *last_char, + int match_start_point, int max_return_elements, + lldb::SBStringList &matches, lldb::SBStringList &descriptions); + + int HandleCompletionWithDescriptions(const char *current_line, + uint32_t cursor_pos, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches, + lldb::SBStringList &descriptions); + bool WasInterrupted() const; // Catch commands before they execute by registering a callback that will get diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h index a372ea2ad9ee..f361ec51e8c6 100644 --- a/include/lldb/API/SBCommandReturnObject.h +++ b/include/lldb/API/SBCommandReturnObject.h @@ -1,23 +1,18 @@ //===-- SBCommandReturnObject.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_SBCommandReturnObject_h_ #define LLDB_SBCommandReturnObject_h_ -// C Includes #include -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/API/SBDefines.h" namespace lldb { diff --git a/include/lldb/API/SBCommunication.h b/include/lldb/API/SBCommunication.h index f0016275b634..53323f314489 100644 --- a/include/lldb/API/SBCommunication.h +++ b/include/lldb/API/SBCommunication.h @@ -1,9 +1,8 @@ //===-- SBCommunication.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBCompileUnit.h b/include/lldb/API/SBCompileUnit.h index 4d5f9f36f246..5ebea9488599 100644 --- a/include/lldb/API/SBCompileUnit.h +++ b/include/lldb/API/SBCompileUnit.h @@ -1,9 +1,8 @@ //===-- SBCompileUnit.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBData.h b/include/lldb/API/SBData.h index 7ff619e68667..f07912d1a668 100644 --- a/include/lldb/API/SBData.h +++ b/include/lldb/API/SBData.h @@ -1,9 +1,8 @@ //===-- SBData.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h index a416b460f318..6bb3632a454f 100644 --- a/include/lldb/API/SBDebugger.h +++ b/include/lldb/API/SBDebugger.h @@ -1,9 +1,8 @@ //===-- SBDebugger.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,6 +12,7 @@ #include #include "lldb/API/SBDefines.h" +#include "lldb/API/SBInitializerOptions.h" #include "lldb/API/SBPlatform.h" namespace lldb { @@ -45,6 +45,7 @@ class LLDB_API SBDebugger { lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs); static void Initialize(); + static lldb::SBError Initialize(SBInitializerOptions &options); static void Terminate(); @@ -109,7 +110,7 @@ class LLDB_API SBDebugger { const char *archname); lldb::SBTarget CreateTarget(const char *filename); - + lldb::SBTarget GetDummyTarget(); // Return true if target is deleted from the target list of the debugger. @@ -226,6 +227,8 @@ class LLDB_API SBDebugger { void SetPrompt(const char *prompt); + const char *GetReproducerPath() const; + lldb::ScriptLanguage GetScriptLanguage() const; void SetScriptLanguage(lldb::ScriptLanguage script_lang); diff --git a/include/lldb/API/SBDeclaration.h b/include/lldb/API/SBDeclaration.h index 42cf76963847..09988df954ce 100644 --- a/include/lldb/API/SBDeclaration.h +++ b/include/lldb/API/SBDeclaration.h @@ -1,10 +1,9 @@ //===-- SBDeclaration.h -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h index ec92c9196737..b45ae08107a6 100644 --- a/include/lldb/API/SBDefines.h +++ b/include/lldb/API/SBDefines.h @@ -1,19 +1,14 @@ //===-- SBDefines.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_SBDefines_h_ #define LLDB_SBDefines_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -55,6 +50,7 @@ class LLDB_API SBFileSpecList; class LLDB_API SBFrame; class LLDB_API SBFunction; class LLDB_API SBHostOS; +class LLDB_API SBInitializerOptions; class LLDB_API SBInstruction; class LLDB_API SBInstructionList; class LLDB_API SBLanguageRuntime; diff --git a/include/lldb/API/SBError.h b/include/lldb/API/SBError.h index c967bf891134..8a917757379a 100644 --- a/include/lldb/API/SBError.h +++ b/include/lldb/API/SBError.h @@ -1,9 +1,8 @@ //===-- SBError.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBEvent.h b/include/lldb/API/SBEvent.h index ff15716d853e..d8a347bd7e8d 100644 --- a/include/lldb/API/SBEvent.h +++ b/include/lldb/API/SBEvent.h @@ -1,9 +1,8 @@ //===-- SBEvent.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBExecutionContext.h b/include/lldb/API/SBExecutionContext.h index c19d539bc80a..c9066cf79447 100644 --- a/include/lldb/API/SBExecutionContext.h +++ b/include/lldb/API/SBExecutionContext.h @@ -1,10 +1,9 @@ //===-- SBExecutionContext.h -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h index 2475d6f2c017..421578470689 100644 --- a/include/lldb/API/SBExpressionOptions.h +++ b/include/lldb/API/SBExpressionOptions.h @@ -1,9 +1,8 @@ //===-- SBEvent.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h index 33e48f5c7c41..c3e7d91441de 100644 --- a/include/lldb/API/SBFileSpec.h +++ b/include/lldb/API/SBFileSpec.h @@ -1,9 +1,8 @@ //===-- SBFileSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -59,6 +58,7 @@ class LLDB_API SBFileSpec { friend class SBDeclaration; friend class SBFileSpecList; friend class SBHostOS; + friend class SBInitializerOptions; friend class SBLaunchInfo; friend class SBLineEntry; friend class SBModule; @@ -67,8 +67,8 @@ class LLDB_API SBFileSpec { friend class SBProcess; friend class SBProcessInfo; friend class SBSourceManager; - friend class SBThread; friend class SBTarget; + friend class SBThread; SBFileSpec(const lldb_private::FileSpec &fspec); diff --git a/include/lldb/API/SBFileSpecList.h b/include/lldb/API/SBFileSpecList.h index 97f843adbb5f..a0e3f2588e2d 100644 --- a/include/lldb/API/SBFileSpecList.h +++ b/include/lldb/API/SBFileSpecList.h @@ -1,10 +1,9 @@ //===-- SBFileSpecList.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h index 44b551764555..1e57575be6df 100644 --- a/include/lldb/API/SBFrame.h +++ b/include/lldb/API/SBFrame.h @@ -1,9 +1,8 @@ //===-- SBFrame.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h index 936fcaaac2cd..2541398cfffe 100644 --- a/include/lldb/API/SBFunction.h +++ b/include/lldb/API/SBFunction.h @@ -1,9 +1,8 @@ //===-- SBFunction.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h index 1671917f865c..ecd7920f2c14 100644 --- a/include/lldb/API/SBHostOS.h +++ b/include/lldb/API/SBHostOS.h @@ -1,9 +1,8 @@ //===-- SBHostOS.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBInitializerOptions.h b/include/lldb/API/SBInitializerOptions.h new file mode 100644 index 000000000000..612856897036 --- /dev/null +++ b/include/lldb/API/SBInitializerOptions.h @@ -0,0 +1,42 @@ +//===-- SBInitializerOptions.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 LLDB_SBInitializerOptuions_h_ +#define LLDB_SBInitializerOptuions_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb_private { +struct InitializerOptions; +} + +namespace lldb { + +class LLDB_API SBInitializerOptions { +public: + SBInitializerOptions(); + SBInitializerOptions(const lldb::SBInitializerOptions &rhs); + ~SBInitializerOptions(); + const SBInitializerOptions &operator=(const lldb::SBInitializerOptions &rhs); + + void SetCaptureReproducer(bool b); + void SetReplayReproducer(bool b); + void SetReproducerPath(const char *path); + + lldb_private::InitializerOptions &ref() const; + +private: + friend class SBDebugger; + + std::unique_ptr m_opaque_up; +}; + +} // namespace lldb + +#endif // LLDB_SBInitializerOptuions_h_ diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h index 5ef02b8f696a..ca40cf493ea3 100644 --- a/include/lldb/API/SBInstruction.h +++ b/include/lldb/API/SBInstruction.h @@ -1,9 +1,8 @@ //===-- SBInstruction.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h index c8fed5c83192..e47bd923b6cb 100644 --- a/include/lldb/API/SBInstructionList.h +++ b/include/lldb/API/SBInstructionList.h @@ -1,9 +1,8 @@ //===-- SBInstructionList.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBLanguageRuntime.h b/include/lldb/API/SBLanguageRuntime.h index 3912f352491b..d28c441593ea 100644 --- a/include/lldb/API/SBLanguageRuntime.h +++ b/include/lldb/API/SBLanguageRuntime.h @@ -1,9 +1,8 @@ //===-- SBLanguageRuntime.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBLaunchInfo.h b/include/lldb/API/SBLaunchInfo.h index 80eea7e42921..5d6c1d11b0ae 100644 --- a/include/lldb/API/SBLaunchInfo.h +++ b/include/lldb/API/SBLaunchInfo.h @@ -1,9 +1,8 @@ //===-- SBLaunchInfo.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBLineEntry.h b/include/lldb/API/SBLineEntry.h index 3d58ea8278ea..e4986c1693c2 100644 --- a/include/lldb/API/SBLineEntry.h +++ b/include/lldb/API/SBLineEntry.h @@ -1,9 +1,8 @@ //===-- SBLineEntry.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBListener.h b/include/lldb/API/SBListener.h index a2f82a83c3ed..9aaca8f0541a 100644 --- a/include/lldb/API/SBListener.h +++ b/include/lldb/API/SBListener.h @@ -1,9 +1,8 @@ //===-- SBListener.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBMemoryRegionInfo.h b/include/lldb/API/SBMemoryRegionInfo.h index 297f877a6341..5518e76bc334 100644 --- a/include/lldb/API/SBMemoryRegionInfo.h +++ b/include/lldb/API/SBMemoryRegionInfo.h @@ -1,9 +1,8 @@ //===-- SBMemoryRegionInfo.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -102,6 +101,7 @@ class LLDB_API SBMemoryRegionInfo { const lldb_private::MemoryRegionInfo &ref() const; + // Unused. SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr); lldb::MemoryRegionInfoUP m_opaque_ap; diff --git a/include/lldb/API/SBMemoryRegionInfoList.h b/include/lldb/API/SBMemoryRegionInfoList.h index 883a2224c92d..c0fa47fc31e4 100644 --- a/include/lldb/API/SBMemoryRegionInfoList.h +++ b/include/lldb/API/SBMemoryRegionInfoList.h @@ -1,9 +1,8 @@ //===-- SBMemoryRegionInfoList.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -42,6 +41,12 @@ class LLDB_API SBMemoryRegionInfoList { const MemoryRegionInfoListImpl &operator*() const; private: + friend class SBProcess; + + lldb_private::MemoryRegionInfos &ref(); + + const lldb_private::MemoryRegionInfos &ref() const; + std::unique_ptr m_opaque_ap; }; diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h index 435f6f0c847b..e89b7a357950 100644 --- a/include/lldb/API/SBModule.h +++ b/include/lldb/API/SBModule.h @@ -1,9 +1,8 @@ //===-- SBModule.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -309,6 +308,7 @@ class LLDB_API SBModule { lldb::SBFileSpec GetSymbolFileSpec() const; lldb::SBAddress GetObjectFileHeaderAddress() const; + lldb::SBAddress GetObjectFileEntryPointAddress() const; lldb::SBError IsTypeSystemCompatible(lldb::LanguageType language); diff --git a/include/lldb/API/SBModuleSpec.h b/include/lldb/API/SBModuleSpec.h index 1a862703a702..48d2e0871a4e 100644 --- a/include/lldb/API/SBModuleSpec.h +++ b/include/lldb/API/SBModuleSpec.h @@ -1,9 +1,8 @@ //===-- SBModuleSpec.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBPlatform.h b/include/lldb/API/SBPlatform.h index 952e31066319..d0dc457d6da1 100644 --- a/include/lldb/API/SBPlatform.h +++ b/include/lldb/API/SBPlatform.h @@ -1,9 +1,8 @@ //===-- SBPlatform.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 69cf8b4ce854..81897d57aa34 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -1,9 +1,8 @@ //===-- SBProcess.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBProcessInfo.h b/include/lldb/API/SBProcessInfo.h index 421227f82c2d..97e1cef6dabb 100644 --- a/include/lldb/API/SBProcessInfo.h +++ b/include/lldb/API/SBProcessInfo.h @@ -1,9 +1,8 @@ //===-- SBProcessInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBQueue.h b/include/lldb/API/SBQueue.h index 53612c0a125f..ffa760ee0345 100644 --- a/include/lldb/API/SBQueue.h +++ b/include/lldb/API/SBQueue.h @@ -1,9 +1,8 @@ //===-- SBQueue.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBQueueItem.h b/include/lldb/API/SBQueueItem.h index 78ca3ba02db1..4f1dd6af7f29 100644 --- a/include/lldb/API/SBQueueItem.h +++ b/include/lldb/API/SBQueueItem.h @@ -1,9 +1,8 @@ //===-- SBQueueItem.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBSection.h b/include/lldb/API/SBSection.h index ffd8bf7c979b..647b1afa06f4 100644 --- a/include/lldb/API/SBSection.h +++ b/include/lldb/API/SBSection.h @@ -1,9 +1,8 @@ //===-- SBSection.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBSourceManager.h b/include/lldb/API/SBSourceManager.h index 6f1c49504d52..df4ca7708797 100644 --- a/include/lldb/API/SBSourceManager.h +++ b/include/lldb/API/SBSourceManager.h @@ -1,9 +1,8 @@ //===-- SBSourceManager.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h index 7364ca7797f8..240e8f91648f 100644 --- a/include/lldb/API/SBStream.h +++ b/include/lldb/API/SBStream.h @@ -1,9 +1,8 @@ //===-- SBStream.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBStringList.h b/include/lldb/API/SBStringList.h index 943384e544cd..921710b8f557 100644 --- a/include/lldb/API/SBStringList.h +++ b/include/lldb/API/SBStringList.h @@ -1,9 +1,8 @@ //===-- SBStringList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBStructuredData.h b/include/lldb/API/SBStructuredData.h index 629d4f3e35ee..ee991bc7529e 100644 --- a/include/lldb/API/SBStructuredData.h +++ b/include/lldb/API/SBStructuredData.h @@ -1,9 +1,8 @@ //===-- SBStructuredData.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h index a29ac61d2912..7086cd067023 100644 --- a/include/lldb/API/SBSymbol.h +++ b/include/lldb/API/SBSymbol.h @@ -1,9 +1,8 @@ //===-- SBSymbol.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h index 9078b5b789e0..e05a61194670 100644 --- a/include/lldb/API/SBSymbolContext.h +++ b/include/lldb/API/SBSymbolContext.h @@ -1,9 +1,8 @@ //===-- SBSymbolContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBSymbolContextList.h b/include/lldb/API/SBSymbolContextList.h index e7299dd5330c..1200bd234846 100644 --- a/include/lldb/API/SBSymbolContextList.h +++ b/include/lldb/API/SBSymbolContextList.h @@ -1,9 +1,8 @@ //===-- SBSymbolContextList.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 9c5cfa52d4e5..818b0c3aa134 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -1,19 +1,14 @@ //===-- SBTarget.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_SBTarget_h_ #define LLDB_SBTarget_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBreakpoint.h" @@ -297,6 +292,10 @@ class LLDB_API SBTarget { lldb::SBFileSpec GetExecutable(); + // Append the path mapping (from -> to) to the target's paths mapping list. + void AppendImageSearchPath(const char *from, const char *to, + lldb::SBError &error); + bool AddModule(lldb::SBModule &module); lldb::SBModule AddModule(const char *path, const char *triple, @@ -914,6 +913,7 @@ class LLDB_API SBTarget { friend class SBSourceManager; friend class SBSymbol; friend class SBValue; + friend class SBVariablesOptions; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to create an diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h index a0392f0f0ed4..e73e1d888b14 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -1,9 +1,8 @@ //===-- SBThread.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -202,6 +201,10 @@ class LLDB_API SBThread { uint32_t GetExtendedBacktraceOriginatingIndexID(); + SBValue GetCurrentException(); + + SBThread GetCurrentExceptionBacktrace(); + bool SafeToCallFunctions(); #ifndef SWIG diff --git a/include/lldb/API/SBThreadCollection.h b/include/lldb/API/SBThreadCollection.h index 715b0826b962..e243635910de 100644 --- a/include/lldb/API/SBThreadCollection.h +++ b/include/lldb/API/SBThreadCollection.h @@ -1,9 +1,8 @@ //===-- SBThreadCollection.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBThreadPlan.h b/include/lldb/API/SBThreadPlan.h index 35150e1b907d..8e777bf5c0b7 100644 --- a/include/lldb/API/SBThreadPlan.h +++ b/include/lldb/API/SBThreadPlan.h @@ -1,9 +1,8 @@ //===-- SBThread.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -98,6 +97,10 @@ class LLDB_API SBThreadPlan { SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address, SBError &error); + SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name); + SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name, + SBError &error); + #ifndef SWIG lldb_private::ThreadPlan *get(); #endif diff --git a/include/lldb/API/SBTrace.h b/include/lldb/API/SBTrace.h index 244a01e5ce11..e4928f0239d4 100644 --- a/include/lldb/API/SBTrace.h +++ b/include/lldb/API/SBTrace.h @@ -1,9 +1,8 @@ //===-- SBTrace.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTraceOptions.h b/include/lldb/API/SBTraceOptions.h index c9735e1ca246..2d1653a70745 100644 --- a/include/lldb/API/SBTraceOptions.h +++ b/include/lldb/API/SBTraceOptions.h @@ -1,9 +1,8 @@ //===-- SBTraceOptions ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h index 0dde0257909f..89f72fd72b28 100644 --- a/include/lldb/API/SBType.h +++ b/include/lldb/API/SBType.h @@ -1,9 +1,8 @@ //===-- SBType.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h index f44dfc451e44..1d202fb44626 100644 --- a/include/lldb/API/SBTypeCategory.h +++ b/include/lldb/API/SBTypeCategory.h @@ -1,10 +1,9 @@ //===-- SBTypeCategory.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeEnumMember.h b/include/lldb/API/SBTypeEnumMember.h index f45c234d2c77..99b12523fb33 100644 --- a/include/lldb/API/SBTypeEnumMember.h +++ b/include/lldb/API/SBTypeEnumMember.h @@ -1,10 +1,9 @@ //===-- SBTypeEnumMember.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeFilter.h b/include/lldb/API/SBTypeFilter.h index 19888ba7cfb6..7108702a87f5 100644 --- a/include/lldb/API/SBTypeFilter.h +++ b/include/lldb/API/SBTypeFilter.h @@ -1,10 +1,9 @@ //===-- SBTypeFilter.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeFormat.h b/include/lldb/API/SBTypeFormat.h index d0429e97ff9c..4575d2d2279f 100644 --- a/include/lldb/API/SBTypeFormat.h +++ b/include/lldb/API/SBTypeFormat.h @@ -1,10 +1,9 @@ //===-- SBTypeFormat.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeNameSpecifier.h b/include/lldb/API/SBTypeNameSpecifier.h index 2a4f09c2068b..c78ae94435ce 100644 --- a/include/lldb/API/SBTypeNameSpecifier.h +++ b/include/lldb/API/SBTypeNameSpecifier.h @@ -1,10 +1,9 @@ //===-- SBTypeNameSpecifier.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h index c9ccdff834ce..e02720c7c727 100644 --- a/include/lldb/API/SBTypeSummary.h +++ b/include/lldb/API/SBTypeSummary.h @@ -1,10 +1,9 @@ //===-- SBTypeSummary.h -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBTypeSynthetic.h b/include/lldb/API/SBTypeSynthetic.h index 2099df316194..d11fe9c0ef73 100644 --- a/include/lldb/API/SBTypeSynthetic.h +++ b/include/lldb/API/SBTypeSynthetic.h @@ -1,10 +1,9 @@ //===-- SBTypeSynthetic.h -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBUnixSignals.h b/include/lldb/API/SBUnixSignals.h index d44a508fbb42..3883c621c788 100644 --- a/include/lldb/API/SBUnixSignals.h +++ b/include/lldb/API/SBUnixSignals.h @@ -1,10 +1,9 @@ //===-- SBUnixSignals.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h index ab5bdfea993d..444557a8c6c0 100644 --- a/include/lldb/API/SBValue.h +++ b/include/lldb/API/SBValue.h @@ -1,9 +1,8 @@ //===-- SBValue.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBValueList.h b/include/lldb/API/SBValueList.h index 0242dd7f71a2..0af0870f1084 100644 --- a/include/lldb/API/SBValueList.h +++ b/include/lldb/API/SBValueList.h @@ -1,9 +1,8 @@ //===-- SBValueList.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/API/SBVariablesOptions.h b/include/lldb/API/SBVariablesOptions.h index 23ff4265be53..ccc77c569a49 100644 --- a/include/lldb/API/SBVariablesOptions.h +++ b/include/lldb/API/SBVariablesOptions.h @@ -1,10 +1,9 @@ //===-- SBVariablesOptions.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -33,7 +32,7 @@ class LLDB_API SBVariablesOptions { void SetIncludeArguments(bool); - bool GetIncludeRecognizedArguments() const; + bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const; void SetIncludeRecognizedArguments(bool); diff --git a/include/lldb/API/SBWatchpoint.h b/include/lldb/API/SBWatchpoint.h index 92d4851fc14d..9eb3b75c53f7 100644 --- a/include/lldb/API/SBWatchpoint.h +++ b/include/lldb/API/SBWatchpoint.h @@ -1,9 +1,8 @@ //===-- SBWatchpoint.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index 95087e42bae8..4b59e02b4dc4 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -1,32 +1,27 @@ //===-- Breakpoint.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Breakpoint_h_ #define liblldb_Breakpoint_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/BreakpointLocationList.h" #include "lldb/Breakpoint/BreakpointName.h" #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/Stoppoint.h" -#include "lldb/Core/Event.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/StringList.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Breakpoint/BreakpointID.h b/include/lldb/Breakpoint/BreakpointID.h index bbad45ca2d8b..de6b056dd230 100644 --- a/include/lldb/Breakpoint/BreakpointID.h +++ b/include/lldb/Breakpoint/BreakpointID.h @@ -1,19 +1,14 @@ //===-- BreakpointID.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointID_h_ #define liblldb_BreakpointID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/BreakpointIDList.h b/include/lldb/Breakpoint/BreakpointIDList.h index ec305583e8d9..9845a9134bd7 100644 --- a/include/lldb/Breakpoint/BreakpointIDList.h +++ b/include/lldb/Breakpoint/BreakpointIDList.h @@ -1,22 +1,17 @@ //===-- BreakpointIDList.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointIDList_h_ #define liblldb_BreakpointIDList_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/Breakpoint/BreakpointID.h" diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h index f4c013d41cc2..152294d63e64 100644 --- a/include/lldb/Breakpoint/BreakpointList.h +++ b/include/lldb/Breakpoint/BreakpointList.h @@ -1,22 +1,17 @@ //===-- BreakpointList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointList_h_ #define liblldb_BreakpointList_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" namespace lldb_private { @@ -53,18 +48,6 @@ class BreakpointList { //------------------------------------------------------------------ void Dump(Stream *s) const; - //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint with id \a breakID. - /// - /// @param[in] breakID - /// The breakpoint ID to seek for. - /// - /// @result - /// A shared pointer to the breakpoint. May contain a NULL pointer if the - /// breakpoint doesn't exist. - //------------------------------------------------------------------ - lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID); - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with id \a breakID. Const /// version. @@ -76,7 +59,7 @@ class BreakpointList { /// A shared pointer to the breakpoint. May contain a NULL pointer if the /// breakpoint doesn't exist. //------------------------------------------------------------------ - const lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const; + lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const; //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with index \a i. @@ -88,20 +71,7 @@ class BreakpointList { /// A shared pointer to the breakpoint. May contain a NULL pointer if the /// breakpoint doesn't exist. //------------------------------------------------------------------ - lldb::BreakpointSP GetBreakpointAtIndex(size_t i); - - //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint with index \a i, const - /// version - /// - /// @param[in] i - /// The breakpoint index to seek for. - /// - /// @result - /// A shared pointer to the breakpoint. May contain a NULL pointer if the - /// breakpoint doesn't exist. - //------------------------------------------------------------------ - const lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const; + lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const; //------------------------------------------------------------------ /// Find all the breakpoints with a given name @@ -201,7 +171,7 @@ class BreakpointList { void GetListMutex(std::unique_lock &lock); protected: - typedef std::list bp_collection; + typedef std::vector bp_collection; bp_collection::iterator GetBreakpointIDIterator(lldb::break_id_t breakID); @@ -211,7 +181,7 @@ class BreakpointList { std::recursive_mutex &GetMutex() const { return m_mutex; } mutable std::recursive_mutex m_mutex; - bp_collection m_breakpoints; // The breakpoint list, currently a list. + bp_collection m_breakpoints; lldb::break_id_t m_next_break_id; bool m_is_internal; diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index c5911085e61b..03c0e7c68c52 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -1,22 +1,17 @@ //===-- BreakpointLocation.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointLocation_h_ #define liblldb_BreakpointLocation_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Core/Address.h" diff --git a/include/lldb/Breakpoint/BreakpointLocationCollection.h b/include/lldb/Breakpoint/BreakpointLocationCollection.h index 579d468647f3..15d7c5cdbf9c 100644 --- a/include/lldb/Breakpoint/BreakpointLocationCollection.h +++ b/include/lldb/Breakpoint/BreakpointLocationCollection.h @@ -1,22 +1,17 @@ //===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointLocationCollection_h_ #define liblldb_BreakpointLocationCollection_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Iterable.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h index 4e61abb2838e..e546e819f698 100644 --- a/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/include/lldb/Breakpoint/BreakpointLocationList.h @@ -1,23 +1,18 @@ //===-- BreakpointLocationList.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointLocationList_h_ #define liblldb_BreakpointLocationList_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Utility/Iterable.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/BreakpointName.h b/include/lldb/Breakpoint/BreakpointName.h index 292a0de4f48b..14b68dab830a 100644 --- a/include/lldb/Breakpoint/BreakpointName.h +++ b/include/lldb/Breakpoint/BreakpointName.h @@ -1,31 +1,26 @@ //===-- BreakpointName.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Breakpoint_Name_h_ #define liblldb_Breakpoint_Name_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/BreakpointLocationList.h" #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/Stoppoint.h" -#include "lldb/Core/Event.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/StringList.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index 84821817f980..5fe659b3d073 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -1,22 +1,17 @@ //===-- BreakpointOptions.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointOptions_h_ #define liblldb_BreakpointOptions_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Baton.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/StringList.h" diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index e343879a713b..054923563d29 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -1,19 +1,14 @@ //===-- BreakpointResolver.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointResolver_h_ #define liblldb_BreakpointResolver_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Address.h" #include "lldb/Core/SearchFilter.h" diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h index 0cbf38327b4b..9ffc9ce4cd9c 100644 --- a/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -1,19 +1,14 @@ //===-- BreakpointResolverAddress.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointResolverAddress_h_ #define liblldb_BreakpointResolverAddress_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/ModuleSpec.h" diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 75602e21d83d..2e64d0db89b7 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -1,19 +1,14 @@ //===-- BreakpointResolverFileLine.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointResolverFileLine_h_ #define liblldb_BreakpointResolverFileLine_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" namespace lldb_private { diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index 2db3c24d58fa..17148589835d 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -1,21 +1,16 @@ //===-- BreakpointResolverFileRegex.h ----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointResolverFileRegex_h_ #define liblldb_BreakpointResolverFileRegex_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Utility/ConstString.h" diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h index b5aa8b7e6b21..9c4d2cf0a6f5 100644 --- a/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/include/lldb/Breakpoint/BreakpointResolverName.h @@ -1,22 +1,17 @@ //===-- BreakpointResolverName.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointResolverName_h_ #define liblldb_BreakpointResolverName_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/Module.h" @@ -31,20 +26,23 @@ namespace lldb_private { class BreakpointResolverName : public BreakpointResolver { public: BreakpointResolverName(Breakpoint *bkpt, const char *name, - uint32_t name_type_mask, lldb::LanguageType language, + lldb::FunctionNameType name_type_mask, + lldb::LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue); // This one takes an array of names. It is always MatchType = Exact. BreakpointResolverName(Breakpoint *bkpt, const char *names[], - size_t num_names, uint32_t name_type_mask, + size_t num_names, + lldb::FunctionNameType name_type_mask, lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); // This one takes a C++ array of names. It is always MatchType = Exact. BreakpointResolverName(Breakpoint *bkpt, std::vector names, - uint32_t name_type_mask, lldb::LanguageType language, - lldb::addr_t offset, bool skip_prologue); + lldb::FunctionNameType name_type_mask, + lldb::LanguageType language, lldb::addr_t offset, + bool skip_prologue); // Creates a function breakpoint by regular expression. Takes over control // of the lifespan of func_regex. @@ -89,7 +87,8 @@ class BreakpointResolverName : public BreakpointResolver { lldb::LanguageType m_language; bool m_skip_prologue; - void AddNameLookup(const ConstString &name, uint32_t name_type_mask); + void AddNameLookup(const ConstString &name, + lldb::FunctionNameType name_type_mask); }; } // namespace lldb_private diff --git a/include/lldb/Breakpoint/BreakpointResolverScripted.h b/include/lldb/Breakpoint/BreakpointResolverScripted.h index f95f9d001548..f12f48ab96d9 100644 --- a/include/lldb/Breakpoint/BreakpointResolverScripted.h +++ b/include/lldb/Breakpoint/BreakpointResolverScripted.h @@ -1,19 +1,14 @@ //===-- BreakpointResolverScripted.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointResolverScripted_h_ #define liblldb_BreakpointResolverScripted_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-forward.h" #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/ModuleSpec.h" diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h index c9bd883ca738..8a183f93f365 100644 --- a/include/lldb/Breakpoint/BreakpointSite.h +++ b/include/lldb/Breakpoint/BreakpointSite.h @@ -1,24 +1,19 @@ //===-- BreakpointSite.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointSite_h_ #define liblldb_BreakpointSite_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Utility/UserID.h" diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h index d6530c170430..91eea560a6c9 100644 --- a/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/include/lldb/Breakpoint/BreakpointSiteList.h @@ -1,23 +1,18 @@ //===-- BreakpointSiteList.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_BreakpointSiteList_h_ #define liblldb_BreakpointSiteList_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointSite.h" namespace lldb_private { diff --git a/include/lldb/Breakpoint/Stoppoint.h b/include/lldb/Breakpoint/Stoppoint.h index 3195ef942d9e..4547c6f93216 100644 --- a/include/lldb/Breakpoint/Stoppoint.h +++ b/include/lldb/Breakpoint/Stoppoint.h @@ -1,19 +1,14 @@ //===-- Stoppoint.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Stoppoint_h_ #define liblldb_Stoppoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/StoppointCallbackContext.h b/include/lldb/Breakpoint/StoppointCallbackContext.h index 1dac342d3325..cfc26feba78e 100644 --- a/include/lldb/Breakpoint/StoppointCallbackContext.h +++ b/include/lldb/Breakpoint/StoppointCallbackContext.h @@ -1,9 +1,8 @@ //===-- StoppointCallbackContext.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h index 5c717bbc3b0f..095ddf7ac768 100644 --- a/include/lldb/Breakpoint/StoppointLocation.h +++ b/include/lldb/Breakpoint/StoppointLocation.h @@ -1,19 +1,14 @@ //===-- StoppointLocation.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StoppointLocation_h_ #define liblldb_StoppointLocation_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" // #include "lldb/Breakpoint/BreakpointOptions.h" diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h index 10df18a5c266..ea59e52ff18e 100644 --- a/include/lldb/Breakpoint/Watchpoint.h +++ b/include/lldb/Breakpoint/Watchpoint.h @@ -1,22 +1,17 @@ //===-- Watchpoint.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Watchpoint_h_ #define liblldb_Watchpoint_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Breakpoint/WatchpointOptions.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Breakpoint/WatchpointList.h b/include/lldb/Breakpoint/WatchpointList.h index d5e0da444afb..3a35fc9bba4f 100644 --- a/include/lldb/Breakpoint/WatchpointList.h +++ b/include/lldb/Breakpoint/WatchpointList.h @@ -1,23 +1,18 @@ //===-- WatchpointList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_WatchpointList_h_ #define liblldb_WatchpointList_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h index 8cb3b97f3a62..460a5684afac 100644 --- a/include/lldb/Breakpoint/WatchpointOptions.h +++ b/include/lldb/Breakpoint/WatchpointOptions.h @@ -1,22 +1,17 @@ //===-- WatchpointOptions.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_WatchpointOptions_h_ #define liblldb_WatchpointOptions_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Baton.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index 617aaefe91c9..313135c3727e 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -1,22 +1,21 @@ //===-- Address.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Address_h_ #define liblldb_Address_h_ -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for SectionWP, SectionSP, ModuleSP -#include "lldb/lldb-private-enumerations.h" // for AddressClass -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include // for size_t -#include // for uint32_t, UINT32_MAX, int64_t +#include +#include namespace lldb_private { class Block; @@ -508,9 +507,9 @@ class Address { /// /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*) //------------------------------------------------------------------ - uint32_t CalculateSymbolContext( - SymbolContext *sc, - uint32_t resolve_scope = lldb::eSymbolContextEverything) const; + uint32_t CalculateSymbolContext(SymbolContext *sc, + lldb::SymbolContextItem resolve_scope = + lldb::eSymbolContextEverything) const; lldb::ModuleSP CalculateSymbolContextModule() const; diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h index 9f69c87ee354..d2f87a21403e 100644 --- a/include/lldb/Core/AddressRange.h +++ b/include/lldb/Core/AddressRange.h @@ -1,9 +1,8 @@ //===-- AddressRange.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #define liblldb_AddressRange_h_ #include "lldb/Core/Address.h" -#include "lldb/lldb-forward.h" // for SectionSP -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include // for size_t +#include namespace lldb_private { class SectionList; diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h index cfd103e0be01..9b155b4fbf7d 100644 --- a/include/lldb/Core/AddressResolver.h +++ b/include/lldb/Core/AddressResolver.h @@ -1,9 +1,8 @@ //===-- AddressResolver.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,9 +11,9 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/SearchFilter.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" -#include // for size_t +#include #include namespace lldb_private { diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h index 5d846e3be72a..e60837eaa8f2 100644 --- a/include/lldb/Core/AddressResolverFileLine.h +++ b/include/lldb/Core/AddressResolverFileLine.h @@ -1,9 +1,8 @@ //===-- AddressResolverFileLine.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,11 +10,11 @@ #define liblldb_AddressResolverFileLine_h_ #include "lldb/Core/AddressResolver.h" -#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR... -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-defines.h" -#include // for uint32_t +#include namespace lldb_private { class Address; diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h index ec8cf6d18d5b..5165f4fda1b6 100644 --- a/include/lldb/Core/AddressResolverName.h +++ b/include/lldb/Core/AddressResolverName.h @@ -1,9 +1,8 @@ //===-- AddressResolverName.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #define liblldb_AddressResolverName_h_ #include "lldb/Core/AddressResolver.h" -#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::Call... -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" namespace lldb_private { class Address; diff --git a/include/lldb/Core/Architecture.h b/include/lldb/Core/Architecture.h index 3a5a9789223d..195fd7ba4a61 100644 --- a/include/lldb/Core/Architecture.h +++ b/include/lldb/Core/Architecture.h @@ -1,9 +1,8 @@ //===-- Architecture.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -67,6 +66,51 @@ class Architecture : public PluginInterface { virtual void AdjustBreakpointAddress(const Symbol &func, Address &addr) const {} + + //------------------------------------------------------------------ + /// Get \a load_addr as a callable code load address for this target + /// + /// Take \a load_addr and potentially add any address bits that are + /// needed to make the address callable. For ARM this can set bit + /// zero (if it already isn't) if \a load_addr is a thumb function. + /// If \a addr_class is set to AddressClass::eInvalid, then the address + /// adjustment will always happen. If it is set to an address class + /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be + /// returned. + //------------------------------------------------------------------ + virtual lldb::addr_t GetCallableLoadAddress( + lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const { + return addr; + } + + //------------------------------------------------------------------ + /// Get \a load_addr as an opcode for this target. + /// + /// Take \a load_addr and potentially strip any address bits that are + /// needed to make the address point to an opcode. For ARM this can + /// clear bit zero (if it already isn't) if \a load_addr is a + /// thumb function and load_addr is in code. + /// If \a addr_class is set to AddressClass::eInvalid, then the address + /// adjustment will always happen. If it is set to an address class + /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be + /// returned. + //------------------------------------------------------------------ + + virtual lldb::addr_t GetOpcodeLoadAddress( + lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const { + return addr; + } + + // Get load_addr as breakable load address for this target. Take a addr and + // check if for any reason there is a better address than this to put a + // breakpoint on. If there is then return that address. For MIPS, if + // instruction at addr is a delay slot instruction then this method will find + // the address of its previous instruction and return that address. + virtual lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr, + Target &target) const { + return addr; + } + private: Architecture(const Architecture &) = delete; void operator=(const Architecture &) = delete; diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h index 4335be050761..245e2a154edc 100644 --- a/include/lldb/Core/ClangForward.h +++ b/include/lldb/Core/ClangForward.h @@ -1,19 +1,14 @@ //===-- ClangForward.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangForward_h_ #define liblldb_ClangForward_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #if defined(__cplusplus) diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h index 3e29307039e4..affb5b898ec0 100644 --- a/include/lldb/Core/Communication.h +++ b/include/lldb/Core/Communication.h @@ -1,30 +1,29 @@ //===-- Communication.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Communication_h_ #define liblldb_Communication_h_ -#include "lldb/Core/Broadcaster.h" #include "lldb/Host/HostThread.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Timeout.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ConnectionStatus, FLAGS_ANONYMOU... -#include "lldb/lldb-forward.h" // for ConnectionSP -#include "lldb/lldb-types.h" // for thread_arg_t, thread_result_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" #include #include -#include // for micro +#include #include -#include // for size_t -#include // for uint8_t +#include +#include namespace lldb_private { class Connection; diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index 4f261a002fe1..f33a14081396 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -1,53 +1,48 @@ //===-- Debugger.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Debugger_h_ #define liblldb_Debugger_h_ -// C Includes #include -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/SourceManager.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/Terminal.h" -#include "lldb/Target/ExecutionContext.h" // for ExecutionContext +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" #include "lldb/Target/TargetList.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/UserID.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ScriptLanguage, Langua... -#include "lldb/lldb-forward.h" // for StreamFileSP, DebuggerSP -#include "lldb/lldb-private-enumerations.h" // for VarSetOperationType -#include "lldb/lldb-private-types.h" // for LoadPluginCallbackType -#include "lldb/lldb-types.h" // for LogOutputCallback, thr... - -#include "llvm/ADT/ArrayRef.h" // for ArrayRef -#include "llvm/ADT/StringMap.h" // for StringMap -#include "llvm/ADT/StringRef.h" // for StringRef -#include "llvm/Support/DynamicLibrary.h" // for DynamicLibrary +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-types.h" +#include "lldb/lldb-types.h" + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Threading.h" -#include // for assert -#include // for size_t +#include +#include #include namespace lldb_private { @@ -268,6 +263,8 @@ class Debugger : public std::enable_shared_from_this, void SetPrompt(llvm::StringRef p); void SetPrompt(const char *) = delete; + llvm::StringRef GetReproducerPath() const; + bool GetUseExternalEditor() const; bool SetUseExternalEditor(bool use_external_editor_p); diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index ef1f2ee54dd1..5a1ef92c2557 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -1,9 +1,8 @@ //===-- Disassembler.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,32 +11,32 @@ #include "lldb/Core/Address.h" #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/FormatEntity.h" // for FormatEntity +#include "lldb/Core/FormatEntity.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Symbol/LineEntry.h" -#include "lldb/Target/ExecutionContext.h" // for ExecutionContext +#include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for InstructionSP, DisassemblerSP -#include "lldb/lldb-private-enumerations.h" // for AddressClass -#include "lldb/lldb-types.h" // for addr_t, offset_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include // for function +#include #include -#include // for enable_shared_from_this +#include #include #include #include -#include // for size_t -#include // for uint32_t, int64_t -#include // for FILE +#include +#include +#include namespace lldb_private { class AddressRange; diff --git a/include/lldb/Core/DumpDataExtractor.h b/include/lldb/Core/DumpDataExtractor.h index 46e676c239d1..f2d9a505a1fa 100644 --- a/include/lldb/Core/DumpDataExtractor.h +++ b/include/lldb/Core/DumpDataExtractor.h @@ -1,20 +1,19 @@ //===-- DumpDataExtractor.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_CORE_DUMPDATAEXTRACTOR_H #define LLDB_CORE_DUMPDATAEXTRACTOR_H -#include "lldb/lldb-enumerations.h" // for Format +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-types.h" -#include // for size_t -#include // for uint32_t, uint64_t +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/DumpRegisterValue.h b/include/lldb/Core/DumpRegisterValue.h index bc4860fbc0e5..443fdb34266a 100644 --- a/include/lldb/Core/DumpRegisterValue.h +++ b/include/lldb/Core/DumpRegisterValue.h @@ -1,9 +1,8 @@ //===-- DumpRegisterValue.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 5d23bcd7b96e..a5b7ae1d8397 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -1,9 +1,8 @@ //===-- EmulateInstruction.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,18 +11,18 @@ #include -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for RegisterKind, ByteOrder -#include "lldb/lldb-private-enumerations.h" // for InstructionType -#include "lldb/lldb-private-types.h" // for RegisterInfo -#include "lldb/lldb-types.h" // for addr_t - -#include // for size_t -#include // for uint32_t, uint64_t, int64_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-types.h" +#include "lldb/lldb-types.h" + +#include +#include namespace lldb_private { class OptionValueDictionary; } diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h index 61a06d499fef..41eb40f5a6eb 100644 --- a/include/lldb/Core/FileLineResolver.h +++ b/include/lldb/Core/FileLineResolver.h @@ -1,21 +1,20 @@ //===-- FileLineResolver.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_FileLineResolver_h_ #define liblldb_FileLineResolver_h_ -#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR... +#include "lldb/Core/SearchFilter.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-defines.h" -#include // for uint32_t, UINT32_MAX +#include namespace lldb_private { class Address; diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h index 713ed2aaffc6..b21ed975e91f 100644 --- a/include/lldb/Core/FileSpecList.h +++ b/include/lldb/Core/FileSpecList.h @@ -1,9 +1,8 @@ //===-- FileSpecList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,7 +14,7 @@ #include -#include // for size_t +#include namespace lldb_private { class Stream; diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h index 7090ee9c58ec..2a9e6c09f9cf 100644 --- a/include/lldb/Core/FormatEntity.h +++ b/include/lldb/Core/FormatEntity.h @@ -1,9 +1,8 @@ //===-- FormatEntity.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,13 +10,13 @@ #define liblldb_FormatEntity_h_ #include "lldb/Utility/CompletionRequest.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" -#include "lldb/lldb-enumerations.h" // for Format::eFormatDefault, Format -#include "lldb/lldb-types.h" // for addr_t -#include // for min -#include // for size_t -#include // for uint32_t, uint64_t +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-types.h" +#include +#include +#include #include #include diff --git a/include/lldb/Core/Highlighter.h b/include/lldb/Core/Highlighter.h index 220557c1f032..8f3c4ab919ce 100644 --- a/include/lldb/Core/Highlighter.h +++ b/include/lldb/Core/Highlighter.h @@ -1,9 +1,8 @@ //===-- Highlighter.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h index d575d3d22ea1..b7fa806def43 100644 --- a/include/lldb/Core/IOHandler.h +++ b/include/lldb/Core/IOHandler.h @@ -1,9 +1,8 @@ //===-- IOHandler.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,22 +10,22 @@ #define liblldb_IOHandler_h_ #include "lldb/Core/ValueObjectList.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for IOHandlerSP, StreamFileSP -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" #include #include #include #include -#include // for uint32_t -#include // for FILE +#include +#include namespace lldb_private { class Debugger; @@ -205,7 +204,7 @@ class IOHandlerDelegate { virtual int IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches); + StringList &matches, StringList &descriptions); virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; } @@ -430,7 +429,8 @@ class IOHandlerEditline : public IOHandler { static int AutoCompleteCallback(const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches, void *baton); + StringList &matches, StringList &descriptions, + void *baton); #endif protected: @@ -464,7 +464,7 @@ class IOHandlerConfirm : public IOHandlerDelegate, public IOHandlerEditline { int IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches) override; + StringList &matches, StringList &descriptions) override; void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override; diff --git a/include/lldb/Core/IOStreamMacros.h b/include/lldb/Core/IOStreamMacros.h index 2562f179ca5d..45bde88f9441 100644 --- a/include/lldb/Core/IOStreamMacros.h +++ b/include/lldb/Core/IOStreamMacros.h @@ -1,9 +1,8 @@ //===-- IOStreamMacros.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h index 6554c64fa870..f7f83604fc1a 100644 --- a/include/lldb/Core/LoadedModuleInfoList.h +++ b/include/lldb/Core/LoadedModuleInfoList.h @@ -1,23 +1,19 @@ //===-- LoadedModuleInfoList.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_LoadedModuleInfoList_h_ #define liblldb_LoadedModuleInfoList_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes #include "lldb/lldb-defines.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h index 12edf8200e43..917184efcd6c 100644 --- a/include/lldb/Core/Mangled.h +++ b/include/lldb/Core/Mangled.h @@ -1,9 +1,8 @@ //===-- Mangled.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h index 1bdf59c73649..7dc9b5be3465 100644 --- a/include/lldb/Core/MappedHash.h +++ b/include/lldb/Core/MappedHash.h @@ -1,27 +1,22 @@ //===-- MappedHash.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_MappedHash_h_ #define liblldb_MappedHash_h_ -// C Includes #include #include -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Stream.h" #include "llvm/Support/DJB.h" diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 8a943b8e5751..59e3f40b3d71 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -1,40 +1,39 @@ //===-- Module.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Module_h_ #define liblldb_Module_h_ -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/ModuleSpec.h" // for ModuleSpec -#include "lldb/Symbol/ObjectFile.h" // for ObjectFile +#include "lldb/Core/Address.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Status.h" #include "lldb/Utility/UUID.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for LanguageType, SymbolType +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" -#include "lldb/lldb-types.h" // for addr_t, offset_t +#include "lldb/lldb-types.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Chrono.h" #include -#include // for enable_shared_from_this +#include #include -#include // for size_t -#include // for uint32_t, uint64_t +#include +#include #include #include @@ -168,10 +167,11 @@ class Module : public std::enable_shared_from_this, // Once we get the object file, update our module with the object file's // architecture since it might differ in vendor/os if some parts were // unknown. - if (!module_sp->m_objfile_sp->GetArchitecture(module_sp->m_arch)) - return nullptr; - - return module_sp; + if (ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture()) { + module_sp->m_arch = arch; + return module_sp; + } + return nullptr; } //------------------------------------------------------------------ @@ -380,7 +380,7 @@ class Module : public std::enable_shared_from_this, //------------------------------------------------------------------ size_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool symbols_ok, + lldb::FunctionNameType name_type_mask, bool symbols_ok, bool inlines_ok, bool append, SymbolContextList &sc_list); @@ -498,10 +498,6 @@ class Module : public std::enable_shared_from_this, /// have to specify complete scoping on all expressions, but it also allows /// for exact matching when required. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. - /// /// @param[in] type_name /// The name of the type we are looking for that is a fully /// or partially qualified type name. @@ -520,8 +516,7 @@ class Module : public std::enable_shared_from_this, /// The number of matches added to \a type_list. //------------------------------------------------------------------ size_t - FindTypes(const SymbolContext &sc, const ConstString &type_name, - bool exact_match, size_t max_matches, + FindTypes(const ConstString &type_name, bool exact_match, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeList &types); @@ -533,10 +528,6 @@ class Module : public std::enable_shared_from_this, /// expression parser when searches need to happen in an exact namespace /// scope. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. - /// /// @param[in] type_name /// The name of a type within a namespace that should not include /// any qualifying namespaces (just a type basename). @@ -550,8 +541,7 @@ class Module : public std::enable_shared_from_this, /// @return /// The number of matches added to \a type_list. //------------------------------------------------------------------ - size_t FindTypesInNamespace(const SymbolContext &sc, - const ConstString &type_name, + size_t FindTypesInNamespace(const ConstString &type_name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList &type_list); @@ -816,10 +806,9 @@ class Module : public std::enable_shared_from_this, /// /// @see SymbolContext::Scope //------------------------------------------------------------------ - uint32_t - ResolveSymbolContextForAddress(const Address &so_addr, uint32_t resolve_scope, - SymbolContext &sc, - bool resolve_tail_call_address = false); + uint32_t ResolveSymbolContextForAddress( + const Address &so_addr, lldb::SymbolContextItem resolve_scope, + SymbolContext &sc, bool resolve_tail_call_address = false); //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. @@ -862,10 +851,9 @@ class Module : public std::enable_shared_from_this, /// /// @see SymbolContext::Scope //------------------------------------------------------------------ - uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, - bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list); + uint32_t ResolveSymbolContextForFilePath( + const char *file_path, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. @@ -909,10 +897,9 @@ class Module : public std::enable_shared_from_this, /// /// @see SymbolContext::Scope //------------------------------------------------------------------ - uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, - uint32_t line, bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list); + uint32_t ResolveSymbolContextsForFileSpec( + const FileSpec &file_spec, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); void SetFileSpecAndObjectName(const FileSpec &file, const ConstString &object_name); @@ -1054,9 +1041,10 @@ class Module : public std::enable_shared_from_this, public: LookupInfo() : m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown), - m_name_type_mask(0), m_match_name_after_lookup(false) {} + m_name_type_mask(lldb::eFunctionNameTypeNone), + m_match_name_after_lookup(false) {} - LookupInfo(const ConstString &name, uint32_t name_type_mask, + LookupInfo(const ConstString &name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language); const ConstString &GetName() const { return m_name; } @@ -1067,24 +1055,31 @@ class Module : public std::enable_shared_from_this, void SetLookupName(const ConstString &name) { m_lookup_name = name; } - uint32_t GetNameTypeMask() const { return m_name_type_mask; } + lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; } - void SetNameTypeMask(uint32_t mask) { m_name_type_mask = mask; } + void SetNameTypeMask(lldb::FunctionNameType mask) { + m_name_type_mask = mask; + } void Prune(SymbolContextList &sc_list, size_t start_idx) const; protected: - ConstString m_name; ///< What the user originally typed - ConstString m_lookup_name; ///< The actual name will lookup when calling in - ///the object or symbol file - lldb::LanguageType - m_language; ///< Limit matches to only be for this language - uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType - ///that indicate what kind of names we are - ///looking for - bool m_match_name_after_lookup; ///< If \b true, then demangled names that - ///match will need to contain "m_name" in - ///order to be considered a match + /// What the user originally typed + ConstString m_name; + + /// The actual name will lookup when calling in the object or symbol file + ConstString m_lookup_name; + + /// Limit matches to only be for this language + lldb::LanguageType m_language; + + /// One or more bits from lldb::FunctionNameType that indicate what kind of + /// names we are looking for + lldb::FunctionNameType m_name_type_mask; + + ///< If \b true, then demangled names that match will need to contain + ///< "m_name" in order to be considered a match + bool m_match_name_after_lookup; }; protected: @@ -1178,7 +1173,7 @@ class Module : public std::enable_shared_from_this, //------------------------------------------------------------------ uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr, bool vm_addr_is_file_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, Address &so_addr, SymbolContext &sc); void SymbolIndicesToSymbolContextList(Symtab *symtab, @@ -1199,9 +1194,8 @@ class Module : public std::enable_shared_from_this, Module(); // Only used internally by CreateJITModule () size_t FindTypes_Impl( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types); diff --git a/include/lldb/Core/ModuleChild.h b/include/lldb/Core/ModuleChild.h index 73438040c359..27245d8ccaa1 100644 --- a/include/lldb/Core/ModuleChild.h +++ b/include/lldb/Core/ModuleChild.h @@ -1,9 +1,8 @@ //===-- ModuleChild.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index 91b142780669..11c507029c3d 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -1,21 +1,20 @@ //===-- ModuleList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ModuleList_h_ #define liblldb_ModuleList_h_ -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/ModuleSpec.h" // for ModuleSpec +#include "lldb/Core/Address.h" +#include "lldb/Core/ModuleSpec.h" #include "lldb/Core/UserSettingsController.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Iterable.h" -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" @@ -27,8 +26,8 @@ #include #include -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { class ConstString; @@ -301,14 +300,16 @@ class ModuleList { //------------------------------------------------------------------ /// @see Module::FindFunctions () //------------------------------------------------------------------ - size_t FindFunctions(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctions(const ConstString &name, + lldb::FunctionNameType name_type_mask, bool include_symbols, bool include_inlines, bool append, SymbolContextList &sc_list) const; //------------------------------------------------------------------ /// @see Module::FindFunctionSymbols () //------------------------------------------------------------------ - size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctionSymbols(const ConstString &name, + lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list); //------------------------------------------------------------------ @@ -416,9 +417,9 @@ class ModuleList { //------------------------------------------------------------------ /// Find types by name. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. + /// @param[in] search_first + /// If non-null, this module will be searched before any other + /// modules. /// /// @param[in] name /// The name of the type we are looking for. @@ -446,7 +447,7 @@ class ModuleList { /// @return /// The number of matches added to \a type_list. //------------------------------------------------------------------ - size_t FindTypes(const SymbolContext &sc, const ConstString &name, + size_t FindTypes(Module *search_first, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeList &types) const; @@ -496,26 +497,24 @@ class ModuleList { /// &,uint32_t,SymbolContext&) //------------------------------------------------------------------ uint32_t ResolveSymbolContextForAddress(const Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContext &sc) const; //------------------------------------------------------------------ /// @copydoc Module::ResolveSymbolContextForFilePath (const char /// *,uint32_t,bool,uint32_t,SymbolContextList&) //------------------------------------------------------------------ - uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, - bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list) const; + uint32_t ResolveSymbolContextForFilePath( + const char *file_path, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const; //------------------------------------------------------------------ /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec /// &,uint32_t,bool,uint32_t,SymbolContextList&) //------------------------------------------------------------------ - uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, - uint32_t line, bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list) const; + uint32_t ResolveSymbolContextsForFileSpec( + const FileSpec &file_spec, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const; //------------------------------------------------------------------ /// Gets the size of the module list. diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index 16a35a187780..d8f042f579f7 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -1,27 +1,23 @@ //===-- ModuleSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ModuleSpec_h_ #define liblldb_ModuleSpec_h_ -// Project includes +#include "lldb/Host/FileSystem.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UUID.h" -// Other libraries and framework includes #include "llvm/Support/Chrono.h" -// C Includes -// C++ Includes #include #include @@ -34,15 +30,17 @@ class ModuleSpec { m_object_name(), m_object_offset(0), m_object_size(0), m_source_mappings() {} - ModuleSpec(const FileSpec &file_spec, const UUID& uuid = UUID()) + ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID()) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(), m_uuid(uuid), m_object_name(), m_object_offset(0), - m_object_size(file_spec.GetByteSize()), m_source_mappings() {} + m_object_size(FileSystem::Instance().GetByteSize(file_spec)), + m_source_mappings() {} ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch), m_uuid(), m_object_name(), m_object_offset(0), - m_object_size(file_spec.GetByteSize()), m_source_mappings() {} + m_object_size(FileSystem::Instance().GetByteSize(file_spec)), + m_source_mappings() {} ModuleSpec(const ModuleSpec &rhs) : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file), @@ -256,20 +254,20 @@ class ModuleSpec { if (match_module_spec.GetFileSpecPtr()) { const FileSpec &fspec = match_module_spec.GetFileSpec(); if (!FileSpec::Equal(fspec, GetFileSpec(), - fspec.GetDirectory().IsEmpty() == false)) + !fspec.GetDirectory().IsEmpty())) return false; } if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr()) { const FileSpec &fspec = match_module_spec.GetPlatformFileSpec(); if (!FileSpec::Equal(fspec, GetPlatformFileSpec(), - fspec.GetDirectory().IsEmpty() == false)) + !fspec.GetDirectory().IsEmpty())) return false; } // Only match the symbol file spec if there is one in this ModuleSpec if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr()) { const FileSpec &fspec = match_module_spec.GetSymbolFileSpec(); if (!FileSpec::Equal(fspec, GetSymbolFileSpec(), - fspec.GetDirectory().IsEmpty() == false)) + !fspec.GetDirectory().IsEmpty())) return false; } if (match_module_spec.GetArchitecturePtr()) { diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index 33857457b2c4..9fdcfdf40ed6 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -1,9 +1,8 @@ //===-- Opcode.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,12 +10,12 @@ #define lldb_Opcode_h #include "lldb/Utility/Endian.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eByteOrde... +#include "lldb/lldb-enumerations.h" #include "llvm/Support/MathExtras.h" -#include // for assert -#include // for uint32_t, uint8_t, uint16_t +#include +#include #include namespace lldb_private { diff --git a/include/lldb/Core/PluginInterface.h b/include/lldb/Core/PluginInterface.h index edda15a1ace0..6e625a605917 100644 --- a/include/lldb/Core/PluginInterface.h +++ b/include/lldb/Core/PluginInterface.h @@ -1,19 +1,14 @@ //===-- PluginInterface.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PluginInterface_h_ #define liblldb_PluginInterface_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index b782294f1f60..5a936f6e8656 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -1,9 +1,8 @@ //===-- PluginManager.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,14 +11,14 @@ #include "lldb/Core/Architecture.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for ScriptLanguage -#include "lldb/lldb-forward.h" // for OptionValuePropertiesSP -#include "lldb/lldb-private-interfaces.h" // for DebuggerInitializeCallback -#include "llvm/ADT/StringRef.h" // for StringRef - -#include // for size_t -#include // for uint32_t +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-interfaces.h" +#include "llvm/ADT/StringRef.h" + +#include +#include namespace lldb_private { class CommandInterpreter; diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index ab73f6038772..7d99c81bf52a 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -1,24 +1,19 @@ //===-- RangeMap.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RangeMap_h_ #define liblldb_RangeMap_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "llvm/ADT/SmallVector.h" -// Project includes #include "lldb/lldb-private.h" // Uncomment to make sure all Range objects are sorted when needed @@ -637,201 +632,12 @@ struct RangeData : public Range { } }; -template class RangeDataArray { +template +class RangeDataVector { public: typedef RangeData Entry; typedef llvm::SmallVector Collection; - RangeDataArray() = default; - - ~RangeDataArray() = default; - - void Append(const Entry &entry) { m_entries.push_back(entry); } - - void Sort() { - if (m_entries.size() > 1) - std::stable_sort(m_entries.begin(), m_entries.end()); - } - -#ifdef ASSERT_RANGEMAP_ARE_SORTED - bool IsSorted() const { - typename Collection::const_iterator pos, end, prev; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; - prev = pos++) { - if (prev != end && *pos < *prev) - return false; - } - return true; - } -#endif - - void CombineConsecutiveEntriesWithEqualData() { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - typename Collection::iterator pos; - typename Collection::iterator end; - typename Collection::iterator prev; - bool can_combine = false; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; - prev = pos++) { - if (prev != end && prev->data == pos->data) { - can_combine = true; - break; - } - } - - // We we can combine at least one entry, then we make a new collection and - // populate it accordingly, and then swap it into place. - if (can_combine) { - Collection minimal_ranges; - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; - pos != end; prev = pos++) { - if (prev != end && prev->data == pos->data) - minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd()); - else - minimal_ranges.push_back(*pos); - } - // Use the swap technique in case our new vector is much smaller. We must - // swap when using the STL because std::vector objects never release or - // reduce the memory once it has been allocated/reserved. - m_entries.swap(minimal_ranges); - } - } - - void Clear() { m_entries.clear(); } - - bool IsEmpty() const { return m_entries.empty(); } - - size_t GetSize() const { return m_entries.size(); } - - const Entry *GetEntryAtIndex(size_t i) const { - return ((i < m_entries.size()) ? &m_entries[i] : nullptr); - } - - // Clients must ensure that "i" is a valid index prior to calling this - // function - const Entry &GetEntryRef(size_t i) const { return m_entries[i]; } - - static bool BaseLessThan(const Entry &lhs, const Entry &rhs) { - return lhs.GetRangeBase() < rhs.GetRangeBase(); - } - - uint32_t FindEntryIndexThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry(addr, 1); - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - if (pos != end && pos->Contains(addr)) { - return std::distance(begin, pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) - return std::distance(begin, pos); - } - } - return UINT32_MAX; - } - - Entry *FindEntryThatContains(B addr) { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - typename Collection::iterator begin = m_entries.begin(); - typename Collection::iterator end = m_entries.end(); - typename Collection::iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - if (pos != end && pos->Contains(addr)) { - return &(*pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) { - return &(*pos); - } - } - } - return nullptr; - } - - const Entry *FindEntryThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - if (pos != end && pos->Contains(addr)) { - return &(*pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) { - return &(*pos); - } - } - } - return nullptr; - } - - const Entry *FindEntryThatContains(const Entry &range) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, range, BaseLessThan); - - if (pos != end && pos->Contains(range)) { - return &(*pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(range)) { - return &(*pos); - } - } - } - return nullptr; - } - - Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); } - - const Entry *Back() const { - return (m_entries.empty() ? nullptr : &m_entries.back()); - } - -protected: - Collection m_entries; -}; - -// Same as RangeDataArray, but uses std::vector as to not require static -// storage of N items in the class itself -template class RangeDataVector { -public: - typedef RangeData Entry; - typedef std::vector Collection; - RangeDataVector() = default; ~RangeDataVector() = default; @@ -893,38 +699,8 @@ template class RangeDataVector { } } - // Calculate the byte size of ranges with zero byte sizes by finding the next - // entry with a base address > the current base address - void CalculateSizesOfZeroByteSizeRanges(S full_size = 0) { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - typename Collection::iterator pos; - typename Collection::iterator end; - typename Collection::iterator next; - for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) { - if (pos->GetByteSize() == 0) { - // Watch out for multiple entries with same address and make sure we - // find an entry that is greater than the current base address before - // we use that for the size - auto curr_base = pos->GetRangeBase(); - for (next = pos + 1; next != end; ++next) { - auto next_base = next->GetRangeBase(); - if (next_base > curr_base) { - pos->SetByteSize(next_base - curr_base); - break; - } - } - if (next == end && full_size > curr_base) - pos->SetByteSize(full_size - curr_base); - } - } - } - void Clear() { m_entries.clear(); } - void Reserve(typename Collection::size_type size) { m_entries.resize(size); } - bool IsEmpty() const { return m_entries.empty(); } size_t GetSize() const { return m_entries.size(); } @@ -946,22 +722,9 @@ template class RangeDataVector { } uint32_t FindEntryIndexThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry(addr, 1); - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - while (pos != begin && pos[-1].Contains(addr)) - --pos; - - if (pos != end && pos->Contains(addr)) - return std::distance(begin, pos); - } + const Entry *entry = FindEntryThatContains(addr); + if (entry) + return std::distance(m_entries.begin(), entry); return UINT32_MAX; } @@ -981,47 +744,13 @@ template class RangeDataVector { } Entry *FindEntryThatContains(B addr) { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - typename Collection::iterator begin = m_entries.begin(); - typename Collection::iterator end = m_entries.end(); - typename Collection::iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - while (pos != begin && pos[-1].Contains(addr)) - --pos; - - if (pos != end && pos->Contains(addr)) - return &(*pos); - } - return nullptr; + return const_cast( + static_cast(this)->FindEntryThatContains( + addr)); } const Entry *FindEntryThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - typename Collection::const_iterator begin = m_entries.begin(); - typename Collection::const_iterator end = m_entries.end(); - typename Collection::const_iterator pos = - std::lower_bound(begin, end, entry, BaseLessThan); - - while (pos != begin && pos[-1].Contains(addr)) - --pos; - - if (pos != end && pos->Contains(addr)) - return &(*pos); - } - return nullptr; + return FindEntryThatContains(Entry(addr, 1)); } const Entry *FindEntryThatContains(const Entry &range) const { diff --git a/include/lldb/Core/RichManglingContext.h b/include/lldb/Core/RichManglingContext.h index bfa910c0b43c..4f11080642f0 100644 --- a/include/lldb/Core/RichManglingContext.h +++ b/include/lldb/Core/RichManglingContext.h @@ -1,9 +1,8 @@ //===-- RichManglingContext.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,10 +24,9 @@ namespace lldb_private { /// providers. See Mangled::DemangleWithRichManglingInfo() class RichManglingContext { public: - RichManglingContext() - : m_provider(None), m_ipd_buf_size(2048), m_ipd_str_len(0) { + RichManglingContext() : m_provider(None), m_ipd_buf_size(2048) { m_ipd_buf = static_cast(std::malloc(m_ipd_buf_size)); - m_ipd_buf[m_ipd_str_len] = '\0'; + m_ipd_buf[0] = '\0'; } ~RichManglingContext() { std::free(m_ipd_buf); } @@ -81,7 +79,6 @@ class RichManglingContext { llvm::ItaniumPartialDemangler m_ipd; char *m_ipd_buf; size_t m_ipd_buf_size; - size_t m_ipd_str_len; /// Members for PluginCxxLanguage /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h index 55f1ac05c975..9e63055456a2 100644 --- a/include/lldb/Core/STLUtils.h +++ b/include/lldb/Core/STLUtils.h @@ -1,25 +1,20 @@ //===-- STLUtils.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_STLUtils_h_ #define liblldb_STLUtils_h_ -// C Includes #include -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes //---------------------------------------------------------------------- // C string less than compare function object diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index 57b383103daf..a74e46661f3f 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -1,9 +1,8 @@ //===-- SearchFilter.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,10 +12,10 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Utility/StructuredData.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-forward.h" // for SearchFilterSP, TargetSP, Modu... +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" -#include // for uint32_t +#include namespace lldb_private { class Address; diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h index 8e275ce3199e..1011eac1dcba 100644 --- a/include/lldb/Core/Section.h +++ b/include/lldb/Core/Section.h @@ -1,9 +1,8 @@ //===-- Section.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,16 +13,16 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/UserID.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for SectionType -#include "lldb/lldb-forward.h" // for SectionSP, ModuleSP, SectionWP -#include "lldb/lldb-types.h" // for addr_t, offset_t, user_id_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include // for enable_shared_from_this -#include // for vector +#include +#include -#include // for size_t -#include // for uint32_t, UINT32_MAX +#include +#include namespace lldb_private { class Address; diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h index 06ff74bd2766..36648378d93a 100644 --- a/include/lldb/Core/SourceManager.h +++ b/include/lldb/Core/SourceManager.h @@ -1,9 +1,8 @@ //===-- SourceManager.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,16 +10,16 @@ #define liblldb_SourceManager_h_ #include "lldb/Utility/FileSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for DebuggerSP, DebuggerWP, DataBufferSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include "llvm/Support/Chrono.h" -#include // for uint32_t, UINT32_MAX +#include #include #include -#include // for size_t -#include // for string +#include +#include #include namespace lldb_private { diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h index 8791315dbeb5..1a9ecba20a93 100644 --- a/include/lldb/Core/StreamAsynchronousIO.h +++ b/include/lldb/Core/StreamAsynchronousIO.h @@ -1,9 +1,8 @@ //===-- StreamAsynchronousIO.h -----------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,7 +13,7 @@ #include -#include // for size_t +#include namespace lldb_private { class Debugger; diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h index 7b2468330ad2..9fbdbf94029d 100644 --- a/include/lldb/Core/StreamBuffer.h +++ b/include/lldb/Core/StreamBuffer.h @@ -1,9 +1,8 @@ //===-- StreamBuffer.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h index 250876bdefbc..4941e994d0ce 100644 --- a/include/lldb/Core/StreamFile.h +++ b/include/lldb/Core/StreamFile.h @@ -1,9 +1,8 @@ //===-- StreamFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,11 +11,11 @@ #include "lldb/Host/File.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for FilePermissions::eFilePermission... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" -#include // for uint32_t -#include // for size_t, FILE +#include +#include namespace lldb_private { diff --git a/include/lldb/Core/StructuredDataImpl.h b/include/lldb/Core/StructuredDataImpl.h index 819d1d9e5d2f..79a709af7ca3 100644 --- a/include/lldb/Core/StructuredDataImpl.h +++ b/include/lldb/Core/StructuredDataImpl.h @@ -1,17 +1,16 @@ //===-- StructuredDataImpl.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StructuredDataImpl_h_ #define liblldb_StructuredDataImpl_h_ -#include "lldb/Core/Event.h" #include "lldb/Target/StructuredDataPlugin.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h index 9b52e0355314..c485b91acb47 100644 --- a/include/lldb/Core/ThreadSafeDenseMap.h +++ b/include/lldb/Core/ThreadSafeDenseMap.h @@ -1,24 +1,19 @@ //===-- ThreadSafeDenseMap.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadSafeDenseMap_h_ #define liblldb_ThreadSafeDenseMap_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h index 44ec2464385f..fbc8d3fb02f8 100644 --- a/include/lldb/Core/ThreadSafeDenseSet.h +++ b/include/lldb/Core/ThreadSafeDenseSet.h @@ -1,24 +1,19 @@ //===-- ThreadSafeDenseSet.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadSafeDenseSet_h_ #define liblldb_ThreadSafeDenseSet_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/DenseSet.h" -// Project includes namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeSTLMap.h b/include/lldb/Core/ThreadSafeSTLMap.h index 5520920c4559..cc5a71695ac1 100644 --- a/include/lldb/Core/ThreadSafeSTLMap.h +++ b/include/lldb/Core/ThreadSafeSTLMap.h @@ -1,22 +1,17 @@ //===-- ThreadSafeSTLMap.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadSafeSTLMap_h_ #define liblldb_ThreadSafeSTLMap_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeSTLVector.h b/include/lldb/Core/ThreadSafeSTLVector.h index 466f4309c2d5..7d20eb99a279 100644 --- a/include/lldb/Core/ThreadSafeSTLVector.h +++ b/include/lldb/Core/ThreadSafeSTLVector.h @@ -1,23 +1,18 @@ //===-- ThreadSafeSTLVector.h ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadSafeSTLVector_h_ #define liblldb_ThreadSafeSTLVector_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h index 10ef8fa41d0c..0bef087c0815 100644 --- a/include/lldb/Core/ThreadSafeValue.h +++ b/include/lldb/Core/ThreadSafeValue.h @@ -1,22 +1,17 @@ //===-- ThreadSafeValue.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadSafeValue_h_ #define liblldb_ThreadSafeValue_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" namespace lldb_private { diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h index fe3e831a6045..554507847332 100644 --- a/include/lldb/Core/UniqueCStringMap.h +++ b/include/lldb/Core/UniqueCStringMap.h @@ -1,22 +1,17 @@ //===-- UniqueCStringMap.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UniqueCStringMap_h_ #define liblldb_UniqueCStringMap_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" @@ -221,7 +216,7 @@ template class UniqueCStringMap { // } // my_map.Sort(); //------------------------------------------------------------------ - void Sort() { std::sort(m_map.begin(), m_map.end()); } + void Sort() { llvm::sort(m_map.begin(), m_map.end()); } //------------------------------------------------------------------ // Since we are using a vector to contain our items it will always double its diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h index aefd42e751ab..a0b2197bebe6 100644 --- a/include/lldb/Core/UserSettingsController.h +++ b/include/lldb/Core/UserSettingsController.h @@ -1,25 +1,24 @@ //====-- UserSettingsController.h --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UserSettingsController_h_ #define liblldb_UserSettingsController_h_ -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-forward.h" // for OptionValuePropertiesSP -#include "lldb/lldb-private-enumerations.h" // for VarSetOperationType +#include "lldb/Utility/Status.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { class CommandInterpreter; diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 801e818c6f5c..3f5efbfd1062 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -1,29 +1,28 @@ //===-- Value.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Value_h_ #define liblldb_Value_h_ -#include "lldb/Core/Scalar.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eB... -#include "lldb/lldb-private-enumerations.h" // for AddressType -#include "lldb/lldb-private-types.h" // for type128, RegisterInfo +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-types.h" -#include "llvm/ADT/APInt.h" // for APInt +#include "llvm/ADT/APInt.h" #include -#include // for uint8_t, uint32_t, uint64_t -#include // for size_t, memcpy +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index 20ee9df37c57..7a3af616521d 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -1,9 +1,8 @@ //===-- ValueObject.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,7 +12,7 @@ #include "lldb/Core/SwiftASTContextReader.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/Type.h" // for TypeImpl +#include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" @@ -21,26 +20,26 @@ #include "lldb/Utility/SharedCluster.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UserID.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID... -#include "lldb/lldb-enumerations.h" // for DynamicValue... -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-private-enumerations.h" // for AddressType -#include "lldb/lldb-types.h" // for addr_t, offs... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include #include #include -#include // for recursive_mutex -#include // for string -#include // for pair +#include +#include +#include -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { class Declaration; } @@ -641,9 +640,6 @@ class ValueObject : public UserID { virtual void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, AddressType address_type = eAddressTypeLoad) {} - // Find the address of the C++ vtable pointer - virtual lldb::addr_t GetCPPVTableAddress(AddressType &address_type); - virtual lldb::ValueObjectSP Cast(const CompilerType &compiler_type); virtual lldb::ValueObjectSP CastPointerType(const char *name, diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h index aaa1ecb67db8..1c004b2bdc76 100644 --- a/include/lldb/Core/ValueObjectCast.h +++ b/include/lldb/Core/ValueObjectCast.h @@ -1,9 +1,8 @@ //===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,13 +10,13 @@ #define liblldb_ValueObjectCast_h_ #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-forward.h" // for ValueObjectSP +#include "lldb/Symbol/CompilerType.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" -#include // for size_t -#include // for uint32_t, uint64_t +#include +#include namespace lldb_private { class ConstString; diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h index ec8c9e805cdf..5b3c8c803019 100644 --- a/include/lldb/Core/ValueObjectChild.h +++ b/include/lldb/Core/ValueObjectChild.h @@ -1,9 +1,8 @@ //===-- ValueObjectChild.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,17 +11,17 @@ #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-private-enumerations.h" // for LazyBool, AddressType -#include "lldb/lldb-types.h" // for offset_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/Optional.h" -#include // for size_t -#include // for uint32_t, uint64_t, int32_t +#include +#include namespace lldb_private { diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h index 1f56129df24a..bb4064928c7d 100644 --- a/include/lldb/Core/ValueObjectConstResult.h +++ b/include/lldb/Core/ValueObjectConstResult.h @@ -1,29 +1,28 @@ //===-- ValueObjectConstResult.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ValueObjectConstResult_h_ #define liblldb_ValueObjectConstResult_h_ -#include "lldb/Core/Value.h" // for Value +#include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-enumerations.h" // for ByteOrder, Dynamic... -#include "lldb/lldb-forward.h" // for ValueObjectSP, Dat... -#include "lldb/lldb-private-enumerations.h" // for AddressType, Addre... -#include "lldb/lldb-types.h" // for addr_t - -#include // for size_t -#include // for uint32_t, uint64_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" + +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h index 442cce420855..f6fa759251e3 100644 --- a/include/lldb/Core/ValueObjectConstResultCast.h +++ b/include/lldb/Core/ValueObjectConstResultCast.h @@ -1,9 +1,8 @@ //===-- ValueObjectConstResultCast.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,14 +11,14 @@ #include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_... -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-types.h" // for addr_t - -#include // for size_t -#include // for uint32_t, int32_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h index a74da0013aba..f9dd57b79865 100644 --- a/include/lldb/Core/ValueObjectConstResultChild.h +++ b/include/lldb/Core/ValueObjectConstResultChild.h @@ -1,9 +1,8 @@ //===-- ValueObjectConstResultChild.h ----------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,14 +11,14 @@ #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_... -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-types.h" // for addr_t - -#include // for size_t -#include // for uint32_t, int32_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include namespace lldb_private { class DataExtractor; } @@ -63,6 +62,9 @@ class ValueObjectConstResultChild : public ValueObjectChild { lldb::ValueObjectSP AddressOf(Status &error) override; + lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr) override; + size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1) override; diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h index d86f25e30579..753db722f9ba 100644 --- a/include/lldb/Core/ValueObjectConstResultImpl.h +++ b/include/lldb/Core/ValueObjectConstResultImpl.h @@ -1,23 +1,22 @@ //===-- ValueObjectConstResultImpl.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ValueObjectConstResultImpl_h_ #define liblldb_ValueObjectConstResultImpl_h_ -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-private-enumerations.h" // for AddressType, AddressType... -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include // for size_t -#include // for uint32_t, int32_t +#include +#include namespace lldb_private { class CompilerType; } diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h index 26180fd36a3f..e765e2ad0790 100644 --- a/include/lldb/Core/ValueObjectDynamicValue.h +++ b/include/lldb/Core/ValueObjectDynamicValue.h @@ -1,29 +1,28 @@ //===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ValueObjectDynamicValue_h_ #define liblldb_ValueObjectDynamicValue_h_ -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/SharingPtr.h" // for operator== -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua... -#include "lldb/lldb-forward.h" // for ValueObjectSP, VariableSP -#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz... - -#include // for assert -#include // for size_t -#include // for uint64_t, uint32_t +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/SharingPtr.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" + +#include +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h index a0d2e681dedb..03f944b87b2c 100644 --- a/include/lldb/Core/ValueObjectList.h +++ b/include/lldb/Core/ValueObjectList.h @@ -1,21 +1,20 @@ //===-- ValueObjectList.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ValueObjectList_h_ #define liblldb_ValueObjectList_h_ -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-types.h" // for user_id_t +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" #include -#include // for size_t +#include namespace lldb_private { class ValueObject; diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h index 8bb649cc3c52..946baf4eaadc 100644 --- a/include/lldb/Core/ValueObjectMemory.h +++ b/include/lldb/Core/ValueObjectMemory.h @@ -1,26 +1,25 @@ //===-- ValueObjectMemory.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ValueObjectMemory_h_ #define liblldb_ValueObjectMemory_h_ -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-forward.h" // for TypeSP, ValueObjectSP, ModuleSP -#include "llvm/ADT/StringRef.h" // for StringRef - -#include // for size_t -#include // for uint32_t, uint64_t +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" + +#include +#include namespace lldb_private { class ExecutionContextScope; diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h index 2aaef9bee99e..83eb5a500602 100644 --- a/include/lldb/Core/ValueObjectRegister.h +++ b/include/lldb/Core/ValueObjectRegister.h @@ -1,26 +1,25 @@ //===-- ValueObjectRegister.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ValueObjectRegister_h_ #define liblldb_ValueObjectRegister_h_ -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType, ValueType::eValueTy... -#include "lldb/lldb-forward.h" // for RegisterContextSP, ValueObjectSP -#include "lldb/lldb-private-types.h" // for RegisterInfo, RegisterSet (ptr... - -#include // for size_t -#include // for uint32_t, uint64_t, int32_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-types.h" + +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h index a163a3478c6b..6ebca2f32c9b 100644 --- a/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -1,9 +1,8 @@ //===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,17 +12,17 @@ #include "lldb/Core/ThreadSafeSTLMap.h" #include "lldb/Core/ThreadSafeSTLVector.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for ThreadSafeSTLMap::operator= -#include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua... -#include "lldb/lldb-forward.h" // for ValueObjectSP, Synthetic... -#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz... - -#include // for uint32_t, uint64_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" + +#include #include -#include // for size_t +#include namespace lldb_private { class Declaration; diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h index 9dd140a84f45..3a974a01a6c1 100644 --- a/include/lldb/Core/ValueObjectVariable.h +++ b/include/lldb/Core/ValueObjectVariable.h @@ -1,9 +1,8 @@ //===-- ValueObjectVariable.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,15 +11,15 @@ #include "lldb/Core/ValueObject.h" -#include "lldb/Core/Value.h" // for Value -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-forward.h" // for VariableSP, ModuleSP, ValueObj... +#include "lldb/Core/Value.h" +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" -#include // for size_t -#include // for uint32_t, uint64_t +#include +#include namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h index 651a2bc29475..0303d3801c14 100644 --- a/include/lldb/Core/dwarf.h +++ b/include/lldb/Core/dwarf.h @@ -1,9 +1,8 @@ //===-- dwarf.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/CXXFunctionPointer.h b/include/lldb/DataFormatters/CXXFunctionPointer.h index 13af2fd9da1c..b5417895f7bf 100644 --- a/include/lldb/DataFormatters/CXXFunctionPointer.h +++ b/include/lldb/DataFormatters/CXXFunctionPointer.h @@ -1,9 +1,8 @@ //===-- CXXFunctionPointer.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index 369fa686a9ff..dbeb229a97b8 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -1,20 +1,15 @@ //===-- DataVisualization.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_DataVisualization_h_ #define lldb_DataVisualization_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Utility/ConstString.h" diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h index f3ed238987b3..d881589c382f 100644 --- a/include/lldb/DataFormatters/DumpValueObjectOptions.h +++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h @@ -1,21 +1,16 @@ //===-- DumpValueObjectOptions.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_DumpValueObjectOptions_h_ #define lldb_DumpValueObjectOptions_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index 9901ec91ebd2..39a428a203bc 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -1,23 +1,18 @@ //===-- FormatCache.h ---------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_FormatCache_h_ #define lldb_FormatCache_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index 458477578d3f..91e7d45cd936 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -1,24 +1,19 @@ //===-- FormatClasses.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_FormatClasses_h_ #define lldb_FormatClasses_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index 373ac5e1ec1a..4d509474c8e3 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -1,25 +1,20 @@ //===-- FormatManager.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_FormatManager_h_ #define lldb_FormatManager_h_ -// C Includes -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h index df88e88011fe..a700bfbb70ec 100644 --- a/include/lldb/DataFormatters/FormattersContainer.h +++ b/include/lldb/DataFormatters/FormattersContainer.h @@ -1,25 +1,20 @@ //===-- FormattersContainer.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_FormattersContainer_h_ #define lldb_FormattersContainer_h_ -// C Includes -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-public.h" #include "lldb/Core/ValueObject.h" diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h index 14ba5e48feb4..35f1f946c3c8 100644 --- a/include/lldb/DataFormatters/FormattersHelpers.h +++ b/include/lldb/DataFormatters/FormattersHelpers.h @@ -1,20 +1,15 @@ //===-- FormattersHelpers.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_FormattersHelpers_h_ #define lldb_FormattersHelpers_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h index e94429407837..f109d46194ad 100644 --- a/include/lldb/DataFormatters/LanguageCategory.h +++ b/include/lldb/DataFormatters/LanguageCategory.h @@ -1,21 +1,16 @@ //===-- LanguageCategory.h----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_LanguageCategory_h_ #define lldb_LanguageCategory_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatCache.h" #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h index 18207921bb71..41d5edd88021 100644 --- a/include/lldb/DataFormatters/StringPrinter.h +++ b/include/lldb/DataFormatters/StringPrinter.h @@ -1,22 +1,17 @@ //===-- StringPrinter.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StringPrinter_h_ #define liblldb_StringPrinter_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-forward.h" #include "lldb/Utility/DataExtractor.h" diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index 0a5b09baa624..431af32feb8d 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -1,25 +1,20 @@ //===-- TypeCategory.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_TypeCategory_h_ #define lldb_TypeCategory_h_ -// C Includes -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" @@ -348,7 +343,7 @@ class TypeCategoryImpl { bool IsEnabled() const { return m_enabled; } uint32_t GetEnabledPosition() { - if (m_enabled == false) + if (!m_enabled) return UINT32_MAX; else return m_enabled_position; diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index f767c985ff34..f430d4cf65ff 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -1,24 +1,19 @@ //===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_TypeCategoryMap_h_ #define lldb_TypeCategoryMap_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h index 77e3542f5522..77e8c0efc706 100644 --- a/include/lldb/DataFormatters/TypeFormat.h +++ b/include/lldb/DataFormatters/TypeFormat.h @@ -1,26 +1,21 @@ //===-- TypeFormat.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_TypeFormat_h_ #define lldb_TypeFormat_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 17cd61ae8c1e..9cd05f076f6d 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -1,25 +1,20 @@ //===-- TypeSummary.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_TypeSummary_h_ #define lldb_TypeSummary_h_ -// C Includes #include -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index 07dacd670a62..b99bc6bf0d43 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -1,27 +1,22 @@ //===-- TypeSynthetic.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_TypeSynthetic_h_ #define lldb_TypeSynthetic_h_ -// C Includes #include -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h index fa2a89148118..531812eeb056 100644 --- a/include/lldb/DataFormatters/TypeValidator.h +++ b/include/lldb/DataFormatters/TypeValidator.h @@ -1,25 +1,20 @@ //===-- TypeValidator.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_TypeValidator_h_ #define lldb_TypeValidator_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h index b9d4ceb40620..41adc2d2b5b2 100644 --- a/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -1,21 +1,16 @@ //===-- ValueObjectPrinter.h ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_ValueObjectPrinter_h_ #define lldb_ValueObjectPrinter_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h index f695d2290502..3309eefa2f49 100644 --- a/include/lldb/DataFormatters/VectorIterator.h +++ b/include/lldb/DataFormatters/VectorIterator.h @@ -1,10 +1,9 @@ //===-- VectorIterator.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/DataFormatters/VectorType.h b/include/lldb/DataFormatters/VectorType.h index 4ca0c4519f9f..b757f758e77f 100644 --- a/include/lldb/DataFormatters/VectorType.h +++ b/include/lldb/DataFormatters/VectorType.h @@ -1,9 +1,8 @@ //===-- VectorType.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h index 3feb50bb964e..06ee4c7a4b51 100644 --- a/include/lldb/Expression/DWARFExpression.h +++ b/include/lldb/Expression/DWARFExpression.h @@ -1,9 +1,8 @@ //===-- DWARFExpression.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,8 +11,8 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include @@ -40,7 +39,10 @@ class DWARFExpression { enum LocationListFormat : uint8_t { NonLocationList, // Not a location list RegularLocationList, // Location list format used in non-split dwarf files - SplitDwarfLocationList, // Location list format used in split dwarf files + SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split + // dwarf files (.debug_loc.dwo) + LocLists, // Location list format used in DWARF v5 + // (.debug_loclists/.debug_loclists.dwo). }; //------------------------------------------------------------------ @@ -152,7 +154,7 @@ class DWARFExpression { lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const; bool Update_DW_OP_addr(lldb::addr_t file_addr); - + void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; } bool ContainsThreadLocalStorage() const; diff --git a/include/lldb/Expression/DiagnosticManager.h b/include/lldb/Expression/DiagnosticManager.h index 83e67df2649a..7e3e2bb8606a 100644 --- a/include/lldb/Expression/DiagnosticManager.h +++ b/include/lldb/Expression/DiagnosticManager.h @@ -1,9 +1,8 @@ //===-- DiagnosticManager.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h index 0495a1218138..db602d6a1b8b 100644 --- a/include/lldb/Expression/Expression.h +++ b/include/lldb/Expression/Expression.h @@ -1,23 +1,18 @@ //===-- Expression.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Expression_h_ #define liblldb_Expression_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Expression/ExpressionTypeSystemHelper.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h index 95ffc942b84a..ebbafef476d0 100644 --- a/include/lldb/Expression/ExpressionParser.h +++ b/include/lldb/Expression/ExpressionParser.h @@ -1,15 +1,15 @@ //===-- ExpressionParser.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ExpressionParser_h_ #define liblldb_ExpressionParser_h_ +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-public.h" @@ -49,6 +49,41 @@ class ExpressionParser { //------------------------------------------------------------------ virtual ~ExpressionParser(){}; + //------------------------------------------------------------------ + /// Attempts to find possible command line completions for the given + /// expression. + /// + /// @param[out] request + /// The completion request to fill out. The completion should be a string + /// that would complete the current token at the cursor position. + /// Note that the string in the list replaces the current token + /// in the command line. + /// + /// @param[in] line + /// The line with the completion cursor inside the expression as a string. + /// The first line in the expression has the number 0. + /// + /// @param[in] pos + /// The character position in the line with the completion cursor. + /// If the value is 0, then the cursor is on top of the first character + /// in the line (i.e. the user has requested completion from the start of + /// the expression). + /// + /// @param[in] typed_pos + /// The cursor position in the line as typed by the user. If the user + /// expression has not been transformed in some form (e.g. wrapping it + /// in a function body for C languages), then this is equal to the + /// 'pos' parameter. The semantics of this value are otherwise equal to + /// 'pos' (e.g. a value of 0 means the cursor is at start of the + /// expression). + /// + /// @return + /// True if we added any completion results to the output; + /// false otherwise. + //------------------------------------------------------------------ + virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos, + unsigned typed_pos) = 0; + //------------------------------------------------------------------ /// Parse a single expression and convert it to IR using Clang. Don't wrap /// the expression in anything at all. diff --git a/include/lldb/Expression/ExpressionSourceCode.h b/include/lldb/Expression/ExpressionSourceCode.h index 5d75aed05037..6b4938f49631 100644 --- a/include/lldb/Expression/ExpressionSourceCode.h +++ b/include/lldb/Expression/ExpressionSourceCode.h @@ -1,9 +1,8 @@ //===-- ExpressionSourceCode.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/ExpressionTypeSystemHelper.h b/include/lldb/Expression/ExpressionTypeSystemHelper.h index ffcad54fb9f9..1466c38f3c55 100644 --- a/include/lldb/Expression/ExpressionTypeSystemHelper.h +++ b/include/lldb/Expression/ExpressionTypeSystemHelper.h @@ -1,10 +1,9 @@ //===-- ExpressionTypeSystemHelper.h ---------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h index d9d6cc4cbb9d..c346802f6e43 100644 --- a/include/lldb/Expression/ExpressionVariable.h +++ b/include/lldb/Expression/ExpressionVariable.h @@ -1,24 +1,19 @@ //===-- ExpressionVariable.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ExpressionVariable_h_ #define liblldb_ExpressionVariable_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes #include "lldb/Core/ValueObject.h" #include "lldb/Utility/ConstString.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Expression/FunctionCaller.h b/include/lldb/Expression/FunctionCaller.h index c36263e34240..b71e2f5ce921 100644 --- a/include/lldb/Expression/FunctionCaller.h +++ b/include/lldb/Expression/FunctionCaller.h @@ -1,24 +1,19 @@ //===-- FunctionCaller.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_FunctionCaller_h_ #define liblldb_FunctionCaller_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Core/Value.h" #include "lldb/Expression/Expression.h" diff --git a/include/lldb/Expression/IRDynamicChecks.h b/include/lldb/Expression/IRDynamicChecks.h index f31c03cfb9ef..68f977a1eea2 100644 --- a/include/lldb/Expression/IRDynamicChecks.h +++ b/include/lldb/Expression/IRDynamicChecks.h @@ -1,10 +1,9 @@ //===-- IRDynamicChecks.h ---------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index 732d8034c088..7723d80862de 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -1,28 +1,23 @@ //===-- IRExecutionUnit.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_IRExecutionUnit_h_ #define liblldb_IRExecutionUnit_h_ -// C Includes -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/Module.h" -// Project includes #include "lldb/Expression/IRMemoryMap.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -113,7 +108,7 @@ class IRExecutionUnit : public std::enable_shared_from_this, void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list) override; - bool GetArchitecture(lldb_private::ArchSpec &arch) override; + ArchSpec GetArchitecture() override; lldb::ModuleSP GetJITModule(); diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h index 2d87346b7066..51dc3355e134 100644 --- a/include/lldb/Expression/IRInterpreter.h +++ b/include/lldb/Expression/IRInterpreter.h @@ -1,9 +1,8 @@ //===-- IRInterpreter.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h index df8a03f4763f..73fbc1cec6bc 100644 --- a/include/lldb/Expression/IRMemoryMap.h +++ b/include/lldb/Expression/IRMemoryMap.h @@ -1,9 +1,8 @@ //===-- IRExecutionUnit.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -39,7 +38,7 @@ class IRMemoryMap { IRMemoryMap(lldb::TargetSP target_sp); ~IRMemoryMap(); - enum AllocationPolicy { + enum AllocationPolicy : uint8_t { eAllocationPolicyInvalid = 0, ///< It is an error for an allocation to have this policy. eAllocationPolicyHostOnly, ///< This allocation was created in the host and @@ -91,32 +90,32 @@ class IRMemoryMap { private: struct Allocation { lldb::addr_t - m_process_alloc; ///< The (unaligned) base for the remote allocation + m_process_alloc; ///< The (unaligned) base for the remote allocation. lldb::addr_t - m_process_start; ///< The base address of the allocation in the process - size_t m_size; ///< The size of the requested allocation - uint32_t m_permissions; ///< The access permissions on the memory in the - ///process. In the host, the memory is always - ///read/write. - uint8_t m_alignment; ///< The alignment of the requested allocation + m_process_start; ///< The base address of the allocation in the process. + size_t m_size; ///< The size of the requested allocation. DataBufferHeap m_data; - ///< Flags + /// Flags. Keep these grouped together to avoid structure padding. AllocationPolicy m_policy; bool m_leak; + uint8_t m_permissions; ///< The access permissions on the memory in the + /// process. In the host, the memory is always + /// read/write. + uint8_t m_alignment; ///< The alignment of the requested allocation. public: Allocation(lldb::addr_t process_alloc, lldb::addr_t process_start, size_t size, uint32_t permissions, uint8_t alignment, AllocationPolicy m_policy); - Allocation() - : m_process_alloc(LLDB_INVALID_ADDRESS), - m_process_start(LLDB_INVALID_ADDRESS), m_size(0), m_permissions(0), - m_alignment(0), m_data(), m_policy(eAllocationPolicyInvalid), - m_leak(false) {} + DISALLOW_COPY_AND_ASSIGN(Allocation); }; + static_assert(sizeof(Allocation) <= + (4 * sizeof(lldb::addr_t)) + sizeof(DataBufferHeap), + "IRMemoryMap::Allocation is larger than expected"); + lldb::ProcessWP m_process_wp; lldb::TargetWP m_target_wp; typedef std::map AllocationMap; diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h index 51832e30fb11..8e41aa2bcac7 100644 --- a/include/lldb/Expression/LLVMUserExpression.h +++ b/include/lldb/Expression/LLVMUserExpression.h @@ -1,25 +1,20 @@ //===-- LLVMUserExpression.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_LLVMUserExpression_h #define liblldb_LLVMUserExpression_h -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes #include "llvm/IR/LegacyPassManager.h" -// Project includes #include "lldb/Expression/UserExpression.h" namespace lldb_private { diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h index 9cd23f25283e..17cad096f0c0 100644 --- a/include/lldb/Expression/Materializer.h +++ b/include/lldb/Expression/Materializer.h @@ -1,22 +1,17 @@ //===-- Materializer.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Materializer_h #define liblldb_Materializer_h -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Expression/IRMemoryMap.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/StackFrame.h" diff --git a/include/lldb/Expression/REPL.h b/include/lldb/Expression/REPL.h index 0c1e97fec259..3a3cb2f62611 100644 --- a/include/lldb/Expression/REPL.h +++ b/include/lldb/Expression/REPL.h @@ -1,21 +1,16 @@ //===-- REPL.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_REPL_h #define lldb_REPL_h -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/../../source/Commands/CommandObjectExpression.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" @@ -117,7 +112,7 @@ class REPL : public IOHandlerDelegate { int IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches) override; + StringList &matches, StringList &descriptions) override; protected: static int CalculateActualIndentation(const StringList &lines); diff --git a/include/lldb/Expression/UserExpression.h b/include/lldb/Expression/UserExpression.h index 87f7a355c448..9dc6bf00b71d 100644 --- a/include/lldb/Expression/UserExpression.h +++ b/include/lldb/Expression/UserExpression.h @@ -1,23 +1,18 @@ //===-- UserExpression.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UserExpression_h_ #define liblldb_UserExpression_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Expression/Expression.h" #include "lldb/Expression/Materializer.h" @@ -99,6 +94,34 @@ class UserExpression : public Expression { bool keep_result_in_memory, bool generate_debug_info, uint32_t line_offset) = 0; + //------------------------------------------------------------------ + /// Attempts to find possible command line completions for the given + /// (possible incomplete) user expression. + /// + /// @param[in] exe_ctx + /// The execution context to use when looking up entities that + /// are needed for parsing and completing (locations of functions, types + /// of variables, persistent variables, etc.) + /// + /// @param[out] request + /// The completion request to fill out. The completion should be a string + /// that would complete the current token at the cursor position. + /// Note that the string in the list replaces the current token + /// in the command line. + /// + /// @param[in] complete_pos + /// The position of the cursor inside the user expression string. + /// The completion process starts on the token that the cursor is in. + /// + /// @return + /// True if we added any completion results to the output; + /// false otherwise. + //------------------------------------------------------------------ + virtual bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request, + unsigned complete_pos) { + return false; + } + virtual bool CanInterpret() = 0; bool MatchesContext(ExecutionContext &exe_ctx); diff --git a/include/lldb/Expression/UtilityFunction.h b/include/lldb/Expression/UtilityFunction.h index 5d4bc8676b95..3a9f2ea739dc 100644 --- a/include/lldb/Expression/UtilityFunction.h +++ b/include/lldb/Expression/UtilityFunction.h @@ -1,23 +1,18 @@ //===-- UtilityFunction.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UtilityFunction_h_ #define liblldb_UtilityFunction_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Expression/Expression.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h index 771937498b32..a16d739892be 100644 --- a/include/lldb/Host/Config.h +++ b/include/lldb/Host/Config.h @@ -1,9 +1,8 @@ //===-- Config.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,6 +25,8 @@ #define HAVE_SIGACTION 1 +#define HAVE_LIBCOMPRESSION 1 + #else #error This file is only used by the Xcode build. diff --git a/include/lldb/Host/Config.h.cmake b/include/lldb/Host/Config.h.cmake index 02a57ad8ca92..b8fb9e9de868 100644 --- a/include/lldb/Host/Config.h.cmake +++ b/include/lldb/Host/Config.h.cmake @@ -1,9 +1,8 @@ //===-- Config.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/ConnectionFileDescriptor.h b/include/lldb/Host/ConnectionFileDescriptor.h index 0d486a34c8d0..00444d011af3 100644 --- a/include/lldb/Host/ConnectionFileDescriptor.h +++ b/include/lldb/Host/ConnectionFileDescriptor.h @@ -1,9 +1,8 @@ //===-- ConnectionFileDescriptor.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h index ed8e633c113f..f8fd564a5299 100644 --- a/include/lldb/Host/Debug.h +++ b/include/lldb/Host/Debug.h @@ -1,21 +1,16 @@ //===-- Debug.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Debug_h_ #define liblldb_Debug_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h index beb96e7c4924..a942ede05ce5 100644 --- a/include/lldb/Host/Editline.h +++ b/include/lldb/Host/Editline.h @@ -1,9 +1,8 @@ //===-- Editline.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -54,8 +53,8 @@ #include #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Predicate.h" namespace lldb_private { namespace line_editor { @@ -101,7 +100,8 @@ typedef int (*FixIndentationCallbackType)(Editline *editline, typedef int (*CompleteCallbackType)(const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches, void *baton); + StringList &matches, + StringList &descriptions, void *baton); /// Status used to decide when and how to start editing another line in /// multi-line sessions diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index de987c1b9a9d..24c5eca05145 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -1,9 +1,8 @@ //===-- File.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -33,6 +32,8 @@ class File : public IOObject { static int kInvalidDescriptor; static FILE *kInvalidStream; + // NB this enum is used in the lldb platform gdb-remote packet + // vFile:open: and existing values cannot be modified. enum OpenOptions { eOpenOptionRead = (1u << 0), // Open file for reading eOpenOptionWrite = (1u << 1), // Open file for writing @@ -64,50 +65,6 @@ class File : public IOObject { m_is_real_terminal(eLazyBoolCalculate), m_supports_colors(eLazyBoolCalculate) {} - //------------------------------------------------------------------ - /// Constructor with path. - /// - /// Takes a path to a file which can be just a filename, or a full path. If - /// \a path is not nullptr or empty, this function will call File::Open - /// (const char *path, uint32_t options, uint32_t permissions). - /// - /// @param[in] path - /// The full or partial path to a file. - /// - /// @param[in] options - /// Options to use when opening (see File::OpenOptions) - /// - /// @param[in] permissions - /// Options to use when opening (see File::Permissions) - /// - /// @see File::Open (const char *path, uint32_t options, uint32_t - /// permissions) - //------------------------------------------------------------------ - File(const char *path, uint32_t options, - uint32_t permissions = lldb::eFilePermissionsFileDefault); - - //------------------------------------------------------------------ - /// Constructor with FileSpec. - /// - /// Takes a FileSpec pointing to a file which can be just a filename, or a - /// full path. If \a path is not nullptr or empty, this function will call - /// File::Open (const char *path, uint32_t options, uint32_t permissions). - /// - /// @param[in] filespec - /// The FileSpec for this file. - /// - /// @param[in] options - /// Options to use when opening (see File::OpenOptions) - /// - /// @param[in] permissions - /// Options to use when opening (see File::Permissions) - /// - /// @see File::Open (const char *path, uint32_t options, uint32_t - /// permissions) - //------------------------------------------------------------------ - File(const FileSpec &filespec, uint32_t options, - uint32_t permissions = lldb::eFilePermissionsFileDefault); - File(int fd, bool transfer_ownership) : IOObject(eFDTypeFile, transfer_ownership), m_descriptor(fd), m_stream(kInvalidStream), m_options(0), m_own_stream(false), @@ -170,23 +127,6 @@ class File : public IOObject { //------------------------------------------------------------------ Status GetFileSpec(FileSpec &file_spec) const; - //------------------------------------------------------------------ - /// Open a file for read/writing with the specified options. - /// - /// Takes a path to a file which can be just a filename, or a full path. - /// - /// @param[in] path - /// The full or partial path to a file. - /// - /// @param[in] options - /// Options to use when opening (see File::OpenOptions) - /// - /// @param[in] permissions - /// Options to use when opening (see File::Permissions) - //------------------------------------------------------------------ - Status Open(const char *path, uint32_t options, - uint32_t permissions = lldb::eFilePermissionsFileDefault); - Status Close() override; void Clear(); @@ -420,8 +360,6 @@ class File : public IOObject { //------------------------------------------------------------------ uint32_t GetPermissions(Status &error) const; - static uint32_t GetPermissions(const FileSpec &file_spec, Status &error); - //------------------------------------------------------------------ /// Return true if this file is interactive. /// @@ -464,8 +402,10 @@ class File : public IOObject { void SetOptions(uint32_t options) { m_options = options; } + static bool DescriptorIsValid(int descriptor) { return descriptor >= 0; }; + protected: - bool DescriptorIsValid() const { return m_descriptor >= 0; } + bool DescriptorIsValid() const { return DescriptorIsValid(m_descriptor); } bool StreamIsValid() const { return m_stream != kInvalidStream; } diff --git a/include/lldb/Host/FileCache.h b/include/lldb/Host/FileCache.h index 1c03540c1eb3..0c1ef1961645 100644 --- a/include/lldb/Host/FileCache.h +++ b/include/lldb/Host/FileCache.h @@ -1,9 +1,8 @@ //===-- FileCache.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Host_FileCache_h diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h index c13d5c84c631..c8da1d1f1657 100644 --- a/include/lldb/Host/FileSystem.h +++ b/include/lldb/Host/FileSystem.h @@ -1,18 +1,23 @@ //===-- FileSystem.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Host_FileSystem_h #define liblldb_Host_FileSystem_h +#include "lldb/Host/File.h" +#include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/FileCollector.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" + +#include "llvm/ADT/Optional.h" #include "llvm/Support/Chrono.h" +#include "llvm/Support/VirtualFileSystem.h" #include "lldb/lldb-types.h" @@ -26,17 +31,161 @@ class FileSystem { static const char *DEV_NULL; static const char *PATH_CONVERSION_ERROR; - static Status Symlink(const FileSpec &src, const FileSpec &dst); - static Status Readlink(const FileSpec &src, FileSpec &dst); + FileSystem() + : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr), + m_mapped(false) {} + FileSystem(FileCollector &collector) + : m_fs(llvm::vfs::getRealFileSystem()), m_collector(&collector), + m_mapped(false) {} + FileSystem(llvm::IntrusiveRefCntPtr fs, + bool mapped = false) + : m_fs(fs), m_mapped(mapped) {} + + FileSystem(const FileSystem &fs) = delete; + FileSystem &operator=(const FileSystem &fs) = delete; + + static FileSystem &Instance(); + + static void Initialize(); + static void Initialize(FileCollector &collector); + static llvm::Error Initialize(const FileSpec &mapping); + static void Initialize(llvm::IntrusiveRefCntPtr fs); + static void Terminate(); + + Status Symlink(const FileSpec &src, const FileSpec &dst); + Status Readlink(const FileSpec &src, FileSpec &dst); + + Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst); + + /// Wraps ::fopen in a platform-independent way. + FILE *Fopen(const char *path, const char *mode); + + /// Wraps ::open in a platform-independent way. + int Open(const char *path, int flags, int mode); + + Status Open(File &File, const FileSpec &file_spec, uint32_t options, + uint32_t permissions = lldb::eFilePermissionsFileDefault); + + /// Get a directory iterator. + /// @{ + llvm::vfs::directory_iterator DirBegin(const FileSpec &file_spec, + std::error_code &ec); + llvm::vfs::directory_iterator DirBegin(const llvm::Twine &dir, + std::error_code &ec); + /// @} + + /// Returns the Status object for the given file. + /// @{ + llvm::ErrorOr GetStatus(const FileSpec &file_spec) const; + llvm::ErrorOr GetStatus(const llvm::Twine &path) const; + /// @} + + /// Returns the modification time of the given file. + /// @{ + llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const; + llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const; + /// @} + + /// Returns the on-disk size of the given file in bytes. + /// @{ + uint64_t GetByteSize(const FileSpec &file_spec) const; + uint64_t GetByteSize(const llvm::Twine &path) const; + /// @} + + /// Return the current permissions of the given file. + /// + /// Returns a bitmask for the current permissions of the file (zero or more + /// of the permission bits defined in File::Permissions). + /// @{ + uint32_t GetPermissions(const FileSpec &file_spec) const; + uint32_t GetPermissions(const llvm::Twine &path) const; + uint32_t GetPermissions(const FileSpec &file_spec, std::error_code &ec) const; + uint32_t GetPermissions(const llvm::Twine &path, std::error_code &ec) const; + /// @} + + /// Returns whether the given file exists. + /// @{ + bool Exists(const FileSpec &file_spec) const; + bool Exists(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given file is readable. + /// @{ + bool Readable(const FileSpec &file_spec) const; + bool Readable(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given path is a directory. + /// @{ + bool IsDirectory(const FileSpec &file_spec) const; + bool IsDirectory(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given path is local to the file system. + /// @{ + bool IsLocal(const FileSpec &file_spec) const; + bool IsLocal(const llvm::Twine &path) const; + /// @} + + /// Make the given file path absolute. + /// @{ + std::error_code MakeAbsolute(llvm::SmallVectorImpl &path) const; + std::error_code MakeAbsolute(FileSpec &file_spec) const; + /// @} + + /// Resolve path to make it canonical. + /// @{ + void Resolve(llvm::SmallVectorImpl &path); + void Resolve(FileSpec &file_spec); + /// @} + + //// Create memory buffer from path. + /// @{ + std::shared_ptr CreateDataBuffer(const llvm::Twine &path, + uint64_t size = 0, + uint64_t offset = 0); + std::shared_ptr CreateDataBuffer(const FileSpec &file_spec, + uint64_t size = 0, + uint64_t offset = 0); + /// @} + + /// Call into the Host to see if it can help find the file. + bool ResolveExecutableLocation(FileSpec &file_spec); + + enum EnumerateDirectoryResult { + /// Enumerate next entry in the current directory. + eEnumerateDirectoryResultNext, + /// Recurse into the current entry if it is a directory or symlink, or next + /// if not. + eEnumerateDirectoryResultEnter, + /// Stop directory enumerations at any level. + eEnumerateDirectoryResultQuit + }; + + typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)( + void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef); + + typedef std::function + DirectoryCallback; + + void EnumerateDirectory(llvm::Twine path, bool find_directories, + bool find_files, bool find_other, + EnumerateDirectoryCallbackType callback, + void *callback_baton); - static Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst); + std::error_code GetRealPath(const llvm::Twine &path, + llvm::SmallVectorImpl &output) const; - /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be - /// manipulated and closed with the normal ::fread, ::fclose, etc. functions. - static FILE *Fopen(const char *path, const char *mode); + llvm::ErrorOr GetExternalPath(const llvm::Twine &path); + llvm::ErrorOr GetExternalPath(const FileSpec &file_spec); - static llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec); +private: + static llvm::Optional &InstanceImpl(); + llvm::IntrusiveRefCntPtr m_fs; + FileCollector *m_collector; + bool m_mapped; }; -} +} // namespace lldb_private #endif diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h index 459e9f563d1e..21e1c5bf96f7 100644 --- a/include/lldb/Host/Host.h +++ b/include/lldb/Host/Host.h @@ -1,9 +1,8 @@ //===-- Host.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostGetOpt.h b/include/lldb/Host/HostGetOpt.h index d37a2526ff04..f37304751cda 100644 --- a/include/lldb/Host/HostGetOpt.h +++ b/include/lldb/Host/HostGetOpt.h @@ -1,9 +1,8 @@ //===-- GetOpt.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #pragma once diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h index df762d7160e0..c593b4011959 100644 --- a/include/lldb/Host/HostInfo.h +++ b/include/lldb/Host/HostInfo.h @@ -1,9 +1,8 @@ //===-- HostInfoBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h index aa32ad21f669..134f52a2cc2a 100644 --- a/include/lldb/Host/HostInfoBase.h +++ b/include/lldb/Host/HostInfoBase.h @@ -1,9 +1,8 @@ //===-- HostInfoBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -75,10 +74,6 @@ class HostInfoBase { /// member of the FileSpec is filled in. static FileSpec GetHeaderDir(); - /// Returns the directory containing the python modules. Only the directory - /// member of the FileSpec is filled in. - static FileSpec GetPythonDir(); - /// Returns the directory containing the system plugins. Only the directory /// member of the FileSpec is filled in. static FileSpec GetSystemPluginDir(); diff --git a/include/lldb/Host/HostNativeProcess.h b/include/lldb/Host/HostNativeProcess.h index 0aabfe197385..c86a2aef38fc 100644 --- a/include/lldb/Host/HostNativeProcess.h +++ b/include/lldb/Host/HostNativeProcess.h @@ -1,9 +1,8 @@ //===-- HostNativeProcess.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostNativeProcessBase.h b/include/lldb/Host/HostNativeProcessBase.h index 07f98c24776c..e8b0683da8bf 100644 --- a/include/lldb/Host/HostNativeProcessBase.h +++ b/include/lldb/Host/HostNativeProcessBase.h @@ -1,9 +1,8 @@ //===-- HostNativeProcessBase.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostNativeThread.h b/include/lldb/Host/HostNativeThread.h index e33d978d5ae4..8bf65849d880 100644 --- a/include/lldb/Host/HostNativeThread.h +++ b/include/lldb/Host/HostNativeThread.h @@ -1,9 +1,8 @@ //===-- HostNativeThread.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostNativeThreadBase.h b/include/lldb/Host/HostNativeThreadBase.h index f1f89f3b75fe..a196f0bc82ca 100644 --- a/include/lldb/Host/HostNativeThreadBase.h +++ b/include/lldb/Host/HostNativeThreadBase.h @@ -1,9 +1,8 @@ //===-- HostNativeThreadBase.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -35,6 +34,7 @@ class HostNativeThreadBase { virtual Status Cancel() = 0; virtual bool IsJoinable() const; virtual void Reset(); + virtual bool EqualsThread(lldb::thread_t thread) const; lldb::thread_t Release(); lldb::thread_t GetSystemHandle() const; diff --git a/include/lldb/Host/HostNativeThreadForward.h b/include/lldb/Host/HostNativeThreadForward.h index 4691a22ac844..261d3c7a836e 100644 --- a/include/lldb/Host/HostNativeThreadForward.h +++ b/include/lldb/Host/HostNativeThreadForward.h @@ -1,9 +1,8 @@ //===-- HostNativeThreadForward.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostProcess.h b/include/lldb/Host/HostProcess.h index 626ebab7ce68..a40424e50aad 100644 --- a/include/lldb/Host/HostProcess.h +++ b/include/lldb/Host/HostProcess.h @@ -1,9 +1,8 @@ //===-- HostProcess.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/HostThread.h b/include/lldb/Host/HostThread.h index 120776283aa4..24b61bc9c410 100644 --- a/include/lldb/Host/HostThread.h +++ b/include/lldb/Host/HostThread.h @@ -1,9 +1,8 @@ //===-- HostThread.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/LockFile.h b/include/lldb/Host/LockFile.h index 81cb10c7fbcb..2a1cd3dbb8f7 100644 --- a/include/lldb/Host/LockFile.h +++ b/include/lldb/Host/LockFile.h @@ -1,9 +1,8 @@ //===-- LockFile.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/LockFileBase.h b/include/lldb/Host/LockFileBase.h index 4eda1916c72e..be9e258c5c2d 100644 --- a/include/lldb/Host/LockFileBase.h +++ b/include/lldb/Host/LockFileBase.h @@ -1,9 +1,8 @@ //===-- LockFileBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/MainLoop.h b/include/lldb/Host/MainLoop.h index 13d1ff0212fa..d59aa28ccb0e 100644 --- a/include/lldb/Host/MainLoop.h +++ b/include/lldb/Host/MainLoop.h @@ -1,9 +1,8 @@ //===-- MainLoop.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h index bf01ba16db0e..3fee2b2c09d8 100644 --- a/include/lldb/Host/MainLoopBase.h +++ b/include/lldb/Host/MainLoopBase.h @@ -1,9 +1,8 @@ //===-- MainLoopBase.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h index 341284800a4e..59111a04fc98 100644 --- a/include/lldb/Host/MonitoringProcessLauncher.h +++ b/include/lldb/Host/MonitoringProcessLauncher.h @@ -1,20 +1,15 @@ //===-- MonitoringProcessLauncher.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_Host_MonitoringProcessLauncher_h_ #define lldb_Host_MonitoringProcessLauncher_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Host/ProcessLauncher.h" namespace lldb_private { diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h index 1b0dc4ae19e0..ca0594645645 100644 --- a/include/lldb/Host/OptionParser.h +++ b/include/lldb/Host/OptionParser.h @@ -1,9 +1,8 @@ //===-- OptionParser.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/Pipe.h b/include/lldb/Host/Pipe.h index 283fb1b83c25..ea75342e5427 100644 --- a/include/lldb/Host/Pipe.h +++ b/include/lldb/Host/Pipe.h @@ -1,9 +1,8 @@ //===-- Pipe.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/PipeBase.h b/include/lldb/Host/PipeBase.h index ad62072c7ba5..1aa4db339b29 100644 --- a/include/lldb/Host/PipeBase.h +++ b/include/lldb/Host/PipeBase.h @@ -1,10 +1,9 @@ //===-- PipeBase.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -41,6 +40,9 @@ class PipeBase { virtual bool CanRead() const = 0; virtual bool CanWrite() const = 0; + virtual lldb::pipe_t GetReadPipe() const = 0; + virtual lldb::pipe_t GetWritePipe() const = 0; + virtual int GetReadFileDescriptor() const = 0; virtual int GetWriteFileDescriptor() const = 0; virtual int ReleaseReadFileDescriptor() = 0; diff --git a/include/lldb/Host/PosixApi.h b/include/lldb/Host/PosixApi.h index dae2bb480091..04ca3a84983b 100644 --- a/include/lldb/Host/PosixApi.h +++ b/include/lldb/Host/PosixApi.h @@ -1,9 +1,8 @@ //===-- PosixApi.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/ProcessLauncher.h b/include/lldb/Host/ProcessLauncher.h index 49fa84113f6c..a5b6a6c76bba 100644 --- a/include/lldb/Host/ProcessLauncher.h +++ b/include/lldb/Host/ProcessLauncher.h @@ -1,9 +1,8 @@ //===-- ProcessLauncher.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h index 6f39eea716e8..88e43b350f72 100644 --- a/include/lldb/Host/ProcessRunLock.h +++ b/include/lldb/Host/ProcessRunLock.h @@ -1,22 +1,17 @@ //===-- ProcessRunLock.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessRunLock_h_ #define liblldb_ProcessRunLock_h_ -// C Includes #include #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" //---------------------------------------------------------------------- diff --git a/include/lldb/Host/PseudoTerminal.h b/include/lldb/Host/PseudoTerminal.h index 858bd35f73a6..7035f65c15cf 100644 --- a/include/lldb/Host/PseudoTerminal.h +++ b/include/lldb/Host/PseudoTerminal.h @@ -1,9 +1,8 @@ //===-- PseudoTerminal.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/SafeMachO.h b/include/lldb/Host/SafeMachO.h similarity index 93% rename from include/lldb/Utility/SafeMachO.h rename to include/lldb/Host/SafeMachO.h index 1565b313f42b..ec9887ececd5 100644 --- a/include/lldb/Utility/SafeMachO.h +++ b/include/lldb/Host/SafeMachO.h @@ -1,9 +1,8 @@ //===-- SafeMachO.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SafeMachO_h_ diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h index f6e51fd45679..642e85e65634 100644 --- a/include/lldb/Host/Socket.h +++ b/include/lldb/Host/Socket.h @@ -1,9 +1,8 @@ //===-- Socket.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,9 @@ #include "lldb/lldb-private.h" -#include "lldb/Host/Predicate.h" #include "lldb/Host/SocketAddress.h" #include "lldb/Utility/IOObject.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" #ifdef _WIN32 diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h index 749a9c664c81..8bf884ee07a3 100644 --- a/include/lldb/Host/SocketAddress.h +++ b/include/lldb/Host/SocketAddress.h @@ -1,16 +1,14 @@ //===-- SocketAddress.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SocketAddress_h_ #define liblldb_SocketAddress_h_ -// C Includes #include #ifdef _WIN32 @@ -28,9 +26,6 @@ typedef ADDRESS_FAMILY sa_family_t; #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include #include diff --git a/include/lldb/Host/StringConvert.h b/include/lldb/Host/StringConvert.h index d197df10d79e..a912c9a895dd 100644 --- a/include/lldb/Host/StringConvert.h +++ b/include/lldb/Host/StringConvert.h @@ -1,22 +1,17 @@ //===-- StringConvert.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StringConvert_h_ #define liblldb_StringConvert_h_ -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes namespace lldb_private { diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h index ce95d91497f8..27bf05d2ef48 100644 --- a/include/lldb/Host/Symbols.h +++ b/include/lldb/Host/Symbols.h @@ -1,21 +1,16 @@ //===-- Symbols.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Symbols_h_ #define liblldb_Symbols_h_ -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/FileSpec.h" namespace lldb_private { diff --git a/include/lldb/Host/TaskPool.h b/include/lldb/Host/TaskPool.h index fe1714151076..49805ce193ed 100644 --- a/include/lldb/Host/TaskPool.h +++ b/include/lldb/Host/TaskPool.h @@ -1,9 +1,8 @@ //===--------------------- TaskPool.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,12 +10,12 @@ #define utility_TaskPool_h_ #include "llvm/ADT/STLExtras.h" -#include // for bind, function +#include #include #include -#include // for make_shared -#include // for mutex, unique_lock, condition_variable -#include // for forward, result_of, move +#include +#include +#include namespace lldb_private { diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h index 193b6d21d51e..fc615a9130cc 100644 --- a/include/lldb/Host/Terminal.h +++ b/include/lldb/Host/Terminal.h @@ -1,9 +1,8 @@ //===-- Terminal.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/ThreadLauncher.h b/include/lldb/Host/ThreadLauncher.h index b50f0e2c2c43..0e4498aa3336 100644 --- a/include/lldb/Host/ThreadLauncher.h +++ b/include/lldb/Host/ThreadLauncher.h @@ -1,10 +1,9 @@ //===-- ThreadLauncher.h -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/Time.h b/include/lldb/Host/Time.h index 3be30dd03375..b27eb082167e 100644 --- a/include/lldb/Host/Time.h +++ b/include/lldb/Host/Time.h @@ -1,9 +1,8 @@ //===-- Time.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h index 5088f1f25b0d..e85998727273 100644 --- a/include/lldb/Host/XML.h +++ b/include/lldb/Host/XML.h @@ -1,29 +1,24 @@ //===-- XML.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_XML_h_ #define liblldb_XML_h_ -// C Includes #if defined(LIBXML2_DEFINED) #include #endif -// C++ Includes #include #include #include -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/android/HostInfoAndroid.h b/include/lldb/Host/android/HostInfoAndroid.h index 7a52abe31964..c76412197878 100644 --- a/include/lldb/Host/android/HostInfoAndroid.h +++ b/include/lldb/Host/android/HostInfoAndroid.h @@ -1,9 +1,8 @@ //===-- HostInfoAndroid.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/common/NativeBreakpoint.h b/include/lldb/Host/common/NativeBreakpoint.h deleted file mode 100644 index 681570aadef0..000000000000 --- a/include/lldb/Host/common/NativeBreakpoint.h +++ /dev/null @@ -1,56 +0,0 @@ -//===-- NativeBreakpoint.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_NativeBreakpoint_h_ -#define liblldb_NativeBreakpoint_h_ - -#include "lldb/lldb-types.h" - -namespace lldb_private { -class NativeBreakpointList; - -class NativeBreakpoint { - friend class NativeBreakpointList; - -public: - // The assumption is that derived breakpoints are enabled when created. - NativeBreakpoint(lldb::addr_t addr); - - virtual ~NativeBreakpoint(); - - Status Enable(); - - Status Disable(); - - lldb::addr_t GetAddress() const { return m_addr; } - - bool IsEnabled() const { return m_enabled; } - - virtual bool IsSoftwareBreakpoint() const = 0; - -protected: - const lldb::addr_t m_addr; - int32_t m_ref_count; - - virtual Status DoEnable() = 0; - - virtual Status DoDisable() = 0; - -private: - bool m_enabled; - - // ----------------------------------------------------------- interface for - // NativeBreakpointList - // ----------------------------------------------------------- - void AddRef(); - int32_t DecRef(); -}; -} - -#endif // ifndef liblldb_NativeBreakpoint_h_ diff --git a/include/lldb/Host/common/NativeBreakpointList.h b/include/lldb/Host/common/NativeBreakpointList.h index ffa659fdd869..c2725b2df959 100644 --- a/include/lldb/Host/common/NativeBreakpointList.h +++ b/include/lldb/Host/common/NativeBreakpointList.h @@ -1,22 +1,17 @@ //===-- NativeBreakpointList.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_NativeBreakpointList_h_ #define liblldb_NativeBreakpointList_h_ -#include "lldb/Utility/Status.h" #include "lldb/lldb-private-forward.h" -// #include "lldb/Host/NativeBreakpoint.h" - -#include +#include "lldb/lldb-types.h" #include -#include namespace lldb_private { @@ -26,35 +21,6 @@ struct HardwareBreakpoint { }; using HardwareBreakpointMap = std::map; - -class NativeBreakpointList { -public: - typedef std::function - CreateBreakpointFunc; - - NativeBreakpointList(); - - Status AddRef(lldb::addr_t addr, size_t size_hint, bool hardware, - CreateBreakpointFunc create_func); - - Status DecRef(lldb::addr_t addr); - - Status EnableBreakpoint(lldb::addr_t addr); - - Status DisableBreakpoint(lldb::addr_t addr); - - Status GetBreakpoint(lldb::addr_t addr, NativeBreakpointSP &breakpoint_sp); - - Status RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, size_t size) const; - -private: - typedef std::map BreakpointMap; - - std::recursive_mutex m_mutex; - BreakpointMap m_breakpoints; -}; } #endif // ifndef liblldb_NativeBreakpointList_h_ diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h index d96835d75839..f1bb79147003 100644 --- a/include/lldb/Host/common/NativeProcessProtocol.h +++ b/include/lldb/Host/common/NativeProcessProtocol.h @@ -1,9 +1,8 @@ //===-- NativeProcessProtocol.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,6 +24,8 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" +#include +#include #include namespace lldb_private { @@ -35,8 +36,6 @@ class ResumeActionList; // NativeProcessProtocol //------------------------------------------------------------------ class NativeProcessProtocol { - friend class SoftwareBreakpoint; - public: virtual ~NativeProcessProtocol() {} @@ -84,8 +83,8 @@ class NativeProcessProtocol { virtual Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) = 0; - virtual Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, - size_t size, size_t &bytes_read) = 0; + Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read); virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0; @@ -111,10 +110,6 @@ class NativeProcessProtocol { virtual Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false); - virtual Status EnableBreakpoint(lldb::addr_t addr); - - virtual Status DisableBreakpoint(lldb::addr_t addr); - //---------------------------------------------------------------------- // Hardware Breakpoint functions //---------------------------------------------------------------------- @@ -402,6 +397,13 @@ class NativeProcessProtocol { } protected: + struct SoftwareBreakpoint { + uint32_t ref_count; + llvm::SmallVector saved_opcodes; + llvm::ArrayRef breakpoint_opcodes; + }; + + std::unordered_map m_software_breakpoints; lldb::pid_t m_pid; std::vector> m_threads; @@ -415,7 +417,6 @@ class NativeProcessProtocol { std::recursive_mutex m_delegates_mutex; std::vector m_delegates; - NativeBreakpointList m_breakpoint_list; NativeWatchpointList m_watchpoint_list; HardwareBreakpointMap m_hw_breakpoints_map; int m_terminal_fd; @@ -446,12 +447,23 @@ class NativeProcessProtocol { // ----------------------------------------------------------- Internal // interface for software breakpoints // ----------------------------------------------------------- + Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint); + Status RemoveSoftwareBreakpoint(lldb::addr_t addr); + + virtual llvm::Expected> + GetSoftwareBreakpointTrapOpcode(size_t size_hint); + + /// Return the offset of the PC relative to the software breakpoint that was hit. If an + /// architecture (e.g. arm) reports breakpoint hits before incrementing the PC, this offset + /// will be 0. If an architecture (e.g. intel) reports breakpoints hits after incrementing the + /// PC, this offset will be the size of the breakpoint opcode. + virtual size_t GetSoftwareBreakpointPCOffset(); - virtual Status - GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, - size_t &actual_opcode_size, - const uint8_t *&trap_opcode_bytes) = 0; + // Adjust the thread's PC after hitting a software breakpoint. On + // architectures where the PC points after the breakpoint instruction, this + // resets it to point to the breakpoint itself. + void FixupBreakpointPCAsNeeded(NativeThreadProtocol &thread); // ----------------------------------------------------------- /// Notify the delegate that an exec occurred. @@ -465,6 +477,8 @@ class NativeProcessProtocol { private: void SynchronouslyNotifyProcessStateChanged(lldb::StateType state); + llvm::Expected + EnableSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint); }; } // namespace lldb_private diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h index 26458db153c1..8e175fd0dcff 100644 --- a/include/lldb/Host/common/NativeRegisterContext.h +++ b/include/lldb/Host/common/NativeRegisterContext.h @@ -1,19 +1,14 @@ //===-- NativeRegisterContext.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_NativeRegisterContext_h_ #define liblldb_NativeRegisterContext_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/common/NativeWatchpointList.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/common/NativeThreadProtocol.h b/include/lldb/Host/common/NativeThreadProtocol.h index 6f4452c688e7..02c9ceec2260 100644 --- a/include/lldb/Host/common/NativeThreadProtocol.h +++ b/include/lldb/Host/common/NativeThreadProtocol.h @@ -1,9 +1,8 @@ //===-- NativeThreadProtocol.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/common/NativeWatchpointList.h b/include/lldb/Host/common/NativeWatchpointList.h index 02920e6faacb..c83ba1eaadca 100644 --- a/include/lldb/Host/common/NativeWatchpointList.h +++ b/include/lldb/Host/common/NativeWatchpointList.h @@ -1,9 +1,8 @@ //===-- NativeWatchpointList.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/common/SoftwareBreakpoint.h b/include/lldb/Host/common/SoftwareBreakpoint.h deleted file mode 100644 index e0f235fecd93..000000000000 --- a/include/lldb/Host/common/SoftwareBreakpoint.h +++ /dev/null @@ -1,53 +0,0 @@ -//===-- SoftwareBreakpoint.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_SoftwareBreakpoint_h_ -#define liblldb_SoftwareBreakpoint_h_ - -#include "NativeBreakpoint.h" -#include "lldb/lldb-private-forward.h" - -namespace lldb_private { -class SoftwareBreakpoint : public NativeBreakpoint { - friend class NativeBreakpointList; - -public: - static Status CreateSoftwareBreakpoint(NativeProcessProtocol &process, - lldb::addr_t addr, size_t size_hint, - NativeBreakpointSP &breakpoint_spn); - - SoftwareBreakpoint(NativeProcessProtocol &process, lldb::addr_t addr, - const uint8_t *saved_opcodes, const uint8_t *trap_opcodes, - size_t opcode_size); - -protected: - Status DoEnable() override; - - Status DoDisable() override; - - bool IsSoftwareBreakpoint() const override; - -private: - /// Max number of bytes that a software trap opcode sequence can occupy. - static const size_t MAX_TRAP_OPCODE_SIZE = 8; - - NativeProcessProtocol &m_process; - uint8_t m_saved_opcodes[MAX_TRAP_OPCODE_SIZE]; - uint8_t m_trap_opcodes[MAX_TRAP_OPCODE_SIZE]; - const size_t m_opcode_size; - - static Status EnableSoftwareBreakpoint(NativeProcessProtocol &process, - lldb::addr_t addr, - size_t bp_opcode_size, - const uint8_t *bp_opcode_bytes, - uint8_t *saved_opcode_bytes); -}; -} - -#endif // #ifndef liblldb_SoftwareBreakpoint_h_ diff --git a/include/lldb/Host/common/TCPSocket.h b/include/lldb/Host/common/TCPSocket.h index 0d32a70fd381..526c39b3f361 100644 --- a/include/lldb/Host/common/TCPSocket.h +++ b/include/lldb/Host/common/TCPSocket.h @@ -1,9 +1,8 @@ //===-- TCPSocket.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h index 27b2d1dc9834..8ab6783da169 100644 --- a/include/lldb/Host/common/UDPSocket.h +++ b/include/lldb/Host/common/UDPSocket.h @@ -1,9 +1,8 @@ //===-- UDPSocket.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/freebsd/HostInfoFreeBSD.h b/include/lldb/Host/freebsd/HostInfoFreeBSD.h index 5b3a18d21079..56f20bbd23d3 100644 --- a/include/lldb/Host/freebsd/HostInfoFreeBSD.h +++ b/include/lldb/Host/freebsd/HostInfoFreeBSD.h @@ -1,9 +1,8 @@ //===-- HostInfoFreeBSD.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/linux/AbstractSocket.h b/include/lldb/Host/linux/AbstractSocket.h index 3b38cde05522..78a567a6b909 100644 --- a/include/lldb/Host/linux/AbstractSocket.h +++ b/include/lldb/Host/linux/AbstractSocket.h @@ -1,9 +1,8 @@ //===-- AbstractSocket.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/linux/HostInfoLinux.h b/include/lldb/Host/linux/HostInfoLinux.h index 820d3bd17a2e..b1c7f9c805bf 100644 --- a/include/lldb/Host/linux/HostInfoLinux.h +++ b/include/lldb/Host/linux/HostInfoLinux.h @@ -1,9 +1,8 @@ //===-- HostInfoLinux.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/linux/Ptrace.h b/include/lldb/Host/linux/Ptrace.h index 1b753c284967..c54b75f07112 100644 --- a/include/lldb/Host/linux/Ptrace.h +++ b/include/lldb/Host/linux/Ptrace.h @@ -1,9 +1,8 @@ //===-- Ptrace.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/linux/Support.h b/include/lldb/Host/linux/Support.h index 8415aa6c4320..d1eb7f83d491 100644 --- a/include/lldb/Host/linux/Support.h +++ b/include/lldb/Host/linux/Support.h @@ -1,9 +1,8 @@ //===-- Support.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/linux/Uio.h b/include/lldb/Host/linux/Uio.h index 0b8b7dbf6fb9..460bd6c84ca3 100644 --- a/include/lldb/Host/linux/Uio.h +++ b/include/lldb/Host/linux/Uio.h @@ -1,9 +1,8 @@ //===-- Uio.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/macosx/HostInfoMacOSX.h b/include/lldb/Host/macosx/HostInfoMacOSX.h index 926f8bb3b112..70f2a74de236 100644 --- a/include/lldb/Host/macosx/HostInfoMacOSX.h +++ b/include/lldb/Host/macosx/HostInfoMacOSX.h @@ -1,9 +1,8 @@ //===-- HostInfoMacOSX.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/macosx/HostThreadMacOSX.h b/include/lldb/Host/macosx/HostThreadMacOSX.h index 16b9a6d6986e..4247de6da128 100644 --- a/include/lldb/Host/macosx/HostThreadMacOSX.h +++ b/include/lldb/Host/macosx/HostThreadMacOSX.h @@ -1,9 +1,8 @@ //===-- HostThreadMacOSX.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h index 0d4de79d03b1..f9ad66eb2b2a 100644 --- a/include/lldb/Host/netbsd/HostInfoNetBSD.h +++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h @@ -1,9 +1,8 @@ //===-- HostInfoNetBSD.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/openbsd/HostInfoOpenBSD.h b/include/lldb/Host/openbsd/HostInfoOpenBSD.h index 5a0388ffdd97..7ec1d5fc3606 100644 --- a/include/lldb/Host/openbsd/HostInfoOpenBSD.h +++ b/include/lldb/Host/openbsd/HostInfoOpenBSD.h @@ -1,9 +1,8 @@ //===-- HostInfoOpenBSD.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,12 +11,13 @@ #include "lldb/Host/posix/HostInfoPosix.h" #include "lldb/Utility/FileSpec.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { class HostInfoOpenBSD : public HostInfoPosix { public: - static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static llvm::VersionTuple GetOSVersion(); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); static FileSpec GetProgramFileSpec(); diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h index 0d125ca2c813..b25fc47c56b6 100644 --- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -1,28 +1,24 @@ //===-- ConnectionFileDescriptorPosix.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Host_posix_ConnectionFileDescriptorPosix_h_ #define liblldb_Host_posix_ConnectionFileDescriptorPosix_h_ -// C++ Includes #include #include #include #include "lldb/lldb-forward.h" -// Other libraries and framework includes -// Project includes #include "lldb/Host/Pipe.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/Connection.h" #include "lldb/Utility/IOObject.h" +#include "lldb/Utility/Predicate.h" namespace lldb_private { diff --git a/include/lldb/Host/posix/DomainSocket.h b/include/lldb/Host/posix/DomainSocket.h index e66b3f971faf..87db2dbddeac 100644 --- a/include/lldb/Host/posix/DomainSocket.h +++ b/include/lldb/Host/posix/DomainSocket.h @@ -1,9 +1,8 @@ //===-- DomainSocket.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/Fcntl.h b/include/lldb/Host/posix/Fcntl.h index 833a90584141..31cc293dd37a 100644 --- a/include/lldb/Host/posix/Fcntl.h +++ b/include/lldb/Host/posix/Fcntl.h @@ -1,9 +1,8 @@ //===-- Fcntl.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h index 1a2a29ec86a3..6987801b66c7 100644 --- a/include/lldb/Host/posix/HostInfoPosix.h +++ b/include/lldb/Host/posix/HostInfoPosix.h @@ -1,9 +1,8 @@ //===-- HostInfoPosix.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h index 0a6d8822d44f..ce0b8e8b176a 100644 --- a/include/lldb/Host/posix/HostProcessPosix.h +++ b/include/lldb/Host/posix/HostProcessPosix.h @@ -1,19 +1,14 @@ //===-- HostProcessPosix.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_Host_HostProcesPosix_h_ #define lldb_Host_HostProcesPosix_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/HostNativeProcessBase.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Host/posix/HostThreadPosix.h b/include/lldb/Host/posix/HostThreadPosix.h index c230a61bc575..54012e15ad99 100644 --- a/include/lldb/Host/posix/HostThreadPosix.h +++ b/include/lldb/Host/posix/HostThreadPosix.h @@ -1,9 +1,8 @@ //===-- HostThreadPosix.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/LockFilePosix.h b/include/lldb/Host/posix/LockFilePosix.h index a59a7fe3e729..63333bff4cd3 100644 --- a/include/lldb/Host/posix/LockFilePosix.h +++ b/include/lldb/Host/posix/LockFilePosix.h @@ -1,9 +1,8 @@ //===-- LockFilePosix.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h index bb65a56abd00..8da34330106c 100644 --- a/include/lldb/Host/posix/PipePosix.h +++ b/include/lldb/Host/posix/PipePosix.h @@ -1,9 +1,8 @@ //===-- PipePosix.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -27,7 +26,7 @@ class PipePosix : public PipeBase { static int kInvalidDescriptor; PipePosix(); - PipePosix(int read_fd, int write_fd); + PipePosix(lldb::pipe_t read, lldb::pipe_t write); PipePosix(const PipePosix &) = delete; PipePosix(PipePosix &&pipe_posix); PipePosix &operator=(const PipePosix &) = delete; @@ -49,6 +48,13 @@ class PipePosix : public PipeBase { bool CanRead() const override; bool CanWrite() const override; + lldb::pipe_t GetReadPipe() const override { + return lldb::pipe_t(GetReadFileDescriptor()); + } + lldb::pipe_t GetWritePipe() const override { + return lldb::pipe_t(GetWriteFileDescriptor()); + } + int GetReadFileDescriptor() const override; int GetWriteFileDescriptor() const override; int ReleaseReadFileDescriptor() override; diff --git a/include/lldb/Host/posix/ProcessLauncherPosixFork.h b/include/lldb/Host/posix/ProcessLauncherPosixFork.h index 1193a20b4d36..15e2d6d23b8e 100644 --- a/include/lldb/Host/posix/ProcessLauncherPosixFork.h +++ b/include/lldb/Host/posix/ProcessLauncherPosixFork.h @@ -1,9 +1,8 @@ //===-- ProcessLauncherPosixFork.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/AutoHandle.h b/include/lldb/Host/windows/AutoHandle.h index 8c8c89767ba9..5c0de8950ce4 100644 --- a/include/lldb/Host/windows/AutoHandle.h +++ b/include/lldb/Host/windows/AutoHandle.h @@ -1,9 +1,8 @@ //===-- AutoHandle.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/ConnectionGenericFileWindows.h b/include/lldb/Host/windows/ConnectionGenericFileWindows.h index 5907ff16d9c3..8856708df944 100644 --- a/include/lldb/Host/windows/ConnectionGenericFileWindows.h +++ b/include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -1,9 +1,8 @@ //===-- ConnectionGenericFileWindows.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/HostInfoWindows.h b/include/lldb/Host/windows/HostInfoWindows.h index 24949e6001f7..3f0810527dc1 100644 --- a/include/lldb/Host/windows/HostInfoWindows.h +++ b/include/lldb/Host/windows/HostInfoWindows.h @@ -1,9 +1,8 @@ //===-- HostInfoWindows.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/HostProcessWindows.h b/include/lldb/Host/windows/HostProcessWindows.h index 4ef35337d70f..4178956f5617 100644 --- a/include/lldb/Host/windows/HostProcessWindows.h +++ b/include/lldb/Host/windows/HostProcessWindows.h @@ -1,9 +1,8 @@ //===-- HostProcessWindows.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/HostThreadWindows.h b/include/lldb/Host/windows/HostThreadWindows.h index 35d83c0ba2b2..be3f7fe13d64 100644 --- a/include/lldb/Host/windows/HostThreadWindows.h +++ b/include/lldb/Host/windows/HostThreadWindows.h @@ -1,9 +1,8 @@ //===-- HostThreadWindows.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -29,6 +28,7 @@ class HostThreadWindows : public HostNativeThreadBase { virtual Status Join(lldb::thread_result_t *result); virtual Status Cancel(); virtual void Reset(); + virtual bool EqualsThread(lldb::thread_t thread) const; lldb::tid_t GetThreadId() const; diff --git a/include/lldb/Host/windows/LockFileWindows.h b/include/lldb/Host/windows/LockFileWindows.h index 10456a1b8b25..0312d14baa11 100644 --- a/include/lldb/Host/windows/LockFileWindows.h +++ b/include/lldb/Host/windows/LockFileWindows.h @@ -1,9 +1,8 @@ //===-- LockFileWindows.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/PipeWindows.h b/include/lldb/Host/windows/PipeWindows.h index e309c421a71c..e5281d4d5edf 100644 --- a/include/lldb/Host/windows/PipeWindows.h +++ b/include/lldb/Host/windows/PipeWindows.h @@ -1,9 +1,8 @@ //===-- PipePosix.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -23,11 +22,19 @@ namespace lldb_private { /// A class that abstracts the LLDB core from host pipe functionality. //---------------------------------------------------------------------- class PipeWindows : public PipeBase { +public: + static const int kInvalidDescriptor = -1; + public: PipeWindows(); + PipeWindows(lldb::pipe_t read, lldb::pipe_t write); ~PipeWindows() override; + // Create an unnamed pipe. Status CreateNew(bool child_process_inherit) override; + + // Create a named pipe. + Status CreateNewNamed(bool child_process_inherit); Status CreateNew(llvm::StringRef name, bool child_process_inherit) override; Status CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, @@ -41,6 +48,9 @@ class PipeWindows : public PipeBase { bool CanRead() const override; bool CanWrite() const override; + lldb::pipe_t GetReadPipe() const { return lldb::pipe_t(m_read); } + lldb::pipe_t GetWritePipe() const { return lldb::pipe_t(m_write); } + int GetReadFileDescriptor() const override; int GetWriteFileDescriptor() const override; int ReleaseReadFileDescriptor() override; diff --git a/include/lldb/Host/windows/PosixApi.h b/include/lldb/Host/windows/PosixApi.h index 801107dadceb..977dd76b018e 100644 --- a/include/lldb/Host/windows/PosixApi.h +++ b/include/lldb/Host/windows/PosixApi.h @@ -1,9 +1,8 @@ //===-- windows/PosixApi.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/ProcessLauncherWindows.h b/include/lldb/Host/windows/ProcessLauncherWindows.h index 1df377d5eb88..e765f1e9ed54 100644 --- a/include/lldb/Host/windows/ProcessLauncherWindows.h +++ b/include/lldb/Host/windows/ProcessLauncherWindows.h @@ -1,9 +1,8 @@ //===-- ProcessLauncherWindows.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Host/windows/editlinewin.h b/include/lldb/Host/windows/editlinewin.h index 4522f0dd41b0..049938956c73 100644 --- a/include/lldb/Host/windows/editlinewin.h +++ b/include/lldb/Host/windows/editlinewin.h @@ -1,9 +1,8 @@ //===-- ELWrapper.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -113,4 +112,4 @@ void el_deletestr(EditLine *, int); History *history_init(void); void history_end(History *); int history(History *, HistEvent *, int, ...); -}; \ No newline at end of file +}; diff --git a/include/lldb/Host/windows/windows.h b/include/lldb/Host/windows/windows.h index 98a675eed4fe..908d970c635c 100644 --- a/include/lldb/Host/windows/windows.h +++ b/include/lldb/Host/windows/windows.h @@ -1,9 +1,8 @@ //===-- lldb-windows.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Initialization/SystemInitializer.h b/include/lldb/Initialization/SystemInitializer.h index 58bbb44b1f34..ec699bd65ce1 100644 --- a/include/lldb/Initialization/SystemInitializer.h +++ b/include/lldb/Initialization/SystemInitializer.h @@ -1,22 +1,32 @@ //===-- SystemInitializer.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H #define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H +#include "llvm/Support/Error.h" + +#include + namespace lldb_private { + +struct InitializerOptions { + bool reproducer_capture = false; + bool reproducer_replay = false; + std::string reproducer_path; +}; + class SystemInitializer { public: SystemInitializer(); virtual ~SystemInitializer(); - virtual void Initialize() = 0; + virtual llvm::Error Initialize(const InitializerOptions &options) = 0; virtual void Terminate() = 0; }; } diff --git a/include/lldb/Initialization/SystemInitializerCommon.h b/include/lldb/Initialization/SystemInitializerCommon.h index 2a9851c6a34c..785ae0459e0b 100644 --- a/include/lldb/Initialization/SystemInitializerCommon.h +++ b/include/lldb/Initialization/SystemInitializerCommon.h @@ -1,9 +1,8 @@ //===-- SystemInitializerCommon.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -28,7 +27,7 @@ class SystemInitializerCommon : public SystemInitializer { SystemInitializerCommon(); ~SystemInitializerCommon() override; - void Initialize() override; + llvm::Error Initialize(const InitializerOptions &options) override; void Terminate() override; }; diff --git a/include/lldb/Initialization/SystemLifetimeManager.h b/include/lldb/Initialization/SystemLifetimeManager.h index 0ebd4a50a342..b176d394b43e 100644 --- a/include/lldb/Initialization/SystemLifetimeManager.h +++ b/include/lldb/Initialization/SystemLifetimeManager.h @@ -1,30 +1,31 @@ //===-- SystemLifetimeManager.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H #define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H +#include "lldb/Initialization/SystemInitializer.h" #include "lldb/lldb-private-types.h" +#include "llvm/Support/Error.h" #include #include namespace lldb_private { -class SystemInitializer; class SystemLifetimeManager { public: SystemLifetimeManager(); ~SystemLifetimeManager(); - void Initialize(std::unique_ptr initializer, - LoadPluginCallbackType plugin_callback); + llvm::Error Initialize(std::unique_ptr initializer, + const InitializerOptions &options, + LoadPluginCallbackType plugin_callback); void Terminate(); private: diff --git a/include/lldb/Interpreter/CommandAlias.h b/include/lldb/Interpreter/CommandAlias.h index 01522bd6ecea..c2a7a383f35a 100644 --- a/include/lldb/Interpreter/CommandAlias.h +++ b/include/lldb/Interpreter/CommandAlias.h @@ -1,21 +1,16 @@ //===-- CommandAlias.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandAlias_h_ #define liblldb_CommandAlias_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/CompletionRequest.h" diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h index 15e7525fdcd3..092e36eee681 100644 --- a/include/lldb/Interpreter/CommandCompletions.h +++ b/include/lldb/Interpreter/CommandCompletions.h @@ -1,21 +1,16 @@ //===-- CommandCompletions.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_CommandCompletions_h_ #define lldb_CommandCompletions_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Utility/CompletionRequest.h" diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h index faef220bbe94..c1386f84fe2e 100644 --- a/include/lldb/Interpreter/CommandHistory.h +++ b/include/lldb/Interpreter/CommandHistory.h @@ -1,23 +1,18 @@ //===-- CommandHistory.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandHistory_h_ #define liblldb_CommandHistory_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Stream.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index 73aa520dc528..49c5415ac440 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -1,34 +1,29 @@ //===-- CommandInterpreter.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandInterpreter_h_ #define liblldb_CommandInterpreter_h_ -// C Includes -// C++ Includes -#include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Event.h" #include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/CommandAlias.h" #include "lldb/Interpreter/CommandHistory.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include namespace lldb_private { @@ -220,7 +215,8 @@ class CommandInterpreter : public Broadcaster, bool include_aliases) const; CommandObject *GetCommandObject(llvm::StringRef cmd, - StringList *matches = nullptr) const; + StringList *matches = nullptr, + StringList *descriptions = nullptr) const; bool CommandExists(llvm::StringRef cmd) const; @@ -324,7 +320,8 @@ class CommandInterpreter : public Broadcaster, // FIXME: Only max_return_elements == -1 is supported at present. int HandleCompletion(const char *current_line, const char *cursor, const char *last_char, int match_start_point, - int max_return_elements, StringList &matches); + int max_return_elements, StringList &matches, + StringList &descriptions); // This version just returns matches, and doesn't compute the substring. It // is here so the Help command can call it for the first argument. It uses @@ -333,7 +330,8 @@ class CommandInterpreter : public Broadcaster, int GetCommandNamesMatchingPartialString(const char *cmd_cstr, bool include_aliases, - StringList &matches); + StringList &matches, + StringList &descriptions); void GetHelp(CommandReturnObject &result, uint32_t types = eCommandTypesAllThem); @@ -540,7 +538,8 @@ class CommandInterpreter : public Broadcaster, lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd, bool include_aliases = true, bool exact = true, - StringList *matches = nullptr) const; + StringList *matches = nullptr, + StringList *descriptions = nullptr) const; private: Status PreprocessCommand(std::string &command); diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index 7afb18b2f598..0bb39c6bb9bb 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -1,23 +1,18 @@ //===-- CommandObject.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObject_h_ #define liblldb_CommandObject_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" #include "lldb/Interpreter/CommandCompletions.h" @@ -37,8 +32,9 @@ namespace lldb_private { // number added. template -int AddNamesMatchingPartialString(const std::map &in_map, - llvm::StringRef cmd_str, StringList &matches) { +int AddNamesMatchingPartialString( + const std::map &in_map, llvm::StringRef cmd_str, + StringList &matches, StringList *descriptions = nullptr) { int number_added = 0; const bool add_all = cmd_str.empty(); @@ -47,6 +43,8 @@ int AddNamesMatchingPartialString(const std::map &in_map if (add_all || (iter->first.find(cmd_str, 0) == 0)) { ++number_added; matches.AppendString(iter->first.c_str()); + if (descriptions) + descriptions->AppendString(iter->second->GetHelp()); } } diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h index d9eff9a6e545..49da49e9104d 100644 --- a/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/include/lldb/Interpreter/CommandObjectMultiword.h @@ -1,19 +1,14 @@ //===-- CommandObjectMultiword.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectMultiword_h_ #define liblldb_CommandObjectMultiword_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/CompletionRequest.h" diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h index 36c3f068bdf3..b4acf71a965e 100644 --- a/include/lldb/Interpreter/CommandObjectRegexCommand.h +++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h @@ -1,21 +1,16 @@ //===-- CommandObjectRegexCommand.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectRegexCommand_h_ #define liblldb_CommandObjectRegexCommand_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/RegularExpression.h" diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h index 05724cace172..5483c1509556 100644 --- a/include/lldb/Interpreter/CommandOptionValidators.h +++ b/include/lldb/Interpreter/CommandOptionValidators.h @@ -1,19 +1,14 @@ //===-- CommandOptionValidators.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandOptionValidators_h_ #define liblldb_CommandOptionValidators_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private-types.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h index 7b04c391bc76..a5f61261455e 100644 --- a/include/lldb/Interpreter/CommandReturnObject.h +++ b/include/lldb/Interpreter/CommandReturnObject.h @@ -1,19 +1,14 @@ //===-- CommandReturnObject.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandReturnObject_h_ #define liblldb_CommandReturnObject_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/STLUtils.h" #include "lldb/Core/StreamFile.h" #include "lldb/Utility/StreamString.h" diff --git a/include/lldb/Interpreter/OptionArgParser.h b/include/lldb/Interpreter/OptionArgParser.h index b5a083929067..ce901b0483b4 100644 --- a/include/lldb/Interpreter/OptionArgParser.h +++ b/include/lldb/Interpreter/OptionArgParser.h @@ -1,9 +1,8 @@ //===-- OptionArgParser.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionGroupArchitecture.h b/include/lldb/Interpreter/OptionGroupArchitecture.h index 2cecaa65a0fd..c82daecd096c 100644 --- a/include/lldb/Interpreter/OptionGroupArchitecture.h +++ b/include/lldb/Interpreter/OptionGroupArchitecture.h @@ -1,9 +1,8 @@ //===-- OptionGroupArchitecture.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h index 2489a648dd7e..3d478bfc73e9 100644 --- a/include/lldb/Interpreter/OptionGroupBoolean.h +++ b/include/lldb/Interpreter/OptionGroupBoolean.h @@ -1,19 +1,14 @@ //===-- OptionGroupBoolean.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupBoolean_h_ #define liblldb_OptionGroupBoolean_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupFile.h b/include/lldb/Interpreter/OptionGroupFile.h index d0c25b8bf8e6..4c5a28819641 100644 --- a/include/lldb/Interpreter/OptionGroupFile.h +++ b/include/lldb/Interpreter/OptionGroupFile.h @@ -1,19 +1,14 @@ //===-- OptionGroupFile.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupFile_h_ #define liblldb_OptionGroupFile_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupFormat.h b/include/lldb/Interpreter/OptionGroupFormat.h index ddf2ccece3bd..222a798132a3 100644 --- a/include/lldb/Interpreter/OptionGroupFormat.h +++ b/include/lldb/Interpreter/OptionGroupFormat.h @@ -1,19 +1,14 @@ //===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupFormat_h_ #define liblldb_OptionGroupFormat_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueFormat.h" #include "lldb/Interpreter/OptionValueSInt64.h" #include "lldb/Interpreter/OptionValueUInt64.h" diff --git a/include/lldb/Interpreter/OptionGroupOutputFile.h b/include/lldb/Interpreter/OptionGroupOutputFile.h index 19453c6215ef..3bb9b0e56dd6 100644 --- a/include/lldb/Interpreter/OptionGroupOutputFile.h +++ b/include/lldb/Interpreter/OptionGroupOutputFile.h @@ -1,19 +1,14 @@ //===-- OptionGroupOutputFile.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupOutputFile_h_ #define liblldb_OptionGroupOutputFile_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h index cda4246f1b01..8ba6ac97eaa1 100644 --- a/include/lldb/Interpreter/OptionGroupPlatform.h +++ b/include/lldb/Interpreter/OptionGroupPlatform.h @@ -1,19 +1,14 @@ //===-- OptionGroupPlatform.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupPlatform_h_ #define liblldb_OptionGroupPlatform_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ConstString.h" #include "llvm/Support/VersionTuple.h" diff --git a/include/lldb/Interpreter/OptionGroupString.h b/include/lldb/Interpreter/OptionGroupString.h index 01e8aa9dc3b6..ad3e7241aec5 100644 --- a/include/lldb/Interpreter/OptionGroupString.h +++ b/include/lldb/Interpreter/OptionGroupString.h @@ -1,19 +1,14 @@ //===-- OptionGroupString.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupString_h_ #define liblldb_OptionGroupString_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupUInt64.h b/include/lldb/Interpreter/OptionGroupUInt64.h index 82eb0e26af9b..1b2e9f09b57a 100644 --- a/include/lldb/Interpreter/OptionGroupUInt64.h +++ b/include/lldb/Interpreter/OptionGroupUInt64.h @@ -1,19 +1,14 @@ //===-- OptionGroupUInt64.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupUInt64_h_ #define liblldb_OptionGroupUInt64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupUUID.h b/include/lldb/Interpreter/OptionGroupUUID.h index def97d5f2551..0a3d5203a885 100644 --- a/include/lldb/Interpreter/OptionGroupUUID.h +++ b/include/lldb/Interpreter/OptionGroupUUID.h @@ -1,19 +1,14 @@ //===-- OptionGroupUUID.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupUUID_h_ #define liblldb_OptionGroupUUID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueUUID.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index 0e075773b3f7..0ae9d9de5266 100644 --- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -1,19 +1,14 @@ //===-- OptionGroupValueObjectDisplay.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupValueObjectDisplay_h_ #define liblldb_OptionGroupValueObjectDisplay_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupVariable.h b/include/lldb/Interpreter/OptionGroupVariable.h index f5902c51d8a0..b14ac7ab12b1 100644 --- a/include/lldb/Interpreter/OptionGroupVariable.h +++ b/include/lldb/Interpreter/OptionGroupVariable.h @@ -1,19 +1,14 @@ //===-- OptionGroupVariable.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupVariable_h_ #define liblldb_OptionGroupVariable_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h index f2665638ba85..f424e15f6829 100644 --- a/include/lldb/Interpreter/OptionGroupWatchpoint.h +++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h @@ -1,19 +1,14 @@ //===-- OptionGroupWatchpoint.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionGroupWatchpoint_h_ #define liblldb_OptionGroupWatchpoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/Options.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h index 4748e309c77e..3e4b6e6489dd 100644 --- a/include/lldb/Interpreter/OptionValue.h +++ b/include/lldb/Interpreter/OptionValue.h @@ -1,19 +1,14 @@ //===-- OptionValue.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValue_h_ #define liblldb_OptionValue_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/FormatEntity.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" @@ -58,9 +53,11 @@ class OptionValue { eDumpOptionValue = (1u << 2), eDumpOptionDescription = (1u << 3), eDumpOptionRaw = (1u << 4), + eDumpOptionCommand = (1u << 5), eDumpGroupValue = (eDumpOptionName | eDumpOptionType | eDumpOptionValue), eDumpGroupHelp = - (eDumpOptionName | eDumpOptionType | eDumpOptionDescription) + (eDumpOptionName | eDumpOptionType | eDumpOptionDescription), + eDumpGroupExport = (eDumpOptionCommand | eDumpOptionName | eDumpOptionValue) }; OptionValue() diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h index 15b74ad17893..39951ed695f4 100644 --- a/include/lldb/Interpreter/OptionValueArch.h +++ b/include/lldb/Interpreter/OptionValueArch.h @@ -1,9 +1,8 @@ //===-- OptionValueArch.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionValueArgs.h b/include/lldb/Interpreter/OptionValueArgs.h index 433679da134e..0254b9aa7e14 100644 --- a/include/lldb/Interpreter/OptionValueArgs.h +++ b/include/lldb/Interpreter/OptionValueArgs.h @@ -1,19 +1,14 @@ //===-- OptionValueArgs.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueArgs_h_ #define liblldb_OptionValueArgs_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueArray.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h index 44709d00763f..d7871cab4450 100644 --- a/include/lldb/Interpreter/OptionValueArray.h +++ b/include/lldb/Interpreter/OptionValueArray.h @@ -1,21 +1,16 @@ //===-- OptionValueArray.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueArray_h_ #define liblldb_OptionValueArray_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index 6d2a16e59597..5e3dd34ee429 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -1,19 +1,14 @@ //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueBoolean_h_ #define liblldb_OptionValueBoolean_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h index 0c5f602efe9b..21b309220aba 100644 --- a/include/lldb/Interpreter/OptionValueChar.h +++ b/include/lldb/Interpreter/OptionValueChar.h @@ -1,19 +1,14 @@ //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueChar_h_ #define liblldb_OptionValueChar_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h index 4e8c86008ea4..80e5a43ed2db 100644 --- a/include/lldb/Interpreter/OptionValueDictionary.h +++ b/include/lldb/Interpreter/OptionValueDictionary.h @@ -1,21 +1,16 @@ //===-- OptionValueDictionary.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueDictionary_h_ #define liblldb_OptionValueDictionary_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 16c09c589a27..3bf56b6b0e79 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -1,9 +1,8 @@ //===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h index 41a479e2fc9e..ca3584db7154 100644 --- a/include/lldb/Interpreter/OptionValueFileSpec.h +++ b/include/lldb/Interpreter/OptionValueFileSpec.h @@ -1,9 +1,8 @@ //===-- OptionValueFileSpec.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h index 9529fbcf38bc..84f7a4f228cd 100644 --- a/include/lldb/Interpreter/OptionValueFileSpecList.h +++ b/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -1,19 +1,14 @@ //===-- OptionValueFileSpecList.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueFileSpecList_h_ #define liblldb_OptionValueFileSpecList_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h index ce7997024b09..9241abacebe5 100644 --- a/include/lldb/Interpreter/OptionValueFormat.h +++ b/include/lldb/Interpreter/OptionValueFormat.h @@ -1,19 +1,14 @@ //===-- OptionValueFormat.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueFormat_h_ #define liblldb_OptionValueFormat_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h index 880e434dc5c0..7338d6168ff9 100644 --- a/include/lldb/Interpreter/OptionValueFormatEntity.h +++ b/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -1,19 +1,14 @@ //===-- OptionValueFormatEntity.h --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueFormatEntity_h_ #define liblldb_OptionValueFormatEntity_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/FormatEntity.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h index 8f81c5df0739..cfac304dbe90 100644 --- a/include/lldb/Interpreter/OptionValueLanguage.h +++ b/include/lldb/Interpreter/OptionValueLanguage.h @@ -1,20 +1,15 @@ //===-- OptionValueLanguage.h -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueLanguage_h_ #define liblldb_OptionValueLanguage_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" #include "lldb/lldb-enumerations.h" diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h index 0e2e98d74b74..6d3cbdb74b7e 100644 --- a/include/lldb/Interpreter/OptionValuePathMappings.h +++ b/include/lldb/Interpreter/OptionValuePathMappings.h @@ -1,19 +1,14 @@ //===-- OptionValuePathMappings.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValuePathMappings_h_ #define liblldb_OptionValuePathMappings_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" #include "lldb/Target/PathMappingList.h" diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h index 10e0cd39dff1..01cec2abf443 100644 --- a/include/lldb/Interpreter/OptionValueProperties.h +++ b/include/lldb/Interpreter/OptionValueProperties.h @@ -1,21 +1,16 @@ //===-- OptionValueProperties.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueProperties_h_ #define liblldb_OptionValueProperties_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/FormatEntity.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h index afe9318ae014..925ef39e71c9 100644 --- a/include/lldb/Interpreter/OptionValueRegex.h +++ b/include/lldb/Interpreter/OptionValueRegex.h @@ -1,19 +1,14 @@ //===-- OptionValueRegex.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueRegex_h_ #define liblldb_OptionValueRegex_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/RegularExpression.h" diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h index a6893d23e692..1ca004283b00 100644 --- a/include/lldb/Interpreter/OptionValueSInt64.h +++ b/include/lldb/Interpreter/OptionValueSInt64.h @@ -1,20 +1,15 @@ //===-- OptionValueSInt64.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueSInt64_h_ #define liblldb_OptionValueSInt64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h index 4a9f2227680e..db619ca974f7 100644 --- a/include/lldb/Interpreter/OptionValueString.h +++ b/include/lldb/Interpreter/OptionValueString.h @@ -1,21 +1,16 @@ //===-- OptionValueString.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueString_h_ #define liblldb_OptionValueString_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h index 96404bed8e67..8d65dbaec3a5 100644 --- a/include/lldb/Interpreter/OptionValueUInt64.h +++ b/include/lldb/Interpreter/OptionValueUInt64.h @@ -1,20 +1,15 @@ //===-- OptionValueUInt64.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueUInt64_h_ #define liblldb_OptionValueUInt64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h index 950efb518d5a..68332bbb4ccf 100644 --- a/include/lldb/Interpreter/OptionValueUUID.h +++ b/include/lldb/Interpreter/OptionValueUUID.h @@ -1,19 +1,14 @@ //===-- OptionValueUUID.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OptionValueUUID_h_ #define liblldb_OptionValueUUID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/UUID.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValues.h b/include/lldb/Interpreter/OptionValues.h index e177d743ff18..d90b2867a4b0 100644 --- a/include/lldb/Interpreter/OptionValues.h +++ b/include/lldb/Interpreter/OptionValues.h @@ -1,9 +1,8 @@ //===-- OptionValues.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index 316bf568fd92..f04a3956bcb8 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -1,22 +1,17 @@ //===-- Options.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Options_h_ #define liblldb_Options_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Args.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Status.h" diff --git a/include/lldb/Interpreter/Property.h b/include/lldb/Interpreter/Property.h index a7515e9903a4..14793b3bd34e 100644 --- a/include/lldb/Interpreter/Property.h +++ b/include/lldb/Interpreter/Property.h @@ -1,9 +1,8 @@ //===-- Property.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index a1b5180c3e30..24188a7edf28 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -1,25 +1,20 @@ //===-- ScriptInterpreter.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ScriptInterpreter_h_ #define liblldb_ScriptInterpreter_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/BreakpointOptions.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h index 422408b034c6..0973bd0eaa87 100644 --- a/include/lldb/Symbol/ArmUnwindInfo.h +++ b/include/lldb/Symbol/ArmUnwindInfo.h @@ -1,9 +1,8 @@ //===-- ArmUnwindInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index 36904e535b64..c4a8fdf4d0f8 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -1,21 +1,16 @@ //===-- Block.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Block_h_ #define liblldb_Block_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Core/RangeMap.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h index c7c0f08bf6ce..257b69cf055b 100644 --- a/include/lldb/Symbol/ClangASTContext.h +++ b/include/lldb/Symbol/ClangASTContext.h @@ -1,19 +1,16 @@ //===-- ClangASTContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangASTContext_h_ #define liblldb_ClangASTContext_h_ -// C Includes #include -// C++ Includes #include #include #include @@ -23,13 +20,12 @@ #include #include -// Other libraries and framework includes #include "clang/AST/ASTContext.h" #include "clang/AST/ExternalASTMerger.h" #include "clang/AST/TemplateBase.h" +#include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallVector.h" -// Project includes #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/ClangForward.h" #include "lldb/Symbol/CompilerType.h" @@ -222,19 +218,24 @@ class ClangASTContext : public TypeSystem { static CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl); template - CompilerType GetTypeForIdentifier(const ConstString &type_name) { + CompilerType + GetTypeForIdentifier(const ConstString &type_name, + clang::DeclContext *decl_context = nullptr) { CompilerType compiler_type; if (type_name.GetLength()) { clang::ASTContext *ast = getASTContext(); if (ast) { + if (!decl_context) + decl_context = ast->getTranslationUnitDecl(); + clang::IdentifierInfo &myIdent = ast->Idents.get(type_name.GetCString()); clang::DeclarationName myName = ast->DeclarationNames.getIdentifier(&myIdent); clang::DeclContext::lookup_result result = - ast->getTranslationUnitDecl()->lookup(myName); + decl_context->lookup(myName); if (!result.empty()) { clang::NamedDecl *named_decl = result[0]; @@ -385,7 +386,17 @@ class ClangASTContext : public TypeSystem { const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, - unsigned type_quals); + unsigned type_quals, + clang::CallingConv cc); + + static CompilerType CreateFunctionType(clang::ASTContext *ast, + const CompilerType &result_type, + const CompilerType *args, + unsigned num_args, bool is_variadic, + unsigned type_quals) { + return ClangASTContext::CreateFunctionType( + ast, result_type, args, num_args, is_variadic, type_quals, clang::CC_C); + } CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, @@ -394,7 +405,17 @@ class ClangASTContext : public TypeSystem { getASTContext(), result_type, args, num_args, is_variadic, type_quals); } - clang::ParmVarDecl *CreateParameterDeclaration(const char *name, + CompilerType CreateFunctionType(const CompilerType &result_type, + const CompilerType *args, unsigned num_args, + bool is_variadic, unsigned type_quals, + clang::CallingConv cc) { + return ClangASTContext::CreateFunctionType(getASTContext(), result_type, + args, num_args, is_variadic, + type_quals, cc); + } + + clang::ParmVarDecl *CreateParameterDeclaration(clang::DeclContext *decl_ctx, + const char *name, const CompilerType ¶m_type, int storage); @@ -839,7 +860,7 @@ class ClangASTContext : public TypeSystem { // Modifying RecordType //---------------------------------------------------------------------- static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type, - const char *name, + llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size); @@ -849,7 +870,7 @@ class ClangASTContext : public TypeSystem { static void SetIsPacked(const CompilerType &type); static clang::VarDecl *AddVariableToRecordType(const CompilerType &type, - const char *name, + llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access); @@ -861,19 +882,17 @@ class ClangASTContext : public TypeSystem { bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial); + void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type); + // C++ Base Classes - clang::CXXBaseSpecifier * + std::unique_ptr CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class); - static void DeleteBaseClassSpecifiers(clang::CXXBaseSpecifier **base_classes, - unsigned num_base_classes); - - bool - SetBaseClassesForClassType(lldb::opaque_compiler_type_t type, - clang::CXXBaseSpecifier const *const *base_classes, - unsigned num_base_classes); + bool TransferBaseClasses( + lldb::opaque_compiler_type_t type, + std::vector> bases); static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type); @@ -909,9 +928,12 @@ class ClangASTContext : public TypeSystem { //---------------------------------------------------------------------- // Modifying Enumeration types //---------------------------------------------------------------------- - bool AddEnumerationValueToEnumerationType( - const CompilerType &enumerator_qual_type, const Declaration &decl, - const char *name, int64_t enum_value, uint32_t enum_value_bit_size); + clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( + const CompilerType &enum_type, const Declaration &decl, const char *name, + int64_t enum_value, uint32_t enum_value_bit_size); + clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( + const CompilerType &enum_type, const Declaration &decl, const char *name, + const llvm::APSInt &value); CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type); @@ -933,6 +955,8 @@ class ClangASTContext : public TypeSystem { //---------------------------------------------------------------------- // Dumping types //---------------------------------------------------------------------- + void Dump(Stream &s); + void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, @@ -965,6 +989,8 @@ class ClangASTContext : public TypeSystem { static clang::TagDecl *GetAsTagDecl(const CompilerType &type); + static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type); + clang::CXXRecordDecl *GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type); static clang::ObjCInterfaceDecl * diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h index 52a164a1d2dd..96641daccde6 100644 --- a/include/lldb/Symbol/ClangASTImporter.h +++ b/include/lldb/Symbol/ClangASTImporter.h @@ -1,23 +1,19 @@ //===-- ClangASTImporter.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangASTImporter_h_ #define liblldb_ClangASTImporter_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes #include "clang/AST/ASTImporter.h" #include "clang/AST/CharUnits.h" #include "clang/AST/Decl.h" @@ -25,7 +21,6 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" -// Project includes #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h index ef0010314e1d..5d7fa61d4a4f 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h @@ -1,24 +1,19 @@ //===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangExternalASTSourceCallbacks_h_ #define liblldb_ClangExternalASTSourceCallbacks_h_ -// C Includes #include -// C++ Includes -// Other libraries and framework includes #include "clang/AST/CharUnits.h" #include "llvm/ADT/DenseMap.h" -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h index 3e700ba2439c..8e69f6d3e4eb 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -1,9 +1,8 @@ //===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,7 +19,6 @@ // file. So we have to define NDEBUG when including clang headers to avoid any // mismatches. This is covered by rdar://problem/8691220 -// C Includes #if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF) #define LLDB_DEFINED_NDEBUG_FOR_CLANG #define NDEBUG @@ -35,11 +33,8 @@ #include #endif -// C++ Includes -// Other libraries and framework includes #include "clang/AST/ExternalASTSource.h" -// Project includes #include "lldb/Core/dwarf.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" diff --git a/include/lldb/Symbol/ClangUtil.h b/include/lldb/Symbol/ClangUtil.h index cb380221152a..d6106032190c 100644 --- a/include/lldb/Symbol/ClangUtil.h +++ b/include/lldb/Symbol/ClangUtil.h @@ -1,9 +1,8 @@ //===-- ClangUtil.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // // A collection of helper methods and data structures for manipulating clang // types and decls. @@ -16,6 +15,10 @@ #include "lldb/Symbol/CompilerType.h" +namespace clang { +class TagDecl; +} + namespace lldb_private { struct ClangUtil { static bool IsClangType(const CompilerType &ct); @@ -25,6 +28,8 @@ struct ClangUtil { static clang::QualType GetCanonicalQualType(const CompilerType &ct); static CompilerType RemoveFastQualifiers(const CompilerType &ct); + + static clang::TagDecl *GetAsTagDecl(const CompilerType &type); }; } diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h index 711420f66a46..8ecb7c0afc6e 100644 --- a/include/lldb/Symbol/CompactUnwindInfo.h +++ b/include/lldb/Symbol/CompactUnwindInfo.h @@ -1,9 +1,8 @@ //===-- CompactUnwindInfo.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h index 5e4e12e96065..6a4520994e36 100644 --- a/include/lldb/Symbol/CompileUnit.h +++ b/include/lldb/Symbol/CompileUnit.h @@ -1,9 +1,8 @@ //===-- CompileUnit.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -392,7 +391,7 @@ class CompileUnit : public std::enable_shared_from_this, //------------------------------------------------------------------ uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, bool exact, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); //------------------------------------------------------------------ @@ -410,6 +409,11 @@ class CompileUnit : public std::enable_shared_from_this, //------------------------------------------------------------------ bool GetIsOptimized(); + //------------------------------------------------------------------ + /// Returns the number of functions in this compile unit + //------------------------------------------------------------------ + size_t GetNumFunctions() const { return m_functions_by_uid.size(); } + protected: /// User data for the SymbolFile parser to store information into. void *m_user_data; diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h index 5d744d999bea..856729048edd 100644 --- a/include/lldb/Symbol/CompilerDecl.h +++ b/include/lldb/Symbol/CompilerDecl.h @@ -1,9 +1,8 @@ //===-- CompilerDecl.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h index 179a1be0248b..15747c8be0bb 100644 --- a/include/lldb/Symbol/CompilerDeclContext.h +++ b/include/lldb/Symbol/CompilerDeclContext.h @@ -1,9 +1,8 @@ //===-- CompilerDeclContext.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h index e2aae4646283..a9366445df07 100644 --- a/include/lldb/Symbol/CompilerType.h +++ b/include/lldb/Symbol/CompilerType.h @@ -1,23 +1,18 @@ //===-- CompilerType.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CompilerType_h_ #define liblldb_CompilerType_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/SwiftForward.h" #include "lldb/lldb-private.h" @@ -302,7 +297,9 @@ class CompilerType { struct IntegralTemplateArgument; + /// Return the size of the type in bytes. llvm::Optional GetByteSize(ExecutionContextScope *exe_scope) const; + /// Return the size of the type in bits. llvm::Optional GetBitSize(ExecutionContextScope *exe_scope) const; uint64_t GetByteStride() const; diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h index 133c66d4ae4f..7f0f3db49a71 100644 --- a/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -1,9 +1,8 @@ //===-- DWARFCallFrameInfo.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h index 640da027cd59..d364299ef490 100644 --- a/include/lldb/Symbol/DebugMacros.h +++ b/include/lldb/Symbol/DebugMacros.h @@ -1,22 +1,17 @@ //===-- DebugMacros.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DebugMacros_h_ #define liblldb_DebugMacros_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h index d1ccb4191cbc..8fd952365fcc 100644 --- a/include/lldb/Symbol/DeclVendor.h +++ b/include/lldb/Symbol/DeclVendor.h @@ -1,9 +1,8 @@ //===-- DeclVendor.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h index b654988bccd2..61e75d60f4c4 100644 --- a/include/lldb/Symbol/Declaration.h +++ b/include/lldb/Symbol/Declaration.h @@ -1,9 +1,8 @@ //===-- Declaration.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h index ad11c8b0af94..bff22bff7abc 100644 --- a/include/lldb/Symbol/Function.h +++ b/include/lldb/Symbol/Function.h @@ -1,9 +1,8 @@ //===-- Function.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -411,43 +410,6 @@ class Function : public UserID, public SymbolContextScope { Type *func_type, const AddressRange &range, bool can_throw = false); - //------------------------------------------------------------------ - /// Construct with a compile unit, function UID, function type UID, optional - /// mangled name, function type, and a section offset based address range. - /// - /// @param[in] comp_unit - /// The compile unit to which this function belongs. - /// - /// @param[in] func_uid - /// The UID for this function. This value is provided by the - /// SymbolFile plug-in and can be any value that allows - /// the plug-in to quickly find and parse more detailed - /// information when and if more information is needed. - /// - /// @param[in] func_type_uid - /// The type UID for the function Type to allow for lazy type - /// parsing from the debug information. - /// - /// @param[in] mangled - /// The optional mangled name for this function. If empty, there - /// is no mangled information. - /// - /// @param[in] func_type - /// The optional function type. If NULL, the function type will - /// be parsed on demand when accessed using the - /// Function::GetType() function by asking the SymbolFile - /// plug-in to get the type for \a func_type_uid. - /// - /// @param[in] range - /// The section offset based address for this function. - /// - /// @param[in] can_throw - /// Pass in true if this is a function know to throw - //------------------------------------------------------------------ - Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, - lldb::user_id_t func_type_uid, const char *mangled, Type *func_type, - const AddressRange &range, bool can_throw = false); - //------------------------------------------------------------------ /// Destructor. //------------------------------------------------------------------ diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h index c1ce614609c1..5dd7b0761181 100644 --- a/include/lldb/Symbol/LineEntry.h +++ b/include/lldb/Symbol/LineEntry.h @@ -1,9 +1,8 @@ //===-- LineEntry.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h index 4464844e548b..383dc0d91e6f 100644 --- a/include/lldb/Symbol/LineTable.h +++ b/include/lldb/Symbol/LineTable.h @@ -1,21 +1,16 @@ //===-- LineTable.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_LineTable_h_ #define liblldb_LineTable_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/ModuleChild.h" #include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" @@ -242,21 +237,22 @@ class LineTable { protected: struct Entry { Entry() - : file_addr(LLDB_INVALID_ADDRESS), line(0), column(0), file_idx(0), + : file_addr(LLDB_INVALID_ADDRESS), line(0), is_start_of_statement(false), is_start_of_basic_block(false), is_prologue_end(false), is_epilogue_begin(false), - is_terminal_entry(false) {} + is_terminal_entry(false), column(0), file_idx(0) {} Entry(lldb::addr_t _file_addr, uint32_t _line, uint16_t _column, uint16_t _file_idx, bool _is_start_of_statement, bool _is_start_of_basic_block, bool _is_prologue_end, bool _is_epilogue_begin, bool _is_terminal_entry) - : file_addr(_file_addr), line(_line), column(_column), - file_idx(_file_idx), is_start_of_statement(_is_start_of_statement), + : file_addr(_file_addr), line(_line), + is_start_of_statement(_is_start_of_statement), is_start_of_basic_block(_is_start_of_basic_block), is_prologue_end(_is_prologue_end), is_epilogue_begin(_is_epilogue_begin), - is_terminal_entry(_is_terminal_entry) {} + is_terminal_entry(_is_terminal_entry), column(_column), + file_idx(_file_idx) {} int bsearch_compare(const void *key, const void *arrmem); diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h index 2138d22808c3..10215bbe9d6c 100644 --- a/include/lldb/Symbol/ObjectContainer.h +++ b/include/lldb/Symbol/ObjectContainer.h @@ -1,19 +1,14 @@ //===-- ObjectContainer.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjectContainer_h_ #define liblldb_ObjectContainer_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/DataExtractor.h" diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h index 1e9ae8b45417..21bea80dcb60 100644 --- a/include/lldb/Symbol/ObjectFile.h +++ b/include/lldb/Symbol/ObjectFile.h @@ -1,9 +1,8 @@ //===-- ObjectFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -40,7 +39,7 @@ class ObjectFileJITDelegate { virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list) = 0; - virtual bool GetArchitecture(lldb_private::ArchSpec &arch) = 0; + virtual ArchSpec GetArchitecture() = 0; }; //---------------------------------------------------------------------- @@ -305,19 +304,13 @@ class ObjectFile : public std::enable_shared_from_this, virtual const FileSpec &GetFileSpec() const { return m_file; } //------------------------------------------------------------------ - /// Get the name of the cpu, vendor and OS for this object file. - /// - /// This value is a string that represents the target triple where the cpu - /// type, the vendor and the OS are encoded into a string. - /// - /// @param[out] target_triple - /// The string value of the target triple. + /// Get the ArchSpec for this object file. /// /// @return - /// \b True if the target triple was able to be computed, \b - /// false otherwise. + /// The ArchSpec of this object file. In case of error, an invalid + /// ArchSpec object is returned. //------------------------------------------------------------------ - virtual bool GetArchitecture(ArchSpec &arch) = 0; + virtual ArchSpec GetArchitecture() = 0; //------------------------------------------------------------------ /// Gets the section list for the currently selected architecture (and @@ -551,18 +544,16 @@ class ObjectFile : public std::enable_shared_from_this, virtual lldb_private::Address GetEntryPointAddress() { return Address(); } //------------------------------------------------------------------ - /// Returns the address that represents the header of this object file. - /// - /// The header address is defined as where the header for the object file is - /// that describes the content of the file. If the header doesn't appear in - /// a section that is defined in the object file, an address with no section - /// is returned that has the file offset set in the m_file_offset member of - /// the lldb_private::Address object. + /// Returns base address of this object file. /// - /// @return - /// Returns the entry address for this module. + /// This also sometimes referred to as the "preferred load address" or the + /// "image base address". Addresses within object files are often expressed + /// relative to this base. If this address corresponds to a specific section + /// (usually the first byte of the first section) then the returned address + /// will have this section set. Otherwise, the address will just have the + /// offset member filled in, indicating that this represents a file address. //------------------------------------------------------------------ - virtual lldb_private::Address GetHeaderAddress() { + virtual lldb_private::Address GetBaseAddress() { return Address(m_memory_addr); } @@ -817,4 +808,16 @@ class ObjectFile : public std::enable_shared_from_this, } // namespace lldb_private +namespace llvm { +template <> struct format_provider { + static void format(const lldb_private::ObjectFile::Type &type, + raw_ostream &OS, StringRef Style); +}; + +template <> struct format_provider { + static void format(const lldb_private::ObjectFile::Strata &strata, + raw_ostream &OS, StringRef Style); +}; +} // namespace llvm + #endif // liblldb_ObjectFile_h_ diff --git a/include/lldb/Symbol/SwiftASTContext.h b/include/lldb/Symbol/SwiftASTContext.h index d7bc61af884f..3a910033cc1b 100644 --- a/include/lldb/Symbol/SwiftASTContext.h +++ b/include/lldb/Symbol/SwiftASTContext.h @@ -47,7 +47,7 @@ class TypeInfo; } namespace serialization { struct ValidationInfo; -struct ExtendedValidationInfo; +class ExtendedValidationInfo; } } diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h index 49e232a0f657..557a9d28b1c8 100644 --- a/include/lldb/Symbol/Symbol.h +++ b/include/lldb/Symbol/Symbol.h @@ -1,9 +1,8 @@ //===-- Symbol.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h index 0ec0006f193a..6e674faed40f 100644 --- a/include/lldb/Symbol/SymbolContext.h +++ b/include/lldb/Symbol/SymbolContext.h @@ -1,23 +1,18 @@ //===-- SymbolContext.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SymbolContext_h_ #define liblldb_SymbolContext_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Core/Mangled.h" #include "lldb/Symbol/LineEntry.h" @@ -232,7 +227,7 @@ class SymbolContext { bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error); - + //------------------------------------------------------------------ /// Find the best global data symbol visible from this context. /// @@ -469,10 +464,6 @@ class SymbolContextList { bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function); - bool MergeSymbolContextIntoFunctionContext(const SymbolContext &symbol_sc, - uint32_t start_idx = 0, - uint32_t stop_idx = UINT32_MAX); - uint32_t AppendIfUnique(const SymbolContextList &sc_list, bool merge_symbol_into_function); @@ -531,18 +522,6 @@ class SymbolContextList { return m_symbol_contexts[idx]; } - //------------------------------------------------------------------ - /// Get accessor for the last symbol context in the list. - /// - /// @param[out] sc - /// A reference to the symbol context to fill in. - /// - /// @return - /// Returns \b true if \a sc was filled in, \b false if the - /// list is empty. - //------------------------------------------------------------------ - bool GetLastContext(SymbolContext &sc) const; - bool RemoveContextAtIndex(size_t idx); //------------------------------------------------------------------ diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h index c2fbb5272fc0..bb36339025a5 100644 --- a/include/lldb/Symbol/SymbolContextScope.h +++ b/include/lldb/Symbol/SymbolContextScope.h @@ -1,19 +1,14 @@ //===-- SymbolContextScope.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SymbolContextScope_h_ #define liblldb_SymbolContextScope_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h index c1a6b34176cf..04666a784c16 100644 --- a/include/lldb/Symbol/SymbolFile.h +++ b/include/lldb/Symbol/SymbolFile.h @@ -1,9 +1,8 @@ //===-- SymbolFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -128,22 +127,19 @@ class SymbolFile : public PluginInterface { virtual uint32_t GetNumCompileUnits() = 0; virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0; - virtual lldb::LanguageType - ParseCompileUnitLanguage(const SymbolContext &sc) = 0; - virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitLineTable(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files) = 0; - virtual bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) { - return false; - } + virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0; + virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0; + virtual bool ParseLineTable(CompileUnit &comp_unit) = 0; + virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0; + virtual bool ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) = 0; + virtual size_t ParseTypes(CompileUnit &comp_unit) = 0; + virtual bool ParseIsOptimized(CompileUnit &comp_unit) { return false; } + virtual bool ParseImportedModules(const SymbolContext &sc, std::vector &imported_modules) = 0; - virtual size_t ParseFunctionBlocks(const SymbolContext &sc) = 0; - virtual size_t ParseTypes(const SymbolContext &sc) = 0; + virtual size_t ParseBlocksRecursive(Function &func) = 0; virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0; virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0; @@ -175,12 +171,14 @@ class SymbolFile : public PluginInterface { return CompilerDeclContext(); } virtual uint32_t ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContext &sc) = 0; virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); + + virtual void DumpClangAST(Stream &s) {} virtual uint32_t FindGlobalVariables(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, @@ -190,15 +188,15 @@ class SymbolFile : public PluginInterface { VariableList &variables); virtual uint32_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, - bool append, SymbolContextList &sc_list); + lldb::FunctionNameType name_type_mask, + bool include_inlines, bool append, + SymbolContextList &sc_list); virtual uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list); virtual uint32_t - FindTypes(const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types); virtual size_t FindTypes(const std::vector &context, @@ -212,7 +210,7 @@ class SymbolFile : public PluginInterface { // types) = 0; virtual TypeList *GetTypeList(); virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, lldb_private::TypeList &type_list) = 0; virtual void PreloadSymbols(); @@ -221,7 +219,7 @@ class SymbolFile : public PluginInterface { GetTypeSystemForLanguage(lldb::LanguageType language); virtual CompilerDeclContext - FindNamespace(const SymbolContext &sc, const ConstString &name, + FindNamespace(const ConstString &name, const CompilerDeclContext *parent_decl_ctx) { return CompilerDeclContext(); } @@ -233,6 +231,8 @@ class SymbolFile : public PluginInterface { return {}; } + virtual void AddSymbols(Symtab &symtab) {} + //------------------------------------------------------------------ /// Notify the SymbolFile that the file addresses in the Sections /// for this module have been changed. diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h index 33349ba9708e..c40e18213f15 100644 --- a/include/lldb/Symbol/SymbolVendor.h +++ b/include/lldb/Symbol/SymbolVendor.h @@ -1,9 +1,8 @@ //===-- SymbolVendor.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -47,38 +46,38 @@ class SymbolVendor : public ModuleChild, public PluginInterface { virtual void Dump(Stream *s); - virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc); + virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit); + + virtual size_t ParseFunctions(CompileUnit &comp_unit); - virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc); + virtual bool ParseLineTable(CompileUnit &comp_unit); - virtual bool ParseCompileUnitLineTable(const SymbolContext &sc); + virtual bool ParseDebugMacros(CompileUnit &comp_unit); - virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc); + virtual bool ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files); - virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files); + virtual bool ParseIsOptimized(CompileUnit &comp_unit); - virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc); + virtual size_t ParseTypes(CompileUnit &comp_unit); virtual bool ParseImportedModules(const SymbolContext &sc, std::vector &imported_modules); - virtual size_t ParseFunctionBlocks(const SymbolContext &sc); - - virtual size_t ParseTypes(const SymbolContext &sc); + virtual size_t ParseBlocksRecursive(Function &func); virtual size_t ParseVariablesForContext(const SymbolContext &sc); virtual Type *ResolveTypeUID(lldb::user_id_t type_uid); virtual uint32_t ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContext &sc); virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); virtual size_t FindGlobalVariables(const ConstString &name, @@ -92,17 +91,17 @@ class SymbolVendor : public ModuleChild, public PluginInterface { virtual size_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, - bool append, SymbolContextList &sc_list); + lldb::FunctionNameType name_type_mask, + bool include_inlines, bool append, + SymbolContextList &sc_list); virtual size_t FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list); virtual size_t - FindTypes(const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - size_t max_matches, + FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types); @@ -110,7 +109,7 @@ class SymbolVendor : public ModuleChild, public PluginInterface { bool append, TypeMap &types); virtual CompilerDeclContext - FindNamespace(const SymbolContext &sc, const ConstString &name, + FindNamespace(const ConstString &name, const CompilerDeclContext *parent_decl_ctx); virtual size_t GetNumCompileUnits(); @@ -124,8 +123,8 @@ class SymbolVendor : public ModuleChild, public PluginInterface { const TypeList &GetTypeList() const { return m_type_list; } - virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask, - TypeList &type_list); + virtual size_t GetTypes(SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, TypeList &type_list); SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); } @@ -185,6 +184,8 @@ class SymbolVendor : public ModuleChild, public PluginInterface { // file) std::unique_ptr m_sym_file_ap; // A single symbol file. Subclasses // can add more of these if needed. + Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of + // the symbol file each time when it is needed private: //------------------------------------------------------------------ diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h index e07f42a64858..6e0bd5eba26d 100644 --- a/include/lldb/Symbol/Symtab.h +++ b/include/lldb/Symbol/Symtab.h @@ -1,9 +1,8 @@ //===-- Symtab.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -172,12 +171,12 @@ class Symtab { Visibility symbol_visibility) const { switch (symbol_debug_type) { case eDebugNo: - if (m_symbols[idx].IsDebug() == true) + if (m_symbols[idx].IsDebug()) return false; break; case eDebugYes: - if (m_symbols[idx].IsDebug() == false) + if (!m_symbols[idx].IsDebug()) return false; break; diff --git a/include/lldb/Symbol/TaggedASTType.h b/include/lldb/Symbol/TaggedASTType.h index eabd41ebbf29..043a9138e07b 100644 --- a/include/lldb/Symbol/TaggedASTType.h +++ b/include/lldb/Symbol/TaggedASTType.h @@ -1,9 +1,8 @@ //===-- TaggedASTType.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h index 5ed5208d52e4..2ffbda1bc2d4 100644 --- a/include/lldb/Symbol/Type.h +++ b/include/lldb/Symbol/Type.h @@ -1,9 +1,8 @@ //===-- Type.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -96,7 +95,7 @@ class Type : public std::enable_shared_from_this, public UserID { } ResolveState; Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name, - uint64_t byte_size, SymbolContextScope *context, + llvm::Optional byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, ResolveState compiler_type_resolve_state); @@ -128,7 +127,7 @@ class Type : public std::enable_shared_from_this, public UserID { const ConstString &GetName(); - uint64_t GetByteSize(); + llvm::Optional GetByteSize(); uint32_t GetNumChildren(bool omit_empty_base_classes); @@ -218,7 +217,8 @@ class Type : public std::enable_shared_from_this, public UserID { Type *m_encoding_type; lldb::user_id_t m_encoding_uid; EncodingDataType m_encoding_uid_type; - uint64_t m_byte_size; + uint64_t m_byte_size : 63; + uint64_t m_byte_size_has_value : 1; Declaration m_decl; CompilerType m_compiler_type; diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h index b6a4e41ff301..20c34f74e4d2 100644 --- a/include/lldb/Symbol/TypeList.h +++ b/include/lldb/Symbol/TypeList.h @@ -1,9 +1,8 @@ //===-- TypeList.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/TypeMap.h b/include/lldb/Symbol/TypeMap.h index 6bf9831c1389..34bfc08481b1 100644 --- a/include/lldb/Symbol/TypeMap.h +++ b/include/lldb/Symbol/TypeMap.h @@ -1,9 +1,8 @@ //===-- TypeMap.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h index a52f1db1dd73..9702d9195bef 100644 --- a/include/lldb/Symbol/TypeSystem.h +++ b/include/lldb/Symbol/TypeSystem.h @@ -1,27 +1,22 @@ //===-- TypeSystem.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_TypeSystem_h_ #define liblldb_TypeSystem_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes #include "llvm/ADT/APSInt.h" #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Expression/Expression.h" #include "lldb/Symbol/CompilerDecl.h" @@ -379,7 +374,7 @@ class TypeSystem : public PluginInterface { const char *name, bool omit_empty_base_classes, std::vector &child_indexes) = 0; - virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) = 0; + virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type); virtual lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx); diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h index a76ea23b46bc..2b49acaafa04 100644 --- a/include/lldb/Symbol/UnwindPlan.h +++ b/include/lldb/Symbol/UnwindPlan.h @@ -1,23 +1,18 @@ //===-- UnwindPlan.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UnwindPlan_h #define liblldb_UnwindPlan_h -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Stream.h" @@ -28,14 +23,22 @@ namespace lldb_private { // The UnwindPlan object specifies how to unwind out of a function - where this // function saves the caller's register values before modifying them (for non- // volatile aka saved registers) and how to find this frame's Canonical Frame -// Address (CFA). +// Address (CFA) or Aligned Frame Address (AFA). +// CFA is a DWARF's Canonical Frame Address. // Most commonly, registers are saved on the stack, offset some bytes from the // Canonical Frame Address, or CFA, which is the starting address of this // function's stack frame (the CFA is same as the eh_frame's CFA, whatever that // may be on a given architecture). The CFA address for the stack frame does // not change during the lifetime of the function. +// AFA is an artificially introduced Aligned Frame Address. +// It is used only for stack frames with realignment (e.g. when some of the +// locals has an alignment requirement higher than the stack alignment right +// after the function call). It is used to access register values saved on the +// stack after the realignment (and so they are inaccessible through the CFA). +// AFA usually equals the stack pointer value right after the realignment. + // Internally, the UnwindPlan is structured as a vector of register locations // organized by code address in the function, showing which registers have been // saved at that point and where they are saved. It can be thought of as the @@ -61,6 +64,8 @@ class UnwindPlan { same, // reg is unchanged atCFAPlusOffset, // reg = deref(CFA + offset) isCFAPlusOffset, // reg = CFA + offset + atAFAPlusOffset, // reg = deref(AFA + offset) + isAFAPlusOffset, // reg = AFA + offset inOtherRegister, // reg = other reg atDWARFExpression, // reg = deref(eval(dwarf_expr)) isDWARFExpression // reg = eval(dwarf_expr) @@ -90,6 +95,10 @@ class UnwindPlan { bool IsAtCFAPlusOffset() const { return m_type == atCFAPlusOffset; } + bool IsAFAPlusOffset() const { return m_type == isAFAPlusOffset; } + + bool IsAtAFAPlusOffset() const { return m_type == atAFAPlusOffset; } + bool IsInOtherRegister() const { return m_type == inOtherRegister; } bool IsAtDWARFExpression() const { return m_type == atDWARFExpression; } @@ -106,6 +115,16 @@ class UnwindPlan { m_location.offset = offset; } + void SetAtAFAPlusOffset(int32_t offset) { + m_type = atAFAPlusOffset; + m_location.offset = offset; + } + + void SetIsAFAPlusOffset(int32_t offset) { + m_type = isAFAPlusOffset; + m_location.offset = offset; + } + void SetInRegister(uint32_t reg_num) { m_type = inOtherRegister; m_location.reg_num = reg_num; @@ -120,9 +139,16 @@ class UnwindPlan { RestoreType GetLocationType() const { return m_type; } int32_t GetOffset() const { - if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset) + switch(m_type) + { + case atCFAPlusOffset: + case isCFAPlusOffset: + case atAFAPlusOffset: + case isAFAPlusOffset: return m_location.offset; - return 0; + default: + return 0; + } } void GetDWARFExpr(const uint8_t **opcodes, uint16_t &len) const { @@ -169,20 +195,20 @@ class UnwindPlan { } m_location; }; - class CFAValue { + class FAValue { public: enum ValueType { unspecified, // not specified - isRegisterPlusOffset, // CFA = register + offset - isRegisterDereferenced, // CFA = [reg] - isDWARFExpression // CFA = eval(dwarf_expr) + isRegisterPlusOffset, // FA = register + offset + isRegisterDereferenced, // FA = [reg] + isDWARFExpression // FA = eval(dwarf_expr) }; - CFAValue() : m_type(unspecified), m_value() {} + FAValue() : m_type(unspecified), m_value() {} - bool operator==(const CFAValue &rhs) const; + bool operator==(const FAValue &rhs) const; - bool operator!=(const CFAValue &rhs) const { return !(*this == rhs); } + bool operator!=(const FAValue &rhs) const { return !(*this == rhs); } void SetUnspecified() { m_type = unspecified; } @@ -279,7 +305,7 @@ class UnwindPlan { uint16_t length; } expr; } m_value; - }; // class CFAValue + }; // class FAValue public: Row(); @@ -302,7 +328,9 @@ class UnwindPlan { void SlideOffset(lldb::addr_t offset) { m_offset += offset; } - CFAValue &GetCFAValue() { return m_cfa_value; } + FAValue &GetCFAValue() { return m_cfa_value; } + + FAValue &GetAFAValue() { return m_afa_value; } bool SetRegisterLocationToAtCFAPlusOffset(uint32_t reg_num, int32_t offset, bool can_replace); @@ -329,7 +357,8 @@ class UnwindPlan { typedef std::map collection; lldb::addr_t m_offset; // Offset into the function for this row - CFAValue m_cfa_value; + FAValue m_cfa_value; + FAValue m_afa_value; collection m_register_locations; }; // class Row diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h index 5c83e3003192..8ca4a4de9ec5 100644 --- a/include/lldb/Symbol/UnwindTable.h +++ b/include/lldb/Symbol/UnwindTable.h @@ -1,9 +1,8 @@ //===-- Symtab.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -50,7 +49,7 @@ class UnwindTable { GetUncachedFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc); - bool GetArchitecture(lldb_private::ArchSpec &arch); + ArchSpec GetArchitecture(); private: void Dump(Stream &s); diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h index 531312e63591..9c9a784a94f8 100644 --- a/include/lldb/Symbol/Variable.h +++ b/include/lldb/Symbol/Variable.h @@ -1,9 +1,8 @@ //===-- Variable.h -----------------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h index 6729a9c108a9..d9f79ded45e7 100644 --- a/include/lldb/Symbol/VariableList.h +++ b/include/lldb/Symbol/VariableList.h @@ -1,9 +1,8 @@ //===-- VariableList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/VerifyDecl.h b/include/lldb/Symbol/VerifyDecl.h index f4b61e6355ce..f412b94a7859 100644 --- a/include/lldb/Symbol/VerifyDecl.h +++ b/include/lldb/Symbol/VerifyDecl.h @@ -1,9 +1,8 @@ //===-- VerifyDecl.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 343b3a749597..9d7996aa7e93 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -1,19 +1,14 @@ //===-- ABI.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABI_h_ #define liblldb_ABI_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/Status.h" diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h index 1a0068f221f1..1e9fb08aae89 100644 --- a/include/lldb/Target/CPPLanguageRuntime.h +++ b/include/lldb/Target/CPPLanguageRuntime.h @@ -1,21 +1,16 @@ //===-- CPPLanguageRuntime.h //---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CPPLanguageRuntime_h_ #define liblldb_CPPLanguageRuntime_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index de9c4e233b0c..cf5826456e9a 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -1,27 +1,25 @@ //===-- DynamicLoader.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DynamicLoader_h_ #define liblldb_DynamicLoader_h_ -// Project includes #include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UUID.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for ModuleSP, ThreadPlanSP -#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz... -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include // for size_t -#include // for int64_t +#include +#include namespace lldb_private { class ModuleList; } diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index 70eba3654dec..21905ffd361f 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -1,21 +1,16 @@ //===-- ExecutionContext.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ExecutionContext_h_ #define liblldb_ExecutionContext_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/StackID.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h index b73ca576bd8a..865de03b0265 100644 --- a/include/lldb/Target/ExecutionContextScope.h +++ b/include/lldb/Target/ExecutionContextScope.h @@ -1,19 +1,14 @@ //===-- ExecutionContextScope.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ExecutionContextScope_h_ #define liblldb_ExecutionContextScope_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Target/FileAction.h b/include/lldb/Target/FileAction.h index f80f57ac588b..fc5abb19a4cb 100644 --- a/include/lldb/Target/FileAction.h +++ b/include/lldb/Target/FileAction.h @@ -1,9 +1,8 @@ //===-- FileAction.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h index 21d66d5766a9..4cee76d657bb 100644 --- a/include/lldb/Target/InstrumentationRuntime.h +++ b/include/lldb/Target/InstrumentationRuntime.h @@ -1,22 +1,17 @@ //===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_InstrumentationRuntime_h_ #define liblldb_InstrumentationRuntime_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h index b11231960ac1..6c2a8ad87418 100644 --- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -1,21 +1,16 @@ //===-- InstrumentationRuntimeStopInfo.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_InstrumentationRuntimeStopInfo_h_ #define liblldb_InstrumentationRuntimeStopInfo_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/StopInfo.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h index 56f1417eddb0..983d6dfa5c69 100644 --- a/include/lldb/Target/JITLoader.h +++ b/include/lldb/Target/JITLoader.h @@ -1,9 +1,8 @@ //===-- JITLoader.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/JITLoaderList.h b/include/lldb/Target/JITLoaderList.h index 4b9d79bbfcab..4b240ba33b20 100644 --- a/include/lldb/Target/JITLoaderList.h +++ b/include/lldb/Target/JITLoaderList.h @@ -1,9 +1,8 @@ //===-- JITLoaderList.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index f3f8acd85f7e..12930917ae5e 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -1,25 +1,20 @@ //===-- Language.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Language_h_ #define liblldb_Language_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Highlighter.h" #include "lldb/Core/PluginInterface.h" #include "lldb/DataFormatters/DumpValueObjectOptions.h" diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h index 1c074e2b0026..2fa3cf4f7273 100644 --- a/include/lldb/Target/LanguageRuntime.h +++ b/include/lldb/Target/LanguageRuntime.h @@ -1,20 +1,15 @@ //===-- LanguageRuntime.h ---------------------------------------------------*- // C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_LanguageRuntime_h_ #define liblldb_LanguageRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Breakpoint/BreakpointResolverName.h" #include "lldb/Core/PluginInterface.h" @@ -129,6 +124,17 @@ class LanguageRuntime : public PluginInterface { static Breakpoint::BreakpointPreconditionSP CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp, bool throw_bp); + + virtual lldb::ValueObjectSP GetExceptionObjectForThread( + lldb::ThreadSP thread_sp) { + return lldb::ValueObjectSP(); + } + + virtual lldb::ThreadSP GetBacktraceThreadFromException( + lldb::ValueObjectSP thread_sp) { + return lldb::ThreadSP(); + } + Process *GetProcess() { return m_process; } static lldb::LanguageType diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h index 16d7b256a78e..05ff22a3f66b 100644 --- a/include/lldb/Target/Memory.h +++ b/include/lldb/Target/Memory.h @@ -1,24 +1,19 @@ //===-- Memory.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Memory_h_ #define liblldb_Memory_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/RangeMap.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/MemoryHistory.h b/include/lldb/Target/MemoryHistory.h index acc36ffe2eb4..501751c55e80 100644 --- a/include/lldb/Target/MemoryHistory.h +++ b/include/lldb/Target/MemoryHistory.h @@ -1,22 +1,17 @@ //===-- MemoryHistory.h ---------------------------------------------------*- //C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_MemoryHistory_h_ #define liblldb_MemoryHistory_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h index 505ecfcfc5ae..b16d8f55bdbc 100644 --- a/include/lldb/Target/MemoryRegionInfo.h +++ b/include/lldb/Target/MemoryRegionInfo.h @@ -1,10 +1,9 @@ //===-- MemoryRegionInfo.h ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,7 +13,6 @@ #include "lldb/Core/RangeMap.h" #include "llvm/Support/FormatProviders.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Range.h" namespace lldb_private { class MemoryRegionInfo { @@ -109,6 +107,26 @@ class MemoryRegionInfo { OptionalBool m_flash; lldb::offset_t m_blocksize; }; + +inline bool operator<(const MemoryRegionInfo &lhs, + const MemoryRegionInfo &rhs) { + return lhs.GetRange() < rhs.GetRange(); +} + +inline bool operator<(const MemoryRegionInfo &lhs, lldb::addr_t rhs) { + return lhs.GetRange().GetRangeBase() < rhs; +} + +inline bool operator<(lldb::addr_t lhs, const MemoryRegionInfo &rhs) { + return lhs < rhs.GetRange().GetRangeBase(); +} + +// Forward-declarable wrapper. +class MemoryRegionInfos : public std::vector { +public: + using std::vector::vector; +}; + } namespace llvm { diff --git a/include/lldb/Target/ModuleCache.h b/include/lldb/Target/ModuleCache.h index a060937e0614..782771c583c3 100644 --- a/include/lldb/Target/ModuleCache.h +++ b/include/lldb/Target/ModuleCache.h @@ -1,9 +1,8 @@ //===-- ModuleCache.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h index 6f8354ea3a27..ac0d28439545 100644 --- a/include/lldb/Target/ObjCLanguageRuntime.h +++ b/include/lldb/Target/ObjCLanguageRuntime.h @@ -1,26 +1,21 @@ //===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjCLanguageRuntime_h_ #define liblldb_ObjCLanguageRuntime_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Core/ThreadSafeDenseMap.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h index fe4fdee182f4..827d7b1daa76 100644 --- a/include/lldb/Target/OperatingSystem.h +++ b/include/lldb/Target/OperatingSystem.h @@ -1,19 +1,15 @@ //===-- OperatingSystem.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_OperatingSystem_h_ #define liblldb_OperatingSystem_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h index a5ee3265a223..8e0b854cc64d 100644 --- a/include/lldb/Target/PathMappingList.h +++ b/include/lldb/Target/PathMappingList.h @@ -1,23 +1,18 @@ //===-- PathMappingList.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PathMappingList_h_ #define liblldb_PathMappingList_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" -// Project includes namespace lldb_private { diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index d3fa5d71548a..a69fdbe6727b 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -1,17 +1,14 @@ //===-- Platform.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Platform_h_ #define liblldb_Platform_h_ -// C Includes -// C++ Includes #include #include #include @@ -19,8 +16,6 @@ #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index c8c25ef4c977..3cd5a4324db6 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -1,9 +1,8 @@ //===-- Process.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,10 +11,8 @@ #include "lldb/Host/Config.h" -// C Includes #include -// C++ Includes #include #include #include @@ -24,13 +21,8 @@ #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointSiteList.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Communication.h" -#include "lldb/Core/Event.h" -#include "lldb/Core/Listener.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/ThreadSafeValue.h" @@ -47,6 +39,9 @@ #include "lldb/Target/QueueList.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/Listener.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" @@ -319,7 +314,7 @@ class ProcessInstanceInfoMatch { NameMatch process_name_match_type) : m_match_info(), m_name_match_type(process_name_match_type), m_match_all_users(false) { - m_match_info.GetExecutableFile().SetFile(process_name, false, + m_match_info.GetExecutableFile().SetFile(process_name, FileSpec::Style::native); } @@ -2100,7 +2095,7 @@ class Process : public std::enable_shared_from_this, /// An error value. //------------------------------------------------------------------ virtual Status - GetMemoryRegions(std::vector ®ion_list); + GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list); virtual Status GetWatchpointSupportInfo(uint32_t &num) { Status error; diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h index 0e0d8548feb6..818e29ef357e 100644 --- a/include/lldb/Target/ProcessInfo.h +++ b/include/lldb/Target/ProcessInfo.h @@ -1,9 +1,8 @@ //===-- ProcessInfo.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h index 92c517a3e460..87ebe336887c 100644 --- a/include/lldb/Target/ProcessLaunchInfo.h +++ b/include/lldb/Target/ProcessLaunchInfo.h @@ -1,9 +1,8 @@ //===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -52,7 +51,10 @@ class ProcessLaunchInfo : public ProcessInfo { bool AppendSuppressFileAction(int fd, bool read, bool write); - void FinalizeFileActions(Target *target, bool default_to_use_pty); + // Redirect stdin/stdout/stderr to a pty, if no action for the respective file + // descriptor is specified. (So if stdin and stdout already have file actions, + // but stderr doesn't, then only stderr will be redirected to a pty.) + llvm::Error SetUpPtyRedirection(); size_t GetNumFileActions() const { return m_file_actions.size(); } @@ -131,8 +133,6 @@ class ProcessLaunchInfo : public ProcessInfo { m_listener_sp = listener_sp; } - lldb::ListenerSP GetListenerForProcess(Debugger &debugger); - lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; } void SetHijackListener(const lldb::ListenerSP &listener_sp) { diff --git a/include/lldb/Target/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h index 79f0b4cccd45..ade29c0a7cf7 100644 --- a/include/lldb/Target/ProcessStructReader.h +++ b/include/lldb/Target/ProcessStructReader.h @@ -1,9 +1,8 @@ //===---------------------ProcessStructReader.h ------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/Queue.h b/include/lldb/Target/Queue.h index 62cc3ccf2e2f..16b5014b23b3 100644 --- a/include/lldb/Target/Queue.h +++ b/include/lldb/Target/Queue.h @@ -1,9 +1,8 @@ //===-- Queue.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h index 76bcea36a2fa..9fd582cee214 100644 --- a/include/lldb/Target/QueueItem.h +++ b/include/lldb/Target/QueueItem.h @@ -1,23 +1,18 @@ //===-- QueueItem.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_QueueItem_h_ #define liblldb_QueueItem_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h index b35de13aa1e5..cdf2d004c350 100644 --- a/include/lldb/Target/QueueList.h +++ b/include/lldb/Target/QueueList.h @@ -1,9 +1,8 @@ //===-- QueueList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h index e4b407124c9f..4f9654f76343 100644 --- a/include/lldb/Target/RegisterCheckpoint.h +++ b/include/lldb/Target/RegisterCheckpoint.h @@ -1,9 +1,8 @@ //===-- RegisterCheckpoint.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h index 73a2930fd2b5..46602edf175b 100644 --- a/include/lldb/Target/RegisterContext.h +++ b/include/lldb/Target/RegisterContext.h @@ -1,19 +1,14 @@ //===-- RegisterContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContext_h_ #define liblldb_RegisterContext_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ExecutionContextScope.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/RegisterNumber.h b/include/lldb/Target/RegisterNumber.h index 1a0ab49bdce3..557480011d6f 100644 --- a/include/lldb/Target/RegisterNumber.h +++ b/include/lldb/Target/RegisterNumber.h @@ -1,9 +1,8 @@ //===-- RegisterNumber.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h index 0ed335a9d040..1c4878a3cfef 100644 --- a/include/lldb/Target/SectionLoadHistory.h +++ b/include/lldb/Target/SectionLoadHistory.h @@ -1,21 +1,17 @@ //===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SectionLoadHistory_h_ #define liblldb_SectionLoadHistory_h_ -// C Includes -// C++ Includes #include #include -// Project includes #include "lldb/lldb-public.h" namespace lldb_private { diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h index 1156c686df17..a8932473bc61 100644 --- a/include/lldb/Target/SectionLoadList.h +++ b/include/lldb/Target/SectionLoadList.h @@ -1,24 +1,19 @@ //===-- SectionLoadList.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SectionLoadList_h_ #define liblldb_SectionLoadList_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes #include "lldb/Core/Section.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index fa26089bb109..da60e0f0e30f 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -1,29 +1,24 @@ //===-- StackFrame.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StackFrame_h_ #define liblldb_StackFrame_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackID.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UserID.h" @@ -173,7 +168,7 @@ class StackFrame : public ExecutionContextScope, /// A SymbolContext reference which includes the types of information /// requested by resolve_scope, if they are available. //------------------------------------------------------------------ - const SymbolContext &GetSymbolContext(uint32_t resolve_scope); + const SymbolContext &GetSymbolContext(lldb::SymbolContextItem resolve_scope); //------------------------------------------------------------------ /// Return the Canonical Frame Address (DWARF term) for this frame. diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h index 0de90b3ba4ac..732a325d4107 100644 --- a/include/lldb/Target/StackFrameList.h +++ b/include/lldb/Target/StackFrameList.h @@ -1,9 +1,8 @@ //===-- StackFrameList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/StackFrameRecognizer.h b/include/lldb/Target/StackFrameRecognizer.h index 05ec905d117c..774226990d11 100644 --- a/include/lldb/Target/StackFrameRecognizer.h +++ b/include/lldb/Target/StackFrameRecognizer.h @@ -1,19 +1,14 @@ //===-- StackFrameRecognizer.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StackFrameRecognizer_h_ #define liblldb_StackFrameRecognizer_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Utility/StructuredData.h" @@ -34,6 +29,9 @@ class RecognizedStackFrame virtual lldb::ValueObjectListSP GetRecognizedArguments() { return m_arguments; } + virtual lldb::ValueObjectSP GetExceptionObject() { + return lldb::ValueObjectSP(); + } virtual ~RecognizedStackFrame(){}; protected: @@ -101,7 +99,8 @@ class ScriptedStackFrameRecognizer : public StackFrameRecognizer { class StackFrameRecognizerManager { public: static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, - ConstString &module, ConstString &symbol, + const ConstString &module, + const ConstString &symbol, bool first_instruction_only = true); static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h index 51e51a6c0741..950929d2a410 100644 --- a/include/lldb/Target/StackID.h +++ b/include/lldb/Target/StackID.h @@ -1,19 +1,14 @@ //===-- StackID.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StackID_h_ #define liblldb_StackID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h index 03f65b9566a4..3d8699ca4ba0 100644 --- a/include/lldb/Target/StopInfo.h +++ b/include/lldb/Target/StopInfo.h @@ -1,21 +1,16 @@ //===-- StopInfo.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StopInfo_h_ #define liblldb_StopInfo_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Target/StructuredDataPlugin.h b/include/lldb/Target/StructuredDataPlugin.h index 5ea265b05420..1be6cec97056 100644 --- a/include/lldb/Target/StructuredDataPlugin.h +++ b/include/lldb/Target/StructuredDataPlugin.h @@ -1,9 +1,8 @@ //===-- StructuredDataPlugin.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/SwiftLanguageRuntime.h b/include/lldb/Target/SwiftLanguageRuntime.h index ba5c1f0fe2bb..6e39f84235a9 100644 --- a/include/lldb/Target/SwiftLanguageRuntime.h +++ b/include/lldb/Target/SwiftLanguageRuntime.h @@ -34,8 +34,8 @@ class MemoryReader; class RemoteAddress; } -template class External; -template class RuntimeTarget; +template struct External; +template struct RuntimeTarget; namespace reflection { template class ReflectionContext; diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h index 06cc3ec2d012..8c0edd5b896d 100644 --- a/include/lldb/Target/SystemRuntime.h +++ b/include/lldb/Target/SystemRuntime.h @@ -1,19 +1,14 @@ //===-- SystemRuntime.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SystemRuntime_h_ #define liblldb_SystemRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include #include "lldb/Core/ModuleList.h" diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index 4ccb04ecd10e..10dc551071dd 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -1,17 +1,14 @@ //===-- Target.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Target_h_ #define liblldb_Target_h_ -// C Includes -// C++ Includes #include #include #include @@ -19,15 +16,12 @@ #include #include -// Other libraries and framework includes -// Project includes #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Breakpoint/BreakpointList.h" #include "lldb/Breakpoint/BreakpointName.h" #include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Core/Architecture.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/UserSettingsController.h" @@ -45,6 +39,7 @@ #include "lldb/Target/SectionLoadHistory.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Timeout.h" #include "lldb/lldb-public.h" @@ -212,6 +207,10 @@ class TargetProperties : public Properties { void SetDisplayRuntimeSupportValues(bool b); + bool GetDisplayRecognizedArguments() const; + + void SetDisplayRecognizedArguments(bool b); + const ProcessLaunchInfo &GetProcessLaunchInfo(); void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info); @@ -572,7 +571,9 @@ class Target : public std::enable_shared_from_this, //------------------------------------------------------------------ void Dump(Stream *s, lldb::DescriptionLevel description_level); - const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener, + // If listener_sp is null, the listener of the owning Debugger object will be + // used. + const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file); @@ -651,14 +652,12 @@ class Target : public std::enable_shared_from_this, // eLazyBoolCalculate, we use the current target setting, else we use the // values passed in. func_name_type_mask is or'ed values from the // FunctionNameType enum. - lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, - const char *func_name, - uint32_t func_name_type_mask, - lldb::LanguageType language, - lldb::addr_t offset, - LazyBool skip_prologue, bool internal, - bool request_hardware); + lldb::BreakpointSP CreateBreakpoint( + const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_name, + lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language, + lldb::addr_t offset, LazyBool skip_prologue, bool internal, + bool request_hardware); lldb::BreakpointSP CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp, @@ -680,20 +679,20 @@ class Target : public std::enable_shared_from_this, // the case where you just want to set a breakpoint on a set of names you // already know. func_name_type_mask is or'ed values from the // FunctionNameType enum. - lldb::BreakpointSP - CreateBreakpoint(const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, - const char *func_names[], size_t num_names, - uint32_t func_name_type_mask, lldb::LanguageType language, - lldb::addr_t offset, LazyBool skip_prologue, bool internal, - bool request_hardware); + lldb::BreakpointSP CreateBreakpoint( + const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_names[], + size_t num_names, lldb::FunctionNameType func_name_type_mask, + lldb::LanguageType language, lldb::addr_t offset, LazyBool skip_prologue, + bool internal, bool request_hardware); lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const std::vector &func_names, - uint32_t func_name_type_mask, lldb::LanguageType language, - lldb::addr_t m_offset, LazyBool skip_prologue, bool internal, + lldb::FunctionNameType func_name_type_mask, + lldb::LanguageType language, lldb::addr_t m_offset, + LazyBool skip_prologue, bool internal, bool request_hardware); // Use this to create a general breakpoint: @@ -980,28 +979,30 @@ class Target : public std::enable_shared_from_this, /// Set the architecture for this target. /// /// If the current target has no Images read in, then this just sets the - /// architecture, which will - /// be used to select the architecture of the ExecutableModule when that is - /// set. - /// If the current target has an ExecutableModule, then calling - /// SetArchitecture with a different + /// architecture, which will be used to select the architecture of the + /// ExecutableModule when that is set. If the current target has an + /// ExecutableModule, then calling SetArchitecture with a different /// architecture from the currently selected one will reset the - /// ExecutableModule to that slice - /// of the file backing the ExecutableModule. If the file backing the - /// ExecutableModule does not - /// contain a fork of this architecture, then this code will return false, and - /// the architecture - /// won't be changed. - /// If the input arch_spec is the same as the already set architecture, this - /// is a no-op. + /// ExecutableModule to that slice of the file backing the ExecutableModule. + /// If the file backing the ExecutableModule does not contain a fork of this + /// architecture, then this code will return false, and the architecture + /// won't be changed. If the input arch_spec is the same as the already set + /// architecture, this is a no-op. /// /// @param[in] arch_spec /// The new architecture. /// + /// @param[in] set_platform + /// If \b true, then the platform will be adjusted if the currently + /// selected platform is not compatible with the archicture being set. + /// If \b false, then just the architecture will be set even if the + /// currently selected platform isn't compatible (in case it might be + /// manually set following this function call). + /// /// @return /// \b true if the architecture was successfully set, \bfalse otherwise. //------------------------------------------------------------------ - bool SetArchitecture(const ArchSpec &arch_spec); + bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false); bool MergeArchitecture(const ArchSpec &arch_spec); @@ -1493,6 +1494,8 @@ class Target : public std::enable_shared_from_this, void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal); + void FinalizeFileActions(ProcessLaunchInfo &info); + DISALLOW_COPY_AND_ASSIGN(Target); }; diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h index 5e190656f039..3026524baf96 100644 --- a/include/lldb/Target/TargetList.h +++ b/include/lldb/Target/TargetList.h @@ -1,24 +1,19 @@ //===-- TargetList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_TargetList_h_ #define liblldb_TargetList_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Broadcaster.h" namespace lldb_private { diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index e7490417e535..020915d161f3 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -1,30 +1,25 @@ //===-- Thread.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Thread_h_ #define liblldb_Thread_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" -#include "lldb/Core/Event.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/RegisterCheckpoint.h" #include "lldb/Target/StackFrameList.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" @@ -284,7 +279,7 @@ class Thread : public std::enable_shared_from_this, /// message). //------------------------------------------------------------------ StructuredData::ObjectSP GetExtendedInfo() { - if (m_extended_info_fetched == false) { + if (!m_extended_info_fetched) { m_extended_info = FetchThreadExtendedInfo(); m_extended_info_fetched = true; } @@ -1268,6 +1263,10 @@ class Thread : public std::enable_shared_from_this, //---------------------------------------------------------------------- virtual uint64_t GetExtendedBacktraceToken() { return LLDB_INVALID_ADDRESS; } + lldb::ValueObjectSP GetCurrentException(); + + lldb::ThreadSP GetCurrentExceptionBacktrace(); + protected: friend class ThreadPlan; friend class ThreadList; diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h index dd5e81c1af48..29ea827203e5 100644 --- a/include/lldb/Target/ThreadCollection.h +++ b/include/lldb/Target/ThreadCollection.h @@ -1,9 +1,8 @@ //===-- ThreadCollection.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h index 6285cb1e0fb4..de680f328504 100644 --- a/include/lldb/Target/ThreadList.h +++ b/include/lldb/Target/ThreadList.h @@ -1,9 +1,8 @@ //===-- ThreadList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h index c39fc23e7484..75d2f2b77f9b 100644 --- a/include/lldb/Target/ThreadPlan.h +++ b/include/lldb/Target/ThreadPlan.h @@ -1,22 +1,17 @@ //===-- ThreadPlan.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlan_h_ #define liblldb_ThreadPlan_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h index 7a8b7eb20bb2..f42885604c3f 100644 --- a/include/lldb/Target/ThreadPlanBase.h +++ b/include/lldb/Target/ThreadPlanBase.h @@ -1,19 +1,14 @@ //===-- ThreadPlanBase.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanFundamental_h_ #define liblldb_ThreadPlanFundamental_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index 66c82652efde..dbe74e0dc54b 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -1,19 +1,14 @@ //===-- ThreadPlanCallFunction.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanCallFunction_h_ #define liblldb_ThreadPlanCallFunction_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/lldb-enumerations.h" diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h index d58f7f050dbe..c21e4d3cf3f7 100644 --- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h +++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h @@ -1,20 +1,15 @@ //===-- ThreadPlanCallFunctionUsingABI.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanCallFunctionUsingABI_h_ #define liblldb_ThreadPlanCallFunctionUsingABI_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanCallFunction.h" diff --git a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h index c7ea368cca6a..00bdda0b6e99 100644 --- a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h +++ b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h @@ -1,9 +1,8 @@ //===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h index 5fe80927ca21..637215582410 100644 --- a/include/lldb/Target/ThreadPlanCallUserExpression.h +++ b/include/lldb/Target/ThreadPlanCallUserExpression.h @@ -1,20 +1,15 @@ //===-- ThreadPlanCallUserExpression.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanCallUserExpression_h_ #define liblldb_ThreadPlanCallUserExpression_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanCallFunction.h" diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h index 41daca6dc555..0e253e34f3ef 100644 --- a/include/lldb/Target/ThreadPlanPython.h +++ b/include/lldb/Target/ThreadPlanPython.h @@ -1,22 +1,17 @@ //===-- ThreadPlanPython.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlan_Python_h_ #define liblldb_ThreadPlan_Python_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h index 8e91fb9472a7..d82a9fad548a 100644 --- a/include/lldb/Target/ThreadPlanRunToAddress.h +++ b/include/lldb/Target/ThreadPlanRunToAddress.h @@ -1,21 +1,16 @@ //===-- ThreadPlanRunToAddress.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanRunToAddress_h_ #define liblldb_ThreadPlanRunToAddress_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlan.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h index 863c89823b4f..1602736e9c02 100644 --- a/include/lldb/Target/ThreadPlanShouldStopHere.h +++ b/include/lldb/Target/ThreadPlanShouldStopHere.h @@ -1,19 +1,14 @@ //===-- ThreadPlanShouldStopHere.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanShouldStopHere_h_ #define liblldb_ThreadPlanShouldStopHere_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlan.h" namespace lldb_private { diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h index 4f7097c9d1a8..76746d1e3346 100644 --- a/include/lldb/Target/ThreadPlanStepInRange.h +++ b/include/lldb/Target/ThreadPlanStepInRange.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepInRange.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepInRange_h_ #define liblldb_ThreadPlanStepInRange_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h index 3916338046f8..127de417f6eb 100644 --- a/include/lldb/Target/ThreadPlanStepInstruction.h +++ b/include/lldb/Target/ThreadPlanStepInstruction.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepInstruction.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepInstruction_h_ #define liblldb_ThreadPlanStepInstruction_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h index 38fe939dc40c..199feca043a5 100644 --- a/include/lldb/Target/ThreadPlanStepOut.h +++ b/include/lldb/Target/ThreadPlanStepOut.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepOut.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepOut_h_ #define liblldb_ThreadPlanStepOut_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanShouldStopHere.h" diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index e799ec5a44ff..7df7049b568a 100644 --- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepOverBreakpoint.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepOverBreakpoint_h_ #define liblldb_ThreadPlanStepOverBreakpoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h index 84fdb0ddcf99..30763e3861fa 100644 --- a/include/lldb/Target/ThreadPlanStepOverRange.h +++ b/include/lldb/Target/ThreadPlanStepOverRange.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepOverRange.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepOverRange_h_ #define liblldb_ThreadPlanStepOverRange_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h index 65bc1671cb1e..93d54ad7dfd5 100644 --- a/include/lldb/Target/ThreadPlanStepRange.h +++ b/include/lldb/Target/ThreadPlanStepRange.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepRange_h_ #define liblldb_ThreadPlanStepRange_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h index ad1f28386ff4..0d0621227b53 100644 --- a/include/lldb/Target/ThreadPlanStepThrough.h +++ b/include/lldb/Target/ThreadPlanStepThrough.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepThrough.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepThrough_h_ #define liblldb_ThreadPlanStepThrough_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h index 037b31ff7259..9a5934a36d7d 100644 --- a/include/lldb/Target/ThreadPlanStepUntil.h +++ b/include/lldb/Target/ThreadPlanStepUntil.h @@ -1,19 +1,14 @@ //===-- ThreadPlanStepUntil.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanStepUntil_h_ #define liblldb_ThreadPlanStepUntil_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h index 65115383efaa..40d4e17dd107 100644 --- a/include/lldb/Target/ThreadPlanTracer.h +++ b/include/lldb/Target/ThreadPlanTracer.h @@ -1,23 +1,18 @@ //===-- ThreadPlanTracer.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadPlanTracer_h_ #define liblldb_ThreadPlanTracer_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h index 34baf8046261..f1710f8c6ec2 100644 --- a/include/lldb/Target/ThreadSpec.h +++ b/include/lldb/Target/ThreadSpec.h @@ -1,9 +1,8 @@ //===-- ThreadSpec.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h index 7ec683585f8e..4be59c4827fd 100644 --- a/include/lldb/Target/UnixSignals.h +++ b/include/lldb/Target/UnixSignals.h @@ -1,23 +1,18 @@ //===-- UnixSignals.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_UnixSignals_h_ #define lldb_UnixSignals_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" #include "llvm/ADT/Optional.h" diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h index a50e8d4a7bdd..043302204f8f 100644 --- a/include/lldb/Target/Unwind.h +++ b/include/lldb/Target/Unwind.h @@ -1,21 +1,16 @@ //===-- Unwind.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Unwind_h_ #define liblldb_Unwind_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Target/UnwindAssembly.h b/include/lldb/Target/UnwindAssembly.h index 3028ffeaa51d..7c42df2d6afd 100644 --- a/include/lldb/Target/UnwindAssembly.h +++ b/include/lldb/Target/UnwindAssembly.h @@ -1,9 +1,8 @@ //===-- UnwindAssembly.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/AnsiTerminal.h b/include/lldb/Utility/AnsiTerminal.h index b5ff239f800d..1473c60eeaf2 100644 --- a/include/lldb/Utility/AnsiTerminal.h +++ b/include/lldb/Utility/AnsiTerminal.h @@ -1,9 +1,8 @@ //===---------------------AnsiTerminal.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/ArchSpec.h b/include/lldb/Utility/ArchSpec.h index 680e9b1b9ea6..89eb3ef3d60e 100644 --- a/include/lldb/Utility/ArchSpec.h +++ b/include/lldb/Utility/ArchSpec.h @@ -1,9 +1,8 @@ //===-- ArchSpec.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,11 +14,11 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private-enumerations.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" -#include // for size_t -#include // for uint32_t -#include // for string +#include +#include +#include namespace lldb_private { @@ -371,6 +370,7 @@ class ArchSpec { bool IsValid() const { return m_core >= eCore_arm_generic && m_core < kNumCores; } + explicit operator bool() const { return IsValid(); } bool TripleVendorWasSpecified() const { return !m_triple.getVendorName().empty(); diff --git a/include/lldb/Utility/Args.h b/include/lldb/Utility/Args.h index aaf044306c10..882fff383614 100644 --- a/include/lldb/Utility/Args.h +++ b/include/lldb/Utility/Args.h @@ -1,9 +1,8 @@ //===-- Args.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Baton.h b/include/lldb/Utility/Baton.h index 59999e4697fa..eb3c51c94583 100644 --- a/include/lldb/Utility/Baton.h +++ b/include/lldb/Utility/Baton.h @@ -1,19 +1,18 @@ //===-- Baton.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_Baton_h_ #define lldb_Baton_h_ -#include "lldb/lldb-enumerations.h" // for DescriptionLevel +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" -#include // for unique_ptr +#include namespace lldb_private { class Stream; diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Utility/Broadcaster.h similarity index 97% rename from include/lldb/Core/Broadcaster.h rename to include/lldb/Utility/Broadcaster.h index 4851007c9a2a..5dd079b3ae56 100644 --- a/include/lldb/Core/Broadcaster.h +++ b/include/lldb/Utility/Broadcaster.h @@ -1,28 +1,27 @@ //===-- Broadcaster.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Broadcaster_h_ -#define liblldb_Broadcaster_h_ +#ifndef LLDB_UTILITY_BROADCASTER_H +#define LLDB_UTILITY_BROADCASTER_H #include "lldb/Utility/ConstString.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for ListenerSP, EventSP, Broadcast... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include "llvm/ADT/SmallVector.h" -#include // for uint32_t, UINT32_MAX +#include #include -#include // for shared_ptr, operator==, enable... +#include #include -#include // for set +#include #include -#include // for pair +#include #include namespace lldb_private { @@ -223,7 +222,7 @@ class BroadcasterManager }; //---------------------------------------------------------------------- -/// @class Broadcaster Broadcaster.h "lldb/Core/Broadcaster.h" An event +/// @class Broadcaster Broadcaster.h "lldb/Utility/Broadcaster.h" An event /// broadcasting class. /// /// The Broadcaster class is designed to be subclassed by objects that wish to @@ -595,4 +594,4 @@ class Broadcaster { } // namespace lldb_private -#endif // liblldb_Broadcaster_h_ +#endif // LLDB_UTILITY_BROADCASTER_H diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h index ef460ddd5e7f..6cd5f332ef95 100644 --- a/include/lldb/Utility/CleanUp.h +++ b/include/lldb/Utility/CleanUp.h @@ -1,9 +1,8 @@ //===-- CleanUp.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/CompletionRequest.h b/include/lldb/Utility/CompletionRequest.h index ef75474813e0..b4e567c0340d 100644 --- a/include/lldb/Utility/CompletionRequest.h +++ b/include/lldb/Utility/CompletionRequest.h @@ -1,9 +1,8 @@ //===-- CompletionRequest.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,11 +10,50 @@ #define LLDB_UTILITY_COMPLETIONREQUEST_H #include "lldb/Utility/Args.h" +#include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/StringList.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" namespace lldb_private { +class CompletionResult { + //---------------------------------------------------------- + /// A single completion and all associated data. + //---------------------------------------------------------- + struct Completion { + Completion(llvm::StringRef completion, llvm::StringRef description) + : m_completion(completion.str()), m_descripton(description.str()) {} + + std::string m_completion; + std::string m_descripton; + + /// Generates a string that uniquely identifies this completion result. + std::string GetUniqueKey() const; + }; + std::vector m_results; + + /// List of added completions so far. Used to filter out duplicates. + llvm::StringSet<> m_added_values; + +public: + void AddResult(llvm::StringRef completion, llvm::StringRef description); + + //---------------------------------------------------------- + /// Adds all collected completion matches to the given list. + /// The list will be cleared before the results are added. The number of + /// results here is guaranteed to be equal to GetNumberOfResults(). + //---------------------------------------------------------- + void GetMatches(StringList &matches) const; + + //---------------------------------------------------------- + /// Adds all collected completion descriptions to the given list. + /// The list will be cleared before the results are added. The number of + /// results here is guaranteed to be equal to GetNumberOfResults(). + //---------------------------------------------------------- + void GetDescriptions(StringList &descriptions) const; + + std::size_t GetNumberOfResults() const { return m_results.size(); } +}; //---------------------------------------------------------------------- /// @class CompletionRequest CompletionRequest.h @@ -46,13 +84,13 @@ class CompletionRequest { /// completion from match_start_point, and return match_return_elements /// elements. /// - /// @param [out] matches - /// A list of matches that will be filled by the different completion - /// handlers. + /// @param [out] result + /// The CompletionResult that will be filled with the results after this + /// request has been handled. //---------------------------------------------------------- CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos, int match_start_point, int max_return_elements, - StringList &matches); + CompletionResult &result); llvm::StringRef GetRawLine() const { return m_command; } @@ -84,10 +122,11 @@ class CompletionRequest { /// afterwards. /// /// @param match The suggested completion. - void AddCompletion(llvm::StringRef completion) { - // Add the completion if we haven't seen the same value before. - if (m_match_set.insert(completion).second) - m_matches->AppendString(completion); + /// @param match An optional description of the completion string. The + /// description will be displayed to the user alongside the completion. + void AddCompletion(llvm::StringRef completion, + llvm::StringRef description = "") { + m_result.AddResult(completion, description); } /// Adds multiple possible completion strings. @@ -100,7 +139,25 @@ class CompletionRequest { AddCompletion(completions.GetStringAtIndex(i)); } - std::size_t GetNumberOfMatches() const { return m_matches->GetSize(); } + /// Adds multiple possible completion strings alongside their descriptions. + /// + /// The number of completions and descriptions must be identical. + /// + /// \param completions The list of completions. + /// \param completions The list of descriptions. + /// + /// @see AddCompletion + void AddCompletions(const StringList &completions, + const StringList &descriptions) { + lldbassert(completions.GetSize() == descriptions.GetSize()); + for (std::size_t i = 0; i < completions.GetSize(); ++i) + AddCompletion(completions.GetStringAtIndex(i), + descriptions.GetStringAtIndex(i)); + } + + std::size_t GetNumberOfMatches() const { + return m_result.GetNumberOfResults(); + } llvm::StringRef GetCursorArgument() const { return GetParsedLine().GetArgumentAtIndex(GetCursorIndex()); @@ -134,14 +191,11 @@ class CompletionRequest { /// after the completion.) \bfalse otherwise. bool m_word_complete = false; - // Note: This list is kept private. This is by design to prevent that any - // completion depends on any already computed completion from another backend. - // Note: We don't own the list. It's owned by the creator of the - // CompletionRequest object. - StringList *m_matches; - - /// List of added completions so far. Used to filter out duplicates. - llvm::StringSet<> m_match_set; + /// The result this request is supposed to fill out. + /// We keep this object private to ensure that no backend can in any way + /// depend on already calculated completions (which would make debugging and + /// testing them much more complicated). + CompletionResult &m_result; }; } // namespace lldb_private diff --git a/include/lldb/Utility/Connection.h b/include/lldb/Utility/Connection.h index 1b0801378f84..72e94b225d0d 100644 --- a/include/lldb/Utility/Connection.h +++ b/include/lldb/Utility/Connection.h @@ -1,25 +1,24 @@ //===-- Connection.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Connection_h_ #define liblldb_Connection_h_ -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ConnectionStatus -#include "lldb/lldb-forward.h" // for IOObjectSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include // for micro +#include #include -#include // for size_t +#include namespace lldb_private { class Status; diff --git a/include/lldb/Utility/ConstString.h b/include/lldb/Utility/ConstString.h index 1c580caf2903..8fd882fa5af8 100644 --- a/include/lldb/Utility/ConstString.h +++ b/include/lldb/Utility/ConstString.h @@ -1,9 +1,8 @@ //===-- ConstString.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,9 +10,9 @@ #define liblldb_ConstString_h_ #include "llvm/ADT/StringRef.h" -#include "llvm/Support/FormatVariadic.h" // for format_provider +#include "llvm/Support/FormatVariadic.h" -#include // for size_t +#include namespace lldb_private { class Stream; @@ -253,7 +252,7 @@ class ConstString { //------------------------------------------------------------------ /// Clear this object's state. /// - /// Clear any contained string and reset the value to the an empty string + /// Clear any contained string and reset the value to the empty string /// value. //------------------------------------------------------------------ void Clear() { m_string = nullptr; } diff --git a/include/lldb/Utility/DataBuffer.h b/include/lldb/Utility/DataBuffer.h index 05cb60920737..94c33dcc647d 100644 --- a/include/lldb/Utility/DataBuffer.h +++ b/include/lldb/Utility/DataBuffer.h @@ -1,9 +1,8 @@ //===-- DataBuffer.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/DataBufferHeap.h b/include/lldb/Utility/DataBufferHeap.h index d64e5b7563a9..a4f10873d6e4 100644 --- a/include/lldb/Utility/DataBufferHeap.h +++ b/include/lldb/Utility/DataBufferHeap.h @@ -1,9 +1,8 @@ //===-- DataBufferHeap.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #define liblldb_DataBufferHeap_h_ #include "lldb/Utility/DataBuffer.h" -#include "lldb/lldb-types.h" // for offset_t -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-types.h" +#include "llvm/ADT/StringRef.h" -#include // for uint8_t, uint64_t +#include #include namespace lldb_private { @@ -90,7 +89,8 @@ class DataBufferHeap : public DataBuffer { /// Set the number of bytes in the data buffer. /// /// Sets the number of bytes that this object should be able to contain. - /// This can be used prior to copying data into the buffer. + /// This can be used prior to copying data into the buffer. Note that this + /// zero-initializes up to \p byte_size bytes. /// /// @param[in] byte_size /// The new size in bytes that this data buffer should attempt diff --git a/include/lldb/Utility/DataBufferLLVM.h b/include/lldb/Utility/DataBufferLLVM.h index d76582cbf47c..e643851efeab 100644 --- a/include/lldb/Utility/DataBufferLLVM.h +++ b/include/lldb/Utility/DataBufferLLVM.h @@ -1,9 +1,8 @@ //===--- DataBufferLLVM.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #define LLDB_CORE_DATABUFFERLLVM_H #include "lldb/Utility/DataBuffer.h" -#include "lldb/lldb-types.h" // for offset_t +#include "lldb/lldb-types.h" #include -#include // for uint8_t, uint64_t +#include namespace llvm { class WritableMemoryBuffer; @@ -23,16 +22,11 @@ class Twine; namespace lldb_private { +class FileSystem; class DataBufferLLVM : public DataBuffer { public: ~DataBufferLLVM(); - static std::shared_ptr - CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size, uint64_t Offset); - - static std::shared_ptr - CreateFromPath(const llvm::Twine &Path); - uint8_t *GetBytes() override; const uint8_t *GetBytes() const override; lldb::offset_t GetByteSize() const override; @@ -40,6 +34,7 @@ class DataBufferLLVM : public DataBuffer { char *GetChars() { return reinterpret_cast(GetBytes()); } private: + friend FileSystem; /// Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a valid /// pointer. explicit DataBufferLLVM(std::unique_ptr Buffer); diff --git a/include/lldb/Utility/DataEncoder.h b/include/lldb/Utility/DataEncoder.h index c1214705c726..31c80cc42582 100644 --- a/include/lldb/Utility/DataEncoder.h +++ b/include/lldb/Utility/DataEncoder.h @@ -1,9 +1,8 @@ //===-- DataEncoder.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,12 +11,12 @@ #if defined(__cplusplus) -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ByteOrder -#include "lldb/lldb-forward.h" // for DataBufferSP -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include // for size_t +#include #include namespace lldb_private { diff --git a/include/lldb/Utility/DataExtractor.h b/include/lldb/Utility/DataExtractor.h index 50c88db8e358..d7cc94b4b210 100644 --- a/include/lldb/Utility/DataExtractor.h +++ b/include/lldb/Utility/DataExtractor.h @@ -1,9 +1,8 @@ //===-- DataExtractor.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,9 +10,10 @@ #define LLDB_UTILITY_DATAEXTRACTOR_H #include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder -#include "lldb/lldb-forward.h" // for DataBufferSP +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" +#include "llvm/ADT/ArrayRef.h" #include #include @@ -29,7 +29,6 @@ namespace llvm { template class SmallVectorImpl; } -// C++ Includes namespace lldb_private { @@ -1095,6 +1094,10 @@ class DataExtractor { void Checksum(llvm::SmallVectorImpl &dest, uint64_t max_data = 0); + llvm::ArrayRef GetData() const { + return {GetDataStart(), size_t(GetByteSize())}; + } + protected: //------------------------------------------------------------------ // Member variables diff --git a/include/lldb/Utility/Endian.h b/include/lldb/Utility/Endian.h index 2a102b63aa10..11929f5d13ca 100644 --- a/include/lldb/Utility/Endian.h +++ b/include/lldb/Utility/Endian.h @@ -1,9 +1,8 @@ //===-- Endian.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Environment.h b/include/lldb/Utility/Environment.h index ed0a36d7b3aa..398b3bae3106 100644 --- a/include/lldb/Utility/Environment.h +++ b/include/lldb/Utility/Environment.h @@ -1,9 +1,8 @@ //===-- Environment.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Core/Event.h b/include/lldb/Utility/Event.h similarity index 92% rename from include/lldb/Core/Event.h rename to include/lldb/Utility/Event.h index fa3017057675..dc95da609ad2 100644 --- a/include/lldb/Core/Event.h +++ b/include/lldb/Utility/Event.h @@ -1,30 +1,29 @@ //===-- Event.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Event_h_ -#define liblldb_Event_h_ +#ifndef LLDB_UTILITY_EVENT_H +#define LLDB_UTILITY_EVENT_H -#include "lldb/Core/Broadcaster.h" -#include "lldb/Host/Predicate.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/StructuredData.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include #include #include -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { class Event; @@ -271,4 +270,4 @@ class Event { } // namespace lldb_private -#endif // liblldb_Event_h_ +#endif // LLDB_UTILITY_EVENT_H diff --git a/include/lldb/Utility/FileCollector.h b/include/lldb/Utility/FileCollector.h new file mode 100644 index 000000000000..d7bdcf479f8a --- /dev/null +++ b/include/lldb/Utility/FileCollector.h @@ -0,0 +1,74 @@ +//===-- FileCollector.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 LLDB_UTILITY_FILE_COLLECTOR_H +#define LLDB_UTILITY_FILE_COLLECTOR_H + +#include "lldb/Utility/FileSpec.h" + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace lldb_private { + +/// Collects files into a directory and generates a mapping that can be used by +/// the VFS. +class FileCollector { +public: + FileCollector(const FileSpec &root); + + void AddFile(const llvm::Twine &file); + void AddFile(const FileSpec &file) { return AddFile(file.GetPath()); } + + /// Write the yaml mapping (for the VFS) to the given file. + std::error_code WriteMapping(const FileSpec &mapping_file); + + /// Copy the files into the root directory. + /// + /// When stop_on_error is true (the default) we abort as soon as one file + /// cannot be copied. This is relatively common, for example when a file was + /// removed after it was added to the mapping. + std::error_code CopyFiles(bool stop_on_error = true); + +protected: + void AddFileImpl(llvm::StringRef src_path); + + bool MarkAsSeen(llvm::StringRef path) { return m_seen.insert(path).second; } + + bool GetRealPath(llvm::StringRef src_path, + llvm::SmallVectorImpl &result); + + void AddFileToMapping(llvm::StringRef virtual_path, + llvm::StringRef real_path) { + m_vfs_writer.addFileMapping(virtual_path, real_path); + } + + /// Synchronizes adding files. + std::mutex m_mutex; + + /// The root directory where files are copied. + FileSpec m_root; + + /// Tracks already seen files so they can be skipped. + llvm::StringSet<> m_seen; + + /// The yaml mapping writer. + llvm::vfs::YAMLVFSWriter m_vfs_writer; + + /// Caches real_path calls when resolving symlinks. + llvm::StringMap m_symlink_map; +}; + +} // namespace lldb_private + +#endif // LLDB_UTILITY_FILE_COLLECTOR_H diff --git a/include/lldb/Utility/FileSpec.h b/include/lldb/Utility/FileSpec.h index d062ba598ccc..21fc990ba3c7 100644 --- a/include/lldb/Utility/FileSpec.h +++ b/include/lldb/Utility/FileSpec.h @@ -1,22 +1,17 @@ //===-- FileSpec.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_FileSpec_h_ #define liblldb_FileSpec_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "llvm/ADT/StringRef.h" @@ -24,8 +19,8 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Path.h" -#include // for size_t -#include // for uint32_t, uint64_t +#include +#include namespace lldb_private { class Stream; @@ -70,23 +65,19 @@ class FileSpec { /// /// Takes a path to a file which can be just a filename, or a full path. If /// \a path is not nullptr or empty, this function will call - /// FileSpec::SetFile (const char *path, bool resolve). + /// FileSpec::SetFile (const char *path). /// /// @param[in] path /// The full or partial path to a file. /// - /// @param[in] resolve_path - /// If \b true, then we resolve the path, removing stray ../.. and so - /// forth, - /// if \b false we trust the path is in canonical form already. + /// @param[in] style + /// The style of the path /// - /// @see FileSpec::SetFile (const char *path, bool resolve) + /// @see FileSpec::SetFile (const char *path) //------------------------------------------------------------------ - explicit FileSpec(llvm::StringRef path, bool resolve_path, - Style style = Style::native); + explicit FileSpec(llvm::StringRef path, Style style = Style::native); - explicit FileSpec(llvm::StringRef path, bool resolve_path, - const llvm::Triple &Triple); + explicit FileSpec(llvm::StringRef path, const llvm::Triple &Triple); //------------------------------------------------------------------ /// Copy constructor @@ -272,47 +263,6 @@ class FileSpec { //------------------------------------------------------------------ void Dump(Stream *s) const; - //------------------------------------------------------------------ - /// Existence test. - /// - /// @return - /// \b true if the file exists on disk, \b false otherwise. - //------------------------------------------------------------------ - bool Exists() const; - - //------------------------------------------------------------------ - /// Check if a file is readable by the current user - /// - /// @return - /// \b true if the file exists on disk and is readable, \b false - /// otherwise. - //------------------------------------------------------------------ - bool Readable() const; - - //------------------------------------------------------------------ - /// Expanded existence test. - /// - /// Call into the Host to see if it can help find the file (e.g. by - /// searching paths set in the environment, etc.). - /// - /// If found, sets the value of m_directory to the directory where the file - /// was found. - /// - /// @return - /// \b true if was able to find the file using expanded search - /// methods, \b false otherwise. - //------------------------------------------------------------------ - bool ResolveExecutableLocation(); - - //------------------------------------------------------------------ - /// Canonicalize this file path (basically running the static - /// FileSpec::Resolve method on it). Useful if you asked us not to resolve - /// the file path when you set the file. - //------------------------------------------------------------------ - bool ResolvePath(); - - uint64_t GetByteSize() const; - Style GetPathStyle() const; //------------------------------------------------------------------ @@ -375,6 +325,13 @@ class FileSpec { //------------------------------------------------------------------ bool IsAbsolute() const; + /// Make the FileSpec absolute by treating it relative to \a dir. Absolute + /// FileSpecs are never changed by this function. + void MakeAbsolute(const FileSpec &dir); + + /// Temporary helper for FileSystem change. + void SetPath(llvm::StringRef p) { SetFile(p); } + //------------------------------------------------------------------ /// Extract the full path to the file. /// @@ -449,19 +406,6 @@ class FileSpec { //------------------------------------------------------------------ ConstString GetFileNameStrippingExtension() const; - //------------------------------------------------------------------ - /// Return the current permissions of the path. - /// - /// Returns a bitmask for the current permissions of the file ( zero or more - /// of the permission bits defined in File::Permissions). - /// - /// @return - /// Zero if the file doesn't exist or we are unable to get - /// information for the file, otherwise one or more permission - /// bits from the File::Permissions enumeration. - //------------------------------------------------------------------ - uint32_t GetPermissions() const; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// @@ -490,10 +434,9 @@ class FileSpec { /// If \b true, then we will try to resolve links the path using /// the static FileSpec::Resolve. //------------------------------------------------------------------ - void SetFile(llvm::StringRef path, bool resolve_path, Style style); + void SetFile(llvm::StringRef path, Style style); - void SetFile(llvm::StringRef path, bool resolve_path, - const llvm::Triple &Triple); + void SetFile(llvm::StringRef path, const llvm::Triple &Triple); bool IsResolved() const { return m_is_resolved; } @@ -512,16 +455,6 @@ class FileSpec { //------------------------------------------------------------------ void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; } - //------------------------------------------------------------------ - /// Resolves user name and links in \a path, and overwrites the input - /// argument with the resolved path. - /// - /// @param[in] path - /// Input path to be resolved, in the form of a llvm::SmallString or - /// similar. - //------------------------------------------------------------------ - static void Resolve(llvm::SmallVectorImpl &path); - FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const; FileSpec CopyByRemovingLastPathComponent() const; @@ -542,32 +475,11 @@ class FileSpec { ConstString GetLastPathComponent() const; - enum EnumerateDirectoryResult { - eEnumerateDirectoryResultNext, // Enumerate next entry in the current - // directory - eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a - // directory or symlink, or next if not - eEnumerateDirectoryResultQuit // Stop directory enumerations at any level - }; - - typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)( - void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec); - - static void EnumerateDirectory(llvm::StringRef dir_path, - bool find_directories, bool find_files, - bool find_other, - EnumerateDirectoryCallbackType callback, - void *callback_baton); - - typedef std::function - DirectoryCallback; - protected: //------------------------------------------------------------------ // Convenience method for setting the file without changing the style. //------------------------------------------------------------------ - void SetFile(llvm::StringRef path, bool resolve_path); + void SetFile(llvm::StringRef path); //------------------------------------------------------------------ // Member variables diff --git a/include/lldb/Utility/Flags.h b/include/lldb/Utility/Flags.h index 5ef6122d1146..8c68e4b77e49 100644 --- a/include/lldb/Utility/Flags.h +++ b/include/lldb/Utility/Flags.h @@ -1,9 +1,8 @@ //===-- Flags.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/IOObject.h b/include/lldb/Utility/IOObject.h index 61f288183850..9199ddbb5793 100644 --- a/include/lldb/Utility/IOObject.h +++ b/include/lldb/Utility/IOObject.h @@ -1,9 +1,8 @@ //===-- IOObject.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h index dcb340a05ef1..d9c61aa958cc 100644 --- a/include/lldb/Utility/Iterable.h +++ b/include/lldb/Utility/Iterable.h @@ -1,21 +1,16 @@ //===-- Iterable.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Iterable_h_ #define liblldb_Iterable_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes namespace lldb_private { diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h index 6fe1945ea227..add7da9146a4 100644 --- a/include/lldb/Utility/JSON.h +++ b/include/lldb/Utility/JSON.h @@ -1,9 +1,8 @@ //===---------------------JSON.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/LLDBAssert.h b/include/lldb/Utility/LLDBAssert.h index 9d9f3ceefab0..7008dd82496d 100644 --- a/include/lldb/Utility/LLDBAssert.h +++ b/include/lldb/Utility/LLDBAssert.h @@ -1,9 +1,8 @@ //===----------------- LLDBAssert.h ------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,7 +13,8 @@ #define lldbassert(x) assert(x) #else #define lldbassert(x) \ - lldb_private::lldb_assert(x, #x, __FUNCTION__, __FILE__, __LINE__) + lldb_private::lldb_assert(static_cast(x), #x, __FUNCTION__, __FILE__, \ + __LINE__) #endif namespace lldb_private { diff --git a/include/lldb/Core/Listener.h b/include/lldb/Utility/Listener.h similarity index 89% rename from include/lldb/Core/Listener.h rename to include/lldb/Utility/Listener.h index 3d12f8fb3391..97c1b9fe8548 100644 --- a/include/lldb/Core/Listener.h +++ b/include/lldb/Utility/Listener.h @@ -1,31 +1,30 @@ //===-- Listener.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Select_h_ -#define liblldb_Select_h_ +#ifndef LLDB_UTILITY_LISTENER_H +#define LLDB_UTILITY_LISTENER_H -#include "lldb/Core/Broadcaster.h" // for Broadcaster::BroadcasterImplWP +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Timeout.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for BroadcasterManagerWP, EventSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include #include #include -#include // for owner_less, enable_shared_from_this +#include #include -#include // for micro +#include #include #include -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { class ConstString; @@ -158,4 +157,4 @@ class Listener : public std::enable_shared_from_this { } // namespace lldb_private -#endif // liblldb_Select_h_ +#endif // LLDB_UTILITY_LISTENER_H diff --git a/include/lldb/Utility/Log.h b/include/lldb/Utility/Log.h index 62776bdb281b..d3ce82fecd23 100644 --- a/include/lldb/Utility/Log.h +++ b/include/lldb/Utility/Log.h @@ -1,9 +1,8 @@ //===-- Log.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,8 +14,8 @@ #include "lldb/lldb-defines.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringMap.h" // for StringMap -#include "llvm/ADT/StringRef.h" // for StringRef, StringLiteral +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ManagedStatic.h" @@ -25,9 +24,9 @@ #include #include #include -#include // for shared_ptr -#include // for string -#include // for forward +#include +#include +#include namespace llvm { class raw_ostream; diff --git a/include/lldb/Utility/Logging.h b/include/lldb/Utility/Logging.h index 2c75a3bf218b..26146a89fca4 100644 --- a/include/lldb/Utility/Logging.h +++ b/include/lldb/Utility/Logging.h @@ -1,9 +1,8 @@ //===-- Logging.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/NameMatches.h b/include/lldb/Utility/NameMatches.h index bc9ec703770a..38900df2bd5d 100644 --- a/include/lldb/Utility/NameMatches.h +++ b/include/lldb/Utility/NameMatches.h @@ -1,9 +1,8 @@ //===-- NameMatches.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_UTILITY_NAMEMATCHES_H diff --git a/include/lldb/Host/Predicate.h b/include/lldb/Utility/Predicate.h similarity index 95% rename from include/lldb/Host/Predicate.h rename to include/lldb/Utility/Predicate.h index d8128e71c53e..3e9e6494061c 100644 --- a/include/lldb/Host/Predicate.h +++ b/include/lldb/Utility/Predicate.h @@ -1,25 +1,20 @@ //===-- Predicate.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Predicate_h_ #define liblldb_Predicate_h_ -// C Includes #include #include -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Timeout.h" #include "lldb/lldb-defines.h" @@ -34,11 +29,11 @@ typedef enum { eBroadcastNever, ///< No broadcast will be sent when the value is modified. eBroadcastAlways, ///< Always send a broadcast when the value is modified. eBroadcastOnChange ///< Only broadcast if the value changes when the value is - ///modified. + /// modified. } PredicateBroadcastType; //---------------------------------------------------------------------- -/// @class Predicate Predicate.h "lldb/Host/Predicate.h" +/// @class Predicate Predicate.h "lldb/Utility/Predicate.h" /// A C++ wrapper class for providing threaded access to a value of /// type T. /// @@ -220,8 +215,8 @@ template class Predicate { T m_value; ///< The templatized value T that we are protecting access to mutable std::mutex m_mutex; ///< The mutex to use when accessing the data std::condition_variable m_condition; ///< The pthread condition variable to - ///use for signaling that data available - ///or changed. + /// use for signaling that data available + /// or changed. private: //------------------------------------------------------------------ diff --git a/include/lldb/Utility/Range.h b/include/lldb/Utility/Range.h deleted file mode 100644 index 60880dbdbc87..000000000000 --- a/include/lldb/Utility/Range.h +++ /dev/null @@ -1,60 +0,0 @@ -//===--------------------- Range.h ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_Range_h_ -#define utility_Range_h_ - -#include - -namespace lldb_utility { - -class Range { -public: - typedef uint64_t ValueType; - - static const ValueType OPEN_END = UINT64_MAX; - - Range(const Range &rng); - - Range(ValueType low = 0, ValueType high = OPEN_END); - - Range &operator=(const Range &rhs); - - ValueType GetLow() { return m_low; } - - ValueType GetHigh() { return m_high; } - - void SetLow(ValueType low) { m_low = low; } - - void SetHigh(ValueType high) { m_high = high; } - - void Flip(); - - void Intersection(const Range &other); - - void Union(const Range &other); - - typedef bool (*RangeCallback)(ValueType index); - - void Iterate(RangeCallback callback); - - ValueType GetSize(); - - bool IsEmpty(); - -private: - void InitRange(); - - ValueType m_low; - ValueType m_high; -}; - -} // namespace lldb_private - -#endif // #ifndef utility_Range_h_ diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Utility/RegisterValue.h similarity index 90% rename from include/lldb/Core/RegisterValue.h rename to include/lldb/Utility/RegisterValue.h index b369c3dff9a9..5aadbaa72bb9 100644 --- a/include/lldb/Core/RegisterValue.h +++ b/include/lldb/Utility/RegisterValue.h @@ -1,37 +1,28 @@ //===-- RegisterValue.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterValue_h -#define lldb_RegisterValue_h +#ifndef LLDB_UTILITY_REGISTERVALUE_H +#define LLDB_UTILITY_REGISTERVALUE_H -#include "lldb/Core/Scalar.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for ByteOrder, Format -#include "lldb/lldb-types.h" // for offset_t - +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/APInt.h" -#include "llvm/ADT/StringRef.h" // for StringRef - -#include // for uint32_t, uint8_t, uint64_t, uin... -#include +#include "llvm/ADT/StringRef.h" +#include +#include namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { struct RegisterInfo; -} -namespace lldb_private { class RegisterValue { public: @@ -276,4 +267,4 @@ class RegisterValue { } // namespace lldb_private -#endif // lldb_RegisterValue_h +#endif // LLDB_UTILITY_REGISTERVALUE_H diff --git a/include/lldb/Utility/RegularExpression.h b/include/lldb/Utility/RegularExpression.h index 6048fcc610a3..175778ea2994 100644 --- a/include/lldb/Utility/RegularExpression.h +++ b/include/lldb/Utility/RegularExpression.h @@ -1,9 +1,8 @@ //===-- RegularExpression.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -40,7 +39,7 @@ inline void regfree(llvm_regex_t *a) { llvm_regfree(a); } #include #include -#include // for size_t +#include #include namespace llvm { diff --git a/include/lldb/Utility/Reproducer.h b/include/lldb/Utility/Reproducer.h new file mode 100644 index 000000000000..83f7d0152277 --- /dev/null +++ b/include/lldb/Utility/Reproducer.h @@ -0,0 +1,232 @@ +//===-- Reproducer.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 LLDB_UTILITY_REPRODUCER_H +#define LLDB_UTILITY_REPRODUCER_H + +#include "lldb/Utility/FileCollector.h" +#include "lldb/Utility/FileSpec.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/YAMLTraits.h" + +#include +#include +#include + +namespace lldb_private { +namespace repro { + +class Reproducer; + +enum class ReproducerMode { + Capture, + Replay, + Off, +}; + +/// The provider defines an interface for generating files needed for +/// reproducing. +/// +/// Different components will implement different providers. +class ProviderBase { +public: + virtual ~ProviderBase() = default; + + const FileSpec &GetRoot() const { return m_root; } + + /// The Keep method is called when it is decided that we need to keep the + /// data in order to provide a reproducer. + virtual void Keep(){}; + + /// The Discard method is called when it is decided that we do not need to + /// keep any information and will not generate a reproducer. + virtual void Discard(){}; + + // Returns the class ID for this type. + static const void *ClassID() { return &ID; } + + // Returns the class ID for the dynamic type of this Provider instance. + virtual const void *DynamicClassID() const = 0; + + virtual llvm::StringRef GetName() const = 0; + virtual llvm::StringRef GetFile() const = 0; + +protected: + ProviderBase(const FileSpec &root) : m_root(root) {} + +private: + /// Every provider knows where to dump its potential files. + FileSpec m_root; + + virtual void anchor(); + static char ID; +}; + +template class Provider : public ProviderBase { +public: + static const void *ClassID() { return &ThisProviderT::ID; } + + const void *DynamicClassID() const override { return &ThisProviderT::ID; } + + llvm::StringRef GetName() const override { return ThisProviderT::info::name; } + llvm::StringRef GetFile() const override { return ThisProviderT::info::file; } + +protected: + using ProviderBase::ProviderBase; // Inherit constructor. +}; + +struct FileInfo { + static const char *name; + static const char *file; +}; + +class FileProvider : public Provider { +public: + typedef FileInfo info; + + FileProvider(const FileSpec &directory) + : Provider(directory), + m_collector(directory.CopyByAppendingPathComponent("root")) {} + + FileCollector &GetFileCollector() { return m_collector; } + + void Keep() override { + auto mapping = GetRoot().CopyByAppendingPathComponent(info::file); + // Temporary files that are removed during execution can cause copy errors. + if (auto ec = m_collector.CopyFiles(/*stop_on_error=*/false)) + return; + m_collector.WriteMapping(mapping); + } + + static char ID; + +private: + FileCollector m_collector; +}; + +/// The generator is responsible for the logic needed to generate a +/// reproducer. For doing so it relies on providers, who serialize data that +/// is necessary for reproducing a failure. +class Generator final { +public: + Generator(const FileSpec &root); + ~Generator(); + + /// Method to indicate we want to keep the reproducer. If reproducer + /// generation is disabled, this does nothing. + void Keep(); + + /// Method to indicate we do not want to keep the reproducer. This is + /// unaffected by whether or not generation reproduction is enabled, as we + /// might need to clean up files already written to disk. + void Discard(); + + /// Create and register a new provider. + template T *Create() { + std::unique_ptr provider = llvm::make_unique(m_root); + return static_cast(Register(std::move(provider))); + } + + /// Get an existing provider. + template T *Get() { + auto it = m_providers.find(T::ClassID()); + if (it == m_providers.end()) + return nullptr; + return static_cast(it->second.get()); + } + + /// Get a provider if it exists, otherwise create it. + template T &GetOrCreate() { + auto *provider = Get(); + if (provider) + return *provider; + return *Create(); + } + + const FileSpec &GetRoot() const; + +private: + friend Reproducer; + + ProviderBase *Register(std::unique_ptr provider); + + /// Builds and index with provider info. + void AddProvidersToIndex(); + + /// Map of provider IDs to provider instances. + llvm::DenseMap> m_providers; + std::mutex m_providers_mutex; + + /// The reproducer root directory. + FileSpec m_root; + + /// Flag to ensure that we never call both keep and discard. + bool m_done; +}; + +class Loader final { +public: + Loader(const FileSpec &root); + + template FileSpec GetFile() { + if (!HasFile(T::file)) + return {}; + + return GetRoot().CopyByAppendingPathComponent(T::file); + } + + llvm::Error LoadIndex(); + + const FileSpec &GetRoot() const { return m_root; } + +private: + bool HasFile(llvm::StringRef file); + + FileSpec m_root; + std::vector m_files; + bool m_loaded; +}; + +/// The reproducer enables clients to obtain access to the Generator and +/// Loader. +class Reproducer { +public: + static Reproducer &Instance(); + static llvm::Error Initialize(ReproducerMode mode, + llvm::Optional root); + static void Terminate(); + + Reproducer() = default; + + Generator *GetGenerator(); + Loader *GetLoader(); + + const Generator *GetGenerator() const; + const Loader *GetLoader() const; + + FileSpec GetReproducerPath() const; + +protected: + llvm::Error SetCapture(llvm::Optional root); + llvm::Error SetReplay(llvm::Optional root); + +private: + static llvm::Optional &InstanceImpl(); + + llvm::Optional m_generator; + llvm::Optional m_loader; + + mutable std::mutex m_mutex; +}; + +} // namespace repro +} // namespace lldb_private + +#endif // LLDB_UTILITY_REPRODUCER_H diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Utility/Scalar.h similarity index 91% rename from include/lldb/Core/Scalar.h rename to include/lldb/Utility/Scalar.h index 40671a242ec3..ac8cf0a213b3 100644 --- a/include/lldb/Core/Scalar.h +++ b/include/lldb/Utility/Scalar.h @@ -1,36 +1,34 @@ //===-- Scalar.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Scalar_h_ -#define liblldb_Scalar_h_ - -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for Encoding, ByteOrder -#include "lldb/lldb-private-types.h" // for type128 +#ifndef LLDB_UTILITY_SCALAR_H +#define LLDB_UTILITY_SCALAR_H +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-types.h" +#include "lldb/Utility/LLDBAssert.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" - -#include // for size_t -#include // for uint32_t, uint64_t, int64_t +#include +#include namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Stream; -} +} // namespace lldb_private #define NUM_OF_WORDS_INT128 2 #define BITWIDTH_INT128 128 #define NUM_OF_WORDS_INT256 4 #define BITWIDTH_INT256 256 +#define NUM_OF_WORDS_INT512 8 +#define BITWIDTH_INT512 512 namespace lldb_private { @@ -54,6 +52,8 @@ class Scalar { e_uint128, e_sint256, e_uint256, + e_sint512, + e_uint512, e_float, e_double, e_long_double @@ -102,30 +102,22 @@ class Scalar { case 8: case 16: case 32: - if (m_integer.isSignedIntN(sizeof(sint_t) * 8)) - m_type = e_sint; - else - m_type = e_uint; - break; + m_type = e_sint; + return; case 64: - if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) - m_type = e_slonglong; - else - m_type = e_ulonglong; - break; + m_type = e_slonglong; + return; case 128: - if (m_integer.isSignedIntN(BITWIDTH_INT128)) - m_type = e_sint128; - else - m_type = e_uint128; - break; + m_type = e_sint128; + return; case 256: - if (m_integer.isSignedIntN(BITWIDTH_INT256)) - m_type = e_sint256; - else - m_type = e_uint256; - break; + m_type = e_sint256; + return; + case 512: + m_type = e_sint512; + return; } + lldbassert(false && "unsupported bitwidth"); } Scalar(const Scalar &rhs); // Scalar(const RegisterValue& reg_value); @@ -260,10 +252,6 @@ class Scalar { llvm::APInt UInt128(const llvm::APInt &fail_value) const; - llvm::APInt SInt256(llvm::APInt &fail_value) const; - - llvm::APInt UInt256(const llvm::APInt &fail_value) const; - float Float(float fail_value = 0.0f) const; double Double(double fail_value = 0.0) const; @@ -375,4 +363,4 @@ bool operator>=(const Scalar &lhs, const Scalar &rhs); } // namespace lldb_private -#endif // liblldb_Scalar_h_ +#endif // LLDB_UTILITY_SCALAR_H diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h index 004952f1c598..ec37f194d329 100644 --- a/include/lldb/Utility/SelectHelper.h +++ b/include/lldb/Utility/SelectHelper.h @@ -1,17 +1,16 @@ //===-- SelectHelper.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SelectHelper_h_ #define liblldb_SelectHelper_h_ -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-types.h" // for socket_t +#include "lldb/Utility/Status.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h index 61b9804ad335..71bbb334cff3 100644 --- a/include/lldb/Utility/SharedCluster.h +++ b/include/lldb/Utility/SharedCluster.h @@ -1,9 +1,8 @@ //===------------------SharedCluster.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h index 691c92afaaae..5515103e6ce3 100644 --- a/include/lldb/Utility/SharingPtr.h +++ b/include/lldb/Utility/SharingPtr.h @@ -1,17 +1,14 @@ //===---------------------SharingPtr.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 utility_SharingPtr_h_ #define utility_SharingPtr_h_ -// C Includes -// C++ Includes #include // Microsoft Visual C++ currently does not enable std::atomic to work in CLR @@ -25,8 +22,6 @@ #include -// Other libraries and framework includes -// Project includes //#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT #if defined(ENABLE_SP_LOGGING) diff --git a/include/lldb/Core/State.h b/include/lldb/Utility/State.h similarity index 84% rename from include/lldb/Core/State.h rename to include/lldb/Utility/State.h index 68f0fee254b3..045b4f87e68a 100644 --- a/include/lldb/Core/State.h +++ b/include/lldb/Utility/State.h @@ -1,22 +1,19 @@ //===-- State.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_State_h_ -#define liblldb_State_h_ +#ifndef LLDB_UTILITY_STATE_H +#define LLDB_UTILITY_STATE_H +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatProviders.h" - -#include "lldb/lldb-enumerations.h" // for StateType -#include "llvm/ADT/StringRef.h" // for StringRef -#include "llvm/Support/raw_ostream.h" // for raw_ostream - -#include // for uint32_t +#include "llvm/Support/raw_ostream.h" +#include namespace lldb_private { @@ -80,6 +77,6 @@ template <> struct format_provider { Stream << lldb_private::StateAsCString(state); } }; -} +} // namespace llvm -#endif // liblldb_State_h_ +#endif // LLDB_UTILITY_STATE_H diff --git a/include/lldb/Utility/Status.h b/include/lldb/Utility/Status.h index 3bd2cd5b3b41..7893fd419dd6 100644 --- a/include/lldb/Utility/Status.h +++ b/include/lldb/Utility/Status.h @@ -1,9 +1,8 @@ //===-- Status.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,15 +10,15 @@ #define LLDB_UTILITY_STATUS_H #include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType... -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include -#include // for uint32_t +#include #include -#include // for error_code -#include // for forward +#include +#include namespace llvm { class raw_ostream; diff --git a/include/lldb/Utility/Stream.h b/include/lldb/Utility/Stream.h index 2f93f78c14ec..aeec26d12f16 100644 --- a/include/lldb/Utility/Stream.h +++ b/include/lldb/Utility/Stream.h @@ -1,9 +1,8 @@ //===-- Stream.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,15 +11,15 @@ #include "lldb/Utility/Flags.h" #include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/raw_ostream.h" #include -#include // for size_t -#include // for uint32_t, uint64_t, uint8_t -#include // for forward +#include +#include +#include namespace lldb_private { @@ -46,6 +45,25 @@ class Stream { // END SWIFT PATCH }; + /// Utility class for counting the bytes that were written to a stream in a + /// certain time span. + /// @example + /// ByteDelta delta(*this); + /// WriteDataToStream("foo"); + /// return *delta; + /// @endcode + class ByteDelta { + Stream *m_stream; + /// Bytes we have written so far when ByteDelta was created. + size_t m_start; + + public: + ByteDelta(Stream &s) : m_stream(&s), m_start(s.GetWrittenBytes()) {} + /// Returns the number of bytes written to the given Stream since this + /// ByteDelta object was created. + size_t operator*() const { return m_stream->GetWrittenBytes() - m_start; } + }; + //------------------------------------------------------------------ /// Construct with flags and address size and byte order. /// @@ -558,7 +576,7 @@ class Stream { int m_indent_level; ///< Indention level. std::size_t m_bytes_written = 0; ///< Number of bytes written so far. - size_t _PutHex8(uint8_t uvalue, bool add_prefix); + void _PutHex8(uint8_t uvalue, bool add_prefix); //------------------------------------------------------------------ /// Output character bytes to the stream. diff --git a/include/lldb/Utility/StreamCallback.h b/include/lldb/Utility/StreamCallback.h index 0aa9d5d57b2f..6dbee67ecca2 100644 --- a/include/lldb/Utility/StreamCallback.h +++ b/include/lldb/Utility/StreamCallback.h @@ -1,9 +1,8 @@ //===-- StreamCallback.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,8 +12,8 @@ #include "lldb/lldb-types.h" #include "llvm/Support/raw_ostream.h" -#include // for size_t -#include // for uint64_t +#include +#include namespace lldb_private { diff --git a/include/lldb/Utility/StreamGDBRemote.h b/include/lldb/Utility/StreamGDBRemote.h index 79234cc03d86..96b2ea164c98 100644 --- a/include/lldb/Utility/StreamGDBRemote.h +++ b/include/lldb/Utility/StreamGDBRemote.h @@ -1,20 +1,19 @@ //===-- StreamGDBRemote.h ----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StreamGDBRemote_h_ #define liblldb_StreamGDBRemote_h_ -#include "lldb/Utility/StreamString.h" // for StreamString -#include "lldb/lldb-enumerations.h" // for ByteOrder +#include "lldb/Utility/StreamString.h" +#include "lldb/lldb-enumerations.h" -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { diff --git a/include/lldb/Utility/StreamString.h b/include/lldb/Utility/StreamString.h index 28c11fcc0f8f..581e102d4e80 100644 --- a/include/lldb/Utility/StreamString.h +++ b/include/lldb/Utility/StreamString.h @@ -1,23 +1,22 @@ //===-- StreamString.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StreamString_h_ #define liblldb_StreamString_h_ -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/lldb-enumerations.h" // for ByteOrder -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" -#include // for string +#include -#include // for size_t -#include // for uint32_t +#include +#include namespace lldb_private { diff --git a/include/lldb/Utility/StreamTee.h b/include/lldb/Utility/StreamTee.h index 4f8e6ab1f002..43e99ac6e565 100644 --- a/include/lldb/Utility/StreamTee.h +++ b/include/lldb/Utility/StreamTee.h @@ -1,9 +1,8 @@ //===-- StreamTee.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h index 4b75d5c5484d..c815ea9fbc33 100644 --- a/include/lldb/Utility/StringExtractor.h +++ b/include/lldb/Utility/StringExtractor.h @@ -1,21 +1,18 @@ //===-- StringExtractor.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 utility_StringExtractor_h_ #define utility_StringExtractor_h_ -// Other libraries and framework includes -// Project includes #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include // for size_t +#include #include #include diff --git a/include/lldb/Utility/StringExtractorGDBRemote.h b/include/lldb/Utility/StringExtractorGDBRemote.h index 93e760b88112..b3f58f3272e2 100644 --- a/include/lldb/Utility/StringExtractorGDBRemote.h +++ b/include/lldb/Utility/StringExtractorGDBRemote.h @@ -1,9 +1,8 @@ //===-- StringExtractorGDBRemote.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,12 +11,12 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/StringExtractor.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include -#include // for size_t -#include // for uint8_t +#include +#include class StringExtractorGDBRemote : public StringExtractor { public: diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h index d779ef429481..239d244cb024 100644 --- a/include/lldb/Utility/StringLexer.h +++ b/include/lldb/Utility/StringLexer.h @@ -1,18 +1,17 @@ //===--------------------- StringLexer.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 utility_StringLexer_h_ #define utility_StringLexer_h_ -#include // for initializer_list -#include // for string -#include // for pair +#include +#include +#include namespace lldb_utility { diff --git a/include/lldb/Utility/StringList.h b/include/lldb/Utility/StringList.h index 1cb68885e771..e1aa9a6d0214 100644 --- a/include/lldb/Utility/StringList.h +++ b/include/lldb/Utility/StringList.h @@ -1,9 +1,8 @@ //===-- StringList.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,7 +11,7 @@ #include "llvm/ADT/StringRef.h" -#include // for size_t +#include #include #include diff --git a/include/lldb/Utility/StructuredData.h b/include/lldb/Utility/StructuredData.h index d3ebab16f51d..20f161b91e92 100644 --- a/include/lldb/Utility/StructuredData.h +++ b/include/lldb/Utility/StructuredData.h @@ -1,9 +1,8 @@ //===-- StructuredData.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,17 +12,17 @@ #include "llvm/ADT/StringRef.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-enumerations.h" // for StructuredDataType +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-enumerations.h" -#include // for assert -#include // for size_t -#include // for uint64_t +#include +#include +#include #include #include #include #include -#include // for move +#include #include #include @@ -170,7 +169,7 @@ class StructuredData { bool ForEach(std::function const &foreach_callback) const { for (const auto &object_sp : m_items) { - if (foreach_callback(object_sp.get()) == false) + if (!foreach_callback(object_sp.get())) return false; } return true; @@ -359,7 +358,7 @@ class StructuredData { void ForEach(std::function const &callback) const { for (const auto &pair : m_dict) { - if (callback(pair.first, pair.second.get()) == false) + if (!callback(pair.first, pair.second.get())) break; } } diff --git a/include/lldb/Utility/TildeExpressionResolver.h b/include/lldb/Utility/TildeExpressionResolver.h index ae6b4073f6aa..196fdfcf9ab4 100644 --- a/include/lldb/Utility/TildeExpressionResolver.h +++ b/include/lldb/Utility/TildeExpressionResolver.h @@ -1,9 +1,8 @@ //===--------------------- TildeExpressionResolver.h ------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Timeout.h b/include/lldb/Utility/Timeout.h index ecb33b346e96..202b747fd480 100644 --- a/include/lldb/Utility/Timeout.h +++ b/include/lldb/Utility/Timeout.h @@ -1,9 +1,8 @@ //===-- Timeout.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/Timer.h b/include/lldb/Utility/Timer.h index 2c1e984837c2..6e10083c1fc8 100644 --- a/include/lldb/Utility/Timer.h +++ b/include/lldb/Utility/Timer.h @@ -1,19 +1,18 @@ //===-- Timer.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Timer_h_ #define liblldb_Timer_h_ -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" #include "llvm/Support/Chrono.h" #include -#include // for uint32_t +#include namespace lldb_private { class Stream; diff --git a/include/lldb/Utility/TraceOptions.h b/include/lldb/Utility/TraceOptions.h index 325ff74e6f55..d5e21ccd8ba3 100644 --- a/include/lldb/Utility/TraceOptions.h +++ b/include/lldb/Utility/TraceOptions.h @@ -1,9 +1,8 @@ //===-- TraceOptions.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/UUID.h b/include/lldb/Utility/UUID.h index 686fb880339b..10b5185a0296 100644 --- a/include/lldb/Utility/UUID.h +++ b/include/lldb/Utility/UUID.h @@ -1,17 +1,14 @@ //===-- UUID.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_UTILITY_UUID_H #define LLDB_UTILITY_UUID_H -// C Includes -// C++ Includes #include #include #include diff --git a/include/lldb/Utility/UriParser.h b/include/lldb/Utility/UriParser.h index db0049d9684c..4a3f01230e1a 100644 --- a/include/lldb/Utility/UriParser.h +++ b/include/lldb/Utility/UriParser.h @@ -1,9 +1,8 @@ //===-- UriParser.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/UserID.h b/include/lldb/Utility/UserID.h index 9e15e6a43c6c..9bd977800e2b 100644 --- a/include/lldb/Utility/UserID.h +++ b/include/lldb/Utility/UserID.h @@ -1,17 +1,16 @@ //===-- UserID.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UserID_h_ #define liblldb_UserID_h_ -#include "lldb/lldb-defines.h" // for LLDB_INVALID_UID -#include "lldb/lldb-types.h" // for user_id_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-types.h" namespace lldb_private { class Stream; } diff --git a/include/lldb/Utility/VASPrintf.h b/include/lldb/Utility/VASPrintf.h index 6e2404ecef93..582645fd2292 100644 --- a/include/lldb/Utility/VASPrintf.h +++ b/include/lldb/Utility/VASPrintf.h @@ -1,9 +1,8 @@ //===-- VASPrintf.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Utility/VMRange.h b/include/lldb/Utility/VMRange.h index 0e696907baa7..7a9a6b30c757 100644 --- a/include/lldb/Utility/VMRange.h +++ b/include/lldb/Utility/VMRange.h @@ -1,19 +1,18 @@ //===-- VMRange.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_VMRange_h_ #define liblldb_VMRange_h_ -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-types.h" -#include // for size_t -#include // for uint32_t +#include +#include #include namespace lldb_private { diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h index 8a54b4c44364..6a5b3a7107e2 100644 --- a/include/lldb/lldb-defines.h +++ b/include/lldb/lldb-defines.h @@ -1,9 +1,8 @@ //===-- lldb-defines.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h index 300df7fd82ec..6f338eec2199 100644 --- a/include/lldb/lldb-enumerations.h +++ b/include/lldb/lldb-enumerations.h @@ -1,15 +1,50 @@ //===-- lldb-enumerations.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_lldb_enumerations_h_ #define LLDB_lldb_enumerations_h_ +#include + +#ifndef SWIG +// Macro to enable bitmask operations on an enum. Without this, Enum | Enum +// gets promoted to an int, so you have to say Enum a = Enum(eFoo | eBar). If +// you mark Enum with LLDB_MARK_AS_BITMASK_ENUM(Enum), however, you can simply +// write Enum a = eFoo | eBar. +// Unfortunately, swig<3.0 doesn't recognise the constexpr keyword, so remove +// this entire block, as it is not necessary for swig processing. +#define LLDB_MARK_AS_BITMASK_ENUM(Enum) \ + constexpr Enum operator|(Enum a, Enum b) { \ + return static_cast( \ + static_cast::type>(a) | \ + static_cast::type>(b)); \ + } \ + constexpr Enum operator&(Enum a, Enum b) { \ + return static_cast( \ + static_cast::type>(a) & \ + static_cast::type>(b)); \ + } \ + constexpr Enum operator~(Enum a) { \ + return static_cast( \ + ~static_cast::type>(a)); \ + } \ + inline Enum &operator|=(Enum &a, Enum b) { \ + a = a | b; \ + return a; \ + } \ + inline Enum &operator&=(Enum &a, Enum b) { \ + a = a & b; \ + return a; \ + } +#else +#define LLDB_MARK_AS_BITMASK_ENUM(Enum) +#endif + #ifndef SWIG // With MSVC, the default type of an enum is always signed, even if one of the // enumerator values is too large to fit into a signed integer but would @@ -57,7 +92,7 @@ enum StateType { eStateSuspended, ///< Process or thread is in a suspended state as far ///< as the debugger is concerned while other processes ///< or threads get the chance to run. - kLastStateType = eStateSuspended + kLastStateType = eStateSuspended }; //---------------------------------------------------------------------- @@ -327,43 +362,45 @@ enum InputReaderGranularity { //------------------------------------------------------------------ FLAGS_ENUM(SymbolContextItem){ eSymbolContextTarget = (1u << 0), ///< Set when \a target is requested from - ///a query, or was located in query - ///results + /// a query, or was located in query + /// results eSymbolContextModule = (1u << 1), ///< Set when \a module is requested from - ///a query, or was located in query - ///results + /// a query, or was located in query + /// results eSymbolContextCompUnit = (1u << 2), ///< Set when \a comp_unit is requested - ///from a query, or was located in query - ///results + /// from a query, or was located in + /// query results eSymbolContextFunction = (1u << 3), ///< Set when \a function is requested - ///from a query, or was located in query - ///results + /// from a query, or was located in + /// query results eSymbolContextBlock = (1u << 4), ///< Set when the deepest \a block is - ///requested from a query, or was located - ///in query results + /// requested from a query, or was located + /// in query results eSymbolContextLineEntry = (1u << 5), ///< Set when \a line_entry is - ///requested from a query, or was - ///located in query results + /// requested from a query, or was + /// located in query results eSymbolContextSymbol = (1u << 6), ///< Set when \a symbol is requested from - ///a query, or was located in query - ///results + /// a query, or was located in query + /// results eSymbolContextEverything = ((eSymbolContextSymbol << 1) - 1u), ///< Indicates to try and lookup everything - ///up during a routine symbol context - ///query. - eSymbolContextVariable = (1u << 7) ///< Set when \a global or static - ///variable is requested from a query, or - ///was located in query results. + /// up during a routine symbol context + /// query. + eSymbolContextVariable = (1u << 7), ///< Set when \a global or static + /// variable is requested from a query, + /// or was located in query results. ///< eSymbolContextVariable is potentially expensive to lookup so it isn't - ///included in + /// included in ///< eSymbolContextEverything which stops it from being used during frame PC - ///lookups and + /// lookups and ///< many other potential address to symbol context lookups. }; +LLDB_MARK_AS_BITMASK_ENUM(SymbolContextItem) FLAGS_ENUM(Permissions){ePermissionsWritable = (1u << 0), ePermissionsReadable = (1u << 1), ePermissionsExecutable = (1u << 2)}; +LLDB_MARK_AS_BITMASK_ENUM(Permissions) enum InputReaderAction { eInputReaderActivate, // reader is newly pushed onto the reader stack @@ -678,7 +715,14 @@ enum SectionType { eSectionTypeDWARFGNUDebugAltLink, eSectionTypeDWARFDebugTypes, // DWARF .debug_types section eSectionTypeDWARFDebugNames, // DWARF v5 .debug_names - eSectionTypeOther + eSectionTypeOther, + eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str + eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists + eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists + eSectionTypeDWARFDebugAbbrevDwo, + eSectionTypeDWARFDebugInfoDwo, + eSectionTypeDWARFDebugStrDwo, + eSectionTypeDWARFDebugStrOffsetsDwo, }; FLAGS_ENUM(EmulateInstructionOptions){ @@ -706,6 +750,7 @@ FLAGS_ENUM(FunctionNameType){ eFunctionNameTypeAny = eFunctionNameTypeAuto // DEPRECATED: use eFunctionNameTypeAuto }; +LLDB_MARK_AS_BITMASK_ENUM(FunctionNameType) //---------------------------------------------------------------------- // Basic types enumeration for the public API SBType::GetBasicType() @@ -780,6 +825,7 @@ FLAGS_ENUM(TypeClass){ eTypeClassOther = (1u << 31), // Define a mask that can be used for any type when finding types eTypeClassAny = (0xffffffffu)}; +LLDB_MARK_AS_BITMASK_ENUM(TypeClass) enum TemplateArgumentKind { eTemplateArgumentKindNull = 0, @@ -1105,7 +1151,6 @@ enum TypeSummaryCapping { eTypeSummaryCapped = true, eTypeSummaryUncapped = false }; - } // namespace lldb #endif // LLDB_lldb_enumerations_h_ diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h index d527440ebd6c..a5d0283eb293 100644 --- a/include/lldb/lldb-forward.h +++ b/include/lldb/lldb-forward.h @@ -1,9 +1,8 @@ //===-- lldb-forward.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -125,13 +124,14 @@ class JITLoaderList; class Language; class LanguageCategory; class LanguageRuntime; -class MemoryRegionInfo; class LineTable; class Listener; class Log; class Mangled; class Materializer; class MemoryHistory; +class MemoryRegionInfo; +class MemoryRegionInfos; class Module; class ModuleList; class ModuleSpec; @@ -372,7 +372,6 @@ typedef std::shared_ptr LineTableSP; typedef std::shared_ptr ListenerSP; typedef std::weak_ptr ListenerWP; typedef std::shared_ptr MemoryHistorySP; -typedef std::shared_ptr MemoryRegionInfoSP; typedef std::unique_ptr MemoryRegionInfoUP; typedef std::shared_ptr ModuleSP; typedef std::weak_ptr ModuleWP; diff --git a/include/lldb/lldb-private-defines.h b/include/lldb/lldb-private-defines.h index 9b6594422e82..737d9ef2434e 100644 --- a/include/lldb/lldb-private-defines.h +++ b/include/lldb/lldb-private-defines.h @@ -1,9 +1,8 @@ //===-- lldb-private-defines.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h index c25f285c9713..9b4134bfdf3f 100644 --- a/include/lldb/lldb-private-enumerations.h +++ b/include/lldb/lldb-private-enumerations.h @@ -1,9 +1,8 @@ //===-- lldb-private-enumerations.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-private-forward.h b/include/lldb/lldb-private-forward.h index 65d303281164..ff160bfd27d6 100644 --- a/include/lldb/lldb-private-forward.h +++ b/include/lldb/lldb-private-forward.h @@ -1,35 +1,23 @@ //===-- lldb-private-forward.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_lldb_private_forward_h_ #define LLDB_lldb_private_forward_h_ -#if defined(__cplusplus) - -#include - namespace lldb_private { // --------------------------------------------------------------- Class // forward decls. // --------------------------------------------------------------- -class NativeBreakpoint; -class NativeBreakpointList; class NativeProcessProtocol; class NativeRegisterContext; class NativeThreadProtocol; class ResumeActionList; class UnixSignals; - -// --------------------------------------------------------------- SP/WP decls. -// --------------------------------------------------------------- -typedef std::shared_ptr NativeBreakpointSP; } -#endif // #if defined(__cplusplus) #endif // #ifndef LLDB_lldb_private_forward_h_ diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h index 3ab5905469f4..d1ed456e0919 100644 --- a/include/lldb/lldb-private-interfaces.h +++ b/include/lldb/lldb-private-interfaces.h @@ -1,9 +1,8 @@ //===-- lldb-private-interfaces.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h index e0f0e413cef4..0e8537ce088a 100644 --- a/include/lldb/lldb-private-types.h +++ b/include/lldb/lldb-private-types.h @@ -1,9 +1,8 @@ //===-- lldb-private-types.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-private.h b/include/lldb/lldb-private.h index 252ca09fae29..24954ad2a1f5 100644 --- a/include/lldb/lldb-private.h +++ b/include/lldb/lldb-private.h @@ -1,9 +1,8 @@ //===-- lldb-private.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-public.h b/include/lldb/lldb-public.h index 290ff6e6d501..97ee623b6d8c 100644 --- a/include/lldb/lldb-public.h +++ b/include/lldb/lldb-public.h @@ -1,9 +1,8 @@ //===-- lldb-include.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h index 79f441569304..90767e120dae 100644 --- a/include/lldb/lldb-types.h +++ b/include/lldb/lldb-types.h @@ -1,9 +1,8 @@ //===-- lldb-types.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -47,7 +46,8 @@ typedef unsigned int __w64 socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef unsigned thread_result_t; // Host thread result type typedef thread_result_t (*thread_func_t)(void *); // Host thread function type -} +typedef void *pipe_t; // Host pipe type is HANDLE +} // namespace lldb #else @@ -65,6 +65,7 @@ typedef int socket_t; // Host socket type typedef void *thread_arg_t; // Host thread argument type typedef void *thread_result_t; // Host thread result type typedef void *(*thread_func_t)(void *); // Host thread function type +typedef int pipe_t; // Host pipe type } // namespace lldb #endif @@ -76,10 +77,11 @@ typedef bool (*CommandOverrideCallbackWithResult)( void *baton, const char **argv, lldb_private::CommandReturnObject &result); typedef bool (*ExpressionCancelCallback)(ExpressionEvaluationPhase phase, void *baton); -} +} // namespace lldb #define LLDB_INVALID_PROCESS ((lldb::process_t)-1) #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) +#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1) namespace lldb { typedef uint64_t addr_t; @@ -91,6 +93,6 @@ typedef int32_t break_id_t; typedef int32_t watch_id_t; typedef void *opaque_compiler_type_t; typedef uint64_t queue_id_t; -} +} // namespace lldb #endif // LLDB_lldb_types_h_ diff --git a/include/lldb/lldb-versioning.h b/include/lldb/lldb-versioning.h index 9d5fd164119e..f3cfd1480fbe 100644 --- a/include/lldb/lldb-versioning.h +++ b/include/lldb/lldb-versioning.h @@ -1,10 +1,9 @@ //===-- lldb-versioning.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/include/lldb/module.modulemap b/include/lldb/module.modulemap index cec0428c1840..9c7f3e6f58e5 100644 --- a/include/lldb/module.modulemap +++ b/include/lldb/module.modulemap @@ -38,10 +38,10 @@ module lldb_Host { module PipeBase { header "Host/PipeBase.h" export * } module Pipe { header "Host/Pipe.h" export * } module PosixApi { header "Host/PosixApi.h" export * } - module Predicate { header "Host/Predicate.h" export * } module ProcessLauncher { header "Host/ProcessLauncher.h" export * } module ProcessRunLock { header "Host/ProcessRunLock.h" export * } module PseudoTerminal { header "Host/PseudoTerminal.h" export * } + module SafeMachO { header "Host/SafeMachO.h" export * } module SocketAddress { header "Host/SocketAddress.h" export * } module Socket { header "Host/Socket.h" export * } module StringConvert { header "Host/StringConvert.h" export * } diff --git a/lit/Breakpoint/Inputs/debug_addrx.yaml b/lit/Breakpoint/Inputs/debug_addrx.yaml new file mode 100644 index 000000000000..7d4cd74543e3 --- /dev/null +++ b/lit/Breakpoint/Inputs/debug_addrx.yaml @@ -0,0 +1,57 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000201000 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000201000 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C700112000E897010000F4CCCCCCCCCCCC55B810202000483D102020004889E57417B8000000004885C0740D5DBF10202000FFE00F1F4400005DC3660F1F440000BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF10202000FFE00F1F005DC3660F1F440000803D592F0000007517554889E5E87EFFFFFFC605472F0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89CCCCCCCCCCCCCCCCCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC31C0C3CCCCCCCCCCCCCCCCCCCCCCCCCC415741564189FF415541544C8D25E61E000055488D2DE61E0000534989F64989D54C29E54883EC0848C1FD03E8430000004885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 44000000050000006B0000005F0000003A0000000E0000001A0000001E000000930000002E0000001600000067000000050000009A0000008E000000000000006900000095000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 74686973005F5A336261723141005F76707472244100666F6F00696E74005F5F7674626C5F7074725F74797065005F5A4E314133666F6F4576002F686F6D652F756D622F74657374735F323031382F3131326C6C64625F726C657461677300746573742E63630041006100636C616E672076657273696F6E20382E302E3020287472756E6B2033343438333429006D61696E0078006F626A410062617200 + - Name: .debug_loc + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: E010200000000000E010200000000000030011009FE010200000000000E1102000000000000500110023019F00000000000000000000000000000000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B25731711015517741700000213011D13360B03250B0B3A0B3B0B0000030D0003254913380B34190000040D00032549133A0B3B0B380B0000052E016E2503253A0B3B0B4C0B4D183C193F191D130000060500491334190000070F0049130000080F00491303250000091500491300000A240003253E0B0B0B00000B2E01111B1206401864137A193B0B471300000C050003254913341900000D3400021703253A0B3B0B491300000E2E01111B120640187A196E2503253A0B3B0B3F1900000F050003253A0B3B0B49130000102E01111B120640187A1903253A0B3B0B49133F19000011340003253A0B3B0B4913000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: C8000000050001080000000001000400010800000000000000020800000000000000000000000C0000000C000000022E000000040910010303035C0000000004066C0000000104080507080105010210002E000000067000000000000761000000086700000005096C0000000A040504072E0000000B000100000001578600000008480000000C0DC60000000D000000000601096C000000000E010100000001570A0B010D0F0E010D2E0000000010020300000001570C01116C000000110F01122E00000000072E00000000 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 27000000050008000000000007E0102000000000000107F010200000000000010700112000000000000300 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 1C00000005000800E010200000000000F0102000000000000011200000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 97000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E02250000000066F622AD4EB40BCEA506478235D9D438250000000066F622AD4EB40BCEA506478235D9D438000902E0102000000000001905010A150201000101000902F010200000000000030C0105010A140201000101000902001120000000000003100105030A170203000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3131326C6C64625F726C657461677300746573742E636300 +Symbols: diff --git a/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml b/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml new file mode 100644 index 000000000000..6a6db28790e3 --- /dev/null +++ b/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml @@ -0,0 +1,50 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400440 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400440 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89900F1F840000000000554889E5B8010000005DC30F1F440000554889E54883EC10C745FC00000000E8DCFFFFFF4883C4105DC3660F1F440000415741564189FF415541544C8D25A618000055488D2DA6180000534989F64989D54C29E54883EC0848C1FD03E86FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 200000000500000000000000230000002C0000005D00000065000000690000006D000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 636C616E672076657273696F6E20382E302E3020287472756E6B203334333438372900746573742E637070002F686F6D652F756D622F74657374735F323031382F313033726E676C697374732F6C6C64622F63726561746574657374005F5A337A656476007A656400696E74006D61696E00 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B251101551774170000022E001101120640186E2503253A0B3B0B49133F190000032E0011011206401803253A0B3B0B49133F19000004240003253E0B0B0B000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 580000000500010800000000010004000108000000000000000200000000000000000C0000000C0000000220054000000000000B000000015603040101570000000330054000000000001A0000000156060105570000000405050400 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 1D00000005000800000000000720054000000000000B0730054000000000001A00 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 82000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E023100000000F7B7492A97F18E69F7EC76B19E9024873100000000F7B7492A97F18E69F7EC76B19E90248700090220054000000000000105020A4B020700010100090230054000000000001605090AE5050206580206000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F313033726E676C697374732F6C6C64622F6372656174657465737400746573742E63707000 +Symbols: +... diff --git a/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml b/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml new file mode 100644 index 000000000000..b919e3e4d1cb --- /dev/null +++ b/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml @@ -0,0 +1,53 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400440 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400440 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C740054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89660F1F840000000000B9020000008B05F91A00000F1F44000021F883C1FF75F98905E71A0000C3669050BF01000000E8D5FFFFFF31C059C390415741564189FF415541544C8D25A618000055488D2DA6180000534989F64989D54C29E54883EC0848C1FD03E86FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 300000000500000000000000230000002C0000004F00000051000000550000005D0000006100000066000000680000006A000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 636C616E672076657273696F6E20382E302E3020287472756E6B203334343033352900746573742E637070002F686F6D652F756D622F74657374735F323031382F3130365F726E676C6973747332004300696E74005F5A33666F6F6900666F6F006D61696E00500049005700 + - Name: .debug_loc + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 05000000000000001000000000000000030011009F00000000000000000000000000000000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B251101120674170000023400032549133F193A0B3B0B0218000003240003253E0B0B0B0000042E011101120640187A196E2503253A0B3B0B3F190000050500021803253A0B3B0B49130000060B01110112060000073400021703253A0B3B0B49130000080B015517000009340003253A0B3B0B491300000A2E011101120640187A1903253A0B3B0B49133F1900000B48007F137D0100000C0F004913000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: AC0000000500010800000000010004000108000000000000000220054000000000002F0000000C00000002033C000000010309032420400000000000030405040420054000000000001E0000000157050601040501550801043C0000000625054000000000001800000007000000000901063C000000080C000000090A0107AA0000000000000A40054000000000000F000000015707010E3C0000000B400000004B05400000000000000C3C00000000 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 18000000050008000000000005200540000000000004051204171D00 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 7F000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E0223000000003D8C80E874CE6D5F1FC4A6544BE9D5B323000000003D8C80E874CE6D5F1FC4A6544BE9D5B300090220054000000000001605080A5B0515C60503063C0508063005016805004105030A21A00204000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3130365F726E676C697374733200746573742E63707000 +Symbols: diff --git a/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml b/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml new file mode 100644 index 000000000000..79807773432f --- /dev/null +++ b/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml @@ -0,0 +1,49 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000201000 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000201000 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C7F0102000E897010000F4CCCCCCCCCCCC55B810202000483D102020004889E57417B8000000004885C0740D5DBF10202000FFE00F1F4400005DC3660F1F440000BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF10202000FFE00F1F005DC3660F1F440000803D592F0000007517554889E5E87EFFFFFFC605472F0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89CCCCCCCCCCCCCCCCCC554889E5B8010000005DC3CCCCCCCCCC554889E54883EC10C745FC00000000E8DCFFFFFF4883C4105DC3CCCCCCCCCCCC415741564189FF415541544C8D25E61E000055488D2DE61E0000534989F64989D54C29E54883EC0848C1FD03E8430000004885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2000000005000000040000002B0000003900000062000000270000000000000034000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 696E7400636C616E672076657273696F6E20382E302E3020287472756E6B2033343430333529007A656400746573742E637070006D61696E002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E64005F5A337A65647600 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B251101551774170000022E001101120640186E2503253A0B3B0B49133F190000032E0011011206401803253A0B3B0B49133F19000004240003253E0B0B0B000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 580000000500010800000000010004000108000000000000000200000000000000000C0000000C00000002E0102000000000000B0000000156030401015700000003F0102000000000001A0000000156060105570000000405050400 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2B000000050008000000000006E010200000000000EB1020000000000006F0102000000000000A1120000000000000 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 82000000050008004C000000010101FB0E0D00010101010000000100000101011F010900000003011F020F051E020000000000C404455D157064301CF8C713A4AC4CEE0000000000C404455D157064301CF8C713A4AC4CEE000902E0102000000000000105030A4B0207000101000902F01020000000000016050A0AE5050306580206000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 746573742E637070002F686F6D652F756D622F74657374735F323031382F3130375F726E676C6973747374617274656E6400 +Symbols: diff --git a/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml b/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml new file mode 100644 index 000000000000..15b95e2a1750 --- /dev/null +++ b/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml @@ -0,0 +1,57 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000201000 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000201000 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C08011200048C7C11011200048C7C700112000E897010000F4CCCCCCCCCCCC55B810202000483D102020004889E57417B8000000004885C0740D5DBF10202000FFE00F1F4400005DC3660F1F440000BE10202000554881EE102020004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF10202000FFE00F1F005DC3660F1F440000803D592F0000007517554889E5E87EFFFFFFC605472F0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89CCCCCCCCCCCCCCCCCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC31C0C3CCCCCCCCCCCCCCCCCCCCCCCCCC415741564189FF415541544C8D25E61E000055488D2DE61E0000534989F64989D54C29E54883EC0848C1FD03E8430000004885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 28000000050000003000000067000000000000002800000076000000240000006F0000007400000022000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3131345F726E676C69737473007900696E74005F5A336261726900636C616E672076657273696F6E20382E302E3020287472756E6B203334353639392920286C6C766D2F7472756E6B203334353530362900746573742E6363006D61696E00780062617200 + - Name: .debug_loclists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '15000000050008000000000003000301005503020101005000' + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B2573171101552374178C01170000022E01111B120640187A196E2503253A0B3B0B49133F190000030500021703253A0B3B0B49130000042E01111B120640187A1903253A0B3B0B49133F1900000534001C0D03253A0B3B0B4913000006240003253E0B0B0B000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 6600000005000108000000000100040001080000000000000002080000000000000000000000000C0000000C00000002000400000001570304010365000000030C0000000701036500000000040106000000015706010765000000050108010865000000000605050400 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '1300000005000800010000000400000003000403010600' + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 1C00000005000800E010200000000000F010200000000000E310200000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 82000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E022200000000FC42F1EAF1396417A8FBE442FBADC7032200000000FC42F1EAF1396417A8FBE442FBADC703000902E01020000000000014050B0A130504063C0201000101000902F0102000000000001805030A140206000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3131345F726E676C6973747300746573742E636300 +Symbols: diff --git a/lit/Breakpoint/Inputs/implicit_const_form_support.yaml b/lit/Breakpoint/Inputs/implicit_const_form_support.yaml new file mode 100644 index 000000000000..f1d8373923b4 --- /dev/null +++ b/lit/Breakpoint/Inputs/implicit_const_form_support.yaml @@ -0,0 +1,41 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004004A0 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004004A0 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C01006400048C7C1A005400048C7C77E054000E8B7FFFFFFF4660F1F440000B820204000483D202040007413B8000000004885C07409BF20204000FFE06690C30F1F440000662E0F1F840000000000BE202040004881EE2020400048C1FE034889F048C1E83F4801C648D1FE7411B8000000004885C07407BF20204000FFE0C30F1F440000662E0F1F840000000000803DD91A0000007517554889E5E87EFFFFFFC605C71A0000015DC30F1F440000C30F1F440000662E0F1F840000000000EB8EB800000000C3B800000000C3554889E5534883EC08E8E6FFFFFF89C3E8E5FFFFFF01D84883C4085B5DC30F1F4000415741564189FF415541544C8D251618000055488D2D16180000534989F64989D54C29E54883EC0848C1FD03E877FEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: 14000000FFFFFFFF03000178100C0708900100000000000014000000000000007205400000000000060000000000000014000000000000007805400000000000060000000000000034000000000000007E054000000000001E0000000000000004010000000E10860204030000000D060405000000830304140000000C070800 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 900000000500010800000000023A00000021310000000000000072054000000000002A0000000000000000000000039A0000000109054C0000007E054000000000001E00000000000000019C040405696E7400012C000000059F0000004C00000078054000000000000600000000000000019C018C00000001910000004C00000072054000000000000600000000000000019C00 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 012E003F19030E3A21013B0B3921056E0E49131101120740187A190000021101250E130B030E1B0E1101120710170000032E003F19030E3A0B3B0B390B49131101120740187C1900000424000B0B3E0B0308000000 + - Name: .debug_aranges + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2C00000002000000000008000000000072054000000000002A0000000000000000000000000000000000000000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 5600000002001F0000000101FB0E0D00010101010000000100000100746573742E6370700000000000050C000902720540000000000001050913050159050C22050913050159050C22050D9105167405175805012F0207000101 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3130315F696D706C696369745F636F6E73742F6E657700666F6F3200746573742E63707000474E5520432B2B313420382E302E3120323031383033313920286578706572696D656E74616C29202D6D74756E653D67656E65726963202D6D617263683D7838362D3634202D67202D6764776172662D3500666F6F31005F5A34666F6F3176006D61696E005F5A34666F6F327600 +Symbols: +... diff --git a/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml b/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml new file mode 100644 index 000000000000..5adc9d82fcad --- /dev/null +++ b/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml @@ -0,0 +1,84 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000010 + Content: 554889E531C0C745FC000000005DC390554889E55DC3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 0C000000050000000000000000000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 746573742E6F002F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C65006D61696E00666F6F005F5A33666F6F7600696E7400 + - Name: .debug_loc.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: '' + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 01110010177217B042251B25B44219B3421711011206000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2B00000005000408000000003F4B7684A29835B9010000000000000000000100000000000000000000000016000000 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_str_offsets.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 200000000500000000000000070000002A00000033000000380000003C00000044000000 + - Name: .debug_str.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 746573742E6F00636C616E672076657273696F6E20382E302E3020287472756E6B203334323731382900746573742E637070006D61696E00696E74005F5A33666F6F7600666F6F00 + - Name: .debug_info.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 3600000005000508000000003F4B7684A29835B901000104000202000F0000000156030101350000000301060000000156050601050404050400 + - Name: .debug_abbrev.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 011101B042252525130503250000022E0011813E1206401803253A0B3B0B49133F190000032E0011813E120640186E2503253A0B3B0B3F19000004240003253E0B0B0B000000 + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '140000000500080000000000000000000000000000000000' + - Name: .debug_names + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: A00000000500000001000000000000000000000004000000040000000D000000080000004C4C564D3037303000000000010000000200000003000000040000003080880B8973880B6A7F9A7C0B3D06B5000000000000000000000000000000000000000009000000120000001B0000002E2E03130000242403130000002435000000000000002E29000000000000002E1A000000000000002E2900000000000000000000 + - Name: .debug_gnu_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 210000000200000000002F0000002900000030666F6F001A000000306D61696E0000000000 + - Name: .debug_gnu_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 170000000200000000002F0000003500000090696E740000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 70000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E020000000000FD7C0F2E46BA561F7BDA351B04E677090000000000FD7C0F2E46BA561F7BDA351B04E6770900090200000000000000000105030AC905003F05010A4B0202000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C6500746573742E63707000 +... diff --git a/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml b/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml new file mode 100644 index 000000000000..da3e160a26e5 --- /dev/null +++ b/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml @@ -0,0 +1,61 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400440 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400440 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C0B005400048C7C14005400048C7C720054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89660F1F840000000000554889E531C0C745FC000000005DC390554889E55DC3662E0F1F840000000000415741564189FF415541544C8D25B618000055488D2DB6180000534989F64989D54C29E54883EC0848C1FD03E87FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 0C000000050000000000000007000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 746573742E6F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006D61696E00666F6F005F5A33666F6F7600696E7400 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 01110010177217B042251B25B44219B3421711011206000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2B00000005000408000000003F4B7684A29835B9010000000008000000000108000000200540000000000016000000 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '140000000500080020054000000000003005400000000000' + - Name: .debug_names + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: A00000000500000001000000000000000000000004000000040000000D000000080000004C4C564D3037303000000000010000000200000003000000040000003080880B8973880B6A7F9A7C0B3D06B56300000057000000520000005B0000000000000009000000120000001B0000002E2E03130000242403130000002435000000000000002E29000000000000002E1A000000000000002E2900000000000000000000 + - Name: .debug_gnu_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 210000000200000000002F0000002900000030666F6F001A000000306D61696E0000000000 + - Name: .debug_gnu_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 170000000200000000002F0000003500000090696E740000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 70000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E024B00000000FD7C0F2E46BA561F7BDA351B04E677094B00000000FD7C0F2E46BA561F7BDA351B04E6770900090220054000000000000105030AC905003F05010A4B0202000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746573742E63707000 +... diff --git a/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml b/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml new file mode 100644 index 000000000000..acacc9b95370 --- /dev/null +++ b/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml @@ -0,0 +1,35 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .debug_loc.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: '' + - Name: .debug_str_offsets.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 200000000500000000000000090000002C000000340000003C0000004000000045000000 + - Name: .debug_str.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 746573742E64776F00636C616E672076657273696F6E20382E302E3020287472756E6B203334373239392900746573742E6363005F5A3362617A760062617A006D61696E00696E7400 + - Name: .debug_info.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 360000000500050800000000E93484C441B7E84A01000104000202000600000001560304010103011C0000000156050104350000000406050400 + - Name: .debug_abbrev.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 011101B042252525130503250000022E00111B120640186E2503253A0B3B0B3F190000032E00111B1206401803253A0B3B0B49133F19000004240003253E0B0B0B000000 +Symbols: {} +DynamicSymbols: {} +... diff --git a/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml b/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml new file mode 100644 index 000000000000..3a362b0d02dd --- /dev/null +++ b/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml @@ -0,0 +1,61 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400440 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400440 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C0C005400048C7C15005400048C7C730054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89660F1F840000000000554889E55DC3662E0F1F840000000000554889E54883EC10C745FC00000000E8DCFFFFFF31C04883C4105DC30F1F4000415741564189FF415541544C8D25A618000055488D2DA6180000534989F64989D54C29E54883EC0848C1FD03E86FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 0C000000050000000000000009000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 746573742E64776F002F686F6D652F756D622F74657374735F323031382F3132322F69737375652F6477617266355F73706C69740062617A005F5A3362617A76006D61696E00696E7400 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 01110010177217B042251B25B442197317111B1206000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 240000000500040800000000E93484C441B7E84A010000000008000000000108000000002C000000 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '140000000500080020054000000000003005400000000000' + - Name: .debug_names + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: A00000000500000001000000000000000000000004000000040000000D000000080000004C4C564D3037303000000000010000000000000003000000000000003080880B64D103B5C260880B6A7F9A7C460000003900000035000000410000000000000009000000120000001B0000002E2E03130000242403130000002435000000000000002E1A000000000000002E1A000000000000002E2600000000000000000000 + - Name: .debug_gnu_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 210000000200000000002800000026000000306D61696E001A0000003062617A0000000000 + - Name: .debug_gnu_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '17000000020000000000280000003500000090696E740000000000' + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 71000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E022C000000004B61BD987753AF9C38389263DC08E24F2C000000004B61BD987753AF9C38389263DC08E24F00090220054000000000000105010A4B0500BC05030AE5750206000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F74657374735F323031382F3132322F69737375652F6477617266355F73706C697400746573742E636300 + diff --git a/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml b/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml new file mode 100644 index 000000000000..6346f6c8eac7 --- /dev/null +++ b/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml @@ -0,0 +1,40 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .debug_loc.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: '' + - Name: .debug_str_offsets.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 5C00000005000000000000000A0000002D000000370000004000000050000000520000005A000000600000006200000066000000760000007F000000840000008A0000008F0000009400000096000000990000009C000000A5000000B5000000 + - Name: .debug_str.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 66696C65312E64776F00636C616E672076657273696F6E20382E302E3020287472756E6B20333437323939290066696C65312E637070007E73747275637431005F5A4E37737472756374313166457600660073747275637431005F5A316776006700696E74005F5A4E377374727563743144324576005F5A347465737476007465737400666C6F6174006D61696E00746869730078007331007332007E73747275637432005F5A4E377374727563743231664576007374727563743200 + - Name: .debug_info.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: D900000005000508000000008D03E0CB5B41F18901000104000202000B000000015607080103B400000003040601020104030202054000000000060405020300072A00000008013200000001565800000001070A30000000090291780FBC0000000A000B029174100108B400000000000C02060000000156010B3A00000002030900000001560B0C010DB80000000D046E00000001560E0111B40000000B0291781101152A0000000B029170120116C1000000000E0905040E0D0404072A0000000304150102060413020705D70000000006140502080007C100000000 + - Name: .debug_abbrev.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 011101B042252525130503250000022E00111B120640186E2503253A0B3B0B49133F190000031301360B03250B0B3A0B3B0B0000042E0103253A0B3B0B3C193F190000050500491334190000062E006E2503253A0B3B0B3C193F190000070F0049130000082E01111B1206401864133A0B3B0B6E2547130000090500021803254913341900000A0B01552300000B3400021803253A0B3B0B491300000C2E00111B120640183A0B3B0B471300000D2E01111B1206401803253A0B3B0B49133F1900000E240003253E0B0B0B000000 + - Name: .debug_rnglists.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 150000000500080001000000040000000101040C1F04253200 +Symbols: {} +DynamicSymbols: {} +... diff --git a/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml b/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml new file mode 100644 index 000000000000..b506415ef8b4 --- /dev/null +++ b/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml @@ -0,0 +1,40 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .debug_loc.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: '' + - Name: .debug_str_offsets.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 3000000005000000000000000A0000002D000000370000004000000050000000520000005A0000006A0000006F00000071000000 + - Name: .debug_str.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 66696C65322E64776F00636C616E672076657273696F6E20382E302E3020287472756E6B20333437323939290066696C65322E637070007E73747275637432005F5A4E37737472756374323166457600660073747275637432005F5A4E3773747275637432443245760074686973007800696E7400 + - Name: .debug_info.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 740000000500050800000000B90811685AA26A1801000104000202040601020603030207043000000000050405020800061A0000000700320000000156480000000103072000000008029178086E00000009000A0291740901047300000000000B0106000000015601072A000000061A0000000C0A050400 + - Name: .debug_abbrev.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 011101B042252525130503250000021301360B03250B0B3A0B3B0B0000032E0103253A0B3B0B3C193F190000040500491334190000052E006E2503253A0B3B0B3C193F190000060F0049130000072E01111B1206401864133A0B3B0B6E254713000008050002180325491334190000090B01552300000A3400021803253A0B3B0B491300000B2E00111B120640183A0B3B0B471300000C240003253E0B0B0B000000 + - Name: .debug_rnglists.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x0000000000000001 + Content: 150000000500080001000000040000000100040C1F04253200 +Symbols: {} +DynamicSymbols: {} +... diff --git a/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml b/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml new file mode 100644 index 000000000000..ee998b4969f5 --- /dev/null +++ b/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml @@ -0,0 +1,70 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400630 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400630 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C0C008400048C7C15008400048C7C790074000E877FFFFFFF4660F1F44000055B840204000483D402040004889E57417B8000000004885C0740D5DBF40204000FFE00F1F4400005DC3660F1F440000BE40204000554881EE402040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF40204000FFE00F1F005DC3660F1F440000803D69190000007517554889E5E87EFFFFFFC60557190000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89900F1F840000000000554889E5B8010000005DC30F1F440000554889E54883EC2048897DF8E8DFFFFFFF8945F0E9000000008B45F08945F44883C4205DC389D14889C7894DECE80E00000066666666662E0F1F84000000000050E88AFEFFFF48890424E891FEFFFF90554889E55DC3662E0F1F840000000000554889E50F57C05DC30F1F8000000000554889E54883EC20C745FC00000000E8CCFFFFFFE897000000E8D2FFFFFFF30F1145E0E900000000C745FC00000000488D7DF0E838000000488D7DF8E84FFFFFFF8B45FC4883C4205DC389D1488945E8894DE4488D7DF0E814000000488D7DF8E82BFFFFFF488B7DE8E812FEFFFF6690554889E54883EC2048897DF8E8FFFEFFFF8945F0E9000000008B45F08945F44883C4205DC389D14889C7894DECE82EFFFFFF66666666662E0F1F840000000000554889E55DC3662E0F1F840000000000415741564189FF415541544C8D257615000055488D2D76150000534989F64989D54C29E54883EC0848C1FD03E81FFDFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .eh_frame_hdr + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400B1C + AddressAlign: 0x0000000000000004 + Content: 011B033BE8FDFFFF0C000000A4FAFFFF04FFFFFF14FBFFFF44FFFFFFF4FBFFFF04FEFFFF04FCFFFF7CFFFFFF44FCFFFF24FEFFFF54FCFFFF3CFEFFFF64FCFFFF5CFEFFFF74FCFFFFA4FFFFFFE4FCFFFFD4FFFFFF24FDFFFF7CFEFFFF34FDFFFFA4FEFFFFA4FDFFFFECFEFFFF + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 0C00000005000000000000000A0000000C000000050000008F0000000A000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 66696C65312E64776F000000000000000000000000000000000000000000000000000000000000000000000000000067005F5A3167760073747275637431007E73747275637431005F5A4E3773747275637431443245760066005F5A4E3773747275637431316645760074657374005F5A347465737476006D61696E00696E7400666C6F617400737472756374320066696C65322E64776F007E73747275637432005F5A4E377374727563743244324576005F5A4E37737472756374323166457600 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 01110010177217B042251B25B44219731711015523741700000001110010177217B042251B25B442197317110155237417000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2C00000005000408000000008D03E0CB5B41F1890100000000080000000001080000000000000000000000000C0000002C000000050004081A000000B90811685AA26A1801F4000000180000000001380000000000000000000000002C000000 + - Name: .debug_rnglists + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 1C00000005000800010000000400000003000B03013203020603030903046E001300000005000800010000000400000003003203010600 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '0000' + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 2C0000000500080010074000000000002007400000000000700740000000000080074000000000009007400000000000140000000500080000084000000000004008400000000000 + - Name: .debug_names + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: 84010000050000000100000000000000000000000D0000000D00000013000000080000004C4C564D3037303000000000000000000000000001000000050000000600000007000000000000000800000000000000000000000B0000000C0000000D0000006CDCF90ECAA55B7A6A7F9A7C1B1710AF1C1710AF0BB602000CB602003080880B88F31A59AB8B407A65689E7C798A6A6F9BE1710F3100000048000000780000003700000087000000580000002F0000007D0000006F0000005A0000006A0000003F000000810000000000000009000000120000001B000000240000002D000000360000003F00000048000000510000005A000000630000006C0000002E2E03130000242403130000131303130000002E1A000000000000002E45000000000000002E8E00000000000000132A0000000000000013C1000000000000002E70000000000000002E1A0000000000000024B4000000000000002E7E000000000000002E70000000000000002E7E000000000000002E450000000000000024B800000000000000D800000005000000010000000000000000000000060000000600000013000000080000004C4C564D30373030300000000100000002000000030000000500000006000000000000007A8A6A6F4BBE6D7A3080880B1C1710AF0BB602002CA4527A99000000A20000007D0000008700000058000000B20000000000000009000000120000001B000000240000002D0000002E2E03130000242403130000131303130000002E35000000000000002E3500000000000000247300000000000000131A000000000000002E60000000000000002E6000000000000000000000 + - Name: .debug_gnu_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 50000000020000000000300000007000000030737472756374313A3A66007E0000003074657374008E000000306D61696E001A0000003067004500000030737472756374313A3A7E73747275637431000000000035000000020030000000300000003500000030737472756374323A3A7E73747275637432006000000030737472756374323A3A660000000000 + - Name: .debug_gnu_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 3C000000020000000000300000002A000000107374727563743100B800000090666C6F617400C1000000107374727563743200B400000090696E74000000000024000000020030000000300000001A0000001073747275637432007300000090696E740000000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: F00000000500080065000000010101FB0E0D00010101010000000100000101011F02000000002500000003011F020F051E0327000000004195A4D2AC12B4F174DBFAD42A0CB9B227000000004195A4D2AC12B4F174DBFAD42A0CB9B2310000000193DBF7D5AE9184526D2D968251B49D0200090210074000000000001405030A4B0207000101000902200740000000000018050B0ABB060378C80507440501063D050B65020D0001010009027007400000000000030A0105140A4A02020001010009028007400000000000030C0105020A4B0205000101000902900740000000000003100105030AE5595DE6050175023F000101A30000000500080065000000010101FB0E0D00010101010000000100000101011F02000000002500000003011F020F051E03390000000040CCBAC21BCB1E430C6A1484F8570F05390000000040CCBAC21BCB1E430C6A1484F8570F05310000000193DBF7D5AE9184526D2D968251B49D02000902000840000000000014050B0ABB06C40507400501063D050B65020D00010100090240084000000000001805140A4A0202000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 000000000000000000000000000000000000000000000000000000000000000000000000002E0066696C65312E637070006465636C732E680066696C65322E63707000 diff --git a/lit/Breakpoint/case-insensitive.test b/lit/Breakpoint/case-insensitive.test index 841448c42990..f6330b5f4320 100644 --- a/lit/Breakpoint/case-insensitive.test +++ b/lit/Breakpoint/case-insensitive.test @@ -1,8 +1,6 @@ -# REQUIRES: windows -# XFAIL: windows -# -> llvm.org/pr24528 -# -# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t +# REQUIRES: system-windows + +# RUN: %build %p/Inputs/case-sensitive.c --nodefaultlib -o %t # RUN: lldb-test breakpoints %t %s | FileCheck %s breakpoint set -f case-sensitive.c -l 3 diff --git a/lit/Breakpoint/case-sensitive.test b/lit/Breakpoint/case-sensitive.test index dd5635b952d6..3f47974c295d 100644 --- a/lit/Breakpoint/case-sensitive.test +++ b/lit/Breakpoint/case-sensitive.test @@ -1,6 +1,6 @@ # REQUIRES: nowindows # -# RUN: %cc %p/Inputs/case-sensitive.c -g -o %t +# RUN: %build %p/Inputs/case-sensitive.c --nodefaultlib -o %t # RUN: lldb-test breakpoints %t %s | FileCheck %s breakpoint set -f case-sensitive.c -l 3 diff --git a/lit/Breakpoint/debug_addrx.test b/lit/Breakpoint/debug_addrx.test new file mode 100644 index 000000000000..d5813cb96686 --- /dev/null +++ b/lit/Breakpoint/debug_addrx.test @@ -0,0 +1,30 @@ +# RUN: yaml2obj %p/Inputs/debug_addrx.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +# The following code and invocation were used. +# clang -gdwarf-5 test.cc -o test_v5 -fuse-ld=lld -fno-rtti -O2 -ffunction-sections +# Then output was converted to yaml and reduced. +# +# struct A { +# void foo() {}; +# }; +# +# void bar(struct A a) { +# a.foo(); +# } +# +# int main() { +# A objA; +# bar(objA); +# +# return 0; +# } +# +# clang and LLD versions were 8.0.0 (trunk 344834) +# +# Output file contains DW_FORM_addrx forms. + +b bar + +# CHECK-LABEL: b bar +# CHECK: Address: {{.*}}`bar(A) at test.cc:15:1 diff --git a/lit/Breakpoint/debug_rnglist_basic.test b/lit/Breakpoint/debug_rnglist_basic.test new file mode 100644 index 000000000000..268e4a0ed301 --- /dev/null +++ b/lit/Breakpoint/debug_rnglist_basic.test @@ -0,0 +1,30 @@ +# RUN: yaml2obj %p/Inputs/debug_rnglist_basic.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +# The following code and invocation were used to produce yaml file, +# which was manually reduced after that. +# clang -O0 -gdwarf-5 test.cpp -o test -fuse-ld=lld -ffunction-sections +# +# //test.cpp: +# int zed() { +# return 1; +# } +# +# int main() { +# return zed(); +# } +# +# clang and LLD versions were 8.0.0 (trunk 343487) +# +# Output file contains .debug_rnglists section with basic entries: +# DW_RLE_start_length and DW_RLE_end_of_list. +# If LLDB would not be able to parse the section and entries correctly, +# then reported location would be incorrect. + +b main +# CHECK-LABEL: b main +# CHECK: Address: {{.*}}`main + 15 at test.cpp:6:9 + +b zed +# CHECK-LABEL: b zed +# CHECK: Address: {{.*}}`zed() + 4 at test.cpp:2:2 diff --git a/lit/Breakpoint/debug_rnglist_offset_pair.test b/lit/Breakpoint/debug_rnglist_offset_pair.test new file mode 100644 index 000000000000..8edf3ee4f000 --- /dev/null +++ b/lit/Breakpoint/debug_rnglist_offset_pair.test @@ -0,0 +1,33 @@ +# RUN: yaml2obj %p/Inputs/debug_rnglist_offset_pair.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +# The following code and invocation were used to produce asm file, +# which was manually edited to add DW_RLE_base_address entry. +# clang -S -g -gdwarf-5 -O1 test.cpp -o test.s +# Then it was compiled and converted to yaml. +# +# int C = 0; +# void foo(int P) +# { +# for (int I = 0; I < 2; ++I) { +# int *W = &C; +# *W &= P; +# } +# } +# +# int main () +# { +# foo (1); +# return 0; +# } +# +# clang and LLD versions were 8.0.0 (trunk 344035) +# +# Output file contains .debug_rnglists section with entries: +# DW_RLE_offset_pair and DW_RLE_base_address. + +b foo +# CHECK-LABEL: b foo +# CHECK: Address: {{.*}}`foo(int) + 5 at test.cpp:8:8 + + diff --git a/lit/Breakpoint/debug_rnglist_rlestartend.test b/lit/Breakpoint/debug_rnglist_rlestartend.test new file mode 100644 index 000000000000..9c8beb82c529 --- /dev/null +++ b/lit/Breakpoint/debug_rnglist_rlestartend.test @@ -0,0 +1,28 @@ +# RUN: yaml2obj %p/Inputs/debug_rnglist_rlestartend.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +# Test shows that LDLB is able to handle DW_RLE_start_end entries properly. + +# The following code and invocation were used to produce asm file. +# clang -O0 -gdwarf-5 test.cpp -S -o test.s -fuse-ld=lld -ffunction-sections +# It was edited to use DW_RLE_start_end, compiled and converted to yaml. +# The yaml was manually reduced. +# +# //test.cpp: +# int zed() { +# return 1; +# } +# +# int main() { +# return zed(); +# } +# +# clang and LLD versions were 8.0.0 (trunk 344035) + +b main +# CHECK-LABEL: b main +# CHECK: Address: {{.*}}`main + 15 at test.cpp:6:10 + +b zed +# CHECK-LABEL: b zed +# CHECK: Address: {{.*}}`zed() + 4 at test.cpp:2:3 diff --git a/lit/Breakpoint/debug_rnglistx_rlex.test b/lit/Breakpoint/debug_rnglistx_rlex.test new file mode 100644 index 000000000000..79a80479e72c --- /dev/null +++ b/lit/Breakpoint/debug_rnglistx_rlex.test @@ -0,0 +1,28 @@ +# RUN: yaml2obj %p/Inputs/debug_rnglistx_rlex.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +# The following code and invocation were used. +# clang -gdwarf-5 test.cc -o test_v5 -fuse-ld=lld -fno-rtti -O2 -ffunction-sections +# Then output was converted to yaml and reduced. +# +# int bar(int x) { +# return ++x; +# } +# +# int main() { +# int y = 1; +# return bar(y); +# } +# +# clang and LLD versions were 8.0.0 (trunk 345699) +# +# Output file contains DW_FORM_rnglistx and DW_RLE_startx_length. + +b bar +b main + +# CHECK-LABEL: b bar +# CHECK: Address: {{.*}}`bar(int) at test.cc:4:11 + +# CHECK-LABEL: b main +# CHECK: Address: {{.*}}`main at test.cc:9:3 diff --git a/lit/Breakpoint/implicit_const_form_support.test b/lit/Breakpoint/implicit_const_form_support.test new file mode 100644 index 000000000000..183181d2f307 --- /dev/null +++ b/lit/Breakpoint/implicit_const_form_support.test @@ -0,0 +1,33 @@ +# RUN: yaml2obj %p/Inputs/implicit_const_form_support.yaml > %ttest +# RUN: lldb-test breakpoints %ttest %s | FileCheck %s + +## The intention of the test is to check that DW_FORM_implicit_const +## is supported and handled properly. + +## About implicit_const_form_support.yaml: +## The following invocation and code were used to produce the binary +## which was converted to yaml and reduced: +## gcc version 8.0.1 20180319 (experimental) (GCC) +## +## g++ test.cpp -g -gdwarf-5 -o test +## +## // test.cpp +## int foo1() { +## return 0; +## } +## +## int foo2() { +## return 0; +## } +## +## int main() { +## return foo1() + foo2(); +## } + +b foo1 +# CHECK-LABEL: b foo1 +# CHECK: Address: {{.*}}foo1() at test.cpp:2:9 + +b foo2 +# CHECK-LABEL: b foo2 +# CHECK: Address: {{.*}}foo2() at test.cpp:6:9 diff --git a/lit/Breakpoint/single-file-split-dwarf.test b/lit/Breakpoint/single-file-split-dwarf.test new file mode 100644 index 000000000000..d0cc003bf210 --- /dev/null +++ b/lit/Breakpoint/single-file-split-dwarf.test @@ -0,0 +1,44 @@ +# RUN: rm -rf %t.dir +# RUN: mkdir %t.dir +# RUN: cd %t.dir +# RUN: yaml2obj %p/Inputs/single-file-split-dwarf.yaml > %t.dir/test +# RUN: yaml2obj %p/Inputs/single-file-split-dwarf.o.yaml > %t.dir/test.o +# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s + +# This test checks that source code location is shown correctly +# when single split file debug information is used (when .dwo sections are in .o files). +# +# single-file-split-dwarf.yaml and single-file-split-dwarf.o.yaml are +# reduced yaml files produces from the object file and the corresponding executable. +# +# The following code was used initially: +# int main() { +# return 0; +# } +# +# void foo() { +# } +# +# Invocation used to produce .o file was: +# clang test.cpp -gdwarf-5 -gsplit-dwarf=single -c -o test.o -v +# +# The full invocation used to produce the executable was: +# "/usr/local/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker +# /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crt1.o +# /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7.3.0/crtbegin.o +# -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0 -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu +# -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../.. +# -L/home/umb/LLVM/build/bin/../lib -L/lib -L/usr/lib test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc +# --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/7.3.0/crtend.o +# /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crtn.o +# +# Also, the DW_AT_comp_dir string value set to empty in yaml produced. +# Build bots had different path there and failed to find object. + +b main +# CHECK-LABEL: b main +# CHECK: Address: {{.*}}main + 13 at test.cpp:2:3 + +b foo +# CHECK-LABEL: b foo +# CHECK: Address: {{.*}}foo() + 4 at test.cpp:6:1 diff --git a/lit/Breakpoint/split-dwarf-5-addrbase.test b/lit/Breakpoint/split-dwarf-5-addrbase.test new file mode 100644 index 000000000000..72a717d609dc --- /dev/null +++ b/lit/Breakpoint/split-dwarf-5-addrbase.test @@ -0,0 +1,30 @@ +# RUN: rm -rf %t.dir +# RUN: mkdir %t.dir +# RUN: cd %t.dir +# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.dwo.yaml > %t.dir/test.dwo +# RUN: yaml2obj %p/Inputs/split-dwarf-5-addrbase.yaml > %t.dir/test +# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s + +# This test checks that source code location is shown correctly +# when -gsplit-dwarf and DWARF 5 are used. +# +# split-dwarf-5-addrbase.dwo.yaml and split-dwarf-5-addrbase.yamlare +# reduced yaml files produces from the dwo file and the corresponding executable. +# +# The following code was used initially: +# void baz() { +# } +# +# int main() { +# baz(); +# return 0; +# } +# +# Invocation used to produce outputs was: +# clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf +# clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf +# clang version 8.0.0 (trunk 347299) + +b baz +# CHECK-LABEL: b baz +# CHECK: Address: {{.*}}baz() + 4 at test.cc:2:1 diff --git a/lit/Breakpoint/split-dwarf5-debug-stroffsets.test b/lit/Breakpoint/split-dwarf5-debug-stroffsets.test new file mode 100644 index 000000000000..c1418ebb0d52 --- /dev/null +++ b/lit/Breakpoint/split-dwarf5-debug-stroffsets.test @@ -0,0 +1,84 @@ +# RUN: rm -rf %t.dir +# RUN: mkdir %t.dir +# RUN: cd %t.dir +# RUN: yaml2obj %p/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml > %t.dir/file1.dwo +# RUN: yaml2obj %p/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml > %t.dir/file2.dwo +# RUN: yaml2obj %p/Inputs/split-dwarf5-debug-stroffsets-main.yaml > %t.dir/test +# RUN: lldb-test breakpoints %t.dir/test %s | FileCheck %s + +# This test checks that source code location is shown correctly +# when split DWARF 5 is used and both DWO/executable file contains +# .debug_str_offsets/.debug_str_offsets.dwo sections. +# Used clang version 8.0.0 (trunk 347299) +# +# split-dwarf5-debug-stroffsets-file1.dwo.yaml, split-dwarf5-debug-stroffsets-file2.dwo.yaml +# and split-dwarf5-debug-stroffsets-main.yaml are reduced yaml files produces +# from the DWO files and the corresponding executable. +# +# Code: +# // decl.h +# struct struct1 { +# ~struct1(); +# static void f(); +# }; +# +# struct struct2 { +# ~struct2(); +# static void f(); +# }; +# +# int g(); +# +# // file1.cpp +# #include "decls.h" +# +# int g() { +# return 1; +# } +# +# struct1::~struct1() { +# int x = g(); +# } +# +# void struct1::f() {} +# +# float test() { +# return 0.0f; +# } +# +# int main() { +# struct1::f(); +# struct2::f(); +# +# struct1 s1; +# struct2 s2; +# +# test(); +# +# return 0; +# } +# +# // file2.cpp +# +# +# #include "decls.h" +# +# struct2::~struct2() { +# int x = g(); +# } +# +# void struct2::f() {} +# +# +# Invocation used was: +# clang++ file1.cpp -o file1.o -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf -ffunction-sections +# clang++ file2.cpp -o file2.o -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf -ffunction-sections +# clang++ file1.o file2.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf -ffunction-sections + +b struct1::f +# CHECK-LABEL: b struct1::f +# CHECK: Address: {{.*}}struct1::f() + 4 at file1.cpp:11:20 + +b struct2::f +# CHECK-LABEL: b struct2::f +# CHECK: Address: {{.*}}struct2::f() + 4 at file2.cpp:7:20 diff --git a/lit/BuildScript/modes.test b/lit/BuildScript/modes.test new file mode 100644 index 000000000000..02311f712d77 --- /dev/null +++ b/lit/BuildScript/modes.test @@ -0,0 +1,35 @@ +RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any -o %t/foo.out foobar.c \ +RUN: | FileCheck --check-prefix=COMPILE %s + +RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any --outdir %t foo.c bar.c \ +RUN: | FileCheck --check-prefix=COMPILE-MULTI %s + +RUN: %build -n --verbose --arch=32 --mode=link --compiler=any -o %t/foo.exe foobar.obj \ +RUN: | FileCheck --check-prefix=LINK %s + +RUN: %build -n --verbose --arch=32 --mode=link --compiler=any -o %t/foobar.exe foo.obj bar.obj \ +RUN: | FileCheck --check-prefix=LINK-MULTI %s + +RUN: %build -n --verbose --arch=32 --mode=compile-and-link --compiler=any -o %t/foobar.exe foobar.c \ +RUN: | FileCheck --check-prefix=BOTH %s + +RUN: %build -n --verbose --arch=32 --mode=compile-and-link --compiler=any -o %t/foobar.exe foo.c bar.c \ +RUN: | FileCheck --check-prefix=BOTH-MULTI %s + + +COMPILE: compiling foobar.c -> foo.out + +COMPILE-MULTI: compiling foo.c -> foo.o{{(bj)?}} +COMPILE-MULTI: compiling bar.c -> bar.o{{(bj)?}} + + +LINK: linking foobar.obj -> foo.exe + +LINK-MULTI: linking foo.obj+bar.obj -> foobar.exe + +BOTH: compiling foobar.c -> [[OBJFOO:foobar.exe-foobar.o(bj)?]] +BOTH: linking [[OBJFOO]] -> foobar.exe + +BOTH-MULTI: compiling foo.c -> [[OBJFOO:foobar.exe-foo.o(bj)?]] +BOTH-MULTI: compiling bar.c -> [[OBJBAR:foobar.exe-bar.o(bj)?]] +BOTH-MULTI: linking [[OBJFOO]]+[[OBJBAR]] -> foobar.exe diff --git a/lit/BuildScript/script-args.test b/lit/BuildScript/script-args.test new file mode 100644 index 000000000000..13e8a5160942 --- /dev/null +++ b/lit/BuildScript/script-args.test @@ -0,0 +1,32 @@ +RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any -o %t/foo.out foobar.c \ +RUN: | FileCheck %s +RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any --outdir %t foo.c bar.c \ +RUN: | FileCheck --check-prefix=MULTI-INPUT %s + + +CHECK: Script Arguments: +CHECK-NEXT: Arch: 32 +CHECK: Compiler: any +CHECK: Outdir: {{.*}}script-args.test.tmp +CHECK: Output: {{.*}}script-args.test.tmp{{.}}foo.out +CHECK: Nodefaultlib: False +CHECK: Opt: none +CHECK: Mode: compile +CHECK: Clean: True +CHECK: Verbose: True +CHECK: Dryrun: True +CHECK: Inputs: foobar.c + +MULTI-INPUT: Script Arguments: +MULTI-INPUT-NEXT: Arch: 32 +MULTI-INPUT-NEXT: Compiler: any +MULTI-INPUT-NEXT: Outdir: {{.*}}script-args.test.tmp +MULTI-INPUT-NEXT: Output: +MULTI-INPUT-NEXT: Nodefaultlib: False +MULTI-INPUT-NEXT: Opt: none +MULTI-INPUT-NEXT: Mode: compile +MULTI-INPUT-NEXT: Clean: True +MULTI-INPUT-NEXT: Verbose: True +MULTI-INPUT-NEXT: Dryrun: True +MULTI-INPUT-NEXT: Inputs: foo.c +MULTI-INPUT-NEXT: bar.c diff --git a/lit/BuildScript/toolchain-clang-cl.test b/lit/BuildScript/toolchain-clang-cl.test new file mode 100644 index 000000000000..cc219aca158f --- /dev/null +++ b/lit/BuildScript/toolchain-clang-cl.test @@ -0,0 +1,49 @@ +REQUIRES: lld, system-windows + +RUN: %build -n --verbose --arch=32 --compiler=clang-cl --mode=compile-and-link -o %t/foo.exe foobar.c \ +RUN: | FileCheck --check-prefix=CHECK-32 %s + +RUN: %build -n --verbose --arch=64 --compiler=clang-cl --mode=compile-and-link -o %t/foo.exe foobar.c \ +RUN: | FileCheck --check-prefix=CHECK-64 %s + +CHECK-32: Script Arguments: +CHECK-32: Arch: 32 +CHECK-32: Compiler: clang-cl +CHECK-32: Outdir: {{.*}} +CHECK-32: Output: {{.*}}toolchain-clang-cl.test.tmp\foo.exe +CHECK-32: Nodefaultlib: False +CHECK-32: Opt: none +CHECK-32: Mode: compile +CHECK-32: Clean: True +CHECK-32: Verbose: True +CHECK-32: Dryrun: True +CHECK-32: Inputs: foobar.c +CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foobar.ilk +CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe-foobar.obj +CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.pdb +CHECK-32: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe +CHECK-32: compiling foobar.c -> foo.exe-foobar.obj +CHECK-32: {{.*}}clang-cl{{(.exe)?}} -m32 +CHECK-32: linking foo.exe-foobar.obj -> foo.exe +CHECK-32: {{.*}}lld-link + +CHECK-64: Script Arguments: +CHECK-64: Arch: 64 +CHECK-64: Compiler: clang-cl +CHECK-64: Outdir: {{.*}} +CHECK-64: Output: {{.*}}toolchain-clang-cl.test.tmp\foo.exe +CHECK-64: Nodefaultlib: False +CHECK-64: Opt: none +CHECK-64: Mode: compile +CHECK-64: Clean: True +CHECK-64: Verbose: True +CHECK-64: Dryrun: True +CHECK-64: Inputs: foobar.c +CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foobar.ilk +CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe-foobar.obj +CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.pdb +CHECK-64: Cleaning {{.*}}toolchain-clang-cl.test.tmp{{.}}foo.exe +CHECK-64: compiling foobar.c -> foo.exe-foobar.obj +CHECK-64: {{.*}}clang-cl{{(.exe)?}} -m64 +CHECK-64: linking foo.exe-foobar.obj -> foo.exe +CHECK-64: {{.*}}lld-link{{(.exe)?}} diff --git a/lit/BuildScript/toolchain-clang.test b/lit/BuildScript/toolchain-clang.test new file mode 100644 index 000000000000..416dc30f6c96 --- /dev/null +++ b/lit/BuildScript/toolchain-clang.test @@ -0,0 +1,14 @@ +RUN: %build -n --verbose --arch=32 --compiler=clang --mode=compile-and-link -o %t/foo.exe foobar.c \ +RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s + +RUN: %build -n --verbose --arch=64 --compiler=clang --mode=compile-and-link -o %t/foo.exe foobar.c \ +RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s + +CHECK: Cleaning {{.*}}toolchain-clang.test.tmp{{.}}foo.exe-foobar.o +CHECK: Cleaning {{.*}}toolchain-clang.test.tmp{{.}}foo.exe +CHECK: compiling foobar.c -> foo.exe-foobar.o +CHECK-32: {{.*}}clang++{{(.exe)?}} -m32 -g -O0 -c -o {{.*}}foo.exe-foobar.o {{.*}}foobar.c +CHECK-64: {{.*}}clang++{{(.exe)?}} -m64 -g -O0 -c -o {{.*}}foo.exe-foobar.o {{.*}}foobar.c +CHECK: linking foo.exe-foobar.o -> foo.exe +CHECK-32: {{.*}}clang++{{(.exe)?}} -m32 -o {{.*}}foo.exe {{.*}}foo.exe-foobar.o +CHECK-64: {{.*}}clang++{{(.exe)?}} -m64 -o {{.*}}foo.exe {{.*}}foo.exe-foobar.o diff --git a/lit/BuildScript/toolchain-msvc.test b/lit/BuildScript/toolchain-msvc.test new file mode 100644 index 000000000000..85a8f0d62f0c --- /dev/null +++ b/lit/BuildScript/toolchain-msvc.test @@ -0,0 +1,62 @@ +REQUIRES: system-windows, msvc + +RUN: %build -n --verbose --arch=32 --compiler=msvc --mode=compile-and-link -o %t/foo.exe foobar.c \ +RUN: | FileCheck --check-prefix=X86 %s + +RUN: %build -n --verbose --arch=64 --compiler=msvc --mode=compile-and-link -o %t/foo.exe foobar.c \ +RUN: | FileCheck --check-prefix=X64 %s + +X86: Script Arguments: +X86: Arch: 32 +X86: Compiler: msvc +X86: Outdir: {{.*}} +X86: Output: {{.*}}toolchain-msvc.test.tmp\foo.exe +X86: Nodefaultlib: False +X86: Opt: none +X86: Mode: compile +X86: Clean: True +X86: Verbose: True +X86: Dryrun: True +X86: Inputs: foobar.c +X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foobar.ilk +X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe-foobar.obj +X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.pdb +X86: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe +X86: compiling foobar.c -> foo.exe-foobar.obj +X86: Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x86\cl.exe +X86: linking foo.exe-foobar.obj -> foo.exe +X86: Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x86\link.exe +X86: Env +X86: LIB = {{.*}}\ATLMFC\lib\x86 +X86: {{.*}}\lib\x86 +X86: {{.*}}\ucrt\x86 +X86: {{.*}}\um\x86 +X86: PATH = {{.*}}\bin\{{[Hh]ost[Xx]64}}\x64 + + +X64: Script Arguments: +X64: Arch: 64 +X64: Compiler: msvc +X64: Outdir: {{.*}} +X64: Output: {{.*}}toolchain-msvc.test.tmp\foo.exe +X64: Nodefaultlib: False +X64: Opt: none +X64: Mode: compile +X64: Clean: True +X64: Verbose: True +X64: Dryrun: True +X64: Inputs: foobar.c +X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foobar.ilk +X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe-foobar.obj +X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.pdb +X64: Cleaning {{.*}}toolchain-msvc.test.tmp\foo.exe +X64: compiling foobar.c -> foo.exe-foobar.obj +X64: Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x64\cl.exe +X64: linking foo.exe-foobar.obj -> foo.exe +X64: Command Line: {{.*}}\{{[Hh]ost[Xx]64}}\x64\link.exe +X64: Env +X64: LIB = {{.*}}\ATLMFC\lib\x64 +X64: {{.*}}\lib\x64 +X64: {{.*}}\ucrt\x64 +X64: {{.*}}\um\x64 +X64: PATH = {{.*}}\bin\{{[Hh]ost[Xx]64}}\x64 diff --git a/lit/CMakeLists.txt b/lit/CMakeLists.txt index 5f4e2f0afe2a..4365ba2c35d3 100644 --- a/lit/CMakeLists.txt +++ b/lit/CMakeLists.txt @@ -7,13 +7,9 @@ else () set(LLVM_BUILD_MODE "%(build_mode)s") endif () -if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER) - string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_C_COMPILER ${LLDB_TEST_C_COMPILER}) -endif () - -if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER) - string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_CXX_COMPILER ${LLDB_TEST_CXX_COMPILER}) -endif () +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LLDB_IS_64_BITS 1) +endif() get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY) @@ -24,6 +20,7 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_D list(APPEND LLDB_TEST_DEPS LLDBUnitTests dsymutil + llc lldb lldb-test llvm-config @@ -33,32 +30,28 @@ list(APPEND LLDB_TEST_DEPS if(TARGET lld) list(APPEND LLDB_TEST_DEPS lld) - set(LLDB_HAVE_LLD 1) -else() - set(LLDB_HAVE_LLD 0) endif() -if(BUILD_SHARED_LIBS) - set(ENABLE_SHARED 1) -else() - set(ENABLE_SHARED 0) -endif(BUILD_SHARED_LIBS) - # the value is not canonicalized within LLVM llvm_canonicalize_cmake_booleans( LLDB_DISABLE_PYTHON - LLVM_ENABLE_ZLIB) + LLVM_ENABLE_ZLIB + LLDB_IS_64_BITS) # This should be inherited from the `check-lldb` target. We currently don't run # it for swift, but we might consider removing this code once we're done. set(LIT_ARGS "-sv") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg) @@ -66,19 +59,13 @@ configure_lit_site_cfg( if(NOT LLDB_BUILT_STANDALONE) list(APPEND LLDB_TEST_DEPS FileCheck + count not - ) -endif() - -set(LLDB_TEST_PARAMS - lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ) +endif() add_lit_testsuite(check-lldb-lit "Running lldb lit test suite" ${CMAKE_CURRENT_BINARY_DIR} - ${LIT_ARGS} - PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg DEPENDS ${LLDB_TEST_DEPS} ) @@ -91,9 +78,6 @@ if (TARGET clang) endif() add_lit_testsuites(LLDB - ${CMAKE_CURRENT_BINARY_DIR} - ${LIT_ARGS} - PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${LLDB_TEST_DEPS} ) diff --git a/lit/Driver/Inputs/Print0.in b/lit/Driver/Inputs/Print0.in new file mode 100644 index 000000000000..cb545cc15ab0 --- /dev/null +++ b/lit/Driver/Inputs/Print0.in @@ -0,0 +1 @@ +expr 0 diff --git a/lit/Driver/Inputs/Print2.in b/lit/Driver/Inputs/Print2.in new file mode 100644 index 000000000000..f51389a02a07 --- /dev/null +++ b/lit/Driver/Inputs/Print2.in @@ -0,0 +1 @@ +expr 2 diff --git a/lit/Driver/Inputs/Print4.in b/lit/Driver/Inputs/Print4.in new file mode 100644 index 000000000000..a2d49f30b990 --- /dev/null +++ b/lit/Driver/Inputs/Print4.in @@ -0,0 +1 @@ +expr 4 diff --git a/lit/Driver/Inputs/Print6.in b/lit/Driver/Inputs/Print6.in new file mode 100644 index 000000000000..dee6212b87c1 --- /dev/null +++ b/lit/Driver/Inputs/Print6.in @@ -0,0 +1 @@ +expr 6 diff --git a/lit/Driver/Inputs/convenience.in b/lit/Driver/Inputs/convenience.in new file mode 100644 index 000000000000..6d5603c43513 --- /dev/null +++ b/lit/Driver/Inputs/convenience.in @@ -0,0 +1,9 @@ +breakpoint set -f hello.cpp -p Hello +run +script print(lldb.debugger) +script print(lldb.target) +script print(lldb.process) +script print(lldb.thread.GetStopDescription(100)) +script lldb.frame.GetLineEntry().GetLine() +script lldb.frame.GetLineEntry().GetFileSpec().GetFilename() +script lldb.frame.GetFunctionName() diff --git a/lit/Driver/Inputs/hello.cpp b/lit/Driver/Inputs/hello.cpp new file mode 100644 index 000000000000..1ec0677aeb2c --- /dev/null +++ b/lit/Driver/Inputs/hello.cpp @@ -0,0 +1,11 @@ +// The build.py script always runs the compiler in C++ mode, regardless of the +// file extension. This results in mangled names presented to the linker which +// in turn cannot find the printf symbol. +extern "C" { +int printf(const char *format, ...); + +int main(int argc, char **argv) { + printf("Hello World\n"); + return 0; +} +} diff --git a/lit/Driver/TestCommands.test b/lit/Driver/TestCommands.test new file mode 100644 index 000000000000..3589abb8278c --- /dev/null +++ b/lit/Driver/TestCommands.test @@ -0,0 +1,41 @@ +# RUN: %lldb -x -b \ +# RUN: -S %S/Inputs/Print0.in \ +# RUN: -O 'expr 1' \ +# RUN: -S %S/Inputs/Print2.in \ +# RUN: -O 'expr 3' \ +# RUN: -s %S/Inputs/Print4.in \ +# RUN: -o 'expr 5' \ +# RUN: -s %S/Inputs/Print6.in \ +# RUN: -o 'expr 7' \ +# RUN: | FileCheck %s +# +# RUN: %lldb -x -b \ +# RUN: -s %S/Inputs/Print4.in \ +# RUN: -o 'expr 5' \ +# RUN: -s %S/Inputs/Print6.in \ +# RUN: -o 'expr 7' \ +# RUN: -S %S/Inputs/Print0.in \ +# RUN: -O 'expr 1' \ +# RUN: -S %S/Inputs/Print2.in \ +# RUN: -O 'expr 3' \ +# RUN: | FileCheck %s +# +# RUN: %lldb -x -b \ +# RUN: -s %S/Inputs/Print4.in \ +# RUN: -S %S/Inputs/Print0.in \ +# RUN: -o 'expr 5' \ +# RUN: -O 'expr 1' \ +# RUN: -s %S/Inputs/Print6.in \ +# RUN: -S %S/Inputs/Print2.in \ +# RUN: -o 'expr 7' \ +# RUN: -O 'expr 3' \ +# RUN: | FileCheck %s + +# CHECK: (int) $0 = 0 +# CHECK: (int) $1 = 1 +# CHECK: (int) $2 = 2 +# CHECK: (int) $3 = 3 +# CHECK: (int) $4 = 4 +# CHECK: (int) $5 = 5 +# CHECK: (int) $6 = 6 +# CHECK: (int) $7 = 7 diff --git a/lit/Driver/TestConvenienceVariables.test b/lit/Driver/TestConvenienceVariables.test new file mode 100644 index 000000000000..99536e4c0290 --- /dev/null +++ b/lit/Driver/TestConvenienceVariables.test @@ -0,0 +1,22 @@ +RUN: %build %p/Inputs/hello.cpp -o %t +RUN: %lldb %t -s %p/Inputs/convenience.in -o quit | FileCheck %s + +script print(lldb.debugger) + +CHECK: stop reason = breakpoint 1.1 +CHECK: Debugger (instance: {{.*}}, id: {{[0-9]+}}) +CHECK: script print(lldb.target) +CHECK: TestConvenienceVariables.test +CHECK: script print(lldb.process) +CHECK: SBProcess: pid = {{[0-9]+}}, +CHECK-SAME: state = stopped, +CHECK-SAME: threads = {{[0-9]+}}, +CHECK-SAME: executable = TestConvenienceVariables.test +CHECK: script print(lldb.thread.GetStopDescription(100)) +CHECK: breakpoint 1.1 +CHECK: script lldb.frame.GetLineEntry().GetLine() +CHECK: 8 +CHECK: script lldb.frame.GetLineEntry().GetFileSpec().GetFilename() +CHECK: hello.c +CHECK: script lldb.frame.GetFunctionName() +CHECK: main \ No newline at end of file diff --git a/lit/Driver/TestCore.test b/lit/Driver/TestCore.test new file mode 100644 index 000000000000..cca8171da631 --- /dev/null +++ b/lit/Driver/TestCore.test @@ -0,0 +1,2 @@ +# RUN: not %lldb -c /bogus/path 2>&1 | FileCheck %s +# CHECK: error: file specified in --core (-c) option doesn't exist diff --git a/lit/Driver/TestFile.test b/lit/Driver/TestFile.test new file mode 100644 index 000000000000..0e80594aeb1b --- /dev/null +++ b/lit/Driver/TestFile.test @@ -0,0 +1,2 @@ +# RUN: not %lldb -f /bogus/path 2>&1 | FileCheck %s +# CHECK: error: file specified in --file (-f) option doesn't exist diff --git a/lit/Driver/TestNoUseColor.test b/lit/Driver/TestNoUseColor.test new file mode 100644 index 000000000000..62735301fca8 --- /dev/null +++ b/lit/Driver/TestNoUseColor.test @@ -0,0 +1,4 @@ +# RUN: %lldb --no-use-color -s %s | FileCheck %s +settings show use-color +# CHECK: use-color (boolean) = false +q diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook-1.lldbinit b/lit/ExecControl/StopHook/Inputs/stop-hook-1.lldbinit new file mode 100644 index 000000000000..4ab5d56f0364 --- /dev/null +++ b/lit/ExecControl/StopHook/Inputs/stop-hook-1.lldbinit @@ -0,0 +1 @@ +target stop-hook add -n b -o "expr ptr" diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit b/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit new file mode 100644 index 000000000000..13de5fb60bc7 --- /dev/null +++ b/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit @@ -0,0 +1 @@ +target stop-hook add -f stop-hook.c -l 29 -e 34 -o "expr ptr" \ No newline at end of file diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit b/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit new file mode 100644 index 000000000000..b4dcda2f88fc --- /dev/null +++ b/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit @@ -0,0 +1,3 @@ +target stop-hook add -f stop-hook.c -l 29 -e 34 +expr ptr +DONE \ No newline at end of file diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit b/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit new file mode 100644 index 000000000000..f192d9952e97 --- /dev/null +++ b/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit @@ -0,0 +1,7 @@ +break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook" +run +target stop-hook add +frame variable --show-globals g_val +thread list +continue +DONE diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit b/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit new file mode 100644 index 000000000000..467f60b1e1e0 --- /dev/null +++ b/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit @@ -0,0 +1,4 @@ +break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook" +run +target stop-hook add -x 2 -o "frame variable thread_index" +target stop-hook add -o continue diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp b/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp index dab133d9d952..5b6f31edd1b5 100644 --- a/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp +++ b/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/lit/ExecControl/StopHook/Inputs/stop-hook.c b/lit/ExecControl/StopHook/Inputs/stop-hook.c index c10c1e5ef0d2..e1b2579526d3 100644 --- a/lit/ExecControl/StopHook/Inputs/stop-hook.c +++ b/lit/ExecControl/StopHook/Inputs/stop-hook.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/lit/ExecControl/StopHook/stop-hook-threads.test b/lit/ExecControl/StopHook/stop-hook-threads.test index cdda6c0827d6..aa6b668340c7 100644 --- a/lit/ExecControl/StopHook/stop-hook-threads.test +++ b/lit/ExecControl/StopHook/stop-hook-threads.test @@ -1,20 +1,9 @@ -# RUN: %cxx %p/Inputs/stop-hook-threads.cpp -g -o %t -# RUN: %lldb -b -s %s -O 'target create %t' \ -# RUN: -O 'break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook"' \ -# RUN: -O run \ -# RUN: -O 'target stop-hook add' \ -# RUN: -O "frame variable --show-globals g_val" \ -# RUN: -O "thread list" \ -# RUN: -O continue \ -# RUN: -O DONE \ +# RUN: %clangxx %p/Inputs/stop-hook-threads.cpp -g -o %t +# RUN: %lldb -b -s %p/Inputs/stop-hook-threads-1.lldbinit -s %s -f %t \ # RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NO-FILTER %s -# RUN: %lldb -b -s %s \ -# RUN: -O 'target create %t' \ -# RUN: -O 'break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook"' \ -# RUN: -O run \ -# RUN: -O 'target stop-hook add -x 2 -o "frame variable thread_index"' \ -# RUN: -O 'target stop-hook add -o continue' \ +# RUN: %lldb -b -s %p/Inputs/stop-hook-threads-2.lldbinit -s %s -f %t \ # RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FILTER %s +# XFAIL: system-windows thread list break set -f stop-hook-threads.cpp -p "Set break point at this line" diff --git a/lit/ExecControl/StopHook/stop-hook.test b/lit/ExecControl/StopHook/stop-hook.test index 8db10f54fbda..ca6495ef14ad 100644 --- a/lit/ExecControl/StopHook/stop-hook.test +++ b/lit/ExecControl/StopHook/stop-hook.test @@ -1,11 +1,16 @@ -# RUN: %cc %p/Inputs/stop-hook.c -g -o %t +# RUN: %clang %p/Inputs/stop-hook.c -g -o %t # Test setting stop-hook per-function -# RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -n b -o "expr ptr"' \ +# RUN: %lldb -b -s %p/Inputs/stop-hook-1.lldbinit -s %s -f %t \ # RUN: | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FUNC %s # Test setting stop-hook per-line range -# RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -f stop-hook.c -l 30 -e 34 -o "expr ptr"' | FileCheck %s +# RUN: %lldb -b -s %p/Inputs/stop-hook-2.lldbinit -s %s -f %t | FileCheck %s # Test setting stop-hook with multi-line expression -# RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -f stop-hook.c -l 30 -e 34' -O 'expr ptr' -O DONE | FileCheck %s +# RUN: %lldb -b -s %p/Inputs/stop-hook-3.lldbinit -s %s -f %t | FileCheck %s +# This test is not "unsupported" on Windows, but it fails because "expr ptr" +# does not evaluate correctly. However, the error message contains the expected +# string, so the test "passes" despite the fact that the commands failed +# llvm.org/pr40119 +# UNSUPPORTED: system-windows break set -f stop-hook.c -p "// Set breakpoint here to test target stop-hook" break set -f stop-hook.c -p "// Another breakpoint which is outside of the stop-hook range" diff --git a/lit/Expr/TestIRMemoryMap.test b/lit/Expr/TestIRMemoryMap.test index 23595945011d..a8f835b1676e 100644 --- a/lit/Expr/TestIRMemoryMap.test +++ b/lit/Expr/TestIRMemoryMap.test @@ -1,6 +1,6 @@ -# XFAIL: windows +# UNSUPPORTED: system-windows -# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t +# RUN: %clangxx %p/Inputs/call-function.cpp -g -o %t # RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic # RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic diff --git a/lit/Expr/TestIRMemoryMapWindows.test b/lit/Expr/TestIRMemoryMapWindows.test new file mode 100644 index 000000000000..f25db591fa51 --- /dev/null +++ b/lit/Expr/TestIRMemoryMapWindows.test @@ -0,0 +1,13 @@ +# REQUIRES: system-windows + +# RUN: %clang_cl /Zi /GS- %p/Inputs/call-function.cpp /c /o %t.obj +# RUN: %msvc_link /debug:full %t.obj /out:%t + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-basic + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-overlap1 +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-overlap1 + +# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-mix-malloc-free +# RUN: lldb-test ir-memory-map -host-only %t %S/Inputs/ir-memory-map-mix-malloc-free diff --git a/lit/Minidump/Inputs/dump-content.dmp b/lit/Minidump/Inputs/dump-content.dmp new file mode 100644 index 000000000000..18eb59ffb7e6 Binary files /dev/null and b/lit/Minidump/Inputs/dump-content.dmp differ diff --git a/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp new file mode 100644 index 000000000000..6bf78b5dc43b --- /dev/null +++ b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp @@ -0,0 +1,40 @@ + +// nodefaultlib build: cl -Zi sigsegv.cpp /link /nodefaultlib + +#ifdef USE_CRT +#include +#else +int main(); +extern "C" +{ + int _fltused; + void mainCRTStartup() { main(); } + void printf(const char*, ...) {} +} +#endif + +void crash(bool crash_self) +{ + printf("Before...\n"); + if(crash_self) + { + printf("Crashing in 3, 2, 1 ...\n"); + *(volatile int*)nullptr = 0; + } + printf("After...\n"); +} + +int foo(int x, float y, const char* msg) +{ + bool flag = x > y; + if(flag) + printf("x = %d, y = %f, msg = %s\n", x, y, msg); + crash(flag); + return x << 1; +} + +int main() +{ + foo(10, 3.14, "testing"); +} + diff --git a/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp new file mode 100644 index 000000000000..c918a6c64e55 Binary files /dev/null and b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp differ diff --git a/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit new file mode 100644 index 000000000000..dff1f1a295e4 --- /dev/null +++ b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit @@ -0,0 +1,2 @@ +bt all +dis diff --git a/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.pdb b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.pdb new file mode 100644 index 000000000000..d60f9cffddac Binary files /dev/null and b/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.pdb differ diff --git a/lit/Minidump/Windows/Sigsegv/sigsegv.test b/lit/Minidump/Windows/Sigsegv/sigsegv.test new file mode 100644 index 000000000000..dfa98c566561 --- /dev/null +++ b/lit/Minidump/Windows/Sigsegv/sigsegv.test @@ -0,0 +1,13 @@ +// RUN: cd %p/Inputs +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 \ +// RUN: %lldb -c sigsegv.dmp -s sigsegv.lldbinit | FileCheck %s + +CHECK: * thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ff7a13110d9 +CHECK: * frame #0: 0x00007ff7a13110d9 sigsegv.exe + +CHECK: -> 0x7ff7a13110d9: movl $0x0, 0x0 +CHECK: 0x7ff7a13110e4: leaq 0x1f45(%rip), %rcx +CHECK: 0x7ff7a13110eb: callq 0x7ff7a1311019 +CHECK: 0x7ff7a13110f0: addq $0x28, %rsp +CHECK: 0x7ff7a13110f4: retq +CHECK: 0x7ff7a13110f5: int3 diff --git a/lit/Minidump/dump-all.test b/lit/Minidump/dump-all.test new file mode 100644 index 000000000000..9af319760456 --- /dev/null +++ b/lit/Minidump/dump-all.test @@ -0,0 +1,86 @@ +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --all' | \ +# RUN: FileCheck --check-prefix=CHECKDIR --check-prefix=CHECKCPU \ +# RUN: --check-prefix=CHECKSTATUS --check-prefix=CHECKLSB \ +# RUN: --check-prefix=CHECKCMD --check-prefix=CHECKENV \ +# RUN: --check-prefix=CHECKAUX --check-prefix=CHECKMAP \ +# RUN: --check-prefix=CHECKSTAT --check-prefix=CHECKUP --check-prefix=CHECKFD %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump -a' | \ +# RUN: FileCheck --check-prefix=CHECKDIR --check-prefix=CHECKCPU \ +# RUN: --check-prefix=CHECKSTATUS --check-prefix=CHECKLSB \ +# RUN: --check-prefix=CHECKCMD --check-prefix=CHECKENV \ +# RUN: --check-prefix=CHECKAUX --check-prefix=CHECKMAP \ +# RUN: --check-prefix=CHECKSTAT --check-prefix=CHECKUP --check-prefix=CHECKFD %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --directory' | FileCheck --check-prefix=CHECKDIR %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --d' | FileCheck --check-prefix=CHECKDIR %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --linux' | \ +# RUN: FileCheck --check-prefix=CHECKCPU --check-prefix=CHECKSTATUS \ +# RUN: --check-prefix=CHECKLSB --check-prefix=CHECKCMD --check-prefix=CHECKENV \ +# RUN: --check-prefix=CHECKAUX --check-prefix=CHECKMAP --check-prefix=CHECKSTAT \ +# RUN: --check-prefix=CHECKUP --check-prefix=CHECKFD %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --cpuinfo' | FileCheck --check-prefix=CHECKCPU %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --C' | FileCheck --check-prefix=CHECKCPU %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --status' | FileCheck --check-prefix=CHECKSTATUS %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --s' | FileCheck --check-prefix=CHECKSTATUS %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --lsb-release' | FileCheck --check-prefix=CHECKLSB %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --r' | FileCheck --check-prefix=CHECKLSB %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --cmdline' | FileCheck --check-prefix=CHECKCMD %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --c' | FileCheck --check-prefix=CHECKCMD %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --environ' | FileCheck --check-prefix=CHECKENV %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --e' | FileCheck --check-prefix=CHECKENV %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --auxv' | FileCheck --check-prefix=CHECKAUX %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --x' | FileCheck --check-prefix=CHECKAUX %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --maps' | FileCheck --check-prefix=CHECKMAP %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --m' | FileCheck --check-prefix=CHECKMAP %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --stat' | FileCheck --check-prefix=CHECKSTAT %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --S' | FileCheck --check-prefix=CHECKSTAT %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --uptime' | FileCheck --check-prefix=CHECKUP %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --u' | FileCheck --check-prefix=CHECKUP %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --fd' | FileCheck --check-prefix=CHECKFD %s +# RUN: %lldb -c %p/Inputs/dump-content.dmp -o 'process plugin dump --f' | FileCheck --check-prefix=CHECKFD %s +# CHECKDIR: RVA SIZE TYPE MinidumpStreamType +# CHECKDIR-NEXT: ---------- ---------- ---------- -------------------------- +# CHECKDIR-NEXT: 0x000000b0 0x00000038 0x00000007 SystemInfo +# CHECKDIR-NEXT: 0x0000015d 0x0000001b 0x47670007 LinuxEnviron +# CHECKDIR-NEXT: 0x00000190 0x000000bc 0x47670009 LinuxMaps +# CHECKDIR-NEXT: 0x00000110 0x0000001a 0x47670004 LinuxProcStatus +# CHECKDIR-NEXT: 0x0000024c 0x00000018 0x4767000b LinuxProcStat +# CHECKDIR-NEXT: 0x00000142 0x0000001b 0x47670006 LinuxCMDLine +# CHECKDIR-NEXT: 0x00000272 0x00000016 0x4767000d LinuxProcFD +# CHECKDIR-NEXT: 0x00000178 0x00000018 0x47670008 LinuxAuxv +# CHECKDIR-NEXT: 0x000000e8 0x00000018 0x0000000f MiscInfo +# CHECKDIR-NEXT: 0x00000100 0x00000010 0x47670003 LinuxCPUInfo +# CHECKDIR-NEXT: 0x0000012a 0x00000018 0x47670005 LinuxLSBRelease +# CHECKDIR-NEXT: 0x00000264 0x0000000e 0x4767000c LinuxProcUptime + +# CHECKCPU: /proc/cpuinfo: +# CHECKCPU-NEXT: cpu info output + +# CHECKSTATUS: /proc/PID/status: +# CHECKSTATUS-NEXT: /proc//status output + +# CHECKLSB: /etc/lsb-release: +# CHECKLSB-NEXT: /etc/lsb-release output + +# CHECKCMD: /proc/PID/cmdline: +# CHECKCMD-NEXT: /proc//cmdline output + +# CHECKENV: /proc/PID/environ: +# CHECKENV-NEXT: /proc//environ output + +# CHECKAUX: /proc/PID/auxv: +# CHECKAUX-NEXT: 0x00000000: 2f 70 72 6f 63 2f 3c 70 69 64 3e 2f 61 75 78 76 /proc//auxv +# CHECKAUX-NEXT: 0x00000010: 20 6f 75 74 70 75 74 00 output. + +# CHECKMAP: /proc/PID/maps: +# CHECKMAP-NEXT: 400d9000-400db000 r-xp 00000000 b3:04 227 /system/bin/app_process +# CHECKMAP-NEXT: 400db000-400dc000 r--p 00001000 b3:04 227 /system/bin/app_process +# CHECKMAP-NEXT: 400dc000-400dd000 rw-p 00000000 00:00 0 + +# CHECKSTAT: /proc/PID/stat: +# CHECKSTAT-NEXT: /proc//stat output + +# CHECKUP: uptime: +# CHECKUP-NEXT: uptime output + +# CHECKFD: /proc/PID/fd: +# CHECKFD-NEXT: /proc//fd output diff --git a/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms b/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms new file mode 100644 index 000000000000..0241d512862c --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms @@ -0,0 +1,2 @@ +MODULE Linux x86_64 E5894855+C35D+CCCCCCCCCCCCCCCCCCCC0 linux.out +PUBLIC 1000 0 _start diff --git a/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms b/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms new file mode 100644 index 000000000000..4ae10438f309 --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms @@ -0,0 +1,2 @@ +MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCC linux.out +PUBLIC 1000 0 _start diff --git a/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms b/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms new file mode 100644 index 000000000000..2e6d72a37d58 --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms @@ -0,0 +1,2 @@ +MODULE Linux x86_64 E58X4855C35DCCCCCCCCXCCCCCCCCCCC0 linux.out +PUBLIC 1000 0 _start diff --git a/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms b/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms new file mode 100644 index 000000000000..bf0a21bc6e09 --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms @@ -0,0 +1,5 @@ +MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 linux.out +INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3 +FILE 0 /tmp/a.c +PUBLIC 1010 0 _start +FILE 1 /tmp/b.c diff --git a/lit/Modules/Breakpad/Inputs/identification-linux.syms b/lit/Modules/Breakpad/Inputs/identification-linux.syms new file mode 100644 index 000000000000..d82e30c4a05d --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/identification-linux.syms @@ -0,0 +1,6 @@ +MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 linux.out +INFO CODE_ID 554889E55DC3CCCCCCCCCCCCCCCCCCCC +PUBLIC 1000 0 _start +STACK CFI INIT 1000 6 .cfa: $rsp 8 + .ra: .cfa -8 + ^ +STACK CFI 1001 $rbp: .cfa -16 + ^ .cfa: $rsp 16 + +STACK CFI 1004 .cfa: $rbp 16 + diff --git a/lit/Modules/Breakpad/Inputs/identification-macosx.syms b/lit/Modules/Breakpad/Inputs/identification-macosx.syms new file mode 100644 index 000000000000..56e0635e5f69 --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/identification-macosx.syms @@ -0,0 +1,6 @@ +MODULE mac x86_64 D98C0E682089AA1BEACD6A8C1F16707B0 mac.out +PUBLIC 0 0 _mh_execute_header +PUBLIC f30 0 start +STACK CFI INIT f30 6 .cfa: $rsp 8 + .ra: .cfa -8 + ^ +STACK CFI f31 $rbp: .cfa -16 + ^ .cfa: $rsp 16 + +STACK CFI f34 .cfa: $rbp 16 + diff --git a/lit/Modules/Breakpad/Inputs/identification-windows.syms b/lit/Modules/Breakpad/Inputs/identification-windows.syms new file mode 100644 index 000000000000..8fa5f305209b --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/identification-windows.syms @@ -0,0 +1,4 @@ +MODULE windows x86 A0C9165780B5490981A1925EA62165C01 a.pdb +INFO CODE_ID 5C01672A4000 a.exe +FILE 1 c:\tmp\a.cpp +PUBLIC 1000 0 main diff --git a/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms b/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms new file mode 100644 index 000000000000..6176d35143cd --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms @@ -0,0 +1,8 @@ +MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 linux.out +INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3 +FILE 0 /tmp/a.c +FUNC 1010 10 0 _start +1010 4 4 0 +1014 5 5 0 +1019 5 6 0 +101e 2 7 0 diff --git a/lit/Modules/Breakpad/Inputs/sections.syms b/lit/Modules/Breakpad/Inputs/sections.syms new file mode 100644 index 000000000000..121cca439b02 --- /dev/null +++ b/lit/Modules/Breakpad/Inputs/sections.syms @@ -0,0 +1,12 @@ +MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 linux.out +INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3 +FILE 0 /tmp/a.c +FUNC 1010 10 0 _start +1010 4 4 0 +1014 5 5 0 +1019 5 6 0 +101e 2 7 0 +PUBLIC 1010 0 _start +STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^ +STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 + +STACK CFI 1014 .cfa: $rbp 16 + diff --git a/lit/Modules/Breakpad/breakpad-identification.test b/lit/Modules/Breakpad/breakpad-identification.test new file mode 100644 index 000000000000..49758b59a1e5 --- /dev/null +++ b/lit/Modules/Breakpad/breakpad-identification.test @@ -0,0 +1,32 @@ +RUN: lldb-test object-file %p/Inputs/identification-linux.syms | FileCheck %s --check-prefix=LINUX +RUN: lldb-test object-file %p/Inputs/identification-macosx.syms | FileCheck %s --check-prefix=MAC +RUN: lldb-test object-file %p/Inputs/identification-windows.syms | FileCheck %s --check-prefix=WINDOWS +RUN: not lldb-test object-file %p/Inputs/bad-module-id-1.syms 2>&1 | FileCheck %s --check-prefix=ERROR +RUN: not lldb-test object-file %p/Inputs/bad-module-id-2.syms 2>&1 | FileCheck %s --check-prefix=ERROR +RUN: not lldb-test object-file %p/Inputs/bad-module-id-3.syms 2>&1 | FileCheck %s --check-prefix=ERROR + +LINUX: Plugin name: breakpad +LINUX: Architecture: x86_64--linux +LINUX: UUID: 554889E5-5DC3-CCCC-CCCC-CCCCCCCCCCCC +LINUX: Executable: false +LINUX: Stripped: false +LINUX: Type: debug info +LINUX: Strata: user + +MAC: Plugin name: breakpad +MAC: Architecture: x86_64--macosx +MAC: UUID: 680E8CD9-8920-1BAA-EACD-6A8C1F16707B +MAC: Executable: false +MAC: Stripped: false +MAC: Type: debug info +MAC: Strata: user + +WINDOWS: Plugin name: breakpad +WINDOWS: Architecture: i386--windows +WINDOWS: UUID: 5716C9A0-B580-0949-81A1-925EA62165C0-01000000 +WINDOWS: Executable: false +WINDOWS: Stripped: false +WINDOWS: Type: debug info +WINDOWS: Strata: user + +ERROR: not recognised as an object file diff --git a/lit/Modules/Breakpad/discontiguous-sections.test b/lit/Modules/Breakpad/discontiguous-sections.test new file mode 100644 index 000000000000..0c9aeea08d7e --- /dev/null +++ b/lit/Modules/Breakpad/discontiguous-sections.test @@ -0,0 +1,27 @@ +# Test handling discontiguous sections. +RUN: lldb-test object-file %p/Inputs/discontiguous-sections.syms -contents | FileCheck %s + +CHECK: Showing 5 sections + +CHECK: ID: 0x1 +CHECK-NEXT: Name: MODULE + +CHECK: ID: 0x2 +CHECK-NEXT: Name: INFO + +CHECK: ID: 0x3 +CHECK-NEXT: Name: FILE +CHECK: File size: 16 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 46494C45 2030202F 746D702F 612E630A |FILE 0 /tmp/a.c.| +CHECK-NEXT: ) + +CHECK: ID: 0x4 +CHECK-NEXT: Name: PUBLIC + +CHECK: ID: 0x5 +CHECK-NEXT: Name: FILE +CHECK: File size: 16 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 46494C45 2031202F 746D702F 622E630A |FILE 1 /tmp/b.c.| +CHECK-NEXT: ) diff --git a/lit/Breakpoint/lit.local.cfg b/lit/Modules/Breakpad/lit.local.cfg similarity index 100% rename from lit/Breakpoint/lit.local.cfg rename to lit/Modules/Breakpad/lit.local.cfg diff --git a/lit/Modules/Breakpad/sections-trailing-func.test b/lit/Modules/Breakpad/sections-trailing-func.test new file mode 100644 index 000000000000..9ea5c9da7810 --- /dev/null +++ b/lit/Modules/Breakpad/sections-trailing-func.test @@ -0,0 +1,15 @@ +# Test handling of a (valid) breakpad file, which ends with a line without a +# recognised keyword. + +RUN: lldb-test object-file %p/Inputs/sections-trailing-func.syms -contents | FileCheck %s + +CHECK: Showing 4 sections + +CHECK: ID: 0x4 +CHECK-NEXT: Name: FUNC +CHECK: File size: 66 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 46554E43 20313031 30203130 2030205F 73746172 740A3130 31302034 20342030 |FUNC 1010 10 0 _start.1010 4 4 0| +CHECK-NEXT: 0020: 0A313031 34203520 3520300A 31303139 20352036 20300A31 30316520 32203720 |.1014 5 5 0.1019 5 6 0.101e 2 7 | +CHECK-NEXT: 0040: 300A |0.| +CHECK-NEXT: ) diff --git a/lit/Modules/Breakpad/sections.test b/lit/Modules/Breakpad/sections.test new file mode 100644 index 000000000000..32ccf848db60 --- /dev/null +++ b/lit/Modules/Breakpad/sections.test @@ -0,0 +1,89 @@ +RUN: lldb-test object-file %p/Inputs/sections.syms -contents | FileCheck %s + +CHECK: Showing 6 sections + +CHECK: Index: 0 +CHECK-NEXT: ID: 0x1 +CHECK-NEXT: Name: MODULE +CHECK-NEXT: Type: regular +CHECK-NEXT: Permissions: --- +CHECK-NEXT: Thread specific: no +CHECK-NEXT: VM address: 0 +CHECK-NEXT: VM size: 0 +CHECK-NEXT: File size: 64 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 4D4F4455 4C45204C 696E7578 20783836 5F363420 30303030 30303030 32344235 |MODULE Linux x86_64 0000000024B5| +CHECK-NEXT: 0020: 44313939 46304637 36364646 46464646 35444333 30206C69 6E75782E 6F75740A |D199F0F766FFFFFF5DC30 linux.out.| +CHECK-NEXT: ) + +CHECK: Index: 1 +CHECK-NEXT: ID: 0x2 +CHECK-NEXT: Name: INFO +CHECK-NEXT: Type: regular +CHECK-NEXT: Permissions: --- +CHECK-NEXT: Thread specific: no +CHECK-NEXT: VM address: 0 +CHECK-NEXT: VM size: 0 +CHECK-NEXT: File size: 46 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 494E464F 20434F44 455F4944 20303030 30303030 30423532 34393944 31463046 |INFO CODE_ID 00000000B52499D1F0F| +CHECK-NEXT: 0020: 37363646 46464646 46354443 330A |766FFFFFF5DC3.| +CHECK-NEXT: ) + +CHECK: Index: 2 +CHECK-NEXT: ID: 0x3 +CHECK-NEXT: Name: FILE +CHECK-NEXT: Type: regular +CHECK-NEXT: Permissions: --- +CHECK-NEXT: Thread specific: no +CHECK-NEXT: VM address: 0 +CHECK-NEXT: VM size: 0 +CHECK-NEXT: File size: 16 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 46494C45 2030202F 746D702F 612E630A |FILE 0 /tmp/a.c.| +CHECK-NEXT: ) + +CHECK: Index: 3 +CHECK-NEXT: ID: 0x4 +CHECK-NEXT: Name: FUNC +CHECK-NEXT: Type: regular +CHECK-NEXT: Permissions: --- +CHECK-NEXT: Thread specific: no +CHECK-NEXT: VM address: 0 +CHECK-NEXT: VM size: 0 +CHECK-NEXT: File size: 66 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 46554E43 20313031 30203130 2030205F 73746172 740A3130 31302034 20342030 |FUNC 1010 10 0 _start.1010 4 4 0| +CHECK-NEXT: 0020: 0A313031 34203520 3520300A 31303139 20352036 20300A31 30316520 32203720 |.1014 5 5 0.1019 5 6 0.101e 2 7 | +CHECK-NEXT: 0040: 300A |0.| +CHECK-NEXT: ) + +CHECK: Index: 4 +CHECK-NEXT: ID: 0x5 +CHECK-NEXT: Name: PUBLIC +CHECK-NEXT: Type: regular +CHECK-NEXT: Permissions: --- +CHECK-NEXT: Thread specific: no +CHECK-NEXT: VM address: 0 +CHECK-NEXT: VM size: 0 +CHECK-NEXT: File size: 21 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 5055424C 49432031 30313020 30205F73 74617274 0A |PUBLIC 1010 0 _start.| +CHECK-NEXT: ) + +CHECK: Index: 5 +CHECK-NEXT: ID: 0x6 +CHECK-NEXT: Name: STACK +CHECK-NEXT: Type: regular +CHECK-NEXT: Permissions: --- +CHECK-NEXT: Thread specific: no +CHECK-NEXT: VM address: 0 +CHECK-NEXT: VM size: 0 +CHECK-NEXT: File size: 136 +CHECK-NEXT: Data: ( +CHECK-NEXT: 0000: 53544143 4B204346 4920494E 49542031 30313020 3130202E 6366613A 20247273 |STACK CFI INIT 1010 10 .cfa: $rs| +CHECK-NEXT: 0020: 70203820 2B202E72 613A202E 63666120 2D38202B 205E0A53 5441434B 20434649 |p 8 + .ra: .cfa -8 + ^.STACK CFI| +CHECK-NEXT: 0040: 20313031 31202472 62703A20 2E636661 202D3136 202B205E 202E6366 613A2024 | 1011 $rbp: .cfa -16 + ^ .cfa: $| +CHECK-NEXT: 0060: 72737020 3136202B 0A535441 434B2043 46492031 30313420 2E636661 3A202472 |rsp 16 +.STACK CFI 1014 .cfa: $r| +CHECK-NEXT: 0080: 62702031 36202B0A |bp 16 +.| +CHECK-NEXT: ) diff --git a/lit/Modules/ELF/Inputs/PT_LOAD-overlap-section.elf b/lit/Modules/ELF/Inputs/PT_LOAD-overlap-section.elf new file mode 100644 index 000000000000..d5fd2d1fa91d Binary files /dev/null and b/lit/Modules/ELF/Inputs/PT_LOAD-overlap-section.elf differ diff --git a/lit/Modules/ELF/PT_LOAD-empty.yaml b/lit/Modules/ELF/PT_LOAD-empty.yaml new file mode 100644 index 000000000000..9f1cb0745723 --- /dev/null +++ b/lit/Modules/ELF/PT_LOAD-empty.yaml @@ -0,0 +1,26 @@ +# Test behavior on unusual (and probably corrupt) files. Test that we drop an +# empty PT_LOAD segment. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s +# +# CHECK-NOT: container + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + Align: 0x4 diff --git a/lit/Modules/ELF/PT_LOAD-overlap-PT_INTERP.yaml b/lit/Modules/ELF/PT_LOAD-overlap-PT_INTERP.yaml new file mode 100644 index 000000000000..e97afe9070ce --- /dev/null +++ b/lit/Modules/ELF/PT_LOAD-overlap-PT_INTERP.yaml @@ -0,0 +1,50 @@ +# Test that an overlapping PT_INTERP segment does not cause us to drop the +# subsequent PT_LOAD segment. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xfffffffffffffffe +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rwx +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 12 +# CHECK-NEXT: File size: 12 +# CHECK-NEXT: Showing 2 subsections + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .interp + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1000 + AddressAlign: 0x4 + Content: 3232 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1004 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_INTERP + Flags: [ PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .interp + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .interp + - Section: .text diff --git a/lit/Modules/ELF/PT_LOAD-overlap-section.yaml b/lit/Modules/ELF/PT_LOAD-overlap-section.yaml new file mode 100644 index 000000000000..3b7bde802ce0 --- /dev/null +++ b/lit/Modules/ELF/PT_LOAD-overlap-section.yaml @@ -0,0 +1,66 @@ +# Test behavior on strange (invalid?) elf files where the sections cross segment +# boundary. The test input was generated from this yaml file, but the program +# header was modified by hand, so this input is here for reference only. +# +# Right now lldb shortens sections to make sure every section is fully contained +# within a segment, but other behaviors are possible too (including outright +# rejecting such files). + +# RUN: lldb-test object-file %S/Inputs/PT_LOAD-overlap-section.elf | FileCheck %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xffffffffffffffff +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rwx +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1006 +# CHECK-NEXT: VM size: 8 +# CHECK-NEXT: File size: 8 +# CHECK-NEXT: Showing 1 subsections +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: ID: 0x2 +# CHECK-NEXT: Name: .text +# CHECK-NEXT: Type: code +# CHECK-NEXT: Permissions: r-x +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1008 +# CHECK-NEXT: VM size: 6 +# CHECK-NEXT: File size: 8 + +# CHECK: Index: 1 +# CHECK-NEXT: ID: 0x1 +# CHECK-NEXT: Name: .interp +# CHECK-NEXT: Type: regular +# CHECK-NEXT: Permissions: r-- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 6 +# CHECK-NEXT: File size: 8 + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .interp + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1008 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1008 # Modified by hand to start at 0x1006 + Align: 0x4 + Sections: + - Section: .text diff --git a/lit/Modules/ELF/PT_LOAD-overlap.yaml b/lit/Modules/ELF/PT_LOAD-overlap.yaml new file mode 100644 index 000000000000..1315f54e6c02 --- /dev/null +++ b/lit/Modules/ELF/PT_LOAD-overlap.yaml @@ -0,0 +1,42 @@ +# Test behavior on unusual (and probably corrupt) object files. Check that we +# drop the second PT_LOAD segment which overlaps with the first one. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Type: container +# CHECK-NOT: Type: container + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1008 + AddressAlign: 0x4 + Content: 3232 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .text + - Section: .data + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x1008 + Align: 0x4 + Sections: + - Section: .data diff --git a/lit/Modules/ELF/PT_LOAD.yaml b/lit/Modules/ELF/PT_LOAD.yaml new file mode 100644 index 000000000000..d673a69c8cd8 --- /dev/null +++ b/lit/Modules/ELF/PT_LOAD.yaml @@ -0,0 +1,79 @@ +# Test that sections are made child-sections of the PT_LOAD segments/sections. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Index: 0 +# CHECK-NEXT: ID: 0xffffffffffffffff +# CHECK-NEXT: Name: PT_LOAD[0] +# CHECK-NEXT: Type: container +# CHECK-NEXT: Permissions: rwx +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 10 +# CHECK-NEXT: File size: 10 +# CHECK-NEXT: Showing 2 subsections +# CHECK-NEXT: Index: 0 +# CHECK-NEXT: ID: 0x1 +# CHECK-NEXT: Name: .text +# CHECK-NEXT: Type: code +# CHECK-NEXT: Permissions: r-x +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1000 +# CHECK-NEXT: VM size: 8 +# CHECK-NEXT: File size: 8 +# CHECK-EMPTY: +# CHECK-NEXT: Index: 1 +# CHECK-NEXT: ID: 0x2 +# CHECK-NEXT: Name: .data +# CHECK-NEXT: Type: data +# CHECK-NEXT: Permissions: r-- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x1008 +# CHECK-NEXT: VM size: 2 +# CHECK-NEXT: File size: 2 +# CHECK-EMPTY: +# CHECK-EMPTY: +# CHECK-NEXT: Index: 1 +# CHECK-NEXT: ID: 0x3 +# CHECK-NEXT: Name: .data_outside +# CHECK-NEXT: Type: regular +# CHECK-NEXT: Permissions: r-- +# CHECK-NEXT: Thread specific: no +# CHECK-NEXT: VM address: 0x2000 +# CHECK-NEXT: VM size: 2 +# CHECK-NEXT: File size: 2 + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1008 + AddressAlign: 0x4 + Content: 3232 + - Name: .data_outside + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2000 + AddressAlign: 0x4 + Content: 3232 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .text + - Section: .data diff --git a/lit/Modules/ELF/base-address.yaml b/lit/Modules/ELF/base-address.yaml new file mode 100644 index 000000000000..68f117708351 --- /dev/null +++ b/lit/Modules/ELF/base-address.yaml @@ -0,0 +1,34 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Base VM address: 0x400000 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400078 +Sections: + - Name: .pad + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400000 + AddressAlign: 0x0000000000001000 + Size: 0x78 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400078 + AddressAlign: 0x0000000000000001 + Content: 48C7C0E700000048C7C72F0000000F05CC +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x400000 + Align: 0x200000 + Sections: + - Section: .pad + - Section: .text +... diff --git a/lit/Modules/ELF/basic-info.yaml b/lit/Modules/ELF/basic-info.yaml new file mode 100644 index 000000000000..0e1db67e9d5f --- /dev/null +++ b/lit/Modules/ELF/basic-info.yaml @@ -0,0 +1,27 @@ +# REQUIRES: lld + +# RUN: yaml2obj %s > %t.o +# RUN: ld.lld %t.o -o %t -image-base 0x47000 +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Plugin name: elf +# CHECK: Architecture: x86_64-- +# CHECK: Executable: true +# CHECK: Stripped: false +# CHECK: Type: executable +# CHECK: Strata: user +# CHECK: Base VM address: 0x47000 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000010 + Content: 554889E55DC3 +... diff --git a/lit/Modules/build-id-case.yaml b/lit/Modules/ELF/build-id-case.yaml similarity index 96% rename from lit/Modules/build-id-case.yaml rename to lit/Modules/ELF/build-id-case.yaml index 246163ad52af..843bc40fb791 100644 --- a/lit/Modules/build-id-case.yaml +++ b/lit/Modules/ELF/build-id-case.yaml @@ -6,8 +6,6 @@ # CHECK: Name: .debug_frame # CHECK-NEXT: Type: dwarf-frame -# CHECK-NEXT: VM size: 0 -# CHECK-NEXT: File size: 8 --- !ELF FileHeader: diff --git a/lit/Modules/compressed-sections.yaml b/lit/Modules/ELF/compressed-sections.yaml similarity index 92% rename from lit/Modules/compressed-sections.yaml rename to lit/Modules/ELF/compressed-sections.yaml index c75dc857522a..df070a2d53d6 100644 --- a/lit/Modules/compressed-sections.yaml +++ b/lit/Modules/ELF/compressed-sections.yaml @@ -19,6 +19,7 @@ Sections: # CHECK: Name: .hello_elf # CHECK-NEXT: Type: regular +# CHECK: VM address: 0 # CHECK-NEXT: VM size: 0 # CHECK-NEXT: File size: 28 # CHECK-NEXT: Data: @@ -26,7 +27,7 @@ Sections: # CHECK: Name: .bogus # CHECK-NEXT: Type: regular +# CHECK: VM address: 0 # CHECK-NEXT: VM size: 0 # CHECK-NEXT: File size: 8 -# CHECK-NEXT: Data: -# CHECK-NEXT: DEADBEEF BAADF00D +# CHECK-NEXT: Data: () diff --git a/lit/Modules/elf-duplicate-section.yaml b/lit/Modules/ELF/duplicate-section.yaml similarity index 100% rename from lit/Modules/elf-duplicate-section.yaml rename to lit/Modules/ELF/duplicate-section.yaml diff --git a/lit/Modules/elf-many-sections.s b/lit/Modules/ELF/many-sections.s similarity index 97% rename from lit/Modules/elf-many-sections.s rename to lit/Modules/ELF/many-sections.s index a5e4aee18821..15d7e8fc1589 100644 --- a/lit/Modules/elf-many-sections.s +++ b/lit/Modules/ELF/many-sections.s @@ -7,7 +7,7 @@ ## aaaaaaaa..dddddddd, plus a couple of standard ones (.strtab, etc.) ## Check the number is correct plus the names of a couple of chosen sections. -# CHECK: Showing 65541 sections +# CHECK: Showing 65540 sections # CHECK: Name: aaaaaaaa # CHECK: Name: bbbbbbbb # CHECK: Name: cccccccc diff --git a/lit/Modules/ELF/section-addresses.yaml b/lit/Modules/ELF/section-addresses.yaml new file mode 100644 index 000000000000..012abbf1f6d3 --- /dev/null +++ b/lit/Modules/ELF/section-addresses.yaml @@ -0,0 +1,58 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-LABEL: Name: .one +# CHECK: VM address: 0x0 + +# CHECK-LABEL: Name: .nonalloc +# CHECK: VM address: 0x0 + +# CHECK-LABEL: Name: .two +# CHECK: VM address: 0x8 + +# CHECK-LABEL: Name: .three +# CHECK: VM address: 0xc + +# CHECK-LABEL: Name: .four +# CHECK: VM address: 0xc + +# CHECK-LABEL: Name: .five +# CHECK: VM address: 0x1000 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .one + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .nonalloc + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .two + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DE + - Name: .three + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + - Name: .four + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .five + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000001000 + Content: DEADBEEFBAADF00D +... diff --git a/lit/Modules/ELF/section-overlap.yaml b/lit/Modules/ELF/section-overlap.yaml new file mode 100644 index 000000000000..bfbd873be41b --- /dev/null +++ b/lit/Modules/ELF/section-overlap.yaml @@ -0,0 +1,51 @@ +# Test handling of (corrupt?) object files, which have sections with overlapping +# virtual addresses. +# +# Right now the overlapping sections get dropped, but other behaviors +# (including outright rejecting such files) are possible too. + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-NOT: .overlap1 +# CHECK-NOT: .overlap2 + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .sect1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .overlap1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x1004 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .sect2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2000 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D + - Name: .overlap2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2004 + AddressAlign: 0x4 + Content: DEADBEEFBAADF00D +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_W, PF_R ] + VAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .sect1 + - Section: .overlap1 diff --git a/lit/Modules/ELF/section-permissions.yaml b/lit/Modules/ELF/section-permissions.yaml new file mode 100644 index 000000000000..99c2773c81b3 --- /dev/null +++ b/lit/Modules/ELF/section-permissions.yaml @@ -0,0 +1,34 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK-LABEL: Name: .r-x +# CHECK: Permissions: r-x +# +# CHECK-LABEL: Name: .rw- +# CHECK: Permissions: rw- + +# CHECK-LABEL: Name: .--- +# CHECK: Permissions: --- + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .r-x + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: DEADBEEFBAADF00D + - Name: .rw- + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .--- + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: DEADBEEFBAADF00D +... diff --git a/lit/Modules/ELF/section-types-edgecases.yaml b/lit/Modules/ELF/section-types-edgecases.yaml new file mode 100644 index 000000000000..ad1fa2d9097b --- /dev/null +++ b/lit/Modules/ELF/section-types-edgecases.yaml @@ -0,0 +1,35 @@ +# This test doesn't attempt to mandate a specific section classification. It is +# here to document the existing behavior and to make sure we don't do something +# completely crazy (like crashing). + +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# The section is called .data, but it has the SHF_EXECINSTR flag set. Have +# the flag take precedence over the name. +# CHECK-LABEL: Name: .data +# CHECK-NEXT: Type: code + +# Section type (SHT_SYMTAB) takes precedence over name-based deduction. +# CHECK-LABEL: Name: .text +# CHECK-NEXT: Type: elf-symbol-table + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 + Entry: 0x00000000000007A0 +Sections: + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_EXECINSTR, SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D + - Name: .text + Type: SHT_SYMTAB + Flags: [ ] + AddressAlign: 0x0000000000000004 + Content: DEADBEEFBAADF00D +... diff --git a/lit/Modules/elf-section-types.yaml b/lit/Modules/ELF/section-types.yaml similarity index 55% rename from lit/Modules/elf-section-types.yaml rename to lit/Modules/ELF/section-types.yaml index 64906a9acf8b..907d57b10cfe 100644 --- a/lit/Modules/elf-section-types.yaml +++ b/lit/Modules/ELF/section-types.yaml @@ -1,37 +1,41 @@ # RUN: yaml2obj %s > %t # RUN: lldb-test object-file %t | FileCheck %s -# CHECK: Name: .text +# CHECK-LABEL: Name: .text # CHECK-NEXT: Type: code -# CHECK: Name: .debug_info +# CHECK-LABEL: Name: .debug_info # CHECK-NEXT: Type: dwarf-info -# CHECK-NEXT: VM size: 0 -# CHECK-NEXT: File size: 8 -# CHECK: Name: .debug_types +# CHECK-LABEL: Name: .debug_types # CHECK-NEXT: Type: dwarf-types -# CHECK-NEXT: VM size: 0 -# CHECK-NEXT: File size: 8 -# CHECK: Name: .debug_names +# CHECK-LABEL: Name: .debug_names # CHECK-NEXT: Type: dwarf-names -# CHECK-NEXT: VM size: 0 -# CHECK-NEXT: File size: 8 -# CHECK: Name: .gnu_debugaltlink +# CHECK-LABEL: Name: .gnu_debugaltlink # CHECK-NEXT: Type: dwarf-gnu-debugaltlink -# CHECK-NEXT: VM size: 0 -# CHECK-NEXT: File size: 8 -# CHECK: Name: __codesection +# CHECK-LABEL: Name: __codesection # CHECK-NEXT: Type: code +# CHECK-LABEL: Name: .data +# CHECK-NEXT: Type: data +# CHECK: Thread specific: no + +# CHECK-LABEL: Name: .tdata +# CHECK-NEXT: Type: data +# CHECK: Thread specific: yes + +# CHECK-LABEL: Name: .tbss +# CHECK-NEXT: Type: zero-fill +# CHECK: Thread specific: yes + --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB - Type: ET_DYN + Type: ET_REL Machine: EM_X86_64 Entry: 0x00000000000007A0 Sections: @@ -59,4 +63,19 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] Content: DEADBEEFBAADF00D + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + AddressAlign: 0x0000000000000004 + Content: 2F000000 + - Name: .tdata + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ] + AddressAlign: 0x0000000000000004 + Content: 2F000000 + - Name: .tbss + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC, SHF_TLS ] + AddressAlign: 0x0000000000000004 + Size: 0x0000000000000004 ... diff --git a/lit/Modules/short-build-id.yaml b/lit/Modules/ELF/short-build-id.yaml similarity index 100% rename from lit/Modules/short-build-id.yaml rename to lit/Modules/ELF/short-build-id.yaml diff --git a/lit/Modules/lc_build_version.yaml b/lit/Modules/MachO/lc_build_version.yaml similarity index 99% rename from lit/Modules/lc_build_version.yaml rename to lit/Modules/MachO/lc_build_version.yaml index 3b356b18fc37..4479662627ff 100644 --- a/lit/Modules/lc_build_version.yaml +++ b/lit/Modules/MachO/lc_build_version.yaml @@ -1,6 +1,5 @@ # RUN: yaml2obj %s > %t.out # RUN: lldb-test symbols %t.out | FileCheck %s -# REQUIRES: system-darwin # Test that the deployment target is parsed from the load commands. # CHECK: x86_64-apple-macosx10.14.0 --- !mach-o diff --git a/lit/Modules/lc_build_version_notools.yaml b/lit/Modules/MachO/lc_build_version_notools.yaml similarity index 99% rename from lit/Modules/lc_build_version_notools.yaml rename to lit/Modules/MachO/lc_build_version_notools.yaml index 03a9b7ec73a5..f84c71aff6aa 100644 --- a/lit/Modules/lc_build_version_notools.yaml +++ b/lit/Modules/MachO/lc_build_version_notools.yaml @@ -1,6 +1,5 @@ # RUN: yaml2obj %s > %t.out # RUN: lldb-test symbols %t.out | FileCheck %s -# REQUIRES: system-darwin # Test that the deployment target is parsed from the load commands. # CHECK: x86_64-apple-macosx10.14.0 --- !mach-o diff --git a/lit/Modules/lc_version_min.yaml b/lit/Modules/MachO/lc_version_min.yaml similarity index 100% rename from lit/Modules/lc_version_min.yaml rename to lit/Modules/MachO/lc_version_min.yaml diff --git a/lit/Modules/MachO/subsections.yaml b/lit/Modules/MachO/subsections.yaml new file mode 100644 index 000000000000..a92ef41d79fc --- /dev/null +++ b/lit/Modules/MachO/subsections.yaml @@ -0,0 +1,126 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +#CHECK: Showing 2 sections +#CHECK-NEXT: Index: 0 +#CHECK-NEXT: ID: 0x100 +#CHECK-NEXT: Name: __PAGEZERO +#CHECK-NEXT: Type: container +#CHECK-NEXT: Permissions: --- +#CHECK-NEXT: Thread specific: no +#CHECK-NEXT: VM address: 0x0 +#CHECK-NEXT: VM size: 4294967296 +#CHECK-NEXT: File size: 0 +#CHECK-NEXT: There are no subsections +#CHECK-EMPTY: +#CHECK-NEXT: Index: 1 +#CHECK-NEXT: ID: 0x200 +#CHECK-NEXT: Name: __TEXT +#CHECK-NEXT: Type: container +#CHECK-NEXT: Permissions: r-x +#CHECK-NEXT: Thread specific: no +#CHECK-NEXT: VM address: 0x100000000 +#CHECK-NEXT: VM size: 4096 +#CHECK-NEXT: File size: 4096 +#CHECK-NEXT: Showing 3 subsections +#CHECK-NEXT: Index: 0 +#CHECK-NEXT: ID: 0x1 +#CHECK-NEXT: Name: __text +#CHECK-NEXT: Type: code +#CHECK-NEXT: Permissions: r-x +#CHECK-NEXT: Thread specific: no +#CHECK-NEXT: VM address: 0x100000f30 +#CHECK-NEXT: VM size: 22 +#CHECK-NEXT: File size: 22 +#CHECK-EMPTY: +#CHECK-NEXT: Index: 1 +#CHECK-NEXT: ID: 0x2 +#CHECK-NEXT: Name: __unwind_info +#CHECK-NEXT: Type: compact-unwind +#CHECK-NEXT: Permissions: r-x +#CHECK-NEXT: Thread specific: no +#CHECK-NEXT: VM address: 0x100000f48 +#CHECK-NEXT: VM size: 76 +#CHECK-NEXT: File size: 76 +#CHECK-EMPTY: +#CHECK-NEXT: Index: 2 +#CHECK-NEXT: ID: 0x3 +#CHECK-NEXT: Name: __eh_frame +#CHECK-NEXT: Type: eh-frame +#CHECK-NEXT: Permissions: r-x +#CHECK-NEXT: Thread specific: no +#CHECK-NEXT: VM address: 0x100000f98 +#CHECK-NEXT: VM size: 104 +#CHECK-NEXT: File size: 104 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000002 + ncmds: 12 + sizeofcmds: 728 + flags: 0x00000085 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __PAGEZERO + vmaddr: 0 + vmsize: 4294967296 + fileoff: 0 + filesize: 0 + maxprot: 0 + initprot: 0 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 312 + segname: __TEXT + vmaddr: 4294967296 + vmsize: 4096 + fileoff: 0 + filesize: 4096 + maxprot: 7 + initprot: 5 + nsects: 3 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000100000F30 + size: 22 + offset: 0x00000F30 + align: 4 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __unwind_info + segname: __TEXT + addr: 0x0000000100000F48 + size: 76 + offset: 0x00000F48 + align: 2 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __eh_frame + segname: __TEXT + addr: 0x0000000100000F98 + size: 104 + offset: 0x00000F98 + align: 3 + reloff: 0x00000000 + nreloc: 0 + flags: 0x0000000B + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 +... diff --git a/lit/Modules/PECOFF/dep-modules.yaml b/lit/Modules/PECOFF/dep-modules.yaml new file mode 100644 index 000000000000..75a27e895234 --- /dev/null +++ b/lit/Modules/PECOFF/dep-modules.yaml @@ -0,0 +1,170 @@ +# REQUIRES: system-windows +# RUN: yaml2obj < %p/export-dllfunc.yaml > %t.export-dllfunc.obj +# RUN: yaml2obj < %s > %t.obj +# +# RUN: lld-link /machine:x64 /out:%t.export-dllfunc.dll /noentry /nodefaultlib /dll %t.export-dllfunc.obj /export:DllFunc +# RUN: lld-link /out:%t.exe %t.obj %t.export-dllfunc.lib /nodefaultlib /entry:main /include:DllFunc +# +# RUN: lldb-test object-file -dep-modules %t.exe | FileCheck -check-prefix=DEPS %s + + +# DEPS: Showing 1 dependent module(s) + +# Ignore checking the directory and any tentative string in the path. +# DEPS: Name: {{.*}}dep-modules.yaml.{{.*}}export-dllfunc.dll + + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 4883EC48C7442444000000004889542438894C2434B904000000E80000000089442430B908000000E8000000008944242C8B4424300344242C4883C448C3 + Relocations: + - VirtualAddress: 27 + SymbolName: 'DllFunc' + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 41 + SymbolName: 'DllFunc' + Type: IMAGE_REL_AMD64_REL32 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .xdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '0104010004820000' + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '000000003E00000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: main + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 4 + SymbolName: main + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 8 + SymbolName: .xdata + Type: IMAGE_REL_AMD64_ADDR32NB + - Name: .llvm_addrsig + Characteristics: [ IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: '10' +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 62 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 373303044 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .xdata + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2657791889 + Number: 4 + - Name: .drectve + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 5 + - Name: .pdata + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 2420588879 + Number: 6 + - Name: .llvm_addrsig + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 1 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 498536548 + Number: 7 + - Name: '@feat.00' + Value: 0 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: 'DllFunc' + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/lit/Modules/PECOFF/export-dllfunc.yaml b/lit/Modules/PECOFF/export-dllfunc.yaml new file mode 100644 index 000000000000..55156e8c792f --- /dev/null +++ b/lit/Modules/PECOFF/export-dllfunc.yaml @@ -0,0 +1,172 @@ +# REQUIRES: system-windows +# RUN: yaml2obj < %s > %t.obj +# +# RUN: lld-link /machine:x64 /out:%t.dll /noentry /nodefaultlib /dll %t.obj /export:DllFunc +# +# RUN: lldb-test object-file %t.dll | FileCheck -check-prefix=BASIC-CHECK %s +# RUN: lldb-test object-file -dep-modules %t.dll | FileCheck -check-prefix=DEPS %s + + +# BASIC-CHECK: Showing 3 sections +# BASIC-CHECK: Index: 0 +# BASIC-CHECK: Name: .text +# BASIC-CHECK: Type: code +# BASIC-CHECK: VM size: 22 +# BASIC-CHECK: File size: 512 +# +# BASIC-CHECK: Index: 1 +# BASIC-CHECK: Name: .rdata +# BASIC-CHECK: Type: data +# BASIC-CHECK: VM size: {{.}} +# BASIC-CHECK: File size: 512 +# +# BASIC-CHECK: Index: 2 +# BASIC-CHECK: Name: .pdata +# BASIC-CHECK: Type: data +# BASIC-CHECK: VM size: 12 +# BASIC-CHECK: File size: 512 +# +# DEPS: Showing 0 dependent module(s) + + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 50894C24048B4C24040FAF4C2404890C248B042459C3 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .xdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '0101010001020000' + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '000000001600000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: 'DllFunc' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 4 + SymbolName: 'DllFunc' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 8 + SymbolName: .xdata + Type: IMAGE_REL_AMD64_ADDR32NB + - Name: .llvm_addrsig + Characteristics: [ IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: '' +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 22 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3054557294 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .xdata + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 448359300 + Number: 4 + - Name: .drectve + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 5 + - Name: .pdata + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 3134470316 + Number: 6 + - Name: .llvm_addrsig + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 7 + - Name: '@feat.00' + Value: 0 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: 'DllFunc' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/lit/Modules/PECOFF/lit.local.cfg b/lit/Modules/PECOFF/lit.local.cfg new file mode 100644 index 000000000000..9ef350be1dee --- /dev/null +++ b/lit/Modules/PECOFF/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.yaml', '.test'] diff --git a/lit/Modules/PECOFF/sections-names.yaml b/lit/Modules/PECOFF/sections-names.yaml new file mode 100644 index 000000000000..b62c0bc0426f --- /dev/null +++ b/lit/Modules/PECOFF/sections-names.yaml @@ -0,0 +1,52 @@ +# RUN: yaml2obj %s > %t +# RUN: lldb-test object-file %t | FileCheck %s + +# CHECK: Name: .text{{$}} +# CHECK: Name: 1234567{{$}} +# CHECK: Name: 12345678{{$}} +# CHECK: Name: 123456789{{$}} + +--- !COFF +OptionalHeader: + AddressOfEntryPoint: 4616 + ImageBase: 1073741824 + SectionAlignment: 4096 + FileAlignment: 512 + MajorOperatingSystemVersion: 6 + MinorOperatingSystemVersion: 0 + MajorImageVersion: 0 + MinorImageVersion: 0 + MajorSubsystemVersion: 6 + MinorSubsystemVersion: 0 + Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI + DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ] + SizeOfStackReserve: 1048576 + SizeOfStackCommit: 4096 + SizeOfHeapReserve: 1048576 + SizeOfHeapCommit: 4096 +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + VirtualAddress: 4096 + VirtualSize: 64 # '@', if it makes its way into the name field + SectionData: DEADBEEFBAADF00D + - Name: 1234567 + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + VirtualAddress: 442368 + VirtualSize: 64 + SectionData: DEADBEEFBAADF00D + - Name: 12345678 + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + VirtualAddress: 446464 + VirtualSize: 64 + SectionData: DEADBEEFBAADF00D + - Name: 123456789 + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + VirtualAddress: 450560 + VirtualSize: 64 + SectionData: DEADBEEFBAADF00D +symbols: [] +... diff --git a/lit/Python/crashlog.test b/lit/Python/crashlog.test index 2a95a280ba3d..93d9cbabbe2d 100644 --- a/lit/Python/crashlog.test +++ b/lit/Python/crashlog.test @@ -1,6 +1,6 @@ # -*- python -*- +# REQUIRES: system-darwin # RUN: cd %S/../../examples/python && %lldb -S %s | FileCheck %s -# REQUIRES : system-darwin # CHECK-LABEL: {{S}}KIP BEYOND CHECKS script import crashlog diff --git a/lit/Quit/TestQuitExitCode-30.test b/lit/Quit/TestQuitExitCode-30.test index 0f6eff927f0c..2f15398c7614 100644 --- a/lit/Quit/TestQuitExitCode-30.test +++ b/lit/Quit/TestQuitExitCode-30.test @@ -1,3 +1,3 @@ -# UNSUPPORTED: windows -# RUN: python %S/expect_exit_code.py 226 %lldb -b -s %s +# UNSUPPORTED: system-windows +# RUN: %python %S/expect_exit_code.py 226 %lldb -b -s %s q -30 diff --git a/lit/Quit/TestQuitExitCode0.test b/lit/Quit/TestQuitExitCode0.test index c15cb5e9ea7b..af39b4293f30 100644 --- a/lit/Quit/TestQuitExitCode0.test +++ b/lit/Quit/TestQuitExitCode0.test @@ -1,3 +1,3 @@ -# UNSUPPORTED: windows +# UNSUPPORTED: system-windows # RUN: %lldb -b -s %s q 0 diff --git a/lit/Quit/TestQuitExitCode30.test b/lit/Quit/TestQuitExitCode30.test index b5249400ec2f..e5ff634e7136 100644 --- a/lit/Quit/TestQuitExitCode30.test +++ b/lit/Quit/TestQuitExitCode30.test @@ -1,3 +1,3 @@ -# UNSUPPORTED: windows -# RUN: python %S/expect_exit_code.py 30 %lldb -b -s %s +# UNSUPPORTED: system-windows +# RUN: %python %S/expect_exit_code.py 30 %lldb -b -s %s q 30 diff --git a/lit/Quit/TestQuitExitCodeHex0.test b/lit/Quit/TestQuitExitCodeHex0.test index 3e1fc5dbeeb1..f85a046fa135 100644 --- a/lit/Quit/TestQuitExitCodeHex0.test +++ b/lit/Quit/TestQuitExitCodeHex0.test @@ -1,3 +1,3 @@ -# UNSUPPORTED: windows +# UNSUPPORTED: system-windows # RUN: %lldb -b -s %s q 0x0 diff --git a/lit/Quit/TestQuitExitCodeHexA.test b/lit/Quit/TestQuitExitCodeHexA.test index e06c25b0619f..ca0e2d5acc3b 100644 --- a/lit/Quit/TestQuitExitCodeHexA.test +++ b/lit/Quit/TestQuitExitCodeHexA.test @@ -1,3 +1,3 @@ -# UNSUPPORTED: windows -# RUN: python %S/expect_exit_code.py 10 %lldb -b -s %s +# UNSUPPORTED: system-windows +# RUN: %python %S/expect_exit_code.py 10 %lldb -b -s %s q 0xA diff --git a/lit/Quit/TestQuitExitCodeImplicit0.test b/lit/Quit/TestQuitExitCodeImplicit0.test index 1a95e8dc0bf1..5494231b23be 100644 --- a/lit/Quit/TestQuitExitCodeImplicit0.test +++ b/lit/Quit/TestQuitExitCodeImplicit0.test @@ -1,3 +1,3 @@ -# UNSUPPORTED: windows +# UNSUPPORTED: system-windows # RUN: %lldb -b -s %s q diff --git a/lit/Quit/TestQuitExitCodeNonInt.test b/lit/Quit/TestQuitExitCodeNonInt.test index 2b54163d6489..87c0bd41bb05 100644 --- a/lit/Quit/TestQuitExitCodeNonInt.test +++ b/lit/Quit/TestQuitExitCodeNonInt.test @@ -1,4 +1,4 @@ -# UNSUPPORTED: windows +# UNSUPPORTED: system-windows # RUN: %lldb -b -s %s 2>&1 | FileCheck %s q str // CHECK: Couldn't parse 'str' diff --git a/lit/Quit/TestQuitExitCodeTooManyArgs.test b/lit/Quit/TestQuitExitCodeTooManyArgs.test index 05be357fd57a..a67669451e99 100644 --- a/lit/Quit/TestQuitExitCodeTooManyArgs.test +++ b/lit/Quit/TestQuitExitCodeTooManyArgs.test @@ -1,4 +1,4 @@ -# UNSUPPORTED: windows +# UNSUPPORTED: system-windows # RUN: %lldb -b -s %s 2>&1 | FileCheck %s q 1 2 // CHECK: Too many arguments for 'quit' diff --git a/lit/Quit/expect_exit_code.py b/lit/Quit/expect_exit_code.py index f4a7590b7d52..32b2e29d53d7 100755 --- a/lit/Quit/expect_exit_code.py +++ b/lit/Quit/expect_exit_code.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import subprocess import sys diff --git a/lit/Quit/lit.local.cfg b/lit/Quit/lit.local.cfg deleted file mode 100644 index df9b335dd131..000000000000 --- a/lit/Quit/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.test'] diff --git a/lit/Reproducer/Inputs/FileCapture.in b/lit/Reproducer/Inputs/FileCapture.in new file mode 100644 index 000000000000..bf6f852dbedb --- /dev/null +++ b/lit/Reproducer/Inputs/FileCapture.in @@ -0,0 +1,3 @@ +run +reproducer status +reproducer generate diff --git a/lit/Reproducer/Inputs/FileReplay.in b/lit/Reproducer/Inputs/FileReplay.in new file mode 100644 index 000000000000..2ed2de164cc3 --- /dev/null +++ b/lit/Reproducer/Inputs/FileReplay.in @@ -0,0 +1,2 @@ +reproducer status +run diff --git a/lit/Reproducer/Inputs/GDBRemoteCapture.in b/lit/Reproducer/Inputs/GDBRemoteCapture.in new file mode 100644 index 000000000000..e632c821d577 --- /dev/null +++ b/lit/Reproducer/Inputs/GDBRemoteCapture.in @@ -0,0 +1,6 @@ +breakpoint set -f simple.c -l 12 +run +bt +cont +reproducer status +reproducer generate diff --git a/lit/Reproducer/Inputs/GDBRemoteReplay.in b/lit/Reproducer/Inputs/GDBRemoteReplay.in new file mode 100644 index 000000000000..efbb7971ab68 --- /dev/null +++ b/lit/Reproducer/Inputs/GDBRemoteReplay.in @@ -0,0 +1,5 @@ +reproducer status +breakpoint set -f simple.c -l 12 +run +bt +cont diff --git a/lit/Reproducer/Inputs/simple.c b/lit/Reproducer/Inputs/simple.c new file mode 100644 index 000000000000..ef14878bcf9c --- /dev/null +++ b/lit/Reproducer/Inputs/simple.c @@ -0,0 +1,18 @@ +//===-- main.c --------------------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include + +void foo() { + printf("testing\n"); +} + +int main (int argc, char const *argv[]) { + foo(); + return 0; +} diff --git a/lit/Reproducer/TestDriverOptions.test b/lit/Reproducer/TestDriverOptions.test new file mode 100644 index 000000000000..c0713295685d --- /dev/null +++ b/lit/Reproducer/TestDriverOptions.test @@ -0,0 +1,7 @@ +# Check that errors are propagated to the driver. + +# RUN: not %lldb --capture %t/bogus/bogus 2>&1 | FileCheck %s --check-prefix CAPTURE +# RUN: not %lldb --replay %t/bogus/bogus 2>&1 | FileCheck %s --check-prefix REPLAY + +# CAPTURE: unable to create reproducer directory +# REPLAY: unable to load reproducer index diff --git a/lit/Reproducer/TestFileRepro.test b/lit/Reproducer/TestFileRepro.test new file mode 100644 index 000000000000..b33f39efaef9 --- /dev/null +++ b/lit/Reproducer/TestFileRepro.test @@ -0,0 +1,20 @@ +# REQUIRES: system-darwin + +# This tests the replaying of GDB remote packets. +# +# We issue the same commands and ensure the output is identical to the original +# process. To ensure we're not actually running the original binary we check +# that the string "testing" is not printed. + +# RUN: %clang %S/Inputs/simple.c -g -o %t.out +# RUN: %lldb -x -b -s %S/Inputs/FileCapture.in --capture %t.repro -- %t.out | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE +# RUN: rm %t.out +# RUN: %lldb -x -b -s %S/Inputs/FileReplay.in --replay %t.repro -- %t.out | FileCheck %s --check-prefix CHECK --check-prefix REPLAY + +# CAPTURE: testing +# REPLAY-NOT: testing + +# CHECK: Process {{.*}} exited + +# CAPTURE: Reproducer is in capture mode. +# CAPTURE: Reproducer written diff --git a/lit/Reproducer/TestGDBRemoteRepro.test b/lit/Reproducer/TestGDBRemoteRepro.test new file mode 100644 index 000000000000..3f509f438403 --- /dev/null +++ b/lit/Reproducer/TestGDBRemoteRepro.test @@ -0,0 +1,26 @@ +# UNSUPPORTED: system-windows, system-freebsd, system-linux + +# This tests the replaying of GDB remote packets. +# +# We issue the same commands and ensure the output is identical to the original +# process. To ensure we're not actually running the original binary we check +# that the string "testing" is not printed. + +# RUN: %clang %S/Inputs/simple.c -g -o %t.out +# RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture %t.repro -- %t.out | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE +# RUN: %lldb -x -b -s %S/Inputs/GDBRemoteReplay.in --replay %t.repro -- %t.out | FileCheck %s --check-prefix CHECK --check-prefix REPLAY + +# CHECK: Breakpoint 1 +# CHECK: Process {{.*}} stopped +# CHECK: Process {{.*}} launched +# CHECK: thread {{.*}} stop reason = breakpoint +# CHECK: frame {{.*}} simple.c + +# CAPTURE: testing +# REPLAY-NOT: testing + +# CHECK: Process {{.*}} resuming +# CHECK: Process {{.*}} exited + +# CAPTURE: Reproducer is in capture mode. +# CAPTURE: Reproducer written diff --git a/lit/Settings/TestDisassemblyFormat.test b/lit/Settings/TestDisassemblyFormat.test new file mode 100644 index 000000000000..29975a1b0163 --- /dev/null +++ b/lit/Settings/TestDisassemblyFormat.test @@ -0,0 +1,2 @@ +# RUN: %lldb -x -b -o "settings show disassembly-format" | FileCheck %s +# CHECK: disassembly-format (format-string) = "{${function.initial-function}{${module.file.basename}\`}{${function.name-without-args}}:\n}{${function.changed}\n{${module.file.basename}\`}{${function.name-without-args}}:\n}{${current-pc-arrow} }${addr-file-or-load}{ <${function.concrete-only-addr-offset-no-padding}>}: " diff --git a/lit/Settings/TestSettingsSet.test b/lit/Settings/TestSettingsSet.test new file mode 100644 index 000000000000..0def3faaadbb --- /dev/null +++ b/lit/Settings/TestSettingsSet.test @@ -0,0 +1,15 @@ +# This tests setting setting values. + +# Check that setting an empty value with -f(orce) clears the value. +# RUN: %lldb -b -s %s 2>&1 | FileCheck %s + +settings set tab-size 16 +settings show tab-size +# CHECK: tab-size (unsigned) = 16 + +settings set -f tab-size +settings show tab-size +# CHECK: tab-size (unsigned) = 4 + +settings set tab-size +# CHECK: error: 'settings set' takes more arguments diff --git a/lit/Settings/TestSettingsWrite.test b/lit/Settings/TestSettingsWrite.test new file mode 100644 index 000000000000..72dcd73e33f0 --- /dev/null +++ b/lit/Settings/TestSettingsWrite.test @@ -0,0 +1,32 @@ +# This tests writing and reading settings from LLDB. + +# Check that the settings can be written to file and read again without +# altering the values. +# RUN: %lldb -b -o 'settings write -f %t.foo' -o 'settings read -f %t.foo' -o 'settings write -f %t.bar' -o 'settings read -f %t.bar' 2>&1 | FileCheck %s --check-prefix SUCCESS +# RUN: diff -w %t.foo %t.bar +# SUCCESS-NOT: error: + +# Check that exporting target settings only export target settings and nothing else. +# RUN: %lldb -b -o 'settings write -f %t.target target' 2>&1 | FileCheck %s --check-prefix SUCCESS +# RUN: cat %t.target | FileCheck %s --check-prefix TARGET +# TARGET: settings set -f target +# TARGET-NOT: settings set -f platform +# TARGET-NOT: settings set -f symbols +# TARGET-NOT: settings set -f interpreter +# TARGET-NOT: settings set -f plugin + +# Check that settings appear twice when appending. +# RUN: %lldb -b -o 'settings write -a -f %t.append target' -o 'settings write -a -f %t.append target' 2>&1 | FileCheck %s --check-prefix SUCCESS +# RUN: cat %t.append | FileCheck %s --check-prefix APPEND +# APPEND: settings set -f target.language +# APPEND: settings set -f target.language + +# Check that an error is printed for non-existing setting. +# RUN: echo "settings set -f bogus" > %t.bogus_setting +# RUN: %lldb -b -o 'settings read -f %t.bogus_setting' 2>&1 | FileCheck %s --check-prefix BOGUS-SETTING +# BOGUS-SETTING: error: invalid value path + +# Check that an error is printed for invalid value. +# RUN: echo "settings set -f target.language bogus" > %t.bogus_value +# RUN: %lldb -b -o 'settings read -f %t.bogus_value' 2>&1 | FileCheck %s --check-prefix BOGUS-VALUE +# BOGUS-VALUE: error: invalid language type diff --git a/lit/Settings/lit.local.cfg b/lit/Settings/lit.local.cfg deleted file mode 100644 index df9b335dd131..000000000000 --- a/lit/Settings/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.test'] diff --git a/lit/Suite/lit.cfg b/lit/Suite/lit.cfg index 690655c00d79..17d85cf7e028 100644 --- a/lit/Suite/lit.cfg +++ b/lit/Suite/lit.cfg @@ -29,7 +29,7 @@ if 'Address' in config.llvm_use_sanitizer and \ runtime = os.path.join(resource_dir, 'lib', 'darwin', 'libclang_rt.asan_osx_dynamic.dylib') config.environment['ASAN_OPTIONS'] = \ - 'detect_stack_use_after_return=1:container_overflow=0' + 'detect_stack_use_after_return=1' # Swift's libReflection builds without ASAN, which causes a known # false positive in std::vector. config.environment['ASAN_OPTIONS'] += \ diff --git a/lit/Suite/lit.site.cfg.in b/lit/Suite/lit.site.cfg.in index 93cfd3ffb031..1a24f8c24c2d 100644 --- a/lit/Suite/lit.site.cfg.in +++ b/lit/Suite/lit.site.cfg.in @@ -1,6 +1,6 @@ @LIT_SITE_CFG_IN_HEADER@ -config.test_exec_root = "@LLVM_BINARY_DIR@" +config.test_exec_root = "@LLDB_BINARY_DIR@" config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" diff --git a/lit/Suite/lldbtest.py b/lit/Suite/lldbtest.py index edabaac554e1..2692d8825b00 100644 --- a/lit/Suite/lldbtest.py +++ b/lit/Suite/lldbtest.py @@ -94,7 +94,13 @@ def execute(self, test, litConfig): litConfig.maxIndividualTestTime)) if exitCode: - return lit.Test.FAIL, out + err + # Match FAIL but not XFAIL. + for line in out.splitlines() + err.splitlines(): + if line.startswith('FAIL:'): + return lit.Test.FAIL, out + err + + if 'XPASS:' in out or 'XPASS:' in err: + return lit.Test.XPASS, out + err passing_test_line = 'RESULT: PASSED' if passing_test_line not in out and passing_test_line not in err: diff --git a/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml b/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml new file mode 100644 index 000000000000..4d6a1e15b604 --- /dev/null +++ b/lit/SymbolFile/Breakpad/Inputs/basic-elf.yaml @@ -0,0 +1,33 @@ +# A very basic ELF file to serve as a recipient of breakpad info + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004000D0 +Sections: + - Name: .text1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400000 + AddressAlign: 0x0000000000001000 + Size: 0xb0 + - Name: .text2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004000B0 + AddressAlign: 0x0000000000000010 + Size: 0x42 +Symbols: +DynamicSymbols: +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x400000 + Align: 0x1000 + Sections: + - Section: .text1 + - Section: .text2 +... diff --git a/lit/SymbolFile/Breakpad/Inputs/basic-macho.yaml b/lit/SymbolFile/Breakpad/Inputs/basic-macho.yaml new file mode 100644 index 000000000000..9a4505c204d8 --- /dev/null +++ b/lit/SymbolFile/Breakpad/Inputs/basic-macho.yaml @@ -0,0 +1,50 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000002 + ncmds: 9 + sizeofcmds: 520 + flags: 0x00000085 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __PAGEZERO + vmaddr: 0 + vmsize: 4294967296 + fileoff: 0 + filesize: 0 + maxprot: 0 + initprot: 0 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 152 + segname: __TEXT + vmaddr: 4294967296 + vmsize: 4096 + fileoff: 0 + filesize: 4096 + maxprot: 7 + initprot: 5 + nsects: 1 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000100000FF0 + size: 6 + offset: 0x00000FF0 + align: 4 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_UUID + cmdsize: 24 + uuid: B3051760-22B1-7D7B-39F9-240E077D625B +... diff --git a/lit/SymbolFile/Breakpad/Inputs/symtab-macho.syms b/lit/SymbolFile/Breakpad/Inputs/symtab-macho.syms new file mode 100644 index 000000000000..6dc8904ed23c --- /dev/null +++ b/lit/SymbolFile/Breakpad/Inputs/symtab-macho.syms @@ -0,0 +1,2 @@ +MODULE mac x86_64 601705B3B1227B7D39F9240E077D625B0 mac.out +PUBLIC ff0 0 _start diff --git a/lit/SymbolFile/Breakpad/Inputs/symtab.syms b/lit/SymbolFile/Breakpad/Inputs/symtab.syms new file mode 100644 index 000000000000..3fd14643bb0f --- /dev/null +++ b/lit/SymbolFile/Breakpad/Inputs/symtab.syms @@ -0,0 +1,9 @@ +MODULE Linux x86_64 761550E08086333960A9074A9CE2895C0 a.out +INFO CODE_ID E05015768680393360A9074A9CE2895C +FILE 0 /tmp/a.c +PUBLIC b0 0 f1 +PUBLIC m c0 0 f2 +PUBLIC d0 0 _start +PUBLIC ff 0 _out_of_range_ignored +FUNC b0 c 0 f1_func +FUNC m a0 d 0 func_only diff --git a/lit/SymbolFile/Breakpad/symtab-macho.test b/lit/SymbolFile/Breakpad/symtab-macho.test new file mode 100644 index 000000000000..eef417733d30 --- /dev/null +++ b/lit/SymbolFile/Breakpad/symtab-macho.test @@ -0,0 +1,21 @@ +# RUN: yaml2obj %S/Inputs/basic-macho.yaml > %T/symtab-macho.out +# RUN: %lldb %T/symtab-macho.out -o "target symbols add -s symtab-macho.out %S/Inputs/symtab-macho.syms" \ +# RUN: -s %s | FileCheck %s + +image dump symtab symtab-macho.out +# CHECK-LABEL: (lldb) image dump symtab symtab-macho.out +# CHECK: Symtab, file = {{.*}}symtab-macho.out, num_symbols = 1: +# CHECK: Index UserID DSX Type File Address/Value Load Address Size Flags Name +# CHECK: [ 0] 0 X Code 0x0000000100000ff0 0x0000000000000006 0x00000000 _start + +# CHECK-LABEL: (lldb) image lookup -a 0x100000ff0 -v +# CHECK: Address: symtab-macho.out[0x0000000100000ff0] (symtab-macho.out.__TEXT.__text + 0) +# CHECK: Symbol: id = {0x00000000}, range = [0x0000000100000ff0-0x0000000100000ff6), name="_start" + +# CHECK-LABEL: (lldb) image lookup -n _start -v +# CHECK: Address: symtab-macho.out[0x0000000100000ff0] (symtab-macho.out.__TEXT.__text + 0) +# CHECK: Symbol: id = {0x00000000}, range = [0x0000000100000ff0-0x0000000100000ff6), name="_start" + +image lookup -a 0x100000ff0 -v +image lookup -n _start -v +exit diff --git a/lit/SymbolFile/Breakpad/symtab.test b/lit/SymbolFile/Breakpad/symtab.test new file mode 100644 index 000000000000..ea766ec8d166 --- /dev/null +++ b/lit/SymbolFile/Breakpad/symtab.test @@ -0,0 +1,24 @@ +# RUN: yaml2obj %S/Inputs/basic-elf.yaml > %T/symtab.out +# RUN: %lldb %T/symtab.out -o "target symbols add -s symtab.out %S/Inputs/symtab.syms" \ +# RUN: -s %s | FileCheck %s + +# CHECK-LABEL: (lldb) image dump symtab symtab.out +# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4: +# CHECK: Index UserID DSX Type File Address/Value Load Address Size Flags Name +# CHECK: [ 0] 0 X Code 0x00000000004000c0 0x0000000000000010 0x00000000 f2 +# CHECK: [ 1] 0 X Code 0x00000000004000d0 0x0000000000000022 0x00000000 _start +# CHECK: [ 2] 0 X Code 0x00000000004000a0 0x000000000000000d 0x00000000 func_only +# CHECK: [ 3] 0 X Code 0x00000000004000b0 0x000000000000000c 0x00000000 f1_func + +# CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v +# CHECK: Address: symtab.out[0x00000000004000b0] (symtab.out.PT_LOAD[0]..text2 + 0) +# CHECK: Symbol: id = {0x00000000}, range = [0x00000000004000b0-0x00000000004000bc), name="f1_func" + +# CHECK-LABEL: (lldb) image lookup -n f2 -v +# CHECK: Address: symtab.out[0x00000000004000c0] (symtab.out.PT_LOAD[0]..text2 + 16) +# CHECK: Symbol: id = {0x00000000}, range = [0x00000000004000c0-0x00000000004000d0), name="f2" + +image dump symtab symtab.out +image lookup -a 0x4000b0 -v +image lookup -n f2 -v +exit diff --git a/lit/SymbolFile/DWARF/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit b/lit/SymbolFile/DWARF/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit new file mode 100644 index 000000000000..390408ec8cca --- /dev/null +++ b/lit/SymbolFile/DWARF/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit @@ -0,0 +1,3 @@ +image dump line-table a.c +breakpoint set -f a.c -l 1 +breakpoint set -f foo/b.c -l 1 diff --git a/lit/SymbolFile/DWARF/Inputs/dir-separator-posix.lldbinit b/lit/SymbolFile/DWARF/Inputs/dir-separator-posix.lldbinit new file mode 100644 index 000000000000..73a8a491bb21 --- /dev/null +++ b/lit/SymbolFile/DWARF/Inputs/dir-separator-posix.lldbinit @@ -0,0 +1,3 @@ +image dump line-table a.c +breakpoint set -f a.c -l 1 +breakpoint set -f /tmp/b.c -l 1 diff --git a/lit/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit b/lit/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit new file mode 100644 index 000000000000..8737aafc8a21 --- /dev/null +++ b/lit/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit @@ -0,0 +1,7 @@ +image dump line-table a.c +breakpoint set -f a.c -l 1 +breakpoint set -f C:/tmp/b.c -l 1 + +# This will fail on non-windows systems because the path will by parsed +# according to posix rules +# breakpoint set -f 'C:\tmp\b.c' -l 1 diff --git a/lit/SymbolFile/DWARF/apple-index-is-used.cpp b/lit/SymbolFile/DWARF/apple-index-is-used.cpp index 104d86756e48..00440531e99f 100644 --- a/lit/SymbolFile/DWARF/apple-index-is-used.cpp +++ b/lit/SymbolFile/DWARF/apple-index-is-used.cpp @@ -1,5 +1,5 @@ // Test that we use the apple indexes. -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols %t | FileCheck %s // CHECK: .apple_names index present diff --git a/lit/SymbolFile/DWARF/childless-compile-unit.s b/lit/SymbolFile/DWARF/childless-compile-unit.s new file mode 100644 index 000000000000..d167e0503c52 --- /dev/null +++ b/lit/SymbolFile/DWARF/childless-compile-unit.s @@ -0,0 +1,45 @@ +# Test that we don't crash when parsing slightly invalid DWARF. The compile +# unit in this file sets DW_CHILDREN_no, but it still includes an +# end-of-children marker in its contribution. + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: lldb-test symbols %t.o + + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "Hand-written DWARF" +.Linfo_string1: + .asciz "-" +.Linfo_string2: + .asciz "/tmp" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_length_end-.Lcu_length_start # Length of Unit +.Lcu_length_start: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x30 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Linfo_string2 # DW_AT_comp_dir + .byte 0 # Bogus End Of Children Mark +.Lcu_length_end: diff --git a/lit/SymbolFile/DWARF/debug-line-basic.s b/lit/SymbolFile/DWARF/debug-line-basic.s new file mode 100644 index 000000000000..2c8024d08f18 --- /dev/null +++ b/lit/SymbolFile/DWARF/debug-line-basic.s @@ -0,0 +1,75 @@ +# REQUIRES: lld + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: %lldb %t -o "image dump line-table -v a.c" -o exit | FileCheck %s + + + .text + .globl _start +_start: +# CHECK: Line table for /tmp/a.c + .file 1 "/tmp/b.c" + .loc 1 0 0 + nop +# CHECK-NEXT: 0x0000000000201000: /tmp/b.c, is_start_of_statement = TRUE{{$}} + .loc 1 1 0 + nop +# CHECK-NEXT: 0x0000000000201001: /tmp/b.c:1, is_start_of_statement = TRUE{{$}} + .loc 1 1 1 + nop +# CHECK-NEXT: 0x0000000000201002: /tmp/b.c:1:1, is_start_of_statement = TRUE{{$}} + .loc 1 2 0 is_stmt 0 + nop +# CHECK-NEXT: 0x0000000000201003: /tmp/b.c:2{{$}} + .loc 1 2 0 is_stmt 0 basic_block + nop +# CHECK-NEXT: 0x0000000000201004: /tmp/b.c:2, is_start_of_basic_block = TRUE{{$}} + .loc 1 2 0 is_stmt 0 prologue_end + nop +# CHECK-NEXT: 0x0000000000201005: /tmp/b.c:2, is_prologue_end = TRUE{{$}} + .loc 1 2 0 is_stmt 0 epilogue_begin + nop +# CHECK-NEXT: 0x0000000000201006: /tmp/b.c:2, is_epilogue_begin = TRUE{{$}} + .file 2 "/tmp/c.c" + .loc 2 1 0 is_stmt 0 + nop +# CHECK-NEXT: 0x0000000000201007: /tmp/c.c:1{{$}} + +# CHECK-NEXT: 0x0000000000201008: /tmp/c.c:1, is_terminal_entry = TRUE{{$}} + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "a.c" +.Linfo_string2: + .asciz "/tmp" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lit/SymbolFile/DWARF/debug-names-compressed.cpp b/lit/SymbolFile/DWARF/debug-names-compressed.cpp index 076cac192522..aeb0ff1d01b1 100644 --- a/lit/SymbolFile/DWARF/debug-names-compressed.cpp +++ b/lit/SymbolFile/DWARF/debug-names-compressed.cpp @@ -3,7 +3,7 @@ // REQUIRES: lld, zlib -// RUN: clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s +// RUN: %clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s // RUN: ld.lld %t.o -o %t --compress-debug-sections=zlib // RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s diff --git a/lit/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s b/lit/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s new file mode 100644 index 000000000000..f75a51eed480 --- /dev/null +++ b/lit/SymbolFile/DWARF/dir-separator-no-comp-dir-relative-name.s @@ -0,0 +1,63 @@ +# Test that parsing of line tables works reasonably. In this case the debug info +# does not have enough information for our heuristics to determine the path +# style, so we will just treat them as native host paths. + +# REQUIRES: lld + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: %lldb %t -s %S/Inputs/dir-separator-no-comp-dir-relative-name.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for foo{{.}}a.c +# CHECK-NEXT: 0x0000000000201000: foo{{.}}a.c:1 +# CHECK-NEXT: 0x0000000000201001: foo{{.}}b.c:1 +# CHECK-NEXT: 0x0000000000201002: foo{{.}}b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f foo/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "foo/a.c" + .loc 1 1 0 + nop + .file 2 "foo/b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "foo/a.c" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lit/SymbolFile/DWARF/dir-separator-no-comp-dir.s b/lit/SymbolFile/DWARF/dir-separator-no-comp-dir.s new file mode 100644 index 000000000000..9e3281a334fa --- /dev/null +++ b/lit/SymbolFile/DWARF/dir-separator-no-comp-dir.s @@ -0,0 +1,62 @@ +# Test that we properly determine the path syntax of a compile unit even if the +# compile unit does not have a DW_AT_comp_dir attribute. + +# REQUIRES: lld + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: %lldb %t -s %S/Inputs/dir-separator-windows.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for C:\tmp\a.c +# CHECK-NEXT: 0x0000000000201000: C:\tmp\a.c:1 +# CHECK-NEXT: 0x0000000000201001: C:\tmp\b.c:1 +# CHECK-NEXT: 0x0000000000201002: C:\tmp\b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f C:/tmp/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "C:\\tmp\\a.c" + .loc 1 1 0 + nop + .file 2 "C:\\tmp\\b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "C:\\tmp\\a.c" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lit/SymbolFile/DWARF/dir-separator-posix.s b/lit/SymbolFile/DWARF/dir-separator-posix.s new file mode 100644 index 000000000000..976038a9f8b7 --- /dev/null +++ b/lit/SymbolFile/DWARF/dir-separator-posix.s @@ -0,0 +1,67 @@ +# Test that parsing of line tables works reasonably, even if the host directory +# separator does not match the separator of the compile unit. + +# REQUIRES: lld + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: %lldb %t -s %S/Inputs/dir-separator-posix.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for /tmp/a.c +# CHECK-NEXT: 0x0000000000201000: /tmp/a.c:1 +# CHECK-NEXT: 0x0000000000201001: /tmp/b.c:1 +# CHECK-NEXT: 0x0000000000201002: /tmp/b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f /tmp/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "/tmp/a.c" + .loc 1 1 0 + nop + .file 2 "/tmp/b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "a.c" +.Linfo_string2: + .asciz "/tmp" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lit/SymbolFile/DWARF/dir-separator-windows.s b/lit/SymbolFile/DWARF/dir-separator-windows.s new file mode 100644 index 000000000000..30308ab9dfb2 --- /dev/null +++ b/lit/SymbolFile/DWARF/dir-separator-windows.s @@ -0,0 +1,67 @@ +# Test that parsing of line tables works reasonably, even if the host directory +# separator does not match the separator of the compile unit. + +# REQUIRES: lld + +# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o +# RUN: ld.lld %t.o -o %t +# RUN: %lldb %t -s %S/Inputs/dir-separator-windows.lldbinit -o exit | FileCheck %s + +# CHECK-LABEL: image dump line-table a.c +# CHECK: Line table for C:\tmp\a.c +# CHECK-NEXT: 0x0000000000201000: C:\tmp\a.c:1 +# CHECK-NEXT: 0x0000000000201001: C:\tmp\b.c:1 +# CHECK-NEXT: 0x0000000000201002: C:\tmp\b.c:1 +# CHECK-EMPTY: + +# CHECK-LABEL: breakpoint set -f a.c -l 1 +# CHECK: Breakpoint 1: {{.*}}`_start, + +# CHECK-LABEL: breakpoint set -f C:/tmp/b.c -l 1 +# CHECK: Breakpoint 2: {{.*}}`_start + 1, + + .text + .globl _start +_start: + .file 1 "C:\\tmp\\a.c" + .loc 1 1 0 + nop + .file 2 "C:\\tmp\\b.c" + .loc 2 1 0 + nop + + .section .debug_str,"MS",@progbits,1 +.Linfo_string1: + .asciz "a.c" +.Linfo_string2: + .asciz "C:\\tmp" + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end0-.Lcu_start0 # Length of Unit +.Lcu_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir +.Lcu_end0: + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp b/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp index 14d2bc076d78..f5122ebadae2 100644 --- a/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp +++ b/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp @@ -2,7 +2,7 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf -gpubnames // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols %t | FileCheck %s diff --git a/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp b/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp index 3a2cf0122951..84e3b62e17bb 100644 --- a/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp +++ b/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp @@ -3,8 +3,8 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t-1.o --target=x86_64-pc-linux -DONE -mllvm -accel-tables=Dwarf -// RUN: clang %s -g -c -o %t-2.o --target=x86_64-pc-linux -DTWO -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t-1.o --target=x86_64-pc-linux -DONE -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t-2.o --target=x86_64-pc-linux -DTWO -mllvm -accel-tables=Dwarf // RUN: ld.lld %t-1.o %t-2.o -o %t // RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s diff --git a/lit/SymbolFile/DWARF/find-basic-function.cpp b/lit/SymbolFile/DWARF/find-basic-function.cpp index d04c94b38547..3d175f63e047 100644 --- a/lit/SymbolFile/DWARF/find-basic-function.cpp +++ b/lit/SymbolFile/DWARF/find-basic-function.cpp @@ -1,6 +1,6 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \ // RUN: FileCheck --check-prefix=BASE %s @@ -15,7 +15,7 @@ // RUN: lldb-test symbols --name=not_there --find=function %t | \ // RUN: FileCheck --check-prefix=EMPTY %s // -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \ // RUN: FileCheck --check-prefix=BASE %s // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ @@ -29,7 +29,7 @@ // RUN: lldb-test symbols --name=not_there --find=function %t | \ // RUN: FileCheck --check-prefix=EMPTY %s -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \ // RUN: FileCheck --check-prefix=BASE %s diff --git a/lit/SymbolFile/DWARF/find-basic-namespace.cpp b/lit/SymbolFile/DWARF/find-basic-namespace.cpp index 11a660bfba9f..e7655a37053c 100644 --- a/lit/SymbolFile/DWARF/find-basic-namespace.cpp +++ b/lit/SymbolFile/DWARF/find-basic-namespace.cpp @@ -1,6 +1,6 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=namespace %t | \ // RUN: FileCheck --check-prefix=FOO %s @@ -9,7 +9,7 @@ // RUN: lldb-test symbols --name=not_there --find=namespace %t | \ // RUN: FileCheck --check-prefix=EMPTY %s // -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=foo --find=namespace %t | \ // RUN: FileCheck --check-prefix=FOO %s // RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \ @@ -17,7 +17,7 @@ // RUN: lldb-test symbols --name=not_there --find=namespace %t | \ // RUN: FileCheck --check-prefix=EMPTY %s -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=namespace %t | \ // RUN: FileCheck --check-prefix=FOO %s diff --git a/lit/SymbolFile/DWARF/find-basic-type.cpp b/lit/SymbolFile/DWARF/find-basic-type.cpp index a470ef762e61..060a5b41eebc 100644 --- a/lit/SymbolFile/DWARF/find-basic-type.cpp +++ b/lit/SymbolFile/DWARF/find-basic-type.cpp @@ -1,6 +1,6 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=type %t | \ // RUN: FileCheck --check-prefix=NAME %s @@ -9,7 +9,7 @@ // RUN: lldb-test symbols --name=not_there --find=type %t | \ // RUN: FileCheck --check-prefix=EMPTY %s // -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=foo --find=type %t | \ // RUN: FileCheck --check-prefix=NAME %s // RUN: lldb-test symbols --name=foo --context=context --find=type %t | \ @@ -17,7 +17,7 @@ // RUN: lldb-test symbols --name=not_there --find=type %t | \ // RUN: FileCheck --check-prefix=EMPTY %s -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=type %t | \ // RUN: FileCheck --check-prefix=NAME %s diff --git a/lit/SymbolFile/DWARF/find-basic-variable.cpp b/lit/SymbolFile/DWARF/find-basic-variable.cpp index 222ad420d400..bca8f27e1d4e 100644 --- a/lit/SymbolFile/DWARF/find-basic-variable.cpp +++ b/lit/SymbolFile/DWARF/find-basic-variable.cpp @@ -1,6 +1,6 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ // RUN: FileCheck --check-prefix=CONTEXT %s @@ -11,7 +11,7 @@ // RUN: lldb-test symbols --name=not_there --find=variable %t | \ // RUN: FileCheck --check-prefix=EMPTY %s // -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ // RUN: FileCheck --check-prefix=CONTEXT %s // RUN: lldb-test symbols --name=foo --find=variable %t | \ @@ -21,7 +21,7 @@ // RUN: lldb-test symbols --name=not_there --find=variable %t | \ // RUN: FileCheck --check-prefix=EMPTY %s // -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ // RUN: FileCheck --check-prefix=CONTEXT %s diff --git a/lit/SymbolFile/DWARF/find-function-regex.cpp b/lit/SymbolFile/DWARF/find-function-regex.cpp index 2e099eb4fd74..b1e9d10e82ac 100644 --- a/lit/SymbolFile/DWARF/find-function-regex.cpp +++ b/lit/SymbolFile/DWARF/find-function-regex.cpp @@ -1,13 +1,13 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s // -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s diff --git a/lit/SymbolFile/DWARF/find-method-local-struct.cpp b/lit/SymbolFile/DWARF/find-method-local-struct.cpp index 19b41e77c17d..3da4a4a23f8a 100644 --- a/lit/SymbolFile/DWARF/find-method-local-struct.cpp +++ b/lit/SymbolFile/DWARF/find-method-local-struct.cpp @@ -1,4 +1,4 @@ -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ // RUN: FileCheck %s diff --git a/lit/SymbolFile/DWARF/find-method.cpp b/lit/SymbolFile/DWARF/find-method.cpp index 013e13435b9f..7e7710fd472b 100644 --- a/lit/SymbolFile/DWARF/find-method.cpp +++ b/lit/SymbolFile/DWARF/find-method.cpp @@ -1,11 +1,11 @@ // REQUIRES: lld -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ // RUN: FileCheck %s // -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \ // RUN: FileCheck %s diff --git a/lit/SymbolFile/DWARF/find-qualified-variable.cpp b/lit/SymbolFile/DWARF/find-qualified-variable.cpp index ca1b3184fbe7..1ad3e7fbadf5 100644 --- a/lit/SymbolFile/DWARF/find-qualified-variable.cpp +++ b/lit/SymbolFile/DWARF/find-qualified-variable.cpp @@ -1,4 +1,4 @@ -// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx +// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx // RUN: lldb-test symbols --name=A::foo --find=variable %t | FileCheck %s // CHECK: Found 1 variables: diff --git a/lit/SymbolFile/DWARF/find-type-in-function.cpp b/lit/SymbolFile/DWARF/find-type-in-function.cpp index a0894284fa26..5c1b4b44523d 100644 --- a/lit/SymbolFile/DWARF/find-type-in-function.cpp +++ b/lit/SymbolFile/DWARF/find-type-in-function.cpp @@ -2,7 +2,7 @@ // XFAIL: * -// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux +// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux // RUN: ld.lld %t.o -o %t // RUN: lldb-test symbols --name=foo --find=type %t | \ // RUN: FileCheck --check-prefix=NAME %s diff --git a/lit/SymbolFile/DWARF/find-variable-dwo.cpp b/lit/SymbolFile/DWARF/find-variable-dwo.cpp index 142ddc82cdab..b2fb1a375cf2 100644 --- a/lit/SymbolFile/DWARF/find-variable-dwo.cpp +++ b/lit/SymbolFile/DWARF/find-variable-dwo.cpp @@ -1,9 +1,9 @@ // REQUIRES: lld -// RUN: clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \ +// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \ // RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-1.dwo -o %t-1.o // RUN: llvm-objcopy --split-dwo=%t-1.dwo %t-1.o -// RUN: clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \ +// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \ // RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-2.dwo -o %t-2.o // RUN: llvm-objcopy --split-dwo=%t-2.dwo %t-2.o // RUN: ld.lld %t-1.o %t-2.o -o %t diff --git a/lit/SymbolFile/DWARF/find-variable-file.cpp b/lit/SymbolFile/DWARF/find-variable-file.cpp index f71d4a2b09b6..5a95c5338f8f 100644 --- a/lit/SymbolFile/DWARF/find-variable-file.cpp +++ b/lit/SymbolFile/DWARF/find-variable-file.cpp @@ -1,15 +1,15 @@ // REQUIRES: lld -// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s -// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp +// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s +// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp // RUN: ld.lld %t-1.o %t-2.o -o %t // RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \ // RUN: FileCheck --check-prefix=ONE %s // RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \ // RUN: FileCheck --check-prefix=TWO %s -// RUN: clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s -// RUN: clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp +// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s +// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp // RUN: ld.lld %t-1.o %t-2.o -o %t // RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \ // RUN: FileCheck --check-prefix=ONE %s diff --git a/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit b/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit new file mode 100644 index 000000000000..c25d96c531d5 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/ast-functions.lldbinit @@ -0,0 +1,8 @@ + +break set -n main +break set -n static_fn +break set -n varargs_fn + +target modules dump ast + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/ast-methods.lldbinit b/lit/SymbolFile/NativePDB/Inputs/ast-methods.lldbinit new file mode 100644 index 000000000000..6d593589c4a3 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/ast-methods.lldbinit @@ -0,0 +1,5 @@ +target variable s + +target modules dump ast + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit b/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit new file mode 100644 index 000000000000..3c0cf6d3cdfd --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit @@ -0,0 +1,20 @@ +target variable TC +target variable TS +target variable TU +target variable TE + +target variable ABCInt +target variable ABCFloat +target variable ABCVoid + +target variable AC0 +target variable ACNeg1 + +target variable AC0D +target variable ACNeg1D +target variable AD +target variable ADE + +target modules dump ast + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/bitfields.lldbinit b/lit/SymbolFile/NativePDB/Inputs/bitfields.lldbinit new file mode 100644 index 000000000000..cf06c494e678 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/bitfields.lldbinit @@ -0,0 +1,5 @@ +settings set auto-one-line-summaries false + +target variable -T TheStruct + +target modules dump ast diff --git a/lit/SymbolFile/NativePDB/Inputs/break-by-function.lldbinit b/lit/SymbolFile/NativePDB/Inputs/break-by-function.lldbinit new file mode 100644 index 000000000000..ff9bf21a8864 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/break-by-function.lldbinit @@ -0,0 +1,6 @@ +break set -n main +break set -n OvlGlobalFn +break set -n StaticFn +break set -n DoesntExist +break list +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/break-by-line.lldbinit b/lit/SymbolFile/NativePDB/Inputs/break-by-line.lldbinit new file mode 100644 index 000000000000..7daa53ba24e0 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/break-by-line.lldbinit @@ -0,0 +1,3 @@ +break set -f break-by-line.cpp -l 14 +break list +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/disassembly.lldbinit b/lit/SymbolFile/NativePDB/Inputs/disassembly.lldbinit new file mode 100644 index 000000000000..2b552a0b01dd --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/disassembly.lldbinit @@ -0,0 +1,2 @@ +disassemble --flavor=intel -m -n main +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/function-types-builtins.lldbinit b/lit/SymbolFile/NativePDB/Inputs/function-types-builtins.lldbinit new file mode 100644 index 000000000000..fe29896b5f52 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/function-types-builtins.lldbinit @@ -0,0 +1,70 @@ +command alias dv target variable + +dv aa +dv ab +dv ac +dv ad +dv ae +dv af +dv ag +dv ah +dv ai +dv aj +dv ak +dv al +dv am +dv an +dv ao +dv aq +dv ar +dv as +dv at +dv au +dv av +dv aw +dv ax +dv ay +dv az +dv aaa +dv aab +dv aac +dv aad +dv ra +dv rb +dv rc +dv rd +dv re +dv rf +dv rg +dv rh +dv ri +dv rj +dv rk +dv rl +dv rm +dv rn +dv ro +dv rq +dv rr +dv rs +dv rt +dv ru +dv rv +dv rw +dv rx +dv ry +dv rz +dv raa +dv rab +dv rac +dv rad +dv ref +dv ref2 +dv ref3 +dv binp +dv binr +dv null +dv rae +dv aae + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/function-types-calling-conv.lldbinit b/lit/SymbolFile/NativePDB/Inputs/function-types-calling-conv.lldbinit new file mode 100644 index 000000000000..8664881b262a --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/function-types-calling-conv.lldbinit @@ -0,0 +1,7 @@ +target variable sfn +target variable ffn +target variable tfn +target variable cfn +target variable vfn + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/function-types-classes.lldbinit b/lit/SymbolFile/NativePDB/Inputs/function-types-classes.lldbinit new file mode 100644 index 000000000000..c06c650e1c45 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/function-types-classes.lldbinit @@ -0,0 +1,14 @@ +target variable a +target variable b +target variable c +target variable d +target variable e +target variable f +target variable g +target variable h +target variable i +target variable incomplete + +target modules dump ast + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit b/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit new file mode 100644 index 000000000000..9bf066ee2af9 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit @@ -0,0 +1,3 @@ +target variable GlobalVariable + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit b/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit new file mode 100644 index 000000000000..cafb863d85fe --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/globals-classes.lldbinit @@ -0,0 +1,16 @@ +settings set auto-one-line-summaries false + +target variable -T ClassWithPaddingInstance +target variable -T ClassNoPaddingInstance +target variable -T DC +target variable -T EBOC +target variable -T PBC + +target variable -T UnnamedClassInstance + +target variable -T PointersInstance +target variable -T ReferencesInstance + +target modules dump ast + +quit \ No newline at end of file diff --git a/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit b/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit new file mode 100644 index 000000000000..4af8b658742b --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit @@ -0,0 +1,222 @@ +target variable BFalse +target variable BTrue +target variable CA +target variable CZ +target variable SCa +target variable SCz +target variable UC24 +target variable UC42 +target variable C16_24 +target variable C32_42 +target variable WC1 +target variable WCP +target variable SMax +target variable SMin +target variable USMax +target variable USMin +target variable IMax +target variable IMin +target variable UIMax +target variable UIMin +target variable LMax +target variable LMin +target variable ULMax +target variable ULMin +target variable LLMax +target variable LLMin +target variable ULLMax +target variable ULLMin +target variable F +target variable D + +target variable CBFalse +target variable CBTrue +target variable CCA +target variable CCZ +target variable CSCa +target variable CSCz +target variable CUC24 +target variable CUC42 +target variable CC16_24 +target variable CC32_42 +target variable CWC1 +target variable CWCP +target variable CSMax +target variable CSMin +target variable CUSMax +target variable CUSMin +target variable CIMax +target variable CIMin +target variable CUIMax +target variable CUIMin +target variable CLMax +target variable CLMin +target variable CULMax +target variable CULMin +target variable CLLMax +target variable CLLMin +target variable CULLMax +target variable CULLMin +target variable CF +target variable CD + +target variable ConstexprBFalse +target variable ConstexprBTrue +target variable ConstexprCA +target variable ConstexprCZ +target variable ConstexprSCa +target variable ConstexprSCz +target variable ConstexprUC24 +target variable ConstexprUC42 +target variable ConstexprC16_24 +target variable ConstexprC32_42 +target variable ConstexprWC1 +target variable ConstexprWCP +target variable ConstexprSMax +target variable ConstexprSMin +target variable ConstexprUSMax +target variable ConstexprUSMin +target variable ConstexprIMax +target variable ConstexprIMin +target variable ConstexprUIMax +target variable ConstexprUIMin +target variable ConstexprLMax +target variable ConstexprLMin +target variable ConstexprULMax +target variable ConstexprULMin +target variable ConstexprLLMax +target variable ConstexprLLMin +target variable ConstexprULLMax +target variable ConstexprULLMin +target variable ConstexprF +target variable ConstexprD + +target variable PBFalse +target variable PBTrue +target variable PCA +target variable PCZ +target variable PSCa +target variable PSCz +target variable PUC24 +target variable PUC42 +target variable PC16_24 +target variable PC32_42 +target variable PWC1 +target variable PWCP +target variable PSMax +target variable PSMin +target variable PUSMax +target variable PUSMin +target variable PIMax +target variable PIMin +target variable PUIMax +target variable PUIMin +target variable PLMax +target variable PLMin +target variable PULMax +target variable PULMin +target variable PLLMax +target variable PLLMin +target variable PULLMax +target variable PULLMin +target variable PF +target variable PD + +target variable CPBFalse +target variable CPBTrue +target variable CPCA +target variable CPCZ +target variable CPSCa +target variable CPSCz +target variable CPUC24 +target variable CPUC42 +target variable CPC16_24 +target variable CPC32_42 +target variable CPWC1 +target variable CPWCP +target variable CPSMax +target variable CPSMin +target variable CPUSMax +target variable CPUSMin +target variable CPIMax +target variable CPIMin +target variable CPUIMax +target variable CPUIMin +target variable CPLMax +target variable CPLMin +target variable CPULMax +target variable CPULMin +target variable CPLLMax +target variable CPLLMin +target variable CPULLMax +target variable CPULLMin +target variable CPF +target variable CPD + +target variable RBFalse +target variable RBTrue +target variable RCA +target variable RCZ +target variable RSCa +target variable RSCz +target variable RUC24 +target variable RUC42 +target variable RSMax +target variable RSMin +target variable RUSMax +target variable RUSMin +target variable RIMax +target variable RIMin +target variable RUIMax +target variable RUIMin +target variable RLMax +target variable RLMin +target variable RULMax +target variable RULMin +target variable RLLMax +target variable RLLMin +target variable RULLMax +target variable RULLMin +target variable RF +target variable RD + +target variable CRBFalse +target variable CRBTrue +target variable CRCA +target variable CRCZ +target variable CRSCa +target variable CRSCz +target variable CRUC24 +target variable CRUC42 +target variable CRSMax +target variable CRSMin +target variable CRUSMax +target variable CRUSMin +target variable CRIMax +target variable CRIMin +target variable CRUIMax +target variable CRUIMin +target variable CRLMax +target variable CRLMin +target variable CRULMax +target variable CRULMin +target variable CRLLMax +target variable CRLLMin +target variable CRULLMax +target variable CRULLMin +target variable CRF +target variable CRD + +target variable RC16_24 +target variable RC32_42 +target variable RWC1 +target variable RWCP +target variable CRC16_24 +target variable CRC32_42 +target variable CRWC1 +target variable CRWCP + +target modules dump ast + + +quit \ No newline at end of file diff --git a/lit/SymbolFile/NativePDB/Inputs/local-variables.lldbinit b/lit/SymbolFile/NativePDB/Inputs/local-variables.lldbinit new file mode 100644 index 000000000000..0d7371e86f1c --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/local-variables.lldbinit @@ -0,0 +1,32 @@ +break set -n main +run a b c d e f g +p argc +step +p SomeLocal +step +p Param1 +p Param2 +step +p Param1 +p Param2 +p Local1 +step +p Param1 +p Param2 +p Local1 +p Local2 +step +p Param1 +p Param2 +p Local1 +p Local2 +step +p Param1 +p Param2 +p Local1 +p Local2 +continue + +target modules dump ast + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/nested-types.lldbinit b/lit/SymbolFile/NativePDB/Inputs/nested-types.lldbinit new file mode 100644 index 000000000000..466df81fc421 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/nested-types.lldbinit @@ -0,0 +1,13 @@ +settings set auto-one-line-summaries false + +target variable -T GlobalA +target variable -T GlobalB +target variable -T GlobalC +target variable -T GlobalD +target variable -T GlobalE +target variable -T GlobalF +target variable -T GlobalG +target variable -T GlobalH +target variable -T GlobalEnum + +target modules dump ast diff --git a/lit/SymbolFile/NativePDB/Inputs/s_constant.lldbinit b/lit/SymbolFile/NativePDB/Inputs/s_constant.lldbinit new file mode 100644 index 000000000000..1a50d808cdc2 --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/s_constant.lldbinit @@ -0,0 +1,25 @@ +target variable GlobalLUEA +target variable GlobalLUEB +target variable GlobalLUEC + +target variable GlobalLSEA +target variable GlobalLSEB +target variable GlobalLSEC + +target variable GlobalUEA +target variable GlobalUEB +target variable GlobalUEC + +target variable GlobalSEA +target variable GlobalSEB +target variable GlobalSEC + +target variable GlobalSUEA +target variable GlobalSUEB +target variable GlobalSUEC + +target variable GlobalSSEA +target variable GlobalSSEB +target variable GlobalSSEC + +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/s_constant.s b/lit/SymbolFile/NativePDB/Inputs/s_constant.s new file mode 100644 index 000000000000..553a5ce06dbf --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/s_constant.s @@ -0,0 +1,971 @@ + .text + .def @feat.00; + .scl 3; + .type 0; + .endef + .globl @feat.00 +.set @feat.00, 0 + .intel_syntax noprefix + .def main; + .scl 2; + .type 32; + .endef + .globl main # -- Begin function main + .p2align 4, 0x90 +main: # @main +.Lfunc_begin0: + .cv_func_id 0 + .cv_file 1 "D:\\src\\llvm-mono\\lldb\\lit\\SymbolFile\\NativePDB\\s_constant.cpp" "7F1DA683A9B72A1360C1FDEDD7550E06" 1 + .cv_loc 0 1 79 0 # D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp:79:0 +.seh_proc main +# %bb.0: # %entry + sub rsp, 24 + .seh_stackalloc 24 + .seh_endprologue + xor eax, eax + mov dword ptr [rsp + 20], 0 + mov qword ptr [rsp + 8], rdx + mov dword ptr [rsp + 4], ecx +.Ltmp0: + .cv_loc 0 1 80 0 # D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp:80:0 + add rsp, 24 + ret +.Ltmp1: +.Lfunc_end0: + .seh_handlerdata + .text + .seh_endproc + # -- End function + .section .rdata,"dr" + .p2align 3 # @GlobalLUEA +GlobalLUEA: + .quad 0 # 0x0 + + .p2align 3 # @GlobalLUEB +GlobalLUEB: + .quad 1000 # 0x3e8 + + .p2align 3 # @GlobalLUEC +GlobalLUEC: + .quad -16 # 0xfffffffffffffff0 + + .p2align 3 # @GlobalLSEA +GlobalLSEA: + .quad 0 # 0x0 + + .p2align 3 # @GlobalLSEB +GlobalLSEB: + .quad 9223372036854775000 # 0x7ffffffffffffcd8 + + .p2align 3 # @GlobalLSEC +GlobalLSEC: + .quad -9223372036854775000 # 0x8000000000000328 + + .p2align 2 # @GlobalUEA +GlobalUEA: + .long 0 # 0x0 + + .p2align 2 # @GlobalUEB +GlobalUEB: + .long 1000 # 0x3e8 + + .p2align 2 # @GlobalUEC +GlobalUEC: + .long 4294000000 # 0xfff13d80 + + .p2align 2 # @GlobalSEA +GlobalSEA: + .long 0 # 0x0 + + .p2align 2 # @GlobalSEB +GlobalSEB: + .long 2147000000 # 0x7ff89ec0 + + .p2align 2 # @GlobalSEC +GlobalSEC: + .long 2147967296 # 0x80076140 + +GlobalSUEA: # @GlobalSUEA + .byte 0 # 0x0 + +GlobalSUEB: # @GlobalSUEB + .byte 100 # 0x64 + +GlobalSUEC: # @GlobalSUEC + .byte 200 # 0xc8 + +GlobalSSEA: # @GlobalSSEA + .byte 0 # 0x0 + +GlobalSSEB: # @GlobalSSEB + .byte 100 # 0x64 + +GlobalSSEC: # @GlobalSSEC + .byte 156 # 0x9c + + .section .drectve,"yn" + .ascii " /DEFAULTLIB:libcmt.lib" + .ascii " /DEFAULTLIB:oldnames.lib" + .section .debug$S,"dr" + .p2align 2 + .long 4 # Debug section magic + .long 241 + .long .Ltmp3-.Ltmp2 # Subsection size +.Ltmp2: + .short .Ltmp5-.Ltmp4 # Record length +.Ltmp4: + .short 4412 # Record kind: S_COMPILE3 + .long 1 # Flags and language + .short 208 # CPUType + .short 8 # Frontend version + .short 0 + .short 0 + .short 0 + .short 8000 # Backend version + .short 0 + .short 0 + .short 0 + .asciz "clang version 8.0.0 " # Null-terminated compiler version string +.Ltmp5: +.Ltmp3: + .p2align 2 + .long 241 # Symbol subsection for main + .long .Ltmp7-.Ltmp6 # Subsection size +.Ltmp6: + .short .Ltmp9-.Ltmp8 # Record length +.Ltmp8: + .short 4423 # Record kind: S_GPROC32_ID + .long 0 # PtrParent + .long 0 # PtrEnd + .long 0 # PtrNext + .long .Lfunc_end0-main # Code size + .long 0 # Offset after prologue + .long 0 # Offset before epilogue + .long 4099 # Function type index + .secrel32 main # Function section relative address + .secidx main # Function section index + .byte 0 # Flags + .asciz "main" # Function name +.Ltmp9: + .short .Ltmp11-.Ltmp10 # Record length +.Ltmp10: + .short 4114 # Record kind: S_FRAMEPROC + .long 24 # FrameSize + .long 0 # Padding + .long 0 # Offset of padding + .long 0 # Bytes of callee saved registers + .long 0 # Exception handler offset + .short 0 # Exception handler section + .long 81920 # Flags (defines frame register) +.Ltmp11: + .short .Ltmp13-.Ltmp12 # Record length +.Ltmp12: + .short 4414 # Record kind: S_LOCAL + .long 116 # TypeIndex + .short 1 # Flags + .asciz "argc" +.Ltmp13: + .cv_def_range .Ltmp0 .Ltmp1, "B\021\004\000\000\000" + .short .Ltmp15-.Ltmp14 # Record length +.Ltmp14: + .short 4414 # Record kind: S_LOCAL + .long 4096 # TypeIndex + .short 1 # Flags + .asciz "argv" +.Ltmp15: + .cv_def_range .Ltmp0 .Ltmp1, "B\021\b\000\000\000" + .short 2 # Record length + .short 4431 # Record kind: S_PROC_ID_END +.Ltmp7: + .p2align 2 + .cv_linetable 0, main, .Lfunc_end0 + .long 241 # Symbol subsection for globals + .long .Ltmp17-.Ltmp16 # Subsection size +.Ltmp16: + .short .Ltmp19-.Ltmp18 # Record length +.Ltmp18: + .short 4359 # Record kind: S_CONSTANT + .long 4104 # Type + .short 0 # Value + .asciz "GlobalLUEA" # Name +.Ltmp19: + .short .Ltmp21-.Ltmp20 # Record length +.Ltmp20: + .short 4359 # Record kind: S_CONSTANT + .long 4104 # Type + .short 1000 # Value + .asciz "GlobalLUEB" # Name +.Ltmp21: + .short .Ltmp23-.Ltmp22 # Record length +.Ltmp22: + .short 4359 # Record kind: S_CONSTANT + .long 4104 # Type + .byte 0x00, 0x80, 0xf0 # Value + .asciz "GlobalLUEC" # Name +.Ltmp23: + .short .Ltmp25-.Ltmp24 # Record length +.Ltmp24: + .short 4359 # Record kind: S_CONSTANT + .long 4108 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalLSEA" # Name +.Ltmp25: + .short .Ltmp27-.Ltmp26 # Record length +.Ltmp26: + .short 4359 # Record kind: S_CONSTANT + .long 4108 # Type + .byte 0x0A, 0x80, 0xD8, 0xFC # Value + .byte 0xFF, 0xFF, 0xFF, 0xFF + .byte 0xFF, 0x7F + .asciz "GlobalLSEB" # Name +.Ltmp27: + .short .Ltmp29-.Ltmp28 # Record length +.Ltmp28: + .short 4359 # Record kind: S_CONSTANT + .long 4108 # Type + .byte 0x09, 0x80, 0x28, 0x03 # Value + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x80 + .asciz "GlobalLSEC" # Name +.Ltmp29: + .short .Ltmp31-.Ltmp30 # Record length +.Ltmp30: + .short 4359 # Record kind: S_CONSTANT + .long 4112 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalUEA" # Name +.Ltmp31: + .short .Ltmp33-.Ltmp32 # Record length +.Ltmp32: + .short 4359 # Record kind: S_CONSTANT + .long 4112 # Type + .byte 0xe8, 0x03 # Value + .asciz "GlobalUEB" # Name +.Ltmp33: + .short .Ltmp35-.Ltmp34 # Record length +.Ltmp34: + .short 4359 # Record kind: S_CONSTANT + .long 4112 # Type + .byte 0x04, 0x80, 0x80, 0x3d # Value + .byte 0xf1, 0xff + .asciz "GlobalUEC" # Name +.Ltmp35: + .short .Ltmp37-.Ltmp36 # Record length +.Ltmp36: + .short 4359 # Record kind: S_CONSTANT + .long 4116 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalSEA" # Name +.Ltmp37: + .short .Ltmp39-.Ltmp38 # Record length +.Ltmp38: + .short 4359 # Record kind: S_CONSTANT + .long 4116 # Type + .byte 0x04, 0x80, 0xc0, 0x9e # Value + .byte 0xf8, 0x7f + .asciz "GlobalSEB" # Name +.Ltmp39: + .short .Ltmp41-.Ltmp40 # Record length +.Ltmp40: + .short 4359 # Record kind: S_CONSTANT + .long 4116 # Type + .byte 0x03, 0x80, 0x40, 0x61 # Value + .byte 0x07, 0x80 + .asciz "GlobalSEC" # Name +.Ltmp41: + .short .Ltmp43-.Ltmp42 # Record length +.Ltmp42: + .short 4359 # Record kind: S_CONSTANT + .long 4120 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalSUEA" # Name +.Ltmp43: + .short .Ltmp45-.Ltmp44 # Record length +.Ltmp44: + .short 4359 # Record kind: S_CONSTANT + .long 4120 # Type + .byte 0x64, 0x00 # Value + .asciz "GlobalSUEB" # Name +.Ltmp45: + .short .Ltmp47-.Ltmp46 # Record length +.Ltmp46: + .short 4359 # Record kind: S_CONSTANT + .long 4120 # Type + .byte 0xc8, 0x00 # Value + .asciz "GlobalSUEC" # Name +.Ltmp47: + .short .Ltmp49-.Ltmp48 # Record length +.Ltmp48: + .short 4359 # Record kind: S_CONSTANT + .long 4124 # Type + .byte 0x00, 0x00 # Value + .asciz "GlobalSSEA" # Name +.Ltmp49: + .short .Ltmp51-.Ltmp50 # Record length +.Ltmp50: + .short 4359 # Record kind: S_CONSTANT + .long 4124 # Type + .byte 0x64, 0x00 # Value + .asciz "GlobalSSEB" # Name +.Ltmp51: + .short .Ltmp53-.Ltmp52 # Record length +.Ltmp52: + .short 4359 # Record kind: S_CONSTANT + .long 4124 # Type + .byte 0x00, 0x80, 0x9c # Value + .asciz "GlobalSSEC" # Name +.Ltmp53: +.Ltmp17: + .p2align 2 + .cv_filechecksums # File index to string table offset subsection + .cv_stringtable # String table + .long 241 + .long .Ltmp55-.Ltmp54 # Subsection size +.Ltmp54: + .short 6 # Record length + .short 4428 # Record kind: S_BUILDINFO + .long 4127 # LF_BUILDINFO index +.Ltmp55: + .p2align 2 + .section .debug$T,"dr" + .p2align 2 + .long 4 # Debug section magic + # Pointer (0x1000) { + # TypeLeafKind: LF_POINTER (0x1002) + # PointeeType: char* (0x670) + # PointerAttributes: 0x1000C + # PtrType: Near64 (0xC) + # PtrMode: Pointer (0x0) + # IsFlat: 0 + # IsConst: 0 + # IsVolatile: 0 + # IsUnaligned: 0 + # IsRestrict: 0 + # SizeOf: 8 + # } + .byte 0x0a, 0x00, 0x02, 0x10 + .byte 0x70, 0x06, 0x00, 0x00 + .byte 0x0c, 0x00, 0x01, 0x00 + # ArgList (0x1001) { + # TypeLeafKind: LF_ARGLIST (0x1201) + # NumArgs: 2 + # Arguments [ + # ArgType: int (0x74) + # ArgType: char** (0x1000) + # ] + # } + .byte 0x0e, 0x00, 0x01, 0x12 + .byte 0x02, 0x00, 0x00, 0x00 + .byte 0x74, 0x00, 0x00, 0x00 + .byte 0x00, 0x10, 0x00, 0x00 + # Procedure (0x1002) { + # TypeLeafKind: LF_PROCEDURE (0x1008) + # ReturnType: int (0x74) + # CallingConvention: NearC (0x0) + # FunctionOptions [ (0x0) + # ] + # NumParameters: 2 + # ArgListType: (int, char**) (0x1001) + # } + .byte 0x0e, 0x00, 0x08, 0x10 + .byte 0x74, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x02, 0x00 + .byte 0x01, 0x10, 0x00, 0x00 + # FuncId (0x1003) { + # TypeLeafKind: LF_FUNC_ID (0x1601) + # ParentScope: 0x0 + # FunctionType: int (int, char**) (0x1002) + # Name: main + # } + .byte 0x12, 0x00, 0x01, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x02, 0x10, 0x00, 0x00 + .byte 0x6d, 0x61, 0x69, 0x6e + .byte 0x00, 0xf3, 0xf2, 0xf1 + # FieldList (0x1004) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: LUE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 1000 + # Name: LUE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 18446744073709551600 + # Name: LUE_C + # } + # } + .byte 0x2e, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x4c, 0x55 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0xe8, 0x03, 0x4c, 0x55 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0xf0, 0xff + .byte 0xff, 0xff, 0xff, 0xff + .byte 0xff, 0xff, 0x4c, 0x55 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x1005) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: unsigned __int64 (0x23) + # FieldListType: (0x1004) + # Name: A::B::C::LargeUnsignedEnum + # LinkageName: .?AW4LargeUnsignedEnum@C@B@A@@ + # } + .byte 0x4a, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x23, 0x00, 0x00, 0x00 + .byte 0x04, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x4c, 0x61, 0x72 + .byte 0x67, 0x65, 0x55, 0x6e + .byte 0x73, 0x69, 0x67, 0x6e + .byte 0x65, 0x64, 0x45, 0x6e + .byte 0x75, 0x6d, 0x00, 0x2e + .byte 0x3f, 0x41, 0x57, 0x34 + .byte 0x4c, 0x61, 0x72, 0x67 + .byte 0x65, 0x55, 0x6e, 0x73 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # StringId (0x1006) { + # TypeLeafKind: LF_STRING_ID (0x1605) + # Id: 0x0 + # StringData: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp + # } + .byte 0x46, 0x00, 0x05, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x44, 0x3a, 0x5c, 0x73 + .byte 0x72, 0x63, 0x5c, 0x6c + .byte 0x6c, 0x76, 0x6d, 0x2d + .byte 0x6d, 0x6f, 0x6e, 0x6f + .byte 0x5c, 0x6c, 0x6c, 0x64 + .byte 0x62, 0x5c, 0x6c, 0x69 + .byte 0x74, 0x5c, 0x53, 0x79 + .byte 0x6d, 0x62, 0x6f, 0x6c + .byte 0x46, 0x69, 0x6c, 0x65 + .byte 0x5c, 0x4e, 0x61, 0x74 + .byte 0x69, 0x76, 0x65, 0x50 + .byte 0x44, 0x42, 0x5c, 0x73 + .byte 0x5f, 0x63, 0x6f, 0x6e + .byte 0x73, 0x74, 0x61, 0x6e + .byte 0x74, 0x2e, 0x63, 0x70 + .byte 0x70, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x1007) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::LargeUnsignedEnum (0x1005) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 14 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x05, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x0e, 0x00, 0x00, 0x00 + # Modifier (0x1008) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::LargeUnsignedEnum (0x1005) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x05, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1009) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: LSE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 9223372036854775000 + # Name: LSE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 9223372036854776616 + # Name: LSE_C + # } + # } + .byte 0x36, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x4c, 0x53 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0xd8, 0xfc + .byte 0xff, 0xff, 0xff, 0xff + .byte 0xff, 0x7f, 0x4c, 0x53 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0x28, 0x03 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x80, 0x4c, 0x53 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x100A) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: __int64 (0x13) + # FieldListType: (0x1009) + # Name: A::B::C::LargeSignedEnum + # LinkageName: .?AW4LargeSignedEnum@C@B@A@@ + # } + .byte 0x46, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x13, 0x00, 0x00, 0x00 + .byte 0x09, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x4c, 0x61, 0x72 + .byte 0x67, 0x65, 0x53, 0x69 + .byte 0x67, 0x6e, 0x65, 0x64 + .byte 0x45, 0x6e, 0x75, 0x6d + .byte 0x00, 0x2e, 0x3f, 0x41 + .byte 0x57, 0x34, 0x4c, 0x61 + .byte 0x72, 0x67, 0x65, 0x53 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x100B) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::LargeSignedEnum (0x100A) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 20 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x0a, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x14, 0x00, 0x00, 0x00 + # Modifier (0x100C) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::LargeSignedEnum (0x100A) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x0a, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x100D) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: UE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 1000 + # Name: UE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 4294000000 + # Name: UE_C + # } + # } + .byte 0x2a, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x55, 0x45 + .byte 0x5f, 0x41, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0xe8, 0x03, 0x55, 0x45 + .byte 0x5f, 0x42, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x04, 0x80, 0x80, 0x3d + .byte 0xf1, 0xff, 0x55, 0x45 + .byte 0x5f, 0x43, 0x00, 0xf1 + # Enum (0x100E) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: unsigned (0x75) + # FieldListType: (0x100D) + # Name: A::B::C::UnsignedEnum + # LinkageName: .?AW4UnsignedEnum@C@B@A@@ + # } + .byte 0x3e, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x75, 0x00, 0x00, 0x00 + .byte 0x0d, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x55, 0x6e, 0x73 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x00, 0x2e, 0x3f + .byte 0x41, 0x57, 0x34, 0x55 + .byte 0x6e, 0x73, 0x69, 0x67 + .byte 0x6e, 0x65, 0x64, 0x45 + .byte 0x6e, 0x75, 0x6d, 0x40 + .byte 0x43, 0x40, 0x42, 0x40 + .byte 0x41, 0x40, 0x40, 0x00 + # UdtSourceLine (0x100F) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::UnsignedEnum (0x100E) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 26 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x0e, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x1a, 0x00, 0x00, 0x00 + # Modifier (0x1010) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::UnsignedEnum (0x100E) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x0e, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1011) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: SE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 2147000000 + # Name: SE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 18446744071562551616 + # Name: SE_C + # } + # } + .byte 0x32, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x53, 0x45 + .byte 0x5f, 0x41, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x04, 0x80, 0xc0, 0x9e + .byte 0xf8, 0x7f, 0x53, 0x45 + .byte 0x5f, 0x42, 0x00, 0xf1 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0x40, 0x61 + .byte 0x07, 0x80, 0xff, 0xff + .byte 0xff, 0xff, 0x53, 0x45 + .byte 0x5f, 0x43, 0x00, 0xf1 + # Enum (0x1012) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: int (0x74) + # FieldListType: (0x1011) + # Name: A::B::C::SignedEnum + # LinkageName: .?AW4SignedEnum@C@B@A@@ + # } + .byte 0x3a, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x74, 0x00, 0x00, 0x00 + .byte 0x11, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x53, 0x69, 0x67 + .byte 0x6e, 0x65, 0x64, 0x45 + .byte 0x6e, 0x75, 0x6d, 0x00 + .byte 0x2e, 0x3f, 0x41, 0x57 + .byte 0x34, 0x53, 0x69, 0x67 + .byte 0x6e, 0x65, 0x64, 0x45 + .byte 0x6e, 0x75, 0x6d, 0x40 + .byte 0x43, 0x40, 0x42, 0x40 + .byte 0x41, 0x40, 0x40, 0x00 + # UdtSourceLine (0x1013) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::SignedEnum (0x1012) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 32 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x12, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x20, 0x00, 0x00, 0x00 + # Modifier (0x1014) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::SignedEnum (0x1012) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x12, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1015) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: SUE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 100 + # Name: SUE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 200 + # Name: SUE_C + # } + # } + .byte 0x26, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x53, 0x55 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x64, 0x00, 0x53, 0x55 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0xc8, 0x00, 0x53, 0x55 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x1016) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: unsigned char (0x20) + # FieldListType: (0x1015) + # Name: A::B::C::SmallUnsignedEnum + # LinkageName: .?AW4SmallUnsignedEnum@C@B@A@@ + # } + .byte 0x4a, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x20, 0x00, 0x00, 0x00 + .byte 0x15, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x53, 0x6d, 0x61 + .byte 0x6c, 0x6c, 0x55, 0x6e + .byte 0x73, 0x69, 0x67, 0x6e + .byte 0x65, 0x64, 0x45, 0x6e + .byte 0x75, 0x6d, 0x00, 0x2e + .byte 0x3f, 0x41, 0x57, 0x34 + .byte 0x53, 0x6d, 0x61, 0x6c + .byte 0x6c, 0x55, 0x6e, 0x73 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x1017) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::SmallUnsignedEnum (0x1016) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 38 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x16, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x26, 0x00, 0x00, 0x00 + # Modifier (0x1018) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::SmallUnsignedEnum (0x1016) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x16, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # FieldList (0x1019) { + # TypeLeafKind: LF_FIELDLIST (0x1203) + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 0 + # Name: SSE_A + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 100 + # Name: SSE_B + # } + # Enumerator { + # TypeLeafKind: LF_ENUMERATE (0x1502) + # AccessSpecifier: Public (0x3) + # EnumValue: 18446744073709551516 + # Name: SSE_C + # } + # } + .byte 0x2e, 0x00, 0x03, 0x12 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x00, 0x00, 0x53, 0x53 + .byte 0x45, 0x5f, 0x41, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x64, 0x00, 0x53, 0x53 + .byte 0x45, 0x5f, 0x42, 0x00 + .byte 0x02, 0x15, 0x03, 0x00 + .byte 0x0a, 0x80, 0x9c, 0xff + .byte 0xff, 0xff, 0xff, 0xff + .byte 0xff, 0xff, 0x53, 0x53 + .byte 0x45, 0x5f, 0x43, 0x00 + # Enum (0x101A) { + # TypeLeafKind: LF_ENUM (0x1507) + # NumEnumerators: 3 + # Properties [ (0x200) + # HasUniqueName (0x200) + # ] + # UnderlyingType: char (0x70) + # FieldListType: (0x1019) + # Name: A::B::C::SmallSignedEnum + # LinkageName: .?AW4SmallSignedEnum@C@B@A@@ + # } + .byte 0x46, 0x00, 0x07, 0x15 + .byte 0x03, 0x00, 0x00, 0x02 + .byte 0x70, 0x00, 0x00, 0x00 + .byte 0x19, 0x10, 0x00, 0x00 + .byte 0x41, 0x3a, 0x3a, 0x42 + .byte 0x3a, 0x3a, 0x43, 0x3a + .byte 0x3a, 0x53, 0x6d, 0x61 + .byte 0x6c, 0x6c, 0x53, 0x69 + .byte 0x67, 0x6e, 0x65, 0x64 + .byte 0x45, 0x6e, 0x75, 0x6d + .byte 0x00, 0x2e, 0x3f, 0x41 + .byte 0x57, 0x34, 0x53, 0x6d + .byte 0x61, 0x6c, 0x6c, 0x53 + .byte 0x69, 0x67, 0x6e, 0x65 + .byte 0x64, 0x45, 0x6e, 0x75 + .byte 0x6d, 0x40, 0x43, 0x40 + .byte 0x42, 0x40, 0x41, 0x40 + .byte 0x40, 0x00, 0xf2, 0xf1 + # UdtSourceLine (0x101B) { + # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) + # UDT: A::B::C::SmallSignedEnum (0x101A) + # SourceFile: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\s_constant.cpp (0x1006) + # LineNumber: 44 + # } + .byte 0x0e, 0x00, 0x06, 0x16 + .byte 0x1a, 0x10, 0x00, 0x00 + .byte 0x06, 0x10, 0x00, 0x00 + .byte 0x2c, 0x00, 0x00, 0x00 + # Modifier (0x101C) { + # TypeLeafKind: LF_MODIFIER (0x1001) + # ModifiedType: A::B::C::SmallSignedEnum (0x101A) + # Modifiers [ (0x1) + # Const (0x1) + # ] + # } + .byte 0x0a, 0x00, 0x01, 0x10 + .byte 0x1a, 0x10, 0x00, 0x00 + .byte 0x01, 0x00, 0xf2, 0xf1 + # StringId (0x101D) { + # TypeLeafKind: LF_STRING_ID (0x1605) + # Id: 0x0 + # StringData: D:\\src\\llvmbuild\\ninja-x64 + # } + .byte 0x26, 0x00, 0x05, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x44, 0x3a, 0x5c, 0x5c + .byte 0x73, 0x72, 0x63, 0x5c + .byte 0x5c, 0x6c, 0x6c, 0x76 + .byte 0x6d, 0x62, 0x75, 0x69 + .byte 0x6c, 0x64, 0x5c, 0x5c + .byte 0x6e, 0x69, 0x6e, 0x6a + .byte 0x61, 0x2d, 0x78, 0x36 + .byte 0x34, 0x00, 0xf2, 0xf1 + # StringId (0x101E) { + # TypeLeafKind: LF_STRING_ID (0x1605) + # Id: 0x0 + # StringData: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\variable.cpp + # } + .byte 0x42, 0x00, 0x05, 0x16 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x44, 0x3a, 0x5c, 0x73 + .byte 0x72, 0x63, 0x5c, 0x6c + .byte 0x6c, 0x76, 0x6d, 0x2d + .byte 0x6d, 0x6f, 0x6e, 0x6f + .byte 0x5c, 0x6c, 0x6c, 0x64 + .byte 0x62, 0x5c, 0x6c, 0x69 + .byte 0x74, 0x5c, 0x53, 0x79 + .byte 0x6d, 0x62, 0x6f, 0x6c + .byte 0x46, 0x69, 0x6c, 0x65 + .byte 0x5c, 0x4e, 0x61, 0x74 + .byte 0x69, 0x76, 0x65, 0x50 + .byte 0x44, 0x42, 0x5c, 0x76 + .byte 0x61, 0x72, 0x69, 0x61 + .byte 0x62, 0x6c, 0x65, 0x2e + .byte 0x63, 0x70, 0x70, 0x00 + # BuildInfo (0x101F) { + # TypeLeafKind: LF_BUILDINFO (0x1603) + # NumArgs: 5 + # Arguments [ + # ArgType: D:\\src\\llvmbuild\\ninja-x64 (0x101D) + # ArgType: 0x0 + # ArgType: D:\src\llvm-mono\lldb\lit\SymbolFile\NativePDB\variable.cpp (0x101E) + # ArgType: 0x0 + # ArgType: 0x0 + # ] + # } + .byte 0x1a, 0x00, 0x03, 0x16 + .byte 0x05, 0x00, 0x1d, 0x10 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x1e, 0x10 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0xf2, 0xf1 + + .addrsig + .addrsig_sym GlobalLUEA + .addrsig_sym GlobalLUEB + .addrsig_sym GlobalLUEC + .addrsig_sym GlobalLSEA + .addrsig_sym GlobalLSEB + .addrsig_sym GlobalLSEC + .addrsig_sym GlobalUEA + .addrsig_sym GlobalUEB + .addrsig_sym GlobalUEC + .addrsig_sym GlobalSEA + .addrsig_sym GlobalSEB + .addrsig_sym GlobalSEC + .addrsig_sym GlobalSUEA + .addrsig_sym GlobalSUEB + .addrsig_sym GlobalSUEC + .addrsig_sym GlobalSSEA + .addrsig_sym GlobalSSEB + .addrsig_sym GlobalSSEC diff --git a/lit/SymbolFile/NativePDB/Inputs/source-list.lldbinit b/lit/SymbolFile/NativePDB/Inputs/source-list.lldbinit new file mode 100644 index 000000000000..624ce5ba156b --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/source-list.lldbinit @@ -0,0 +1,3 @@ +source list -n main +source list -n OvlGlobalFn +quit diff --git a/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit b/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit new file mode 100644 index 000000000000..c50e18101b1b --- /dev/null +++ b/lit/SymbolFile/NativePDB/Inputs/tag-types.lldbinit @@ -0,0 +1,8 @@ +type lookup -- Struct +type lookup -- Class +type lookup -- Union +type lookup -- Derived +type lookup -- Derived2 +type lookup -- EnumInt +type lookup -- EnumShort +type lookup -- InvalidType diff --git a/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp b/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp new file mode 100644 index 000000000000..b8154168aff3 --- /dev/null +++ b/lit/SymbolFile/NativePDB/ast-functions-msvc.cpp @@ -0,0 +1,7 @@ +// clang-format off +// REQUIRES: msvc + +// RUN: %build --compiler=msvc --nodefaultlib -o %t.exe -- %S/ast-functions.cpp + +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-functions.lldbinit 2>&1 | FileCheck %S/ast-functions.cpp diff --git a/lit/SymbolFile/NativePDB/ast-functions.cpp b/lit/SymbolFile/NativePDB/ast-functions.cpp new file mode 100644 index 000000000000..1cfd01f13c1b --- /dev/null +++ b/lit/SymbolFile/NativePDB/ast-functions.cpp @@ -0,0 +1,28 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s + +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-functions.lldbinit 2>&1 | FileCheck %s + +static int static_fn() { + return 42; +} + +int varargs_fn(int x, int y, ...) { + return x + y; +} + +int main(int argc, char **argv) { + return static_fn() + varargs_fn(argc, argc); +} + +// CHECK: TranslationUnitDecl +// CHECK-NEXT: |-FunctionDecl {{.*}} main 'int (int, char **)' +// CHECK-NEXT: | |-ParmVarDecl {{.*}} argc 'int' +// CHECK-NEXT: | `-ParmVarDecl {{.*}} argv 'char **' +// CHECK-NEXT: |-FunctionDecl {{.*}} static_fn 'int ()' static +// CHECK-NEXT: `-FunctionDecl {{.*}} varargs_fn 'int (int, int, ...)' +// CHECK-NEXT: |-ParmVarDecl {{.*}} x 'int' +// CHECK-NEXT: `-ParmVarDecl {{.*}} y 'int' diff --git a/lit/SymbolFile/NativePDB/ast-methods.cpp b/lit/SymbolFile/NativePDB/ast-methods.cpp new file mode 100644 index 000000000000..6006c722cfba --- /dev/null +++ b/lit/SymbolFile/NativePDB/ast-methods.cpp @@ -0,0 +1,36 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-methods.lldbinit 2>&1 | FileCheck %s + +struct Struct { + void simple_method() {} + + virtual void virtual_method() {} + + static void static_method() {} + + int overloaded_method() {} + int overloaded_method(char c) {} + int overloaded_method(char c, int i, ...) {} +}; + +Struct s; + +int main(int argc, char **argv) { + return 0; +} + +// CHECK: TranslationUnitDecl +// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition +// CHECK: | |-CXXMethodDecl {{.*}} simple_method 'void (){{.*}}' +// CHECK: | |-CXXMethodDecl {{.*}} virtual_method 'void (){{.*}}' virtual +// CHECK: | |-CXXMethodDecl {{.*}} static_method 'void ()' static +// CHECK: | |-CXXMethodDecl {{.*}} overloaded_method 'int (){{.*}}' +// CHECK: | |-CXXMethodDecl {{.*}} overloaded_method 'int (char){{.*}}' +// CHECK: | | `-ParmVarDecl {{.*}} 'char' +// CHECK: | `-CXXMethodDecl {{.*}} overloaded_method 'int (char, int, ...)' +// CHECK: | |-ParmVarDecl {{.*}} 'char' +// CHECK: | `-ParmVarDecl {{.*}} 'int' diff --git a/lit/SymbolFile/NativePDB/ast-types.cpp b/lit/SymbolFile/NativePDB/ast-types.cpp new file mode 100644 index 000000000000..224c7c26e846 --- /dev/null +++ b/lit/SymbolFile/NativePDB/ast-types.cpp @@ -0,0 +1,131 @@ +// clang-format off +// REQUIRES: lld + +// Test various interesting cases for AST reconstruction. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/ast-types.lldbinit 2>&1 | FileCheck %s + +// Test trivial versions of each tag type. +class TrivialC {}; +struct TrivialS {}; +union TrivialU {}; +enum TrivialE {TE_A}; + +// Test reconstruction of DeclContext hierarchies. +namespace A { + namespace B { + template + struct C { + T ABCMember; + }; + + // Let's try a template specialization with a different implementation + template<> + struct C { + void *ABCSpecializationMember; + }; + } + + // Let's make sure we can distinguish classes and namespaces. Also let's try + // a non-type template parameter. + template + struct C { + class D { + int ACDMember = 0; + C *CPtr = nullptr; + }; + }; + + struct D { + // Let's make a nested class with the same name as another nested class + // elsewhere, and confirm that they appear in the right DeclContexts in + // the AST. + struct E { + int ADDMember; + }; + }; +} + + +// Let's try an anonymous namespace. +namespace { + template + struct Anonymous { + int AnonymousMember; + // And a nested class within an anonymous namespace + struct D { + int AnonymousDMember; + }; + }; +} + +TrivialC TC; +TrivialS TS; +TrivialU TU; +TrivialE TE; + +A::B::C ABCInt; +A::B::C ABCFloat; +A::B::C ABCVoid; + +A::C<0> AC0; +A::C<-1> ACNeg1; + +A::C<0>::D AC0D; +A::C<-1>::D ACNeg1D; +A::D AD; +A::D::E ADE; + +// FIXME: Anonymous namespaces aren't working correctly. +Anonymous AnonInt; +Anonymous> AnonABCVoid; +Anonymous>::D AnonABCVoidD; + +// FIXME: Enum size isn't being correctly determined. +// FIXME: Can't read memory for variable values. + +// CHECK: (TrivialC) TC = {} +// CHECK: (TrivialS) TS = {} +// CHECK: (TrivialU) TU = {} +// CHECK: (TrivialE) TE = TE_A +// CHECK: (A::B::C) ABCInt = (ABCMember = 0) +// CHECK: (A::B::C) ABCFloat = (ABCMember = 0) +// CHECK: (A::B::C) ABCVoid = (ABCSpecializationMember = 0x{{0+}}) +// CHECK: (A::C<0>) AC0 = {} +// CHECK: (A::C<-1>) ACNeg1 = {} +// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x{{0+}}) +// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x{{0+}}) +// CHECK: (A::D) AD = {} +// CHECK: (A::D::E) ADE = (ADDMember = 0) +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} class TrivialC definition +// CHECK: |-CXXRecordDecl {{.*}} struct TrivialS definition +// CHECK: |-CXXRecordDecl {{.*}} union TrivialU definition +// CHECK: |-EnumDecl {{.*}} TrivialE +// CHECK: | `-EnumConstantDecl {{.*}} TE_A 'TrivialE' +// CHECK: |-NamespaceDecl {{.*}} A +// CHECK: | |-NamespaceDecl {{.*}} B +// CHECK: | | |-CXXRecordDecl {{.*}} struct C definition +// CHECK: | | | `-FieldDecl {{.*}} ABCMember 'int' +// CHECK: | | |-CXXRecordDecl {{.*}} struct C definition +// CHECK: | | | `-FieldDecl {{.*}} ABCMember 'float' +// CHECK: | | `-CXXRecordDecl {{.*}} struct C definition +// CHECK: | | `-FieldDecl {{.*}} ABCSpecializationMember 'void *' +// CHECK: | |-CXXRecordDecl {{.*}} struct C<0> definition +// CHECK: | | `-CXXRecordDecl {{.*}} class D definition +// CHECK: | | |-FieldDecl {{.*}} ACDMember 'int' +// CHECK: | | `-FieldDecl {{.*}} CPtr 'A::C<-1> *' +// CHECK: | |-CXXRecordDecl {{.*}} struct C<-1> definition +// CHECK: | | `-CXXRecordDecl {{.*}} class D definition +// CHECK: | | |-FieldDecl {{.*}} ACDMember 'int' +// CHECK: | | `-FieldDecl {{.*}} CPtr 'A::C<-2> *' +// CHECK: | |-CXXRecordDecl {{.*}} struct C<-2> +// CHECK: | `-CXXRecordDecl {{.*}} struct D definition +// CHECK: | `-CXXRecordDecl {{.*}} struct E definition +// CHECK: | `-FieldDecl {{.*}} ADDMember 'int' + +int main(int argc, char **argv) { + return 0; +} diff --git a/lit/SymbolFile/NativePDB/bitfields.cpp b/lit/SymbolFile/NativePDB/bitfields.cpp new file mode 100644 index 000000000000..301ae3067d13 --- /dev/null +++ b/lit/SymbolFile/NativePDB/bitfields.cpp @@ -0,0 +1,60 @@ +// clang-format off +// REQUIRES: lld + +// Test various interesting cases for AST reconstruction. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/bitfields.lldbinit 2>&1 | FileCheck %s + +// Test trivial versions of each tag type. +struct Struct { + int A : 5 = 6; + int B : 7 = 8; + unsigned C : 3 = 2; + unsigned D : 15 = 12345; + char E : 1 = 0; + char F : 2 = 1; + char G : 3 = 2; + // H should be at offset 0 of a new byte. + char H : 3 = 3; +}; + +constexpr Struct TheStruct; + + +int main(int argc, char **argv) { + return TheStruct.A; +} + +// CHECK: (lldb) target variable -T TheStruct +// CHECK: (const Struct) TheStruct = { +// CHECK: (int:5) A = 6 +// CHECK: (int:7) B = 8 +// CHECK: (unsigned int:3) C = 2 +// CHECK: (unsigned int:15) D = 12345 +// CHECK: (char:1) E = '\0' +// CHECK: (char:2) F = '\x01' +// CHECK: (char:3) G = '\x02' +// CHECK: (char:3) H = '\x03' +// CHECK: } +// +// CHECK: target modules dump ast +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition +// CHECK: | |-FieldDecl {{.*}} A 'int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 5 +// CHECK: | |-FieldDecl {{.*}} B 'int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 7 +// CHECK: | |-FieldDecl {{.*}} C 'unsigned int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3 +// CHECK: | |-FieldDecl {{.*}} D 'unsigned int' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 15 +// CHECK: | |-FieldDecl {{.*}} E 'char' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1 +// CHECK: | |-FieldDecl {{.*}} F 'char' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 2 +// CHECK: | |-FieldDecl {{.*}} G 'char' +// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3 +// CHECK: | `-FieldDecl {{.*}} H 'char' +// CHECK: | `-IntegerLiteral {{.*}} 'int' 3 diff --git a/lit/SymbolFile/NativePDB/break-by-function.cpp b/lit/SymbolFile/NativePDB/break-by-function.cpp new file mode 100644 index 000000000000..c0c26f7617c9 --- /dev/null +++ b/lit/SymbolFile/NativePDB/break-by-function.cpp @@ -0,0 +1,57 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can set simple breakpoints using PDB on any platform. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/break-by-function.lldbinit | FileCheck %s + +// Use different indentation style for each overload so that the starting +// line is in a different place. + +int OvlGlobalFn(int X) { + return X + 42; +} + +int OvlGlobalFn(int X, int Y) { return X + Y + 42; } + +int OvlGlobalFn(int X, int Y, int Z) +{ + return X + Y + Z + 42; +} + +static int StaticFn(int X) { + return X + 42; +} + +int main(int argc, char **argv) { + // Make sure they don't get optimized out. + // Note the comments here, we want to make sure the line number reported + // for the breakpoint is the first actual line of code. + int Result = OvlGlobalFn(argc) + OvlGlobalFn(argc, argc) + + OvlGlobalFn(argc, argc, argc) + StaticFn(argc); + return Result; +} + + +// CHECK: (lldb) target create "{{.*}}break-by-function.cpp.tmp.exe" +// CHECK: Current executable set to '{{.*}}break-by-function.cpp.tmp.exe' +// CHECK: (lldb) break set -n main +// CHECK: Breakpoint 1: where = break-by-function.cpp.tmp.exe`main + {{[0-9]+}} +// CHECK: (lldb) break set -n OvlGlobalFn +// CHECK: Breakpoint 2: 3 locations. +// CHECK: (lldb) break set -n StaticFn +// CHECK: Breakpoint 3: where = break-by-function.cpp.tmp.exe`StaticFn + {{[0-9]+}} +// CHECK: (lldb) break set -n DoesntExist +// CHECK: Breakpoint 4: no locations (pending). +// CHECK: (lldb) break list +// CHECK: Current breakpoints: +// CHECK: 1: name = 'main', locations = 1 +// CHECK: 1.1: where = break-by-function.cpp.tmp.exe`main + {{[0-9]+}} +// CHECK: 2: name = 'OvlGlobalFn', locations = 3 +// CHECK: 2.1: where = break-by-function.cpp.tmp.exe`OvlGlobalFn + {{[0-9]+}} +// CHECK: 2.2: where = break-by-function.cpp.tmp.exe`OvlGlobalFn +// CHECK: 2.3: where = break-by-function.cpp.tmp.exe`OvlGlobalFn + {{[0-9]+}} +// CHECK: 3: name = 'StaticFn', locations = 1 +// CHECK: 3.1: where = break-by-function.cpp.tmp.exe`StaticFn + {{[0-9]+}} +// CHECK: 4: name = 'DoesntExist', locations = 0 (pending) diff --git a/lit/SymbolFile/NativePDB/break-by-line.cpp b/lit/SymbolFile/NativePDB/break-by-line.cpp new file mode 100644 index 000000000000..ae3269f3719f --- /dev/null +++ b/lit/SymbolFile/NativePDB/break-by-line.cpp @@ -0,0 +1,26 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can set simple breakpoints using PDB on any platform. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/break-by-line.lldbinit | FileCheck %s + +// This is a separate test from break-by-function.cpp because this test is +// sensitive to edits in the source file. + +namespace NS { + int NamespaceFn(int X) { + return X + 42; + } +} + +int main(int argc, char **argv) { + return NS::NamespaceFn(argc); +} + + +// CHECK: (lldb) target create "{{.*}}break-by-line.cpp.tmp.exe" +// CHECK: Current executable set to '{{.*}}break-by-line.cpp.tmp.exe' +// CHECK: (lldb) break set -f break-by-line.cpp -l 14 +// CHECK: Breakpoint 1: where = break-by-line.cpp.tmp.exe`NS::NamespaceFn + {{[0-9]+}} at break-by-line.cpp:14 diff --git a/lit/SymbolFile/NativePDB/disassembly.cpp b/lit/SymbolFile/NativePDB/disassembly.cpp new file mode 100644 index 000000000000..3553f29ce55c --- /dev/null +++ b/lit/SymbolFile/NativePDB/disassembly.cpp @@ -0,0 +1,38 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can show disassembly and source. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/disassembly.lldbinit | FileCheck %s + +// Some context lines before +// the function. + +int foo() { return 42; } + +int main(int argc, char **argv) { + foo(); + return 0; +} + + +// CHECK: (lldb) disassemble --flavor=intel -m -n main +// CHECK: 12 int foo() { return 42; } +// CHECK-NEXT: 13 +// CHECK-NEXT: ** 14 int main(int argc, char **argv) { +// CHECK: disassembly.cpp.tmp.exe`main: +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+0>: sub rsp, 0x38 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+4>: mov dword ptr [rsp + 0x34], 0x0 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+12>: mov qword ptr [rsp + 0x28], rdx +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+17>: mov dword ptr [rsp + 0x24], ecx +// CHECK: ** 15 foo(); +// CHECK: disassembly.cpp.tmp.exe[{{.*}}] <+21>: call {{.*}} ; foo at disassembly.cpp:12 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+26>: xor ecx, ecx +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+28>: mov dword ptr [rsp + 0x20], eax +// CHECK: ** 16 return 0; +// CHECK-NEXT: 17 } +// CHECK-NEXT: 18 +// CHECK: disassembly.cpp.tmp.exe[{{.*}}] <+32>: mov eax, ecx +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+34>: add rsp, 0x38 +// CHECK-NEXT: disassembly.cpp.tmp.exe[{{.*}}] <+38>: ret diff --git a/lit/SymbolFile/NativePDB/function-types-builtins.cpp b/lit/SymbolFile/NativePDB/function-types-builtins.cpp index f07ea282670e..05ad68419938 100644 --- a/lit/SymbolFile/NativePDB/function-types-builtins.cpp +++ b/lit/SymbolFile/NativePDB/function-types-builtins.cpp @@ -11,6 +11,10 @@ // This technique in general allows us to exercise most of LLDB's type // system without a running process. +// Define _fltused, since we're not linking against the MS C runtime, but use +// floats. +extern "C" int _fltused = 0; + template struct MakeResult { static T result() { diff --git a/lit/SymbolFile/NativePDB/function-types-calling-conv.cpp b/lit/SymbolFile/NativePDB/function-types-calling-conv.cpp new file mode 100644 index 000000000000..cd13159d508c --- /dev/null +++ b/lit/SymbolFile/NativePDB/function-types-calling-conv.cpp @@ -0,0 +1,32 @@ +// clang-format off +// REQUIRES: lld + +// RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/function-types-calling-conv.lldbinit | FileCheck %s + + +void __stdcall StdcallFn() {} +void __fastcall FastcallFn() {} +void __thiscall ThiscallFn() {} +void __cdecl CdeclFn() {} +void __vectorcall VectorcallFn() {} + +auto sfn = &StdcallFn; +// CHECK: (void (*)() __attribute__((stdcall))) sfn = {{.*}} + +auto ffn = &FastcallFn; +// CHECK: (void (*)() __attribute__((fastcall))) ffn = {{.*}} + +auto tfn = &ThiscallFn; +// CHECK: (void (*)() __attribute__((thiscall))) tfn = {{.*}} + +auto cfn = &CdeclFn; +// CHECK: (void (*)()) cfn = {{.*}} + +auto vfn = &VectorcallFn; +// CHECK: (void (*)() __attribute__((vectorcall))) vfn = {{.*}} + +int main(int argc, char **argv) { + return 0; +} diff --git a/lit/SymbolFile/NativePDB/function-types-classes.cpp b/lit/SymbolFile/NativePDB/function-types-classes.cpp new file mode 100644 index 000000000000..4a8caa7f8377 --- /dev/null +++ b/lit/SymbolFile/NativePDB/function-types-classes.cpp @@ -0,0 +1,141 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display function signatures with class types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/function-types-classes.lldbinit | FileCheck %s + +// This is just some unimportant helpers needed so that we can get reference and +// rvalue-reference types into return values. +template +struct MakeResult { + static T result() { + return T{}; + } +}; + +template +struct MakeResult { + static T& result() { + static T t; + return t; + } +}; + +template +struct MakeResult { + static T&& result() { + static T t; + return static_cast(t); + } +}; + + +template +R nullary() { return MakeResult::result(); } + +template +R three(A a, B b) { return MakeResult::result(); } + +template +R four(A a, B b, C c) { return MakeResult::result(); } + +struct S {}; +class C {}; +union U {}; +enum E {}; + +namespace A { + namespace B { + // NS::NS + struct S { }; + } + + struct C { + // NS::Struct + struct S {}; + }; +} + +struct B { + struct A { + // Struct::Struct + struct S {}; + }; +}; + +// clang (incorrectly) doesn't emit debug information for outer classes +// unless they are instantiated. They should also be emitted if there +// is an inner class which is instantiated. +A::C ForceInstantiateAC; +B ForceInstantiateB; +B::A ForceInstantiateBA; + +template +struct TC {}; + +// const and volatile modifiers +auto a = &four; +// CHECK: (S (*)(C *, U &, E &&)) a = {{.*}} +auto b = &four; +// CHECK: (E (*)(const S *, const C &, const U &&)) b = {{.*}} +auto c = &four; +// CHECK: (U (*)(volatile E *, volatile S &, volatile C &&)) c = {{.*}} +auto d = &four; +// CHECK: (C (*)(const volatile U *, const volatile E &, const volatile S &&)) d = {{.*}} + +// classes nested in namespaces and inner classes + +auto e = &three; +// CHECK: (A::B::S *(*)(B::A::S *, A::C::S &)) e = {{.*}} +auto f = &three; +// CHECK: (A::C::S &(*)(A::B::S *, B::A::S *)) f = {{.*}} +auto g = &three; +// CHECK: (B::A::S *(*)(A::C::S &, A::B::S *)) g = {{.*}} + +// parameter types that are themselves template instantiations. +auto h = &four, TC, TC>, TC>; +// CHECK: (TC (*)(TC, TC>, TC)) h = {{.*}} + +auto i = &nullary; +// CHECK: (A::B::S (*)()) i = {{.*}} + + +// Make sure we can handle types that don't have complete debug info. +struct Incomplete; +auto incomplete = &three; +// CHECK: (Incomplete *(*)(Incomplete **, const Incomplete *)) incomplete = {{.*}} + +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} class C +// CHECK: |-CXXRecordDecl {{.*}} union U +// CHECK: |-EnumDecl {{.*}} E +// CHECK: |-CXXRecordDecl {{.*}} struct S +// CHECK: |-VarDecl {{.*}} a 'S (*)(C *, U &, E &&)' +// CHECK: |-VarDecl {{.*}} b 'E (*)(const S *, const C &, const U &&)' +// CHECK: |-VarDecl {{.*}} c 'U (*)(volatile E *, volatile S &, volatile C &&)' +// CHECK: |-VarDecl {{.*}} d 'C (*)(const volatile U *, const volatile E &, const volatile S &&)' +// CHECK: |-CXXRecordDecl {{.*}} struct B +// CHECK: | `-CXXRecordDecl {{.*}} struct A +// CHECK: | `-CXXRecordDecl {{.*}} struct S +// CHECK: |-NamespaceDecl {{.*}} A +// CHECK: | |-CXXRecordDecl {{.*}} struct C +// CHECK: | | `-CXXRecordDecl {{.*}} struct S +// CHECK: | `-NamespaceDecl {{.*}} B +// CHECK: | `-CXXRecordDecl {{.*}} struct S +// CHECK: |-VarDecl {{.*}} e 'A::B::S *(*)(B::A::S *, A::C::S &)' +// CHECK: |-VarDecl {{.*}} f 'A::C::S &(*)(A::B::S *, B::A::S *)' +// CHECK: |-VarDecl {{.*}} g 'B::A::S *(*)(A::C::S &, A::B::S *)' +// CHECK: |-CXXRecordDecl {{.*}} struct TC +// CHECK: |-CXXRecordDecl {{.*}} struct TC> +// CHECK: |-CXXRecordDecl {{.*}} struct TC +// CHECK: |-CXXRecordDecl {{.*}} struct TC +// CHECK: |-VarDecl {{.*}} h 'TC (*)(TC, TC>, TC)' +// CHECK: |-VarDecl {{.*}} i 'A::B::S (*)()' +// CHECK: |-CXXRecordDecl {{.*}} struct Incomplete +// CHECK: `-VarDecl {{.*}} incomplete 'Incomplete *(*)(Incomplete **, const Incomplete *)' + +int main(int argc, char **argv) { + return 0; +} diff --git a/lit/SymbolFile/NativePDB/global-classes.cpp b/lit/SymbolFile/NativePDB/global-classes.cpp new file mode 100644 index 000000000000..e45fbfa4eefe --- /dev/null +++ b/lit/SymbolFile/NativePDB/global-classes.cpp @@ -0,0 +1,385 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/globals-classes.lldbinit | FileCheck %s + +enum class EnumType : unsigned { + A = 1, + B = 2 +}; + +class ClassNoPadding { + /* [ 0] */ unsigned char a = 86; + /* [ 1] */ char b = 'a'; + /* [ 2] */ bool c = false; + /* [ 3] */ bool d = true; + /* [ 4] */ short e = -1234; + /* [ 6] */ unsigned short f = 8123; + /* [ 8] */ unsigned int g = 123908; + /* [12] */ int h = -890234; + /* [16] */ unsigned long i = 2908234; + /* [20] */ long j = 7234890; + /* [24] */ float k = 908234.12392; + /* [28] */ EnumType l = EnumType::A; + /* [32] */ double m = 23890.897423; + /* [40] */ unsigned long long n = 23490782; + /* [48] */ long long o = -923409823; + /* [56] */ int p[5] = { 2, 3, 5, 8, 13 }; +}; + +class ClassWithPadding { + /* [ 0] */ char a = '0'; + // char padding[1]; + /* [ 2] */ short b = 50; + /* [ 4] */ char c[2] = { '0', '1' }; + // char padding[2]; + /* [ 8] */ int d = 100; + /* [12] */ char e = '0'; + // char padding[3]; + /* [16] */ int f = 200; + // char padding[4]; + /* [24] */ long long g = 300; + /* [32] */ char h[3] = { '0', '1', '2' }; + // char padding[5]; + /* [40] */ long long i = 400; + /* [48] */ char j[2] = { '0', '1' }; + // char padding[6]; + /* [56] */ long long k = 500; + /* [64] */ char l = '0'; + // char padding[7]; + /* [72] */ long long m = 600; +} ; + +struct EmptyBase {}; + +template +struct BaseClass { + constexpr BaseClass(int N) + : BaseMember(N) {} + + int BaseMember; +}; + +struct DerivedClass : public BaseClass { + constexpr DerivedClass(int Base, int Derived) + : BaseClass(Base), DerivedMember(Derived) {} + + int DerivedMember; +}; + +struct EBO : public EmptyBase { + constexpr EBO(int N) : Member(N) {} + int Member; +}; + +struct PaddedBases : public BaseClass, public BaseClass, BaseClass { + constexpr PaddedBases(char CH, short S, int N, long long D) + : BaseClass(CH), BaseClass(S), BaseClass(N), DerivedMember(D) {} + long long DerivedMember; +}; + +struct Statics { + static char a; + static bool b; + static short c; + static unsigned short d; + static unsigned int e; + static int f; + static unsigned long g; + static long h; + static float i; + static EnumType j; + static double k; + static unsigned long long l; + static long long m; +}; + +char Statics::a = 'a'; +bool Statics::b = true; +short Statics::c = 1234; +unsigned short Statics::d = 2345; +unsigned int Statics::e = 3456; +int Statics::f = 4567; +unsigned long Statics::g = 5678; +long Statics::h = 6789; +float Statics::i = 7890.1234; +EnumType Statics::j = EnumType::A; +double Statics::k = 8901.2345; +unsigned long long Statics::l = 9012345; +long long Statics::m = 1234567; + + +struct Pointers { + void *a = nullptr; + char *b = &Statics::a; + bool *c = &Statics::b; + short *e = &Statics::c; + unsigned short *f = &Statics::d; + unsigned int *g = &Statics::e; + int *h = &Statics::f; + unsigned long *i = &Statics::g; + long *j = &Statics::h; + float *k = &Statics::i; + EnumType *l = &Statics::j; + double *m = &Statics::k; + unsigned long long *n = &Statics::l; + long long *o = &Statics::m; +}; + +struct References { + char &a = Statics::a; + bool &b = Statics::b; + short &c = Statics::c; + unsigned short &d = Statics::d; + unsigned int &e = Statics::e; + int &f = Statics::f; + unsigned long &g = Statics::g; + long &h = Statics::h; + float &i = Statics::i; + EnumType &j = Statics::j; + double &k = Statics::k; + unsigned long long &l = Statics::l; + long long &m = Statics::m; +}; + + +constexpr ClassWithPadding ClassWithPaddingInstance; +// CHECK: (lldb) target variable -T ClassWithPaddingInstance +// CHECK-NEXT: (const ClassWithPadding) ClassWithPaddingInstance = { +// CHECK-NEXT: (char) a = '0' +// CHECK-NEXT: (short) b = 50 +// CHECK-NEXT: (char [2]) c = "01" +// CHECK-NEXT: (int) d = 100 +// CHECK-NEXT: (char) e = '0' +// CHECK-NEXT: (int) f = 200 +// CHECK-NEXT: (long long) g = 300 +// CHECK-NEXT: (char [3]) h = "012" +// CHECK-NEXT: (long long) i = 400 +// CHECK-NEXT: (char [2]) j = "01" +// CHECK-NEXT: (long long) k = 500 +// CHECK-NEXT: (char) l = '0' +// CHECK-NEXT: (long long) m = 600 +// CHECK-NEXT: } + +constexpr ClassNoPadding ClassNoPaddingInstance; +// CHECK: (lldb) target variable -T ClassNoPaddingInstance +// CHECK-NEXT: (const ClassNoPadding) ClassNoPaddingInstance = { +// CHECK-NEXT: (unsigned char) a = 'V' +// CHECK-NEXT: (char) b = 'a' +// CHECK-NEXT: (bool) c = false +// CHECK-NEXT: (bool) d = true +// CHECK-NEXT: (short) e = -1234 +// CHECK-NEXT: (unsigned short) f = 8123 +// CHECK-NEXT: (unsigned int) g = 123908 +// CHECK-NEXT: (int) h = -890234 +// CHECK-NEXT: (unsigned long) i = 2908234 +// CHECK-NEXT: (long) j = 7234890 +// CHECK-NEXT: (float) k = 908234.125 +// CHECK-NEXT: (EnumType) l = A +// CHECK-NEXT: (double) m = 23890.897422999999 +// CHECK-NEXT: (unsigned long long) n = 23490782 +// CHECK-NEXT: (long long) o = -923409823 +// CHECK-NEXT: (int [5]) p = { +// CHECK-NEXT: (int) [0] = 2 +// CHECK-NEXT: (int) [1] = 3 +// CHECK-NEXT: (int) [2] = 5 +// CHECK-NEXT: (int) [3] = 8 +// CHECK-NEXT: (int) [4] = 13 +// CHECK-NEXT: } +// CHECK-NEXT: } + +constexpr DerivedClass DC(10, 20); +// CHECK: (lldb) target variable -T DC +// CHECK-NEXT: (const DerivedClass) DC = { +// CHECK-NEXT: (BaseClass) BaseClass = { +// CHECK-NEXT: (int) BaseMember = 10 +// CHECK-NEXT: } +// CHECK-NEXT: (int) DerivedMember = 20 +// CHECK-NEXT: } + +constexpr EBO EBOC(20); +// CHECK: (lldb) target variable -T EBOC +// CHECK-NEXT: (const EBO) EBOC = { +// CHECK-NEXT: (int) Member = 20 +// CHECK-NEXT: } + +constexpr PaddedBases PBC('a', 12, 120, 1200); +// CHECK: (lldb) target variable -T PBC +// CHECK-NEXT: (const PaddedBases) PBC = { +// CHECK-NEXT: (BaseClass) BaseClass = { +// CHECK-NEXT: (int) BaseMember = 97 +// CHECK-NEXT: } +// CHECK-NEXT: (BaseClass) BaseClass = { +// CHECK-NEXT: (int) BaseMember = 12 +// CHECK-NEXT: } +// CHECK-NEXT: (BaseClass) BaseClass = { +// CHECK-NEXT: (int) BaseMember = 120 +// CHECK-NEXT: } +// CHECK-NEXT: (long long) DerivedMember = 1200 +// CHECK-NEXT: } + +constexpr struct { + int x = 12; + EBO EBOC{ 42 }; +} UnnamedClassInstance; +// CHECK: (lldb) target variable -T UnnamedClassInstance +// CHECK-NEXT: (const ) UnnamedClassInstance = { +// CHECK-NEXT: (int) x = 12 +// CHECK-NEXT: (EBO) EBOC = { +// CHECK-NEXT: (int) Member = 42 +// CHECK-NEXT: } +// CHECK-NEXT: } + +constexpr Pointers PointersInstance; +// CHECK: (lldb) target variable -T PointersInstance +// CHECK-NEXT: (const Pointers) PointersInstance = { +// CHECK-NEXT: (void *) a = {{.*}} +// CHECK-NEXT: (char *) b = {{.*}} +// CHECK-NEXT: (bool *) c = {{.*}} +// CHECK-NEXT: (short *) e = {{.*}} +// CHECK-NEXT: (unsigned short *) f = {{.*}} +// CHECK-NEXT: (unsigned int *) g = {{.*}} +// CHECK-NEXT: (int *) h = {{.*}} +// CHECK-NEXT: (unsigned long *) i = {{.*}} +// CHECK-NEXT: (long *) j = {{.*}} +// CHECK-NEXT: (float *) k = {{.*}} +// CHECK-NEXT: (EnumType *) l = {{.*}} +// CHECK-NEXT: (double *) m = {{.*}} +// CHECK-NEXT: (unsigned long long *) n = {{.*}} +// CHECK-NEXT: (long long *) o = {{.*}} +// CHECK-NEXT: } +constexpr References ReferencesInstance; +// CHECK: (lldb) target variable -T ReferencesInstance +// CHECK-NEXT: (const References) ReferencesInstance = { +// CHECK-NEXT: (char &) a = {{.*}} +// CHECK-NEXT: (bool &) b = {{.*}} +// CHECK-NEXT: (short &) c = {{.*}} +// CHECK-NEXT: (unsigned short &) d = {{.*}} +// CHECK-NEXT: (unsigned int &) e = {{.*}} +// CHECK-NEXT: (int &) f = {{.*}} +// CHECK-NEXT: (unsigned long &) g = {{.*}} +// CHECK-NEXT: (long &) h = {{.*}} +// CHECK-NEXT: (float &) i = {{.*}} +// CHECK-NEXT: (EnumType &) j = {{.*}} +// CHECK-NEXT: (double &) k = {{.*}} +// CHECK-NEXT: (unsigned long long &) l = {{.*}} +// CHECK-NEXT: (long long &) m = {{.*}} +// CHECK-NEXT: } + +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} class ClassWithPadding definition +// CHECK: | |-FieldDecl {{.*}} a 'char' +// CHECK: | |-FieldDecl {{.*}} b 'short' +// CHECK: | |-FieldDecl {{.*}} c 'char [2]' +// CHECK: | |-FieldDecl {{.*}} d 'int' +// CHECK: | |-FieldDecl {{.*}} e 'char' +// CHECK: | |-FieldDecl {{.*}} f 'int' +// CHECK: | |-FieldDecl {{.*}} g 'long long' +// CHECK: | |-FieldDecl {{.*}} h 'char [3]' +// CHECK: | |-FieldDecl {{.*}} i 'long long' +// CHECK: | |-FieldDecl {{.*}} j 'char [2]' +// CHECK: | |-FieldDecl {{.*}} k 'long long' +// CHECK: | |-FieldDecl {{.*}} l 'char' +// CHECK: | `-FieldDecl {{.*}} m 'long long' +// CHECK: |-VarDecl {{.*}} ClassWithPaddingInstance 'const ClassWithPadding' +// CHECK: |-CXXRecordDecl {{.*}} class ClassNoPadding definition +// CHECK: | |-FieldDecl {{.*}} a 'unsigned char' +// CHECK: | |-FieldDecl {{.*}} b 'char' +// CHECK: | |-FieldDecl {{.*}} c 'bool' +// CHECK: | |-FieldDecl {{.*}} d 'bool' +// CHECK: | |-FieldDecl {{.*}} e 'short' +// CHECK: | |-FieldDecl {{.*}} f 'unsigned short' +// CHECK: | |-FieldDecl {{.*}} g 'unsigned int' +// CHECK: | |-FieldDecl {{.*}} h 'int' +// CHECK: | |-FieldDecl {{.*}} i 'unsigned long' +// CHECK: | |-FieldDecl {{.*}} j 'long' +// CHECK: | |-FieldDecl {{.*}} k 'float' +// CHECK: | |-FieldDecl {{.*}} l 'EnumType' +// CHECK: | |-FieldDecl {{.*}} m 'double' +// CHECK: | |-FieldDecl {{.*}} n 'unsigned long long' +// CHECK: | |-FieldDecl {{.*}} o 'long long' +// CHECK: | `-FieldDecl {{.*}} p 'int [5]' +// CHECK: |-VarDecl {{.*}} ClassNoPaddingInstance 'const ClassNoPadding' +// CHECK: |-EnumDecl {{.*}} EnumType +// CHECK: | |-EnumConstantDecl {{.*}} A 'EnumType' +// CHECK: | `-EnumConstantDecl {{.*}} B 'EnumType' +// CHECK: |-CXXRecordDecl {{.*}} struct DerivedClass definition +// CHECK: | |-public 'BaseClass' +// CHECK: | |-FieldDecl {{.*}} DerivedMember 'int' +// CHECK: | `-CXXConstructorDecl {{.*}} DerivedClass 'void (int, int)' +// CHECK: | |-ParmVarDecl {{.*}} 'int' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-VarDecl {{.*}} DC 'const DerivedClass' +// CHECK: |-CXXRecordDecl {{.*}} struct BaseClass definition +// CHECK: | |-FieldDecl {{.*}} BaseMember 'int' +// CHECK: | `-CXXMethodDecl {{.*}} BaseClass 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct EBO definition +// CHECK: | |-public 'EmptyBase' +// CHECK: | |-FieldDecl {{.*}} Member 'int' +// CHECK: | `-CXXConstructorDecl {{.*}} EBO 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-VarDecl {{.*}} EBOC 'const EBO' +// CHECK: |-CXXRecordDecl {{.*}} struct EmptyBase definition +// CHECK: |-CXXRecordDecl {{.*}} struct PaddedBases definition +// CHECK: | |-public 'BaseClass' +// CHECK: | |-public 'BaseClass' +// CHECK: | |-public 'BaseClass' +// CHECK: | |-FieldDecl {{.*}} DerivedMember 'long long' +// CHECK: | `-CXXConstructorDecl {{.*}} PaddedBases 'void (char, short, int, long long)' +// CHECK: | |-ParmVarDecl {{.*}} 'char' +// CHECK: | |-ParmVarDecl {{.*}} 'short' +// CHECK: | |-ParmVarDecl {{.*}} 'int' +// CHECK: | `-ParmVarDecl {{.*}} 'long long' +// CHECK: |-VarDecl {{.*}} PBC 'const PaddedBases' +// CHECK: |-CXXRecordDecl {{.*}} struct BaseClass definition +// CHECK: | |-FieldDecl {{.*}} BaseMember 'int' +// CHECK: | `-CXXMethodDecl {{.*}} BaseClass 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct BaseClass definition +// CHECK: | |-FieldDecl {{.*}} BaseMember 'int' +// CHECK: | `-CXXMethodDecl {{.*}} BaseClass 'void (int)' +// CHECK: | `-ParmVarDecl {{.*}} 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct definition +// CHECK: | |-FieldDecl {{.*}} x 'int' +// CHECK: | `-FieldDecl {{.*}} EBOC 'EBO' +// CHECK: |-VarDecl {{.*}} UnnamedClassInstance 'const ' +// CHECK: |-CXXRecordDecl {{.*}} struct Pointers definition +// CHECK: | |-FieldDecl {{.*}} a 'void *' +// CHECK: | |-FieldDecl {{.*}} b 'char *' +// CHECK: | |-FieldDecl {{.*}} c 'bool *' +// CHECK: | |-FieldDecl {{.*}} e 'short *' +// CHECK: | |-FieldDecl {{.*}} f 'unsigned short *' +// CHECK: | |-FieldDecl {{.*}} g 'unsigned int *' +// CHECK: | |-FieldDecl {{.*}} h 'int *' +// CHECK: | |-FieldDecl {{.*}} i 'unsigned long *' +// CHECK: | |-FieldDecl {{.*}} j 'long *' +// CHECK: | |-FieldDecl {{.*}} k 'float *' +// CHECK: | |-FieldDecl {{.*}} l 'EnumType *' +// CHECK: | |-FieldDecl {{.*}} m 'double *' +// CHECK: | |-FieldDecl {{.*}} n 'unsigned long long *' +// CHECK: | `-FieldDecl {{.*}} o 'long long *' +// CHECK: |-VarDecl {{.*}} PointersInstance 'const Pointers' +// CHECK: |-CXXRecordDecl {{.*}} struct References definition +// CHECK: | |-FieldDecl {{.*}} a 'char &' +// CHECK: | |-FieldDecl {{.*}} b 'bool &' +// CHECK: | |-FieldDecl {{.*}} c 'short &' +// CHECK: | |-FieldDecl {{.*}} d 'unsigned short &' +// CHECK: | |-FieldDecl {{.*}} e 'unsigned int &' +// CHECK: | |-FieldDecl {{.*}} f 'int &' +// CHECK: | |-FieldDecl {{.*}} g 'unsigned long &' +// CHECK: | |-FieldDecl {{.*}} h 'long &' +// CHECK: | |-FieldDecl {{.*}} i 'float &' +// CHECK: | |-FieldDecl {{.*}} j 'EnumType &' +// CHECK: | |-FieldDecl {{.*}} k 'double &' +// CHECK: | |-FieldDecl {{.*}} l 'unsigned long long &' +// CHECK: | `-FieldDecl {{.*}} m 'long long &' +// CHECK: `-VarDecl {{.*}} ReferencesInstance 'const References' + +int main(int argc, char **argv) { + return 0; +} diff --git a/lit/SymbolFile/NativePDB/globals-bss.cpp b/lit/SymbolFile/NativePDB/globals-bss.cpp new file mode 100644 index 000000000000..c10c3c196286 --- /dev/null +++ b/lit/SymbolFile/NativePDB/globals-bss.cpp @@ -0,0 +1,34 @@ +// clang-format off +// REQUIRES: lld + +// Make sure we can read variables from BSS +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: llvm-readobj -s %t.exe | FileCheck --check-prefix=BSS %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/globals-bss.lldbinit 2>&1 | FileCheck %s + +int GlobalVariable = 0; + +int main(int argc, char **argv) { + return 0; +} + +// BSS: Section { +// BSS: Number: 3 +// BSS: Name: .data +// BSS-NEXT: VirtualSize: 0x4 +// BSS-NEXT: VirtualAddress: +// BSS-NEXT: RawDataSize: 0 +// BSS-NEXT: PointerToRawData: 0x0 +// BSS-NEXT: PointerToRelocations: 0x0 +// BSS-NEXT: PointerToLineNumbers: 0x0 +// BSS-NEXT: RelocationCount: 0 +// BSS-NEXT: LineNumberCount: 0 +// BSS-NEXT: Characteristics [ (0xC0000040) +// BSS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40) +// BSS-NEXT: IMAGE_SCN_MEM_READ (0x40000000) +// BSS-NEXT: IMAGE_SCN_MEM_WRITE (0x80000000) +// BSS-NEXT: ] +// BSS-NEXT: } + +// CHECK: (int) GlobalVariable = 0 diff --git a/lit/SymbolFile/NativePDB/globals-fundamental.cpp b/lit/SymbolFile/NativePDB/globals-fundamental.cpp new file mode 100644 index 000000000000..48dea6d51e48 --- /dev/null +++ b/lit/SymbolFile/NativePDB/globals-fundamental.cpp @@ -0,0 +1,879 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/globals-fundamental.lldbinit | FileCheck %s + + +// Fundamental data types +bool BFalse = false; +// CHECK: (lldb) target variable BFalse +// CHECK-NEXT: (bool) BFalse = false +bool BTrue = true; +// CHECK-NEXT: (lldb) target variable BTrue +// CHECK-NEXT: (bool) BTrue = true +char CA = 'A'; +// CHECK-NEXT: (lldb) target variable CA +// CHECK-NEXT: (char) CA = 'A' +char CZ = 'Z'; +// CHECK-NEXT: (lldb) target variable CZ +// CHECK-NEXT: (char) CZ = 'Z' +signed char SCa = 'a'; +// CHECK-NEXT: (lldb) target variable SCa +// CHECK-NEXT: (signed char) SCa = 'a' +signed char SCz = 'z'; +// CHECK-NEXT: (lldb) target variable SCz +// CHECK-NEXT: (signed char) SCz = 'z' +unsigned char UC24 = 24; +// CHECK-NEXT: (lldb) target variable UC24 +// CHECK-NEXT: (unsigned char) UC24 = '\x18' +unsigned char UC42 = 42; +// CHECK-NEXT: (lldb) target variable UC42 +// CHECK-NEXT: (unsigned char) UC42 = '*' +char16_t C16_24 = u'\24'; +// CHECK-NEXT: (lldb) target variable C16_24 +// CHECK-NEXT: (char16_t) C16_24 = U+0014 +char32_t C32_42 = U'\42'; +// CHECK-NEXT: (lldb) target variable C32_42 +// CHECK-NEXT: (char32_t) C32_42 = U+0x00000022 +wchar_t WC1 = L'1'; +// CHECK-NEXT: (lldb) target variable WC1 +// CHECK-NEXT: (wchar_t) WC1 = L'1' +wchar_t WCP = L'P'; +// CHECK-NEXT: (lldb) target variable WCP +// CHECK-NEXT: (wchar_t) WCP = L'P' +short SMax = 32767; +// CHECK-NEXT: (lldb) target variable SMax +// CHECK-NEXT: (short) SMax = 32767 +short SMin = -32768; +// CHECK-NEXT: (lldb) target variable SMin +// CHECK-NEXT: (short) SMin = -32768 +unsigned short USMax = 65535; +// CHECK-NEXT: (lldb) target variable USMax +// CHECK-NEXT: (unsigned short) USMax = 65535 +unsigned short USMin = 0; +// CHECK-NEXT: (lldb) target variable USMin +// CHECK-NEXT: (unsigned short) USMin = 0 +int IMax = 2147483647; +// CHECK-NEXT: (lldb) target variable IMax +// CHECK-NEXT: (int) IMax = 2147483647 +int IMin = -2147483648; +// CHECK-NEXT: (lldb) target variable IMin +// CHECK-NEXT: (int) IMin = -2147483648 +unsigned int UIMax = 4294967295; +// CHECK-NEXT: (lldb) target variable UIMax +// CHECK-NEXT: (unsigned int) UIMax = 4294967295 +unsigned int UIMin = 0; +// CHECK-NEXT: (lldb) target variable UIMin +// CHECK-NEXT: (unsigned int) UIMin = 0 +long LMax = 2147483647; +// CHECK-NEXT: (lldb) target variable LMax +// CHECK-NEXT: (long) LMax = 2147483647 +long LMin = -2147483648; +// CHECK-NEXT: (lldb) target variable LMin +// CHECK-NEXT: (long) LMin = -2147483648 +unsigned long ULMax = 4294967295; +// CHECK-NEXT: (lldb) target variable ULMax +// CHECK-NEXT: (unsigned long) ULMax = 4294967295 +unsigned long ULMin = 0; +// CHECK-NEXT: (lldb) target variable ULMin +// CHECK-NEXT: (unsigned long) ULMin = 0 +long long LLMax = 9223372036854775807LL; +// CHECK-NEXT: (lldb) target variable LLMax +// CHECK-NEXT: (long long) LLMax = 9223372036854775807 +long long LLMin = -9223372036854775807i64 - 1; +// CHECK-NEXT: (lldb) target variable LLMin +// CHECK-NEXT: (long long) LLMin = -9223372036854775808 +unsigned long long ULLMax = 18446744073709551615ULL; +// CHECK-NEXT: (lldb) target variable ULLMax +// CHECK-NEXT: (unsigned long long) ULLMax = 18446744073709551615 +unsigned long long ULLMin = 0; +// CHECK-NEXT: (lldb) target variable ULLMin +// CHECK-NEXT: (unsigned long long) ULLMin = 0 +float F = 3.1415f; +// CHECK-NEXT: (lldb) target variable F +// CHECK-NEXT: (float) F = 3.1415 +double D = 3.1415; +// CHECK-NEXT: (lldb) target variable D +// CHECK-NEXT: (double) D = 3.1415 + +const bool CBFalse = false; +// CHECK-NEXT: (lldb) target variable CBFalse +// CHECK-NEXT: (const bool) CBFalse = false +const bool CBTrue = true; +// CHECK-NEXT: (lldb) target variable CBTrue +// CHECK-NEXT: (const bool) CBTrue = true +const char CCA = 'A'; +// CHECK-NEXT: (lldb) target variable CCA +// CHECK-NEXT: (const char) CCA = 'A' +const char CCZ = 'Z'; +// CHECK-NEXT: (lldb) target variable CCZ +// CHECK-NEXT: (const char) CCZ = 'Z' +const signed char CSCa = 'a'; +// CHECK-NEXT: (lldb) target variable CSCa +// CHECK-NEXT: (const signed char) CSCa = 'a' +const signed char CSCz = 'z'; +// CHECK-NEXT: (lldb) target variable CSCz +// CHECK-NEXT: (const signed char) CSCz = 'z' +const unsigned char CUC24 = 24; +// CHECK-NEXT: (lldb) target variable CUC24 +// CHECK-NEXT: (const unsigned char) CUC24 = '\x18' +const unsigned char CUC42 = 42; +// CHECK-NEXT: (lldb) target variable CUC42 +// CHECK-NEXT: (const unsigned char) CUC42 = '*' +const char16_t CC16_24 = u'\24'; +// CHECK-NEXT: (lldb) target variable CC16_24 +// CHECK-NEXT: (const char16_t) CC16_24 = U+0014 +const char32_t CC32_42 = U'\42'; +// CHECK-NEXT: (lldb) target variable CC32_42 +// CHECK-NEXT: (const char32_t) CC32_42 = U+0x00000022 +const wchar_t CWC1 = L'1'; +// CHECK-NEXT: (lldb) target variable CWC1 +// CHECK-NEXT: (const wchar_t) CWC1 = L'1' +const wchar_t CWCP = L'P'; +// CHECK-NEXT: (lldb) target variable CWCP +// CHECK-NEXT: (const wchar_t) CWCP = L'P' +const short CSMax = 32767; +// CHECK-NEXT: (lldb) target variable CSMax +// CHECK-NEXT: (const short) CSMax = 32767 +const short CSMin = -32768; +// CHECK-NEXT: (lldb) target variable CSMin +// CHECK-NEXT: (const short) CSMin = -32768 +const unsigned short CUSMax = 65535; +// CHECK-NEXT: (lldb) target variable CUSMax +// CHECK-NEXT: (const unsigned short) CUSMax = 65535 +const unsigned short CUSMin = 0; +// CHECK-NEXT: (lldb) target variable CUSMin +// CHECK-NEXT: (const unsigned short) CUSMin = 0 +const int CIMax = 2147483647; +// CHECK-NEXT: (lldb) target variable CIMax +// CHECK-NEXT: (const int) CIMax = 2147483647 +const int CIMin = -2147483648; +// CHECK-NEXT: (lldb) target variable CIMin +// CHECK-NEXT: (const int) CIMin = -2147483648 +const unsigned int CUIMax = 4294967295; +// CHECK-NEXT: (lldb) target variable CUIMax +// CHECK-NEXT: (const unsigned int) CUIMax = 4294967295 +const unsigned int CUIMin = 0; +// CHECK-NEXT: (lldb) target variable CUIMin +// CHECK-NEXT: (const unsigned int) CUIMin = 0 +const long CLMax = 2147483647; +// CHECK-NEXT: (lldb) target variable CLMax +// CHECK-NEXT: (const long) CLMax = 2147483647 +const long CLMin = -2147483648; +// CHECK-NEXT: (lldb) target variable CLMin +// CHECK-NEXT: (const long) CLMin = -2147483648 +const unsigned long CULMax = 4294967295; +// CHECK-NEXT: (lldb) target variable CULMax +// CHECK-NEXT: (const unsigned long) CULMax = 4294967295 +const unsigned long CULMin = 0; +// CHECK-NEXT: (lldb) target variable CULMin +// CHECK-NEXT: (const unsigned long) CULMin = 0 +const long long CLLMax = 9223372036854775807i64; +// CHECK-NEXT: (lldb) target variable CLLMax +// CHECK-NEXT: (const long long) CLLMax = 9223372036854775807 +const long long CLLMin = -9223372036854775807i64 - 1; +// CHECK-NEXT: (lldb) target variable CLLMin +// CHECK-NEXT: (const long long) CLLMin = -9223372036854775808 +const unsigned long long CULLMax = 18446744073709551615ULL; +// CHECK-NEXT: (lldb) target variable CULLMax +// CHECK-NEXT: (const unsigned long long) CULLMax = 18446744073709551615 +const unsigned long long CULLMin = 0; +// CHECK-NEXT: (lldb) target variable CULLMin +// CHECK-NEXT: (const unsigned long long) CULLMin = 0 +const float CF = 3.1415f; +// CHECK-NEXT: (lldb) target variable CF +// CHECK-NEXT: (const float) CF = 3.1415 +const double CD = 3.1415; +// CHECK-NEXT: (lldb) target variable CD +// CHECK-NEXT: (const double) CD = 3.1415 + +// constexpr fundamental data types. +constexpr bool ConstexprBFalse = false; +// CHECK-NEXT: (lldb) target variable ConstexprBFalse +// CHECK-NEXT: (const bool) ConstexprBFalse = false +constexpr bool ConstexprBTrue = true; +// CHECK-NEXT: (lldb) target variable ConstexprBTrue +// CHECK-NEXT: (const bool) ConstexprBTrue = true +constexpr char ConstexprCA = 'A'; +// CHECK-NEXT: (lldb) target variable ConstexprCA +// CHECK-NEXT: (const char) ConstexprCA = 'A' +constexpr char ConstexprCZ = 'Z'; +// CHECK-NEXT: (lldb) target variable ConstexprCZ +// CHECK-NEXT: (const char) ConstexprCZ = 'Z' +constexpr signed char ConstexprSCa = 'a'; +// CHECK-NEXT: (lldb) target variable ConstexprSCa +// CHECK-NEXT: (const signed char) ConstexprSCa = 'a' +constexpr signed char ConstexprSCz = 'z'; +// CHECK-NEXT: (lldb) target variable ConstexprSCz +// CHECK-NEXT: (const signed char) ConstexprSCz = 'z' +constexpr unsigned char ConstexprUC24 = 24; +// CHECK-NEXT: (lldb) target variable ConstexprUC24 +// CHECK-NEXT: (const unsigned char) ConstexprUC24 = '\x18' +constexpr unsigned char ConstexprUC42 = 42; +// CHECK-NEXT: (lldb) target variable ConstexprUC42 +// CHECK-NEXT: (const unsigned char) ConstexprUC42 = '*' +constexpr char16_t ConstexprC16_24 = u'\24'; +// CHECK-NEXT: (lldb) target variable ConstexprC16_24 +// CHECK-NEXT: (const char16_t) ConstexprC16_24 = U+0014 +constexpr char32_t ConstexprC32_42 = U'\42'; +// CHECK-NEXT: (lldb) target variable ConstexprC32_42 +// CHECK-NEXT: (const char32_t) ConstexprC32_42 = U+0x00000022 +constexpr wchar_t ConstexprWC1 = L'1'; +// CHECK-NEXT: (lldb) target variable ConstexprWC1 +// CHECK-NEXT: (const wchar_t) ConstexprWC1 = L'1' +constexpr wchar_t ConstexprWCP = L'P'; +// CHECK-NEXT: (lldb) target variable ConstexprWCP +// CHECK-NEXT: (const wchar_t) ConstexprWCP = L'P' +constexpr short ConstexprSMax = 32767; +// CHECK-NEXT: (lldb) target variable ConstexprSMax +// CHECK-NEXT: (const short) ConstexprSMax = 32767 +constexpr short ConstexprSMin = -32768; +// CHECK-NEXT: (lldb) target variable ConstexprSMin +// CHECK-NEXT: (const short) ConstexprSMin = -32768 +constexpr unsigned short ConstexprUSMax = 65535; +// CHECK-NEXT: (lldb) target variable ConstexprUSMax +// CHECK-NEXT: (const unsigned short) ConstexprUSMax = 65535 +constexpr unsigned short ConstexprUSMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprUSMin +// CHECK-NEXT: (const unsigned short) ConstexprUSMin = 0 +constexpr int ConstexprIMax = 2147483647; +// CHECK-NEXT: (lldb) target variable ConstexprIMax +// CHECK-NEXT: (const int) ConstexprIMax = 2147483647 +constexpr int ConstexprIMin = -2147483648; +// CHECK-NEXT: (lldb) target variable ConstexprIMin +// CHECK-NEXT: (const int) ConstexprIMin = -2147483648 +constexpr unsigned int ConstexprUIMax = 4294967295; +// CHECK-NEXT: (lldb) target variable ConstexprUIMax +// CHECK-NEXT: (const unsigned int) ConstexprUIMax = 4294967295 +constexpr unsigned int ConstexprUIMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprUIMin +// CHECK-NEXT: (const unsigned int) ConstexprUIMin = 0 +constexpr long ConstexprLMax = 2147483647; +// CHECK-NEXT: (lldb) target variable ConstexprLMax +// CHECK-NEXT: (const long) ConstexprLMax = 2147483647 +constexpr long ConstexprLMin = -2147483648; +// CHECK-NEXT: (lldb) target variable ConstexprLMin +// CHECK-NEXT: (const long) ConstexprLMin = -2147483648 +constexpr unsigned long ConstexprULMax = 4294967295; +// CHECK-NEXT: (lldb) target variable ConstexprULMax +// CHECK-NEXT: (const unsigned long) ConstexprULMax = 4294967295 +constexpr unsigned long ConstexprULMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprULMin +// CHECK-NEXT: (const unsigned long) ConstexprULMin = 0 +constexpr long long ConstexprLLMax = 9223372036854775807i64; +// CHECK-NEXT: (lldb) target variable ConstexprLLMax +// CHECK-NEXT: (const long long) ConstexprLLMax = 9223372036854775807 +constexpr long long ConstexprLLMin = -9223372036854775807i64 - 1; +// CHECK-NEXT: (lldb) target variable ConstexprLLMin +// CHECK-NEXT: (const long long) ConstexprLLMin = -9223372036854775808 +constexpr unsigned long long ConstexprULLMax = 18446744073709551615ULL; +// CHECK-NEXT: (lldb) target variable ConstexprULLMax +// CHECK-NEXT: (const unsigned long long) ConstexprULLMax = 18446744073709551615 +constexpr unsigned long long ConstexprULLMin = 0; +// CHECK-NEXT: (lldb) target variable ConstexprULLMin +// CHECK-NEXT: (const unsigned long long) ConstexprULLMin = 0 +constexpr float ConstexprF = 3.1415f; +// CHECK-NEXT: (lldb) target variable ConstexprF +// CHECK-NEXT: (const float) ConstexprF = 3.1415 +constexpr double ConstexprD = 3.1415; +// CHECK-NEXT: (lldb) target variable ConstexprD +// CHECK-NEXT: (const double) ConstexprD = 3.1415 + + +// FIXME: LLDB currently doesn't resolve pointers within the target without a +// running process (I haven't checked whether or not it can with a running +// process). So currently it will just print an address, which is unstable and +// should not be relied upon for testing. So for now we're just checking that +// the variable name and type is correct. We should fix this in LLDB and then +// update the tests. +bool *PBFalse = &BFalse; +// CHECK-NEXT: (lldb) target variable PBFalse +// CHECK-NEXT: (bool *) PBFalse = {{.*}} +bool *PBTrue = &BTrue; +// CHECK-NEXT: (lldb) target variable PBTrue +// CHECK-NEXT: (bool *) PBTrue = {{.*}} +char *PCA = &CA; +// CHECK-NEXT: (lldb) target variable PCA +// CHECK-NEXT: (char *) PCA = {{.*}} +char *PCZ = &CZ; +// CHECK-NEXT: (lldb) target variable PCZ +// CHECK-NEXT: (char *) PCZ = {{.*}} +signed char *PSCa = &SCa; +// CHECK-NEXT: (lldb) target variable PSCa +// CHECK-NEXT: (signed char *) PSCa = {{.*}} +signed char *PSCz = &SCz; +// CHECK-NEXT: (lldb) target variable PSCz +// CHECK-NEXT: (signed char *) PSCz = {{.*}} +unsigned char *PUC24 = &UC24; +// CHECK-NEXT: (lldb) target variable PUC24 +// CHECK-NEXT: (unsigned char *) PUC24 = {{.*}} +unsigned char *PUC42 = &UC42; +// CHECK-NEXT: (lldb) target variable PUC42 +// CHECK-NEXT: (unsigned char *) PUC42 = {{.*}} +char16_t *PC16_24 = &C16_24; +// CHECK-NEXT: (lldb) target variable PC16_24 +// CHECK-NEXT: (char16_t *) PC16_24 = {{.*}} +char32_t *PC32_42 = &C32_42; +// CHECK-NEXT: (lldb) target variable PC32_42 +// CHECK-NEXT: (char32_t *) PC32_42 = {{.*}} +wchar_t *PWC1 = &WC1; +// CHECK-NEXT: (lldb) target variable PWC1 +// CHECK-NEXT: (wchar_t *) PWC1 = {{.*}} +wchar_t *PWCP = &WCP; +// CHECK-NEXT: (lldb) target variable PWCP +// CHECK-NEXT: (wchar_t *) PWCP = {{.*}} +short *PSMax = &SMax; +// CHECK-NEXT: (lldb) target variable PSMax +// CHECK-NEXT: (short *) PSMax = {{.*}} +short *PSMin = &SMin; +// CHECK-NEXT: (lldb) target variable PSMin +// CHECK-NEXT: (short *) PSMin = {{.*}} +unsigned short *PUSMax = &USMax; +// CHECK-NEXT: (lldb) target variable PUSMax +// CHECK-NEXT: (unsigned short *) PUSMax = {{.*}} +unsigned short *PUSMin = &USMin; +// CHECK-NEXT: (lldb) target variable PUSMin +// CHECK-NEXT: (unsigned short *) PUSMin = {{.*}} +int *PIMax = &IMax; +// CHECK-NEXT: (lldb) target variable PIMax +// CHECK-NEXT: (int *) PIMax = {{.*}} +int *PIMin = &IMin; +// CHECK-NEXT: (lldb) target variable PIMin +// CHECK-NEXT: (int *) PIMin = {{.*}} +unsigned int *PUIMax = &UIMax; +// CHECK-NEXT: (lldb) target variable PUIMax +// CHECK-NEXT: (unsigned int *) PUIMax = {{.*}} +unsigned int *PUIMin = &UIMin; +// CHECK-NEXT: (lldb) target variable PUIMin +// CHECK-NEXT: (unsigned int *) PUIMin = {{.*}} +long *PLMax = &LMax; +// CHECK-NEXT: (lldb) target variable PLMax +// CHECK-NEXT: (long *) PLMax = {{.*}} +long *PLMin = &LMin; +// CHECK-NEXT: (lldb) target variable PLMin +// CHECK-NEXT: (long *) PLMin = {{.*}} +unsigned long *PULMax = &ULMax; +// CHECK-NEXT: (lldb) target variable PULMax +// CHECK-NEXT: (unsigned long *) PULMax = {{.*}} +unsigned long *PULMin = &ULMin; +// CHECK-NEXT: (lldb) target variable PULMin +// CHECK-NEXT: (unsigned long *) PULMin = {{.*}} +long long *PLLMax = &LLMax; +// CHECK-NEXT: (lldb) target variable PLLMax +// CHECK-NEXT: (long long *) PLLMax = {{.*}} +long long *PLLMin = &LLMin; +// CHECK-NEXT: (lldb) target variable PLLMin +// CHECK-NEXT: (long long *) PLLMin = {{.*}} +unsigned long long *PULLMax = &ULLMax; +// CHECK-NEXT: (lldb) target variable PULLMax +// CHECK-NEXT: (unsigned long long *) PULLMax = {{.*}} +unsigned long long *PULLMin = &ULLMin; +// CHECK-NEXT: (lldb) target variable PULLMin +// CHECK-NEXT: (unsigned long long *) PULLMin = {{.*}} +float *PF = &F; +// CHECK-NEXT: (lldb) target variable PF +// CHECK-NEXT: (float *) PF = {{.*}} +double *PD = &D; +// CHECK-NEXT: (lldb) target variable PD +// CHECK-NEXT: (double *) PD = {{.*}} + +// Const pointers to fundamental data types +const bool *CPBFalse = &BFalse; +// CHECK-NEXT: (lldb) target variable CPBFalse +// CHECK-NEXT: (const bool *) CPBFalse = {{.*}} +const bool *CPBTrue = &BTrue; +// CHECK-NEXT: (lldb) target variable CPBTrue +// CHECK-NEXT: (const bool *) CPBTrue = {{.*}} +const char *CPCA = &CA; +// CHECK-NEXT: (lldb) target variable CPCA +// CHECK-NEXT: (const char *) CPCA = {{.*}} +const char *CPCZ = &CZ; +// CHECK-NEXT: (lldb) target variable CPCZ +// CHECK-NEXT: (const char *) CPCZ = {{.*}} +const signed char *CPSCa = &SCa; +// CHECK-NEXT: (lldb) target variable CPSCa +// CHECK-NEXT: (const signed char *) CPSCa = {{.*}} +const signed char *CPSCz = &SCz; +// CHECK-NEXT: (lldb) target variable CPSCz +// CHECK-NEXT: (const signed char *) CPSCz = {{.*}} +const unsigned char *CPUC24 = &UC24; +// CHECK-NEXT: (lldb) target variable CPUC24 +// CHECK-NEXT: (const unsigned char *) CPUC24 = {{.*}} +const unsigned char *CPUC42 = &UC42; +// CHECK-NEXT: (lldb) target variable CPUC42 +// CHECK-NEXT: (const unsigned char *) CPUC42 = {{.*}} +const char16_t *CPC16_24 = &C16_24; +// CHECK-NEXT: (lldb) target variable CPC16_24 +// CHECK-NEXT: (const char16_t *) CPC16_24 = {{.*}} +const char32_t *CPC32_42 = &C32_42; +// CHECK-NEXT: (lldb) target variable CPC32_42 +// CHECK-NEXT: (const char32_t *) CPC32_42 = {{.*}} +const wchar_t *CPWC1 = &WC1; +// CHECK-NEXT: (lldb) target variable CPWC1 +// CHECK-NEXT: (const wchar_t *) CPWC1 = {{.*}} +const wchar_t *CPWCP = &WCP; +// CHECK-NEXT: (lldb) target variable CPWCP +// CHECK-NEXT: (const wchar_t *) CPWCP = {{.*}} +const short *CPSMax = &SMax; +// CHECK-NEXT: (lldb) target variable CPSMax +// CHECK-NEXT: (const short *) CPSMax = {{.*}} +const short *CPSMin = &SMin; +// CHECK-NEXT: (lldb) target variable CPSMin +// CHECK-NEXT: (const short *) CPSMin = {{.*}} +const unsigned short *CPUSMax = &USMax; +// CHECK-NEXT: (lldb) target variable CPUSMax +// CHECK-NEXT: (const unsigned short *) CPUSMax = {{.*}} +const unsigned short *CPUSMin = &USMin; +// CHECK-NEXT: (lldb) target variable CPUSMin +// CHECK-NEXT: (const unsigned short *) CPUSMin = {{.*}} +const int *CPIMax = &IMax; +// CHECK-NEXT: (lldb) target variable CPIMax +// CHECK-NEXT: (const int *) CPIMax = {{.*}} +const int *CPIMin = &IMin; +// CHECK-NEXT: (lldb) target variable CPIMin +// CHECK-NEXT: (const int *) CPIMin = {{.*}} +const unsigned int *CPUIMax = &UIMax; +// CHECK-NEXT: (lldb) target variable CPUIMax +// CHECK-NEXT: (const unsigned int *) CPUIMax = {{.*}} +const unsigned int *CPUIMin = &UIMin; +// CHECK-NEXT: (lldb) target variable CPUIMin +// CHECK-NEXT: (const unsigned int *) CPUIMin = {{.*}} +const long *CPLMax = &LMax; +// CHECK-NEXT: (lldb) target variable CPLMax +// CHECK-NEXT: (const long *) CPLMax = {{.*}} +const long *CPLMin = &LMin; +// CHECK-NEXT: (lldb) target variable CPLMin +// CHECK-NEXT: (const long *) CPLMin = {{.*}} +const unsigned long *CPULMax = &ULMax; +// CHECK-NEXT: (lldb) target variable CPULMax +// CHECK-NEXT: (const unsigned long *) CPULMax = {{.*}} +const unsigned long *CPULMin = &ULMin; +// CHECK-NEXT: (lldb) target variable CPULMin +// CHECK-NEXT: (const unsigned long *) CPULMin = {{.*}} +const long long *CPLLMax = &LLMax; +// CHECK-NEXT: (lldb) target variable CPLLMax +// CHECK-NEXT: (const long long *) CPLLMax = {{.*}} +const long long *CPLLMin = &LLMin; +// CHECK-NEXT: (lldb) target variable CPLLMin +// CHECK-NEXT: (const long long *) CPLLMin = {{.*}} +const unsigned long long *CPULLMax = &ULLMax; +// CHECK-NEXT: (lldb) target variable CPULLMax +// CHECK-NEXT: (const unsigned long long *) CPULLMax = {{.*}} +const unsigned long long *CPULLMin = &ULLMin; +// CHECK-NEXT: (lldb) target variable CPULLMin +// CHECK-NEXT: (const unsigned long long *) CPULLMin = {{.*}} +const float *CPF = &F; +// CHECK-NEXT: (lldb) target variable CPF +// CHECK-NEXT: (const float *) CPF = {{.*}} +const double *CPD = &D; +// CHECK-NEXT: (lldb) target variable CPD +// CHECK-NEXT: (const double *) CPD = {{.*}} + + +// References to fundamental data types + +bool &RBFalse = BFalse; +// CHECK-NEXT: (lldb) target variable RBFalse +// CHECK-NEXT: (bool &) RBFalse = {{.*}} (&::RBFalse = false) +bool &RBTrue = BTrue; +// CHECK-NEXT: (lldb) target variable RBTrue +// CHECK-NEXT: (bool &) RBTrue = {{.*}} (&::RBTrue = true) +char &RCA = CA; +// CHECK-NEXT: (lldb) target variable RCA +// CHECK-NEXT: (char &) RCA = {{.*}} (&::RCA = 'A') +char &RCZ = CZ; +// CHECK-NEXT: (lldb) target variable RCZ +// CHECK-NEXT: (char &) RCZ = {{.*}} (&::RCZ = 'Z') +signed char &RSCa = SCa; +// CHECK-NEXT: (lldb) target variable RSCa +// CHECK-NEXT: (signed char &) RSCa = {{.*}} (&::RSCa = 'a') +signed char &RSCz = SCz; +// CHECK-NEXT: (lldb) target variable RSCz +// CHECK-NEXT: (signed char &) RSCz = {{.*}} (&::RSCz = 'z') +unsigned char &RUC24 = UC24; +// CHECK-NEXT: (lldb) target variable RUC24 +// CHECK-NEXT: (unsigned char &) RUC24 = {{.*}} (&::RUC24 = '\x18') +unsigned char &RUC42 = UC42; +// CHECK-NEXT: (lldb) target variable RUC42 +// CHECK-NEXT: (unsigned char &) RUC42 = {{.*}} (&::RUC42 = '*') +short &RSMax = SMax; +// CHECK-NEXT: (lldb) target variable RSMax +// CHECK-NEXT: (short &) RSMax = {{.*}} (&::RSMax = 32767) +short &RSMin = SMin; +// CHECK-NEXT: (lldb) target variable RSMin +// CHECK-NEXT: (short &) RSMin = {{.*}} (&::RSMin = -32768) +unsigned short &RUSMax = USMax; +// CHECK-NEXT: (lldb) target variable RUSMax +// CHECK-NEXT: (unsigned short &) RUSMax = {{.*}} (&::RUSMax = 65535) +unsigned short &RUSMin = USMin; +// CHECK-NEXT: (lldb) target variable RUSMin +// CHECK-NEXT: (unsigned short &) RUSMin = {{.*}} (&::RUSMin = 0) +int &RIMax = IMax; +// CHECK-NEXT: (lldb) target variable RIMax +// CHECK-NEXT: (int &) RIMax = {{.*}} (&::RIMax = 2147483647) +int &RIMin = IMin; +// CHECK-NEXT: (lldb) target variable RIMin +// CHECK-NEXT: (int &) RIMin = {{.*}} (&::RIMin = -2147483648) +unsigned int &RUIMax = UIMax; +// CHECK-NEXT: (lldb) target variable RUIMax +// CHECK-NEXT: (unsigned int &) RUIMax = {{.*}} (&::RUIMax = 4294967295) +unsigned int &RUIMin = UIMin; +// CHECK-NEXT: (lldb) target variable RUIMin +// CHECK-NEXT: (unsigned int &) RUIMin = {{.*}} (&::RUIMin = 0) +long &RLMax = LMax; +// CHECK-NEXT: (lldb) target variable RLMax +// CHECK-NEXT: (long &) RLMax = {{.*}} (&::RLMax = 2147483647) +long &RLMin = LMin; +// CHECK-NEXT: (lldb) target variable RLMin +// CHECK-NEXT: (long &) RLMin = {{.*}} (&::RLMin = -2147483648) +unsigned long &RULMax = ULMax; +// CHECK-NEXT: (lldb) target variable RULMax +// CHECK-NEXT: (unsigned long &) RULMax = {{.*}} (&::RULMax = 4294967295) +unsigned long &RULMin = ULMin; +// CHECK-NEXT: (lldb) target variable RULMin +// CHECK-NEXT: (unsigned long &) RULMin = {{.*}} (&::RULMin = 0) +long long &RLLMax = LLMax; +// CHECK-NEXT: (lldb) target variable RLLMax +// CHECK-NEXT: (long long &) RLLMax = {{.*}} (&::RLLMax = 9223372036854775807) +long long &RLLMin = LLMin; +// CHECK-NEXT: (lldb) target variable RLLMin +// CHECK-NEXT: (long long &) RLLMin = {{.*}} (&::RLLMin = -9223372036854775808) +unsigned long long &RULLMax = ULLMax; +// CHECK-NEXT: (lldb) target variable RULLMax +// CHECK-NEXT: (unsigned long long &) RULLMax = {{.*}} (&::RULLMax = 18446744073709551615) +unsigned long long &RULLMin = ULLMin; +// CHECK-NEXT: (lldb) target variable RULLMin +// CHECK-NEXT: (unsigned long long &) RULLMin = {{.*}} (&::RULLMin = 0) +float &RF = F; +// CHECK-NEXT: (lldb) target variable RF +// CHECK-NEXT: (float &) RF = {{.*}} (&::RF = 3.1415) +double &RD = D; +// CHECK-NEXT: (lldb) target variable RD +// CHECK-NEXT: (double &) RD = {{.*}} (&::RD = 3.1415000000000002) + +// const references to fundamental data types +const bool &CRBFalse = BFalse; +// CHECK-NEXT: (lldb) target variable CRBFalse +// CHECK-NEXT: (const bool &) CRBFalse = {{.*}} (&::CRBFalse = false) +const bool &CRBTrue = BTrue; +// CHECK-NEXT: (lldb) target variable CRBTrue +// CHECK-NEXT: (const bool &) CRBTrue = {{.*}} (&::CRBTrue = true) +const char &CRCA = CA; +// CHECK-NEXT: (lldb) target variable CRCA +// CHECK-NEXT: (const char &) CRCA = {{.*}} (&::CRCA = 'A') +const char &CRCZ = CZ; +// CHECK-NEXT: (lldb) target variable CRCZ +// CHECK-NEXT: (const char &) CRCZ = {{.*}} (&::CRCZ = 'Z') +const signed char &CRSCa = SCa; +// CHECK-NEXT: (lldb) target variable CRSCa +// CHECK-NEXT: (const signed char &) CRSCa = {{.*}} (&::CRSCa = 'a') +const signed char &CRSCz = SCz; +// CHECK-NEXT: (lldb) target variable CRSCz +// CHECK-NEXT: (const signed char &) CRSCz = {{.*}} (&::CRSCz = 'z') +const unsigned char &CRUC24 = UC24; +// CHECK-NEXT: (lldb) target variable CRUC24 +// CHECK-NEXT: (const unsigned char &) CRUC24 = {{.*}} (&::CRUC24 = '\x18') +const unsigned char &CRUC42 = UC42; +// CHECK-NEXT: (lldb) target variable CRUC42 +// CHECK-NEXT: (const unsigned char &) CRUC42 = {{.*}} (&::CRUC42 = '*') +const short &CRSMax = SMax; +// CHECK-NEXT: (lldb) target variable CRSMax +// CHECK-NEXT: (const short &) CRSMax = {{.*}} (&::CRSMax = 32767) +const short &CRSMin = SMin; +// CHECK-NEXT: (lldb) target variable CRSMin +// CHECK-NEXT: (const short &) CRSMin = {{.*}} (&::CRSMin = -32768) +const unsigned short &CRUSMax = USMax; +// CHECK-NEXT: (lldb) target variable CRUSMax +// CHECK-NEXT: (const unsigned short &) CRUSMax = {{.*}} (&::CRUSMax = 65535) +const unsigned short &CRUSMin = USMin; +// CHECK-NEXT: (lldb) target variable CRUSMin +// CHECK-NEXT: (const unsigned short &) CRUSMin = {{.*}} (&::CRUSMin = 0) +const int &CRIMax = IMax; +// CHECK-NEXT: (lldb) target variable CRIMax +// CHECK-NEXT: (const int &) CRIMax = {{.*}} (&::CRIMax = 2147483647) +const int &CRIMin = IMin; +// CHECK-NEXT: (lldb) target variable CRIMin +// CHECK-NEXT: (const int &) CRIMin = {{.*}} (&::CRIMin = -2147483648) +const unsigned int &CRUIMax = UIMax; +// CHECK-NEXT: (lldb) target variable CRUIMax +// CHECK-NEXT: (const unsigned int &) CRUIMax = {{.*}} (&::CRUIMax = 4294967295) +const unsigned int &CRUIMin = UIMin; +// CHECK-NEXT: (lldb) target variable CRUIMin +// CHECK-NEXT: (const unsigned int &) CRUIMin = {{.*}} (&::CRUIMin = 0) +const long &CRLMax = LMax; +// CHECK-NEXT: (lldb) target variable CRLMax +// CHECK-NEXT: (const long &) CRLMax = {{.*}} (&::CRLMax = 2147483647) +const long &CRLMin = LMin; +// CHECK-NEXT: (lldb) target variable CRLMin +// CHECK-NEXT: (const long &) CRLMin = {{.*}} (&::CRLMin = -2147483648) +const unsigned long &CRULMax = ULMax; +// CHECK-NEXT: (lldb) target variable CRULMax +// CHECK-NEXT: (const unsigned long &) CRULMax = {{.*}} (&::CRULMax = 4294967295) +const unsigned long &CRULMin = ULMin; +// CHECK-NEXT: (lldb) target variable CRULMin +// CHECK-NEXT: (const unsigned long &) CRULMin = {{.*}} (&::CRULMin = 0) +const long long &CRLLMax = LLMax; +// CHECK-NEXT: (lldb) target variable CRLLMax +// CHECK-NEXT: (const long long &) CRLLMax = {{.*}} (&::CRLLMax = 9223372036854775807) +const long long &CRLLMin = LLMin; +// CHECK-NEXT: (lldb) target variable CRLLMin +// CHECK-NEXT: (const long long &) CRLLMin = {{.*}} (&::CRLLMin = -9223372036854775808) +const unsigned long long &CRULLMax = ULLMax; +// CHECK-NEXT: (lldb) target variable CRULLMax +// CHECK-NEXT: (const unsigned long long &) CRULLMax = {{.*}} (&::CRULLMax = 18446744073709551615) +const unsigned long long &CRULLMin = ULLMin; +// CHECK-NEXT: (lldb) target variable CRULLMin +// CHECK-NEXT: (const unsigned long long &) CRULLMin = {{.*}} (&::CRULLMin = 0) +const float &CRF = F; +// CHECK-NEXT: (lldb) target variable CRF +// CHECK-NEXT: (const float &) CRF = {{.*}} (&::CRF = 3.1415) +const double &CRD = D; +// CHECK-NEXT: (lldb) target variable CRD +// CHECK-NEXT: (const double &) CRD = {{.*}} (&::CRD = 3.1415000000000002) + +char16_t &RC16_24 = C16_24; +// CHECK: (lldb) target variable RC16_24 +// FIXME: (char16_t &) RC16_24 = {{.*}} (&::RC16_24 = U+0014) +char32_t &RC32_42 = C32_42; +// CHECK: (lldb) target variable RC32_42 +// FIXME: (char32_t &) RC32_42 = {{.*}} (&::RC32_42 = U+0x00000022) +wchar_t &RWC1 = WC1; +// CHECK: (lldb) target variable RWC1 +// FIXME: (wchar_t &) RWC1 = {{.*}} (&::RWC1 = L'1') +wchar_t &RWCP = WCP; +// CHECK: (lldb) target variable RWCP +// FIXME: (wchar_t &) RWCP = {{.*}} (&::RWCP = L'P') +const char16_t &CRC16_24 = C16_24; +// CHECK: (lldb) target variable CRC16_24 +// FIXME: (const char16_t &) CRC16_24 = {{.*}} (&::CRC16_24 = U+0014) +const char32_t &CRC32_42 = C32_42; +// CHECK: (lldb) target variable CRC32_42 +// FIXME: (const char32_t &) CRC32_42 = {{.*}} (&::CRC32_42 = U+0x00000022) +const wchar_t &CRWC1 = WC1; +// CHECK: (lldb) target variable CRWC1 +// FIXME: (const wchar_t &) CRWC1 = {{.*}} (&::CRWC1 = L'1') +const wchar_t &CRWCP = WCP; +// CHECK: (lldb) target variable CRWCP +// FIXME: (const wchar_t &) CRWCP = {{.*}} (&::CRWCP = L'P') + + +// CHECK: TranslationUnitDecl {{.*}} +// CHECK-NEXT: |-VarDecl {{.*}} BFalse 'bool' +// CHECK-NEXT: |-VarDecl {{.*}} BTrue 'bool' +// CHECK-NEXT: |-VarDecl {{.*}} CA 'char' +// CHECK-NEXT: |-VarDecl {{.*}} CZ 'char' +// CHECK-NEXT: |-VarDecl {{.*}} SCa 'signed char' +// CHECK-NEXT: |-VarDecl {{.*}} SCz 'signed char' +// CHECK-NEXT: |-VarDecl {{.*}} UC24 'unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} UC42 'unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} C16_24 'char16_t' +// CHECK-NEXT: |-VarDecl {{.*}} C32_42 'char32_t' +// CHECK-NEXT: |-VarDecl {{.*}} WC1 'wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} WCP 'wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} SMax 'short' +// CHECK-NEXT: |-VarDecl {{.*}} SMin 'short' +// CHECK-NEXT: |-VarDecl {{.*}} USMax 'unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} USMin 'unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} IMax 'int' +// CHECK-NEXT: |-VarDecl {{.*}} IMin 'int' +// CHECK-NEXT: |-VarDecl {{.*}} UIMax 'unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} UIMin 'unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} LMax 'long' +// CHECK-NEXT: |-VarDecl {{.*}} LMin 'long' +// CHECK-NEXT: |-VarDecl {{.*}} ULMax 'unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} ULMin 'unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} LLMax 'long long' +// CHECK-NEXT: |-VarDecl {{.*}} LLMin 'long long' +// CHECK-NEXT: |-VarDecl {{.*}} ULLMax 'unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} ULLMin 'unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} F 'float' +// CHECK-NEXT: |-VarDecl {{.*}} D 'double' +// CHECK-NEXT: |-VarDecl {{.*}} CBFalse 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} CBTrue 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} CCA 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} CCZ 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} CSCa 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} CSCz 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} CUC24 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} CUC42 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} CC16_24 'const char16_t' +// CHECK-NEXT: |-VarDecl {{.*}} CC32_42 'const char32_t' +// CHECK-NEXT: |-VarDecl {{.*}} CWC1 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} CWCP 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} CSMax 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} CSMin 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} CUSMax 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} CUSMin 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} CIMax 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} CIMin 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} CUIMax 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} CUIMin 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} CLMax 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} CLMin 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} CULMax 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} CULMin 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} CLLMax 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} CLLMin 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} CULLMax 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} CULLMin 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} CF 'const float' +// CHECK-NEXT: |-VarDecl {{.*}} CD 'const double' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprBFalse 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprBTrue 'const bool' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprCA 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprCZ 'const char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSCa 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSCz 'const signed char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUC24 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUC42 'const unsigned char' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprC16_24 'const char16_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprC32_42 'const char32_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprWC1 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprWCP 'const wchar_t' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSMax 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprSMin 'const short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUSMax 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUSMin 'const unsigned short' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprIMax 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprIMin 'const int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUIMax 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprUIMin 'const unsigned int' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLMax 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLMin 'const long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULMax 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULMin 'const unsigned long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLLMax 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprLLMin 'const long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULLMax 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprULLMin 'const unsigned long long' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprF 'const float' +// CHECK-NEXT: |-VarDecl {{.*}} ConstexprD 'const double' +// CHECK-NEXT: |-VarDecl {{.*}} PBFalse 'bool *' +// CHECK-NEXT: |-VarDecl {{.*}} PBTrue 'bool *' +// CHECK-NEXT: |-VarDecl {{.*}} PCA 'char *' +// CHECK-NEXT: |-VarDecl {{.*}} PCZ 'char *' +// CHECK-NEXT: |-VarDecl {{.*}} PSCa 'signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} PSCz 'signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} PUC24 'unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} PUC42 'unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} PC16_24 'char16_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PC32_42 'char32_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PWC1 'wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PWCP 'wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} PSMax 'short *' +// CHECK-NEXT: |-VarDecl {{.*}} PSMin 'short *' +// CHECK-NEXT: |-VarDecl {{.*}} PUSMax 'unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} PUSMin 'unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} PIMax 'int *' +// CHECK-NEXT: |-VarDecl {{.*}} PIMin 'int *' +// CHECK-NEXT: |-VarDecl {{.*}} PUIMax 'unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} PUIMin 'unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} PLMax 'long *' +// CHECK-NEXT: |-VarDecl {{.*}} PLMin 'long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULMax 'unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULMin 'unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} PLLMax 'long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PLLMin 'long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULLMax 'unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PULLMin 'unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} PF 'float *' +// CHECK-NEXT: |-VarDecl {{.*}} PD 'double *' +// CHECK-NEXT: |-VarDecl {{.*}} CPBFalse 'const bool *' +// CHECK-NEXT: |-VarDecl {{.*}} CPBTrue 'const bool *' +// CHECK-NEXT: |-VarDecl {{.*}} CPCA 'const char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPCZ 'const char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSCa 'const signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSCz 'const signed char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUC24 'const unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUC42 'const unsigned char *' +// CHECK-NEXT: |-VarDecl {{.*}} CPC16_24 'const char16_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPC32_42 'const char32_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPWC1 'const wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPWCP 'const wchar_t *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSMax 'const short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPSMin 'const short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUSMax 'const unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUSMin 'const unsigned short *' +// CHECK-NEXT: |-VarDecl {{.*}} CPIMax 'const int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPIMin 'const int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUIMax 'const unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPUIMin 'const unsigned int *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLMax 'const long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLMin 'const long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULMax 'const unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULMin 'const unsigned long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLLMax 'const long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPLLMin 'const long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULLMax 'const unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPULLMin 'const unsigned long long *' +// CHECK-NEXT: |-VarDecl {{.*}} CPF 'const float *' +// CHECK-NEXT: |-VarDecl {{.*}} CPD 'const double *' +// CHECK-NEXT: |-VarDecl {{.*}} RBFalse 'bool &' +// CHECK-NEXT: |-VarDecl {{.*}} RBTrue 'bool &' +// CHECK-NEXT: |-VarDecl {{.*}} RCA 'char &' +// CHECK-NEXT: |-VarDecl {{.*}} RCZ 'char &' +// CHECK-NEXT: |-VarDecl {{.*}} RSCa 'signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} RSCz 'signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} RUC24 'unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} RUC42 'unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} RSMax 'short &' +// CHECK-NEXT: |-VarDecl {{.*}} RSMin 'short &' +// CHECK-NEXT: |-VarDecl {{.*}} RUSMax 'unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} RUSMin 'unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} RIMax 'int &' +// CHECK-NEXT: |-VarDecl {{.*}} RIMin 'int &' +// CHECK-NEXT: |-VarDecl {{.*}} RUIMax 'unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} RUIMin 'unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} RLMax 'long &' +// CHECK-NEXT: |-VarDecl {{.*}} RLMin 'long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULMax 'unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULMin 'unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} RLLMax 'long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RLLMin 'long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULLMax 'unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RULLMin 'unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} RF 'float &' +// CHECK-NEXT: |-VarDecl {{.*}} RD 'double &' +// CHECK-NEXT: |-VarDecl {{.*}} CRBFalse 'const bool &' +// CHECK-NEXT: |-VarDecl {{.*}} CRBTrue 'const bool &' +// CHECK-NEXT: |-VarDecl {{.*}} CRCA 'const char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRCZ 'const char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSCa 'const signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSCz 'const signed char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUC24 'const unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUC42 'const unsigned char &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSMax 'const short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRSMin 'const short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUSMax 'const unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUSMin 'const unsigned short &' +// CHECK-NEXT: |-VarDecl {{.*}} CRIMax 'const int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRIMin 'const int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUIMax 'const unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRUIMin 'const unsigned int &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLMax 'const long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLMin 'const long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULMax 'const unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULMin 'const unsigned long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLLMax 'const long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRLLMin 'const long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULLMax 'const unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRULLMin 'const unsigned long long &' +// CHECK-NEXT: |-VarDecl {{.*}} CRF 'const float &' +// CHECK-NEXT: |-VarDecl {{.*}} CRD 'const double &' +// CHECK-NEXT: |-VarDecl {{.*}} RC16_24 'char16_t &' +// CHECK-NEXT: |-VarDecl {{.*}} RC32_42 'char32_t &' +// CHECK-NEXT: |-VarDecl {{.*}} RWC1 'wchar_t &' +// CHECK-NEXT: |-VarDecl {{.*}} RWCP 'wchar_t &' +// CHECK-NEXT: |-VarDecl {{.*}} CRC16_24 'const char16_t &' +// CHECK-NEXT: |-VarDecl {{.*}} CRC32_42 'const char32_t &' +// CHECK-NEXT: |-VarDecl {{.*}} CRWC1 'const wchar_t &' +// CHECK-NEXT: `-VarDecl {{.*}} CRWCP 'const wchar_t &' + +// CHECK: (lldb) quit + +int main(int argc, char **argv) { + return CIMax; +} diff --git a/lit/SymbolFile/NativePDB/local-variables.cpp b/lit/SymbolFile/NativePDB/local-variables.cpp new file mode 100644 index 000000000000..a7e786dc4e52 --- /dev/null +++ b/lit/SymbolFile/NativePDB/local-variables.cpp @@ -0,0 +1,161 @@ +// clang-format off + +// REQUIRES: system-windows +// RUN: %build -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/local-variables.lldbinit 2>&1 | FileCheck %s + +int Function(int Param1, char Param2) { + unsigned Local1 = Param1 + 1; + char Local2 = Param2 + 1; + ++Local1; + ++Local2; + return Local1; +} + +int main(int argc, char **argv) { + int SomeLocal = argc * 2; + return Function(SomeLocal, 'a'); +} + +// CHECK: (lldb) target create "{{.*}}local-variables.cpp.tmp.exe" +// CHECK-NEXT: Current executable set to '{{.*}}local-variables.cpp.tmp.exe' +// CHECK-NEXT: (lldb) command source -s 0 '{{.*}}local-variables.lldbinit' +// CHECK-NEXT: Executing commands in '{{.*}}local-variables.lldbinit'. +// CHECK-NEXT: (lldb) break set -n main +// CHECK-NEXT: Breakpoint 1: where = local-variables.cpp.tmp.exe`main + {{.*}} at local-variables.cpp:{{.*}}, address = {{.*}} +// CHECK-NEXT: (lldb) run a b c d e f g +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = breakpoint 1.1 +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`main(argc=8, argv={{.*}}) at local-variables.cpp:{{.*}} +// CHECK-NEXT: 14 } +// CHECK-NEXT: 15 +// CHECK-NEXT: 16 int main(int argc, char **argv) { +// CHECK-NEXT: -> 17 int SomeLocal = argc * 2; +// CHECK-NEXT: 18 return Function(SomeLocal, 'a'); +// CHECK-NEXT: 19 } +// CHECK-NEXT: 20 + +// CHECK: Process {{.*}} launched: '{{.*}}local-variables.cpp.tmp.exe' +// CHECK-NEXT: (lldb) p argc +// CHECK-NEXT: (int) $0 = 8 +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`main(argc=8, argv={{.*}}) at local-variables.cpp:{{.*}} +// CHECK-NEXT: 15 +// CHECK-NEXT: 16 int main(int argc, char **argv) { +// CHECK-NEXT: 17 int SomeLocal = argc * 2; +// CHECK-NEXT: -> 18 return Function(SomeLocal, 'a'); +// CHECK-NEXT: 19 } +// CHECK-NEXT: 20 + +// CHECK: (lldb) p SomeLocal +// CHECK-NEXT: (int) $1 = 16 +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 6 +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 int Function(int Param1, char Param2) { +// CHECK-NEXT: -> 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $2 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $3 = 'a' +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 int Function(int Param1, char Param2) { +// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: -> 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; +// CHECK-NEXT: 13 return Local1; + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $4 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $5 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $6 = 17 +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 8 int Function(int Param1, char Param2) { +// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: -> 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; +// CHECK-NEXT: 13 return Local1; +// CHECK-NEXT: 14 } + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $7 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $8 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $9 = 17 +// CHECK-NEXT: (lldb) p Local2 +// CHECK-NEXT: (char) $10 = 'b' +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 9 unsigned Local1 = Param1 + 1; +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: -> 12 ++Local2; +// CHECK-NEXT: 13 return Local1; +// CHECK-NEXT: 14 } +// CHECK-NEXT: 15 + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $11 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $12 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $13 = 18 +// CHECK-NEXT: (lldb) p Local2 +// CHECK-NEXT: (char) $14 = 'b' +// CHECK-NEXT: (lldb) step +// CHECK-NEXT: Process {{.*}} stopped +// CHECK-NEXT: * thread #1, stop reason = step in +// CHECK-NEXT: frame #0: {{.*}} local-variables.cpp.tmp.exe`Function(Param1=16, Param2='a') at local-variables.cpp:{{.*}} +// CHECK-NEXT: 10 char Local2 = Param2 + 1; +// CHECK-NEXT: 11 ++Local1; +// CHECK-NEXT: 12 ++Local2; +// CHECK-NEXT: -> 13 return Local1; +// CHECK-NEXT: 14 } +// CHECK-NEXT: 15 +// CHECK-NEXT: 16 int main(int argc, char **argv) { + +// CHECK: (lldb) p Param1 +// CHECK-NEXT: (int) $15 = 16 +// CHECK-NEXT: (lldb) p Param2 +// CHECK-NEXT: (char) $16 = 'a' +// CHECK-NEXT: (lldb) p Local1 +// CHECK-NEXT: (unsigned int) $17 = 18 +// CHECK-NEXT: (lldb) p Local2 +// CHECK-NEXT: (char) $18 = 'c' +// CHECK-NEXT: (lldb) continue +// CHECK-NEXT: Process {{.*}} resuming +// CHECK-NEXT: Process {{.*}} exited with status = 18 (0x00000012) + +// CHECK: (lldb) target modules dump ast +// CHECK-NEXT: Dumping clang ast for {{.*}} modules. +// CHECK-NEXT: TranslationUnitDecl +// CHECK-NEXT: |-FunctionDecl {{.*}} main 'int (int, char **)' +// CHECK-NEXT: | |-ParmVarDecl {{.*}} argc 'int' +// CHECK-NEXT: | `-ParmVarDecl {{.*}} argv 'char **' +// CHECK-NEXT: `-FunctionDecl {{.*}} Function 'int (int, char)' +// CHECK-NEXT: |-ParmVarDecl {{.*}} Param1 'int' +// CHECK-NEXT: `-ParmVarDecl {{.*}} Param2 'char' diff --git a/lit/SymbolFile/NativePDB/nested-types.cpp b/lit/SymbolFile/NativePDB/nested-types.cpp new file mode 100644 index 000000000000..e9bee690d301 --- /dev/null +++ b/lit/SymbolFile/NativePDB/nested-types.cpp @@ -0,0 +1,153 @@ +// clang-format off +// REQUIRES: lld + +// Test various interesting cases for AST reconstruction. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/nested-types.lldbinit 2>&1 | FileCheck %s + +struct S { + struct NestedStruct { + int A = 0; + int B = 1; + }; + + enum class NestedEnum { + EnumValue1 = 0, + EnumValue2 = 1, + }; + int C = 2; + int D = 3; + using VoidPtrT = void *; + VoidPtrT DD = nullptr; +}; +struct T { + using NestedTypedef = int; + using NestedTypedef2 = S; + + struct NestedStruct { + int E = 4; + int F = 5; + }; + + using NestedStructAlias = NestedStruct; + using NST = S::NestedStruct; + + NestedTypedef NT = 4; + + using U = struct { + int G = 6; + int H = 7; + }; +}; + +template +class U { +public: + // See llvm.org/pr39607. clang-cl currently doesn't emit an important debug + // info record for nested template instantiations, so we can't reconstruct + // a proper DeclContext hierarchy for these. As such, U::V will show up + // in the global namespace. + template + struct V { + Param I = 8; + Param J = 9; + + using W = T::NestedTypedef; + using X = U; + }; + + struct W { + Param M = 12; + Param N = 13; + }; + Param K = 10; + Param L = 11; + using Y = V; + using Z = V; +}; + +constexpr S GlobalA; +constexpr S::NestedStruct GlobalB; +constexpr T GlobalC; +constexpr T::NestedStruct GlobalD; +constexpr T::U GlobalE; +constexpr U GlobalF; +constexpr U::V GlobalG; +constexpr U::W GlobalH; +constexpr S::NestedEnum GlobalEnum = S::NestedEnum::EnumValue1; + + +int main(int argc, char **argv) { + return 0; +} + + + +// CHECK: (lldb) target variable -T GlobalA +// CHECK: (const S) GlobalA = { +// CHECK: (int) C = 2 +// CHECK: (int) D = 3 +// CHECK: (void *) DD = 0x00000000 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalB +// CHECK: (const S::NestedStruct) GlobalB = { +// CHECK: (int) A = 0 +// CHECK: (int) B = 1 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalC +// CHECK: (const T) GlobalC = { +// CHECK: (int) NT = 4 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalD +// CHECK: (const T::NestedStruct) GlobalD = { +// CHECK: (int) E = 4 +// CHECK: (int) F = 5 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalE +// CHECK: (const T::U) GlobalE = { +// CHECK: (int) G = 6 +// CHECK: (int) H = 7 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalF +// CHECK: (const U) GlobalF = { +// CHECK: (int) K = 10 +// CHECK: (int) L = 11 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalG +// CHECK: (const U::V) GlobalG = { +// CHECK: (int) I = 8 +// CHECK: (int) J = 9 +// CHECK: } +// CHECK: (lldb) target variable -T GlobalEnum +// CHECK: (const S::NestedEnum) GlobalEnum = EnumValue1 +// CHECK: (lldb) target modules dump ast +// CHECK: Dumping clang ast for 1 modules. +// CHECK: TranslationUnitDecl {{.*}} +// CHECK: |-CXXRecordDecl {{.*}} struct S definition +// CHECK: | |-FieldDecl {{.*}} C 'int' +// CHECK: | |-FieldDecl {{.*}} D 'int' +// CHECK: | |-FieldDecl {{.*}} DD 'void *' +// CHECK: | |-CXXRecordDecl {{.*}} struct NestedStruct definition +// CHECK: | | |-FieldDecl {{.*}} A 'int' +// CHECK: | | `-FieldDecl {{.*}} B 'int' +// CHECK: | `-EnumDecl {{.*}} NestedEnum +// CHECK: | |-EnumConstantDecl {{.*}} EnumValue1 'S::NestedEnum' +// CHECK: | `-EnumConstantDecl {{.*}} EnumValue2 'S::NestedEnum' +// CHECK: |-CXXRecordDecl {{.*}} struct T definition +// CHECK: | |-FieldDecl {{.*}} NT 'int' +// CHECK: | |-CXXRecordDecl {{.*}} struct NestedStruct definition +// CHECK: | | |-FieldDecl {{.*}} E 'int' +// CHECK: | | `-FieldDecl {{.*}} F 'int' +// CHECK: | `-CXXRecordDecl {{.*}} struct U definition +// CHECK: | |-FieldDecl {{.*}} G 'int' +// CHECK: | `-FieldDecl {{.*}} H 'int' +// CHECK: |-CXXRecordDecl {{.*}} class U definition +// CHECK: | |-FieldDecl {{.*}} K 'int' +// CHECK: | |-FieldDecl {{.*}} L 'int' +// CHECK: | `-CXXRecordDecl {{.*}} struct W definition +// CHECK: | |-FieldDecl {{.*}} M 'int' +// CHECK: | `-FieldDecl {{.*}} N 'int' +// CHECK: |-CXXRecordDecl {{.*}} struct U::V definition +// CHECK: | |-FieldDecl {{.*}} I 'int' +// CHECK: | `-FieldDecl {{.*}} J 'int' diff --git a/lit/SymbolFile/NativePDB/s_constant.cpp b/lit/SymbolFile/NativePDB/s_constant.cpp new file mode 100644 index 000000000000..7603a4daba40 --- /dev/null +++ b/lit/SymbolFile/NativePDB/s_constant.cpp @@ -0,0 +1,115 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display S_CONSTANT records. + +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %p/Inputs/s_constant.s > %t.obj +// RUN: %build --compiler=clang-cl --nodefaultlib --mode=link -o %t.exe -- %t.obj +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/s_constant.lldbinit | FileCheck %s + +// clang-cl cannot generate S_CONSTANT records, but we need to test that we can +// handle them for compatibility with MSVC, which does emit them. This test +// case was generated by compiling this file with MSVC and copying the bytes +// that they emit for S_CONSTANT records. Then we compile the same code with +// clang to get a .s file, and replace all S_LDATA32 records with the bytes from +// the S_CONSTANT records. This way we end up with a .s file that contains +// symbol records that clang-cl won't generate. + +namespace A { +namespace B { +namespace C { + enum LargeUnsignedEnum : unsigned long long { + LUE_A = 0ULL, + LUE_B = 1000ULL, + LUE_C = 18446744073709551600ULL, + }; + + enum LargeSignedEnum : long long { + LSE_A = 0LL, + LSE_B = 9223372036854775000LL, + LSE_C = -9223372036854775000LL, + }; + + enum UnsignedEnum : unsigned int { + UE_A = 0, + UE_B = 1000, + UE_C = 4294000000, + }; + + enum SignedEnum : int { + SE_A = 0, + SE_B = 2147000000, + SE_C = -2147000000, + }; + + enum SmallUnsignedEnum : unsigned char { + SUE_A = 0, + SUE_B = 100, + SUE_C = 200, + }; + + enum SmallSignedEnum : char { + SSE_A = 0, + SSE_B = 100, + SSE_C = -100, + }; +} +} +} + +using namespace A::B::C; + +constexpr LargeUnsignedEnum GlobalLUEA = LUE_A; +constexpr LargeUnsignedEnum GlobalLUEB = LUE_B; +constexpr LargeUnsignedEnum GlobalLUEC = LUE_C; + +constexpr LargeSignedEnum GlobalLSEA = LSE_A; +constexpr LargeSignedEnum GlobalLSEB = LSE_B; +constexpr LargeSignedEnum GlobalLSEC = LSE_C; + +constexpr UnsignedEnum GlobalUEA = UE_A; +constexpr UnsignedEnum GlobalUEB = UE_B; +constexpr UnsignedEnum GlobalUEC = UE_C; + +constexpr SignedEnum GlobalSEA = SE_A; +constexpr SignedEnum GlobalSEB = SE_B; +constexpr SignedEnum GlobalSEC = SE_C; + +constexpr SmallUnsignedEnum GlobalSUEA = SUE_A; +constexpr SmallUnsignedEnum GlobalSUEB = SUE_B; +constexpr SmallUnsignedEnum GlobalSUEC = SUE_C; + +constexpr SmallSignedEnum GlobalSSEA = SSE_A; +constexpr SmallSignedEnum GlobalSSEB = SSE_B; +constexpr SmallSignedEnum GlobalSSEC = SSE_C; + +int main(int argc, char **argv) { + return 0; +} + +// CHECK: (const A::B::C::LargeUnsignedEnum) GlobalLUEA = LUE_A +// CHECK: (const A::B::C::LargeUnsignedEnum) GlobalLUEB = LUE_B + +// X-FAIL: Something is outputting bad debug info here, maybe cl. +// CHECK: (const A::B::C::LargeUnsignedEnum) GlobalLUEC = {{.*}} + +// CHECK: (const A::B::C::LargeSignedEnum) GlobalLSEA = LSE_A +// CHECK: (const A::B::C::LargeSignedEnum) GlobalLSEB = LSE_B +// CHECK: (const A::B::C::LargeSignedEnum) GlobalLSEC = LSE_C + +// CHECK: (const A::B::C::UnsignedEnum) GlobalUEA = UE_A +// CHECK: (const A::B::C::UnsignedEnum) GlobalUEB = UE_B +// CHECK: (const A::B::C::UnsignedEnum) GlobalUEC = UE_C + +// CHECK: (const A::B::C::SignedEnum) GlobalSEA = SE_A +// CHECK: (const A::B::C::SignedEnum) GlobalSEB = SE_B +// CHECK: (const A::B::C::SignedEnum) GlobalSEC = SE_C + +// CHECK: (const A::B::C::SmallUnsignedEnum) GlobalSUEA = SUE_A +// CHECK: (const A::B::C::SmallUnsignedEnum) GlobalSUEB = SUE_B +// CHECK: (const A::B::C::SmallUnsignedEnum) GlobalSUEC = SUE_C + +// CHECK: (const A::B::C::SmallSignedEnum) GlobalSSEA = SSE_A +// CHECK: (const A::B::C::SmallSignedEnum) GlobalSSEB = SSE_B +// CHECK: (const A::B::C::SmallSignedEnum) GlobalSSEC = SSE_C diff --git a/lit/SymbolFile/NativePDB/source-list.cpp b/lit/SymbolFile/NativePDB/source-list.cpp new file mode 100644 index 000000000000..6b749b082e3d --- /dev/null +++ b/lit/SymbolFile/NativePDB/source-list.cpp @@ -0,0 +1,42 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can set display source of functions. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/source-list.lldbinit | FileCheck %s + + + +// Some context lines before +// the function. + + +int main(int argc, char **argv) { + // Here are some comments. + // That we should print when listing source. + return 0; +} + +// Some context lines after +// the function. + +// check lines go at the end so that line numbers stay stable when +// changing this file. + +// CHECK: (lldb) source list -n main +// CHECK: File: {{.*}}source-list.cpp +// CHECK: 10 +// CHECK: 11 // Some context lines before +// CHECK: 12 // the function. +// CHECK: 13 +// CHECK: 14 +// CHECK: 15 int main(int argc, char **argv) { +// CHECK: 16 // Here are some comments. +// CHECK: 17 // That we should print when listing source. +// CHECK: 18 return 0; +// CHECK: 19 } +// CHECK: 20 +// CHECK: 21 // Some context lines after +// CHECK: 22 // the function. +// CHECK: 23 diff --git a/lit/SymbolFile/NativePDB/tag-types.cpp b/lit/SymbolFile/NativePDB/tag-types.cpp new file mode 100644 index 000000000000..127ad5980925 --- /dev/null +++ b/lit/SymbolFile/NativePDB/tag-types.cpp @@ -0,0 +1,235 @@ +// clang-format off +// REQUIRES: lld + +// Test that we can display tag types. +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \ +// RUN: %p/Inputs/tag-types.lldbinit | FileCheck %s + +// Test struct +struct Struct { + // Test builtin types, which are represented by special CodeView type indices. + bool B; + char C; + signed char SC; + unsigned char UC; + char16_t C16; + char32_t C32; + wchar_t WC; + short S; + unsigned short US; + int I; + unsigned int UI; + long L; + unsigned long UL; + long long LL; + unsigned long long ULL; + float F; + double D; + long double LD; +}; + +// Test class +class Class { +public: + // Test pointers to builtin types, which are represented by different special + // CodeView type indices. + bool *PB; + char *PC; + signed char *PSC; + unsigned char *PUC; + char16_t *PC16; + char32_t *PC32; + wchar_t *PWC; + short *PS; + unsigned short *PUS; + int *PI; + unsigned int *PUI; + long *PL; + unsigned long *PUL; + long long *PLL; + unsigned long long *PULL; + float *PF; + double *PD; + long double *PLD; +}; + +// Test union +union Union { + // Test modified types. + const bool *PB; + const char *PC; + const signed char *PSC; + const unsigned char *PUC; + const char16_t *PC16; + const char32_t *PC32; + const wchar_t *PWC; + const short *PS; + const unsigned short *PUS; + const int *PI; + const unsigned int *PUI; + const long *PL; + const unsigned long *PUL; + const long long *PLL; + const unsigned long long *PULL; + const float *PF; + const double *PD; + const long double *PLD; +}; + +struct OneMember { + int N = 0; +}; + + +// Test single inheritance. +class Derived : public Class { +public: + explicit Derived() + : Reference(*this), RefMember(Member), RValueRefMember((OneMember&&)Member) {} + + // Test reference to self, to make sure we don't end up in an + // infinite cycle. + Derived &Reference; + + // Test aggregate class member. + OneMember Member; + + // And modified aggregate class member. + const OneMember ConstMember; + volatile OneMember VolatileMember; + const volatile OneMember CVMember; + + // And all types of pointers to class members + OneMember *PtrMember; + OneMember &RefMember; + OneMember &&RValueRefMember; +}; + +// Test multiple inheritance, as well as protected and private inheritance. +class Derived2 : protected Class, private Struct { +public: + // Test static data members + static unsigned StaticDataMember; +}; + +unsigned Derived2::StaticDataMember = 0; + +// Test scoped enums and unscoped enums. +enum class EnumInt { + A = 1, + B = 2 +}; + +// Test explicit underlying types +enum EnumShort : short { + ES_A = 2, + ES_B = 3 +}; + +int main(int argc, char **argv) { + Struct S; + Class C; + Union U; + Derived D; + Derived2 D2; + EnumInt EI; + EnumShort ES; + + return 0; +} + +// CHECK: (lldb) target create "{{.*}}tag-types.cpp.tmp.exe" +// CHECK-NEXT: Current executable set to '{{.*}}tag-types.cpp.tmp.exe' +// CHECK-NEXT: (lldb) command source -s 0 '{{.*}}tag-types.lldbinit' +// CHECK-NEXT: Executing commands in '{{.*}}tag-types.lldbinit'. +// CHECK-NEXT: (lldb) type lookup -- Struct +// CHECK-NEXT: struct Struct { +// CHECK-NEXT: bool B; +// CHECK-NEXT: char C; +// CHECK-NEXT: signed char SC; +// CHECK-NEXT: unsigned char UC; +// CHECK-NEXT: char16_t C16; +// CHECK-NEXT: char32_t C32; +// CHECK-NEXT: wchar_t WC; +// CHECK-NEXT: short S; +// CHECK-NEXT: unsigned short US; +// CHECK-NEXT: int I; +// CHECK-NEXT: unsigned int UI; +// CHECK-NEXT: long L; +// CHECK-NEXT: unsigned long UL; +// CHECK-NEXT: long long LL; +// CHECK-NEXT: unsigned long long ULL; +// CHECK-NEXT: float F; +// CHECK-NEXT: double D; +// CHECK-NEXT: double LD; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- Class +// CHECK-NEXT: class Class { +// CHECK-NEXT: bool *PB; +// CHECK-NEXT: char *PC; +// CHECK-NEXT: signed char *PSC; +// CHECK-NEXT: unsigned char *PUC; +// CHECK-NEXT: char16_t *PC16; +// CHECK-NEXT: char32_t *PC32; +// CHECK-NEXT: wchar_t *PWC; +// CHECK-NEXT: short *PS; +// CHECK-NEXT: unsigned short *PUS; +// CHECK-NEXT: int *PI; +// CHECK-NEXT: unsigned int *PUI; +// CHECK-NEXT: long *PL; +// CHECK-NEXT: unsigned long *PUL; +// CHECK-NEXT: long long *PLL; +// CHECK-NEXT: unsigned long long *PULL; +// CHECK-NEXT: float *PF; +// CHECK-NEXT: double *PD; +// CHECK-NEXT: double *PLD; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- Union +// CHECK-NEXT: union Union { +// CHECK-NEXT: const bool *PB; +// CHECK-NEXT: const char *PC; +// CHECK-NEXT: const signed char *PSC; +// CHECK-NEXT: const unsigned char *PUC; +// CHECK-NEXT: const char16_t *PC16; +// CHECK-NEXT: const char32_t *PC32; +// CHECK-NEXT: const wchar_t *PWC; +// CHECK-NEXT: const short *PS; +// CHECK-NEXT: const unsigned short *PUS; +// CHECK-NEXT: const int *PI; +// CHECK-NEXT: const unsigned int *PUI; +// CHECK-NEXT: const long *PL; +// CHECK-NEXT: const unsigned long *PUL; +// CHECK-NEXT: const long long *PLL; +// CHECK-NEXT: const unsigned long long *PULL; +// CHECK-NEXT: const float *PF; +// CHECK-NEXT: const double *PD; +// CHECK-NEXT: const double *PLD; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- Derived +// CHECK-NEXT: class Derived : public Class { +// CHECK: Derived &Reference; +// CHECK-NEXT: OneMember Member; +// CHECK-NEXT: const OneMember ConstMember; +// CHECK-NEXT: volatile OneMember VolatileMember; +// CHECK-NEXT: const volatile OneMember CVMember; +// CHECK-NEXT: OneMember *PtrMember; +// CHECK-NEXT: OneMember &RefMember; +// CHECK-NEXT: OneMember &&RValueRefMember; +// CHECK: } +// CHECK-NEXT: (lldb) type lookup -- Derived2 +// CHECK-NEXT: class Derived2 : protected Class, private Struct { +// CHECK-NEXT: static unsigned int StaticDataMember; +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- EnumInt +// CHECK-NEXT: enum EnumInt { +// CHECK-NEXT: A, +// CHECK-NEXT: B +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- EnumShort +// CHECK-NEXT: enum EnumShort { +// CHECK-NEXT: ES_A, +// CHECK-NEXT: ES_B +// CHECK-NEXT: } +// CHECK-NEXT: (lldb) type lookup -- InvalidType +// CHECK-NEXT: no type was found matching 'InvalidType' diff --git a/lit/SymbolFile/NativePDB/typedefs.cpp b/lit/SymbolFile/NativePDB/typedefs.cpp new file mode 100644 index 000000000000..738fbe615d90 --- /dev/null +++ b/lit/SymbolFile/NativePDB/typedefs.cpp @@ -0,0 +1,71 @@ +// clang-format off + +// REQUIRES: system-windows +// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -dump-ast %t.exe | FileCheck %s + +namespace A { + namespace B { + using NamespaceTypedef = double; + } + template + class C { + public: + using ClassTypedef = T; + }; + using ClassTypedef = C::ClassTypedef; + using ClassTypedef2 = C::ClassTypedef; + + template + using AliasTemplate = typename C::ClassTypedef; +} + +namespace { + using AnonNamespaceTypedef = bool; +} + +using IntTypedef = int; + +using ULongArrayTypedef = unsigned long[10]; + +using RefTypedef = long double*&; + +using FuncPtrTypedef = long long(*)(int&, unsigned char**, short[], const double, volatile bool); + +using VarArgsFuncTypedef = char(*)(void*, long, unsigned short, unsigned int, ...); + +using VarArgsFuncTypedefA = float(*)(...); + +int main(int argc, char **argv) { + long double *Ptr; + + A::B::NamespaceTypedef *X0; + A::C::ClassTypedef *X1; + A::C::ClassTypedef *X2; + AnonNamespaceTypedef *X3; + IntTypedef *X4; + ULongArrayTypedef *X5; + RefTypedef X6 = Ptr; + FuncPtrTypedef X7; + VarArgsFuncTypedef X8; + VarArgsFuncTypedefA X9; + A::AliasTemplate X10; + return 0; +} + + +// CHECK: namespace `anonymous namespace' { +// CHECK-NEXT: typedef bool AnonNamespaceTypedef; +// CHECK-NEXT: } +// CHECK-NEXT: typedef unsigned long ULongArrayTypedef[10]; +// CHECK-NEXT: typedef double *&RefTypedef; +// CHECK-NEXT: namespace A { +// CHECK-NEXT: namespace B { +// CHECK-NEXT: typedef double NamespaceTypedef; +// CHECK-NEXT: } +// CHECK-NEXT: typedef float AliasTemplate; +// CHECK-NEXT: } +// CHECK-NEXT: typedef long long (*FuncPtrTypedef)(int &, unsigned char **, short *, const double, volatile bool); +// CHECK-NEXT: typedef char (*VarArgsFuncTypedef)(void *, long, unsigned short, unsigned int, ...); +// CHECK-NEXT: typedef float (*VarArgsFuncTypedefA)(...); +// CHECK-NEXT: typedef int IntTypedef; diff --git a/lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp b/lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp new file mode 100644 index 000000000000..8c9e26744d5f --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/AstRestoreTest.cpp @@ -0,0 +1,55 @@ +namespace N0 { +namespace N1 { + +namespace { +enum Enum { Enum_0 = 1, Enum_1 = 2, Enum_2 = 4, Enum_3 = 8 }; +} + +Enum Global = Enum_3; + +struct Base { + Enum m_e = Enum_1; +}; + +class Class : public Base { +public: + Class(Enum e) : m_ce(e) {} + + static int StaticFunc(const Class &c) { + return c.PrivateFunc(c.m_inner) + Global + ClassStatic; + } + + const Enum m_ce; + + static int ClassStatic; + +private: + struct Inner { + char x; + short y; + int z; + }; + + int PrivateFunc(const Inner &i) const { return i.z; } + + Inner m_inner{}; +}; +int Class::ClassStatic = 7; + +template +struct Template { + template + void TemplateFunc() { + T::StaticFunc(T(E)); + } +}; + +void foo() { Template().TemplateFunc(); } + +} // namespace N1 +} // namespace N0 + +int main() { + N0::N1::foo(); + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp b/lit/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp new file mode 100644 index 000000000000..60854c04c60a --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp @@ -0,0 +1,20 @@ +int FuncCCall() { return 0; } +auto FuncCCallPtr = &FuncCCall; + +int __stdcall FuncStdCall() { return 0; } +auto FuncStdCallPtr = &FuncStdCall; + +int __fastcall FuncFastCall() { return 0; } +auto FuncFastCallPtr = &FuncFastCall; + +int __vectorcall FuncVectorCall() { return 0; } +auto FuncVectorCallPtr = &FuncVectorCall; + +struct S { + int FuncThisCall() { return 0; } +}; +auto FuncThisCallPtr = &S::FuncThisCall; + +int main() { + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp b/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp new file mode 100644 index 000000000000..3c4b005cdf1b --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp @@ -0,0 +1,111 @@ +// To avoid linking MSVC specific libs, we don't test virtual/override methods +// that needs vftable support in this file. + +// Enum. +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +// Union. +union Union { + short Row; + unsigned short Col; + int Line : 16; // Test named bitfield. + short : 8; // Unnamed bitfield symbol won't be generated in PDB. + long Table; +}; +Union UnionVar; + +// Struct. +struct Struct; +typedef Struct StructTypedef; + +struct Struct { + bool A; + unsigned char UCharVar; + unsigned int UIntVar; + long long LongLongVar; + Enum EnumVar; // Test struct has UDT member. + int array[10]; +}; +struct Struct StructVar; + +struct _List; // Forward declaration. +struct Complex { + struct _List *array[90]; + struct { // Test unnamed struct. MSVC treats it as `int x` + int x; + }; + union { // Test unnamed union. MSVC treats it as `int a; float b;` + int a; + float b; + }; +}; +struct Complex c; + +struct _List { // Test doubly linked list. + struct _List *current; + struct _List *previous; + struct _List *next; +}; +struct _List ListVar; + +typedef struct { + int a; +} UnnamedStruct; // Test unnamed typedef-ed struct. +UnnamedStruct UnnanmedVar; + +// Class. +namespace MemberTest { +class Base { +public: + Base() {} + ~Base() {} + +public: + int Get() { return 0; } + +protected: + int a; +}; +class Friend { +public: + int f() { return 3; } +}; +class Class : public Base { // Test base class. + friend Friend; + static int m_static; // Test static member variable. +public: + Class() : m_public(), m_private(), m_protected() {} + explicit Class(int a) { m_public = a; } // Test first reference of m_public. + ~Class() {} + + static int StaticMemberFunc(int a, ...) { + return 1; + } // Test static member function. + int Get() { return 1; } + int f(Friend c) { return c.f(); } + inline bool operator==(const Class &rhs) const // Test operator. + { + return (m_public == rhs.m_public); + } + +public: + int m_public; + struct Struct m_struct; + +private: + Union m_union; + int m_private; + +protected: + friend class Friend; + int m_protected; +}; +} // namespace MemberTest + +int main() { + MemberTest::Base B1; + B1.Get(); + MemberTest::Class::StaticMemberFunc(1, 10, 2); + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp b/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp new file mode 100644 index 000000000000..3785cd3c64c7 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp @@ -0,0 +1,20 @@ +namespace N0 { +namespace N1 { + +char *buf0 = nullptr; +char buf1[] = {0, 1, 2, 3, 4, 5, 6, 7}; + +char sum(char *buf, int size) { + char result = 0; + for (int i = 0; i < size; i++) + result += buf[i]; + return result; +} + +} // namespace N1 +} // namespace N0 + +int main() { + char result = N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)); + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script b/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script new file mode 100644 index 000000000000..d31a2abb68a2 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script @@ -0,0 +1,7 @@ +breakpoint set --file ExpressionsTest.cpp --line 19 +run +print result +print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) +print N1::sum(N1::buf1, sizeof(N1::buf1)) +print sum(buf1, sizeof(buf1)) +print sum(buf1, 1000000000) diff --git a/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script b/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script new file mode 100644 index 000000000000..dac887faa5bb --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script @@ -0,0 +1 @@ +print sum(buf0, 1) diff --git a/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script b/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script new file mode 100644 index 000000000000..b19240baf99d --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script @@ -0,0 +1,2 @@ +print sum(buf0, result - 28) +print sum(buf1 + 3, 3) diff --git a/lit/SymbolFile/PDB/Inputs/PointerTypeTest.cpp b/lit/SymbolFile/PDB/Inputs/PointerTypeTest.cpp new file mode 100644 index 000000000000..6612c30f00df --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/PointerTypeTest.cpp @@ -0,0 +1,23 @@ +int main() { + // Test pointer to array. + int array[2][4]; + int(*array_pointer)[2][4] = &array; + + struct ST { + int a; + int f(int x) { return 1; } + }; + + ST s = {10}; + + // Test pointer to a local. + int *p_int = &s.a; + + // Test pointer to data member. + int ST::*p_member_field = &ST::a; + + // Test pointer to member function. + int (ST::*p_member_method)(int) = &ST::f; + + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp b/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp index 8e516201644c..de13a5b430c1 100644 --- a/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp +++ b/lit/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp @@ -35,6 +35,9 @@ EnumClass EnumClassVar; enum struct EnumStruct { red, blue, black }; EnumStruct EnumStructVar; +typedef signed char SCharTypedef; +SCharTypedef SCVar; + typedef char16_t WChar16Typedef; WChar16Typedef WC16Var; diff --git a/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp b/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp new file mode 100644 index 000000000000..59a4fc585d77 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp @@ -0,0 +1,61 @@ +struct A { + explicit A(int u) { _u._u3 = u; } + A(const A &) = default; + virtual ~A() = default; + +private: + union U { + char _u1; + short _u2; + int _u3; + }; + + A::U _u; +}; + +#pragma pack(push, 1) +template struct B : public virtual A { + B(char a, unsigned short b, int c) : A(a + b + c), _a(a), _b(b), _c(c) {} + +private: + char _a; + unsigned short : 3; + unsigned short _b : 6; + unsigned short : 4; + int _c; +}; +#pragma pack(pop) + +#pragma pack(push, 16) +class C : private virtual B<0>, public virtual B<1>, private B<2>, public B<3> { +public: + C(char x, char y, char z) + : A(x - y + z), B<0>(x, y, z), B<1>(x * 2, y * 2, z * 2), + B<2>(x * 3, y * 3, z * 3), B<3>(x * 4, y * 4, z * 4), _x(x * 5), + _y(y * 5), _z(z * 5) {} + + static int abc; + +private: + int _x; + short _y; + char _z; +}; +int C::abc = 123; +#pragma pack(pop) + +class List { +public: + List() = default; + List(List *p, List *n, C v) : Prev(p), Next(n), Value(v) {} + +private: + List *Prev = nullptr; + List *Next = nullptr; + C Value{1, 2, 3}; +}; + +int main() { + List ls[16]; + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.script b/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.script new file mode 100644 index 000000000000..91de55f4ade4 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/UdtLayoutTest.script @@ -0,0 +1,4 @@ +breakpoint set --file UdtLayoutTest.cpp --line 60 +run +target variable +frame variable diff --git a/lit/SymbolFile/PDB/Inputs/VBases.cpp b/lit/SymbolFile/PDB/Inputs/VBases.cpp new file mode 100644 index 000000000000..a5e84bd36571 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/VBases.cpp @@ -0,0 +1,16 @@ +struct A { + char a = 1; +}; + +struct B { + int b = 2; +}; + +struct C : virtual A, virtual B { + short c = 3; +}; + +int main() { + C c{}; + return 0; +} diff --git a/lit/SymbolFile/PDB/Inputs/VBases.script b/lit/SymbolFile/PDB/Inputs/VBases.script new file mode 100644 index 000000000000..8675890b76e1 --- /dev/null +++ b/lit/SymbolFile/PDB/Inputs/VBases.script @@ -0,0 +1,7 @@ +breakpoint set --file VBases.cpp --line 15 + +run + +print c + +frame variable c \ No newline at end of file diff --git a/lit/SymbolFile/PDB/ast-restore.test b/lit/SymbolFile/PDB/ast-restore.test new file mode 100644 index 000000000000..2158fc1b3d44 --- /dev/null +++ b/lit/SymbolFile/PDB/ast-restore.test @@ -0,0 +1,82 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/AstRestoreTest.cpp +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=GLOBAL %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=BASE %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=CLASS %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=INNER %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=TEMPLATE %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=FOO %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=MAIN %s + +ENUM: Module: {{.*}} +ENUM: namespace N0 { +ENUM: namespace N1 { +ENUM: namespace { +ENUM: enum Enum { +ENUM: Enum_0, +ENUM: Enum_1, +ENUM: Enum_2, +ENUM: Enum_3 +ENUM: }; +ENUM: } +ENUM: } +ENUM: } + +GLOBAL: Module: {{.*}} +GLOBAL: namespace N0 { +GLOBAL: namespace N1 { +GLOBAL: N0::N1::(anonymous namespace)::Enum Global; +GLOBAL: } +GLOBAL: } + +BASE: Module: {{.*}} +BASE: namespace N0 { +BASE: namespace N1 { +BASE: struct Base { +BASE: N0::N1::(anonymous namespace)::Enum m_e; +BASE: }; +BASE: } +BASE: } + +CLASS: Module: {{.*}} +CLASS: namespace N0 { +CLASS: namespace N1 { +CLASS: class Class : public N0::N1::Base { +CLASS-DAG: const N0::N1::(anonymous namespace)::Enum m_ce; +CLASS-DAG: static int ClassStatic; +CLASS-DAG: N0::N1::Class::Inner m_inner; +CLASS-DAG: {{(inline )?}}Class(N0::N1::(anonymous namespace)::Enum); +CLASS-DAG: static {{(inline )?}}int StaticFunc(const N0::N1::Class &); +CLASS-DAG: {{(inline )?}}int PrivateFunc(const N0::N1::Class::Inner &); +CLASS: }; +CLASS: } +CLASS: } + +INNER: Module: {{.*}} +INNER: namespace N0 { +INNER: namespace N1 { +INNER: class Class : public N0::N1::Base { +INNER: struct Inner { +INNER: char x; +INNER: short y; +INNER: int z; +INNER: }; +INNER: }; +INNER: } +INNER: } + +TEMPLATE: Module: {{.*}} +TEMPLATE: struct Template { +TEMPLATE: inline void TemplateFunc<1>(); +TEMPLATE: }; + +FOO: Module: {{.*}} +FOO: namespace N0 { +FOO: namespace N1 { +FOO: void foo(); +FOO: } +FOO: } + +MAIN: Module: {{.*}} +MAIN: int main(); diff --git a/lit/SymbolFile/PDB/calling-conventions.test b/lit/SymbolFile/PDB/calling-conventions.test new file mode 100644 index 000000000000..a85dc65ff04d --- /dev/null +++ b/lit/SymbolFile/PDB/calling-conventions.test @@ -0,0 +1,10 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe %S/Inputs/CallingConventionsTest.cpp +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s + +CHECK: Module: {{.*}} +CHECK-DAG: int (*FuncCCallPtr)(); +CHECK-DAG: int (*FuncStdCallPtr)() __attribute__((stdcall)); +CHECK-DAG: int (*FuncFastCallPtr)() __attribute__((fastcall)); +CHECK-DAG: int (*FuncVectorCallPtr)() __attribute__((vectorcall)); +CHECK-DAG: int (S::*FuncThisCallPtr)() __attribute__((thiscall)); diff --git a/lit/SymbolFile/PDB/class-layout.test b/lit/SymbolFile/PDB/class-layout.test new file mode 100644 index 000000000000..5c0194485d76 --- /dev/null +++ b/lit/SymbolFile/PDB/class-layout.test @@ -0,0 +1,92 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/ClassLayoutTest.cpp.obj %S/Inputs/ClassLayoutTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/ClassLayoutTest.cpp.exe %T/ClassLayoutTest.cpp.obj +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNION %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=STRUCT %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=COMPLEX %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=LIST %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNNAMED-STRUCT %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=BASE %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=FRIEND %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=CLASS %s + +CHECK: Module [[MOD:.*]] +CHECK: {{^[0-9A-F]+}}: SymbolVendor pdb ([[MOD]]) +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\ClassLayoutTest.cpp' + +ENUM: name = "Enum", size = 4, decl = ClassLayoutTest.cpp:5 +ENUM-SAME: enum Enum { +ENUM: RED, +ENUM: GREEN, +ENUM: BLUE +ENUM:} + +UNION: name = "Union", size = 4, decl = ClassLayoutTest.cpp:9 +UNION-SAME: union Union { +UNION: short Row; +UNION: unsigned short Col; +UNION: int Line : 16; +UNION: long Table; +UNION:} + +STRUCT: name = "Struct", size = 64, decl = ClassLayoutTest.cpp:22 +STRUCT-SAME: struct Struct { +STRUCT: bool A; +STRUCT: unsigned char UCharVar; +STRUCT: unsigned int UIntVar; +STRUCT: long long LongLongVar; +STRUCT: Enum EnumVar; +STRUCT: int array[10]; +STRUCT:} + +COMPLEX: name = "Complex", size = 368, decl = ClassLayoutTest.cpp:33 +COMPLEX-SAME: struct Complex { +COMPLEX: _List *array[90]; +COMPLEX: int x; +COMPLEX: int a; +COMPLEX: float b; +COMPLEX:} + +LIST: name = "_List", size = 12, decl = ClassLayoutTest.cpp:45 +LIST-SAME: struct _List { +LIST: _List *current; +LIST: _List *previous; +LIST: _List *next; +LIST:} + +UNNAMED-STRUCT: name = "UnnamedStruct", size = 4, decl = ClassLayoutTest.cpp:52 +UNNAMED-STRUCT-SAME: struct UnnamedStruct { +UNNAMED-STRUCT: int a; +UNNAMED-STRUCT:} + +BASE: name = "Base", size = 4, decl = ClassLayoutTest.cpp:59 +BASE-SAME: class Base { +BASE: int a; +BASE: Base(); +BASE: ~Base(); +BASE: int Get(); +BASE:} + +FRIEND: name = "Friend", size = 1, decl = ClassLayoutTest.cpp:70 +FRIEND-SAME: class Friend { +FRIEND: int f(); +FRIEND: } + +CLASS: name = "Class", size = 88, decl = ClassLayoutTest.cpp:74 +CLASS-SAME: class Class : public MemberTest::Base { +CLASS: static int m_static; +CLASS: int m_public; +CLASS: Struct m_struct; +CLASS: Union m_union; +CLASS: int m_private; +CLASS: int m_protected; +CLASS: Class(); +CLASS: Class(int); +CLASS: ~Class(); +CLASS: static int {{.*}}StaticMemberFunc(int, ...); +CLASS: int Get(); +CLASS: int f(MemberTest::Friend); +CLASS: bool operator==(const MemberTest::Class &) +CLASS:} diff --git a/lit/SymbolFile/PDB/compilands.test b/lit/SymbolFile/PDB/compilands.test index 2e7b014fe966..d719ab7669d8 100644 --- a/lit/SymbolFile/PDB/compilands.test +++ b/lit/SymbolFile/PDB/compilands.test @@ -1,9 +1,11 @@ -REQUIRES: windows -RUN: clang-cl /Z7 %S/Inputs/CompilandsTest.cpp /o %T/CompilandsTest.cpp.exe -RUN: lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/CompilandsTest.cpp.obj %S/Inputs/CompilandsTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/CompilandsTest.cpp.exe %T/CompilandsTest.cpp.obj +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s ; Link default libraries CHECK: Module [[CU:.*]] -CHECK: {{^[0-9A-F]+}}: SymbolVendor ([[CU]]) +CHECK: {{^[0-9A-F]+}}: SymbolVendor pdb ([[CU]]) CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\CompilandsTest.cpp' diff --git a/lit/SymbolFile/PDB/enums-layout.test b/lit/SymbolFile/PDB/enums-layout.test index ce0b23f453be..79efb259663d 100644 --- a/lit/SymbolFile/PDB/enums-layout.test +++ b/lit/SymbolFile/PDB/enums-layout.test @@ -1,45 +1,45 @@ -REQUIRES: windows -RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.enums.obj -RUN: link %T/SimpleTypesTest.cpp.enums.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.enums.exe -RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck %s +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.enums.exe %S/Inputs/SimpleTypesTest.cpp +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CONST %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_EMPTY %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_UCHAR %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CLASS %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_STRUCT %s ; FIXME: PDB does not have information about scoped enumeration (Enum class) so the ; compiler type used is the same as the one for unscoped enumeration. -CHECK: Module [[CU:.*]] -CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[CU]]) -CHECK: Type{{.*}} , name = "Enum", size = 4, decl = SimpleTypesTest.cpp:19, compiler_type = {{.*}} enum Enum { -CHECK-NEXT: RED, -CHECK-NEXT: GREEN, -CHECK-NEXT: BLUE -CHECK-NEXT:} +ENUM: Type{{.*}} , name = "Enum", size = 4, decl = simpletypestest.cpp:19, compiler_type = {{.*}} enum Enum { +ENUM_NEXT: RED, +ENUM_NEXT: GREEN, +ENUM_NEXT: BLUE +ENUM_NEXT:} -CHECK: Type{{.*}} , name = "EnumConst", size = 4, decl = SimpleTypesTest.cpp:22, compiler_type = {{.*}} enum EnumConst { -CHECK-NEXT: LOW, -CHECK-NEXT: NORMAL, -CHECK-NEXT: HIGH -CHECK-NEXT:} +ENUM_CONST: Type{{.*}} , name = "EnumConst", size = 4, decl = simpletypestest.cpp:22, compiler_type = {{.*}} enum EnumConst { +ENUM_CONST-NEXT: LOW, +ENUM_CONST-NEXT: NORMAL, +ENUM_CONST-NEXT: HIGH +ENUM_CONST-NEXT:} -CHECK: Type{{.*}} , name = "EnumEmpty", size = 4, decl = SimpleTypesTest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { -CHECK-NEXT:} +ENUM_EMPTY: Type{{.*}} , name = "EnumEmpty", size = 4, decl = simpletypestest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { +ENUM_EMPTY-NEXT:} -CHECK: Type{{.*}} , name = "EnumUChar", size = 1, decl = SimpleTypesTest.cpp:28, compiler_type = {{.*}} enum EnumUChar { -CHECK-NEXT: ON, -CHECK-NEXT: OFF, -CHECK-NEXT: AUTO -CHECK-NEXT:} +ENUM_UCHAR: Type{{.*}} , name = "EnumUChar", size = 1, decl = simpletypestest.cpp:28, compiler_type = {{.*}} enum EnumUChar { +ENUM_UCHAR-NEXT: ON, +ENUM_UCHAR-NEXT: OFF, +ENUM_UCHAR-NEXT: AUTO +ENUM_UCHAR-NEXT:} ; Note that `enum EnumClass` is tested instead of `enum class EnumClass` -CHECK: Type{{.*}} , name = "EnumClass", size = 4, decl = SimpleTypesTest.cpp:32, compiler_type = {{.*}} enum EnumClass { -CHECK-NEXT: YES, -CHECK-NEXT: NO, -CHECK-NEXT: DEFAULT -CHECK-NEXT:} - -CHECK: Type{{.*}} , name = "EnumStruct", size = 4, decl = SimpleTypesTest.cpp:35, compiler_type = {{.*}} enum EnumStruct { -CHECK-NEXT: red, -CHECK-NEXT: blue, -CHECK-NEXT: black -CHECK-NEXT:} - -CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\SimpleTypesTest.cpp' +ENUM_CLASS: Type{{.*}} , name = "EnumClass", size = 4, decl = simpletypestest.cpp:32, compiler_type = {{.*}} enum EnumClass { +ENUM_CLASS-NEXT: YES, +ENUM_CLASS-NEXT: NO, +ENUM_CLASS-NEXT: DEFAULT +ENUM_CLASS-NEXT:} + +ENUM_STRUCT: Type{{.*}} , name = "EnumStruct", size = 4, decl = simpletypestest.cpp:35, compiler_type = {{.*}} enum EnumStruct { +ENUM_STRUCT-NEXT: red, +ENUM_STRUCT-NEXT: blue, +ENUM_STRUCT-NEXT: black +ENUM_STRUCT-NEXT:} diff --git a/lit/SymbolFile/PDB/expressions.test b/lit/SymbolFile/PDB/expressions.test new file mode 100644 index 000000000000..49016196117e --- /dev/null +++ b/lit/SymbolFile/PDB/expressions.test @@ -0,0 +1,35 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/ExpressionsTest.cpp +RUN: %lldb -b -s %S/Inputs/ExpressionsTest0.script -s %S/Inputs/ExpressionsTest1.script -s %S/Inputs/ExpressionsTest2.script -- %t.exe 2>&1 | FileCheck %s + +// Check the variable value through `print` +CHECK: (lldb) print result +CHECK: (char) $0 = '\x1c' + +// Call the function just like in the code +CHECK: (lldb) print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) +CHECK: (char) $1 = '\x1c' + +// Try the relaxed namespaces search +CHECK: (lldb) print N1::sum(N1::buf1, sizeof(N1::buf1)) +CHECK: (char) $2 = '\x1c' + +// Try the relaxed variables and functions search +CHECK: (lldb) print sum(buf1, sizeof(buf1)) +CHECK: (char) $3 = '\x1c' + +// Make a crash during expression calculation +CHECK: (lldb) print sum(buf1, 1000000000) +CHECK: The process has been returned to the state before expression evaluation. + +// Make one more crash +CHECK: (lldb) print sum(buf0, 1) +CHECK: The process has been returned to the state before expression evaluation. + +// Check if the process state was restored succesfully +CHECK: (lldb) print sum(buf0, result - 28) +CHECK: (char) $4 = '\0' + +// Call the function with arbitrary parameters +CHECK: (lldb) print sum(buf1 + 3, 3) +CHECK: (char) $5 = '\f' diff --git a/lit/SymbolFile/PDB/func-symbols.test b/lit/SymbolFile/PDB/func-symbols.test index b13ff7e65bb0..fbbf5ddfb856 100644 --- a/lit/SymbolFile/PDB/func-symbols.test +++ b/lit/SymbolFile/PDB/func-symbols.test @@ -1,7 +1,5 @@ -REQUIRES: windows -RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbolsTestMain.cpp /o %T/FuncSymbolsTestMain.cpp.obj -RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbols.cpp /o %T/FuncSymbols.cpp.obj -RUN: link %T/FuncSymbolsTestMain.cpp.obj %T/FuncSymbols.cpp.obj /DEBUG /nodefaultlib /Entry:main /OUT:%T/FuncSymbolsTest.exe +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%T/FuncSymbolsTest.exe %S/Inputs/FuncSymbolsTestMain.cpp %S/Inputs/FuncSymbols.cpp RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-ONE %s RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-TWO %s @@ -9,16 +7,16 @@ RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-T ; In this test, We don't check demangled name of a mangled function. CHECK-ONE: Module [[MD:.*]] -CHECK-ONE-DAG: {{.*}}: SymbolVendor ([[MD]]) +CHECK-ONE-DAG: {{.*}}: SymbolVendor pdb ([[MD]]) CHECK-ONE-DAG: [[TY0:.*]]: Type{[[UID0:.*]]} , name = "Func_arg_array", decl = FuncSymbolsTestMain.cpp:3, compiler_type = {{.*}} int (int *) CHECK-ONE-DAG: [[TY1:.*]]: Type{[[UID1:.*]]} , name = "Func_arg_void", decl = FuncSymbolsTestMain.cpp:4, compiler_type = {{.*}} void (void) CHECK-ONE-DAG: [[TY2:.*]]: Type{[[UID2:.*]]} , name = "Func_arg_none", decl = FuncSymbolsTestMain.cpp:5, compiler_type = {{.*}} void (void) CHECK-ONE-DAG: [[TY3:.*]]: Type{[[UID3:.*]]} , name = "Func_varargs", decl = FuncSymbolsTestMain.cpp:6, compiler_type = {{.*}} void (...) -CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "NS::Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (signed char, int) +CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (char, int) CHECK-ONE-DAG: [[TY5:.*]]: Type{[[UID5:.*]]} , name = "main", decl = FuncSymbolsTestMain.cpp:44, compiler_type = {{.*}} int (void) -CHECK-ONE-DAG: [[TY6:.*]]: Type{[[UID6:.*]]} , name = "`anonymous namespace'::Func", decl = FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...) +CHECK-ONE-DAG: [[TY6:.*]]: Type{[[UID6:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...) CHECK-ONE-DAG: [[TY7:.*]]: Type{[[UID7:.*]]} , name = "StaticFunction", decl = FuncSymbolsTestMain.cpp:35, compiler_type = {{.*}} long (int) -CHECK-ONE-DAG: [[TY8:.*]]: Type{[[UID8:.*]]} , name = "MemberTest::A::Func", decl = FuncSymbolsTestMain.cpp:12, compiler_type = {{.*}} int (int, ...) +CHECK-ONE-DAG: [[TY8:.*]]: Type{[[UID8:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:12, compiler_type = {{.*}} int (int, ...) CHECK-ONE-DAG: [[TY9:.*]]: Type{[[UID9:.*]]} , name = "TemplateFunc<1,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int) CHECK-ONE-DAG: [[TY10:.*]]: Type{[[UID10:.*]]} , name = "TemplateFunc<1,int,int,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int, int, int) CHECK-ONE-DAG: [[TY11:.*]]: Type{[[UID11:.*]]} , name = "InlinedFunction", decl = FuncSymbolsTestMain.cpp:40, compiler_type = {{.*}} void (long) @@ -39,7 +37,7 @@ CHECK-ONE-DAG: Function{[[UID11]]}, mangled = ?InlinedFunction@@YAXJ@Z, demangle ; We expect new types observed in another compile unit CHECK-TWO-DAG: [[TY30:.*]]: Type{[[UID30:.*]]} , name = "FunctionCall", decl = FuncSymbols.cpp:13, compiler_type = {{.*}} void (void) -CHECK-TWO-DAG: [[TY31:.*]]: Type{[[UID31:.*]]} , name = "`anonymous namespace'::StaticFunction", decl = FuncSymbols.cpp:4, compiler_type = {{.*}} long (int) +CHECK-TWO-DAG: [[TY31:.*]]: Type{[[UID31:.*]]} , name = "StaticFunction", decl = FuncSymbols.cpp:4, compiler_type = {{.*}} long (int) CHECK-TWO-DAG: [[TY32:.*]]: Type{[[UID32:.*]]} , name = "InlinedFunction", decl = FuncSymbols.cpp:10, compiler_type = {{.*}} int (long) CHECK-TWO: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp' diff --git a/lit/SymbolFile/PDB/function-level-linking.test b/lit/SymbolFile/PDB/function-level-linking.test index 9b28ec1ba217..37b2cbc761b8 100644 --- a/lit/SymbolFile/PDB/function-level-linking.test +++ b/lit/SymbolFile/PDB/function-level-linking.test @@ -1,4 +1,5 @@ -REQUIRES: windows, lld -RUN: clang-cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj +REQUIRES: system-windows, lld +RUN: %clang_cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj RUN: lld-link /debug:full /nodefaultlib /entry:main /order:@%S/Inputs/FunctionLevelLinkingTest.ord %t.obj /out:%t.exe -RUN: lldb-test symbols -verify %t.exe +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -verify %t.exe +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -verify %t.exe diff --git a/lit/SymbolFile/PDB/function-nested-block.test b/lit/SymbolFile/PDB/function-nested-block.test index 93543c681130..9057d01c2584 100644 --- a/lit/SymbolFile/PDB/function-nested-block.test +++ b/lit/SymbolFile/PDB/function-nested-block.test @@ -1,7 +1,11 @@ -REQUIRES: windows, lld -RUN: clang-cl /c /Zi %S/Inputs/FunctionNestedBlockTest.cpp /o %t.obj -RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe -RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck %s +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --nodefaultlib --output=%t.exe %S/Inputs/FunctionNestedBlockTest.cpp +RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s +RUN: lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s -CHECK: Found 1 functions: -CHECK: name = "{{.*}}", mangled = "{{_?}}main" +CHECK-FUNCTION: Found 1 functions: +CHECK-FUNCTION: name = "{{.*}}", mangled = "{{_?}}main" + +CHECK-BLOCK: Found 1 blocks: +CHECK-BLOCK: Blocks: id = {{.*}}, range = {{.*}} +CHECK-BLOCK: id = {{.*}}, range = {{.*}} diff --git a/lit/SymbolFile/PDB/lit.local.cfg b/lit/SymbolFile/PDB/lit.local.cfg deleted file mode 100644 index df9b335dd131..000000000000 --- a/lit/SymbolFile/PDB/lit.local.cfg +++ /dev/null @@ -1 +0,0 @@ -config.suffixes = ['.test'] diff --git a/lit/SymbolFile/PDB/pointers.test b/lit/SymbolFile/PDB/pointers.test new file mode 100644 index 000000000000..a8f84f14783d --- /dev/null +++ b/lit/SymbolFile/PDB/pointers.test @@ -0,0 +1,38 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/PointerTypeTest.cpp.obj %S/Inputs/PointerTypeTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/PointerTypeTest.cpp.exe %T/PointerTypeTest.cpp.obj +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST-F %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=F %s + +CHECK: Module [[MOD:.*]] +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\PointerTypeTest.cpp' + +MAIN-ST-F: name = "f" +MAIN-ST-F-SAME: decl = PointerTypeTest.cpp:8 +MAIN-ST-F-SAME: compiler_type = {{.*}} int (int) + +MAIN-ST: name = "ST", size = 4, decl = PointerTypeTest.cpp:6, compiler_type = {{.*}} struct ST { +MAIN-ST-NEXT: int a; +MAIN-ST-NEXT: int {{.*}}f(int); +MAIN-ST-NEXT:} + +MAIN: Function{[[FID1:.*]]}, mangled = _main +MAIN-NEXT: Block{[[FID1]]} +MAIN: Variable{{.*}}, name = "array_pointer" +MAIN-SAME: (int (*)[2][4]), scope = local +MAIN: Variable{{.*}}, name = "p_int" +MAIN-SAME: (int *), scope = local +MAIN: Variable{{.*}}, name = "p_member_field" +MAIN-SAME: (int ST::*), scope = local +MAIN: Variable{{.*}}, name = "p_member_method" +MAIN-SAME: (int (ST::*)(int) __attribute__((thiscall))), scope = local + +F: Function{[[FID2:.*]]}, demangled = {{.*}}f(int) +F-NEXT: Block{[[FID2]]} +F: Variable{{.*}}, name = "this" +F-SAME: (ST *), scope = parameter, location = {{.*}}, artificial +F: Variable{{.*}}, name = "x" +F-SAME: (int), scope = parameter, decl = PointerTypeTest.cpp:8 diff --git a/lit/SymbolFile/PDB/type-quals.test b/lit/SymbolFile/PDB/type-quals.test index fbe10c0d8d64..734509f78345 100644 --- a/lit/SymbolFile/PDB/type-quals.test +++ b/lit/SymbolFile/PDB/type-quals.test @@ -1,39 +1,39 @@ -REQUIRES: windows -RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/TypeQualsTest.cpp /o %T/TypeQualsTest.cpp.obj -RUN: link %T/TypeQualsTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/TypeQualsTest.cpp.exe +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/TypeQualsTest.cpp.obj %S/Inputs/TypeQualsTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/TypeQualsTest.cpp.exe %T/TypeQualsTest.cpp.obj RUN: lldb-test symbols %T/TypeQualsTest.cpp.exe | FileCheck %s CHECK: Module [[MOD:.*]] -CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor ([[MOD]]) -CHECK: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * -CHECK: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) - -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * -CHECK: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) - -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int * -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int & -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int && -CHECK: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) +CHECK-DAG: {{^[0-9A-F]+}}: SymbolVendor pdb ([[MOD]]) +CHECK-DAG: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * +CHECK-DAG: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * +CHECK-DAG: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int && +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & +CHECK-DAG: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) // FIXME: __unaligned is not supported. -CHECK: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) +CHECK-DAG: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict -CHECK: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict +CHECK-DAG: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) -CHECK: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) +CHECK-DAG: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) -CHECK: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] -CHECK: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] +CHECK-DAG: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] +CHECK-DAG: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] -CHECK: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\TypeQualsTest.cpp' diff --git a/lit/SymbolFile/PDB/typedefs.test b/lit/SymbolFile/PDB/typedefs.test index 659ef6392d1c..caf23a8c1664 100644 --- a/lit/SymbolFile/PDB/typedefs.test +++ b/lit/SymbolFile/PDB/typedefs.test @@ -1,6 +1,5 @@ -REQUIRES: windows -RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.typedefs.obj -RUN: link %T/SimpleTypesTest.cpp.typedefs.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.typedefs.exe +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.typedefs.exe %S/Inputs/SimpleTypesTest.cpp RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s ; Generate 32-bit target @@ -13,7 +12,7 @@ RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s ; both of them is the same. CHECK: Module [[MOD:.*]] -CHECK: {{^[0-9A-F]+}}: SymbolVendor ([[MOD]]) +CHECK: {{^[0-9A-F]+}}: SymbolVendor pdb ([[MOD]]) CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = {{.*}} unsigned long @@ -46,9 +45,10 @@ CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void * CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = {{.*}} unsigned short CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = {{.*}} unsigned int +CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} signed char -CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} signed char (void *, long, unsigned short, unsigned int, ...) -CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} signed char (*)(void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, long, unsigned short, unsigned int, ...) CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} typedef VarArgsFuncTypedef CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float diff --git a/lit/SymbolFile/PDB/udt-layout.test b/lit/SymbolFile/PDB/udt-layout.test new file mode 100644 index 000000000000..726f633efe5b --- /dev/null +++ b/lit/SymbolFile/PDB/udt-layout.test @@ -0,0 +1,51 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp +RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s + +CHECK:(int) int C::abc = 123 +CHECK:(List [16]) ls = { +CHECK: [15] = { +CHECK: Prev = 0x00000000 +CHECK: Next = 0x00000000 +CHECK: Value = { +CHECK: B<0> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x01' +CHECK: _b = 2 +CHECK: _c = 3 +CHECK: } +CHECK: B<1> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x02' +CHECK: _b = 4 +CHECK: _c = 6 +CHECK: } +CHECK: B<2> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x03' +CHECK: _b = 6 +CHECK: _c = 9 +CHECK: } +CHECK: B<3> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x04' +CHECK: _b = 8 +CHECK: _c = 12 +CHECK: } +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _x = 5 +CHECK: _y = 10 +CHECK: _z = '\x0f' +CHECK: } +CHECK: } +CHECK:} diff --git a/lit/SymbolFile/PDB/variables-locations.test b/lit/SymbolFile/PDB/variables-locations.test index b70339fa23ac..7696dc92cee8 100644 --- a/lit/SymbolFile/PDB/variables-locations.test +++ b/lit/SymbolFile/PDB/variables-locations.test @@ -1,6 +1,6 @@ -REQUIRES: windows -RUN: clang-cl /Zi %S/Inputs/VariablesLocationsTest.cpp /o %t.exe -RUN: %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/VariablesLocationsTest.cpp +RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s CHECK: g_var = 2222 diff --git a/lit/SymbolFile/PDB/variables.test b/lit/SymbolFile/PDB/variables.test index 6d37cd975b45..2e9b59471091 100644 --- a/lit/SymbolFile/PDB/variables.test +++ b/lit/SymbolFile/PDB/variables.test @@ -1,58 +1,66 @@ -REQUIRES: windows -RUN: clang-cl /Z7 /c /GS- %S/Inputs/VariablesTest.cpp /o %T/VariablesTest.cpp.obj -RUN: link %T/VariablesTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/VariablesTest.cpp.exe -RUN: lldb-test symbols %T/VariablesTest.cpp.exe | FileCheck %s +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=64 --nodefaultlib --output=%T/VariablesTest.cpp.obj %S/Inputs/VariablesTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=64 --nodefaultlib --output=%T/VariablesTest.cpp.exe %T/VariablesTest.cpp.obj +RUN: lldb-test symbols %T/VariablesTest.cpp.exe > %T/VariablesTest.out +RUN: FileCheck --check-prefix=GLOBALS --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-F --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-MAIN --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-CONSTRUCTOR --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-MEMBER --input-file=%T/VariablesTest.out %s -CHECK: Module [[MOD:.*]] -CHECK: SymbolVendor ([[MOD]]) -CHECK: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\VariablesTest.cpp' -CHECK-DAG: Variable{{.*}}, name = "g_IntVar" -CHECK-SAME: scope = global, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "m_StaticClassMember" -CHECK-SAME: scope = global, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "g_pConst" -CHECK-SAME: scope = global, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "same_name_var" -CHECK-SAME: scope = global, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "g_EnumVar" -CHECK-SAME: scope = global, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "g_tls" -CHECK-SAME: scope = thread local, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "ClassVar" -CHECK-SAME: scope = global, location = {{.*}}, external -CHECK-DAG: Variable{{.*}}, name = "g_Const" -CHECK-SAME: scope = ??? (2) +GLOBALS: Module [[MOD:.*]] +GLOBALS: SymbolVendor pdb ([[MOD]]) +GLOBALS: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\VariablesTest.cpp' +GLOBALS-DAG: Variable{{.*}}, name = "g_IntVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "m_StaticClassMember" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_pConst" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "same_name_var" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_EnumVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_tls" +GLOBALS-SAME: scope = thread local, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "ClassVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_Const" +GLOBALS-SAME: scope = ??? (2) +GLOBALS: Function -CHECK-DAG: Function{[[FID1:.*]]}, mangled = ?f@@YAHHH@Z -CHECK-NEXT: Block{[[FID1]]} -CHECK-DAG: Variable{{.*}}, name = "var_arg1" -CHECK-SAME: scope = parameter -CHECK-DAG: Variable{{.*}}, name = "var_arg2" -CHECK-SAME: scope = parameter -CHECK-DAG: Variable{{.*}}, name = "same_name_var" -CHECK-SAME: scope = local +FUNC-F: Function{{.*}}, mangled = ?f@@YAHHH@Z +FUNC-F-NEXT: Block +FUNC-F-NEXT: Variable{{.*}}, name = "var_arg1" +FUNC-F-SAME: scope = parameter +FUNC-F-NEXT: Variable{{.*}}, name = "var_arg2" +FUNC-F-SAME: scope = parameter +FUNC-F-NEXT: Variable{{.*}}, name = "same_name_var" +FUNC-F-SAME: scope = local -CHECK-DAG: Function{[[FID2:.*]]}, mangled = main -CHECK-NEXT: Block{[[FID2]]} -CHECK-DAG: Variable{{.*}}, name = "same_name_var" -CHECK-SAME: scope = local -CHECK-DAG: Variable{{.*}}, name = "local_const" -CHECK-SAME: scope = local -CHECK-DAG: Variable{{.*}}, name = "local_pCString" -CHECK-SAME: scope = local -CHECK-DAG: Variable{{.*}}, name = "a" -CHECK-SAME: scope = local +FUNC-MAIN: Function{{.*}}, mangled = main +FUNC-MAIN-NEXT: Block +FUNC-MAIN-NEXT: Variable{{.*}}, name = "same_name_var" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_const" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_CString" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_pCString" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "a" +FUNC-MAIN-SAME: scope = local -CHECK-DAG: Function{[[FID3:.*]]}, mangled = ??0Class@@QEAA@H@Z -CHECK-NEXT: Block{[[FID3]]} -CHECK-DAG: Variable{{.*}}, name = "this" -CHECK-SAME: scope = parameter -CHECK-SAME: artificial -CHECK-DAG: Variable{{.*}}, name = "a" -CHECK-SAME: scope = parameter +FUNC-CONSTRUCTOR: Function{{.*}}, mangled = ??0Class@@QEAA@H@Z +FUNC-CONSTRUCTOR-NEXT: Block +FUNC-CONSTRUCTOR-NEXT: Variable{{.*}}, name = "this" +FUNC-CONSTRUCTOR-SAME: scope = parameter +FUNC-CONSTRUCTOR-SAME: artificial +FUNC-CONSTRUCTOR-NEXT: Variable{{.*}}, name = "a" +FUNC-CONSTRUCTOR-SAME: scope = parameter -CHECK-DAG: Function{[[FID4:.*]]}, mangled = ?Func@Class@@QEAAXXZ -CHECK-NEXT: Block{[[FID4]]} -CHECK-DAG: Variable{{.*}}, name = "this" -CHECK-SAME: scope = parameter -CHECK-SAME: artificial \ No newline at end of file +FUNC-MEMBER: Function{{.*}}, mangled = ?Func@Class@@QEAAXXZ +FUNC-MEMBER-NEXT: Block +FUNC-MEMBER-NEXT: Variable{{.*}}, name = "this" +FUNC-MEMBER-SAME: scope = parameter +FUNC-MEMBER-SAME: artificial diff --git a/lit/SymbolFile/PDB/vbases.test b/lit/SymbolFile/PDB/vbases.test new file mode 100644 index 000000000000..57239e07c87d --- /dev/null +++ b/lit/SymbolFile/PDB/vbases.test @@ -0,0 +1,15 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/VBases.cpp +RUN: %lldb -b -s %S/Inputs/VBases.script -- %t.exe | FileCheck %s + +CHECK: { +CHECK: A = (a = '\x01') +CHECK: B = (b = 2) +CHECK: c = 3 +CHECK: } + +CHECK: { +CHECK: A = (a = '\x01') +CHECK: B = (b = 2) +CHECK: c = 3 +CHECK: } diff --git a/lit/Unit/lit.cfg b/lit/Unit/lit.cfg.py similarity index 56% rename from lit/Unit/lit.cfg rename to lit/Unit/lit.cfg.py index 338adfd7bd9a..3633c73a1d40 100644 --- a/lit/Unit/lit.cfg +++ b/lit/Unit/lit.cfg.py @@ -3,8 +3,10 @@ # Configuration file for the 'lit' test runner. import os +import sys import lit.formats +from lit.llvm import llvm_config # name: The name of this test suite. config.name = 'lldb-Unit' @@ -17,5 +19,12 @@ config.test_source_root = os.path.join(config.lldb_obj_root, 'unittests') config.test_exec_root = config.test_source_root +# One of our unit tests dynamically links against python.dll, and on Windows +# it needs to be able to find it at runtime. This is fine if Python is on your +# system PATH, but if it's not, then this unit test executable will fail to run. +# We can solve this by forcing the Python directory onto the system path here. +llvm_config.with_system_environment('PATH') +llvm_config.with_environment('PATH', os.path.dirname(sys.executable), append_path=True) + # testFormat: The test format to use to interpret tests. config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests') diff --git a/lit/Unit/lit.site.cfg.in b/lit/Unit/lit.site.cfg.py.in similarity index 90% rename from lit/Unit/lit.site.cfg.in rename to lit/Unit/lit.site.cfg.py.in index 9c43172e61e0..0c629fdfaa56 100644 --- a/lit/Unit/lit.site.cfg.in +++ b/lit/Unit/lit.site.cfg.py.in @@ -1,6 +1,6 @@ @LIT_SITE_CFG_IN_HEADER@ -config.test_exec_root = "@LLVM_BINARY_DIR@" +config.test_exec_root = "@LLDB_BINARY_DIR@" config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" @@ -22,5 +22,8 @@ except KeyError as e: key, = e.args lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) +import lit.llvm +lit.llvm.initialize(lit_config, config) + # Let the main config do the real work. -lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Unit/lit.cfg") +lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Unit/lit.cfg.py") diff --git a/lit/helper/__init__.py b/lit/helper/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lit/helper/build.py b/lit/helper/build.py new file mode 100755 index 000000000000..26f321d709f8 --- /dev/null +++ b/lit/helper/build.py @@ -0,0 +1,787 @@ +#! /usr/bin/env python + +from __future__ import print_function + +import argparse +import os +import signal +import subprocess +import sys + +if sys.platform == 'win32': + # This module was renamed in Python 3. Make sure to import it using a + # consistent name regardless of python version. + try: + import winreg + except: + import _winreg as winreg + +if __name__ != "__main__": + raise RuntimeError("Do not import this script, run it instead") + + +parser = argparse.ArgumentParser(description='LLDB compilation wrapper') +parser.add_argument('--arch', + metavar='arch', + dest='arch', + required=True, + default='host', + choices=['32', '64', 'host'], + help='Specify the architecture to target.') + +parser.add_argument('--compiler', + metavar='compiler', + dest='compiler', + required=True, + help='Path to a compiler executable, or one of the values [any, msvc, clang-cl, gcc, clang]') + +parser.add_argument('--tools-dir', + metavar='directory', + dest='tools_dir', + required=False, + action='append', + help='If specified, a path to search in addition to PATH when --compiler is not an exact path') + +if sys.platform == 'darwin': + parser.add_argument('--apple-sdk', + metavar='apple_sdk', + dest='apple_sdk', + default="macosx", + help='Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK\'s toolchain.') + +parser.add_argument('--output', '-o', + dest='output', + metavar='file', + required=False, + default='', + help='Path to output file') + +parser.add_argument('--outdir', '-d', + dest='outdir', + metavar='directory', + required=False, + help='Directory for output files') + +parser.add_argument('--nodefaultlib', + dest='nodefaultlib', + action='store_true', + default=False, + help='When specified, the resulting image should not link against system libraries or include system headers. Useful when writing cross-targeting tests.') + +parser.add_argument('--opt', + dest='opt', + default='none', + choices=['none', 'basic', 'lto'], + help='Optimization level') + +parser.add_argument('--mode', + dest='mode', + default='compile-and-link', + choices=['compile', 'link', 'compile-and-link'], + help='Specifies whether to compile, link, or both') + +parser.add_argument('--noclean', + dest='clean', + action='store_false', + default=True, + help='Dont clean output file before building') + +parser.add_argument('--verbose', + dest='verbose', + action='store_true', + default=False, + help='Print verbose output') + +parser.add_argument('-n', '--dry-run', + dest='dry', + action='store_true', + default=False, + help='Print the commands that would run, but dont actually run them') + +parser.add_argument('inputs', + metavar='file', + nargs='+', + help='Source file(s) to compile / object file(s) to link') + + +args = parser.parse_args(args=sys.argv[1:]) + + +def to_string(b): + """Return the parameter as type 'str', possibly encoding it. + + In Python2, the 'str' type is the same as 'bytes'. In Python3, the + 'str' type is (essentially) Python2's 'unicode' type, and 'bytes' is + distinct. + + This function is copied from llvm/utils/lit/lit/util.py + """ + if isinstance(b, str): + # In Python2, this branch is taken for types 'str' and 'bytes'. + # In Python3, this branch is taken only for 'str'. + return b + if isinstance(b, bytes): + # In Python2, this branch is never taken ('bytes' is handled as 'str'). + # In Python3, this is true only for 'bytes'. + try: + return b.decode('utf-8') + except UnicodeDecodeError: + # If the value is not valid Unicode, return the default + # repr-line encoding. + return str(b) + + # By this point, here's what we *don't* have: + # + # - In Python2: + # - 'str' or 'bytes' (1st branch above) + # - In Python3: + # - 'str' (1st branch above) + # - 'bytes' (2nd branch above) + # + # The last type we might expect is the Python2 'unicode' type. There is no + # 'unicode' type in Python3 (all the Python3 cases were already handled). In + # order to get a 'str' object, we need to encode the 'unicode' object. + try: + return b.encode('utf-8') + except AttributeError: + raise TypeError('not sure how to convert %s to %s' % (type(b), str)) + +def format_text(lines, indent_0, indent_n): + result = ' ' * indent_0 + lines[0] + for next in lines[1:]: + result = result + '\n{0}{1}'.format(' ' * indent_n, next) + return result + +def print_environment(env): + if env is None: + print(' Inherited') + return + for e in env: + value = env[e] + lines = value.split(os.pathsep) + formatted_value = format_text(lines, 0, 7 + len(e)) + print(' {0} = {1}'.format(e, formatted_value)) + +def find_executable(binary_name, search_paths): + if sys.platform == 'win32': + binary_name = binary_name + '.exe' + + search_paths = os.pathsep.join(search_paths) + paths = search_paths + os.pathsep + os.environ.get('PATH', '') + for path in paths.split(os.pathsep): + p = os.path.join(path, binary_name) + if os.path.exists(p) and not os.path.isdir(p): + return os.path.normpath(p) + return None + +def find_toolchain(compiler, tools_dir): + if compiler == 'msvc': + return ('msvc', find_executable('cl', tools_dir)) + if compiler == 'clang-cl': + return ('clang-cl', find_executable('clang-cl', tools_dir)) + if compiler == 'gcc': + return ('gcc', find_executable('g++', tools_dir)) + if compiler == 'clang': + return ('clang', find_executable('clang++', tools_dir)) + if compiler == 'any': + priorities = [] + if sys.platform == 'win32': + priorities = ['clang-cl', 'msvc', 'clang', 'gcc'] + else: + priorities = ['clang', 'gcc', 'clang-cl'] + for toolchain in priorities: + (type, dir) = find_toolchain(toolchain, tools_dir) + if type and dir: + return (type, dir) + # Could not find any toolchain. + return (None, None) + + # From here on, assume that |compiler| is a path to a file. + file = os.path.basename(compiler) + name, ext = os.path.splitext(file) + if file.lower() == 'cl.exe': + return 'msvc' + if name == 'clang-cl': + return 'clang-cl' + if name.startswith('clang'): + return 'clang' + if name.startswith('gcc') or name.startswith('g++'): + return 'gcc' + if name == 'cc' or name == 'c++': + return 'generic' + return 'unknown' + +class Builder(object): + def __init__(self, toolchain_type, args, obj_ext): + self.toolchain_type = toolchain_type + self.inputs = args.inputs + self.arch = args.arch + self.opt = args.opt + self.outdir = args.outdir + self.compiler = args.compiler + self.clean = args.clean + self.output = args.output + self.mode = args.mode + self.nodefaultlib = args.nodefaultlib + self.verbose = args.verbose + self.obj_ext = obj_ext + + def _exe_file_name(self): + assert self.mode != 'compile' + return self.output + + def _output_name(self, input, extension, with_executable=False): + basename = os.path.splitext(os.path.basename(input))[0] + extension + if with_executable: + exe_basename = os.path.basename(self._exe_file_name()) + basename = exe_basename + '-' + basename + + output = os.path.join(self.outdir, basename) + return os.path.normpath(output) + + def _obj_file_names(self): + if self.mode == 'link': + return self.inputs + + if self.mode == 'compile-and-link': + # Object file names should factor in both the input file (source) + # name and output file (executable) name, to ensure that two tests + # which share a common source file don't race to write the same + # object file. + return [self._output_name(x, self.obj_ext, True) for x in self.inputs] + + if self.mode == 'compile' and self.output: + return [self.output] + + return [self._output_name(x, self.obj_ext) for x in self.inputs] + + def build_commands(self): + commands = [] + if self.mode == 'compile' or self.mode == 'compile-and-link': + for input, output in zip(self.inputs, self._obj_file_names()): + commands.append(self._get_compilation_command(input, output)) + if self.mode == 'link' or self.mode == 'compile-and-link': + commands.append(self._get_link_command()) + return commands + + +class MsvcBuilder(Builder): + def __init__(self, toolchain_type, args): + Builder.__init__(self, toolchain_type, args, '.obj') + + self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64' + + if toolchain_type == 'msvc': + # Make sure we're using the appropriate toolchain for the desired + # target type. + compiler_parent_dir = os.path.dirname(self.compiler) + selected_target_version = os.path.basename(compiler_parent_dir) + if selected_target_version != self.msvc_arch_str: + host_dir = os.path.dirname(compiler_parent_dir) + self.compiler = os.path.join(host_dir, self.msvc_arch_str, 'cl.exe') + if self.verbose: + print('Using alternate compiler "{0}" to match selected target.'.format(self.compiler)) + + if self.mode == 'link' or self.mode == 'compile-and-link': + self.linker = self._find_linker('link') if toolchain_type == 'msvc' else self._find_linker('lld-link') + if not self.linker: + raise ValueError('Unable to find an appropriate linker.') + + self.compile_env, self.link_env = self._get_visual_studio_environment() + + def _find_linker(self, name): + if sys.platform == 'win32': + name = name + '.exe' + compiler_dir = os.path.dirname(self.compiler) + linker_path = os.path.join(compiler_dir, name) + if not os.path.exists(linker_path): + raise ValueError('Could not find \'{}\''.format(linker_path)) + return linker_path + + def _get_vc_install_dir(self): + dir = os.getenv('VCINSTALLDIR', None) + if dir: + if self.verbose: + print('Using %VCINSTALLDIR% {}'.format(dir)) + return dir + + dir = os.getenv('VSINSTALLDIR', None) + if dir: + if self.verbose: + print('Using %VSINSTALLDIR% {}'.format(dir)) + return os.path.join(dir, 'VC') + + dir = os.getenv('VS2019INSTALLDIR', None) + if dir: + if self.verbose: + print('Using %VS2019INSTALLDIR% {}'.format(dir)) + return os.path.join(dir, 'VC') + + dir = os.getenv('VS2017INSTALLDIR', None) + if dir: + if self.verbose: + print('Using %VS2017INSTALLDIR% {}'.format(dir)) + return os.path.join(dir, 'VC') + + dir = os.getenv('VS2015INSTALLDIR', None) + if dir: + if self.verbose: + print('Using %VS2015INSTALLDIR% {}'.format(dir)) + return os.path.join(dir, 'VC') + return None + + def _get_vctools_version(self): + ver = os.getenv('VCToolsVersion', None) + if ver: + if self.verbose: + print('Using %VCToolsVersion% {}'.format(ver)) + return ver + + vcinstalldir = self._get_vc_install_dir() + vcinstalldir = os.path.join(vcinstalldir, 'Tools', 'MSVC') + subdirs = next(os.walk(vcinstalldir))[1] + if not subdirs: + return None + + from distutils.version import StrictVersion + subdirs.sort(key=lambda x : StrictVersion(x)) + + if self.verbose: + full_path = os.path.join(vcinstalldir, subdirs[-1]) + print('Using VC tools version directory {0} found by directory walk.'.format(full_path)) + return subdirs[-1] + + def _get_vctools_install_dir(self): + dir = os.getenv('VCToolsInstallDir', None) + if dir: + if self.verbose: + print('Using %VCToolsInstallDir% {}'.format(dir)) + return dir + + vcinstalldir = self._get_vc_install_dir() + if not vcinstalldir: + return None + vctoolsver = self._get_vctools_version() + if not vctoolsver: + return None + result = os.path.join(vcinstalldir, 'Tools', 'MSVC', vctoolsver) + if not os.path.exists(result): + return None + if self.verbose: + print('Using VC tools install dir {} found by directory walk'.format(result)) + return result + + def _find_windows_sdk_in_registry_view(self, view): + products_key = None + roots_key = None + installed_options_keys = [] + try: + sam = view | winreg.KEY_READ + products_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, + r'Software\Microsoft\Windows Kits\Installed Products', + 0, + sam) + + # This is the GUID for the desktop component. If this is present + # then the components required for the Desktop SDK are installed. + # If not it will throw an exception. + winreg.QueryValueEx(products_key, '{5A3D81EC-D870-9ECF-D997-24BDA6644752}') + + roots_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, + r'Software\Microsoft\Windows Kits\Installed Roots', + 0, + sam) + root_dir = winreg.QueryValueEx(roots_key, 'KitsRoot10') + root_dir = to_string(root_dir[0]) + sdk_versions = [] + index = 0 + while True: + # Installed SDK versions are stored as sub-keys of the + # 'Installed Roots' key. Find all of their names, then sort + # them by version + try: + ver_key = winreg.EnumKey(roots_key, index) + sdk_versions.append(ver_key) + index = index + 1 + except WindowsError: + break + if not sdk_versions: + return (None, None) + + # Windows SDK version numbers consist of 4 dotted components, so we + # have to use LooseVersion, as StrictVersion supports 3 or fewer. + from distutils.version import LooseVersion + sdk_versions.sort(key=lambda x : LooseVersion(x), reverse=True) + option_value_name = 'OptionId.DesktopCPP' + self.msvc_arch_str + for v in sdk_versions: + try: + version_subkey = v + r'\Installed Options' + key = winreg.OpenKey(roots_key, version_subkey) + installed_options_keys.append(key) + (value, value_type) = winreg.QueryValueEx(key, option_value_name) + if value == 1: + # The proper architecture is installed. Return the + # associated paths. + if self.verbose: + print('Found Installed Windows SDK v{0} at {1}'.format(v, root_dir)) + return (root_dir, v) + except: + continue + except: + return (None, None) + finally: + del products_key + del roots_key + for k in installed_options_keys: + del k + return (None, None) + + def _find_windows_sdk_in_registry(self): + # This could be a clang-cl cross-compile. If so, there's no registry + # so just exit. + if sys.platform != 'win32': + return (None, None) + if self.verbose: + print('Looking for Windows SDK in 64-bit registry.') + dir, ver = self._find_windows_sdk_in_registry_view(winreg.KEY_WOW64_64KEY) + if not dir or not ver: + if self.verbose: + print('Looking for Windows SDK in 32-bit registry.') + dir, ver = self._find_windows_sdk_in_registry_view(winreg.KEY_WOW64_32KEY) + + return (dir, ver) + + def _get_winsdk_dir(self): + # If a Windows SDK is specified in the environment, use that. Otherwise + # try to find one in the Windows registry. + dir = os.getenv('WindowsSdkDir', None) + if not dir or not os.path.exists(dir): + return self._find_windows_sdk_in_registry() + ver = os.getenv('WindowsSDKLibVersion', None) + if not ver: + return self._find_windows_sdk_in_registry() + + ver = ver.rstrip('\\') + if self.verbose: + print('Using %WindowsSdkDir% {}'.format(dir)) + print('Using %WindowsSDKLibVersion% {}'.format(ver)) + return (dir, ver) + + def _get_msvc_native_toolchain_dir(self): + assert self.toolchain_type == 'msvc' + compiler_dir = os.path.dirname(self.compiler) + target_dir = os.path.dirname(compiler_dir) + host_name = os.path.basename(target_dir) + host_name = host_name[4:].lower() + return os.path.join(target_dir, host_name) + + def _get_visual_studio_environment(self): + vctools = self._get_vctools_install_dir() + winsdk, winsdkver = self._get_winsdk_dir() + + if not vctools and self.verbose: + print('Unable to find VC tools installation directory.') + if (not winsdk or not winsdkver) and self.verbose: + print('Unable to find Windows SDK directory.') + + vcincludes = [] + vclibs = [] + sdkincludes = [] + sdklibs = [] + if vctools is not None: + includes = [['ATLMFC', 'include'], ['include']] + libs = [['ATLMFC', 'lib'], ['lib']] + vcincludes = [os.path.join(vctools, *y) for y in includes] + vclibs = [os.path.join(vctools, *y) for y in libs] + if winsdk is not None: + includes = [['include', winsdkver, 'ucrt'], + ['include', winsdkver, 'shared'], + ['include', winsdkver, 'um'], + ['include', winsdkver, 'winrt'], + ['include', winsdkver, 'cppwinrt']] + libs = [['lib', winsdkver, 'ucrt'], + ['lib', winsdkver, 'um']] + sdkincludes = [os.path.join(winsdk, *y) for y in includes] + sdklibs = [os.path.join(winsdk, *y) for y in libs] + + includes = vcincludes + sdkincludes + libs = vclibs + sdklibs + libs = [os.path.join(x, self.msvc_arch_str) for x in libs] + compileenv = None + linkenv = None + defaultenv = {} + if sys.platform == 'win32': + defaultenv = { x : os.environ[x] for x in + ['SystemDrive', 'SystemRoot', 'TMP', 'TEMP'] } + # The directory to mspdbcore.dll needs to be in PATH, but this is + # always in the native toolchain path, not the cross-toolchain + # path. So, for example, if we're using HostX64\x86 then we need + # to add HostX64\x64 to the path, and if we're using HostX86\x64 + # then we need to add HostX86\x86 to the path. + if self.toolchain_type == 'msvc': + defaultenv['PATH'] = self._get_msvc_native_toolchain_dir() + + if includes: + compileenv = {} + compileenv['INCLUDE'] = os.pathsep.join(includes) + compileenv.update(defaultenv) + if libs: + linkenv = {} + linkenv['LIB'] = os.pathsep.join(libs) + linkenv.update(defaultenv) + return (compileenv, linkenv) + + def _ilk_file_names(self): + if self.mode == 'link': + return [] + + return [self._output_name(x, '.ilk') for x in self.inputs] + + def _pdb_file_name(self): + if self.mode == 'compile': + return None + return os.path.splitext(self.output)[0] + '.pdb' + + def _get_compilation_command(self, source, obj): + args = [] + + args.append(self.compiler) + if self.toolchain_type == 'clang-cl': + args.append('-m' + self.arch) + + if self.opt == 'none': + args.append('/Od') + elif self.opt == 'basic': + args.append('/O2') + elif self.opt == 'lto': + if self.toolchain_type == 'msvc': + args.append('/GL') + args.append('/Gw') + else: + args.append('-flto=thin') + if self.nodefaultlib: + args.append('/GS-') + args.append('/GR-') + args.append('/Z7') + if self.toolchain_type == 'clang-cl': + args.append('-Xclang') + args.append('-fkeep-static-consts') + args.append('/c') + + args.append('/Fo' + obj) + args.append(source) + + return ('compiling', [source], obj, + self.compile_env, + args) + + def _get_link_command(self): + args = [] + args.append(self.linker) + args.append('/DEBUG:FULL') + args.append('/INCREMENTAL:NO') + if self.nodefaultlib: + args.append('/nodefaultlib') + args.append('/entry:main') + args.append('/PDB:' + self._pdb_file_name()) + args.append('/OUT:' + self._exe_file_name()) + args.extend(self._obj_file_names()) + + return ('linking', self._obj_file_names(), self._exe_file_name(), + self.link_env, + args) + + def build_commands(self): + commands = [] + if self.mode == 'compile' or self.mode == 'compile-and-link': + for input, output in zip(self.inputs, self._obj_file_names()): + commands.append(self._get_compilation_command(input, output)) + if self.mode == 'link' or self.mode == 'compile-and-link': + commands.append(self._get_link_command()) + return commands + + def output_files(self): + outputs = [] + if self.mode == 'compile' or self.mode == 'compile-and-link': + outputs.extend(self._ilk_file_names()) + outputs.extend(self._obj_file_names()) + if self.mode == 'link' or self.mode == 'compile-and-link': + outputs.append(self._pdb_file_name()) + outputs.append(self._exe_file_name()) + + return [x for x in outputs if x is not None] + +class GccBuilder(Builder): + def __init__(self, toolchain_type, args): + Builder.__init__(self, toolchain_type, args, '.o') + + def _get_compilation_command(self, source, obj): + args = [] + + args.append(self.compiler) + args.append('-m' + self.arch) + + args.append('-g') + if self.opt == 'none': + args.append('-O0') + elif self.opt == 'basic': + args.append('-O2') + elif self.opt == 'lto': + args.append('-flto=thin') + if self.nodefaultlib: + args.append('-nostdinc') + args.append('-static') + args.append('-c') + + args.extend(['-o', obj]) + args.append(source) + + return ('compiling', [source], obj, None, args) + + def _get_link_command(self): + args = [] + args.append(self.compiler) + args.append('-m' + self.arch) + if self.nodefaultlib: + args.append('-nostdlib') + args.append('-static') + main_symbol = 'main' + if sys.platform == 'darwin': + main_symbol = '_main' + args.append('-Wl,-e,' + main_symbol) + args.extend(['-o', self._exe_file_name()]) + args.extend(self._obj_file_names()) + + return ('linking', self._obj_file_names(), self._exe_file_name(), None, args) + + + def output_files(self): + outputs = [] + if self.mode == 'compile' or self.mode == 'compile-and-link': + outputs.extend(self._obj_file_names()) + if self.mode == 'link' or self.mode == 'compile-and-link': + outputs.append(self._exe_file_name()) + + return outputs + +def indent(text, spaces): + def prefixed_lines(): + prefix = ' ' * spaces + for line in text.splitlines(True): + yield prefix + line + return ''.join(prefixed_lines()) + +def build(commands): + global args + for (status, inputs, output, env, child_args) in commands: + print('\n\n') + inputs = [os.path.basename(x) for x in inputs] + output = os.path.basename(output) + print(status + ' {0} -> {1}'.format('+'.join(inputs), output)) + + if args.verbose: + print(' Command Line: ' + ' '.join(child_args)) + print(' Env:') + print_environment(env) + if args.dry: + continue + + popen = subprocess.Popen(child_args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, + universal_newlines=True) + stdout, stderr = popen.communicate() + res = popen.wait() + if res == -signal.SIGINT: + raise KeyboardInterrupt + print(' STDOUT:') + print(indent(stdout, 4)) + if res != 0: + print(' STDERR:') + print(indent(stderr, 4)) + sys.exit(res) + +def clean(files): + global args + if not files: + return + for o in files: + file = o if args.verbose else os.path.basename(o) + print('Cleaning {0}'.format(file)) + try: + if os.path.exists(o): + if not args.dry: + os.remove(o) + if args.verbose: + print(' The file was successfully cleaned.') + elif args.verbose: + print(' The file does not exist.') + except: + if args.verbose: + print(' The file could not be removed.') + +def fix_arguments(args): + if not args.inputs: + raise ValueError('No input files specified') + + if args.output and args.mode == 'compile' and len(args.inputs) > 1: + raise ValueError('Cannot specify -o with mode=compile and multiple source files. Use --outdir instead.') + + if not args.dry: + args.inputs = [os.path.abspath(x) for x in args.inputs] + + # If user didn't specify the outdir, use the directory of the first input. + if not args.outdir: + if args.output: + args.outdir = os.path.dirname(args.output) + else: + args.outdir = os.path.dirname(args.inputs[0]) + args.outdir = os.path.abspath(args.outdir) + args.outdir = os.path.normpath(args.outdir) + + # If user specified a non-absolute path for the output file, append the + # output directory to it. + if args.output: + if not os.path.isabs(args.output): + args.output = os.path.join(args.outdir, args.output) + args.output = os.path.normpath(args.output) + +fix_arguments(args) + +(toolchain_type, toolchain_path) = find_toolchain(args.compiler, args.tools_dir) +if not toolchain_path or not toolchain_type: + print('Unable to find toolchain {0}'.format(args.compiler)) + sys.exit(1) + +if args.verbose: + print('Script Arguments:') + print(' Arch: ' + args.arch) + print(' Compiler: ' + args.compiler) + print(' Outdir: ' + args.outdir) + print(' Output: ' + args.output) + print(' Nodefaultlib: ' + str(args.nodefaultlib)) + print(' Opt: ' + args.opt) + print(' Mode: ' + args.mode) + print(' Clean: ' + str(args.clean)) + print(' Verbose: ' + str(args.verbose)) + print(' Dryrun: ' + str(args.dry)) + print(' Inputs: ' + format_text(args.inputs, 0, 10)) + print('Script Environment:') + print_environment(os.environ) + +args.compiler = toolchain_path +if not os.path.exists(args.compiler) and not args.dry: + raise ValueError('The toolchain {} does not exist.'.format(args.compiler)) + +if toolchain_type == 'msvc' or toolchain_type=='clang-cl': + builder = MsvcBuilder(toolchain_type, args) +else: + builder = GccBuilder(toolchain_type, args) + +if args.clean: + clean(builder.output_files()) + +cmds = builder.build_commands() + +build(cmds) diff --git a/lit/helper/toolchain.py b/lit/helper/toolchain.py new file mode 100644 index 000000000000..a1f241e330fd --- /dev/null +++ b/lit/helper/toolchain.py @@ -0,0 +1,133 @@ +import os +import itertools +import platform +import subprocess +import sys + +import lit.util +from lit.llvm import llvm_config +from lit.llvm.subst import FindTool +from lit.llvm.subst import ToolSubst + +def use_lldb_substitutions(config): + # Set up substitutions for primary tools. These tools must come from config.lldb_tools_dir + # which is basically the build output directory. We do not want to find these in path or + # anywhere else, since they are specifically the programs which are actually being tested. + + dsname = 'debugserver' if platform.system() in ['Darwin'] else 'lldb-server' + dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver'] + lldbmi = ToolSubst('%lldbmi', + command=FindTool('lldb-mi'), + extra_args=['--synchronous'], + unresolved='ignore') + + + build_script = os.path.dirname(__file__) + build_script = os.path.join(build_script, 'build.py') + build_script_args = [build_script, + '--compiler=any', # Default to best compiler + '--arch=' + str(config.lldb_bitness)] + if config.lldb_lit_tools_dir: + build_script_args.append('--tools-dir={0}'.format(config.lldb_lit_tools_dir)) + if config.lldb_tools_dir: + build_script_args.append('--tools-dir={0}'.format(config.lldb_tools_dir)) + + primary_tools = [ + ToolSubst('%lldb', + command=FindTool('lldb'), + extra_args=['-S', + os.path.join(config.test_source_root, + 'lit-lldb-init')]), + lldbmi, + ToolSubst('%debugserver', + command=FindTool(dsname), + extra_args=dsargs, + unresolved='ignore'), + 'lldb-test', + ToolSubst('%build', + command="'" + sys.executable + "'", + extra_args=build_script_args) + ] + + llvm_config.add_tool_substitutions(primary_tools, + [config.lldb_tools_dir]) + if lldbmi.was_resolved: + config.available_features.add('lldb-mi') + +def _use_msvc_substitutions(config): + # If running from a Visual Studio Command prompt (e.g. vcvars), this will + # detect the include and lib paths, and find cl.exe and link.exe and create + # substitutions for each of them that explicitly specify /I and /L paths + cl = lit.util.which('cl') + link = lit.util.which('link') + + if not cl or not link: + return + + cl = '"' + cl + '"' + link = '"' + link + '"' + includes = os.getenv('INCLUDE', '').split(';') + libs = os.getenv('LIB', '').split(';') + + config.available_features.add('msvc') + compiler_flags = ['"/I{}"'.format(x) for x in includes if os.path.exists(x)] + linker_flags = ['"/LIBPATH:{}"'.format(x) for x in libs if os.path.exists(x)] + + tools = [ + ToolSubst('%msvc_cl', command=cl, extra_args=compiler_flags), + ToolSubst('%msvc_link', command=link, extra_args=linker_flags)] + llvm_config.add_tool_substitutions(tools) + return + +def use_support_substitutions(config): + # Set up substitutions for support tools. These tools can be overridden at the CMake + # level (by specifying -DLLDB_LIT_TOOLS_DIR), installed, or as a last resort, we can use + # the just-built version. + flags = [] + if platform.system() in ['Darwin']: + try: + out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip() + res = 0 + except OSError: + res = -1 + if res == 0 and out: + sdk_path = lit.util.to_string(out) + llvm_config.lit_config.note('using SDKROOT: %r' % sdk_path) + flags = ['-isysroot', sdk_path] + elif platform.system() in ['OpenBSD', 'Linux']: + flags = ['-pthread'] + + # Swift support + swift_sdk = [' -sdk ', sdk_path] if platform.system() in ['Darwin'] else [] + tools = [ + ToolSubst( + '%target-swiftc', command=config.swiftc, extra_args=swift_sdk), + ToolSubst( + '%target-swift-frontend', + command=config.swiftc[:-1], + extra_args=['-frontend'] + swift_sdk) + ] + llvm_config.add_tool_substitutions(tools) + + additional_tool_dirs=[] + if config.lldb_lit_tools_dir: + additional_tool_dirs.append(config.lldb_lit_tools_dir) + + llvm_config.use_clang(additional_flags=flags, + additional_tool_dirs=additional_tool_dirs, + required=True) + + if sys.platform == 'win32': + _use_msvc_substitutions(config) + + have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs, + required=False) + if have_lld: + config.available_features.add('lld') + + + support_tools = ['yaml2obj', 'obj2yaml', 'llvm-pdbutil', + 'llvm-mc', 'llvm-readobj', 'llvm-objdump', + 'llvm-objcopy'] + additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir] + llvm_config.add_tool_substitutions(support_tools, additional_tool_dirs) diff --git a/lit/lit.cfg b/lit/lit.cfg deleted file mode 100644 index cbe3761b488a..000000000000 --- a/lit/lit.cfg +++ /dev/null @@ -1,191 +0,0 @@ -# -*- Python -*- - -import os -import platform -import re -import subprocess -import shutil -import locale - -import lit.formats -import lit.util - -def binary_feature(on, feature, off_prefix): - return feature if on else off_prefix + feature - -# Configuration file for the 'lit' test runner. - -# name: The name of this test suite. -config.name = 'lldb' - -# testFormat: The test format to use to interpret tests. -# -# For now we require '&&' between commands, until they get globally killed and -# the test runner updated. -execute_external = (platform.system() != 'Windows' - or lit_config.getBashPath() not in [None, ""]) -config.test_format = lit.formats.ShTest(execute_external) - -# suffixes: We only support unit tests -config.suffixes = [] - -config.excludes = ['Inputs'] - -# test_source_root: The root path where tests are located. -config.test_source_root = os.path.dirname(__file__) - -# test_exec_root: The root path where tests should be run. -config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit') - -# Tweak the PATH to include the tools dir and the scripts dir. -lldb_tools_dir = config.lldb_tools_dir -llvm_tools_dir = config.llvm_tools_dir -path = os.path.pathsep.join((config.lldb_tools_dir, config.llvm_tools_dir, config.environment['PATH'])) - -config.environment['PATH'] = path - -path = os.path.pathsep.join((config.lldb_libs_dir, config.llvm_libs_dir, - config.environment.get('LD_LIBRARY_PATH',''))) -config.environment['LD_LIBRARY_PATH'] = path - -# Propagate LLVM_SRC_ROOT into the environment. -config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '') - -# Propagate PYTHON_EXECUTABLE into the environment -config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable', '') - -# Register substitutions -config.substitutions.append(('%python', config.python_executable)) - -debugserver = lit.util.which('debugserver', lldb_tools_dir) -lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), - config.test_source_root) - -lldbmi = lit.util.which('lldb-mi', lldb_tools_dir) - -if not os.path.exists(config.cc): - config.cc = lit.util.which(config.cc, config.environment['PATH']) - -if not os.path.exists(config.cxx): - config.cxx = lit.util.which(config.cxx, config.environment['PATH']) - -if platform.system() in ['Darwin']: - try: - out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip() - res = 0 - except OSError: - res = -1 - if res == 0 and out: - sdk_path = out - lit_config.note('using SDKROOT: %r' % sdk_path) - config.cc += " -isysroot %s" % sdk_path - config.cxx += " -isysroot %s" % sdk_path - -if platform.system() in ['OpenBSD']: - config.cc += " -pthread" - config.cxx += " -pthread" - -config.substitutions.append(('%cc', config.cc)) -config.substitutions.append(('%cxx', config.cxx)) - -config.substitutions.append(('%lldbmi', lldbmi + " --synchronous")) -config.substitutions.append(('%lldb', lldb)) - -# Swift support -swift_sdk = (' -sdk ' + sdk_path) if platform.system() in ['Darwin'] else '' -config.substitutions.append(('%target-swiftc', config.swiftc + swift_sdk)) -config.substitutions.append(('%target-swift-frontend', config.swiftc[:-1] + - ' -frontend' + swift_sdk)) - -if debugserver is not None: - config.substitutions.append(('%debugserver', debugserver)) - -for pattern in [r"\bFileCheck\b", - r"\blldb-test\b", - r"\byaml2obj\b", - r"\| \bnot\b"]: - tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", - pattern) - tool_pipe = tool_match.group(2) - tool_name = tool_match.group(4) - tool_path = lit.util.which(tool_name, config.environment['PATH']) - if not tool_path: - # Warn, but still provide a substitution. - lit_config.note( - 'Did not find ' + tool_name + ' in ' + config.environment['PATH']) - config.substitutions.append((pattern, tool_pipe + tool_path)) - -# Shell execution -if platform.system() not in ['Windows'] or lit_config.getBashPath() != '': - config.available_features.add('shell') - -# Running on Darwin OS -if platform.system() in ['Darwin']: - config.available_features.add('darwin') - config.available_features.add('system-linker-mach-o') - -# Running on ELF based *nix -if platform.system() in ['FreeBSD', 'Linux']: - config.available_features.add('system-linker-elf') - if platform.system() in ['FreeBSD']: - config.available_features.add('freebsd') - else: - config.available_features.add('linux') - -config.available_features.add( - binary_feature(platform.system() in ['Windows'], 'windows', 'no')) - -if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple): - config.available_features.add("armhf-linux") - -if re.match(r'icc', config.cc): - config.available_features.add("compiler-icc") -elif re.match(r'clang', config.cc): - config.available_features.add("compiler-clang") -elif re.match(r'gcc', config.cc): - config.available_features.add("compiler-gcc") -elif re.match(r'cl', config.cc): - config.available_features.add("compiler-msvc") - -config.available_features.add(binary_feature(config.have_zlib, "zlib", "no")) -if config.have_lld: - config.available_features.add("lld") - -# llvm-config knows whether it is compiled with asserts (and) -# whether we are operating in release/debug mode. -import subprocess -try: - llvm_config_cmd = \ - subprocess.Popen([os.path.join(llvm_tools_dir, 'llvm-config'), - '--build-mode', '--assertion-mode', '--targets-built'], - stdout = subprocess.PIPE) -except OSError as why: - print("Could not find llvm-config in " + llvm_tools_dir) - exit(42) - -llvm_config_output = llvm_config_cmd.stdout.read().decode('utf_8') -llvm_config_output_list = llvm_config_output.split("\n") - -if re.search(r'DEBUG', llvm_config_output_list[0]): - config.available_features.add('debug') -if re.search(r'ON', llvm_config_output_list[1]): - config.available_features.add('asserts') -if re.search(r'ARM', llvm_config_output_list[2]): - config.available_features.add('arm') -if re.search(r'Mips', llvm_config_output_list[2]): - config.available_features.add('mips') -if re.search(r'PowerPC', llvm_config_output_list[2]): - config.available_features.add('powerpc') -if re.search(r'X86', llvm_config_output_list[2]): - config.available_features.add('x86') -llvm_config_cmd.wait() - -# Clean the module caches in the test build directory. This is -# necessary in an incremental build whenever clang changes underneath, -# so doing it once per lit.py invocation is close enough. -for i in ['module-cache-clang', 'module-cache-lldb']: - cachedir = os.path.join(config.lldb_libs_dir, '..', - 'lldb-test-build.noindex', i) - if os.path.isdir(cachedir): - print("Deleting module cache at %s."%cachedir) - shutil.rmtree(cachedir) diff --git a/lit/lit.cfg.py b/lit/lit.cfg.py new file mode 100644 index 000000000000..e1db7621e328 --- /dev/null +++ b/lit/lit.cfg.py @@ -0,0 +1,75 @@ +# -*- Python -*- + +import os +import re +import shutil +import site +import sys + +import lit.formats +from lit.llvm import llvm_config +from lit.llvm.subst import FindTool +from lit.llvm.subst import ToolSubst + +site.addsitedir(os.path.dirname(__file__)) +from helper import toolchain + +# name: The name of this test suite. +config.name = 'LLDB' + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) + +# suffixes: A list of file extensions to treat as test files. This is overriden +# by individual lit.local.cfg files in the test subdirectories. +config.suffixes = ['.test', '.cpp', '.s'] + +# excludes: A list of directories to exclude from the testsuite. The 'Inputs' +# subdirectories contain auxiliary inputs for various tests in their parent +# directories. +config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt'] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +# test_exec_root: The root path where tests should be run. +config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit') + + +llvm_config.use_default_substitutions() + +toolchain.use_lldb_substitutions(config) + +toolchain.use_support_substitutions(config) + + +if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple): + config.available_features.add("armhf-linux") + +def calculate_arch_features(arch_string): + # This will add a feature such as x86, arm, mips, etc for each built + # target + features = [] + for arch in arch_string.split(): + features.append(arch.lower()) + return features + +# Run llvm-config and add automatically add features for whether we have +# assertions enabled, whether we are in debug mode, and what targets we +# are built for. +llvm_config.feature_config( + [('--assertion-mode', {'ON': 'asserts'}), + ('--build-mode', {'DEBUG': 'debug'}), + ('--targets-built', calculate_arch_features) + ]) + +# Clean the module caches in the test build directory. This is +# necessary in an incremental build whenever clang changes underneath, +# so doing it once per lit.py invocation is close enough. + +for i in ['module-cache-clang', 'module-cache-lldb']: + cachedir = os.path.join(config.lldb_libs_dir, '..', + 'lldb-test-build.noindex', i) + if os.path.isdir(cachedir): + print("Deleting module cache at %s."%cachedir) + shutil.rmtree(cachedir) diff --git a/lit/lit.site.cfg.in b/lit/lit.site.cfg.py.in similarity index 66% rename from lit/lit.site.cfg.in rename to lit/lit.site.cfg.py.in index 3cc4a0a48862..2c669e9b6844 100644 --- a/lit/lit.site.cfg.in +++ b/lit/lit.site.cfg.py.in @@ -4,30 +4,37 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.llvm_shlib_dir = "@SHLIBDIR@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lldb_obj_root = "@LLDB_BINARY_DIR@" config.lldb_libs_dir = "@LLDB_LIBS_DIR@" config.lldb_tools_dir = "@LLDB_TOOLS_DIR@" +# Since it comes from the command line, it may have backslashes which +# should not need to be escaped. +config.lldb_lit_tools_dir = r"@LLDB_LIT_TOOLS_DIR@" config.target_triple = "@TARGET_TRIPLE@" config.python_executable = "@PYTHON_EXECUTABLE@" -config.cc = "@LLDB_TEST_C_COMPILER@" -config.cxx = "@LLDB_TEST_CXX_COMPILER@" config.swiftc = "@LLDB_SWIFTC@" config.have_zlib = @LLVM_ENABLE_ZLIB@ -config.have_lld = @LLDB_HAVE_LLD@ +config.host_triple = "@LLVM_HOST_TRIPLE@" +config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32 # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. try: config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params + config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params config.lldb_tools_dir = config.lldb_tools_dir % lit_config.params - config.cc = config.cc % lit_config.params - config.cxx = config.cxx % lit_config.params + config.lldb_lit_tools_dir = config.lldb_lit_tools_dir % lit_config.params + except KeyError as e: key, = e.args lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) +import lit.llvm +lit.llvm.initialize(lit_config, config) + # Let the main config do the real work. -lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/lit.cfg") +lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/lit.cfg.py") diff --git a/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test b/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test new file mode 100644 index 000000000000..48f86b4d678c --- /dev/null +++ b/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test @@ -0,0 +1,47 @@ +# XFAIL: system-windows +# -> llvm.org/pr24452 +# +# RUN: %clang -o %t %p/inputs/break-insert-pending.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test for enabling pending breakpoints globally + +-break-insert printf +# CHECK: ^error,msg="Command 'break-insert'. Breakpoint location 'printf' not found + +-gdb-set breakpoint pending on +# CHECK: ^done +-gdb-show breakpoint pending +# CHECK: ^done,value="on" +-break-insert printf +# CHECK: ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0xffffffffffffffff",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"} + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={level="0",addr="{{0x[0-9a-f]*[^f][0-9a-f]*}}" +-break-disable 2 +# CHECK: ^done +-exec-continue +# CHECK: ^running +# CHECK: *stopped,reason="exited-normally" + +# Test that it can be turned back off +-gdb-show breakpoint pending +# CHECK: ^done,value="on" +-gdb-set breakpoint pending off +# CHECK: ^done +-gdb-show breakpoint pending +# CHECK: ^done,value="off" +-break-insert printf-non-existent +# CHECK: ^error,msg="Command 'break-insert'. Breakpoint location 'printf-non-existent' not found" +# Check that enable/disable with 1 and 0 works +-gdb-set breakpoint pending 1 +# CHECK: ^done +-gdb-show breakpoint pending +# CHECK: ^done,value="on" +-gdb-set breakpoint pending 0 +# CHECK: ^done +-gdb-show breakpoint pending +# CHECK: ^done,value="off" +-gdb-set breakpoint pending garbage +# CHECK: ^done diff --git a/lit/tools/lldb-mi/breakpoint/break-insert.test b/lit/tools/lldb-mi/breakpoint/break-insert.test index cecf9e2443ae..ef50bf530077 100644 --- a/lit/tools/lldb-mi/breakpoint/break-insert.test +++ b/lit/tools/lldb-mi/breakpoint/break-insert.test @@ -1,7 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# -# RUN: %cc -o a.exe %p/inputs/break-insert.c -g +# RUN: %build %p/inputs/break-insert.c --nodefaultlib -o a.exe # RUN: %lldbmi < %s | FileCheck %s # Test that a breakpoint can be inserted before creating a target. diff --git a/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c b/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c new file mode 100644 index 000000000000..99722abfbd4b --- /dev/null +++ b/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char const *argv[]) { + printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]); + return 0; +} diff --git a/lit/tools/lldb-mi/data/data-info-line.test b/lit/tools/lldb-mi/data/data-info-line.test index c224efa4de2d..287e833ab9ef 100644 --- a/lit/tools/lldb-mi/data/data-info-line.test +++ b/lit/tools/lldb-mi/data/data-info-line.test @@ -1,7 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# -# RUN: %cc -o %t %p/inputs/data-info-line.c -g +# RUN: %build %p/inputs/data-info-line.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -data-info-line command. diff --git a/lit/tools/lldb-mi/exec/exec-continue.test b/lit/tools/lldb-mi/exec/exec-continue.test index c363422373d3..d51393e5c716 100644 --- a/lit/tools/lldb-mi/exec/exec-continue.test +++ b/lit/tools/lldb-mi/exec/exec-continue.test @@ -1,7 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-continue command. diff --git a/lit/tools/lldb-mi/exec/exec-finish.test b/lit/tools/lldb-mi/exec/exec-finish.test index 03c6b158fcf3..b2a50c5267fd 100644 --- a/lit/tools/lldb-mi/exec/exec-finish.test +++ b/lit/tools/lldb-mi/exec/exec-finish.test @@ -1,7 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-finish command. diff --git a/lit/tools/lldb-mi/exec/exec-interrupt.test b/lit/tools/lldb-mi/exec/exec-interrupt.test index 81a3e72ee7e6..2c063236d7f5 100644 --- a/lit/tools/lldb-mi/exec/exec-interrupt.test +++ b/lit/tools/lldb-mi/exec/exec-interrupt.test @@ -1,7 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-interrupt command. diff --git a/lit/tools/lldb-mi/exec/exec-next-instruction.test b/lit/tools/lldb-mi/exec/exec-next-instruction.test index 80905f50f075..abd4e526375f 100644 --- a/lit/tools/lldb-mi/exec/exec-next-instruction.test +++ b/lit/tools/lldb-mi/exec/exec-next-instruction.test @@ -1,8 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# REQUIRES: FIX_FOR_RACE_CONDITION -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-next-instruction command. diff --git a/lit/tools/lldb-mi/exec/exec-next.test b/lit/tools/lldb-mi/exec/exec-next.test index 7e35ccac50bd..87d9d44bb582 100644 --- a/lit/tools/lldb-mi/exec/exec-next.test +++ b/lit/tools/lldb-mi/exec/exec-next.test @@ -1,9 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# REQUIRES: FIX_FOR_RACE_CONDITION -# -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-next command. diff --git a/lit/tools/lldb-mi/exec/exec-step-instruction.test b/lit/tools/lldb-mi/exec/exec-step-instruction.test index 18f261a9afb5..0613fb5c7934 100644 --- a/lit/tools/lldb-mi/exec/exec-step-instruction.test +++ b/lit/tools/lldb-mi/exec/exec-step-instruction.test @@ -1,8 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# REQUIRES: FIX_FOR_RACE_CONDITION -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-step-instruction command. diff --git a/lit/tools/lldb-mi/exec/exec-step.test b/lit/tools/lldb-mi/exec/exec-step.test index 4967ec6127f9..976afb33bcd4 100644 --- a/lit/tools/lldb-mi/exec/exec-step.test +++ b/lit/tools/lldb-mi/exec/exec-step.test @@ -1,8 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# REQUIRES: FIX_FOR_RACE_CONDITION -# -# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %build %p/inputs/main.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -exec-step command. diff --git a/lit/tools/lldb-mi/symbol/symbol-list-lines.test b/lit/tools/lldb-mi/symbol/symbol-list-lines.test index f40ad2f94e40..792f283db1bb 100644 --- a/lit/tools/lldb-mi/symbol/symbol-list-lines.test +++ b/lit/tools/lldb-mi/symbol/symbol-list-lines.test @@ -1,7 +1,4 @@ -# XFAIL: windows -# -> llvm.org/pr24452 -# -# RUN: %cc -o %t %p/inputs/main.c %p/inputs/symbol-list-lines.c %p/inputs/list-lines-helper.c -g +# RUN: %build %p/inputs/main.c %p/inputs/symbol-list-lines.c %p/inputs/list-lines-helper.c --nodefaultlib -o %t # RUN: %lldbmi %t < %s | FileCheck %s # Test lldb-mi -symbol-list-lines command. @@ -14,7 +11,7 @@ # CHECK: ^error,msg="File Handler. Invalid file name path" -symbol-list-lines symbol-list-lines.c -# CHECK: ^done,lines=[{pc="0x{{[0-9A-Fa-f]+}}",line="3"},{pc="0x{{[0-9A-Fa-f]+}}",line="4"},{pc="0x{{[0-9A-Fa-f]+}}",line="5"}] +# CHECK: ^done,lines=[{pc="0x{{[0-9A-Fa-f]+}}",line="3"},{pc="0x{{[0-9A-Fa-f]+}}",line="4"},{pc="0x{{[0-9A-Fa-f]+}}",line="5"}{{.*}}] -symbol-list-lines list-lines-helper.c -# CHECK: ^done,lines=[{pc="0x{{[0-9A-Fa-f]+}}",line="1"},{pc="0x{{[0-9A-Fa-f]+}}",line="2"},{pc="0x{{[0-9A-Fa-f]+}}",line="3"}] +# CHECK: ^done,lines=[{pc="0x{{[0-9A-Fa-f]+}}",line="1"},{pc="0x{{[0-9A-Fa-f]+}}",line="2"},{pc="0x{{[0-9A-Fa-f]+}}",line="3"}{{.*}}] diff --git a/lit/tools/lldb-mi/target/inputs/main.c b/lit/tools/lldb-mi/target/inputs/main.c new file mode 100644 index 000000000000..8c74b3496f7c --- /dev/null +++ b/lit/tools/lldb-mi/target/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} diff --git a/lit/tools/lldb-mi/target/inputs/target-select-so-path.py b/lit/tools/lldb-mi/target/inputs/target-select-so-path.py new file mode 100644 index 000000000000..5eb07d84237c --- /dev/null +++ b/lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -0,0 +1,50 @@ +import os +import sys +import subprocess +from threading import Timer + + +hostname = 'localhost' + +(r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): + kwargs['pass_fds'] = [w] + +args = sys.argv +# Get debugserver, lldb-mi and FileCheck executables' paths with arguments. +debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) +lldbmi = args[2] +test_file = args[3] +filecheck = 'FileCheck ' + test_file + +# Run debugserver, lldb-mi and FileCheck. +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) +lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, shell=True) +filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, + shell=True) + +timeout_sec = 30 +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) +try: + timer.start() + + # Get a tcp port chosen by debugserver. + # The number quite big to get lldb-server's output and to not hang. + bytes_to_read = 10 + port_bytes = os.read(r, bytes_to_read) + port = str(port_bytes.decode('utf-8').strip('\x00')) + + with open(test_file, 'r') as f: + # Replace '$PORT' with a free port number and pass + # test's content to lldb-mi. + lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) + out, err = lldbmi_proc.communicate() + filecheck_proc.stdin.write(out) + filecheck_proc.communicate() +finally: + timer.cancel() + +debugserver_proc.kill() +exit(filecheck_proc.returncode) diff --git a/lit/Expr/lit.local.cfg b/lit/tools/lldb-mi/target/lit.local.cfg similarity index 100% rename from lit/Expr/lit.local.cfg rename to lit/tools/lldb-mi/target/lit.local.cfg diff --git a/lit/tools/lldb-mi/target/target-select-so-path.test b/lit/tools/lldb-mi/target/target-select-so-path.test new file mode 100644 index 000000000000..8b71be5436d9 --- /dev/null +++ b/lit/tools/lldb-mi/target/target-select-so-path.test @@ -0,0 +1,25 @@ +# UNSUPPORTED: system-windows, system-darwin +# +# RUN: %clang -o %t %p/inputs/main.c -g +# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s + +# Test that -target-select command can hook up a path +# added by gdb-set solib-search-path. + +# Check that we have a valid target created via file-exec-and-symbols. +# CHECK: ^done + +-interpreter-exec console "target modules search-paths list" +# CHECK ^done + +-gdb-set solib-search-path /example/dir +# CHECK: ^done + +-target-select remote localhost:$PORT +# CHECK: ^connected + +-interpreter-exec console "target modules search-paths list" +# CHECK: ~"[0] \".\" -> \"/example/dir\"\n" +# CHECK-NEXT: ^done + +-gdb-exit diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj index e3054772b8fa..4c37b3230b7d 100644 --- a/lldb.xcodeproj/project.pbxproj +++ b/lldb.xcodeproj/project.pbxproj @@ -92,6 +92,17 @@ name = "ios-mini"; productName = ios; }; + DD8DC26B22026E2C00EB6F9E /* lldb-docs */ = { + isa = PBXAggregateTarget; + buildConfigurationList = DD8DC27022026E2C00EB6F9E /* Build configuration list for PBXAggregateTarget "lldb-docs" */; + buildPhases = ( + DD8DC27122026E4400EB6F9E /* ShellScript */, + ); + dependencies = ( + ); + name = "lldb-docs"; + productName = "lldb-docs"; + }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ @@ -147,6 +158,7 @@ 2689002C13353E0400698AC0 /* AddressResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7034011752C6B0086C050 /* AddressResolver.cpp */; }; 2689002D13353E0400698AC0 /* AddressResolverFileLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7034211752C720086C050 /* AddressResolverFileLine.cpp */; }; 2689002E13353E0400698AC0 /* AddressResolverName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7034411752C790086C050 /* AddressResolverName.cpp */; }; + 4C639ED521FA684900A7B957 /* AnsiTerminalTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC721FA684800A7B957 /* AnsiTerminalTest.cpp */; }; 4CD44CFD20B37C440003557C /* AppleDWARFIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD44CFA20B37C440003557C /* AppleDWARFIndex.cpp */; }; AF0E22F018A09FB20009B7D1 /* AppleGetItemInfoHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF0E22EE18A09FB20009B7D1 /* AppleGetItemInfoHandler.cpp */; }; AF1F7B07189C904B0087DB9C /* AppleGetPendingItemsHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1F7B05189C904B0087DB9C /* AppleGetPendingItemsHandler.cpp */; }; @@ -165,6 +177,8 @@ 23E2E5251D90373D006F38BB /* ArchSpecTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E2E5161D903689006F38BB /* ArchSpecTest.cpp */; }; AF2E02A31FA2CEAF00A86C34 /* ArchitectureArm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF2E02A11FA2CEAF00A86C34 /* ArchitectureArm.cpp */; }; AF2E02A41FA2CEAF00A86C34 /* ArchitectureArm.h in Headers */ = {isa = PBXBuildFile; fileRef = AF2E02A21FA2CEAF00A86C34 /* ArchitectureArm.h */; }; + 2647B63221C4366300A81D15 /* ArchitectureMips.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2647B63021C4366300A81D15 /* ArchitectureMips.cpp */; }; + 2647B63121C4366300A81D15 /* ArchitectureMips.h in Headers */ = {isa = PBXBuildFile; fileRef = 2647B62F21C4366200A81D15 /* ArchitectureMips.h */; }; 4C14CEFB2057258D00DEEF94 /* ArchitecturePPC64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C14CEF82057258D00DEEF94 /* ArchitecturePPC64.cpp */; }; 2689007D13353E2200698AC0 /* Args.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6C10F1B85900F91463 /* Args.cpp */; }; 23CB153C1D66DA9300EDDDE1 /* ArgsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2321F93E1BDD33CE00BA9A93 /* ArgsTest.cpp */; }; @@ -173,7 +187,9 @@ AFC2DCE91E6E2F2C00283714 /* Baton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCE81E6E2F2C00283714 /* Baton.cpp */; }; 268900D013353E6F00698AC0 /* Block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1310F1B8EC00F91463 /* Block.cpp */; }; 49DEF1251CD7C6DF006A7C7D /* BlockPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DEF11F1CD7BD90006A7C7D /* BlockPointer.cpp */; }; + 4CAEC6A821F26D15007C3DD5 /* BreakpadRecords.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CAEC6A621F26D15007C3DD5 /* BreakpadRecords.cpp */; }; 2689FFEF13353DB600698AC0 /* Breakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0A10F1B83100F91463 /* Breakpoint.cpp */; }; + 2660387E211CA98200329572 /* BreakpointBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2660387D211CA98200329572 /* BreakpointBase.cpp */; }; 2689FFF113353DB600698AC0 /* BreakpointID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0B10F1B83100F91463 /* BreakpointID.cpp */; }; 2689FFF313353DB600698AC0 /* BreakpointIDList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0C10F1B83100F91463 /* BreakpointIDList.cpp */; }; 2689FFF513353DB600698AC0 /* BreakpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0D10F1B83100F91463 /* BreakpointList.cpp */; }; @@ -190,7 +206,8 @@ 4CCF9F612143014D006CC7EA /* BreakpointResolverScripted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCF9F5E2143012F006CC7EA /* BreakpointResolverScripted.cpp */; }; 2689000713353DB600698AC0 /* BreakpointSite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1310F1B83100F91463 /* BreakpointSite.cpp */; }; 2689000913353DB600698AC0 /* BreakpointSiteList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1410F1B83100F91463 /* BreakpointSiteList.cpp */; }; - 2689003113353E0400698AC0 /* Broadcaster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */; }; + 2647B63A21C436AC00A81D15 /* Broadcaster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2647B63921C436AB00A81D15 /* Broadcaster.cpp */; }; + 2647B63621C4368300A81D15 /* Broadcaster.h in Headers */ = {isa = PBXBuildFile; fileRef = 2647B63521C4368300A81D15 /* Broadcaster.h */; }; 23CB15431D66DA9300EDDDE1 /* BroadcasterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23CB14E61D66CC0E00EDDDE1 /* BroadcasterTest.cpp */; }; 949EEDAE1BA7671C008C63CF /* CF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDAC1BA76719008C63CF /* CF.cpp */; }; 2689007613353E1A00698AC0 /* CFCBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */; }; @@ -247,6 +264,7 @@ 2689002113353DDE00698AC0 /* CommandObjectQuit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */; }; 2689008413353E2200698AC0 /* CommandObjectRegexCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DFBC59113B48F300DD817F /* CommandObjectRegexCommand.cpp */; }; 2689002213353DDE00698AC0 /* CommandObjectRegister.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */; }; + AFCB1D5C219CD5A800730AD5 /* CommandObjectReproducer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFCB1D5A219CD5A700730AD5 /* CommandObjectReproducer.cpp */; }; 2689002313353DDE00698AC0 /* CommandObjectScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */; }; 2689002413353DDE00698AC0 /* CommandObjectSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4010F1B84700F91463 /* CommandObjectSettings.cpp */; }; 2689002513353DDE00698AC0 /* CommandObjectSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */; }; @@ -263,10 +281,12 @@ 2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2642FBA813D003B400ED6808 /* CommunicationKDP.cpp */; }; 964463EC1A330C0500154ED8 /* CompactUnwindInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 964463EB1A330C0500154ED8 /* CompactUnwindInfo.cpp */; }; 268900D513353E6F00698AC0 /* CompileUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */; }; + AFD966B8217140B6006714AC /* CompileUnitIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFD966B4217140B5006714AC /* CompileUnitIndex.cpp */; }; 265192C61BA8E905002F08F6 /* CompilerDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265192C51BA8E905002F08F6 /* CompilerDecl.cpp */; }; 2657AFB71B86910100958979 /* CompilerDeclContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2657AFB61B86910100958979 /* CompilerDeclContext.cpp */; }; 268900D213353E6F00698AC0 /* CompilerType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* CompilerType.cpp */; }; 58EC744120EAEB5200695209 /* CompletionRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58EC744020EAEB5200695209 /* CompletionRequest.cpp */; }; + 4C639ED721FA684900A7B957 /* CompletionRequestTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC921FA684800A7B957 /* CompletionRequestTest.cpp */; }; 2689003313353E0400698AC0 /* Connection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E6F10F1B85900F91463 /* Connection.cpp */; }; AFDFDFD119E34D3400EAE509 /* ConnectionFileDescriptorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFDFDFD019E34D3400EAE509 /* ConnectionFileDescriptorPosix.cpp */; }; 26764C971E48F482008D3573 /* ConstString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764C961E48F482008D3573 /* ConstString.cpp */; }; @@ -299,13 +319,14 @@ 2689006613353E0E00698AC0 /* DWARFExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */; }; 268900C613353E5F00698AC0 /* DWARFFormValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D310F57C5600BB2B04 /* DWARFFormValue.cpp */; }; 4CD44CFB20B37C440003557C /* DWARFIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD44CF820B37C440003557C /* DWARFIndex.cpp */; }; + 4C38996421B9AECD002BAEF4 /* DWARFLocationExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C38996221B9AECC002BAEF4 /* DWARFLocationExpression.cpp */; }; AFE228832060699D0042D0C8 /* DWARFUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F2AAA5920601BE000A422D8 /* DWARFUnit.cpp */; }; 26FFC19B14FC072100087D58 /* DYLDRendezvous.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FFC19514FC072100087D58 /* DYLDRendezvous.cpp */; }; 49CA96FC1E6AACC900C03FEE /* DataBufferHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E61E6AAC6600C03FEE /* DataBufferHeap.cpp */; }; 49CA96FD1E6AACC900C03FEE /* DataBufferLLVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E71E6AAC6600C03FEE /* DataBufferLLVM.cpp */; }; 49CA96FE1E6AACC900C03FEE /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E81E6AAC6600C03FEE /* DataEncoder.cpp */; }; 49CA96FF1E6AACC900C03FEE /* DataExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */; }; - 23CB15391D66DA9300EDDDE1 /* DataExtractorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23CB14E81D66CC0E00EDDDE1 /* DataExtractorTest.cpp */; }; + AFA1B62C219E0ED900A8AB7E /* DataExtractorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFA1B62B219E0ED900A8AB7E /* DataExtractorTest.cpp */; }; 94CB255C16B069770059775D /* DataVisualization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB255816B069770059775D /* DataVisualization.cpp */; }; 23D4007E1C210201000C3885 /* DebugMacros.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E77CDB1C20F2F2007192AD /* DebugMacros.cpp */; }; AF116BEF20CF234B0071093F /* DebugNamesDWARFIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF116BED20CF234B0071093F /* DebugNamesDWARFIndex.cpp */; }; @@ -341,7 +362,11 @@ AFDBC36E204663AF00B9C8F2 /* EmulateInstructionPPC64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFDBC36C204663AF00B9C8F2 /* EmulateInstructionPPC64.cpp */; }; 9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15F135E30370024DDC3 /* EmulationStateARM.cpp */; }; 6B74D89B200696BB0074051B /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22DC561920064C9600A7E9E8 /* Environment.cpp */; }; - 2689003D13353E0400698AC0 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7910F1B85900F91463 /* Event.cpp */; }; + 4C639ECB21FA684900A7B957 /* EnvironmentTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EBD21FA684600A7B957 /* EnvironmentTest.cpp */; }; + 2647B63C21C436B400A81D15 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2647B63B21C436B400A81D15 /* Event.cpp */; }; + 2647B63421C4367A00A81D15 /* Event.h in Headers */ = {isa = PBXBuildFile; fileRef = 2647B63321C4367A00A81D15 /* Event.h */; }; + 4C639ED321FA684900A7B957 /* EventTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC521FA684800A7B957 /* EventTest.cpp */; }; + 2660387A211CA90F00329572 /* ExceptionBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26603874211CA90E00329572 /* ExceptionBreakpoint.cpp */; }; 268900EB13353E6F00698AC0 /* ExecutionContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F3510F1B90C00F91463 /* ExecutionContext.cpp */; }; 4C88BC2A1BA3722B00AA0964 /* Expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C88BC291BA3722B00AA0964 /* Expression.cpp */; }; 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; }; @@ -350,14 +375,16 @@ 2689006E13353E1A00698AC0 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C6EA213011581005E16B0 /* File.cpp */; }; 3FDFDDBD199C3A06009756A7 /* FileAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */; }; 3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBE199D345E009756A7 /* FileCache.cpp */; }; + DD8F277F22011CD8004ED75B /* FileCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD8F277D22011CC9004ED75B /* FileCollector.cpp */; }; + DD8F278222011D15004ED75B /* FileCollectorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD8F278022011D0F004ED75B /* FileCollectorTest.cpp */; }; 26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */; }; - 239D380B1D70FBAC00D8E937 /* FileSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 239D38091D70FB9900D8E937 /* FileSpec.cpp */; }; 2689006F13353E1A00698AC0 /* FileSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FA43171301048600E71120 /* FileSpec.cpp */; }; 2689003E13353E0400698AC0 /* FileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */; }; 23CB15361D66DA9300EDDDE1 /* FileSpecTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23CB14FD1D66CD2400EDDDE1 /* FileSpecTest.cpp */; }; 250D6AE31A9679440049CC70 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 250D6AE11A9679270049CC70 /* FileSystem.cpp */; }; 3FDFDDC6199D37ED009756A7 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */; }; 9A2057381F3B8E7E00F6C293 /* FileSystemTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A20572E1F3B8E7600F6C293 /* FileSystemTest.cpp */; }; + 4C639ED621FA684900A7B957 /* FlagsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC821FA684800A7B957 /* FlagsTest.cpp */; }; 94CB257416B1D3880059775D /* FormatCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB257316B1D3870059775D /* FormatCache.cpp */; }; 94CB255D16B069770059775D /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB255916B069770059775D /* FormatClasses.cpp */; }; 263FDE601A79A01500E68013 /* FormatEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263FDE5F1A79A01500E68013 /* FormatEntity.cpp */; }; @@ -367,12 +394,15 @@ AF23B4DB19009C66003E2A58 /* FreeBSDSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF23B4D919009C66003E2A58 /* FreeBSDSignals.cpp */; }; 268900D913353E6F00698AC0 /* FuncUnwinders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */; }; 268900D813353E6F00698AC0 /* Function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1810F1B8EC00F91463 /* Function.cpp */; }; + 2660387C211CA90F00329572 /* FunctionBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26603877211CA90E00329572 /* FunctionBreakpoint.cpp */; }; 4C2479BD1BA39295009C9A7B /* FunctionCaller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0083321B9A5DE200D5CF24 /* FunctionCaller.cpp */; }; 2374D7531D4BB2FF005C9575 /* GDBRemoteClientBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2374D74E1D4BB299005C9575 /* GDBRemoteClientBase.cpp */; }; 23CB153A1D66DA9300EDDDE1 /* GDBRemoteClientBaseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2370A37D1D66C587000E7BE6 /* GDBRemoteClientBaseTest.cpp */; }; 2689009D13353E4200698AC0 /* GDBRemoteCommunication.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618EE5B1315B29C001D6D71 /* GDBRemoteCommunication.cpp */; }; 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; }; 23CB153D1D66DA9300EDDDE1 /* GDBRemoteCommunicationClientTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2370A37E1D66C587000E7BE6 /* GDBRemoteCommunicationClientTest.cpp */; }; + AF8AD945219CD45800614785 /* GDBRemoteCommunicationHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF8AD943219CD45700614785 /* GDBRemoteCommunicationHistory.cpp */; }; + AFCB1D59219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFCB1D57219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp */; }; 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; }; 6D55B2901A8A806200A70529 /* GDBRemoteCommunicationServerCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D55B28D1A8A806200A70529 /* GDBRemoteCommunicationServerCommon.cpp */; }; 6D55B2911A8A806200A70529 /* GDBRemoteCommunicationServerLLGS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D55B28E1A8A806200A70529 /* GDBRemoteCommunicationServerLLGS.cpp */; }; @@ -417,9 +447,11 @@ 8C3BD9A01EF5D1FF0016C343 /* JSONTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C3BD99F1EF5D1B50016C343 /* JSONTest.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; 2669424D1A6DC32B0063BE93 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; + 26792623211CA42300EE1D10 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; 943BDEFE1AA7B2F800789CE8 /* LLDBAssert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 943BDEFD1AA7B2F800789CE8 /* LLDBAssert.cpp */; }; 6D762BEE1B1605D2006C929D /* LLDBServerUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D762BEC1B1605CD006C929D /* LLDBServerUtilities.cpp */; }; + 26F7619B211CBBB30044F6EA /* LLDBUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F76199211CBBB30044F6EA /* LLDBUtils.cpp */; }; 2660AAB914622483003A9694 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; settings = {COMPILER_FLAGS = "-Dregister="; }; }; AEB0E4591BD6E9F800B24093 /* LLVMUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEB0E4581BD6E9F800B24093 /* LLVMUserExpression.cpp */; }; 94B638531B8F8E6C004FE1E4 /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B638521B8F8E6C004FE1E4 /* Language.cpp */; }; @@ -443,8 +475,11 @@ 4CDB8D6D1DBA91B6006C5B13 /* LibStdcppUniquePointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CDB8D671DBA91A6006C5B13 /* LibStdcppUniquePointer.cpp */; }; 268900DA13353E6F00698AC0 /* LineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1910F1B8EC00F91463 /* LineEntry.cpp */; }; 268900DB13353E6F00698AC0 /* LineTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1A10F1B8EC00F91463 /* LineTable.cpp */; }; + 2647B64421C43BB000A81D15 /* LinuxProcMaps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2647B64221C43BB000A81D15 /* LinuxProcMaps.cpp */; }; + 2647B64321C43BB000A81D15 /* LinuxProcMaps.h in Headers */ = {isa = PBXBuildFile; fileRef = 2647B64121C43BAF00A81D15 /* LinuxProcMaps.h */; }; 23059A0719532B96007B8189 /* LinuxSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23059A0519532B96007B8189 /* LinuxSignals.cpp */; }; - 2689004113353E0400698AC0 /* Listener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7E10F1B85900F91463 /* Listener.cpp */; }; + 2647B63E21C436BD00A81D15 /* Listener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2647B63D21C436BC00A81D15 /* Listener.cpp */; }; + 2647B63821C4369500A81D15 /* Listener.h in Headers */ = {isa = PBXBuildFile; fileRef = 2647B63721C4369500A81D15 /* Listener.h */; }; 9A3D43EC1F3237F900EB767C /* ListenerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */; }; 255EFF741AFABA720069F277 /* LockFileBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 255EFF731AFABA720069F277 /* LockFileBase.cpp */; }; 255EFF761AFABA950069F277 /* LockFilePosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 255EFF751AFABA950069F277 /* LockFilePosix.cpp */; }; @@ -525,6 +560,7 @@ 266942451A6DC2AC0063BE93 /* MIUtilString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266941EE1A6DC2AC0063BE93 /* MIUtilString.cpp */; }; 2669424A1A6DC2AC0063BE93 /* MIUtilThreadBaseStd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266941F81A6DC2AC0063BE93 /* MIUtilThreadBaseStd.cpp */; }; 2669424B1A6DC2AC0063BE93 /* MIUtilVariant.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266941FA1A6DC2AC0063BE93 /* MIUtilVariant.cpp */; }; + AF395C03219254F300894EC3 /* MSVCUndecoratedNameParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF395C01219254F200894EC3 /* MSVCUndecoratedNameParser.cpp */; }; D67521381EA17C4200439694 /* MainLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D67521351EA17C3900439694 /* MainLoop.cpp */; }; 9A20573A1F3B8E7E00F6C293 /* MainLoopTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A2057301F3B8E7600F6C293 /* MainLoopTest.cpp */; }; 8C3BD9961EF45DA50016C343 /* MainThreadCheckerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C3BD9951EF45D9B0016C343 /* MainThreadCheckerRuntime.cpp */; }; @@ -555,8 +591,6 @@ 3F81691A1ABA2419001DA9DF /* NameMatches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169181ABA2419001DA9DF /* NameMatches.cpp */; }; 9A3D43D81F3151C400EB767C /* NameMatchesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43CB1F3150D200EB767C /* NameMatchesTest.cpp */; }; 268900C913353E5F00698AC0 /* NameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */; }; - 232CB615191E00CD00EF39FC /* NativeBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 232CB60B191E00CC00EF39FC /* NativeBreakpoint.cpp */; }; - 232CB617191E00CD00EF39FC /* NativeBreakpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 232CB60D191E00CC00EF39FC /* NativeBreakpointList.cpp */; }; 232CB619191E00CD00EF39FC /* NativeProcessProtocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 232CB60F191E00CC00EF39FC /* NativeProcessProtocol.cpp */; }; 267A47FB1B1411C40021A5BC /* NativeRegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267A47FA1B1411C40021A5BC /* NativeRegisterContext.cpp */; }; 23F4034D1926E0F60046DC9B /* NativeRegisterContextRegisterInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F403481926CC250046DC9B /* NativeRegisterContextRegisterInfo.cpp */; }; @@ -571,6 +605,7 @@ 2689009613353E4200698AC0 /* ObjectContainerBSDArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A3B4AC1181454800381BC2 /* ObjectContainerBSDArchive.cpp */; }; 2689009713353E4200698AC0 /* ObjectContainerUniversalMachO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C898010F57C5600BB2B04 /* ObjectContainerUniversalMachO.cpp */; }; 268900DC13353E6F00698AC0 /* ObjectFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F4C10F1BC1A00F91463 /* ObjectFile.cpp */; }; + 4C9BF11B21C0467700FA4036 /* ObjectFileBreakpad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C9BF11921C0467700FA4036 /* ObjectFileBreakpad.cpp */; }; 2689009913353E4200698AC0 /* ObjectFileELF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C898510F57C5600BB2B04 /* ObjectFileELF.cpp */; }; 26EFC4CD18CFAF0D00865D87 /* ObjectFileJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26EFC4CA18CFAF0D00865D87 /* ObjectFileJIT.cpp */; }; 2689009A13353E4200698AC0 /* ObjectFileMachO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C898810F57C5600BB2B04 /* ObjectFileMachO.cpp */; }; @@ -613,10 +648,15 @@ 260CC65315D0440D002BF2E0 /* OptionValueUInt64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260CC64615D0440D002BF2E0 /* OptionValueUInt64.cpp */; }; 260CC65415D0440D002BF2E0 /* OptionValueUUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260CC64715D0440D002BF2E0 /* OptionValueUUID.cpp */; }; 2689008613353E2200698AC0 /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8610F1B85900F91463 /* Options.cpp */; }; + 4C639ED121FA684900A7B957 /* OptionsWithRawTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC321FA684700A7B957 /* OptionsWithRawTest.cpp */; }; 4C562CC71CC07DF700C52EAC /* PDBASTParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C562CC21CC07DDD00C52EAC /* PDBASTParser.cpp */; }; 4CA0C6CC20F929C700CFE6BB /* PDBLocationToDWARFExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0C6CA20F929C600CFE6BB /* PDBLocationToDWARFExpression.cpp */; }; 268900EE13353E6F00698AC0 /* PathMappingList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 495BBACB119A0DBE00418BEA /* PathMappingList.cpp */; }; 2668A2EE20AF417D00D94111 /* PathMappingListTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2668A2ED20AF417D00D94111 /* PathMappingListTest.cpp */; }; + AF815DF921C855B400023A34 /* PdbAstBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF815DF721C855B400023A34 /* PdbAstBuilder.cpp */; }; + AFD966BA217140B6006714AC /* PdbIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFD966B6217140B6006714AC /* PdbIndex.cpp */; }; + AF0F459E219FA1C800C1E612 /* PdbSymUid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF0F459D219FA1C800C1E612 /* PdbSymUid.cpp */; }; + AFD966B9217140B6006714AC /* PdbUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFD966B5217140B6006714AC /* PdbUtil.cpp */; }; 25420ED21A649D88009ADBCB /* PipeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25420ED11A649D88009ADBCB /* PipeBase.cpp */; }; 2377C2F819E613C100737875 /* PipePosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2377C2F719E613C100737875 /* PipePosix.cpp */; }; 268900EF13353E6F00698AC0 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 264A43BD1320BCEB005B4096 /* Platform.cpp */; }; @@ -649,6 +689,7 @@ 26B7564E14F89356008D9CB3 /* PlatformiOSSimulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B7564C14F89356008D9CB3 /* PlatformiOSSimulator.cpp */; }; AFF81FB320D1CC910010F95E /* PlatformiOSSimulatorCoreSimulatorSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = AFF81FB220D1CC910010F95E /* PlatformiOSSimulatorCoreSimulatorSupport.mm */; }; 2689004713353E0400698AC0 /* PluginManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */; }; + 4C639ECE21FA684900A7B957 /* PredicateTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC021FA684700A7B957 /* PredicateTest.cpp */; }; 268900F013353E6F00698AC0 /* Process.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F3610F1B90C00F91463 /* Process.cpp */; }; 26BC17AB18C7F4CB00D2196D /* ProcessElfCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC17A218C7F4CB00D2196D /* ProcessElfCore.cpp */; }; 2689009F13353E4200698AC0 /* ProcessGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618EE5F1315B29C001D6D71 /* ProcessGDBRemote.cpp */; }; @@ -673,7 +714,6 @@ AF0C112818580CD800C4C45B /* QueueItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF0C112718580CD800C4C45B /* QueueItem.cpp */; }; AF26703B1852D01E00B6CC36 /* QueueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF2670391852D01E00B6CC36 /* QueueList.cpp */; }; 4939EA8D1BD56B6D00084382 /* REPL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4939EA8C1BD56B6D00084382 /* REPL.cpp */; }; - 94BA8B6D176F8C9B005A91B5 /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94BA8B6C176F8C9B005A91B5 /* Range.cpp */; }; 268900F113353E6F00698AC0 /* RegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F3710F1B90C00F91463 /* RegisterContext.cpp */; }; 26957D9813D381C900670048 /* RegisterContextDarwin_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */; }; AF9107EE168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF9107EC168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp */; }; @@ -702,6 +742,10 @@ 26474CBE18D0CB2D0073DEBA /* RegisterContextMach_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CB818D0CB2D0073DEBA /* RegisterContextMach_i386.cpp */; }; 26474CC018D0CB2D0073DEBA /* RegisterContextMach_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CBA18D0CB2D0073DEBA /* RegisterContextMach_x86_64.cpp */; }; 26474CC918D0CB5B0073DEBA /* RegisterContextMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26474CC218D0CB5B0073DEBA /* RegisterContextMemory.cpp */; }; + 2619C4852107A9A2009CDE81 /* RegisterContextMinidump_ARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2619C4812107A9A1009CDE81 /* RegisterContextMinidump_ARM.cpp */; }; + 2619C4872107A9A2009CDE81 /* RegisterContextMinidump_ARM.h in Headers */ = {isa = PBXBuildFile; fileRef = 2619C4832107A9A2009CDE81 /* RegisterContextMinidump_ARM.h */; }; + 2619C4842107A9A2009CDE81 /* RegisterContextMinidump_ARM64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2619C4802107A9A1009CDE81 /* RegisterContextMinidump_ARM64.cpp */; }; + 2619C4862107A9A2009CDE81 /* RegisterContextMinidump_ARM64.h in Headers */ = {isa = PBXBuildFile; fileRef = 2619C4822107A9A2009CDE81 /* RegisterContextMinidump_ARM64.h */; }; 947CF7761DC7B20D00EF980B /* RegisterContextMinidump_x86_32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 947CF7741DC7B20D00EF980B /* RegisterContextMinidump_x86_32.cpp */; }; AFD65C811D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFD65C7F1D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp */; }; AFD65C821D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = AFD65C801D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h */; }; @@ -735,11 +779,14 @@ 2654A6831E54D5E200DA1013 /* RegisterNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2654A6821E54D5E200DA1013 /* RegisterNumber.cpp */; }; 4CA9D1401FCE07CD00300E18 /* RegisterUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9D13C1FCE07AF00300E18 /* RegisterUtilities.cpp */; }; 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; + 4C639ED221FA684900A7B957 /* RegisterValueTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC421FA684800A7B957 /* RegisterValueTest.cpp */; }; 26764CA01E48F528008D3573 /* RegularExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764C9F1E48F528008D3573 /* RegularExpression.cpp */; }; 23D0658F1D4A7BEE0008EDE6 /* RenderScriptExpressionOpts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D065821D4A7BDA0008EDE6 /* RenderScriptExpressionOpts.cpp */; }; 23D065901D4A7BEE0008EDE6 /* RenderScriptRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D065841D4A7BDA0008EDE6 /* RenderScriptRuntime.cpp */; }; 9485545A1DCBAE3B00345FF5 /* RenderScriptScriptGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 948554591DCBAE3B00345FF5 /* RenderScriptScriptGroup.cpp */; }; 23D065911D4A7BEE0008EDE6 /* RenderScriptx86ABIFixups.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D065861D4A7BDA0008EDE6 /* RenderScriptx86ABIFixups.cpp */; }; + AFCB1D5F219CD5EA00730AD5 /* Reproducer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFCB1D5E219CD5EA00730AD5 /* Reproducer.cpp */; }; + 4C639ECF21FA684900A7B957 /* ReproducerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC121FA684700A7B957 /* ReproducerTest.cpp */; }; 4FBC04ED211A06200015A814 /* RichManglingContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FBC04EC211A06200015A814 /* RichManglingContext.cpp */; }; 4FBC04EF211A06820015A814 /* RichManglingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FBC04EE211A06820015A814 /* RichManglingContext.h */; }; 4FBC04F5211A13770015A814 /* RichManglingContextTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FBC04F3211A0F0F0015A814 /* RichManglingContextTest.cpp */; }; @@ -791,6 +838,8 @@ 26DE205311618FAC00A093E2 /* SBFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE205211618FAC00A093E2 /* SBFunction.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; }; 9A3576A8116E9AB700E8ED2F /* SBHostOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AFB2F2F621B71AF30078DEF1 /* SBInitializerOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFB2F2F421B71AE90078DEF1 /* SBInitializerOptions.cpp */; }; + 4C38996D21BA11CA002BAEF4 /* SBInitializerOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C38996C21BA11CA002BAEF4 /* SBInitializerOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; }; 9AC7038E117674FB0086C050 /* SBInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038D117674EB0086C050 /* SBInstruction.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; }; @@ -892,7 +941,7 @@ 26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */; }; 23CB15451D66DA9300EDDDE1 /* SocketAddressTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2321F9391BDD332400BA9A93 /* SocketAddressTest.cpp */; }; 23CB153B1D66DA9300EDDDE1 /* SocketTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2321F93A1BDD332400BA9A93 /* SocketTest.cpp */; }; - 232CB61D191E00CD00EF39FC /* SoftwareBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 232CB613191E00CC00EF39FC /* SoftwareBreakpoint.cpp */; }; + 26603879211CA90F00329572 /* SourceBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26603870211CA90D00329572 /* SourceBreakpoint.cpp */; }; 2689004C13353E0400698AC0 /* SourceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8F10F1B85900F91463 /* SourceManager.cpp */; }; 268900F313353E6F00698AC0 /* StackFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F3810F1B90C00F91463 /* StackFrame.cpp */; }; 268900F413353E6F00698AC0 /* StackFrameList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F3910F1B90C00F91463 /* StackFrameList.cpp */; }; @@ -915,12 +964,15 @@ AFC2DCF91E6E318000283714 /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCF81E6E318000283714 /* StreamGDBRemote.cpp */; }; 26764CA21E48F547008D3573 /* StreamString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764CA11E48F547008D3573 /* StreamString.cpp */; }; 58EAC73F2106A07B0029571E /* StreamTeeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */; }; + 4C639ECD21FA684900A7B957 /* StreamTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EBF21FA684700A7B957 /* StreamTest.cpp */; }; 33E5E8471A674FB60024ED68 /* StringConvert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33E5E8411A672A240024ED68 /* StringConvert.cpp */; }; 2689011113353E8200698AC0 /* StringExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2660D9F611922A1300958FBD /* StringExtractor.cpp */; }; 2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */; }; 23CB15411D66DA9300EDDDE1 /* StringExtractorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2321F9441BDD346100BA9A93 /* StringExtractorTest.cpp */; }; 94380B8219940B0A00BFE4A8 /* StringLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94380B8119940B0A00BFE4A8 /* StringLexer.cpp */; }; + 4C639ED421FA684900A7B957 /* StringLexerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC621FA684800A7B957 /* StringLexerTest.cpp */; }; 2689005113353E0400698AC0 /* StringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A35765F116E76B900E8ED2F /* StringList.cpp */; }; + 4C639ECC21FA684900A7B957 /* StringListTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EBE21FA684600A7B957 /* StringListTest.cpp */; }; 94F48F251A01C687005C0EC6 /* StringPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94F48F241A01C687005C0EC6 /* StringPrinter.cpp */; }; AFEC3362194A8ABA00FF05C6 /* StructuredData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */; }; 238F2BA81D2C85FA001FF92A /* StructuredDataDarwinLog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 238F2BA61D2C85FA001FF92A /* StructuredDataDarwinLog.cpp */; }; @@ -931,12 +983,14 @@ 268900DD13353E6F00698AC0 /* Symbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1B10F1B8EC00F91463 /* Symbol.cpp */; }; 268900DE13353E6F00698AC0 /* SymbolContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1C10F1B8EC00F91463 /* SymbolContext.cpp */; }; 268900DF13353E6F00698AC0 /* SymbolFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F1D10F1B8EC00F91463 /* SymbolFile.cpp */; }; + AF97744721E9947E006876A7 /* SymbolFileBreakpad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF97744621E9947B006876A7 /* SymbolFileBreakpad.cpp */; }; 268900CA13353E5F00698AC0 /* SymbolFileDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */; }; 268900CC13353E5F00698AC0 /* SymbolFileDWARFDebugMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89DB10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.cpp */; }; 6D95DC021B9DC057000E318A /* SymbolFileDWARFDwo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D95DBFF1B9DC057000E318A /* SymbolFileDWARFDwo.cpp */; }; 4C7D48251F5099B2005314B4 /* SymbolFileDWARFDwoDwp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7D481F1F509964005314B4 /* SymbolFileDWARFDwoDwp.cpp */; }; 4C7D48241F5099A1005314B4 /* SymbolFileDWARFDwp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7D481C1F509963005314B4 /* SymbolFileDWARFDwp.cpp */; }; 9A2057121F3B824B00F6C293 /* SymbolFileDWARFTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A20570A1F3B81F300F6C293 /* SymbolFileDWARFTests.cpp */; }; + AFD966BB217140B6006714AC /* SymbolFileNativePDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFD966B7217140B6006714AC /* SymbolFileNativePDB.cpp */; }; AF6335E21C87B21E00F7D554 /* SymbolFilePDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF6335E01C87B21E00F7D554 /* SymbolFilePDB.cpp */; }; 268900CE13353E5F00698AC0 /* SymbolFileSymtab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89DE10F57C5600BB2B04 /* SymbolFileSymtab.cpp */; }; 268900E013353E6F00698AC0 /* SymbolVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF94005711C03F6500085DB9 /* SymbolVendor.cpp */; }; @@ -1018,6 +1072,8 @@ 54067BF11DF2041B00749AA5 /* UBSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54067BEC1DF2034B00749AA5 /* UBSanRuntime.cpp */; }; 2579065D1BD0488100178368 /* UDPSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2579065B1BD0488100178368 /* UDPSocket.cpp */; }; 49CA97001E6AACC900C03FEE /* UUID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */; }; + 4C639ED021FA684900A7B957 /* UUIDTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639EC221FA684700A7B957 /* UUIDTest.cpp */; }; + AF0578C4217FA80700CF9D80 /* UdtRecordCompleter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF0578C2217FA80700CF9D80 /* UdtRecordCompleter.cpp */; }; 268900CD13353E5F00698AC0 /* UniqueDWARFASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B8B42312EEC52A00A831B2 /* UniqueDWARFASTType.cpp */; }; 2689010C13353E6F00698AC0 /* UnixSignals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C00987011500B4300F316B0 /* UnixSignals.cpp */; }; 9A2057201F3B8D2500F6C293 /* UnixSignalsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A20571E1F3B8D2100F6C293 /* UnixSignalsTest.cpp */; }; @@ -1037,6 +1093,8 @@ 2654A6901E552ED500DA1013 /* VASprintf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2654A68F1E552ED500DA1013 /* VASprintf.cpp */; }; 9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C41F3150D200EB767C /* VASprintfTest.cpp */; }; AFC2DCF01E6E2FD200283714 /* VMRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCEF1E6E2FD200283714 /* VMRange.cpp */; }; + 4C639ED821FA684900A7B957 /* VMRangeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C639ECA21FA684900A7B957 /* VMRangeTest.cpp */; }; + 26603878211CA90F00329572 /* VSCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2660386E211CA90D00329572 /* VSCode.cpp */; }; 2689005613353E0400698AC0 /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9910F1B85900F91463 /* Value.cpp */; }; 2689005713353E0400698AC0 /* ValueObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */; }; 94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */; }; @@ -1087,8 +1145,8 @@ 23CB154D1D66DA9300EDDDE1 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2326CF471BDD67C100A5CEAC /* libncurses.dylib */; }; 2670F8121862B44A006B332C /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; }; 26780C611867C33D00234593 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; }; - 49A9B8C21BB4AF1C006D7743 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; }; 94C4F2CC1A96A3B200029D70 /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2670F8111862B44A006B332C /* libncurses.dylib */; }; + 26792622211CA41E00EE1D10 /* libncurses.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 26792621211CA41E00EE1D10 /* libncurses.tbd */; }; 26680233115FD1A7008E1FE4 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 2326CF4F1BDD687800A5CEAC /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2326CF4E1BDD687800A5CEAC /* libpanel.dylib */; }; 23CB154A1D66DA9300EDDDE1 /* libpanel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2326CF4E1BDD687800A5CEAC /* libpanel.dylib */; }; @@ -1113,6 +1171,7 @@ E769331E1A94D18100C73337 /* lldb-server.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E769331D1A94D18100C73337 /* lldb-server.cpp */; }; 26680214115FD12C008E1FE4 /* lldb-types.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2910F1B3BC00F91463 /* lldb-types.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94145431175E63B500284436 /* lldb-versioning.h in Headers */ = {isa = PBXBuildFile; fileRef = 94145430175D7FDE00284436 /* lldb-versioning.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2679261E211CA3F200EE1D10 /* lldb-vscode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26792619211CA3E100EE1D10 /* lldb-vscode.cpp */; }; AF4C10152065C7CB00698839 /* lldb.1 in Copy Files */ = {isa = PBXBuildFile; fileRef = AF90106315AB7C5700FF120D /* lldb.1 */; }; AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = AF90106315AB7C5700FF120D /* lldb.1 */; }; 2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7410F1B85900F91463 /* lldb.cpp */; }; @@ -1191,6 +1250,13 @@ remoteGlobalIDString = 26680206115FD0ED008E1FE4; remoteInfo = LLDB; }; + 2679261F211CA40700EE1D10 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 26680206115FD0ED008E1FE4; + remoteInfo = LLDB; + }; 2687EACA1508115000DD8C2E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; @@ -1327,6 +1393,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 2679260A211CA3AC00EE1D10 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; 49753FB21BEAB2BB00019E45 /* Copy Files */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; @@ -1511,6 +1586,7 @@ 2361029E1CF38A3500B8E0B9 /* Android.cmake */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.cmake; sourceTree = ""; }; 6D55BAE21A8CD06000A70529 /* Android.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Android.h; path = include/lldb/Host/android/Android.h; sourceTree = ""; }; 26CF992414428766001E4138 /* AnsiTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnsiTerminal.h; path = include/lldb/Utility/AnsiTerminal.h; sourceTree = ""; }; + 4C639EC721FA684800A7B957 /* AnsiTerminalTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnsiTerminalTest.cpp; sourceTree = ""; }; 4CD44CFA20B37C440003557C /* AppleDWARFIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleDWARFIndex.cpp; sourceTree = ""; }; 4CD44CFF20B37C580003557C /* AppleDWARFIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleDWARFIndex.h; sourceTree = ""; }; AF0E22EE18A09FB20009B7D1 /* AppleGetItemInfoHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleGetItemInfoHandler.cpp; sourceTree = ""; }; @@ -1542,6 +1618,8 @@ 23E2E5161D903689006F38BB /* ArchSpecTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArchSpecTest.cpp; sourceTree = ""; }; AF2E02A11FA2CEAF00A86C34 /* ArchitectureArm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArchitectureArm.cpp; sourceTree = ""; }; AF2E02A21FA2CEAF00A86C34 /* ArchitectureArm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArchitectureArm.h; sourceTree = ""; }; + 2647B63021C4366300A81D15 /* ArchitectureMips.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchitectureMips.cpp; path = source/Plugins/Architecture/Mips/ArchitectureMips.cpp; sourceTree = SOURCE_ROOT; }; + 2647B62F21C4366200A81D15 /* ArchitectureMips.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ArchitectureMips.h; path = source/Plugins/Architecture/Mips/ArchitectureMips.h; sourceTree = SOURCE_ROOT; }; 4C14CEF82057258D00DEEF94 /* ArchitecturePPC64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArchitecturePPC64.cpp; sourceTree = ""; }; 4C14CEF72057258D00DEEF94 /* ArchitecturePPC64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArchitecturePPC64.h; sourceTree = ""; }; 26BC7E6C10F1B85900F91463 /* Args.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Args.cpp; path = source/Utility/Args.cpp; sourceTree = ""; }; @@ -1558,8 +1636,12 @@ 26BC7C5510F1B6E900F91463 /* Block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Block.h; path = include/lldb/Symbol/Block.h; sourceTree = ""; }; 49DEF11F1CD7BD90006A7C7D /* BlockPointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlockPointer.cpp; path = Language/CPlusPlus/BlockPointer.cpp; sourceTree = ""; }; 49DEF1201CD7BD90006A7C7D /* BlockPointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlockPointer.h; path = Language/CPlusPlus/BlockPointer.h; sourceTree = ""; }; + 4CAEC6A621F26D15007C3DD5 /* BreakpadRecords.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BreakpadRecords.cpp; sourceTree = ""; }; + 4CAEC6A721F26D15007C3DD5 /* BreakpadRecords.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BreakpadRecords.h; sourceTree = ""; }; 26BC7E0A10F1B83100F91463 /* Breakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Breakpoint.cpp; path = source/Breakpoint/Breakpoint.cpp; sourceTree = ""; }; 26BC7CEE10F1B71400F91463 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Breakpoint.h; path = include/lldb/Breakpoint/Breakpoint.h; sourceTree = ""; }; + 2660387D211CA98200329572 /* BreakpointBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointBase.cpp; path = "tools/lldb-vscode/BreakpointBase.cpp"; sourceTree = ""; }; + 26603872211CA90D00329572 /* BreakpointBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BreakpointBase.h; path = "tools/lldb-vscode/BreakpointBase.h"; sourceTree = ""; }; 26BC7E0B10F1B83100F91463 /* BreakpointID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointID.cpp; path = source/Breakpoint/BreakpointID.cpp; sourceTree = ""; }; 26BC7CEF10F1B71400F91463 /* BreakpointID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BreakpointID.h; path = include/lldb/Breakpoint/BreakpointID.h; sourceTree = ""; }; 26BC7E0C10F1B83100F91463 /* BreakpointIDList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointIDList.cpp; path = source/Breakpoint/BreakpointIDList.cpp; sourceTree = ""; }; @@ -1593,8 +1675,8 @@ 26BC7CF710F1B71400F91463 /* BreakpointSite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BreakpointSite.h; path = include/lldb/Breakpoint/BreakpointSite.h; sourceTree = ""; }; 26BC7E1410F1B83100F91463 /* BreakpointSiteList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointSiteList.cpp; path = source/Breakpoint/BreakpointSiteList.cpp; sourceTree = ""; }; 26BC7CF810F1B71400F91463 /* BreakpointSiteList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BreakpointSiteList.h; path = include/lldb/Breakpoint/BreakpointSiteList.h; sourceTree = ""; }; - 26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Broadcaster.cpp; path = source/Core/Broadcaster.cpp; sourceTree = ""; }; - 26BC7D5410F1B77400F91463 /* Broadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Broadcaster.h; path = include/lldb/Core/Broadcaster.h; sourceTree = ""; }; + 2647B63921C436AB00A81D15 /* Broadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Broadcaster.cpp; path = source/Utility/Broadcaster.cpp; sourceTree = ""; }; + 2647B63521C4368300A81D15 /* Broadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Broadcaster.h; path = include/lldb/Utility/Broadcaster.h; sourceTree = ""; }; 23CB14E61D66CC0E00EDDDE1 /* BroadcasterTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BroadcasterTest.cpp; sourceTree = ""; }; 949EEDAC1BA76719008C63CF /* CF.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CF.cpp; path = Language/ObjC/CF.cpp; sourceTree = ""; }; 94B9E5031BBEFCF6000A48DC /* CF.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CF.h; path = Language/ObjC/CF.h; sourceTree = ""; }; @@ -1632,6 +1714,7 @@ 23D065811D4A7BDA0008EDE6 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 23E2E5361D9048FB006F38BB /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 2669415B1A6DC2AB0063BE93 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CMakeLists.txt; path = "tools/lldb-mi/CMakeLists.txt"; sourceTree = SOURCE_ROOT; }; + 26792617211CA3E100EE1D10 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CMakeLists.txt; path = "tools/lldb-vscode/CMakeLists.txt"; sourceTree = ""; }; 9A1890311F47D5D400394BCA /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CMakeLists.txt; path = TestingSupport/CMakeLists.txt; sourceTree = ""; }; 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CPPLanguageRuntime.cpp; path = source/Target/CPPLanguageRuntime.cpp; sourceTree = ""; }; 4CB443BB1249920C00C13DC2 /* CPPLanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CPPLanguageRuntime.h; path = include/lldb/Target/CPPLanguageRuntime.h; sourceTree = ""; }; @@ -1731,6 +1814,8 @@ 26DFBC52113B48D600DD817F /* CommandObjectRegexCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectRegexCommand.h; path = include/lldb/Interpreter/CommandObjectRegexCommand.h; sourceTree = ""; }; 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectRegister.cpp; path = source/Commands/CommandObjectRegister.cpp; sourceTree = ""; }; 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectRegister.h; path = source/Commands/CommandObjectRegister.h; sourceTree = ""; }; + AFCB1D5A219CD5A700730AD5 /* CommandObjectReproducer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectReproducer.cpp; path = source/Commands/CommandObjectReproducer.cpp; sourceTree = ""; }; + AFCB1D5B219CD5A700730AD5 /* CommandObjectReproducer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectReproducer.h; path = source/Commands/CommandObjectReproducer.h; sourceTree = ""; }; 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectScript.cpp; path = source/Interpreter/CommandObjectScript.cpp; sourceTree = ""; }; 26BC7D2410F1B76300F91463 /* CommandObjectScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectScript.h; path = source/Interpreter/CommandObjectScript.h; sourceTree = ""; }; 26BC7E4010F1B84700F91463 /* CommandObjectSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSettings.cpp; path = source/Commands/CommandObjectSettings.cpp; sourceTree = ""; }; @@ -1763,6 +1848,8 @@ 964463ED1A330C1B00154ED8 /* CompactUnwindInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactUnwindInfo.h; path = include/lldb/Symbol/CompactUnwindInfo.h; sourceTree = ""; }; 26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompileUnit.cpp; path = source/Symbol/CompileUnit.cpp; sourceTree = ""; }; 26BC7C5710F1B6E900F91463 /* CompileUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompileUnit.h; path = include/lldb/Symbol/CompileUnit.h; sourceTree = ""; }; + AFD966B4217140B5006714AC /* CompileUnitIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompileUnitIndex.cpp; path = source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp; sourceTree = SOURCE_ROOT; }; + AFD966BD217140C8006714AC /* CompileUnitIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CompileUnitIndex.h; path = source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h; sourceTree = SOURCE_ROOT; }; 265192C51BA8E905002F08F6 /* CompilerDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompilerDecl.cpp; path = source/Symbol/CompilerDecl.cpp; sourceTree = ""; }; 265192C41BA8E8F8002F08F6 /* CompilerDecl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CompilerDecl.h; path = include/lldb/Symbol/CompilerDecl.h; sourceTree = ""; }; 2657AFB61B86910100958979 /* CompilerDeclContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompilerDeclContext.cpp; path = source/Symbol/CompilerDeclContext.cpp; sourceTree = ""; }; @@ -1771,6 +1858,7 @@ 49E45FA911F660DC008F7B28 /* CompilerType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompilerType.h; path = include/lldb/Symbol/CompilerType.h; sourceTree = ""; }; 58EC744020EAEB5200695209 /* CompletionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompletionRequest.cpp; path = source/Utility/CompletionRequest.cpp; sourceTree = ""; }; 58EC744220EAEB6C00695209 /* CompletionRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CompletionRequest.h; path = include/lldb/Utility/CompletionRequest.h; sourceTree = ""; }; + 4C639EC921FA684800A7B957 /* CompletionRequestTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompletionRequestTest.cpp; sourceTree = ""; }; 266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = ""; }; 3FDFE53C19A293CA009756A7 /* Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/freebsd/Config.h; sourceTree = ""; }; 3FDFE56319AF9B77009756A7 /* Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/linux/Config.h; sourceTree = SOURCE_ROOT; }; @@ -1839,6 +1927,8 @@ 260C89D410F57C5600BB2B04 /* DWARFFormValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFFormValue.h; sourceTree = ""; }; 4CD44CF820B37C440003557C /* DWARFIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFIndex.cpp; sourceTree = ""; }; 4CD44CFE20B37C570003557C /* DWARFIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DWARFIndex.h; sourceTree = ""; }; + 4C38996221B9AECC002BAEF4 /* DWARFLocationExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DWARFLocationExpression.cpp; path = source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp; sourceTree = SOURCE_ROOT; }; + 4C38996321B9AECC002BAEF4 /* DWARFLocationExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DWARFLocationExpression.h; path = source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h; sourceTree = SOURCE_ROOT; }; 7F2AAA5920601BE000A422D8 /* DWARFUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFUnit.cpp; sourceTree = ""; }; 7F2AAA5820601BDF00A422D8 /* DWARFUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFUnit.h; sourceTree = ""; }; 26FFC19514FC072100087D58 /* DYLDRendezvous.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DYLDRendezvous.cpp; sourceTree = ""; }; @@ -1852,7 +1942,7 @@ 49CA96F31E6AAC8E00C03FEE /* DataEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataEncoder.h; path = include/lldb/Utility/DataEncoder.h; sourceTree = ""; }; 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataExtractor.cpp; path = source/Utility/DataExtractor.cpp; sourceTree = ""; }; 49CA96F41E6AAC8E00C03FEE /* DataExtractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataExtractor.h; path = include/lldb/Utility/DataExtractor.h; sourceTree = ""; }; - 23CB14E81D66CC0E00EDDDE1 /* DataExtractorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataExtractorTest.cpp; sourceTree = ""; }; + AFA1B62B219E0ED900A8AB7E /* DataExtractorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataExtractorTest.cpp; sourceTree = ""; }; 94CB255816B069770059775D /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataVisualization.cpp; path = source/DataFormatters/DataVisualization.cpp; sourceTree = ""; }; 94CB256016B069800059775D /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataVisualization.h; path = include/lldb/DataFormatters/DataVisualization.h; sourceTree = ""; }; 3FDFED1E19BA6D55009756A7 /* Debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Debug.h; path = include/lldb/Host/Debug.h; sourceTree = ""; }; @@ -1924,8 +2014,12 @@ 26BC7DD310F1B7D500F91463 /* Endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Endian.h; path = include/lldb/Utility/Endian.h; sourceTree = ""; }; 22DC561920064C9600A7E9E8 /* Environment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Environment.cpp; path = source/Utility/Environment.cpp; sourceTree = ""; }; 6B74D89C2006972D0074051B /* Environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Environment.h; path = include/lldb/Utility/Environment.h; sourceTree = ""; }; - 26BC7E7910F1B85900F91463 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Event.cpp; path = source/Core/Event.cpp; sourceTree = ""; }; - 26BC7D6110F1B77400F91463 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Event.h; path = include/lldb/Core/Event.h; sourceTree = ""; }; + 4C639EBD21FA684600A7B957 /* EnvironmentTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnvironmentTest.cpp; sourceTree = ""; }; + 2647B63B21C436B400A81D15 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Event.cpp; path = source/Utility/Event.cpp; sourceTree = ""; }; + 2647B63321C4367A00A81D15 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Event.h; path = include/lldb/Utility/Event.h; sourceTree = ""; }; + 4C639EC521FA684800A7B957 /* EventTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventTest.cpp; sourceTree = ""; }; + 26603874211CA90E00329572 /* ExceptionBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExceptionBreakpoint.cpp; path = "tools/lldb-vscode/ExceptionBreakpoint.cpp"; sourceTree = ""; }; + 26603873211CA90E00329572 /* ExceptionBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExceptionBreakpoint.h; path = "tools/lldb-vscode/ExceptionBreakpoint.h"; sourceTree = ""; }; 26BC7F3510F1B90C00F91463 /* ExecutionContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExecutionContext.cpp; path = source/Target/ExecutionContext.cpp; sourceTree = ""; }; 26BC7DF210F1B81A00F91463 /* ExecutionContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionContext.h; path = include/lldb/Target/ExecutionContext.h; sourceTree = ""; }; 26DAFD9711529BC7005A394E /* ExecutionContextScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionContextScope.h; path = include/lldb/Target/ExecutionContextScope.h; sourceTree = ""; }; @@ -1944,6 +2038,8 @@ 3FDFD6C3199C396E009756A7 /* FileAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileAction.h; path = include/lldb/Target/FileAction.h; sourceTree = ""; }; 3FDFDDBE199D345E009756A7 /* FileCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileCache.cpp; path = source/Host/common/FileCache.cpp; sourceTree = ""; }; 3FDFDDC0199D34E2009756A7 /* FileCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FileCache.h; path = include/lldb/Host/FileCache.h; sourceTree = ""; }; + DD8F277D22011CC9004ED75B /* FileCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileCollector.cpp; path = source/Utility/FileCollector.cpp; sourceTree = ""; }; + DD8F278022011D0F004ED75B /* FileCollectorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileCollectorTest.cpp; sourceTree = ""; }; 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileLineResolver.cpp; path = source/Core/FileLineResolver.cpp; sourceTree = ""; }; 26BD407D135D2AC400237D80 /* FileLineResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FileLineResolver.h; path = include/lldb/Core/FileLineResolver.h; sourceTree = ""; }; 239D38091D70FB9900D8E937 /* FileSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSpec.cpp; path = source/Utility/FileSpec.cpp; sourceTree = ""; }; @@ -1958,6 +2054,7 @@ 3FDFDDC1199D34E2009756A7 /* FileSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FileSystem.h; path = include/lldb/Host/FileSystem.h; sourceTree = ""; }; 9A20572E1F3B8E7600F6C293 /* FileSystemTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemTest.cpp; sourceTree = ""; }; 4CBFF0471F579A36004AFA92 /* Flags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Flags.h; path = include/lldb/Utility/Flags.h; sourceTree = ""; }; + 4C639EC821FA684800A7B957 /* FlagsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlagsTest.cpp; sourceTree = ""; }; 94CB257316B1D3870059775D /* FormatCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatCache.cpp; path = source/DataFormatters/FormatCache.cpp; sourceTree = ""; }; 94CB257516B1D3910059775D /* FormatCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatCache.h; path = include/lldb/DataFormatters/FormatCache.h; sourceTree = ""; }; 94CB255916B069770059775D /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/DataFormatters/FormatClasses.cpp; sourceTree = ""; }; @@ -1981,6 +2078,8 @@ 269FF07D12494F7D00225026 /* FuncUnwinders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FuncUnwinders.h; path = include/lldb/Symbol/FuncUnwinders.h; sourceTree = ""; }; 26BC7F1810F1B8EC00F91463 /* Function.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Function.cpp; path = source/Symbol/Function.cpp; sourceTree = ""; }; 26BC7C5A10F1B6E900F91463 /* Function.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Function.h; path = include/lldb/Symbol/Function.h; sourceTree = ""; }; + 26603877211CA90E00329572 /* FunctionBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FunctionBreakpoint.cpp; path = "tools/lldb-vscode/FunctionBreakpoint.cpp"; sourceTree = ""; }; + 26603871211CA90D00329572 /* FunctionBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FunctionBreakpoint.h; path = "tools/lldb-vscode/FunctionBreakpoint.h"; sourceTree = ""; }; 4C0083321B9A5DE200D5CF24 /* FunctionCaller.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FunctionCaller.cpp; path = source/Expression/FunctionCaller.cpp; sourceTree = ""; }; 4C00832D1B9A58A700D5CF24 /* FunctionCaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FunctionCaller.h; path = include/lldb/Expression/FunctionCaller.h; sourceTree = ""; }; 2374D74E1D4BB299005C9575 /* GDBRemoteClientBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteClientBase.cpp; sourceTree = ""; }; @@ -1991,6 +2090,10 @@ 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationClient.cpp; sourceTree = ""; }; 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationClient.h; sourceTree = ""; }; 2370A37E1D66C587000E7BE6 /* GDBRemoteCommunicationClientTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationClientTest.cpp; sourceTree = ""; }; + AF8AD943219CD45700614785 /* GDBRemoteCommunicationHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationHistory.cpp; sourceTree = ""; }; + AF8AD944219CD45700614785 /* GDBRemoteCommunicationHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationHistory.h; sourceTree = ""; }; + AFCB1D57219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationReplayServer.cpp; sourceTree = ""; }; + AFCB1D56219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationReplayServer.h; sourceTree = ""; }; 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationServer.cpp; sourceTree = ""; }; 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GDBRemoteCommunicationServer.h; sourceTree = ""; }; 6D55B28D1A8A806200A70529 /* GDBRemoteCommunicationServerCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GDBRemoteCommunicationServerCommon.cpp; sourceTree = ""; }; @@ -2103,6 +2206,8 @@ 6D762BEC1B1605CD006C929D /* LLDBServerUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LLDBServerUtilities.cpp; path = "tools/lldb-server/LLDBServerUtilities.cpp"; sourceTree = ""; }; 6D762BED1B1605CD006C929D /* LLDBServerUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLDBServerUtilities.h; path = "tools/lldb-server/LLDBServerUtilities.h"; sourceTree = ""; }; 2361029A1CF38A2B00B8E0B9 /* LLDBStandalone.cmake */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LLDBStandalone.cmake; sourceTree = ""; }; + 26F76199211CBBB30044F6EA /* LLDBUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLDBUtils.cpp; path = "tools/lldb-vscode/LLDBUtils.cpp"; sourceTree = ""; }; + 26F7619A211CBBB30044F6EA /* LLDBUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDBUtils.h; path = "tools/lldb-vscode/LLDBUtils.h"; sourceTree = ""; }; 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = LLDBWrapPython.cpp; sourceTree = BUILT_PRODUCTS_DIR; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; AEB0E4581BD6E9F800B24093 /* LLVMUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLVMUserExpression.cpp; path = source/Expression/LLVMUserExpression.cpp; sourceTree = ""; }; AEB0E45A1BD6EA1400B24093 /* LLVMUserExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLVMUserExpression.h; path = include/lldb/Expression/LLVMUserExpression.h; sourceTree = ""; }; @@ -2136,10 +2241,12 @@ 26BC7C5B10F1B6E900F91463 /* LineEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LineEntry.h; path = include/lldb/Symbol/LineEntry.h; sourceTree = ""; }; 26BC7F1A10F1B8EC00F91463 /* LineTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LineTable.cpp; path = source/Symbol/LineTable.cpp; sourceTree = ""; }; 26BC7C5C10F1B6E900F91463 /* LineTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LineTable.h; path = include/lldb/Symbol/LineTable.h; sourceTree = ""; }; + 2647B64221C43BB000A81D15 /* LinuxProcMaps.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LinuxProcMaps.cpp; path = Utility/LinuxProcMaps.cpp; sourceTree = ""; }; + 2647B64121C43BAF00A81D15 /* LinuxProcMaps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LinuxProcMaps.h; path = Utility/LinuxProcMaps.h; sourceTree = ""; }; 23059A0519532B96007B8189 /* LinuxSignals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LinuxSignals.cpp; path = Utility/LinuxSignals.cpp; sourceTree = ""; }; 23059A0619532B96007B8189 /* LinuxSignals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LinuxSignals.h; path = Utility/LinuxSignals.h; sourceTree = ""; }; - 26BC7E7E10F1B85900F91463 /* Listener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Listener.cpp; path = source/Core/Listener.cpp; sourceTree = ""; }; - 26BC7D6710F1B77400F91463 /* Listener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Listener.h; path = include/lldb/Core/Listener.h; sourceTree = ""; }; + 2647B63D21C436BC00A81D15 /* Listener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Listener.cpp; path = source/Utility/Listener.cpp; sourceTree = ""; }; + 2647B63721C4369500A81D15 /* Listener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Listener.h; path = include/lldb/Utility/Listener.h; sourceTree = ""; }; 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ListenerTest.cpp; sourceTree = ""; }; 255EFF731AFABA720069F277 /* LockFileBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LockFileBase.cpp; sourceTree = ""; }; 255EFF751AFABA950069F277 /* LockFilePosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LockFilePosix.cpp; sourceTree = ""; }; @@ -2302,6 +2409,8 @@ 266941F91A6DC2AC0063BE93 /* MIUtilThreadBaseStd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MIUtilThreadBaseStd.h; path = "tools/lldb-mi/MIUtilThreadBaseStd.h"; sourceTree = SOURCE_ROOT; }; 266941FA1A6DC2AC0063BE93 /* MIUtilVariant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MIUtilVariant.cpp; path = "tools/lldb-mi/MIUtilVariant.cpp"; sourceTree = SOURCE_ROOT; }; 266941FB1A6DC2AC0063BE93 /* MIUtilVariant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MIUtilVariant.h; path = "tools/lldb-mi/MIUtilVariant.h"; sourceTree = SOURCE_ROOT; }; + AF395C01219254F200894EC3 /* MSVCUndecoratedNameParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MSVCUndecoratedNameParser.cpp; path = Language/CPlusPlus/MSVCUndecoratedNameParser.cpp; sourceTree = ""; }; + AF395C00219254F200894EC3 /* MSVCUndecoratedNameParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MSVCUndecoratedNameParser.h; path = Language/CPlusPlus/MSVCUndecoratedNameParser.h; sourceTree = ""; }; D67521351EA17C3900439694 /* MainLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainLoop.cpp; sourceTree = ""; }; 9A2057301F3B8E7600F6C293 /* MainLoopTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainLoopTest.cpp; sourceTree = ""; }; 8C3BD9951EF45D9B0016C343 /* MainThreadCheckerRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MainThreadCheckerRuntime.cpp; sourceTree = ""; }; @@ -2353,9 +2462,6 @@ 9A3D43CB1F3150D200EB767C /* NameMatchesTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameMatchesTest.cpp; sourceTree = ""; }; 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameToDIE.cpp; sourceTree = ""; }; 2618D957124056C700F2B8FE /* NameToDIE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameToDIE.h; sourceTree = ""; }; - 232CB60B191E00CC00EF39FC /* NativeBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeBreakpoint.cpp; path = source/Host/common/NativeBreakpoint.cpp; sourceTree = ""; }; - 267A47F31B14116E0021A5BC /* NativeBreakpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeBreakpoint.h; path = include/lldb/Host/common/NativeBreakpoint.h; sourceTree = ""; }; - 232CB60D191E00CC00EF39FC /* NativeBreakpointList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeBreakpointList.cpp; path = source/Host/common/NativeBreakpointList.cpp; sourceTree = ""; }; 267A47F41B1411750021A5BC /* NativeBreakpointList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeBreakpointList.h; path = include/lldb/Host/common/NativeBreakpointList.h; sourceTree = ""; }; 232CB60F191E00CC00EF39FC /* NativeProcessProtocol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = NativeProcessProtocol.cpp; path = source/Host/common/NativeProcessProtocol.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 267A47F51B14117F0021A5BC /* NativeProcessProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeProcessProtocol.h; path = include/lldb/Host/common/NativeProcessProtocol.h; sourceTree = ""; }; @@ -2386,6 +2492,8 @@ 260C898110F57C5600BB2B04 /* ObjectContainerUniversalMachO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectContainerUniversalMachO.h; sourceTree = ""; }; 26BC7F4C10F1BC1A00F91463 /* ObjectFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFile.cpp; path = source/Symbol/ObjectFile.cpp; sourceTree = ""; }; 26BC7C5E10F1B6E900F91463 /* ObjectFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFile.h; path = include/lldb/Symbol/ObjectFile.h; sourceTree = ""; }; + 4C9BF11921C0467700FA4036 /* ObjectFileBreakpad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFileBreakpad.cpp; sourceTree = ""; }; + 4C9BF11821C0467700FA4036 /* ObjectFileBreakpad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFileBreakpad.h; sourceTree = ""; }; 260C898510F57C5600BB2B04 /* ObjectFileELF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFileELF.cpp; sourceTree = ""; }; 260C898610F57C5600BB2B04 /* ObjectFileELF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFileELF.h; sourceTree = ""; }; 26EFC4CA18CFAF0D00865D87 /* ObjectFileJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFileJIT.cpp; sourceTree = ""; }; @@ -2471,6 +2579,9 @@ 260A248D15D06C4F009981B0 /* OptionValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OptionValues.h; path = include/lldb/Interpreter/OptionValues.h; sourceTree = ""; }; 26BC7E8610F1B85900F91463 /* Options.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Options.cpp; path = source/Interpreter/Options.cpp; sourceTree = ""; }; 26BC7D6D10F1B77400F91463 /* Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Options.h; path = include/lldb/Interpreter/Options.h; sourceTree = ""; }; + DD5F951A21ADE5BD00B8265A /* Options.inc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.pascal; name = Options.inc; path = build/Debug/include/Options.inc; sourceTree = ""; }; + DD5F951B21ADE5F000B8265A /* Options.td */ = {isa = PBXFileReference; lastKnownFileType = text; name = Options.td; path = tools/driver/Options.td; sourceTree = ""; }; + 4C639EC321FA684700A7B957 /* OptionsWithRawTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionsWithRawTest.cpp; sourceTree = ""; }; 4C562CC21CC07DDD00C52EAC /* PDBASTParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PDBASTParser.cpp; path = PDB/PDBASTParser.cpp; sourceTree = ""; }; 4C562CC31CC07DDD00C52EAC /* PDBASTParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDBASTParser.h; path = PDB/PDBASTParser.h; sourceTree = ""; }; 4CA0C6CA20F929C600CFE6BB /* PDBLocationToDWARFExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PDBLocationToDWARFExpression.cpp; path = PDB/PDBLocationToDWARFExpression.cpp; sourceTree = ""; }; @@ -2480,6 +2591,14 @@ 495BBACB119A0DBE00418BEA /* PathMappingList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PathMappingList.cpp; path = source/Target/PathMappingList.cpp; sourceTree = ""; }; 495BBACF119A0DE700418BEA /* PathMappingList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PathMappingList.h; path = include/lldb/Target/PathMappingList.h; sourceTree = ""; }; 2668A2ED20AF417D00D94111 /* PathMappingListTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PathMappingListTest.cpp; path = Target/PathMappingListTest.cpp; sourceTree = ""; }; + AF815DF721C855B400023A34 /* PdbAstBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PdbAstBuilder.cpp; path = source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp; sourceTree = SOURCE_ROOT; }; + AF815DF821C855B400023A34 /* PdbAstBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PdbAstBuilder.h; path = source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h; sourceTree = SOURCE_ROOT; }; + AFD966B6217140B6006714AC /* PdbIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PdbIndex.cpp; path = source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp; sourceTree = SOURCE_ROOT; }; + AFD966BF217140C8006714AC /* PdbIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PdbIndex.h; path = source/Plugins/SymbolFile/NativePDB/PdbIndex.h; sourceTree = SOURCE_ROOT; }; + AF0F459D219FA1C800C1E612 /* PdbSymUid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PdbSymUid.cpp; path = source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp; sourceTree = SOURCE_ROOT; }; + AFD966BC217140C8006714AC /* PdbSymUid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PdbSymUid.h; path = source/Plugins/SymbolFile/NativePDB/PdbSymUid.h; sourceTree = SOURCE_ROOT; }; + AFD966B5217140B6006714AC /* PdbUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PdbUtil.cpp; path = source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp; sourceTree = SOURCE_ROOT; }; + AFD966BE217140C8006714AC /* PdbUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PdbUtil.h; path = source/Plugins/SymbolFile/NativePDB/PdbUtil.h; sourceTree = SOURCE_ROOT; }; 260A39A519647A3A004B4130 /* Pipe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Pipe.h; path = include/lldb/Host/Pipe.h; sourceTree = ""; }; 25420ED11A649D88009ADBCB /* PipeBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PipeBase.cpp; sourceTree = ""; }; 3F5E8AF31A40D4A500A73232 /* PipeBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PipeBase.h; path = include/lldb/Host/PipeBase.h; sourceTree = ""; }; @@ -2534,6 +2653,7 @@ 26BC7D7010F1B77400F91463 /* PluginInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PluginInterface.h; path = include/lldb/Core/PluginInterface.h; sourceTree = ""; }; 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginManager.cpp; path = source/Core/PluginManager.cpp; sourceTree = ""; }; 26BC7D7110F1B77400F91463 /* PluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PluginManager.h; path = include/lldb/Core/PluginManager.h; sourceTree = ""; }; + 4C639EC021FA684700A7B957 /* PredicateTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PredicateTest.cpp; sourceTree = ""; }; 26BC7F3610F1B90C00F91463 /* Process.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Process.cpp; path = source/Target/Process.cpp; sourceTree = ""; }; 26BC7DF310F1B81A00F91463 /* Process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Process.h; path = include/lldb/Target/Process.h; sourceTree = ""; }; 26BC17A218C7F4CB00D2196D /* ProcessElfCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessElfCore.cpp; sourceTree = ""; }; @@ -2587,8 +2707,6 @@ 4939EA8C1BD56B6D00084382 /* REPL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = REPL.cpp; path = source/Expression/REPL.cpp; sourceTree = ""; }; 4939EA8B1BD56B3700084382 /* REPL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = REPL.h; path = include/lldb/Expression/REPL.h; sourceTree = ""; }; 9A2057451F3B905C00F6C293 /* RNBSocketTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RNBSocketTest.cpp; path = debugserver/RNBSocketTest.cpp; sourceTree = ""; }; - 94BA8B6C176F8C9B005A91B5 /* Range.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Range.cpp; path = source/Utility/Range.cpp; sourceTree = ""; }; - 94BA8B6E176F8CA0005A91B5 /* Range.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Range.h; path = include/lldb/Utility/Range.h; sourceTree = ""; }; 2626B6AD143E1BEA00EF935C /* RangeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RangeMap.h; path = include/lldb/Core/RangeMap.h; sourceTree = ""; }; 26AB54111832DC3400EADFF3 /* RegisterCheckpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterCheckpoint.h; path = include/lldb/Target/RegisterCheckpoint.h; sourceTree = ""; }; 26BC7F3710F1B90C00F91463 /* RegisterContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContext.cpp; path = source/Target/RegisterContext.cpp; sourceTree = ""; }; @@ -2646,6 +2764,10 @@ 26474CC218D0CB5B0073DEBA /* RegisterContextMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMemory.cpp; path = Utility/RegisterContextMemory.cpp; sourceTree = ""; }; 262D24E513FB8710002D1960 /* RegisterContextMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMemory.h; path = Utility/RegisterContextMemory.h; sourceTree = ""; }; 26474CC318D0CB5B0073DEBA /* RegisterContextMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMemory.h; path = Utility/RegisterContextMemory.h; sourceTree = ""; }; + 2619C4812107A9A1009CDE81 /* RegisterContextMinidump_ARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextMinidump_ARM.cpp; sourceTree = ""; }; + 2619C4832107A9A2009CDE81 /* RegisterContextMinidump_ARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextMinidump_ARM.h; sourceTree = ""; }; + 2619C4802107A9A1009CDE81 /* RegisterContextMinidump_ARM64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextMinidump_ARM64.cpp; sourceTree = ""; }; + 2619C4822107A9A2009CDE81 /* RegisterContextMinidump_ARM64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextMinidump_ARM64.h; sourceTree = ""; }; 947CF7741DC7B20D00EF980B /* RegisterContextMinidump_x86_32.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextMinidump_x86_32.cpp; sourceTree = ""; }; 947CF7721DC7B20300EF980B /* RegisterContextMinidump_x86_32.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RegisterContextMinidump_x86_32.h; sourceTree = ""; }; AFD65C7F1D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextMinidump_x86_64.cpp; sourceTree = ""; }; @@ -2722,8 +2844,9 @@ 2654A6841E54D5EE00DA1013 /* RegisterNumber.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterNumber.h; path = include/lldb/Target/RegisterNumber.h; sourceTree = ""; }; 4CA9D13C1FCE07AF00300E18 /* RegisterUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterUtilities.cpp; sourceTree = ""; }; 4CA9D13D1FCE07AF00300E18 /* RegisterUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterUtilities.h; sourceTree = ""; }; - 26C6886E137880C400407EDF /* RegisterValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterValue.cpp; path = source/Core/RegisterValue.cpp; sourceTree = ""; }; - 26C6886D137880B900407EDF /* RegisterValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterValue.h; path = include/lldb/Core/RegisterValue.h; sourceTree = ""; }; + 26C6886E137880C400407EDF /* RegisterValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterValue.cpp; path = source/Utility/RegisterValue.cpp; sourceTree = ""; }; + 26C6886D137880B900407EDF /* RegisterValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegisterValue.h; path = include/lldb/Utility/RegisterValue.h; sourceTree = ""; }; + 4C639EC421FA684800A7B957 /* RegisterValueTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterValueTest.cpp; sourceTree = ""; }; 26764C9F1E48F528008D3573 /* RegularExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegularExpression.cpp; path = source/Utility/RegularExpression.cpp; sourceTree = ""; }; 26764C9C1E48F516008D3573 /* RegularExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RegularExpression.h; path = include/lldb/Utility/RegularExpression.h; sourceTree = ""; }; 23D065821D4A7BDA0008EDE6 /* RenderScriptExpressionOpts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderScriptExpressionOpts.cpp; sourceTree = ""; }; @@ -2734,6 +2857,8 @@ 948554581DCBAE3200345FF5 /* RenderScriptScriptGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderScriptScriptGroup.h; sourceTree = ""; }; 23D065861D4A7BDA0008EDE6 /* RenderScriptx86ABIFixups.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderScriptx86ABIFixups.cpp; sourceTree = ""; }; 23D065871D4A7BDA0008EDE6 /* RenderScriptx86ABIFixups.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderScriptx86ABIFixups.h; sourceTree = ""; }; + AFCB1D5E219CD5EA00730AD5 /* Reproducer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Reproducer.cpp; path = source/Utility/Reproducer.cpp; sourceTree = ""; }; + 4C639EC121FA684700A7B957 /* ReproducerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReproducerTest.cpp; sourceTree = ""; }; 4FBC04EC211A06200015A814 /* RichManglingContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RichManglingContext.cpp; path = source/Core/RichManglingContext.cpp; sourceTree = ""; }; 4FBC04EE211A06820015A814 /* RichManglingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RichManglingContext.h; path = include/lldb/Core/RichManglingContext.h; sourceTree = ""; }; 4FBC04F3211A0F0F0015A814 /* RichManglingContextTest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RichManglingContextTest.cpp; sourceTree = ""; }; @@ -2809,6 +2934,8 @@ 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBHostOS.cpp; path = source/API/SBHostOS.cpp; sourceTree = ""; }; 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBHostOS.h; path = include/lldb/API/SBHostOS.h; sourceTree = ""; }; 2611FF00142D83060017FEA3 /* SBHostOS.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBHostOS.i; sourceTree = ""; }; + AFB2F2F421B71AE90078DEF1 /* SBInitializerOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInitializerOptions.cpp; path = source/API/SBInitializerOptions.cpp; sourceTree = ""; }; + 4C38996C21BA11CA002BAEF4 /* SBInitializerOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBInitializerOptions.h; path = include/lldb/API/SBInitializerOptions.h; sourceTree = ""; }; 9AC703AE117675410086C050 /* SBInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInstruction.cpp; path = source/API/SBInstruction.cpp; sourceTree = ""; }; 9AC7038D117674EB0086C050 /* SBInstruction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBInstruction.h; path = include/lldb/API/SBInstruction.h; sourceTree = ""; }; 2611FF02142D83060017FEA3 /* SBInstruction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBInstruction.i; sourceTree = ""; }; @@ -2934,9 +3061,8 @@ B2A58721143119810092BFBA /* SBWatchpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBWatchpoint.h; path = include/lldb/API/SBWatchpoint.h; sourceTree = ""; }; B2A5872514313B480092BFBA /* SBWatchpoint.i */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = SBWatchpoint.i; sourceTree = ""; }; 26BC7D7810F1B77400F91463 /* STLUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STLUtils.h; path = include/lldb/Core/STLUtils.h; sourceTree = ""; }; - 4CAB257C18EC9DB800BAD33E /* SafeMachO.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SafeMachO.h; path = include/lldb/Utility/SafeMachO.h; sourceTree = ""; }; - 26BC7E8D10F1B85900F91463 /* Scalar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Scalar.cpp; path = source/Core/Scalar.cpp; sourceTree = ""; }; - 26BC7D7410F1B77400F91463 /* Scalar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Scalar.h; path = include/lldb/Core/Scalar.h; sourceTree = ""; }; + 26BC7E8D10F1B85900F91463 /* Scalar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Scalar.cpp; path = source/Utility/Scalar.cpp; sourceTree = ""; }; + 26BC7D7410F1B77400F91463 /* Scalar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Scalar.h; path = include/lldb/Utility/Scalar.h; sourceTree = ""; }; 23CB14E91D66CC0E00EDDDE1 /* ScalarTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScalarTest.cpp; sourceTree = ""; }; 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = ""; }; 26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScriptInterpreter.h; path = include/lldb/Interpreter/ScriptInterpreter.h; sourceTree = ""; }; @@ -2964,10 +3090,11 @@ 26D7E45B13D5E2F9007FD12B /* SocketAddress.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SocketAddress.h; path = include/lldb/Host/SocketAddress.h; sourceTree = ""; }; 2321F9391BDD332400BA9A93 /* SocketAddressTest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SocketAddressTest.cpp; sourceTree = ""; }; 2321F93A1BDD332400BA9A93 /* SocketTest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SocketTest.cpp; sourceTree = ""; }; - 232CB613191E00CC00EF39FC /* SoftwareBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SoftwareBreakpoint.cpp; path = source/Host/common/SoftwareBreakpoint.cpp; sourceTree = ""; }; - 267A47F21B14115A0021A5BC /* SoftwareBreakpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SoftwareBreakpoint.h; path = include/lldb/Host/common/SoftwareBreakpoint.h; sourceTree = ""; }; + 26603870211CA90D00329572 /* SourceBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SourceBreakpoint.cpp; path = "tools/lldb-vscode/SourceBreakpoint.cpp"; sourceTree = ""; }; + 2660386D211CA90C00329572 /* SourceBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceBreakpoint.h; path = "tools/lldb-vscode/SourceBreakpoint.h"; sourceTree = ""; }; 26BC7E8F10F1B85900F91463 /* SourceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SourceManager.cpp; path = source/Core/SourceManager.cpp; sourceTree = ""; }; 26BC7D7610F1B77400F91463 /* SourceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceManager.h; path = include/lldb/Core/SourceManager.h; sourceTree = ""; }; + 26F76198211CB8870044F6EA /* SourceReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceReference.h; path = "tools/lldb-vscode/SourceReference.h"; sourceTree = ""; }; 26BC7F3810F1B90C00F91463 /* StackFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StackFrame.cpp; path = source/Target/StackFrame.cpp; sourceTree = ""; }; 26BC7DF510F1B81A00F91463 /* StackFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StackFrame.h; path = include/lldb/Target/StackFrame.h; sourceTree = ""; }; 26BC7F3910F1B90C00F91463 /* StackFrameList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StackFrameList.cpp; path = source/Target/StackFrameList.cpp; sourceTree = ""; }; @@ -2976,8 +3103,8 @@ 8CFDB67920467B390052B399 /* StackFrameRecognizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StackFrameRecognizer.h; path = include/lldb/Target/StackFrameRecognizer.h; sourceTree = ""; }; 26BC7F3A10F1B90C00F91463 /* StackID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StackID.cpp; path = source/Target/StackID.cpp; sourceTree = ""; }; 26BC7DF710F1B81A00F91463 /* StackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StackID.h; path = include/lldb/Target/StackID.h; sourceTree = ""; }; - 26BC7E9010F1B85900F91463 /* State.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = State.cpp; path = source/Core/State.cpp; sourceTree = ""; }; - 26BC7D7710F1B77400F91463 /* State.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = State.h; path = include/lldb/Core/State.h; sourceTree = ""; }; + 26BC7E9010F1B85900F91463 /* State.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = State.cpp; path = source/Utility/State.cpp; sourceTree = ""; }; + 26BC7D7710F1B77400F91463 /* State.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = State.h; path = include/lldb/Utility/State.h; sourceTree = ""; }; 9A3D43E21F3237D500EB767C /* StateTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StateTest.cpp; sourceTree = ""; }; 492DB7E81EC662D100B9E9AF /* Status.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Status.cpp; path = source/Utility/Status.cpp; sourceTree = ""; }; 492DB7E61EC662B100B9E9AF /* Status.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Status.h; path = include/lldb/Utility/Status.h; sourceTree = ""; }; @@ -3008,17 +3135,20 @@ 26764CA31E48F550008D3573 /* StreamString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamString.h; path = include/lldb/Utility/StreamString.h; sourceTree = ""; }; 26764CA41E48F566008D3573 /* StreamTee.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamTee.h; path = include/lldb/Utility/StreamTee.h; sourceTree = ""; }; 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamTeeTest.cpp; sourceTree = ""; }; + 4C639EBF21FA684700A7B957 /* StreamTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamTest.cpp; sourceTree = ""; }; 33E5E8411A672A240024ED68 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConvert.cpp; sourceTree = ""; }; 33E5E8451A6736D30024ED68 /* StringConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringConvert.h; path = include/lldb/Host/StringConvert.h; sourceTree = SOURCE_ROOT; }; 2660D9F611922A1300958FBD /* StringExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractor.cpp; path = source/Utility/StringExtractor.cpp; sourceTree = ""; }; 26A375831D59486000D6CBDB /* StringExtractor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringExtractor.h; path = include/lldb/Utility/StringExtractor.h; sourceTree = ""; }; 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = ""; }; - 2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = source/Utility/StringExtractorGDBRemote.h; sourceTree = ""; }; + 2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = include/lldb/Utility/StringExtractorGDBRemote.h; sourceTree = ""; }; 2321F9441BDD346100BA9A93 /* StringExtractorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringExtractorTest.cpp; sourceTree = ""; }; 94380B8119940B0A00BFE4A8 /* StringLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringLexer.cpp; path = source/Utility/StringLexer.cpp; sourceTree = ""; }; 94380B8019940B0300BFE4A8 /* StringLexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringLexer.h; path = include/lldb/Utility/StringLexer.h; sourceTree = ""; }; + 4C639EC621FA684800A7B957 /* StringLexerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringLexerTest.cpp; sourceTree = ""; }; 9A35765F116E76B900E8ED2F /* StringList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringList.cpp; path = source/Utility/StringList.cpp; sourceTree = ""; }; 9A35765E116E76A700E8ED2F /* StringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringList.h; path = include/lldb/Utility/StringList.h; sourceTree = ""; }; + 4C639EBE21FA684600A7B957 /* StringListTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringListTest.cpp; sourceTree = ""; }; 94F48F241A01C687005C0EC6 /* StringPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringPrinter.cpp; path = source/DataFormatters/StringPrinter.cpp; sourceTree = ""; }; 4C848DEC18D2863E00EC6DD0 /* StringPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringPrinter.h; path = include/lldb/DataFormatters/StringPrinter.h; sourceTree = ""; }; 9A3D43DF1F31521200EB767C /* StructuredData-basic.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "StructuredData-basic.json"; sourceTree = ""; }; @@ -3037,6 +3167,8 @@ 26BC7C6110F1B6E900F91463 /* SymbolContextScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SymbolContextScope.h; path = include/lldb/Symbol/SymbolContextScope.h; sourceTree = ""; }; 26BC7F1D10F1B8EC00F91463 /* SymbolFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolFile.cpp; path = source/Symbol/SymbolFile.cpp; sourceTree = ""; }; 26BC7C6210F1B6E900F91463 /* SymbolFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SymbolFile.h; path = include/lldb/Symbol/SymbolFile.h; sourceTree = ""; }; + AF97744621E9947B006876A7 /* SymbolFileBreakpad.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolFileBreakpad.cpp; path = source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp; sourceTree = SOURCE_ROOT; }; + AF97744521E9947B006876A7 /* SymbolFileBreakpad.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SymbolFileBreakpad.h; path = source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h; sourceTree = SOURCE_ROOT; }; 260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFileDWARF.cpp; sourceTree = ""; }; 260C89DA10F57C5600BB2B04 /* SymbolFileDWARF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolFileDWARF.h; sourceTree = ""; }; 260C89DB10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFileDWARFDebugMap.cpp; sourceTree = ""; }; @@ -3048,6 +3180,8 @@ 4C7D481C1F509963005314B4 /* SymbolFileDWARFDwp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFileDWARFDwp.cpp; sourceTree = ""; }; 4C7D481E1F509964005314B4 /* SymbolFileDWARFDwp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolFileDWARFDwp.h; sourceTree = ""; }; 9A20570A1F3B81F300F6C293 /* SymbolFileDWARFTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolFileDWARFTests.cpp; path = DWARF/SymbolFileDWARFTests.cpp; sourceTree = ""; }; + AFD966B7217140B6006714AC /* SymbolFileNativePDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolFileNativePDB.cpp; path = source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp; sourceTree = SOURCE_ROOT; }; + AFD966C0217140C8006714AC /* SymbolFileNativePDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SymbolFileNativePDB.h; path = source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h; sourceTree = SOURCE_ROOT; }; AF6335E01C87B21E00F7D554 /* SymbolFilePDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolFilePDB.cpp; path = PDB/SymbolFilePDB.cpp; sourceTree = ""; }; AF6335E11C87B21E00F7D554 /* SymbolFilePDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SymbolFilePDB.h; path = PDB/SymbolFilePDB.h; sourceTree = ""; }; 23CB15141D66CF8700EDDDE1 /* SymbolFilePDBTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFilePDBTests.cpp; sourceTree = ""; }; @@ -3200,6 +3334,9 @@ 2579065B1BD0488100178368 /* UDPSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UDPSocket.cpp; sourceTree = ""; }; 49CA96EA1E6AAC6600C03FEE /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UUID.cpp; path = source/Utility/UUID.cpp; sourceTree = ""; }; 49CA96F51E6AAC8E00C03FEE /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UUID.h; path = include/lldb/Utility/UUID.h; sourceTree = ""; }; + 4C639EC221FA684700A7B957 /* UUIDTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UUIDTest.cpp; sourceTree = ""; }; + AF0578C2217FA80700CF9D80 /* UdtRecordCompleter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UdtRecordCompleter.cpp; path = source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp; sourceTree = SOURCE_ROOT; }; + AF0578C1217FA80700CF9D80 /* UdtRecordCompleter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UdtRecordCompleter.h; path = source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h; sourceTree = SOURCE_ROOT; }; 268A813F115B19D000F645B0 /* UniqueCStringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniqueCStringMap.h; path = include/lldb/Core/UniqueCStringMap.h; sourceTree = ""; }; 26B8B42312EEC52A00A831B2 /* UniqueDWARFASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueDWARFASTType.cpp; sourceTree = ""; }; 26B8B42212EEC52A00A831B2 /* UniqueDWARFASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueDWARFASTType.h; sourceTree = ""; }; @@ -3237,6 +3374,10 @@ 9A3D43C41F3150D200EB767C /* VASprintfTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VASprintfTest.cpp; sourceTree = ""; }; AFC2DCEF1E6E2FD200283714 /* VMRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VMRange.cpp; path = source/Utility/VMRange.cpp; sourceTree = ""; }; AFC2DCF11E6E2FDA00283714 /* VMRange.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VMRange.h; path = include/lldb/Utility/VMRange.h; sourceTree = ""; }; + 4C639ECA21FA684900A7B957 /* VMRangeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMRangeTest.cpp; sourceTree = ""; }; + 2660386E211CA90D00329572 /* VSCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VSCode.cpp; path = "tools/lldb-vscode/VSCode.cpp"; sourceTree = ""; }; + 2660386F211CA90D00329572 /* VSCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSCode.h; path = "tools/lldb-vscode/VSCode.h"; sourceTree = ""; }; + 26F7619C211CDD700044F6EA /* VSCodeForward.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSCodeForward.h; path = "tools/lldb-vscode/VSCodeForward.h"; sourceTree = ""; }; 26BC7E9910F1B85900F91463 /* Value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Value.cpp; path = source/Core/Value.cpp; sourceTree = ""; }; 26BC7D8110F1B77400F91463 /* Value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Value.h; path = include/lldb/Core/Value.h; sourceTree = ""; }; 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObject.cpp; path = source/Core/ValueObject.cpp; sourceTree = ""; }; @@ -3318,6 +3459,7 @@ 2326CF471BDD67C100A5CEAC /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = ../../../../../../usr/lib/libncurses.dylib; sourceTree = ""; }; 239481851C59EBDD00DF7168 /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = ../../../../../usr/lib/libncurses.dylib; sourceTree = ""; }; 2670F8111862B44A006B332C /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = /usr/lib/libncurses.dylib; sourceTree = ""; }; + 26792621211CA41E00EE1D10 /* libncurses.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libncurses.tbd; path = usr/lib/libncurses.tbd; sourceTree = SDKROOT; }; 26F5C37410F3F61B009D5894 /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = ""; }; 2326CF4E1BDD687800A5CEAC /* libpanel.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpanel.dylib; path = ../../../../../../usr/lib/libpanel.dylib; sourceTree = ""; }; 26F5C32410F3DF23009D5894 /* libpython.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpython.dylib; path = /usr/lib/libpython.dylib; sourceTree = ""; }; @@ -3349,6 +3491,9 @@ E769331D1A94D18100C73337 /* lldb-server.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "lldb-server.cpp"; path = "tools/lldb-server/lldb-server.cpp"; sourceTree = ""; }; 26BC7C2910F1B3BC00F91463 /* lldb-types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-types.h"; path = "include/lldb/lldb-types.h"; sourceTree = ""; }; 94145430175D7FDE00284436 /* lldb-versioning.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-versioning.h"; path = "include/lldb/lldb-versioning.h"; sourceTree = ""; }; + 2679260C211CA3AC00EE1D10 /* lldb-vscode */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "lldb-vscode"; sourceTree = BUILT_PRODUCTS_DIR; }; + 26792618211CA3E100EE1D10 /* lldb-vscode-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "lldb-vscode-Info.plist"; path = "tools/lldb-vscode/lldb-vscode-Info.plist"; sourceTree = ""; }; + 26792619211CA3E100EE1D10 /* lldb-vscode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "lldb-vscode.cpp"; path = "tools/lldb-vscode/lldb-vscode.cpp"; sourceTree = ""; }; 23173F8B192BA93F005C708F /* lldb-x86-register-enums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-x86-register-enums.h"; path = "Utility/lldb-x86-register-enums.h"; sourceTree = ""; }; AF90106315AB7C5700FF120D /* lldb.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; name = lldb.1; path = docs/lldb.1; sourceTree = ""; }; 26BC7E7410F1B85900F91463 /* lldb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lldb.cpp; path = source/lldb.cpp; sourceTree = ""; }; @@ -3356,6 +3501,7 @@ 4947DE491E3C0B20008D6ED0 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; 9438E18B19217ABA00AE7A2A /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 94E367CC140C4EC4001C7A5A /* modify-python-lldb.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = "modify-python-lldb.py"; sourceTree = ""; }; + 26792616211CA3E100EE1D10 /* package.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = package.json; path = "tools/lldb-vscode/package.json"; sourceTree = ""; }; 9A48A3A7124AAA5A00922451 /* python-extensions.swig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "python-extensions.swig"; sourceTree = ""; }; 944DC3481774C99000D7D884 /* python-swigsafecast.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-swigsafecast.swig"; sourceTree = ""; }; 94E367CE140C4EEA001C7A5A /* python-typemaps.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-typemaps.swig"; sourceTree = ""; }; @@ -3421,13 +3567,21 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 26792609211CA3AC00EE1D10 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 26792623211CA42300EE1D10 /* LLDB.framework in Frameworks */, + 26792622211CA41E00EE1D10 /* libncurses.tbd in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2690CD141A6DC0D000E717C8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 239481861C59EBDD00DF7168 /* libncurses.dylib in Frameworks */, 2669424D1A6DC32B0063BE93 /* LLDB.framework in Frameworks */, - 49A9B8C21BB4AF1C006D7743 /* libncurses.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3530,6 +3684,7 @@ 942829C01A89835300521B30 /* lldb-argdumper */, 239504D41BDD451400963CEA /* lldb-gtest */, 23CB15561D66DA9300EDDDE1 /* lldb-gtest */, + 2679260C211CA3AC00EE1D10 /* lldb-vscode */, ); name = Products; sourceTree = ""; @@ -3611,24 +3766,44 @@ 2321F9421BDD343A00BA9A93 /* Utility */ = { isa = PBXGroup; children = ( - 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */, - 7F94D7172040A13A006EE3EA /* CleanUpTest.cpp */, + 4C639EC721FA684800A7B957 /* AnsiTerminalTest.cpp */, 23E2E5161D903689006F38BB /* ArchSpecTest.cpp */, + 23CB14E61D66CC0E00EDDDE1 /* BroadcasterTest.cpp */, + 7F94D7172040A13A006EE3EA /* CleanUpTest.cpp */, + 4C639EC921FA684800A7B957 /* CompletionRequestTest.cpp */, 9A3D43C81F3150D200EB767C /* ConstStringTest.cpp */, + AFA1B62B219E0ED900A8AB7E /* DataExtractorTest.cpp */, + 4C639EBD21FA684600A7B957 /* EnvironmentTest.cpp */, + 4C639EC521FA684800A7B957 /* EventTest.cpp */, + 4C639EC821FA684800A7B957 /* FlagsTest.cpp */, 23CB14FD1D66CD2400EDDDE1 /* FileSpecTest.cpp */, + 8C3BD99F1EF5D1B50016C343 /* JSONTest.cpp */, + 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */, 9A3D43C71F3150D200EB767C /* LogTest.cpp */, 9A3D43CB1F3150D200EB767C /* NameMatchesTest.cpp */, + 4C639EC321FA684700A7B957 /* OptionsWithRawTest.cpp */, + 4C639EC021FA684700A7B957 /* PredicateTest.cpp */, + 4C639EC421FA684800A7B957 /* RegisterValueTest.cpp */, + 4C639EC121FA684700A7B957 /* ReproducerTest.cpp */, + 23CB14E91D66CC0E00EDDDE1 /* ScalarTest.cpp */, + 9A3D43E21F3237D500EB767C /* StateTest.cpp */, 9A3D43C61F3150D200EB767C /* StatusTest.cpp */, + 4C639EBF21FA684700A7B957 /* StreamTest.cpp */, + 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */, + 2321F9441BDD346100BA9A93 /* StringExtractorTest.cpp */, + DD8F278022011D0F004ED75B /* FileCollectorTest.cpp */, + 4C639EC621FA684800A7B957 /* StringLexerTest.cpp */, + 4C639EBE21FA684600A7B957 /* StringListTest.cpp */, 9A3D43CA1F3150D200EB767C /* StructuredDataTest.cpp */, 9A3D43C91F3150D200EB767C /* TildeExpressionResolverTest.cpp */, 9A3D43CC1F3150D200EB767C /* TimeoutTest.cpp */, 9A3D43C51F3150D200EB767C /* TimerTest.cpp */, + 2321F9461BDD346100BA9A93 /* UriParserTest.cpp */, + 4C639EC221FA684700A7B957 /* UUIDTest.cpp */, + 4C639ECA21FA684900A7B957 /* VMRangeTest.cpp */, 9A3D43C41F3150D200EB767C /* VASprintfTest.cpp */, 2321F9431BDD346100BA9A93 /* CMakeLists.txt */, 23CB15041D66CD9200EDDDE1 /* Inputs */, - 2321F9441BDD346100BA9A93 /* StringExtractorTest.cpp */, - 8C3BD99F1EF5D1B50016C343 /* JSONTest.cpp */, - 2321F9461BDD346100BA9A93 /* UriParserTest.cpp */, ); path = Utility; sourceTree = ""; @@ -3764,6 +3939,7 @@ isa = PBXGroup; children = ( 237E0CDF1D907D4B00DD3F2B /* libz.tbd */, + 26792621211CA41E00EE1D10 /* libncurses.tbd */, 23CB14E31D66CA2200EDDDE1 /* libxml2.2.dylib */, ); name = Frameworks; @@ -3772,16 +3948,11 @@ 23CB14E51D66CBEB00EDDDE1 /* Core */ = { isa = PBXGroup; children = ( + 23CB14E71D66CC0E00EDDDE1 /* CMakeLists.txt */, 58A080B12112AB2200D5580F /* HighlighterTest.cpp */, 4F29D3CD21010F84003B549A /* MangledTest.cpp */, - 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */, - 9A3D43E21F3237D500EB767C /* StateTest.cpp */, - 9A3D43E11F3237D500EB767C /* StreamCallbackTest.cpp */, - 23CB14E71D66CC0E00EDDDE1 /* CMakeLists.txt */, - 23CB14E61D66CC0E00EDDDE1 /* BroadcasterTest.cpp */, - 23CB14E81D66CC0E00EDDDE1 /* DataExtractorTest.cpp */, - 23CB14E91D66CC0E00EDDDE1 /* ScalarTest.cpp */, 4FBC04F3211A0F0F0015A814 /* RichManglingContextTest.cpp */, + 9A3D43E11F3237D500EB767C /* StreamCallbackTest.cpp */, ); path = Core; sourceTree = ""; @@ -3873,6 +4044,10 @@ 23E2E5351D9048E7006F38BB /* minidump */ = { isa = PBXGroup; children = ( + 2619C4812107A9A1009CDE81 /* RegisterContextMinidump_ARM.cpp */, + 2619C4832107A9A2009CDE81 /* RegisterContextMinidump_ARM.h */, + 2619C4802107A9A1009CDE81 /* RegisterContextMinidump_ARM64.cpp */, + 2619C4822107A9A2009CDE81 /* RegisterContextMinidump_ARM64.h */, AFD65C7F1D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp */, AFD65C801D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h */, 23E2E5361D9048FB006F38BB /* CMakeLists.txt */, @@ -3984,6 +4159,7 @@ 260C898210F57C5600BB2B04 /* ObjectFile */ = { isa = PBXGroup; children = ( + 4C9BF11621C0467700FA4036 /* Breakpad */, 260C898310F57C5600BB2B04 /* ELF */, 26EFC4C718CFAF0D00865D87 /* JIT */, 260C898710F57C5600BB2B04 /* Mach-O */, @@ -4030,6 +4206,8 @@ 260C89B110F57C5600BB2B04 /* SymbolFile */ = { isa = PBXGroup; children = ( + AF97744421E99467006876A7 /* Breakpad */, + AFD966B321714099006714AC /* NativePDB */, AF6335DF1C87B20A00F7D554 /* PDB */, 260C89B210F57C5600BB2B04 /* DWARF */, 260C89DD10F57C5600BB2B04 /* Symtab */, @@ -4286,6 +4464,8 @@ 26DE205C1161901400A093E2 /* SBFunction.cpp */, 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */, 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */, + AFB2F2F421B71AE90078DEF1 /* SBInitializerOptions.cpp */, + 4C38996C21BA11CA002BAEF4 /* SBInitializerOptions.h */, 9AC7038D117674EB0086C050 /* SBInstruction.h */, 9AC703AE117675410086C050 /* SBInstruction.cpp */, 9AC7038F117675270086C050 /* SBInstructionList.h */, @@ -4416,6 +4596,16 @@ path = "MacOSX-Kernel"; sourceTree = ""; }; + 2647B62E21C4364F00A81D15 /* MIPS */ = { + isa = PBXGroup; + children = ( + 2647B63021C4366300A81D15 /* ArchitectureMips.cpp */, + 2647B62F21C4366200A81D15 /* ArchitectureMips.h */, + ); + name = MIPS; + path = "New Group"; + sourceTree = ""; + }; 264A12F91372522000875C42 /* ARM64 */ = { isa = PBXGroup; children = ( @@ -4534,6 +4724,33 @@ path = OperatingSystem; sourceTree = ""; }; + 26792615211CA3C100EE1D10 /* lldb-vscode */ = { + isa = PBXGroup; + children = ( + 26792617211CA3E100EE1D10 /* CMakeLists.txt */, + 26792618211CA3E100EE1D10 /* lldb-vscode-Info.plist */, + 26792619211CA3E100EE1D10 /* lldb-vscode.cpp */, + 26792616211CA3E100EE1D10 /* package.json */, + 2660387D211CA98200329572 /* BreakpointBase.cpp */, + 26603872211CA90D00329572 /* BreakpointBase.h */, + 26603874211CA90E00329572 /* ExceptionBreakpoint.cpp */, + 26603873211CA90E00329572 /* ExceptionBreakpoint.h */, + 26603877211CA90E00329572 /* FunctionBreakpoint.cpp */, + 26603871211CA90D00329572 /* FunctionBreakpoint.h */, + 26603875211CA90E00329572 /* JSONUtils.cpp */, + 26603876211CA90E00329572 /* JSONUtils.h */, + 26F76199211CBBB30044F6EA /* LLDBUtils.cpp */, + 26F7619A211CBBB30044F6EA /* LLDBUtils.h */, + 26603870211CA90D00329572 /* SourceBreakpoint.cpp */, + 2660386D211CA90C00329572 /* SourceBreakpoint.h */, + 26F76198211CB8870044F6EA /* SourceReference.h */, + 2660386E211CA90D00329572 /* VSCode.cpp */, + 2660386F211CA90D00329572 /* VSCode.h */, + 26F7619C211CDD700044F6EA /* VSCodeForward.h */, + ); + name = "lldb-vscode"; + sourceTree = ""; + }; 267F68461CC02DED0086832B /* SysV-s390x */ = { isa = PBXGroup; children = ( @@ -4556,11 +4773,14 @@ 26BC7E6F10F1B85900F91463 /* Connection.cpp */, 26FA4315130103F400E71120 /* FileSpec.h */, 26FA43171301048600E71120 /* FileSpec.cpp */, + DD8F277D22011CC9004ED75B /* FileCollector.cpp */, 26CF992414428766001E4138 /* AnsiTerminal.h */, 26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */, 264A12FF137252C700875C42 /* ARM64_DWARF_Registers.h */, AFC2DCE81E6E2F2C00283714 /* Baton.cpp */, AFC2DCEE1E6E2FA300283714 /* Baton.h */, + 2647B63521C4368300A81D15 /* Broadcaster.h */, + 2647B63921C436AB00A81D15 /* Broadcaster.cpp */, 264723A511FA076E00DE380C /* CleanUp.h */, 26764C951E48F46F008D3573 /* ConstString.h */, 26764C961E48F482008D3573 /* ConstString.cpp */, @@ -4575,19 +4795,25 @@ 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */, 9481FE6B1B5F2D9200DED357 /* Either.h */, 26BC7DD310F1B7D500F91463 /* Endian.h */, + 2647B63321C4367A00A81D15 /* Event.h */, + 2647B63B21C436B400A81D15 /* Event.cpp */, 4CBFF0471F579A36004AFA92 /* Flags.h */, 236124A61986B50E004EFC37 /* IOObject.h */, 236124A21986B4E2004EFC37 /* IOObject.cpp */, 4C73152119B7D71700F865A4 /* Iterable.h */, 942829541A89614000521B30 /* JSON.h */, 942829551A89614C00521B30 /* JSON.cpp */, + 2647B63721C4369500A81D15 /* Listener.h */, + 2647B63D21C436BC00A81D15 /* Listener.cpp */, 943BDEFC1AA7B2DE00789CE8 /* LLDBAssert.h */, 943BDEFD1AA7B2F800789CE8 /* LLDBAssert.cpp */, 3F81691C1ABA242B001DA9DF /* NameMatches.h */, 3F8169181ABA2419001DA9DF /* NameMatches.cpp */, + 26C6886D137880B900407EDF /* RegisterValue.h */, + 26C6886E137880C400407EDF /* RegisterValue.cpp */, 26764C9C1E48F516008D3573 /* RegularExpression.h */, 26764C9F1E48F528008D3573 /* RegularExpression.cpp */, - 4CAB257C18EC9DB800BAD33E /* SafeMachO.h */, + AFCB1D5E219CD5EA00730AD5 /* Reproducer.cpp */, 26BC7D7410F1B77400F91463 /* Scalar.h */, 26BC7E8D10F1B85900F91463 /* Scalar.cpp */, 26A375841D59487700D6CBDB /* SelectHelper.h */, @@ -4595,6 +4821,8 @@ 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */, 4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */, 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */, + 26BC7D7710F1B77400F91463 /* State.h */, + 26BC7E9010F1B85900F91463 /* State.cpp */, 492DB7E61EC662B100B9E9AF /* Status.h */, 492DB7E81EC662D100B9E9AF /* Status.cpp */, 26764C9B1E48F50C008D3573 /* Stream.h */, @@ -4616,8 +4844,6 @@ 9A35765F116E76B900E8ED2F /* StringList.cpp */, 26F2F8FD1B156678007857DE /* StructuredData.h */, AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */, - 94BA8B6E176F8CA0005A91B5 /* Range.h */, - 94BA8B6C176F8C9B005A91B5 /* Range.cpp */, AFF8FF0B1E779D4B003830EF /* TildeExpressionResolver.cpp */, AFF8FF0D1E779D51003830EF /* TildeExpressionResolver.h */, 26BC7D7E10F1B77400F91463 /* Timer.h */, @@ -4911,6 +5137,8 @@ B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */, B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */, B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */, + 2647B64221C43BB000A81D15 /* LinuxProcMaps.cpp */, + 2647B64121C43BAF00A81D15 /* LinuxProcMaps.h */, 23059A0519532B96007B8189 /* LinuxSignals.cpp */, 23059A0619532B96007B8189 /* LinuxSignals.h */, 23173F8B192BA93F005C708F /* lldb-x86-register-enums.h */, @@ -5063,8 +5291,6 @@ 9AC7034211752C720086C050 /* AddressResolverFileLine.cpp */, 9AC7033F11752C590086C050 /* AddressResolverName.h */, 9AC7034411752C790086C050 /* AddressResolverName.cpp */, - 26BC7D5410F1B77400F91463 /* Broadcaster.h */, - 26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */, 26BC7D5510F1B77400F91463 /* ClangForward.h */, 26BC7D5610F1B77400F91463 /* Communication.h */, 26BC7E6E10F1B85900F91463 /* Communication.cpp */, @@ -5078,8 +5304,6 @@ 26BC7D5F10F1B77400F91463 /* dwarf.h */, 26D9FDC612F784E60003F2EE /* EmulateInstruction.h */, 26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */, - 26BC7D6110F1B77400F91463 /* Event.h */, - 26BC7E7910F1B85900F91463 /* Event.cpp */, 26BD407D135D2AC400237D80 /* FileLineResolver.h */, 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */, 26BC7D6310F1B77400F91463 /* FileSpecList.h */, @@ -5089,8 +5313,6 @@ 260A63161861008E00FECF8E /* IOHandler.h */, 260A63181861009E00FECF8E /* IOHandler.cpp */, 26BC7D6510F1B77400F91463 /* IOStreamMacros.h */, - 26BC7D6710F1B77400F91463 /* Listener.h */, - 26BC7E7E10F1B85900F91463 /* Listener.cpp */, 26BC7D6810F1B77400F91463 /* Log.h */, 26BC7E7F10F1B85900F91463 /* Log.cpp */, 3F8160A71AB9F809001DA9DF /* Logging.h */, @@ -5113,8 +5335,6 @@ 26BC7D7110F1B77400F91463 /* PluginManager.h */, 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */, 2626B6AD143E1BEA00EF935C /* RangeMap.h */, - 26C6886D137880B900407EDF /* RegisterValue.h */, - 26C6886E137880C400407EDF /* RegisterValue.cpp */, 4FBC04EE211A06820015A814 /* RichManglingContext.h */, 4FBC04EC211A06200015A814 /* RichManglingContext.cpp */, 26BC7CF910F1B71400F91463 /* SearchFilter.h */, @@ -5123,8 +5343,6 @@ 26BC7E8E10F1B85900F91463 /* Section.cpp */, 26BC7D7610F1B77400F91463 /* SourceManager.h */, 26BC7E8F10F1B85900F91463 /* SourceManager.cpp */, - 26BC7D7710F1B77400F91463 /* State.h */, - 26BC7E9010F1B85900F91463 /* State.cpp */, 26BC7D7810F1B77400F91463 /* STLUtils.h */, 9A4F35111368A54100823F52 /* StreamAsynchronousIO.h */, 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */, @@ -5344,6 +5562,8 @@ 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */, 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */, 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */, + AFCB1D5A219CD5A700730AD5 /* CommandObjectReproducer.cpp */, + AFCB1D5B219CD5A700730AD5 /* CommandObjectReproducer.h */, 26BC7D2410F1B76300F91463 /* CommandObjectScript.h */, 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */, 26BC7D2710F1B76300F91463 /* CommandObjectSettings.h */, @@ -5434,10 +5654,7 @@ 3FDFED2119BA6D55009756A7 /* HostNativeThreadBase.h */, 3FDFE57419AFABFD009756A7 /* HostProcess.h */, 3FDFE57519AFABFD009756A7 /* HostThread.h */, - 267A47F31B14116E0021A5BC /* NativeBreakpoint.h */, - 232CB60B191E00CC00EF39FC /* NativeBreakpoint.cpp */, 267A47F41B1411750021A5BC /* NativeBreakpointList.h */, - 232CB60D191E00CC00EF39FC /* NativeBreakpointList.cpp */, 267A47F51B14117F0021A5BC /* NativeProcessProtocol.h */, 232CB60F191E00CC00EF39FC /* NativeProcessProtocol.cpp */, 267A47F61B14118F0021A5BC /* NativeRegisterContext.h */, @@ -5455,8 +5672,6 @@ 236124A71986B50E004EFC37 /* Socket.h */, 26D7E45B13D5E2F9007FD12B /* SocketAddress.h */, 26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */, - 267A47F21B14115A0021A5BC /* SoftwareBreakpoint.h */, - 232CB613191E00CC00EF39FC /* SoftwareBreakpoint.cpp */, 2689B0A4113EE3CD00A4AEDB /* Symbols.h */, 6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */, 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */, @@ -5914,6 +6129,7 @@ children = ( 94A9286C1A92B83F00771D51 /* argdumper */, E769331B1A94D10E00C73337 /* lldb-server */, + 26792615211CA3C100EE1D10 /* lldb-vscode */, 26579F55126A255E0007C5CB /* darwin-debug */, 265E9BE0115C2B8500D0DCCB /* debugserver */, 26F5C22510F3D956009D5894 /* Driver */, @@ -5927,6 +6143,8 @@ 26F5C22510F3D956009D5894 /* Driver */ = { isa = PBXGroup; children = ( + DD5F951B21ADE5F000B8265A /* Options.td */, + DD5F951A21ADE5BD00B8265A /* Options.inc */, 26F5C27210F3D9E4009D5894 /* lldb-Info.plist */, 26F5C27410F3D9E4009D5894 /* Driver.h */, 26F5C27310F3D9E4009D5894 /* Driver.cpp */, @@ -6192,6 +6410,17 @@ path = PPC64; sourceTree = ""; }; + 4C9BF11621C0467700FA4036 /* Breakpad */ = { + isa = PBXGroup; + children = ( + 4CAEC6A721F26D15007C3DD5 /* BreakpadRecords.h */, + 4CAEC6A621F26D15007C3DD5 /* BreakpadRecords.cpp */, + 4C9BF11821C0467700FA4036 /* ObjectFileBreakpad.h */, + 4C9BF11921C0467700FA4036 /* ObjectFileBreakpad.cpp */, + ); + path = Breakpad; + sourceTree = ""; + }; 4CCA643A13B40B82003BDF98 /* LanguageRuntime */ = { isa = PBXGroup; children = ( @@ -6291,6 +6520,10 @@ 2618EE5C1315B29C001D6D71 /* GDBRemoteCommunication.h */, 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */, 26744EEE1338317700EF765A /* GDBRemoteCommunicationClient.h */, + AF8AD943219CD45700614785 /* GDBRemoteCommunicationHistory.cpp */, + AF8AD944219CD45700614785 /* GDBRemoteCommunicationHistory.h */, + AFCB1D57219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp */, + AFCB1D56219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.h */, 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */, 26744EF01338317700EF765A /* GDBRemoteCommunicationServer.h */, 2618EE5D1315B29C001D6D71 /* GDBRemoteRegisterContext.cpp */, @@ -6558,6 +6791,8 @@ 94B6385B1B8FB174004FE1E4 /* CPlusPlusLanguage.cpp */, 49F811F01E931B1500F4E163 /* CPlusPlusNameParser.h */, 49F811EF1E931B1500F4E163 /* CPlusPlusNameParser.cpp */, + AF395C01219254F200894EC3 /* MSVCUndecoratedNameParser.cpp */, + AF395C00219254F200894EC3 /* MSVCUndecoratedNameParser.h */, ); name = CPlusPlus; sourceTree = ""; @@ -6804,6 +7039,7 @@ AF2E029F1FA2CE8A00A86C34 /* Architecture */ = { isa = PBXGroup; children = ( + 2647B62E21C4364F00A81D15 /* MIPS */, 4C14CEF52057258D00DEEF94 /* PPC64 */, AF2E02A01FA2CE9900A86C34 /* Arm */, ); @@ -6859,6 +7095,16 @@ path = ../Disassembler; sourceTree = ""; }; + AF97744421E99467006876A7 /* Breakpad */ = { + isa = PBXGroup; + children = ( + AF97744621E9947B006876A7 /* SymbolFileBreakpad.cpp */, + AF97744521E9947B006876A7 /* SymbolFileBreakpad.h */, + ); + name = Breakpad; + path = "New Group"; + sourceTree = ""; + }; AFAFD8081E57E19E0017A14F /* Target */ = { isa = PBXGroup; children = ( @@ -6869,6 +7115,30 @@ name = Target; sourceTree = ""; }; + AFD966B321714099006714AC /* NativePDB */ = { + isa = PBXGroup; + children = ( + AFD966B4217140B5006714AC /* CompileUnitIndex.cpp */, + AFD966BD217140C8006714AC /* CompileUnitIndex.h */, + 4C38996221B9AECC002BAEF4 /* DWARFLocationExpression.cpp */, + 4C38996321B9AECC002BAEF4 /* DWARFLocationExpression.h */, + AF815DF721C855B400023A34 /* PdbAstBuilder.cpp */, + AF815DF821C855B400023A34 /* PdbAstBuilder.h */, + AFD966B6217140B6006714AC /* PdbIndex.cpp */, + AFD966BF217140C8006714AC /* PdbIndex.h */, + AF0F459D219FA1C800C1E612 /* PdbSymUid.cpp */, + AFD966BC217140C8006714AC /* PdbSymUid.h */, + AFD966B5217140B6006714AC /* PdbUtil.cpp */, + AFD966BE217140C8006714AC /* PdbUtil.h */, + AFD966B7217140B6006714AC /* SymbolFileNativePDB.cpp */, + AFD966C0217140C8006714AC /* SymbolFileNativePDB.h */, + AF0578C2217FA80700CF9D80 /* UdtRecordCompleter.cpp */, + AF0578C1217FA80700CF9D80 /* UdtRecordCompleter.h */, + ); + name = NativePDB; + path = "New Group"; + sourceTree = ""; + }; AFDBC36A2046638D00B9C8F2 /* PPC64 */ = { isa = PBXGroup; children = ( @@ -7007,6 +7277,7 @@ 4C56543519D2297A002E9C44 /* SBThreadPlan.h in Headers */, 263C493A178B50CF0070F12D /* SBModuleSpec.h in Headers */, 2617447A11685869005ADD65 /* SBType.h in Headers */, + 4C38996D21BA11CA002BAEF4 /* SBInitializerOptions.h in Headers */, 9475C18914E5EA08001BFC6D /* SBTypeCategory.h in Headers */, 941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */, 941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */, @@ -7031,24 +7302,31 @@ files = ( AF0639AA1BEC2D2500EA1B29 /* PlatformDarwin.h in Headers */, 26EFB61C1BFE8D3E00544801 /* PlatformNetBSD.h in Headers */, + 2647B64321C43BB000A81D15 /* LinuxProcMaps.h in Headers */, AF3A4AD31EA05C4700B5DEB4 /* PlatformRemoteDarwinDevice.h in Headers */, AF9113FE1FBE78EA004320CD /* RegisterContextPOSIXCore_ppc64le.h in Headers */, AF33B4BF1C1FA441001B28D9 /* NetBSDSignals.h in Headers */, AF6CA6681FBBAF37005A0DC3 /* ArchSpec.h in Headers */, AF235EB41FBE7858009C5541 /* RegisterInfoPOSIX_ppc64le.h in Headers */, AF2E02A41FA2CEAF00A86C34 /* ArchitectureArm.h in Headers */, + 2619C4872107A9A2009CDE81 /* RegisterContextMinidump_ARM.h in Headers */, 267F685A1CC02EBE0086832B /* RegisterInfos_s390x.h in Headers */, 267F68541CC02E920086832B /* RegisterContextLinux_s390x.h in Headers */, + 2619C4862107A9A2009CDE81 /* RegisterContextMinidump_ARM64.h in Headers */, + 2647B63421C4367A00A81D15 /* Event.h in Headers */, AF235EB11FBE77B6009C5541 /* RegisterContextPOSIX_ppc64le.h in Headers */, 267F68501CC02E270086832B /* RegisterContextPOSIXCore_s390x.h in Headers */, 4FBC04EF211A06820015A814 /* RichManglingContext.h in Headers */, 4984BA181B979C08008658D4 /* ExpressionVariable.h in Headers */, + 2647B63121C4366300A81D15 /* ArchitectureMips.h in Headers */, 26C7C4841BFFEA7E009BD01F /* WindowsMiniDump.h in Headers */, 30B38A001CAAA6D7009524E3 /* ClangUtil.h in Headers */, AFD65C821D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h in Headers */, + 2647B63621C4368300A81D15 /* Broadcaster.h in Headers */, 238F2BA11D2C835A001FF92A /* StructuredDataPlugin.h in Headers */, 238F2BA91D2C85FA001FF92A /* StructuredDataDarwinLog.h in Headers */, 257906651BD5AFD000178368 /* Acceptor.h in Headers */, + 2647B63821C4369500A81D15 /* Listener.h in Headers */, 238F2BA21D2C835A001FF92A /* SystemRuntime.h in Headers */, 260A63171861008E00FECF8E /* IOHandler.h in Headers */, AF0639B81BEC2D2500EA1B29 /* PlatformRemoteiOS.h in Headers */, @@ -7203,6 +7481,24 @@ productReference = 26680207115FD0ED008E1FE4 /* LLDB.framework */; productType = "com.apple.product-type.framework"; }; + 2679260B211CA3AC00EE1D10 /* lldb-vscode */ = { + isa = PBXNativeTarget; + buildConfigurationList = 26792614211CA3AD00EE1D10 /* Build configuration list for PBXNativeTarget "lldb-vscode" */; + buildPhases = ( + 26792608211CA3AC00EE1D10 /* Sources */, + 26792609211CA3AC00EE1D10 /* Frameworks */, + 2679260A211CA3AC00EE1D10 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 26792620211CA40700EE1D10 /* PBXTargetDependency */, + ); + name = "lldb-vscode"; + productName = "lldb-vscode"; + productReference = 2679260C211CA3AC00EE1D10 /* lldb-vscode */; + productType = "com.apple.product-type.tool"; + }; 2689FFC913353D7A00698AC0 /* lldb-core */ = { isa = PBXNativeTarget; buildConfigurationList = 2689FFD813353D7A00698AC0 /* Build configuration list for PBXNativeTarget "lldb-core" */; @@ -7261,6 +7557,7 @@ isa = PBXNativeTarget; buildConfigurationList = 26F5C26E10F3D9C5009D5894 /* Build configuration list for PBXNativeTarget "lldb-tool" */; buildPhases = ( + DD5F951721ADD0C900B8265A /* Run Tablegen */, 26F5C26710F3D9A4009D5894 /* Sources */, 26F5C26810F3D9A4009D5894 /* Frameworks */, ); @@ -7331,6 +7628,9 @@ LastSwiftUpdateCheck = 0800; ProvisioningStyle = Manual; }; + 2679260B211CA3AC00EE1D10 = { + CreatedOnToolsVersion = 9.4.1; + }; 2687EAC51508110B00DD8C2E = { ProvisioningStyle = Manual; }; @@ -7376,6 +7676,10 @@ AF6967871B4609A80014D221 = { ProvisioningStyle = Manual; }; + DD8DC26B22026E2C00EB6F9E = { + CreatedOnToolsVersion = 11.0; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; @@ -7415,6 +7719,8 @@ 2690CD161A6DC0D000E717C8 /* lldb-mi */, 941E2F521AE81CA100AAA711 /* PrebuiltSwiftDebugBuild */, 942829BF1A89835300521B30 /* lldb-argdumper */, + 2679260B211CA3AC00EE1D10 /* lldb-vscode */, + DD8DC26B22026E2C00EB6F9E /* lldb-docs */, ); }; /* End PBXProject section */ @@ -7529,8 +7835,74 @@ files = ( ); inputPaths = ( - "$(SRCROOT)/source/API", - "$(SRCROOT)/include/API", + "$(SRCROOT)/scripts/Python/python-wrapper.swig", + "$(SRCROOT)/scripts/Python/python-typemaps.swig", + "$(SRCROOT)/scripts/Python/python-swigsafecast.swig", + "$(SRCROOT)/source/API/SBAddress.cpp", + "$(SRCROOT)/source/API/SBAttachInfo.cpp", + "$(SRCROOT)/source/API/SBBlock.cpp", + "$(SRCROOT)/source/API/SBBreakpoint.cpp", + "$(SRCROOT)/source/API/SBBreakpointLocation.cpp", + "$(SRCROOT)/source/API/SBBreakpointName.cpp", + "$(SRCROOT)/source/API/SBBreakpointOptionCommon.cpp", + "$(SRCROOT)/source/API/SBBroadcaster.cpp", + "$(SRCROOT)/source/API/SBCommandInterpreter.cpp", + "$(SRCROOT)/source/API/SBCommandReturnObject.cpp", + "$(SRCROOT)/source/API/SBCompileUnit.cpp", + "$(SRCROOT)/source/API/SBData.cpp", + "$(SRCROOT)/source/API/SBDebugger.cpp", + "$(SRCROOT)/source/API/SBDeclaration.cpp", + "$(SRCROOT)/source/API/SBError.cpp", + "$(SRCROOT)/source/API/SBEvent.cpp", + "$(SRCROOT)/source/API/SBExecutionContext.cpp", + "$(SRCROOT)/source/API/SBExpressionOptions.cpp", + "$(SRCROOT)/source/API/SBFileSpec.cpp", + "$(SRCROOT)/source/API/SBFileSpecList.cpp", + "$(SRCROOT)/source/API/SBFrame.cpp", + "$(SRCROOT)/source/API/SBFunction.cpp", + "$(SRCROOT)/source/API/SBHostOS.cpp", + "$(SRCROOT)/source/API/SBInstruction.cpp", + "$(SRCROOT)/source/API/SBInstructionList.cpp", + "$(SRCROOT)/source/API/SBLanguageRuntime.cpp", + "$(SRCROOT)/source/API/SBLaunchInfo.cpp", + "$(SRCROOT)/source/API/SBLineEntry.cpp", + "$(SRCROOT)/source/API/SBListener.cpp", + "$(SRCROOT)/source/API/SBMemoryRegionInfo.cpp", + "$(SRCROOT)/source/API/SBMemoryRegionInfoList.cpp", + "$(SRCROOT)/source/API/SBModule.cpp", + "$(SRCROOT)/source/API/SBModuleSpec.cpp", + "$(SRCROOT)/source/API/SBPlatform.cpp", + "$(SRCROOT)/source/API/SBProcess.cpp", + "$(SRCROOT)/source/API/SBProcessInfo.cpp", + "$(SRCROOT)/source/API/SBQueue.cpp", + "$(SRCROOT)/source/API/SBQueueItem.cpp", + "$(SRCROOT)/source/API/SBSection.cpp", + "$(SRCROOT)/source/API/SBSourceManager.cpp", + "$(SRCROOT)/source/API/SBStream.cpp", + "$(SRCROOT)/source/API/SBStringList.cpp", + "$(SRCROOT)/source/API/SBStructuredData.cpp", + "$(SRCROOT)/source/API/SBSymbol.cpp", + "$(SRCROOT)/source/API/SBSymbolContext.cpp", + "$(SRCROOT)/source/API/SBSymbolContextList.cpp", + "$(SRCROOT)/source/API/SBTarget.cpp", + "$(SRCROOT)/source/API/SBThread.cpp", + "$(SRCROOT)/source/API/SBThreadCollection.cpp", + "$(SRCROOT)/source/API/SBThreadPlan.cpp", + "$(SRCROOT)/source/API/SBTrace.cpp", + "$(SRCROOT)/source/API/SBTraceOptions.cpp", + "$(SRCROOT)/source/API/SBType.cpp", + "$(SRCROOT)/source/API/SBTypeCategory.cpp", + "$(SRCROOT)/source/API/SBTypeEnumMember.cpp", + "$(SRCROOT)/source/API/SBTypeFilter.cpp", + "$(SRCROOT)/source/API/SBTypeFormat.cpp", + "$(SRCROOT)/source/API/SBTypeNameSpecifier.cpp", + "$(SRCROOT)/source/API/SBTypeSummary.cpp", + "$(SRCROOT)/source/API/SBTypeSynthetic.cpp", + "$(SRCROOT)/source/API/SBUnixSignals.cpp", + "$(SRCROOT)/source/API/SBValue.cpp", + "$(SRCROOT)/source/API/SBValueList.cpp", + "$(SRCROOT)/source/API/SBVariablesOptions.cpp", + "$(SRCROOT)/source/API/SBWatchpoint.cpp", ); name = "Prepare Swig Bindings"; outputPaths = ( @@ -7657,7 +8029,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sh $SRCROOT/scripts/finish-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $BUILT_PRODUCTS_DIR \"\""; + shellScript = "sh $SRCROOT/scripts/finish-swig-wrapper-classes.sh $SRCROOT $TARGET_BUILD_DIR $BUILT_PRODUCTS_DIR \"\"\n"; }; A54A7D131A0D99FC001912FE /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -7684,9 +8056,88 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = "/bin/sh -x"; - shellScript = "/bin/rm -rf \"$INSTALL_ROOT/System/Library/PrivateFrameworks/LLDB.framework/Resources\" \"$INSTALL_ROOT/System/Library/PrivateFrameworks/LLDB.framework/Swift\""; + shellScript = "/bin/rm -rf \"$INSTALL_ROOT/System/Library/PrivateFrameworks/LLDB.framework/Resources\" \"$INSTALL_ROOT/System/Library/PrivateFrameworks/LLDB.framework/Swift\"\n"; showEnvVarsInLog = 0; }; + DD5F951721ADD0C900B8265A /* Run Tablegen */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + $SOURCE_DIR/tools/driver/Options.td, + ); + name = "Run Tablegen"; + outputFileListPaths = ( + ); + outputPaths = ( + $BUILT_PRODUCTS_DIR/Options.inc, + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -x\nmkdir -p $BUILT_PRODUCTS_DIR/include\n$(find $LLVM_BUILD_DIR/ -path '*/bin/llvm-tblgen'|head -1) -I$LLDB_PATH_TO_LLVM_SOURCE/include -gen-opt-parser-defs $SRCROOT/tools/driver/Options.td -o $BUILT_PRODUCTS_DIR/include/Options.inc\n"; + }; + DD8DC27122026E4400EB6F9E /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "$(SRCROOT)/docs/index.rst", + "$(SRCROOT)/docs/resources/build.rst", + "$(SRCROOT)/docs/resources/download.rst", + "$(SRCROOT)/docs/resources/external.rst", + "$(SRCROOT)/docs/resources/sbapi.rst", + "$(SRCROOT)/docs/resources/test.rst", + "$(SRCROOT)/docs/status/about.rst", + "$(SRCROOT)/docs/status/features.rst", + "$(SRCROOT)/docs/status/goals.rst", + "$(SRCROOT)/docs/status/projects.rst", + "$(SRCROOT)/docs/status/status.rst", + "$(SRCROOT)/docs/use/architecture.rst", + "$(SRCROOT)/docs/use/formatting.rst", + "$(SRCROOT)/docs/use/map.rst", + "$(SRCROOT)/docs/use/python.rst", + "$(SRCROOT)/docs/use/remote.rst", + "$(SRCROOT)/docs/use/symbolication.rst", + "$(SRCROOT)/docs/use/symbols.rst", + "$(SRCROOT)/docs/use/troubleshooting.rst", + "$(SRCROOT)/docs/use/tutorial.rst", + "$(SRCROOT)/docs/use/variable.rst", + ); + outputFileListPaths = ( + ); + outputPaths = ( + $BUILT_PRODUCTS_DIR/docs/html/index.html, + $BUILT_PRODUCTS_DIR/docs/html/resources/build.html, + $BUILT_PRODUCTS_DIR/docs/html/resources/download.html, + $BUILT_PRODUCTS_DIR/docs/html/resources/external.html, + $BUILT_PRODUCTS_DIR/docs/html/resources/sbapi.html, + $BUILT_PRODUCTS_DIR/docs/html/resources/test.html, + $BUILT_PRODUCTS_DIR/docs/html/status/about.html, + $BUILT_PRODUCTS_DIR/docs/html/status/features.html, + $BUILT_PRODUCTS_DIR/docs/html/status/goals.html, + $BUILT_PRODUCTS_DIR/docs/html/status/projects.html, + $BUILT_PRODUCTS_DIR/docs/html/status/status.html, + $BUILT_PRODUCTS_DIR/docs/html/use/architecture.html, + $BUILT_PRODUCTS_DIR/docs/html/use/formatting.html, + $BUILT_PRODUCTS_DIR/docs/html/use/map.html, + $BUILT_PRODUCTS_DIR/docs/html/use/python.html, + $BUILT_PRODUCTS_DIR/docs/html/use/remote.html, + $BUILT_PRODUCTS_DIR/docs/html/use/symbolication.html, + $BUILT_PRODUCTS_DIR/docs/html/use/symbols.html, + $BUILT_PRODUCTS_DIR/docs/html/use/troubleshooting.html, + $BUILT_PRODUCTS_DIR/docs/html/use/tutorial.html, + $BUILT_PRODUCTS_DIR/docs/html/use/variable.html, + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "mkdir -p $BUILT_PRODUCTS_DIR/docs\ncd $SRCROOT/docs\nsphinx-build -b html -d $BUILT_PRODUCTS_DIR/docs/_doctrees-lldb-html -q -W $SRCROOT/docs $BUILT_PRODUCTS_DIR/docs/html\necho \"Docs written to $BUILT_PRODUCTS_DIR/docs/html\"\n"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -7694,6 +8145,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4C639ED221FA684900A7B957 /* RegisterValueTest.cpp in Sources */, 9A3D43D91F3151C400EB767C /* StatusTest.cpp in Sources */, 23CB15341D66DA9300EDDDE1 /* CPlusPlusLanguageTest.cpp in Sources */, 9A2057381F3B8E7E00F6C293 /* FileSystemTest.cpp in Sources */, @@ -7710,19 +8162,23 @@ 58A080B32112AB2900D5580F /* HighlighterTest.cpp in Sources */, 9A2057081F3B819100F6C293 /* MemoryRegionInfoTest.cpp in Sources */, 9A20572D1F3B8E6600F6C293 /* TestCompletion.cpp in Sources */, + AFA1B62C219E0ED900A8AB7E /* DataExtractorTest.cpp in Sources */, 4C719399207D23E300FDF430 /* TestOptionArgParser.cpp in Sources */, + 4C639ED621FA684900A7B957 /* FlagsTest.cpp in Sources */, 23CB15371D66DA9300EDDDE1 /* PythonTestSuite.cpp in Sources */, 4CEC86A7204738EB009B37B1 /* TestPPC64InstEmulation.cpp in Sources */, 58EAC73F2106A07B0029571E /* StreamTeeTest.cpp in Sources */, + 4C639ED821FA684900A7B957 /* VMRangeTest.cpp in Sources */, 23CB15381D66DA9300EDDDE1 /* PythonExceptionStateTests.cpp in Sources */, 9A3D43D81F3151C400EB767C /* NameMatchesTest.cpp in Sources */, - 23CB15391D66DA9300EDDDE1 /* DataExtractorTest.cpp in Sources */, 4CEC86A4204738C5009B37B1 /* TestArm64InstEmulation.cpp in Sources */, 9A3D43ED1F3237F900EB767C /* StateTest.cpp in Sources */, 23CB153A1D66DA9300EDDDE1 /* GDBRemoteClientBaseTest.cpp in Sources */, 23CB153B1D66DA9300EDDDE1 /* SocketTest.cpp in Sources */, + DD8F278222011D15004ED75B /* FileCollectorTest.cpp in Sources */, 23CB153C1D66DA9300EDDDE1 /* ArgsTest.cpp in Sources */, 9A3D43DB1F3151C400EB767C /* TildeExpressionResolverTest.cpp in Sources */, + 4C639ED021FA684900A7B957 /* UUIDTest.cpp in Sources */, 9A2057291F3B8DDB00F6C293 /* TestObjectFileELF.cpp in Sources */, 23CB153D1D66DA9300EDDDE1 /* GDBRemoteCommunicationClientTest.cpp in Sources */, 23CB153E1D66DA9300EDDDE1 /* PythonDataObjectsTests.cpp in Sources */, @@ -7734,14 +8190,20 @@ 9A3D43EC1F3237F900EB767C /* ListenerTest.cpp in Sources */, 9A3D43DC1F3151C400EB767C /* TimeoutTest.cpp in Sources */, 9A3D43D61F3151C400EB767C /* ConstStringTest.cpp in Sources */, + 4C639ECB21FA684900A7B957 /* EnvironmentTest.cpp in Sources */, 9A20571C1F3B867400F6C293 /* PlatformDarwinTest.cpp in Sources */, + 4C639ECF21FA684900A7B957 /* ReproducerTest.cpp in Sources */, 23CB153F1D66DA9300EDDDE1 /* SymbolsTest.cpp in Sources */, 23CB15401D66DA9300EDDDE1 /* TestClangASTContext.cpp in Sources */, 23CB15411D66DA9300EDDDE1 /* StringExtractorTest.cpp in Sources */, 9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */, + 4C639ED121FA684900A7B957 /* OptionsWithRawTest.cpp in Sources */, + 4C639ED321FA684900A7B957 /* EventTest.cpp in Sources */, 9A18903C1F47D5E600394BCA /* TestUtilities.cpp in Sources */, AF6F1EDE2193B022008F190E /* TestSwiftASTContext.cpp in Sources */, + 4C639ECD21FA684900A7B957 /* StreamTest.cpp in Sources */, 23CB15421D66DA9300EDDDE1 /* TaskPoolTest.cpp in Sources */, + 4C639ECE21FA684900A7B957 /* PredicateTest.cpp in Sources */, 23CB15431D66DA9300EDDDE1 /* BroadcasterTest.cpp in Sources */, 9A3D43EE1F3237F900EB767C /* StreamCallbackTest.cpp in Sources */, 9A18903B1F47D5E600394BCA /* MockTildeExpressionResolver.cpp in Sources */, @@ -7750,8 +8212,13 @@ 23CB15451D66DA9300EDDDE1 /* SocketAddressTest.cpp in Sources */, 9A3D43DD1F3151C400EB767C /* TimerTest.cpp in Sources */, 23CB15461D66DA9300EDDDE1 /* GDBRemoteTestUtils.cpp in Sources */, + 4C639ED521FA684900A7B957 /* AnsiTerminalTest.cpp in Sources */, AF7F97682141FA4500795BC0 /* TestArmv7Disassembly.cpp in Sources */, + 23E2E5271D903782006F38BB /* MinidumpParserTest.cpp in Sources */, + 4C639ECC21FA684900A7B957 /* StringListTest.cpp in Sources */, + 4C639ED721FA684900A7B957 /* CompletionRequestTest.cpp in Sources */, 23CB15471D66DA9300EDDDE1 /* EditlineTest.cpp in Sources */, + 4C639ED421FA684900A7B957 /* StringLexerTest.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7797,6 +8264,7 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */, 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */, 26DE204511618ADA00A093E2 /* SBAddress.cpp in Sources */, + AFB2F2F621B71AF30078DEF1 /* SBInitializerOptions.cpp in Sources */, 26DE204711618AED00A093E2 /* SBSymbolContext.cpp in Sources */, 26DE204D11618E7A00A093E2 /* SBModule.cpp in Sources */, 26DE205D1161901400A093E2 /* SBFunction.cpp in Sources */, @@ -7839,17 +8307,32 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 26792608211CA3AC00EE1D10 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2679261E211CA3F200EE1D10 /* lldb-vscode.cpp in Sources */, + 2660387E211CA98200329572 /* BreakpointBase.cpp in Sources */, + 26603879211CA90F00329572 /* SourceBreakpoint.cpp in Sources */, + 2660387A211CA90F00329572 /* ExceptionBreakpoint.cpp in Sources */, + 2660387B211CA90F00329572 /* JSONUtils.cpp in Sources */, + 26F7619B211CBBB30044F6EA /* LLDBUtils.cpp in Sources */, + 2660387C211CA90F00329572 /* FunctionBreakpoint.cpp in Sources */, + 26603878211CA90F00329572 /* VSCode.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2689FFC613353D7A00698AC0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 33E5E8471A674FB60024ED68 /* StringConvert.cpp in Sources */, 2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */, + 4C9BF11B21C0467700FA4036 /* ObjectFileBreakpad.cpp in Sources */, 4C0083401B9F9BA900D5CF24 /* UtilityFunction.cpp in Sources */, 26474CCD18D0CB5B0073DEBA /* RegisterContextPOSIX_x86.cpp in Sources */, 4FBC04ED211A06200015A814 /* RichManglingContext.cpp in Sources */, AEB0E4591BD6E9F800B24093 /* LLVMUserExpression.cpp in Sources */, - AFF81FB320D1CC910010F95E /* PlatformiOSSimulatorCoreSimulatorSupport.mm in Sources */, 2689FFEF13353DB600698AC0 /* Breakpoint.cpp in Sources */, 267A47FB1B1411C40021A5BC /* NativeRegisterContext.cpp in Sources */, 2689FFF113353DB600698AC0 /* BreakpointID.cpp in Sources */, @@ -7858,15 +8341,16 @@ 2689FFF313353DB600698AC0 /* BreakpointIDList.cpp in Sources */, 2689FFF513353DB600698AC0 /* BreakpointList.cpp in Sources */, 4CDB8D6E1DBA91B6006C5B13 /* LibStdcppTuple.cpp in Sources */, - 949EEDB31BA76736008C63CF /* NSSet.cpp in Sources */, AF77E08F1A033C700096C0EA /* ABISysV_ppc.cpp in Sources */, 2689FFF713353DB600698AC0 /* BreakpointLocation.cpp in Sources */, 2654A68D1E552D1500DA1013 /* PseudoTerminal.cpp in Sources */, 2689FFF913353DB600698AC0 /* BreakpointLocationCollection.cpp in Sources */, 49F811F31E931B2100F4E163 /* CPlusPlusNameParser.cpp in Sources */, 2689FFFB13353DB600698AC0 /* BreakpointLocationList.cpp in Sources */, + AFD966B9217140B6006714AC /* PdbUtil.cpp in Sources */, 2689FFFD13353DB600698AC0 /* BreakpointOptions.cpp in Sources */, 948C86D31B97764D00F3CAC3 /* SwiftDictionary.cpp in Sources */, + AF0578C4217FA80700CF9D80 /* UdtRecordCompleter.cpp in Sources */, 2689FFFF13353DB600698AC0 /* BreakpointResolver.cpp in Sources */, 25420ECD1A6490B8009ADBCB /* OptionValueChar.cpp in Sources */, 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */, @@ -7910,6 +8394,8 @@ 964463EC1A330C0500154ED8 /* CompactUnwindInfo.cpp in Sources */, 26B7564E14F89356008D9CB3 /* PlatformiOSSimulator.cpp in Sources */, 94B638531B8F8E6C004FE1E4 /* Language.cpp in Sources */, + AF395C03219254F300894EC3 /* MSVCUndecoratedNameParser.cpp in Sources */, + AF815DF921C855B400023A34 /* PdbAstBuilder.cpp in Sources */, 2689001D13353DDE00698AC0 /* CommandObjectLog.cpp in Sources */, 949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */, 262173A318395D4600C52091 /* SectionLoadHistory.cpp in Sources */, @@ -7921,6 +8407,7 @@ 2689002113353DDE00698AC0 /* CommandObjectQuit.cpp in Sources */, 2689002213353DDE00698AC0 /* CommandObjectRegister.cpp in Sources */, 26BC17AF18C7F4CB00D2196D /* RegisterContextPOSIXCore_x86_64.cpp in Sources */, + 2619C4842107A9A2009CDE81 /* RegisterContextMinidump_ARM64.cpp in Sources */, 2689002313353DDE00698AC0 /* CommandObjectScript.cpp in Sources */, 2689002413353DDE00698AC0 /* CommandObjectSettings.cpp in Sources */, 2689002513353DDE00698AC0 /* CommandObjectSource.cpp in Sources */, @@ -7949,7 +8436,6 @@ 2689002D13353E0400698AC0 /* AddressResolverFileLine.cpp in Sources */, 2689002E13353E0400698AC0 /* AddressResolverName.cpp in Sources */, 250D6AE31A9679440049CC70 /* FileSystem.cpp in Sources */, - 2689003113353E0400698AC0 /* Broadcaster.cpp in Sources */, 49DCF702170E70120092F75E /* Materializer.cpp in Sources */, 2689003213353E0400698AC0 /* Communication.cpp in Sources */, 2689003313353E0400698AC0 /* Connection.cpp in Sources */, @@ -7964,19 +8450,20 @@ 946216C21A97C080006E19CC /* OptionValueLanguage.cpp in Sources */, 26764CA01E48F528008D3573 /* RegularExpression.cpp in Sources */, 2689003B13353E0400698AC0 /* EmulateInstruction.cpp in Sources */, - 2689003D13353E0400698AC0 /* Event.cpp in Sources */, AFC2DCE91E6E2F2C00283714 /* Baton.cpp in Sources */, 26B75B441AD6E29A001F7A57 /* MipsLinuxSignals.cpp in Sources */, 2689003E13353E0400698AC0 /* FileSpecList.cpp in Sources */, - 2689004113353E0400698AC0 /* Listener.cpp in Sources */, 269DDD4A1B8FD1C300D0DBD8 /* DWARFASTParserClang.cpp in Sources */, 2689004213353E0400698AC0 /* Log.cpp in Sources */, 2689004313353E0400698AC0 /* Mangled.cpp in Sources */, 2689004413353E0400698AC0 /* Module.cpp in Sources */, 2689004513353E0400698AC0 /* ModuleChild.cpp in Sources */, + 2647B63A21C436AC00A81D15 /* Broadcaster.cpp in Sources */, + AF8AD6301BEC28A400150209 /* PlatformAppleWatchSimulator.cpp in Sources */, 266E829D1B8E542C008FCA06 /* DWARFAttribute.cpp in Sources */, 26764C9E1E48F51E008D3573 /* Stream.cpp in Sources */, 2689004613353E0400698AC0 /* ModuleList.cpp in Sources */, + AF0F459E219FA1C800C1E612 /* PdbSymUid.cpp in Sources */, 2689004713353E0400698AC0 /* PluginManager.cpp in Sources */, AFF81FAF20D1CC400010F95E /* HostThreadMacOSX.mm in Sources */, AF0C112818580CD800C4C45B /* QueueItem.cpp in Sources */, @@ -7998,6 +8485,7 @@ 2689005113353E0400698AC0 /* StringList.cpp in Sources */, 2689005213353E0400698AC0 /* Timer.cpp in Sources */, 2689005413353E0400698AC0 /* UserSettingsController.cpp in Sources */, + 2619C4852107A9A2009CDE81 /* RegisterContextMinidump_ARM.cpp in Sources */, 948C86D61B97764D00F3CAC3 /* SwiftMetatype.cpp in Sources */, 23059A0719532B96007B8189 /* LinuxSignals.cpp in Sources */, 8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */, @@ -8047,6 +8535,7 @@ AF2BA6EC1A707E3400C5248A /* UriParser.cpp in Sources */, 2689006D13353E0E00698AC0 /* IRExecutionUnit.cpp in Sources */, 304B2E461CAAA57B007829FE /* ClangUtil.cpp in Sources */, + 2647B64421C43BB000A81D15 /* LinuxProcMaps.cpp in Sources */, 2689006E13353E1A00698AC0 /* File.cpp in Sources */, 2689006F13353E1A00698AC0 /* FileSpec.cpp in Sources */, AF6CA6661FBBAF28005A0DC3 /* ArchSpec.cpp in Sources */, @@ -8059,7 +8548,6 @@ 26474CBC18D0CB2D0073DEBA /* RegisterContextMach_arm.cpp in Sources */, 948C86D51B97764D00F3CAC3 /* SwiftHashedContainer.cpp in Sources */, 2689007413353E1A00698AC0 /* Terminal.cpp in Sources */, - AF6335E21C87B21E00F7D554 /* SymbolFilePDB.cpp in Sources */, 942612F01B94D33200EF842E /* SwiftLanguage.cpp in Sources */, 2689007613353E1A00698AC0 /* CFCBundle.cpp in Sources */, 9A0FDEA71E8EF5110086B2F5 /* RegisterContextLinux_mips.cpp in Sources */, @@ -8127,10 +8615,14 @@ AFE228832060699D0042D0C8 /* DWARFUnit.cpp in Sources */, AEEA34051AC88A7400AB639D /* TypeSystem.cpp in Sources */, AF1729D6182C907200E0AB97 /* HistoryThread.cpp in Sources */, + 2647B63221C4366300A81D15 /* ArchitectureMips.cpp in Sources */, 268900AF13353E5000698AC0 /* UnwindLLDB.cpp in Sources */, 268900B013353E5000698AC0 /* RegisterContextLLDB.cpp in Sources */, 23E2E5451D904913006F38BB /* MinidumpTypes.cpp in Sources */, AF33B4BE1C1FA441001B28D9 /* NetBSDSignals.cpp in Sources */, + 949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */, + AFD966BB217140B6006714AC /* SymbolFileNativePDB.cpp in Sources */, + AFCB1D59219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp in Sources */, 3FDFE56C19AF9C44009756A7 /* HostProcessPosix.cpp in Sources */, 268900B413353E5000698AC0 /* RegisterContextMacOSXFrameBackchain.cpp in Sources */, 6B74D89B200696BB0074051B /* Environment.cpp in Sources */, @@ -8140,8 +8632,11 @@ 268900B613353E5000698AC0 /* UnwindMacOSXFrameBackchain.cpp in Sources */, 4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp in Sources */, 268900B713353E5F00698AC0 /* DWARFAbbreviationDeclaration.cpp in Sources */, + AFD966B8217140B6006714AC /* CompileUnitIndex.cpp in Sources */, 268900B813353E5F00698AC0 /* DWARFCompileUnit.cpp in Sources */, 268900B913353E5F00698AC0 /* DWARFDebugAbbrev.cpp in Sources */, + AF8AD945219CD45800614785 /* GDBRemoteCommunicationHistory.cpp in Sources */, + 949EEDB31BA76736008C63CF /* NSSet.cpp in Sources */, 268900BA13353E5F00698AC0 /* DWARFDebugAranges.cpp in Sources */, 268900BB13353E5F00698AC0 /* DWARFDebugArangeSet.cpp in Sources */, 268900BC13353E5F00698AC0 /* DWARFDebugInfo.cpp in Sources */, @@ -8183,6 +8678,7 @@ 945261C11B9A11FC00BF138D /* LibCxxInitializerList.cpp in Sources */, 268900D313353E6F00698AC0 /* ClangExternalASTSourceCallbacks.cpp in Sources */, 268900D513353E6F00698AC0 /* CompileUnit.cpp in Sources */, + AFCB1D5C219CD5A800730AD5 /* CommandObjectReproducer.cpp in Sources */, 268900D613353E6F00698AC0 /* Declaration.cpp in Sources */, 2579065C1BD0488100178368 /* TCPSocket.cpp in Sources */, 268900D713353E6F00698AC0 /* DWARFCallFrameInfo.cpp in Sources */, @@ -8207,6 +8703,7 @@ 945261C51B9A11FC00BF138D /* LibCxxVector.cpp in Sources */, 3FDFED2719BA6D96009756A7 /* HostNativeThreadBase.cpp in Sources */, 268900E313353E6F00698AC0 /* TypeList.cpp in Sources */, + 2647B63E21C436BD00A81D15 /* Listener.cpp in Sources */, 268900E413353E6F00698AC0 /* UnwindPlan.cpp in Sources */, 268900E513353E6F00698AC0 /* UnwindTable.cpp in Sources */, AFF8FF0C1E779D4B003830EF /* TildeExpressionResolver.cpp in Sources */, @@ -8228,6 +8725,7 @@ 268900EE13353E6F00698AC0 /* PathMappingList.cpp in Sources */, 4C2479BD1BA39295009C9A7B /* FunctionCaller.cpp in Sources */, AF2907BF1D3F082400E10654 /* DynamicLoaderMacOS.cpp in Sources */, + AFCB1D5F219CD5EA00730AD5 /* Reproducer.cpp in Sources */, 268900EF13353E6F00698AC0 /* Platform.cpp in Sources */, 268900F013353E6F00698AC0 /* Process.cpp in Sources */, 948C86D21B97764D00F3CAC3 /* SwiftBasicTypes.cpp in Sources */, @@ -8269,13 +8767,12 @@ 232CB61B191E00CD00EF39FC /* NativeThreadProtocol.cpp in Sources */, 4CD44CFB20B37C440003557C /* DWARFIndex.cpp in Sources */, 2689010113353E6F00698AC0 /* ThreadPlanStepOut.cpp in Sources */, + 4CAEC6A821F26D15007C3DD5 /* BreakpadRecords.cpp in Sources */, 2689010213353E6F00698AC0 /* ThreadPlanStepOverBreakpoint.cpp in Sources */, 3FDFED2919BA6D96009756A7 /* ThreadLauncher.cpp in Sources */, - 232CB617191E00CD00EF39FC /* NativeBreakpointList.cpp in Sources */, 4C719395207D235400FDF430 /* OptionArgParser.cpp in Sources */, 942829561A89614C00521B30 /* JSON.cpp in Sources */, 267F68531CC02E920086832B /* RegisterContextLinux_s390x.cpp in Sources */, - 232CB615191E00CD00EF39FC /* NativeBreakpoint.cpp in Sources */, 2689010313353E6F00698AC0 /* ThreadPlanStepRange.cpp in Sources */, 2689010413353E6F00698AC0 /* ThreadPlanStepInRange.cpp in Sources */, 2689010513353E6F00698AC0 /* ThreadPlanStepOverRange.cpp in Sources */, @@ -8292,6 +8789,7 @@ 26474CAA18D0CB070073DEBA /* RegisterContextFreeBSD_mips64.cpp in Sources */, 256CBDC01ADD11C000BC6CDC /* RegisterContextPOSIX_arm.cpp in Sources */, 26CA97A1172B1FD5005DC71B /* RegisterContextThreadMemory.cpp in Sources */, + DD8F277F22011CD8004ED75B /* FileCollector.cpp in Sources */, 2689010B13353E6F00698AC0 /* ThreadSpec.cpp in Sources */, 2689010C13353E6F00698AC0 /* UnixSignals.cpp in Sources */, 2689011013353E8200698AC0 /* SharingPtr.cpp in Sources */, @@ -8364,7 +8862,6 @@ AF415AE71D949E4400FCE0D4 /* x86AssemblyInspectionEngine.cpp in Sources */, 9404957B1BEC497E00926025 /* NSException.cpp in Sources */, 26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */, - 232CB61D191E00CD00EF39FC /* SoftwareBreakpoint.cpp in Sources */, 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */, 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */, 4C562CC71CC07DF700C52EAC /* PDBASTParser.cpp in Sources */, @@ -8373,13 +8870,13 @@ 4CCA644D13B40B82003BDF98 /* ItaniumABILanguageRuntime.cpp in Sources */, 4CCA645013B40B82003BDF98 /* AppleObjCRuntime.cpp in Sources */, 4CCA645213B40B82003BDF98 /* AppleObjCRuntimeV1.cpp in Sources */, - 949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */, 4CCA645413B40B82003BDF98 /* AppleObjCRuntimeV2.cpp in Sources */, 4CCA645613B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp in Sources */, 4CCA645813B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */, 9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */, 49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */, 26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */, + 2647B63C21C436B400A81D15 /* Event.cpp in Sources */, 2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */, 2642FBB013D003B400ED6808 /* ProcessKDP.cpp in Sources */, 23D4007E1C210201000C3885 /* DebugMacros.cpp in Sources */, @@ -8389,6 +8886,7 @@ AF254E31170CCC33007AE5C9 /* PlatformDarwinKernel.cpp in Sources */, 263641191B34AEE200145B2F /* ABISysV_mips64.cpp in Sources */, 26957D9813D381C900670048 /* RegisterContextDarwin_arm.cpp in Sources */, + 4C38996421B9AECD002BAEF4 /* DWARFLocationExpression.cpp in Sources */, 26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */, 26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */, 948C86D81B97764D00F3CAC3 /* SwiftOptionSet.cpp in Sources */, @@ -8408,6 +8906,8 @@ 3FBA69E11B6067120008F44A /* ScriptInterpreterNone.cpp in Sources */, AF9113FD1FBE78EA004320CD /* RegisterContextPOSIXCore_ppc64le.cpp in Sources */, 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */, + AF97744721E9947E006876A7 /* SymbolFileBreakpad.cpp in Sources */, + AF8AD6391BEC28C400150209 /* PlatformRemoteAppleWatch.cpp in Sources */, 26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */, 6D9AB3DD1BB2B74E003F2289 /* TypeMap.cpp in Sources */, 255EFF761AFABA950069F277 /* LockFilePosix.cpp in Sources */, @@ -8456,7 +8956,6 @@ 260CC64A15D0440D002BF2E0 /* OptionValueBoolean.cpp in Sources */, 260CC64B15D0440D002BF2E0 /* OptionValueProperties.cpp in Sources */, 6D86CEA01B440F8500A7FBFA /* CommandObjectBugreport.cpp in Sources */, - AF8AD6391BEC28C400150209 /* PlatformRemoteAppleWatch.cpp in Sources */, 260CC64C15D0440D002BF2E0 /* OptionValueDictionary.cpp in Sources */, 49DCF6FE170E6B4A0092F75E /* IRMemoryMap.cpp in Sources */, 260CC64D15D0440D002BF2E0 /* OptionValueEnumeration.cpp in Sources */, @@ -8472,7 +8971,6 @@ 6D55B2911A8A806200A70529 /* GDBRemoteCommunicationServerLLGS.cpp in Sources */, 260CC65315D0440D002BF2E0 /* OptionValueUInt64.cpp in Sources */, 260CC65415D0440D002BF2E0 /* OptionValueUUID.cpp in Sources */, - 94BA8B6D176F8C9B005A91B5 /* Range.cpp in Sources */, 267F684A1CC02DED0086832B /* ABISysV_s390x.cpp in Sources */, AFDBC36E204663AF00B9C8F2 /* EmulateInstructionPPC64.cpp in Sources */, 26DAED6315D327C200E15819 /* OptionValuePathMappings.cpp in Sources */, @@ -8489,6 +8987,7 @@ 947A1D641616476B0017C8D1 /* CommandObjectPlugin.cpp in Sources */, 2666ADC81B3CB675001FAFD3 /* HexagonDYLDRendezvous.cpp in Sources */, 26A375811D59462700D6CBDB /* SelectHelper.cpp in Sources */, + AFD966BA217140B6006714AC /* PdbIndex.cpp in Sources */, 262ED0081631FA3A00879631 /* OptionGroupString.cpp in Sources */, 94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */, AF9107EF168570D200DBCD3C /* RegisterContextDarwin_arm64.cpp in Sources */, @@ -8671,6 +9170,11 @@ target = 26680206115FD0ED008E1FE4 /* LLDB */; targetProxy = 266803611160110D008E1FE4 /* PBXContainerItemProxy */; }; + 26792620211CA40700EE1D10 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 26680206115FD0ED008E1FE4 /* LLDB */; + targetProxy = 2679261F211CA40700EE1D10 /* PBXContainerItemProxy */; + }; 2687EACB1508115000DD8C2E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 2687EAC51508110B00DD8C2E /* install-headers */; @@ -8847,26 +9351,23 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(LLVM_BUILD_DIR)"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/swift"; LLDB_TOOLS_INSTALL_DIR = /usr/bin; LLDB_USE_OSS_VERSION_SCHEME = 1; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLVM_BUILD_DIRTREE)/$(LLVM_CONFIGURATION)"; LLVM_BUILD_DIRTREE = "$(SRCROOT)/llvm-build"; - LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; - "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; + LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64"; + "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=watchos*]" = "llvm-watchos-x86_64/"; - LLVM_CONFIGURATION = ReleaseAssert; + LLVM_CONFIGURATION = "Release+Asserts"; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", "-DLLDB_BUILD_DATE=\"$(LLDB_BUILD_DATE)\"", @@ -8875,7 +9376,7 @@ "-Wimplicit-fallthrough", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", + "-lcompression", "$(LLDB_COMPRESSION_LDFLAGS)", ); PYTHON_FRAMEWORK_PATH = "$(SDKROOT)/System/Library/Frameworks/Python.framework"; @@ -8973,26 +9474,23 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(LLVM_BUILD_DIR)"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/../swift"; LLDB_TOOLS_INSTALL_DIR = /usr/bin; LLDB_USE_OSS_VERSION_SCHEME = 1; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLVM_BUILD_DIRTREE)/$(LLVM_CONFIGURATION)"; LLVM_BUILD_DIRTREE = "$(SRCROOT)/llvm-build"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=watchos*]" = "llvm-watchos-x86_64/"; - LLVM_CONFIGURATION = ReleaseAssert; + LLVM_CONFIGURATION = "Release+Asserts"; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", "-DLLDB_BUILD_DATE=\"$(LLDB_BUILD_DATE)\"", @@ -9001,7 +9499,7 @@ "-Wimplicit-fallthrough", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", + "-lcompression", "$(LLDB_COMPRESSION_LDFLAGS)", ); PYTHON_FRAMEWORK_PATH = "$(SDKROOT)/System/Library/Frameworks/Python.framework"; @@ -9124,12 +9622,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -9157,6 +9654,39 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", + "$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks", + ); + HEADER_SEARCH_PATHS = ( + "$(LLVM_SOURCE_DIR)/tools/clang/include", + "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", + ); + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; + OTHER_CFLAGS = ( + "-fno-rtti", + "-Wparentheses", + "$(LLDB_GTESTS_CFLAGS)", + "-DGTEST_HAS_RTTI=0", + ); + OTHER_LDFLAGS = ( + "$(inherited)", + "-filelist", + "$(LLVM_BUILD_DIR)/archives.txt", + "-framework", + Foundation, + "-framework", + DebugSymbols, + "-framework", + Security, + "-framework", + CoreServices, + "-framework", + ApplicationServices, + "$(LLDB_GTESTS_LDFLAGS)", + ); PRODUCT_NAME = "$(TARGET_NAME)"; }; name = "CustomSwift-RelWithDebInfo"; @@ -9203,12 +9733,11 @@ INFOPLIST_FILE = "tools/driver/lldb-Info.plist"; INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; LIBRARY_SEARCH_PATHS = "$(inherited)"; - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -9253,7 +9782,7 @@ LD_DYLIB_INSTALL_NAME = "@rpath/LLDB.framework/LLDB"; LIBRARY_SEARCH_PATHS = "$(LLDB_PATH_TO_LLVM_BUILD)"; LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_GTESTS_CFLAGS = "-I unittests -I ${SOURCE_ROOT} -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I ${SOURCE_ROOT} -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_TOOLS_INSTALL_DIR = ""; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; @@ -9264,6 +9793,9 @@ "-fno-rtti", "-Wglobal-constructors", "$(OTHER_CFLAGS)", + "-Wparentheses", + "$(LLDB_GTESTS_CFLAGS)", + "-DGTEST_HAS_RTTI=0", ); OTHER_CPLUSPLUSFLAGS = ( "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", @@ -9280,7 +9812,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -9300,7 +9831,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -9346,7 +9876,7 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = /usr/include/libxml2; LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_GTESTS_CFLAGS = "-I unittests -I ${SOURCE_ROOT} -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I ${SOURCE_ROOT} -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; MACH_O_TYPE = staticlib; OTHER_CFLAGS = ( @@ -9360,6 +9890,9 @@ "$(OTHER_CFLAGS)", "-DLIBXML2_DEFINED", "-DDT_VARIANT_$(DT_VARIANT)", + "-Wparentheses", + "$(LLDB_GTESTS_CFLAGS)", + "-DGTEST_HAS_RTTI=0", ); "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = ( "-fno-rtti", @@ -9408,7 +9941,7 @@ "-v", "-Wl,-v", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/x86_64/bin/yaml2obj\\\"\" -I include -I source -I $PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/include/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/include/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; @@ -9433,7 +9966,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -9451,7 +9983,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -9613,7 +10144,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; HEADER_SEARCH_PATHS = /usr/include/libxml2; LIBRARY_SEARCH_PATHS = "$(LLDB_PATH_TO_LLVM_BUILD)"; - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; @@ -9675,10 +10206,12 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "$(inherited)", + "-fno-rtti", + "-Wparentheses", "$(LLDB_GTESTS_CFLAGS)", ); OTHER_LDFLAGS = ( @@ -9713,12 +10246,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/include/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/include/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -9754,12 +10286,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -9799,12 +10330,24 @@ "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", "$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "$(inherited)", "$(LLDB_GTESTS_CFLAGS)", ); + LLDB_COMPRESSION_LDFLAGS = "-lcompression"; + OTHER_CPLUSPLUSFLAGS = ( + "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", + "-fno-rtti", + "-Wglobal-constructors", + "$(OTHER_CFLAGS)", + ); + "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = ( + "-fno-rtti", + "-Wglobal-constructors", + "$(OTHER_CFLAGS)", + ); OTHER_LDFLAGS = ( "$(inherited)", "-filelist", @@ -9833,7 +10376,7 @@ }; name = Release; }; - 239504DB1BDD451400963CEA /* BuildAndIntegration */ = { + 239504DB1BDD451400963CEA /* Release */ = { isa = XCBuildConfiguration; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( @@ -9841,12 +10384,24 @@ "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", "$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/x86_64/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "$(inherited)", "$(LLDB_GTESTS_CFLAGS)", ); + LLDB_COMPRESSION_LDFLAGS = "-lcompression"; + OTHER_CPLUSPLUSFLAGS = ( + "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", + "-fno-rtti", + "-Wglobal-constructors", + "$(OTHER_CFLAGS)", + ); + "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = ( + "-fno-rtti", + "-Wglobal-constructors", + "$(OTHER_CFLAGS)", + ); OTHER_LDFLAGS = ( "$(inherited)", "-filelist", @@ -9863,9 +10418,17 @@ ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", ); - PRODUCT_NAME = "$(TARGET_NAME)"; + "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( + "$(inherited)", + "-lllvmclang", + "-framework", + Foundation, + ); + PRODUCT_NAME = LLDB; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/Target/ARM"; + VERSIONING_SYSTEM = "apple-generic"; }; - name = BuildAndIntegration; + name = Release; }; 239D37F81D70A4AD00D8E937 /* Debug */ = { isa = XCBuildConfiguration; @@ -9879,12 +10442,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; - LLDB_GTESTS_LDFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/include/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_LDFLAGS = "-I unittests -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/include/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -9903,7 +10465,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PATH = /opt/local/bin; @@ -9927,12 +10488,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -9951,7 +10511,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -9967,7 +10526,7 @@ "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks\"", ); GCC_ENABLE_CPP_RTTI = NO; - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_GTEST_LIB = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a"; LLDB_PATH_TO_LLVM_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/llvm-macosx-x86_64"; @@ -9991,7 +10550,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -10032,12 +10590,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -10056,7 +10613,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -10078,7 +10634,7 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLDB_GTEST_LIB) -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_GTEST_LIB = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a"; LLDB_PATH_TO_LLVM_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/llvm-macosx-x86_64"; @@ -10102,7 +10658,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -10121,12 +10676,11 @@ "$(LLVM_SOURCE_DIR)/tools/clang/include", "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -10145,7 +10699,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -10162,7 +10715,7 @@ "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks\"", ); GCC_ENABLE_CPP_RTTI = NO; - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLDB_GTEST_LIB) -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_GTEST_LIB = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a"; OTHER_CFLAGS = ( @@ -10184,7 +10737,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -10200,7 +10752,7 @@ "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks\"", ); GCC_ENABLE_CPP_RTTI = NO; - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers -DGTEST_HAS_RTTI=0"; LLDB_GTESTS_LDFLAGS = "$(LLDB_GTEST_LIB) -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; LLDB_GTEST_LIB = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a"; LLDB_PATH_TO_LLVM_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/llvm-macosx-x86_64"; @@ -10224,7 +10776,6 @@ "-framework", ApplicationServices, "$(LLDB_GTESTS_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PRODUCT_NAME = "lldb-gtest"; @@ -10301,8 +10852,6 @@ "$(inherited)", ); LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; @@ -10327,7 +10876,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -10347,7 +10895,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -10388,8 +10935,6 @@ "$(inherited)", ); LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; @@ -10414,7 +10959,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -10434,7 +10978,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -10447,6 +10990,212 @@ }; name = Release; }; + 26792610211CA3AD00EE1D10 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CURRENT_PROJECT_VERSION = 360.99.0; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "$(PROJECT_DIR)/tools/lldb-vscode/lldb-vscode-Info.plist", + "-Wl,-rpath,@loader_path/", + "-filelist", + "$(LLVM_BUILD_DIR)/archives.txt", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/Target/ARM"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 26792611211CA3AD00EE1D10 /* DebugClang */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CURRENT_PROJECT_VERSION = 360.99.0; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "$(PROJECT_DIR)/tools/lldb-vscode/lldb-vscode-Info.plist", + "-Wl,-rpath,@loader_path/", + "-filelist", + "$(LLVM_BUILD_DIR)/archives.txt", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/Target/ARM"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = DebugClang; + }; + 26792612211CA3AD00EE1D10 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CURRENT_PROJECT_VERSION = 360.99.0; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ( + "-sectcreate", + __TEXT, + __info_plist, + "$(PROJECT_DIR)/tools/lldb-vscode/lldb-vscode-Info.plist", + "-Wl,-rpath,@loader_path/", + "-filelist", + "$(LLVM_BUILD_DIR)/archives.txt", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/Target/ARM"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; + 26792613211CA3AD00EE1D10 /* BuildAndIntegration */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 360.99.0; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; + MTL_ENABLE_DEBUG_INFO = NO; + "OTHER_LDFLAGS[sdk=iphoneos*]" = ( + "-sectcreate", + __TEXT, + __info_plist, + "$(PROJECT_DIR)/tools/lldb-vscode/lldb-vscode-Info.plist", + "-Wl,-rpath,@loader_path/../../../System/Library/PrivateFrameworks", + "-filelist", + "$(LLVM_BUILD_DIR)/archives.txt", + ); + "OTHER_LDFLAGS[sdk=macosx*]" = ( + "-sectcreate", + __TEXT, + __info_plist, + "$(PROJECT_DIR)/tools/lldb-vscode/lldb-vscode-Info.plist", + "-Wl,-rpath,@loader_path/../../Library/PrivateFrameworks/", + "-Wl,-rpath,@loader_path/../../../SharedFrameworks", + "-Wl,-rpath,@loader_path/../../System/Library/PrivateFrameworks", + "-Wl,-rpath,@loader_path/../../Library/PrivateFrameworks", + "-filelist", + "$(LLVM_BUILD_DIR)/archives.txt", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + STRIP_INSTALLED_PRODUCT = YES; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/lib/Target/ARM"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = BuildAndIntegration; + }; 2687EAC71508110B00DD8C2E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -10493,13 +11242,12 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 360.0.0; + CURRENT_PROJECT_VERSION = 360.99.0; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; }; name = BuildAndIntegration; }; @@ -10519,8 +11267,6 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = /usr/include/libxml2; LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; MACH_O_TYPE = staticlib; OTHER_CFLAGS = ( "$(inherited)", @@ -10570,8 +11316,6 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = /usr/include/libxml2; LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; MACH_O_TYPE = staticlib; OTHER_CFLAGS = ( "$(inherited)", @@ -10621,8 +11365,6 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = /usr/include/libxml2; LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; MACH_O_TYPE = staticlib; OTHER_CFLAGS = ( "$(inherited)", @@ -10732,14 +11474,12 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(LLVM_BUILD_DIR)"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/../llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/../swift"; LLDB_TOOLS_INSTALL_DIR = "/$(DT_VARIANT)/Applications/Xcode.app/Contents/Developer/usr/bin"; "LLDB_TOOLS_INSTALL_DIR[sdk=iphoneos*]" = "/$(DT_VARIANT)/usr/local/bin"; LLDB_USE_OSS_VERSION_SCHEME = 0; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLVM_BUILD_DIRTREE)/$(LLVM_CONFIGURATION)"; LLVM_BUILD_DIRTREE = "$(OBJROOT)/llvm-build"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; @@ -10752,7 +11492,6 @@ "-fno-rtti", "-flimit-debug-info", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", "-DLLDB_BUILD_DATE=\"$(LLDB_BUILD_DATE)\"", @@ -10760,7 +11499,6 @@ "-DNDEBUG", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PYTHON_FRAMEWORK_PATH = "$(SDKROOT)/System/Library/Frameworks/Python.framework"; @@ -10854,8 +11592,6 @@ "$(inherited)", ); LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; @@ -10880,7 +11616,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -10900,7 +11635,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -11200,7 +11934,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -11218,7 +11951,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -11288,7 +12020,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -11306,7 +12037,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -11372,7 +12102,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -11390,7 +12119,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -11741,13 +12469,11 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(LLVM_BUILD_DIR)"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/swift"; LLDB_TOOLS_INSTALL_DIR = /usr/bin; LLDB_USE_OSS_VERSION_SCHEME = 1; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLVM_BUILD_DIRTREE)/$(LLVM_CONFIGURATION)"; LLVM_BUILD_DIRTREE = "$(SRCROOT)/llvm-build"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; @@ -11761,14 +12487,12 @@ "-fno-rtti", "-flimit-debug-info", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", "-DLLDB_BUILD_DATE=\"$(LLDB_BUILD_DATE)\"", "$(LLDB_VERSION_SCHEME_CFLAGS)", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PYTHON_FRAMEWORK_PATH = "$(SDKROOT)/System/Library/Frameworks/Python.framework"; @@ -11870,8 +12594,6 @@ "$(inherited)", ); LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; @@ -11896,7 +12618,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -11916,7 +12637,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -11957,8 +12677,6 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = /usr/include/libxml2; LLDB_COMPRESSION_LDFLAGS = "-lcompression"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; MACH_O_TYPE = staticlib; OTHER_CFLAGS = ( "$(inherited)", @@ -12050,7 +12768,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -12068,7 +12785,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -12132,12 +12848,11 @@ "$(LLDB_PATH_TO_LLVM_SOURCE)/tools/clang/include", "$(LLDB_PATH_TO_LLVM_BUILD)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -12173,12 +12888,11 @@ "$(LLDB_PATH_TO_LLVM_SOURCE)/tools/clang/include", "$(LLDB_PATH_TO_LLVM_BUILD)/tools/clang/include", ); - LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -DYAML2OBJ=\"\\\"$(LLDB_PATH_TO_LLVM_BUILD)/x86_64/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; + LLDB_GTESTS_CFLAGS = "-I unittests -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googlemock/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/utils/unittest/googletest/include -I $(LLDB_PATH_TO_LLVM_SOURCE)/include -I $(LLDB_PATH_TO_LLVM_BUILD)/x86_64/include -I $(LLDB_PATH_TO_SWIFT_SOURCE)/include -I $(LLDB_PATH_TO_SWIFT_BUILD)/include -DYAML2OBJ=\"\\\"$(LLVM_BUILD_DIR)/bin/yaml2obj\\\"\" -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers"; LLDB_GTESTS_LDFLAGS = "$(LLDB_PATH_TO_LLVM_BUILD)/lib/libgtest.a -L $(PYTHON_FRAMEWORK_PATH)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib -l python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)"; OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GTESTS_CFLAGS)", "-DGTEST_HAS_RTTI=0", ); @@ -12430,13 +13144,11 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(LLVM_BUILD_DIR)"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/../llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/../swift"; LLDB_TOOLS_INSTALL_DIR = /usr/bin; LLDB_USE_OSS_VERSION_SCHEME = 1; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLVM_BUILD_DIRTREE)/$(LLVM_CONFIGURATION)"; LLVM_BUILD_DIRTREE = "$(SRCROOT)/llvm-build"; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; @@ -12450,7 +13162,6 @@ "-fno-rtti", "-flimit-debug-info", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_COVERAGE_CFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", @@ -12458,7 +13169,6 @@ "$(LLDB_VERSION_SCHEME_CFLAGS)", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); PYTHON_FRAMEWORK_PATH = "$(SDKROOT)/System/Library/Frameworks/Python.framework"; @@ -12568,6 +13278,9 @@ "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=watchos*]" = "llvm-watchos-x86_64/"; + HEADER_SEARCH_PATHS = /usr/include/libxml2; + LLDB_COMPRESSION_LDFLAGS = "-lcompression"; + MACH_O_TYPE = staticlib; OTHER_CPLUSPLUSFLAGS = ( "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", "-fno-rtti", @@ -12587,7 +13300,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -12607,7 +13319,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -12742,7 +13453,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COVERAGE_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -12761,7 +13471,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -12787,6 +13496,34 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", + __STDC_CONSTANT_MACROS, + __STDC_LIMIT_MACROS, + LLDB_CONFIGURATION_BUILD_AND_INTEGRATION, + "LLDB_VERSION_STRING=lldb-${CURRENT_PROJECT_VERSION}", + ); + "GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*][arch=*]" = ( + __STDC_CONSTANT_MACROS, + __STDC_LIMIT_MACROS, + LLDB_CONFIGURATION_BUILD_AND_INTEGRATION, + LLDB_DISABLE_PYTHON, + NO_XPC_SERVICES, + "LLDB_VERSION_STRING=lldb-${CURRENT_PROJECT_VERSION}", + ); + HEADER_SEARCH_PATHS = /usr/include/libxml2; + LLDB_COMPRESSION_LDFLAGS = "-lcompression"; + MACH_O_TYPE = staticlib; + OTHER_CPLUSPLUSFLAGS = ( + "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", + "-fno-rtti", + "-Wglobal-constructors", + "$(OTHER_CFLAGS)", + "-DLIBXML2_DEFINED", + ); + "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = ( + "-fno-rtti", + "-Wglobal-constructors", + "$(OTHER_CFLAGS)", + "-DLIBXML2_DEFINED", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -12839,8 +13576,6 @@ "LLDB_FRAMEWORK_INSTALL_DIR[sdk=iphoneos*]" = /System/Library/PrivateFrameworks; LLDB_TOOLS_INSTALL_DIR = /Applications/Xcode.app/Contents/Developer/usr/bin; "LLDB_TOOLS_INSTALL_DIR[sdk=iphoneos*]" = /usr/local/bin; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(OBJROOT)/llvm"; LLVM_BUILD_DIRTREE = "$(OBJROOT)/llvm-build"; LLVM_BUILD_DIR_ARCH = x86_64/; @@ -12848,18 +13583,17 @@ LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; OTHER_CFLAGS = ( "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_COVERAGE_CFLAGS)", "-Wimplicit-fallthrough", "-DNDEBUG", ); OTHER_LDFLAGS = ( - "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", + "-lcompression", "$(LLDB_COVERAGE_LDFLAGS)", ); PRODUCT_NAME = "$(TARGET_NAME)"; - PYTHON_FRAMEWORK_PATH = /System/Library/Frameworks/Python.framework; + "OTHER_LDFLAGS[sdk=macosx*]" = ""; + PYTHON_FRAMEWORK_PATH = /System/Library/Frameworks/Python.framework/; PYTHON_VERSION_MAJOR = 2; PYTHON_VERSION_MINOR = 7; REPL_SWIFT_RPATH = "@executable_path/../../../../../Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx @executable_path/../../../../../../usr/lib/swift/macosx @executable_path/../../../../../../../usr/lib/swift/macosx @executable_path/LLDB.framework/Resources/Swift/macosx @executable_path/Swift/macosx"; @@ -12901,13 +13635,41 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; MTL_ENABLE_DEBUG_INFO = YES; - OTHER_LDFLAGS = ( + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_CFLAGS = ( + "-Wparentheses", + "$(LLDB_COVERAGE_CFLAGS)", + "-Wimplicit-fallthrough", + "-fno-rtti", + "-fno-exceptions", + "-DNDEBUG", + ); + "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "$(inherited)", "-sectcreate", __TEXT, __info_plist, - "$(PROJECT_DIR)/tools/lldb-mi/lldb-Info.plist", - "-Wl,-rpath,@loader_path/", + "$(PROJECT_DIR)/tools/driver/lldb-Info.plist", + "-Wl,-rpath,@loader_path/../../../System/Library/PrivateFrameworks", + "-L$(LLVM_BUILD_DIR)/lib", + "-lLLVMOption", + "-lLLVMSupport", + "-lLLVMDemangle", + ); + "OTHER_LDFLAGS[sdk=macosx*]" = ( + "$(inherited)", + "-sectcreate", + __TEXT, + __info_plist, + "-L$(LLVM_BUILD_DIR)/lib", + "-lLLVMOption", + "-lLLVMSupport", + "-lLLVMDemangle", + "$(PROJECT_DIR)/tools/driver/lldb-Info.plist", + "-Wl,-rpath,@loader_path/../../Library/PrivateFrameworks", + "-Wl,-rpath,@loader_path/../../../SharedFrameworks", + "-Wl,-rpath,@loader_path/../../System/Library/PrivateFrameworks", + "-Wl,-rpath,@loader_path/../../Library/PrivateFrameworks", ); PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = YES; @@ -12946,12 +13708,12 @@ MTL_ENABLE_DEBUG_INFO = YES; OTHER_CFLAGS = ( "$(inherited)", - "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", "-flimit-debug-info", "-Wparentheses", ); - "OTHER_CFLAGS[sdk=iphoneos*]" = ( - "$(inherited)", + LLDB_COMPRESSION_LDFLAGS = "-lcompression"; + OTHER_CPLUSPLUSFLAGS = ( + "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", "-flimit-debug-info", "-Wparentheses", ); @@ -13401,13 +14163,11 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/llvm-macosx-x86_64"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/../llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/../swift"; LLDB_TOOLS_INSTALL_DIR = "$(LLDB_TOOLCHAIN_PREFIX)/usr/bin"; LLDB_USE_OSS_VERSION_SCHEME = 1; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLDB_PATH_TO_LLVM_BUILD)"; LLVM_BUILD_DIRTREE = "$(PREBUILT_SWIFTLANG)/.."; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; @@ -13422,14 +14182,12 @@ "-fno-rtti", "-flimit-debug-info", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", "-DLLDB_BUILD_DATE=\"$(LLDB_BUILD_DATE)\"", "$(LLDB_VERSION_SCHEME_CFLAGS)", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( @@ -13567,7 +14325,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -13587,7 +14344,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -13714,7 +14470,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -13732,7 +14487,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -13835,6 +14589,14 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; MTL_ENABLE_DEBUG_INFO = YES; + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_CFLAGS = ( + "-Wparentheses", + "$(LLDB_COVERAGE_CFLAGS)", + "-Wimplicit-fallthrough", + "-fno-rtti", + "-fno-exceptions", + ); OTHER_LDFLAGS = ( "$(inherited)", "-filelist", @@ -13842,9 +14604,12 @@ "-sectcreate", __TEXT, __info_plist, - "$(PROJECT_DIR)/tools/lldb-mi/lldb-Info.plist", - "-Wl,-rpath,@loader_path/", - "-Wl,-rpath,@loader_path/../../System/Library/PrivateFrameworks", + "$(PROJECT_DIR)/tools/driver/lldb-Info.plist", + "-Wl,-rpath,@loader_path", + "-L$(LLVM_BUILD_DIR)/lib", + "-lLLVMOption", + "-lLLVMSupport", + "-lLLVMDemangle", ); PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -13886,6 +14651,10 @@ "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", "-flimit-debug-info", "-Wparentheses", + "$(LLDB_COVERAGE_CFLAGS)", + "-Wimplicit-fallthrough", + "-fno-rtti", + "-fno-exceptions", ); "OTHER_CFLAGS[sdk=iphoneos*]" = ( "$(inherited)", @@ -13894,8 +14663,6 @@ ); "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = "$(OTHER_CFLAGS)"; OTHER_LDFLAGS = ( - "-filelist", - "$(LLDB_PATH_TO_LLVM_BUILD)/archives.txt", "-L/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config", "-lpython2.7", "-lxml2", @@ -13907,6 +14674,10 @@ Carbon, "-framework", Security, + "-L$(LLVM_BUILD_DIR)/lib", + "-lLLVMOption", + "-lLLVMSupport", + "-lLLVMDemangle", ); "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( "-filelist", @@ -14004,13 +14775,11 @@ LLDB_PATH_TO_CMARK_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/cmark-macosx-x86_64"; LLDB_PATH_TO_LLVM_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/llvm-macosx-x86_64"; LLDB_PATH_TO_LLVM_SOURCE = "$(PROJECT_DIR)/../llvm"; - LLDB_PATH_TO_SWIFT_BUILD = "$(PROJECT_DIR)/../build/Ninja-$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; + LLDB_PATH_TO_SWIFT_BUILD = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)/swift-macosx-x86_64"; LLDB_PATH_TO_SWIFT_SOURCE = "$(PROJECT_DIR)/../swift"; LLDB_TOOLS_INSTALL_DIR = "$(LLDB_TOOLCHAIN_PREFIX)/usr/bin"; LLDB_USE_OSS_VERSION_SCHEME = 1; LLDB_VERSION_SCHEME_CFLAGS = "$(LLDB_DEFINES_FOR_USE_OSS_VERSION_SCHEME_$(LLDB_USE_OSS_VERSION_SCHEME))"; - LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1"; - LLDB_ZLIB_LDFLAGS = "-lz"; LLVM_BUILD_DIR = "$(LLDB_PATH_TO_LLVM_BUILD)"; LLVM_BUILD_DIRTREE = "$(PREBUILT_SWIFTLANG)/.."; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; @@ -14024,7 +14793,6 @@ OTHER_CFLAGS = ( "-fno-rtti", "-Wparentheses", - "$(LLDB_ZLIB_CFLAGS)", "$(LLDB_COVERAGE_LDFLAGS)", "$(LLDB_GUI_CFLAGS)", "$(LLDB_BUILDBOT_BUILD_CFLAGS)", @@ -14033,7 +14801,7 @@ "-Wimplicit-fallthrough", ); OTHER_LDFLAGS = ( - "$(LLDB_ZLIB_LDFLAGS)", + "-lcompression", "$(LLDB_COMPRESSION_LDFLAGS)", ); PYTHON_FRAMEWORK_PATH = "$(SDKROOT)/System/Library/Frameworks/Python.framework"; @@ -14091,6 +14859,13 @@ INFOPLIST_FILE = "tools/driver/lldb-Info.plist"; INSTALL_PATH = "$(LLDB_TOOLS_INSTALL_DIR)"; LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_CFLAGS = ( + "-Wparentheses", + "$(LLDB_COVERAGE_CFLAGS)", + "-Wimplicit-fallthrough", + "-fno-rtti", + "-fno-exceptions", + ); OTHER_LDFLAGS = ( "$(inherited)", "-sectcreate", @@ -14099,8 +14874,10 @@ "$(PROJECT_DIR)/tools/driver/lldb-Info.plist", "-Wl,-rpath,@loader_path", "-Wl,-rpath,@loader_path/../../System/Library/PrivateFrameworks", - "-filelist", - "$(LLVM_BUILD_DIR)/archives.txt", + "-L$(LLVM_BUILD_DIR)/lib", + "-lLLVMOption", + "-lLLVMSupport", + "-lLLVMDemangle", ); PRODUCT_NAME = lldb; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(LLDB_PATH_TO_LLVM_SOURCE)/include $(LLDB_PATH_TO_CLANG_SOURCE)/include $(LLDB_PATH_TO_SWIFT_SOURCE)/include $(LLDB_PATH_TO_LLVM_BUILD)/include $(LLDB_PATH_TO_LLVM_BUILD)/tools/clang/include $(LLDB_PATH_TO_SWIFT_BUILD)/include $(SRCROOT)/source"; @@ -14132,12 +14909,16 @@ INSTALL_PATH = "$(LLDB_FRAMEWORK_INSTALL_DIR)"; LD_DYLIB_INSTALL_NAME = "@rpath/LLDB.framework/LLDB"; LIBRARY_SEARCH_PATHS = "$(LLDB_PATH_TO_LLVM_BUILD)"; - LLDB_COMPRESSION_LDFLAGS = "-lcompression"; LLDB_TOOLS_INSTALL_DIR = ""; LLVM_BUILD_DIR_ARCH = "llvm-macosx-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=appletvos*]" = "llvm-appletvos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=iphoneos*]" = "llvm-iphoneos-x86_64/"; "LLVM_BUILD_DIR_ARCH[sdk=watchos*]" = "llvm-watchos-x86_64/"; + LIBRARY_SEARCH_PATHS = ( + "$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)", + "$(inherited)", + ); + LLDB_COMPRESSION_LDFLAGS = "-lcompression"; OTHER_CPLUSPLUSFLAGS = ( "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7", "-fno-rtti", @@ -14158,7 +14939,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( @@ -14178,7 +14958,6 @@ "-framework", ApplicationServices, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = LLDB; @@ -14309,7 +15088,6 @@ "-framework", Foundation, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "$(inherited)", @@ -14327,7 +15105,6 @@ "-framework", Security, "$(LLDB_COMPRESSION_LDFLAGS)", - "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_GUI_LDFLAGS)", ); PRODUCT_NAME = "lldb-server"; @@ -14552,6 +15329,34 @@ }; name = "CustomSwift-Release"; }; + AF213BB82193751500A9BB37 /* BuildAndIntegration */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "lldb-gtest"; + }; + name = BuildAndIntegration; + }; + AF213BB92193751500A9BB37 /* DebugPresubmission */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "lldb-vscode"; + }; + name = DebugPresubmission; + }; + AF213BBA2193751500A9BB37 /* CustomSwift-Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "lldb-vscode"; + }; + name = "CustomSwift-Debug"; + }; + AF213BBB2193751500A9BB37 /* CustomSwift-Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "lldb-vscode"; + }; + name = "CustomSwift-Release"; + }; AF6967891B4609A80014D221 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -14735,6 +15540,38 @@ }; name = BuildAndIntegration; }; + DD8DC26C22026E2C00EB6F9E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + DD8DC26D22026E2C00EB6F9E /* DebugClang */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = DebugClang; + }; + DD8DC26E22026E2C00EB6F9E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + DD8DC26F22026E2C00EB6F9E /* BuildAndIntegration */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = BuildAndIntegration; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -14774,11 +15611,12 @@ 239504D81BDD451400963CEA /* Debug */, 239504D91BDD451400963CEA /* DebugClang */, 239504DA1BDD451400963CEA /* Release */, - 239504DB1BDD451400963CEA /* BuildAndIntegration */, + 239504DB1BDD451400963CEA /* Release */, 49CE1A521BDFDDEB00953D79 /* DebugPresubmission */, 49CE1A531BDFDDEB00953D79 /* CustomSwift-Debug */, 49CE1A541BDFDDEB00953D79 /* CustomSwift-Release */, 237965FB1C12369B008D490F /* CustomSwift-RelWithDebInfo */, + AF213BB82193751500A9BB37 /* BuildAndIntegration */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = BuildAndIntegration; @@ -14828,6 +15666,20 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = BuildAndIntegration; }; + 26792614211CA3AD00EE1D10 /* Build configuration list for PBXNativeTarget "lldb-vscode" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 26792610211CA3AD00EE1D10 /* Debug */, + 26792611211CA3AD00EE1D10 /* DebugClang */, + 26792612211CA3AD00EE1D10 /* Release */, + 26792613211CA3AD00EE1D10 /* BuildAndIntegration */, + AF213BB92193751500A9BB37 /* DebugPresubmission */, + AF213BBA2193751500A9BB37 /* CustomSwift-Debug */, + AF213BBB2193751500A9BB37 /* CustomSwift-Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = BuildAndIntegration; + }; 2687EAC61508110B00DD8C2E /* Build configuration list for PBXLegacyTarget "install-headers" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -15053,6 +15905,17 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = BuildAndIntegration; }; + DD8DC27022026E2C00EB6F9E /* Build configuration list for PBXAggregateTarget "lldb-docs" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DD8DC26C22026E2C00EB6F9E /* Debug */, + DD8DC26D22026E2C00EB6F9E /* DebugClang */, + DD8DC26E22026E2C00EB6F9E /* Release */, + DD8DC26F22026E2C00EB6F9E /* BuildAndIntegration */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = BuildAndIntegration; + }; /* End XCConfigurationList section */ }; rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; diff --git a/lldb.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/lldb.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/lldb.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme b/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme index 82a97dfbe24f..881829e27feb 100644 --- a/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme +++ b/lldb.xcodeproj/xcshareddata/xcschemes/LLDB.xcscheme @@ -54,7 +54,6 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" displayScaleIsEnabled = "NO" displayScale = "1.00" - enableThreadSanitizer = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme b/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme index 352ef7194155..74864b2078d8 100644 --- a/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme +++ b/lldb.xcodeproj/xcshareddata/xcschemes/darwin-debug.xcscheme @@ -45,7 +45,6 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" displayScaleIsEnabled = "NO" displayScale = "1.00" - enableThreadSanitizer = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/lldb.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/lldb.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/lldb.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/Python/lldbsuite/support/encoded_file.py b/packages/Python/lldbsuite/support/encoded_file.py index f75873459570..c8ed2df72b15 100644 --- a/packages/Python/lldbsuite/support/encoded_file.py +++ b/packages/Python/lldbsuite/support/encoded_file.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Prepares language bindings for LLDB build process. Run with --help to see a description of the supported command line arguments. @@ -32,13 +31,7 @@ def impl(s): # If we were asked to write a `str` (in Py2) or a `bytes` (in Py3) decode it # as unicode before attempting to write. if isinstance(s, six.binary_type): - try: - s = s.decode(encoding) - except UnicodeError as err: - sys.stderr.write( - "attempted to write non-unicode-conformant byte " - "string '{}', ignoring decode step: {}\n".format(s, err)) - s = u"" + s = s.decode(encoding, "replace") return old_write(s) return impl diff --git a/packages/Python/lldbsuite/support/fs.py b/packages/Python/lldbsuite/support/fs.py index 30388596ea16..71394f03ac30 100644 --- a/packages/Python/lldbsuite/support/fs.py +++ b/packages/Python/lldbsuite/support/fs.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Prepares language bindings for LLDB build process. Run with --help to see a description of the supported command line arguments. diff --git a/packages/Python/lldbsuite/support/seven.py b/packages/Python/lldbsuite/support/seven.py index e04f48308b7d..c83047896fbd 100644 --- a/packages/Python/lldbsuite/support/seven.py +++ b/packages/Python/lldbsuite/support/seven.py @@ -15,7 +15,7 @@ def get_command_status_output(command): subprocess.check_output( command, shell=True, - universal_newlines=True)) + universal_newlines=True).rstrip()) except subprocess.CalledProcessError as e: return (e.returncode, e.output) diff --git a/packages/Python/lldbsuite/support/sockutil.py b/packages/Python/lldbsuite/support/sockutil.py index 789deed8017a..56a9ed8bd79d 100644 --- a/packages/Python/lldbsuite/support/sockutil.py +++ b/packages/Python/lldbsuite/support/sockutil.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Helper functions for working with sockets. """ diff --git a/packages/Python/lldbsuite/test/README-TestSuite b/packages/Python/lldbsuite/test/README-TestSuite index 92649fc9963c..8ea64c0aa3d5 100644 --- a/packages/Python/lldbsuite/test/README-TestSuite +++ b/packages/Python/lldbsuite/test/README-TestSuite @@ -1,7 +1,7 @@ -This README file describes the files and directories related to the Python test -suite under the current 'test' directory. +This README file describes the files and directories related -*- rst -*- +to the Python test suite under the current 'test' directory. -o dotest.py +- dotest.py Provides the test driver for the test suite. To invoke it, cd to the 'test' directory and issue the './dotest.py' command or './dotest.py -v' for more @@ -20,7 +20,7 @@ o dotest.py This runs the test suite, with logging turned on for the lldb as well as the process.gdb-remote channels and directs the run log to a file. -o lldbtest.py +- lldbtest.py Provides an abstract base class of lldb test case named 'TestBase', which in turn inherits from Python's unittest.TestCase. The concrete subclass can @@ -41,7 +41,7 @@ o lldbtest.py test case on its own. To run the whole test suite, 'dotest.py' is all you need to do. -o subdirectories of 'test' +- subdirectories of 'test' Most of them predate the introduction of the python test suite and contain example C/C++/ObjC source files which get compiled into executables which are @@ -58,7 +58,7 @@ o subdirectories of 'test' testcase that run a process to a breakpoint and check a local variable. These are convenient starting points for adding new tests. -o make directory +- make directory Contains Makefile.rules, which can be utilized by test cases to write Makefile based rules to build binaries for the inferiors. @@ -95,12 +95,12 @@ o make directory The exe names for the two test methods are equal to the test method names and are therefore guaranteed different. -o plugins directory +- plugins directory Contains platform specific plugin to build binaries with dsym/dwarf debugging info. Other platform specific functionalities may be added in the future. -o unittest2 directory +- unittest2 directory Many new features were added to unittest in Python 2.7, including test discovery. unittest2 allows you to use these features with earlier versions of @@ -114,7 +114,7 @@ o unittest2 directory Later versions of unittest2 include changes in unittest made in Python 3.2 and onwards after the release of Python 2.7. -o dotest.pl +- dotest.pl In case you wonder, there is also a 'dotest.pl' perl script file. It was created to visit each Python test case under the specified directory and @@ -127,47 +127,56 @@ o dotest.pl Note: dotest.pl has been moved to the attic directory. -o Profiling dotest.py runs +- Profiling dotest.py runs I used the following command line thingy to do the profiling on a SnowLeopard machine: -$ DOTEST_PROFILE=YES DOTEST_SCRIPT_DIR=/Volumes/data/lldb/svn/trunk/test /System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/cProfile.py -o my.profile ./dotest.py -v -w 2> ~/Developer/Log/lldbtest.log + $ DOTEST_PROFILE=YES DOTEST_SCRIPT_DIR=/Volumes/data/lldb/svn/trunk/test /System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/cProfile.py -o my.profile ./dotest.py -v -w 2> ~/Developer/Log/lldbtest.log After that, I used the pstats.py module to browse the statistics: -$ python /System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/pstats.py my.profile - -o Writing test cases: - - We strongly prefer writing test cases using the SB API's rather than the runCmd & expect. - Unless you are actually testing some feature of the command line, please don't write - command based tests. For historical reasons there are plenty of examples of tests in the - test suite that use runCmd where they shouldn't, but don't copy them, copy the plenty that - do use the SB API's instead. - - The reason for this is that our policy is that we will maintain compatibility with the - SB API's. But we don't make any similar guarantee about the details of command result format. - If your test is using the command line, it is going to have to check against the command result - text, and you either end up writing your check pattern by checking as little as possible so - you won't be exposed to random changes in the text; in which case you can end up missing some - failure, or you test too much and it means irrelevant changes break your tests. - - However, if you use the Python API's it is possible to check all the results you want - to check in a very explicit way, which makes the tests much more robust. - - Even if you are testing that a command-line command does some specific thing, it is still - better in general to use the SB API's to drive to the point where you want to run the test, - then use SBInterpreter::HandleCommand to run the command. You get the full result text - from the command in the command return object, and all the part where you are driving the - debugger to the point you want to test will be more robust. - - The sample_test directory contains a standard and an "inline" test that are good starting - points for writing a new test. - -o Attaching in test cases: - - If you need to attach to inferiors in your tests, you must make sure the inferior calls - lldb_enable_attach(), before the debugger attempts to attach. This function performs any - platform-specific processing needed to enable attaching to this process (e.g., on Linux, we - execute prctl(PR_SET_TRACER) syscall to disable protections present in some Linux systems). + $ python /System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/pstats.py my.profile + +- Writing test cases: + + We strongly prefer writing test cases using the SB API's rather than + the runCmd & expect. Unless you are actually testing some feature + of the command line, please don't write command based tests. For + historical reasons there are plenty of examples of tests in the test + suite that use runCmd where they shouldn't, but don't copy them, + copy the plenty that do use the SB API's instead. + + The reason for this is that our policy is that we will maintain + compatibility with the SB API's. But we don't make any similar + guarantee about the details of command result format. If your test + is using the command line, it is going to have to check against the + command result text, and you either end up writing your check + pattern by checking as little as possible so you won't be exposed to + random changes in the text; in which case you can end up missing + some failure, or you test too much and it means irrelevant changes + break your tests. + + However, if you use the Python API's it is possible to check all the + results you want to check in a very explicit way, which makes the + tests much more robust. + + Even if you are testing that a command-line command does some + specific thing, it is still better in general to use the SB API's to + drive to the point where you want to run the test, then use + SBInterpreter::HandleCommand to run the command. You get the full + result text from the command in the command return object, and all + the part where you are driving the debugger to the point you want to + test will be more robust. + + The sample_test directory contains a standard and an "inline" test + that are good starting points for writing a new test. + +- Attaching in test cases: + + If you need to attach to inferiors in your tests, you must make sure + the inferior calls lldb_enable_attach(), before the debugger + attempts to attach. This function performs any platform-specific + processing needed to enable attaching to this process (e.g., on + Linux, we execute prctl(PR_SET_TRACER) syscall to disable + protections present in some Linux systems). diff --git a/packages/Python/lldbsuite/test/android/platform/main.cpp b/packages/Python/lldbsuite/test/android/platform/main.cpp index 3fb9edc47270..e8f3fa65eb0d 100644 --- a/packages/Python/lldbsuite/test/android/platform/main.cpp +++ b/packages/Python/lldbsuite/test/android/platform/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template b/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template index ed754add6100..7fced85cd3aa 100644 --- a/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template +++ b/packages/Python/lldbsuite/test/api/check_public_api_headers/main.cpp.template @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py index e43afa5ac761..9e2489597c92 100644 --- a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py +++ b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py @@ -70,7 +70,7 @@ def test_sb_api_listener_event_process_state(self): # clang-cl does not support throw or catch (llvm.org/pr24538) @skipIfWindows @expectedFlakeyFreeBSD - @expectedFailureAll(oslist=["linux"]) + @skipIf(oslist=["linux"]) # flakey def test_sb_api_listener_resume(self): """ Test that a process can be resumed from a non-main thread. """ self.build_and_test( diff --git a/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py index f020a6538525..6540261262ad 100644 --- a/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py +++ b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py @@ -18,6 +18,7 @@ class TestBreakpointThumbCodesection(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(archs=no_match(["arm"])) + @skipIfDarwinEmbedded # codegen on darwin always defaults to thumb for armv7/armv7k targets def test_breakpoint(self): self.build() exe = self.getBuildArtifact("a.out") diff --git a/packages/Python/lldbsuite/test/benchmarks/disassembly/TestDisassembly.py b/packages/Python/lldbsuite/test/benchmarks/disassembly/TestDisassembly.py deleted file mode 100644 index 8bce4815894d..000000000000 --- a/packages/Python/lldbsuite/test/benchmarks/disassembly/TestDisassembly.py +++ /dev/null @@ -1,165 +0,0 @@ -"""Disassemble lldb's Driver::MainLoop() functions comparing lldb against gdb.""" - -from __future__ import print_function - - -import os -import sys -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbbench import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -def is_exe(fpath): - """Returns true if fpath is an executable.""" - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - - -class DisassembleDriverMainLoop(BenchBase): - - mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - """ - Note that lldbtest_config.lldbExec can be specified with the LLDB_EXEC env variable (see - dotest.py), and gdbExec can be specified with the GDB_EXEC env variable. - This provides a flexibility in specifying different versions of gdb for - comparison purposes. - """ - BenchBase.setUp(self) - # If env var GDB_EXEC is specified, use it; otherwise, use gdb in your - # PATH env var. - if "GDB_EXEC" in os.environ and is_exe(os.environ["GDB_EXEC"]): - self.gdbExec = os.environ["GDB_EXEC"] - else: - self.gdbExec = "gdb" - - self.exe = lldbtest_config.lldbExec - self.function = 'Driver::MainLoop()' - self.lldb_avg = None - self.gdb_avg = None - self.count = 5 - - @benchmarks_test - @no_debug_info_test - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - def test_run_lldb_then_gdb(self): - """Test disassembly on a large function with lldb vs. gdb.""" - print() - print("lldb path: %s" % lldbtest_config.lldbExec) - print("gdb path: %s" % self.gdbExec) - - print() - self.run_lldb_disassembly(self.exe, self.function, self.count) - print("lldb benchmark:", self.stopwatch) - self.run_gdb_disassembly(self.exe, self.function, self.count) - print("gdb benchmark:", self.stopwatch) - print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg)) - - @benchmarks_test - @no_debug_info_test - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - def test_run_gdb_then_lldb(self): - """Test disassembly on a large function with lldb vs. gdb.""" - print() - print("lldb path: %s" % lldbtest_config.lldbExec) - print("gdb path: %s" % self.gdbExec) - - print() - self.run_gdb_disassembly(self.exe, self.function, self.count) - print("gdb benchmark:", self.stopwatch) - self.run_lldb_disassembly(self.exe, self.function, self.count) - print("lldb benchmark:", self.stopwatch) - print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg)) - - def run_lldb_disassembly(self, exe, function, count): - import pexpect - # Set self.child_prompt, which is "(lldb) ". - self.child_prompt = '(lldb) ' - prompt = self.child_prompt - - # So that the child gets torn down after the test. - self.child = pexpect.spawn( - '%s %s %s' % - (lldbtest_config.lldbExec, self.lldbOption, exe)) - child = self.child - - # Turn on logging for what the child sends back. - if self.TraceOn(): - child.logfile_read = sys.stdout - - child.expect_exact(prompt) - child.sendline('breakpoint set -F %s' % function) - child.expect_exact(prompt) - child.sendline('run') - child.expect_exact(prompt) - - # Reset the stopwatch now. - self.stopwatch.reset() - for i in range(count): - with self.stopwatch: - # Disassemble the function. - child.sendline('disassemble -f') - child.expect_exact(prompt) - child.sendline('next') - child.expect_exact(prompt) - - child.sendline('quit') - try: - self.child.expect(pexpect.EOF) - except: - pass - - self.lldb_avg = self.stopwatch.avg() - if self.TraceOn(): - print("lldb disassembly benchmark:", str(self.stopwatch)) - self.child = None - - def run_gdb_disassembly(self, exe, function, count): - import pexpect - # Set self.child_prompt, which is "(gdb) ". - self.child_prompt = '(gdb) ' - prompt = self.child_prompt - - # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s --nx %s' % (self.gdbExec, exe)) - child = self.child - - # Turn on logging for what the child sends back. - if self.TraceOn(): - child.logfile_read = sys.stdout - - child.expect_exact(prompt) - child.sendline('break %s' % function) - child.expect_exact(prompt) - child.sendline('run') - child.expect_exact(prompt) - - # Reset the stopwatch now. - self.stopwatch.reset() - for i in range(count): - with self.stopwatch: - # Disassemble the function. - child.sendline('disassemble') - child.expect_exact(prompt) - child.sendline('next') - child.expect_exact(prompt) - - child.sendline('quit') - child.expect_exact('The program is running. Exit anyway?') - child.sendline('y') - try: - self.child.expect(pexpect.EOF) - except: - pass - - self.gdb_avg = self.stopwatch.avg() - if self.TraceOn(): - print("gdb disassembly benchmark:", str(self.stopwatch)) - self.child = None diff --git a/packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py b/packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py deleted file mode 100644 index 36f23572648d..000000000000 --- a/packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py +++ /dev/null @@ -1,70 +0,0 @@ -"""Test lldb's disassemblt speed. This bench deliberately attaches to an lldb -inferior and traverses the stack for thread0 to arrive at frame with function -'MainLoop'. It is important to specify an lldb executable as the inferior.""" - -from __future__ import print_function - - -import os -import sys -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbbench import * -from lldbsuite.test.lldbtest import * - - -class AttachThenDisassemblyBench(BenchBase): - - mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - BenchBase.setUp(self) - self.exe = lldbtest_config.lldbExec - self.count = 10 - - @benchmarks_test - @no_debug_info_test - def test_attach_then_disassembly(self): - """Attach to a spawned lldb process then run disassembly benchmarks.""" - print() - self.run_lldb_attach_then_disassembly(self.exe, self.count) - print("lldb disassembly benchmark:", self.stopwatch) - - def run_lldb_attach_then_disassembly(self, exe, count): - target = self.dbg.CreateTarget(exe) - - # Spawn a new process and don't display the stdout if not in TraceOn() - # mode. - import subprocess - popen = subprocess.Popen([exe, self.lldbOption], stdout=open( - os.devnull, 'w') if not self.TraceOn() else None) - if self.TraceOn(): - print("pid of spawned process: %d" % popen.pid) - - # Attach to the launched lldb process. - listener = lldb.SBListener("my.attach.listener") - error = lldb.SBError() - process = target.AttachToProcessWithID(listener, popen.pid, error) - - # Set thread0 as the selected thread, followed by the 'MainLoop' frame - # as the selected frame. Then do disassembly on the function. - thread0 = process.GetThreadAtIndex(0) - process.SetSelectedThread(thread0) - i = 0 - found = False - for f in thread0: - # print("frame#%d %s" % (i, f.GetFunctionName())) - if "MainLoop" in f.GetFunctionName(): - found = True - thread0.SetSelectedFrame(i) - if self.TraceOn(): - print("Found frame#%d for function 'MainLoop'" % i) - break - i += 1 - - # Reset the stopwatch now. - self.stopwatch.reset() - for i in range(count): - with self.stopwatch: - # Disassemble the function. - self.runCmd("disassemble -f") diff --git a/packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py b/packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py deleted file mode 100644 index fd91bb441d9f..000000000000 --- a/packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py +++ /dev/null @@ -1,120 +0,0 @@ -"""Disassemble lldb's Driver::MainLoop() functions comparing Xcode 4.1 vs. 4.2's gdb.""" - -from __future__ import print_function - - -import os -import sys -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbbench import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import configuration -from lldbsuite.test import lldbutil - - -class XCode41Vs42GDBDisassembly(BenchBase): - - mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - BenchBase.setUp(self) - self.gdb_41_exe = '/Xcode41/usr/bin/gdb' - self.gdb_42_exe = '/Developer/usr/bin/gdb' - self.exe = lldbtest_config.lldbExec - self.function = 'Driver::MainLoop()' - self.gdb_41_avg = None - self.gdb_42_avg = None - self.count = 5 - - @benchmarks_test - @no_debug_info_test - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - def test_run_41_then_42(self): - """Test disassembly on a large function with 4.1 vs. 4.2's gdb.""" - print() - self.run_gdb_disassembly( - self.gdb_41_exe, - self.exe, - self.function, - self.count) - print("4.1 gdb benchmark:", self.stopwatch) - self.gdb_41_avg = self.stopwatch.avg() - self.run_gdb_disassembly( - self.gdb_42_exe, - self.exe, - self.function, - self.count) - print("4.2 gdb benchmark:", self.stopwatch) - self.gdb_42_avg = self.stopwatch.avg() - print("gdb_42_avg/gdb_41_avg: %f" % - (self.gdb_42_avg / self.gdb_41_avg)) - - @benchmarks_test - @no_debug_info_test - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - def test_run_42_then_41(self): - """Test disassembly on a large function with 4.1 vs. 4.2's gdb.""" - print() - self.run_gdb_disassembly( - self.gdb_42_exe, - self.exe, - self.function, - self.count) - print("4.2 gdb benchmark:", self.stopwatch) - self.gdb_42_avg = self.stopwatch.avg() - self.run_gdb_disassembly( - self.gdb_41_exe, - self.exe, - self.function, - self.count) - print("4.1 gdb benchmark:", self.stopwatch) - self.gdb_41_avg = self.stopwatch.avg() - print("gdb_42_avg/gdb_41_avg: %f" % - (self.gdb_42_avg / self.gdb_41_avg)) - - def run_gdb_disassembly(self, gdb_exe_path, exe, function, count): - import pexpect - # Set self.child_prompt, which is "(gdb) ". - self.child_prompt = '(gdb) ' - prompt = self.child_prompt - - # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s --nx %s' % (gdb_exe_path, exe)) - child = self.child - - # Turn on logging for what the child sends back. - if self.TraceOn(): - child.logfile_read = sys.stdout - - child.expect_exact(prompt) - child.sendline('break %s' % function) - child.expect_exact(prompt) - child.sendline('run') - child.expect_exact(prompt) - - # Reset the stopwatch now. - self.stopwatch.reset() - for i in range(count): - with self.stopwatch: - # Disassemble the function. - child.sendline('disassemble') - child.expect_exact(prompt) - child.sendline('next') - child.expect_exact(prompt) - - child.sendline('quit') - child.expect_exact('The program is running. Exit anyway?') - child.sendline('y') - try: - self.child.expect(pexpect.EOF) - except: - pass - - if self.TraceOn(): - print("gdb disassembly benchmark:", str(self.stopwatch)) - self.child = None diff --git a/packages/Python/lldbsuite/test/benchmarks/expression/main.cpp b/packages/Python/lldbsuite/test/benchmarks/expression/main.cpp index 8f2706e26388..4083a6808658 100644 --- a/packages/Python/lldbsuite/test/benchmarks/expression/main.cpp +++ b/packages/Python/lldbsuite/test/benchmarks/expression/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/configuration.py b/packages/Python/lldbsuite/test/configuration.py index 0a4654a56f13..684152f81a1e 100644 --- a/packages/Python/lldbsuite/test/configuration.py +++ b/packages/Python/lldbsuite/test/configuration.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides the configuration class, which holds all information related to how this invocation of the test suite should be run. @@ -193,5 +192,5 @@ def get_filecheck_path(): """ Get the path to the FileCheck testing tool. """ - if os.path.lexists(filecheck): + if filecheck and os.path.lexists(filecheck): return filecheck diff --git a/packages/Python/lldbsuite/test/decorators.py b/packages/Python/lldbsuite/test/decorators.py index 31575d40c0d7..73b5b4d992fb 100644 --- a/packages/Python/lldbsuite/test/decorators.py +++ b/packages/Python/lldbsuite/test/decorators.py @@ -75,13 +75,14 @@ def fn_neq(x, y): return x != y LooseVersion(expected_str)) +_re_pattern_type = type(re.compile('')) def _match_decorator_property(expected, actual): if actual is None or expected is None: return True if isinstance(expected, no_match): return not _match_decorator_property(expected.item, actual) - elif isinstance(expected, (re._pattern_type,) + six.string_types): + elif isinstance(expected, (_re_pattern_type,) + six.string_types): return re.search(expected, actual) is not None elif hasattr(expected, "__iter__"): return any([x is not None and _match_decorator_property(x, actual) @@ -162,7 +163,7 @@ def _decorateTest(mode, debug_info=None, swig_version=None, py_version=None, macos_version=None, - remote=None): + remote=None, dwarf_version=None): def fn(self): skip_for_os = _match_decorator_property( lldbplatform.translate(oslist), self.getPlatform()) @@ -193,10 +194,15 @@ def fn(self): py_version is None) or _check_expected_version( py_version[0], py_version[1], sys.version_info) skip_for_macos_version = (macos_version is None) or ( - _check_expected_version( + (platform.mac_ver()[0] != "") and (_check_expected_version( macos_version[0], macos_version[1], - platform.mac_ver()[0])) + platform.mac_ver()[0]))) + skip_for_dwarf_version = ( + dwarf_version is None) or ( + (self.getDebugInfo() is 'dwarf') and + _check_expected_version( + dwarf_version[0], dwarf_version[1], self.getDwarfVersion())) # For the test to be skipped, all specified (e.g. not None) parameters must be True. # An unspecified parameter means "any", so those are marked skip by default. And we skip @@ -210,7 +216,8 @@ def fn(self): (swig_version, skip_for_swig_version, "swig version"), (py_version, skip_for_py_version, "python version"), (macos_version, skip_for_macos_version, "macOS version"), - (remote, skip_for_remote, "platform locality (remote/local)")] + (remote, skip_for_remote, "platform locality (remote/local)"), + (dwarf_version, skip_for_dwarf_version, "dwarf version")] reasons = [] final_skip_result = True for this_condition in conditions: @@ -254,7 +261,7 @@ def expectedFailureAll(bugnumber=None, debug_info=None, swig_version=None, py_version=None, macos_version=None, - remote=None): + remote=None, dwarf_version=None): return _decorateTest(DecorateMode.Xfail, bugnumber=bugnumber, oslist=oslist, hostoslist=hostoslist, @@ -263,7 +270,7 @@ def expectedFailureAll(bugnumber=None, debug_info=debug_info, swig_version=swig_version, py_version=py_version, macos_version=None, - remote=remote) + remote=remote,dwarf_version=dwarf_version) # provide a function to skip on defined oslist, compiler version, and archs @@ -279,7 +286,7 @@ def skipIf(bugnumber=None, debug_info=None, swig_version=None, py_version=None, macos_version=None, - remote=None): + remote=None, dwarf_version=None): return _decorateTest(DecorateMode.Skip, bugnumber=bugnumber, oslist=oslist, hostoslist=hostoslist, @@ -288,7 +295,7 @@ def skipIf(bugnumber=None, debug_info=debug_info, swig_version=swig_version, py_version=py_version, macos_version=macos_version, - remote=remote) + remote=remote, dwarf_version=dwarf_version) def _skip_for_android(reason, api_levels, archs): @@ -357,7 +364,7 @@ def should_skip_simulator_test(): return "simulator tests are run only on darwin hosts" try: DEVNULL = open(os.devnull, 'w') - output = subprocess.check_output(["xcodebuild", "-showsdks"], stderr=DEVNULL) + output = subprocess.check_output(["xcodebuild", "-showsdks"], stderr=DEVNULL).decode("utf-8") if re.search('%ssimulator' % platform, output): return None else: @@ -458,12 +465,6 @@ def wrapper(*args, **kwargs): return expectedFailure_impl -def expectedFlakeyDsym(bugnumber=None): - def fn(self): - return self.getDebugInfo() == "dwarf" - return expectedFlakey(fn, bugnumber) - - def expectedFlakeyOS(oslist, bugnumber=None, compilers=None): def fn(self): return (self.getPlatform() in oslist and @@ -616,6 +617,7 @@ def is_not_swift_compatible(self): return None return skipTestIfFn(is_not_swift_compatible)(func) + def skipIfHostIncompatibleWithRemote(func): """Decorate the item to skip tests if binaries built on this host are incompatible.""" @@ -850,7 +852,7 @@ def is_feature_enabled(self): if platform.system() == 'Darwin': try: DEVNULL = open(os.devnull, 'w') - output = subprocess.check_output(["/usr/sbin/sysctl", feature], stderr=DEVNULL) + output = subprocess.check_output(["/usr/sbin/sysctl", feature], stderr=DEVNULL).decode("utf-8") # If 'feature: 1' was output, then this feature is available and # the test should not be skipped. if re.match('%s: 1\s*' % feature, output): @@ -860,3 +862,10 @@ def is_feature_enabled(self): except subprocess.CalledProcessError: return "%s is not supported on this system." % feature return skipTestIfFn(is_feature_enabled) + +def skipIfSanitized(func): + """Skip this test if the environment is set up to run LLDB itself under ASAN.""" + def is_sanitized(): + return (('DYLD_INSERT_LIBRARIES' in os.environ) and + 'libclang_rt.asan' in os.environ['DYLD_INSERT_LIBRARIES']) + return skipTestIfFn(is_sanitized)(func) diff --git a/packages/Python/lldbsuite/test/dosep.py b/packages/Python/lldbsuite/test/dosep.py index 53f8ae1ab9b5..ed8036bfa000 100644 --- a/packages/Python/lldbsuite/test/dosep.py +++ b/packages/Python/lldbsuite/test/dosep.py @@ -1701,7 +1701,7 @@ def main(num_threads, test_runner_name, results_formatter): # move core files into session dir cores = find('core.*', test_subdir) for core in cores: - dst = core.replace(test_directory, "")[1:] + dst = core.replace(test_subdir, "")[1:] dst = dst.replace(os.path.sep, "-") os.rename(core, os.path.join(session_dir, dst)) diff --git a/packages/Python/lldbsuite/test/dotest.py b/packages/Python/lldbsuite/test/dotest.py index 0df65d9046df..b7dfc1d1bf17 100644 --- a/packages/Python/lldbsuite/test/dotest.py +++ b/packages/Python/lldbsuite/test/dotest.py @@ -724,6 +724,7 @@ def setupSysPath(): pluginPath = os.path.join(scriptPath, 'plugins') toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi') + toolsLLDBVSCode = os.path.join(scriptPath, 'tools', 'lldb-vscode') toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server') # Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the @@ -732,6 +733,9 @@ def setupSysPath(): # Adding test/tools/lldb-mi to the path makes it easy sys.path.insert(0, toolsLLDBMIPath) # to "import lldbmi_testcase" from the MI tests + # Adding test/tools/lldb-vscode to the path makes it easy to + # "import lldb_vscode_testcase" from the VSCode tests + sys.path.insert(0, toolsLLDBVSCode) # Adding test/tools/lldb-server to the path makes it easy sys.path.insert(0, toolsLLDBServerPath) # to "import lldbgdbserverutils" from the lldb-server tests @@ -801,6 +805,15 @@ def setupSysPath(): "The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.") configuration.skipCategories.append("lldb-mi") + lldbVSCodeExec = os.path.join(lldbDir, "lldb-vscode") + if is_exe(lldbVSCodeExec): + os.environ["LLDBVSCODE_EXEC"] = lldbVSCodeExec + else: + if not configuration.shouldSkipBecauseOfCategories(["lldb-vscode"]): + print( + "The 'lldb-vscode' executable cannot be located. The lldb-vscode tests can not be run as a result.") + configuration.skipCategories.append("lldb-vscode") + lldbPythonDir = None # The directory that contains 'lldb/__init__.py' if not configuration.lldbFrameworkPath and os.path.exists(os.path.join(lldbLibDir, "LLDB.framework")): configuration.lldbFrameworkPath = os.path.join(lldbLibDir, "LLDB.framework") @@ -1083,14 +1096,15 @@ def getMyCommandLine(): def checkDsymForUUIDIsNotOn(): cmd = ["defaults", "read", "com.apple.DebugSymbols"] - pipe = subprocess.Popen( + process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - cmd_output = pipe.stdout.read() - if cmd_output and "DBGFileMappedPaths = " in cmd_output: + cmd_output = process.stdout.read() + output_str = cmd_output.decode("utf-8") + if "DBGFileMappedPaths = " in output_str: print("%s =>" % ' '.join(cmd)) - print(cmd_output) + print(output_str) print( "Disable automatic lookup and caching of dSYMs before running the test suite!") print("Exiting...") diff --git a/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py b/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py index 6a8fb5db5439..1108b1215329 100644 --- a/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py +++ b/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py @@ -23,7 +23,6 @@ def setUp(self): # Find the breakpoint self.line = line_number('main.cpp', '// lldb testsuite break') - @expectedFailureAll(oslist=["windows"]) @expectedFailureAll( oslist=['linux'], archs=['arm'], diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py index 63511779a927..d832983bdb64 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py @@ -6,7 +6,6 @@ import lldb -from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil @@ -24,10 +23,6 @@ def setUp(self): '// Please test these expressions while stopped at this line:') self.func_line = line_number('main.cpp', '{5, "five"}') - @expectedFlakeyDarwin("llvm.org/pr20274") - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test(self): """Test gathering result from interrupted function call.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py index ff3bd99ced99..0eb7086b6160 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py @@ -28,10 +28,6 @@ def setUp(self): 'main.cpp', '// Please test these expressions while stopped at this line:') - @expectedFlakeyDsym("llvm.org/pr20274") - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test(self): """Test return values of user defined function calls.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py index b328ece6d39c..a9679b7dd368 100644 --- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py +++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py @@ -41,7 +41,6 @@ def do_test(self, dictionary=None): self.assertTrue(value.GetError().Success()) self.assertEqual(value.GetValueAsSigned(0), 3) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_default_char(self): self.do_test() @@ -52,7 +51,6 @@ def test_default_char(self): "powerpc64le", "s390x"], bugnumber="llvm.org/pr23069") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_signed_char(self): self.do_test(dictionary={'CFLAGS_EXTRAS': '-fsigned-char'}) @@ -64,7 +62,6 @@ def test_signed_char(self): 'armv7', 'armv7k'], bugnumber="llvm.org/pr23069, ") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") @expectedFailureAll(triple='mips*', bugnumber="llvm.org/pr23069") def test_unsigned_char(self): self.do_test(dictionary={'CFLAGS_EXTRAS': '-funsigned-char'}) diff --git a/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/Makefile b/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/Makefile new file mode 100644 index 000000000000..8a7102e347af --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/TestClassTemplateSpecializationParametersHandling.py b/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/TestClassTemplateSpecializationParametersHandling.py new file mode 100644 index 000000000000..d1974d05a244 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/TestClassTemplateSpecializationParametersHandling.py @@ -0,0 +1,23 @@ +""" +Test Expression Parser code gen for ClassTemplateSpecializationDecl to insure +that we generate a TemplateTypeParmDecl in the TemplateParameterList for empty +variadic packs. +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestClassTemplateSpecializationParametersHandling(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_class_template_specialization(self): + self.build() + + lldbutil.run_to_source_breakpoint(self, '// break here', + lldb.SBFileSpec("main.cpp", False)) + + self.expect("expr -u 0 -- b.foo()", substrs=['$0 = 1']) diff --git a/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/main.cpp b/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/main.cpp new file mode 100644 index 000000000000..bc831604aed6 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/main.cpp @@ -0,0 +1,9 @@ +template +struct A { + int foo() { return 1;} +}; + +int main() { + A b; + return b.foo(); // break here +} diff --git a/packages/Python/lldbsuite/test/expression_command/completion/.categories b/packages/Python/lldbsuite/test/expression_command/completion/.categories new file mode 100644 index 000000000000..3a3f4df6416b --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/completion/.categories @@ -0,0 +1 @@ +cmdline diff --git a/packages/Python/lldbsuite/test/expression_command/completion/Makefile b/packages/Python/lldbsuite/test/expression_command/completion/Makefile new file mode 100644 index 000000000000..6fc26a9193f0 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/completion/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp other.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/completion/TestExprCompletion.py b/packages/Python/lldbsuite/test/expression_command/completion/TestExprCompletion.py new file mode 100644 index 000000000000..0a280d04d701 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/completion/TestExprCompletion.py @@ -0,0 +1,259 @@ +""" +Test the lldb command line completion mechanism for the 'expr' command. +""" + +from __future__ import print_function + +import random +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbplatform +from lldbsuite.test import lldbutil + +class CommandLineExprCompletionTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + @expectedFailureAll(bugnumber="rdar://47370292") + def test_expr_completion(self): + self.build() + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + + # Try the completion before we have a context to complete on. + self.assume_no_completions('expr some_expr') + self.assume_no_completions('expr ') + self.assume_no_completions('expr f') + + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + + # Completing member functions + self.complete_exactly('expr some_expr.FooNoArgs', + 'expr some_expr.FooNoArgsBar()') + self.complete_exactly('expr some_expr.FooWithArgs', + 'expr some_expr.FooWithArgsBar(') + self.complete_exactly('expr some_expr.FooWithMultipleArgs', + 'expr some_expr.FooWithMultipleArgsBar(') + self.complete_exactly('expr some_expr.FooUnderscore', + 'expr some_expr.FooUnderscoreBar_()') + self.complete_exactly('expr some_expr.FooNumbers', + 'expr some_expr.FooNumbersBar1()') + self.complete_exactly('expr some_expr.StaticMemberMethod', + 'expr some_expr.StaticMemberMethodBar()') + + # Completing static functions + self.complete_exactly('expr Expr::StaticMemberMethod', + 'expr Expr::StaticMemberMethodBar()') + + # Completing member variables + self.complete_exactly('expr some_expr.MemberVariab', + 'expr some_expr.MemberVariableBar') + + # Multiple completions + self.completions_contain('expr some_expr.', + ['some_expr.FooNumbersBar1()', + 'some_expr.FooUnderscoreBar_()', + 'some_expr.FooWithArgsBar(', + 'some_expr.MemberVariableBar']) + + self.completions_contain('expr some_expr.Foo', + ['some_expr.FooNumbersBar1()', + 'some_expr.FooUnderscoreBar_()', + 'some_expr.FooWithArgsBar(']) + + self.completions_contain('expr ', + ['static_cast', + 'reinterpret_cast', + 'dynamic_cast']) + + self.completions_contain('expr 1 + ', + ['static_cast', + 'reinterpret_cast', + 'dynamic_cast']) + + # Completion expr without spaces + # This is a bit awkward looking for the user, but that's how + # the completion API works at the moment. + self.completions_contain('expr 1+', + ['1+some_expr', "1+static_cast"]) + + # Test with spaces + self.complete_exactly('expr some_expr .FooNoArgs', + 'expr some_expr .FooNoArgsBar()') + self.complete_exactly('expr some_expr .FooNoArgs', + 'expr some_expr .FooNoArgsBar()') + self.complete_exactly('expr some_expr .FooNoArgs', + 'expr some_expr .FooNoArgsBar()') + self.complete_exactly('expr some_expr. FooNoArgs', + 'expr some_expr. FooNoArgsBar()') + self.complete_exactly('expr some_expr . FooNoArgs', + 'expr some_expr . FooNoArgsBar()') + self.complete_exactly('expr Expr :: StaticMemberMethod', + 'expr Expr :: StaticMemberMethodBar()') + self.complete_exactly('expr Expr ::StaticMemberMethod', + 'expr Expr ::StaticMemberMethodBar()') + self.complete_exactly('expr Expr:: StaticMemberMethod', + 'expr Expr:: StaticMemberMethodBar()') + + # Test that string literals don't break our parsing logic. + self.complete_exactly('expr const char *cstr = "some_e"; char c = *cst', + 'expr const char *cstr = "some_e"; char c = *cstr') + self.complete_exactly('expr const char *cstr = "some_e" ; char c = *cst', + 'expr const char *cstr = "some_e" ; char c = *cstr') + # Requesting completions inside an incomplete string doesn't provide any + # completions. + self.complete_exactly('expr const char *cstr = "some_e', + 'expr const char *cstr = "some_e') + + # Completing inside double dash should do nothing + self.assume_no_completions('expr -i0 -- some_expr.', 10) + self.assume_no_completions('expr -i0 -- some_expr.', 11) + + # Test with expr arguments + self.complete_exactly('expr -i0 -- some_expr .FooNoArgs', + 'expr -i0 -- some_expr .FooNoArgsBar()') + self.complete_exactly('expr -i0 -- some_expr .FooNoArgs', + 'expr -i0 -- some_expr .FooNoArgsBar()') + + # Addrof and deref + self.complete_exactly('expr (*(&some_expr)).FooNoArgs', + 'expr (*(&some_expr)).FooNoArgsBar()') + self.complete_exactly('expr (*(&some_expr)) .FooNoArgs', + 'expr (*(&some_expr)) .FooNoArgsBar()') + self.complete_exactly('expr (* (&some_expr)) .FooNoArgs', + 'expr (* (&some_expr)) .FooNoArgsBar()') + self.complete_exactly('expr (* (& some_expr)) .FooNoArgs', + 'expr (* (& some_expr)) .FooNoArgsBar()') + + # Addrof and deref (part 2) + self.complete_exactly('expr (&some_expr)->FooNoArgs', + 'expr (&some_expr)->FooNoArgsBar()') + self.complete_exactly('expr (&some_expr) ->FooNoArgs', + 'expr (&some_expr) ->FooNoArgsBar()') + self.complete_exactly('expr (&some_expr) -> FooNoArgs', + 'expr (&some_expr) -> FooNoArgsBar()') + self.complete_exactly('expr (&some_expr)-> FooNoArgs', + 'expr (&some_expr)-> FooNoArgsBar()') + + # Builtin arg + self.complete_exactly('expr static_ca', + 'expr static_cast') + + # From other files + self.complete_exactly('expr fwd_decl_ptr->Hidden', + 'expr fwd_decl_ptr->HiddenMember') + + + # Types + self.complete_exactly('expr LongClassNa', + 'expr LongClassName') + self.complete_exactly('expr LongNamespaceName::NestedCla', + 'expr LongNamespaceName::NestedClass') + + # Namespaces + self.complete_exactly('expr LongNamespaceNa', + 'expr LongNamespaceName::') + + # Multiple arguments + self.complete_exactly('expr &some_expr + &some_e', + 'expr &some_expr + &some_expr') + self.complete_exactly('expr SomeLongVarNameWithCapitals + SomeLongVarName', + 'expr SomeLongVarNameWithCapitals + SomeLongVarNameWithCapitals') + self.complete_exactly('expr SomeIntVar + SomeIntV', + 'expr SomeIntVar + SomeIntVar') + + # Multiple statements + self.complete_exactly('expr long LocalVariable = 0; LocalVaria', + 'expr long LocalVariable = 0; LocalVariable') + + # Custom Decls + self.complete_exactly('expr auto l = [](int LeftHandSide, int bx){ return LeftHandS', + 'expr auto l = [](int LeftHandSide, int bx){ return LeftHandSide') + self.complete_exactly('expr struct LocalStruct { long MemberName; } ; LocalStruct S; S.Mem', + 'expr struct LocalStruct { long MemberName; } ; LocalStruct S; S.MemberName') + + # Completing function call arguments + self.complete_exactly('expr some_expr.FooWithArgsBar(some_exp', + 'expr some_expr.FooWithArgsBar(some_expr') + self.complete_exactly('expr some_expr.FooWithArgsBar(SomeIntV', + 'expr some_expr.FooWithArgsBar(SomeIntVar') + self.complete_exactly('expr some_expr.FooWithMultipleArgsBar(SomeIntVar, SomeIntVa', + 'expr some_expr.FooWithMultipleArgsBar(SomeIntVar, SomeIntVar') + + # Function return values + self.complete_exactly('expr some_expr.Self().FooNoArgs', + 'expr some_expr.Self().FooNoArgsBar()') + self.complete_exactly('expr some_expr.Self() .FooNoArgs', + 'expr some_expr.Self() .FooNoArgsBar()') + self.complete_exactly('expr some_expr.Self(). FooNoArgs', + 'expr some_expr.Self(). FooNoArgsBar()') + + @expectedFailureAll(bugnumber="rdar://47370292") + def test_expr_completion_with_descriptions(self): + self.build() + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + + self.check_completion_with_desc("expr ", [ + # VarDecls have their type as description. + ["some_expr", "Expr &"], + # builtin types have no description. + ["int", ""], + ["float", ""] + ]) + self.check_completion_with_desc("expr some_expr.", [ + # Functions have their signature as description. + ["some_expr.Self()", "Expr &Self()"], + ["some_expr.operator=(", "inline Expr &operator=(const Expr &)"], + ["some_expr.FooNumbersBar1()", "int FooNumbersBar1()"], + ["some_expr.StaticMemberMethodBar()", "static int StaticMemberMethodBar()"], + ["some_expr.FooWithArgsBar(", "int FooWithArgsBar(int)"], + ["some_expr.FooNoArgsBar()", "int FooNoArgsBar()"], + ["some_expr.FooUnderscoreBar_()", "int FooUnderscoreBar_()"], + ["some_expr.FooWithMultipleArgsBar(", "int FooWithMultipleArgsBar(int, int)"], + ["some_expr.~Expr()", "inline ~Expr()"], + # FieldDecls have their type as description. + ["some_expr.MemberVariableBar", "int"], + ]) + + def assume_no_completions(self, str_input, cursor_pos = None): + interp = self.dbg.GetCommandInterpreter() + match_strings = lldb.SBStringList() + if cursor_pos is None: + cursor_pos = len(str_input) + num_matches = interp.HandleCompletion(str_input, cursor_pos, 0, -1, match_strings) + + available_completions = [] + for m in match_strings: + available_completions.append(m) + + self.assertEquals(num_matches, 0, "Got matches, but didn't expect any: " + str(available_completions)) + + def completions_contain(self, str_input, items): + interp = self.dbg.GetCommandInterpreter() + match_strings = lldb.SBStringList() + num_matches = interp.HandleCompletion(str_input, len(str_input), 0, -1, match_strings) + common_match = match_strings.GetStringAtIndex(0) + + for item in items: + found = False + for m in match_strings: + if m == item: + found = True + if not found: + # Transform match_strings to a python list with strings + available_completions = [] + for m in match_strings: + available_completions.append(m) + self.assertTrue(found, "Couldn't find completion " + item + " in completions " + str(available_completions)) diff --git a/packages/Python/lldbsuite/test/expression_command/completion/main.cpp b/packages/Python/lldbsuite/test/expression_command/completion/main.cpp new file mode 100644 index 000000000000..908bebbebff5 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/completion/main.cpp @@ -0,0 +1,35 @@ +namespace LongNamespaceName { class NestedClass { long m; }; } + +// Defined in other.cpp, we only have a forward declaration here. +struct ForwardDecl; +extern ForwardDecl fwd_decl; + +class LongClassName { long i ; }; + +class Expr { +public: + int FooNoArgsBar() { return 1; } + int FooWithArgsBar(int i) { return i; } + int FooWithMultipleArgsBar(int i, int j) { return i + j; } + int FooUnderscoreBar_() { return 4; } + int FooNumbersBar1() { return 8; } + int MemberVariableBar = 0; + Expr &Self() { return *this; } + static int StaticMemberMethodBar() { return 82; } +}; + +int main() +{ + LongClassName a; + LongNamespaceName::NestedClass NestedFoo; + long SomeLongVarNameWithCapitals = 44; + int SomeIntVar = 33; + Expr some_expr; + some_expr.FooNoArgsBar(); + some_expr.FooWithArgsBar(1); + some_expr.FooUnderscoreBar_(); + some_expr.FooNumbersBar1(); + Expr::StaticMemberMethodBar(); + ForwardDecl *fwd_decl_ptr = &fwd_decl; + return 0; // Break here +} diff --git a/packages/Python/lldbsuite/test/expression_command/completion/other.cpp b/packages/Python/lldbsuite/test/expression_command/completion/other.cpp new file mode 100644 index 000000000000..1f8a488639b9 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/completion/other.cpp @@ -0,0 +1,4 @@ +struct ForwardDecl { + long HiddenMemberName; +}; +ForwardDecl fwd_decl; diff --git a/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestAllowJIT.py b/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestAllowJIT.py index a39e891c90b5..05c67902a3ab 100644 --- a/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestAllowJIT.py +++ b/packages/Python/lldbsuite/test/expression_command/dont_allow_jit/TestAllowJIT.py @@ -22,22 +22,18 @@ class TestAllowJIT(TestBase): # each debug info format. NO_DEBUG_INFO_TESTCASE = True - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_allow_jit_expr_command(self): """Test the --allow-jit command line flag""" self.build() self.main_source_file = lldb.SBFileSpec("main.c") self.expr_cmd_test() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_allow_jit_options(self): """Test the SetAllowJIT SBExpressionOption setting""" self.build() self.main_source_file = lldb.SBFileSpec("main.c") self.expr_options_test() - - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -62,7 +58,7 @@ def expr_options_test(self): "Set a breakpoint here", self.main_source_file) frame = thread.GetFrameAtIndex(0) - + # First make sure we can call the function with the default option set. options = lldb.SBExpressionOptions() # Check that the default is to allow JIT: diff --git a/packages/Python/lldbsuite/test/expression_command/formatters/main.cpp b/packages/Python/lldbsuite/test/expression_command/formatters/main.cpp index 4c3b180f3709..1b8ce48041f9 100644 --- a/packages/Python/lldbsuite/test/expression_command/formatters/main.cpp +++ b/packages/Python/lldbsuite/test/expression_command/formatters/main.cpp @@ -45,4 +45,4 @@ int main(int argc, char** argv) return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp b/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp index b144f9cc1b47..8e181aeba3b0 100644 --- a/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp +++ b/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py index 1dbafc36a82a..13bc3b7ce2ac 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py +++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py @@ -14,6 +14,7 @@ import time import lldb import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -63,3 +64,30 @@ def test_expr_options(self): val = frame.EvaluateExpression('foo != nullptr', options) self.assertTrue(val.IsValid()) self.assertFalse(val.GetError().Success()) + + @skipIfDarwin + def test_expr_options_lang(self): + """These expression language options should work as expected.""" + self.build() + + # Set debugger into synchronous mode + self.dbg.SetAsync(False) + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, '// breakpoint_in_main', self.main_source_spec) + + frame = thread.GetFrameAtIndex(0) + options = lldb.SBExpressionOptions() + + # Make sure we can retrieve `id` variable if language is set to C++11: + options.SetLanguage(lldb.eLanguageTypeC_plus_plus_11) + val = frame.EvaluateExpression('id == 0', options) + self.assertTrue(val.IsValid()) + self.assertTrue(val.GetError().Success()) + self.DebugSBValue(val) + + # Make sure we can't retrieve `id` variable if language is set to ObjC: + options.SetLanguage(lldb.eLanguageTypeObjC) + val = frame.EvaluateExpression('id == 0', options) + self.assertTrue(val.IsValid()) + self.assertFalse(val.GetError().Success()) diff --git a/packages/Python/lldbsuite/test/expression_command/options/main.cpp b/packages/Python/lldbsuite/test/expression_command/options/main.cpp index ecd9a90f6626..0d30c79bd229 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/main.cpp +++ b/packages/Python/lldbsuite/test/expression_command/options/main.cpp @@ -1,11 +1,13 @@ extern "C" int foo(void); static int static_value = 0; +static int id = 1234; int bar() { static_value++; - return static_value; + id++; + return static_value + id; } int main (int argc, char const *argv[]) diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py index f4ee1b0fb625..8630d6f41b34 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py @@ -17,7 +17,6 @@ class NestedPersistentTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_persistent_types(self): """Test that nested persistent types work.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py index f56cb11a80d8..403d24246a9d 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py @@ -17,7 +17,6 @@ class PersistenttypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_persistent_types(self): """Test that lldb persistent types works correctly.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/main.c b/packages/Python/lldbsuite/test/expression_command/persistent_types/main.c index 9e26e619bfdb..9425c8b1cec7 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/main.c +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_variables/main.c b/packages/Python/lldbsuite/test/expression_command/persistent_variables/main.c index fd41471df8ed..771bf4ad3422 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_variables/main.c +++ b/packages/Python/lldbsuite/test/expression_command/persistent_variables/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py b/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py index dd3d06fd672f..6d019c7415fc 100644 --- a/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py @@ -16,7 +16,6 @@ def setUp(self): self.main_source = "main.cpp" self.main_source_spec = lldb.SBFileSpec(self.main_source) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_issue35310(self): """Test invoking functions with non-standard linkage names. diff --git a/packages/Python/lldbsuite/test/expression_command/radar_8638051/main.c b/packages/Python/lldbsuite/test/expression_command/radar_8638051/main.c index 1329fd69a2e1..dc528a458b36 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_8638051/main.c +++ b/packages/Python/lldbsuite/test/expression_command/radar_8638051/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py b/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py index c44cb6fc39da..dc8ee77fd6fb 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py @@ -18,7 +18,6 @@ class Radar9531204TestCase(TestBase): mydir = TestBase.compute_mydir(__file__) # rdar://problem/9531204 - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_expr_commands(self): """The evaluating printf(...) after break stop and then up a stack frame.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9531204/main.c b/packages/Python/lldbsuite/test/expression_command/radar_9531204/main.c index 2bf05f2b3065..43200d317453 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9531204/main.c +++ b/packages/Python/lldbsuite/test/expression_command/radar_9531204/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py index dfef8735071b..d18720ccf3f1 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py @@ -24,7 +24,6 @@ def setUp(self): self.main_source = "main.c" self.line = line_number(self.main_source, '// Set breakpoint here.') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_expr_commands(self): """The following expression commands should just work.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9673664/main.c b/packages/Python/lldbsuite/test/expression_command/radar_9673664/main.c index 934abdfaef3e..c765cf2a83a7 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9673664/main.c +++ b/packages/Python/lldbsuite/test/expression_command/radar_9673664/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/expression_command/rdar44436068/Test128BitsInteger.py b/packages/Python/lldbsuite/test/expression_command/rdar44436068/Test128BitsInteger.py index 03424658f3ed..433c275fb58c 100644 --- a/packages/Python/lldbsuite/test/expression_command/rdar44436068/Test128BitsInteger.py +++ b/packages/Python/lldbsuite/test/expression_command/rdar44436068/Test128BitsInteger.py @@ -1,4 +1,6 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), None) +lldbinline.MakeInlineTest(__file__, globals(), + decorators.skipIf(archs=["armv7k"])) + diff --git a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/main.c b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/main.c index ec4c943dfe39..c9775b6e9892 100644 --- a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/main.c +++ b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/expression_command/radar_43822994/Makefile b/packages/Python/lldbsuite/test/expression_command/scoped_enums/Makefile similarity index 100% rename from packages/Python/lldbsuite/test/expression_command/radar_43822994/Makefile rename to packages/Python/lldbsuite/test/expression_command/scoped_enums/Makefile diff --git a/packages/Python/lldbsuite/test/expression_command/radar_43822994/TestScopedEnumType.py b/packages/Python/lldbsuite/test/expression_command/scoped_enums/TestScopedEnumType.py similarity index 56% rename from packages/Python/lldbsuite/test/expression_command/radar_43822994/TestScopedEnumType.py rename to packages/Python/lldbsuite/test/expression_command/scoped_enums/TestScopedEnumType.py index 603a14c70a6d..e7bc79d8e7cc 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_43822994/TestScopedEnumType.py +++ b/packages/Python/lldbsuite/test/expression_command/scoped_enums/TestScopedEnumType.py @@ -7,10 +7,11 @@ from lldbsuite.test import lldbutil -class ExprXValuePrintingTestCase(TestBase): +class ScopedEnumType(TestBase): mydir = TestBase.compute_mydir(__file__) + @skipIf(dwarf_version=['<', '4']) def test(self): self.build() @@ -27,3 +28,18 @@ def test(self): self.assertTrue(value.IsValid()) self.assertTrue(value.GetError().Success()) self.assertEqual(value.GetValueAsUnsigned(), 1) + + value = frame.EvaluateExpression("b == BarBar") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsUnsigned(), 1) + + ## b is not a Foo + value = frame.EvaluateExpression("b == Foo::FooBar") + self.assertTrue(value.IsValid()) + self.assertFalse(value.GetError().Success()) + + ## integral is not implicitly convertible to a scoped enum + value = frame.EvaluateExpression("1 == Foo::FooBar") + self.assertTrue(value.IsValid()) + self.assertFalse(value.GetError().Success()) diff --git a/packages/Python/lldbsuite/test/expression_command/radar_43822994/main.cpp b/packages/Python/lldbsuite/test/expression_command/scoped_enums/main.cpp similarity index 65% rename from packages/Python/lldbsuite/test/expression_command/radar_43822994/main.cpp rename to packages/Python/lldbsuite/test/expression_command/scoped_enums/main.cpp index 93cde15886bd..b0d67d23dc5e 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_43822994/main.cpp +++ b/packages/Python/lldbsuite/test/expression_command/scoped_enums/main.cpp @@ -2,8 +2,15 @@ enum class Foo { FooBar = 42 }; +enum Bar { + BarBar = 3, + BarBarBar = 42 +}; + int main(int argc, const char **argv) { Foo f = Foo::FooBar; + Bar b = BarBar; bool b1 = f == Foo::FooBar; + bool b2 = b == BarBar; return 0; // Set break point at this line. } diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py index 3af7d808e128..deae7feb3ac1 100644 --- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py +++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py @@ -102,7 +102,6 @@ def test_many_expr_commands(self): # (const char *) $8 = 0x... "/Volumes/data/lldb/svn/trunk/test/expression_command/test/a.out" @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_evaluate_expression_python(self): """Test SBFrame.EvaluateExpression() API for evaluating an expression.""" self.build() @@ -203,7 +202,6 @@ def test_evaluate_expression_python(self): # rdar://problem/8686536 # CommandInterpreter::HandleCommand is stripping \'s from input for # WantsRawCommand commands - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_expr_commands_can_handle_quotes(self): """Throw some expression commands with quotes at lldb.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py index f5ec4f027866..88412e6b7c82 100644 --- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py +++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py @@ -24,9 +24,6 @@ def setUp(self): 'main.cpp', '// Please test many expressions while stopped at this line:') - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_more_expr_commands(self): """Test some more expression commands.""" self.build() @@ -60,9 +57,7 @@ def test_more_expr_commands(self): # (int) $5 = 6 @skipIfLinux - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test_expr_symbols(self): """Test symbols.""" self.build() diff --git a/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py b/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py index c942427a8e66..108de8867d50 100644 --- a/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py +++ b/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py @@ -55,7 +55,6 @@ def test_conditional_bktp(self): @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"]) def test_unwind_expression(self): """Test unwinding from an expression.""" self.build_and_run_to_bkpt() diff --git a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp index 44c149687f21..d18c86512bf3 100644 --- a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/archives/a.c b/packages/Python/lldbsuite/test/functionalities/archives/a.c index 2b6ebbe47a76..c8d226ab9de3 100644 --- a/packages/Python/lldbsuite/test/functionalities/archives/a.c +++ b/packages/Python/lldbsuite/test/functionalities/archives/a.c @@ -1,9 +1,8 @@ //===-- a.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// int __a_global = 1; diff --git a/packages/Python/lldbsuite/test/functionalities/archives/b.c b/packages/Python/lldbsuite/test/functionalities/archives/b.c index 51d77dd4bcdc..6510b978f378 100644 --- a/packages/Python/lldbsuite/test/functionalities/archives/b.c +++ b/packages/Python/lldbsuite/test/functionalities/archives/b.c @@ -1,9 +1,8 @@ //===-- b.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// static int __b_global = 2; diff --git a/packages/Python/lldbsuite/test/functionalities/archives/main.c b/packages/Python/lldbsuite/test/functionalities/archives/main.c index c5b1cc2f0d1c..1525a1a5e389 100644 --- a/packages/Python/lldbsuite/test/functionalities/archives/main.c +++ b/packages/Python/lldbsuite/test/functionalities/archives/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/asan/main.c b/packages/Python/lldbsuite/test/functionalities/asan/main.c index fab760e49f00..45f9f4f9fb79 100644 --- a/packages/Python/lldbsuite/test/functionalities/asan/main.c +++ b/packages/Python/lldbsuite/test/functionalities/asan/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py b/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py index ad87796766c3..754acade015a 100644 --- a/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py +++ b/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py @@ -21,7 +21,7 @@ class AttachResumeTestCase(TestBase): @skipIfRemote @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") + @skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 def test_attach_continue_interrupt_detach(self): """Test attach/continue/interrupt/detach""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py index 1eb535befe7f..f06fb07b3bf6 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py @@ -18,27 +18,31 @@ class BreakpointByLineAndColumnTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + ## Skip gcc version less 7.1 since it doesn't support -gcolumn-info + @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLineAndColumn(self): self.build() main_c = lldb.SBFileSpec("main.c") _, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, - main_c, 20, 50) + main_c, 19, 50) self.expect("fr v did_call", substrs='1') in_then = False for i in range(breakpoint.GetNumLocations()): b_loc = breakpoint.GetLocationAtIndex(i).GetAddress().GetLineEntry() - self.assertEqual(b_loc.GetLine(), 20) + self.assertEqual(b_loc.GetLine(), 19) in_then |= b_loc.GetColumn() == 50 self.assertTrue(in_then) + ## Skip gcc version less 7.1 since it doesn't support -gcolumn-info + @skipIf(compiler="gcc", compiler_version=['<', '7.1']) def testBreakpointByLine(self): self.build() main_c = lldb.SBFileSpec("main.c") - _, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, main_c, 20) + _, _, _, breakpoint = lldbutil.run_to_line_breakpoint(self, main_c, 19) self.expect("fr v did_call", substrs='0') in_condition = False for i in range(breakpoint.GetNumLocations()): b_loc = breakpoint.GetLocationAtIndex(i).GetAddress().GetLineEntry() - self.assertEqual(b_loc.GetLine(), 20) + self.assertEqual(b_loc.GetLine(), 19) in_condition |= b_loc.GetColumn() < 30 self.assertTrue(in_condition) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/main.c index 921bc382023f..f9adad305755 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py index 9ebe61b65e36..8143fa96433f 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -25,7 +25,6 @@ def test_breakpoint_command_sequence(self): self.build() self.breakpoint_command_sequence() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_script_parameters(self): """Test a sequence of breakpoint command add, list, and delete.""" self.build() @@ -45,7 +44,6 @@ def setUp(self): self.addTearDownHook( lambda: self.runCmd("settings clear auto-confirm")) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_delete_all_breakpoints(self): """Test that deleting all breakpoints works.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c index 702644b692d8..8bebb9455a61 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/main.c index 1aa8235e1b0c..c830b17a3ce7 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/main.cpp index 333e9b6405a7..9fc133f24006 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/main.cpp index 3deef22c93c8..3c98e147f221 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py index eb4bac7e6e66..e3bf4c27f31e 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py @@ -18,12 +18,14 @@ class BreakpointIgnoreCountTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + @skipIfWindows # This test will hang on windows llvm.org/pr21753 def test_with_run_command(self): """Exercise breakpoint ignore count with 'breakpoint set -i '.""" self.build() self.breakpoint_ignore_count() @add_test_categories(['pyapi']) + @skipIfWindows # This test will hang on windows llvm.org/pr21753 def test_with_python_api(self): """Use Python APIs to set breakpoint ignore count.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/main.c index b74b37b48b08..b1ed4465c1d4 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/main.c index b74b37b48b08..b1ed4465c1d4 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp index e6d3a95d017f..46682ec264dc 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/main.cpp index fef06a011e92..13e5e3e891f9 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp index c1943f03dbf1..94d0a0415d75 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp index 01f679139249..4afabcbd36e1 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp index d13393095c61..94a12c6241d9 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py index 16d5bc75473c..b8281e9c85bd 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py @@ -18,6 +18,8 @@ def setUp(self): # Find the line number to break inside main(). self.line1 = line_number('foo.h', '// !BR1') self.line2 = line_number('foo.h', '// !BR2') + self.line_between = line_number('main.cpp', "// BR_Between") + print("BR_Between found at", self.line_between) self.line_main = line_number('main.cpp', '// !BR_main') def test(self): @@ -61,3 +63,7 @@ def test(self): # "return .." lldbutil.run_break_set_by_file_and_line(self, 'main.cpp', self.line_main+2, extra_options="-m 1") + + # Make sure we don't put move the breakpoint if it is set between two functions: + lldbutil.run_break_set_by_file_and_line(self, 'main.cpp', + self.line_between, extra_options="-m 1", num_expected_locations=0) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp index c9295a5c7d3c..76a22a5420fe 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp @@ -1,7 +1,7 @@ #include "foo.h" int call_foo2() { return foo2(); } - +// BR_Between int main() // !BR_main { diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py index 1a1ee2eaa893..cda15fee84b8 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py @@ -27,6 +27,7 @@ def test_breakpoint(self): breakpoint = target.BreakpointCreateByLocation("main.c", 1) self.assertTrue(breakpoint.IsHardware()) + @skipIfWindows def test_step_range(self): """Test stepping when hardware breakpoints are required.""" self.build() @@ -47,6 +48,7 @@ def test_step_range(self): self.assertTrue("Could not create hardware breakpoint for thread plan" in error.GetCString()) + @skipIfWindows def test_step_out(self): """Test stepping out when hardware breakpoints are required.""" self.build() @@ -66,6 +68,7 @@ def test_step_out(self): self.assertTrue("Could not create hardware breakpoint for thread plan" in error.GetCString()) + @skipIfWindows def test_step_over(self): """Test stepping over when hardware breakpoints are required.""" self.build() @@ -84,6 +87,7 @@ def test_step_over(self): 'Could not create hardware breakpoint for thread plan' ]) + @skipIfWindows def test_step_until(self): """Test stepping until when hardware breakpoints are required.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py index 62f756b5e658..0eb9033e754b 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py @@ -10,6 +10,7 @@ import re import lldb import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -19,17 +20,20 @@ class TestScriptedResolver(TestBase): NO_DEBUG_INFO_TESTCASE = True + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_scripted_resolver(self): """Use a scripted resolver to set a by symbol name breakpoint""" self.build() self.do_test() + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_search_depths(self): """ Make sure we are called at the right depths depending on what we return from __get_depth__""" self.build() self.do_test_depths() + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_command_line(self): """ Make sure we are called at the right depths depending on what we return from __get_depth__""" diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/main.c index b74b37b48b08..b1ed4465c1d4 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp b/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp index 0b24cb73a619..a0e9efd6ee0c 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/command_script/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py b/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py index cee9bd272189..383f2d7cef09 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py +++ b/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py @@ -1,7 +1,5 @@ """ Test that lldb command "command source" works correctly. - -See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673. """ from __future__ import print_function diff --git a/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py b/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py index 5971e5a673d2..c073425a93fb 100644 --- a/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ b/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -176,8 +176,8 @@ def test_settings_set_th(self): @skipIfFreeBSD # timing out on the FreeBSD buildbot def test_settings_s_dash(self): - """Test that 'settings set -' completes to 'settings set -g'.""" - self.complete_from_to('settings set -', 'settings set -g') + """Test that 'settings set --g' completes to 'settings set --global'.""" + self.complete_from_to('settings set --g', 'settings set --global') @skipIfFreeBSD # timing out on the FreeBSD buildbot def test_settings_clear_th(self): @@ -274,6 +274,22 @@ def test_command_argument_completion(self): self.complete_from_to("watchpoint set variable foo --watch w", "watchpoint set variable foo --watch write") self.complete_from_to('watchpoint set variable foo -w read_', 'watchpoint set variable foo -w read_write') + def test_completion_description_commands(self): + """Test descriptions of top-level command completions""" + self.check_completion_with_desc("", [ + ["command", "Commands for managing custom LLDB commands."], + ["bugreport", "Commands for creating domain-specific bug reports."] + ]) + + self.check_completion_with_desc("pl", [ + ["platform", "Commands to manage and create platforms."], + ["plugin", "Commands for managing LLDB plugins."] + ]) + + # Just check that this doesn't crash. + self.check_completion_with_desc("comman", []) + self.check_completion_with_desc("non-existent-command", []) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test_symbol_name(self): self.build() @@ -281,39 +297,3 @@ def test_symbol_name(self): self.complete_from_to('breakpoint set -n Fo', 'breakpoint set -n Foo::Bar(int,\\ int)', turn_off_re_match=True) - - def complete_from_to(self, str_input, patterns, turn_off_re_match=False): - """Test that the completion mechanism completes str_input to patterns, - where patterns could be a pattern-string or a list of pattern-strings""" - # Patterns should not be None in order to proceed. - self.assertFalse(patterns is None) - # And should be either a string or list of strings. Check for list type - # below, if not, make a list out of the singleton string. If patterns - # is not a string or not a list of strings, there'll be runtime errors - # later on. - if not isinstance(patterns, list): - patterns = [patterns] - - interp = self.dbg.GetCommandInterpreter() - match_strings = lldb.SBStringList() - num_matches = interp.HandleCompletion(str_input, len(str_input), 0, -1, match_strings) - common_match = match_strings.GetStringAtIndex(0) - if num_matches == 0: - compare_string = str_input - else: - if common_match != None and len(common_match) > 0: - compare_string = str_input + common_match - else: - compare_string = "" - for idx in range(1, num_matches+1): - compare_string += match_strings.GetStringAtIndex(idx) + "\n" - - for p in patterns: - if turn_off_re_match: - self.expect( - compare_string, msg=COMPLETION_MSG( - str_input, p, match_strings), exe=False, substrs=[p]) - else: - self.expect( - compare_string, msg=COMPLETION_MSG( - str_input, p, match_strings), exe=False, patterns=[p]) diff --git a/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py b/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py index 904fb4c90372..7b123950c23d 100644 --- a/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py @@ -34,9 +34,6 @@ def test_with_command(self): self.build() self.simulate_conditional_break_by_user() - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr26265: args in frames other than #0 are not evaluated correctly") def do_conditional_break(self): """Exercise some thread and frame APIs to break if c() is called by a().""" exe = self.getBuildArtifact("a.out") diff --git a/packages/Python/lldbsuite/test/functionalities/conditional_break/main.c b/packages/Python/lldbsuite/test/functionalities/conditional_break/main.c index 1329fd69a2e1..dc528a458b36 100644 --- a/packages/Python/lldbsuite/test/functionalities/conditional_break/main.c +++ b/packages/Python/lldbsuite/test/functionalities/conditional_break/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/main.c index e6554564411f..c69d0ab1c353 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/main.c index f851e23d8800..b4b26c158d35 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/message/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/message/main.c index 5648ddae74b8..b0b430187467 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/message/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/message/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/main.c index c93474eedb01..fbe5106b5db0 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/format/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/format/main.c index e371a547438a..889a4e978568 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/format/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/format/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c index 1f5cd1aa6c70..b3af8cb34767 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c index 5ab6f39c0079..3472a9bc507e 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm index 22c8790a7541..e63aa32394ec 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp index bbbd823ec313..f31d2a1a18ad 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp index 2462e28db127..6eabbb3ae0fc 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp index b51dd45a7f60..e0e7c7ab9bdb 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py index 9749061f42d5..4b9de961724b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py @@ -23,9 +23,6 @@ def setUp(self): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24462: Data formatters have problems on Windows") @skipIf(debug_info="gmodules", bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_with_run_command(self): diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp index 5bcfbfd4d46e..c591313de881 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp index 521f7a6931e9..0f922b313524 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp index fdec5fecd3a2..62ff7b227774 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m index 8d76708bc1d1..25cdef4196fd 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/main.m index baaff180e34e..e34cf5222994 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m index 7b8c3785a18c..b0d926fd54ef 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m index 71ab8a746bb6..dc9e5609fbe4 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp index 15fa5614d7fd..334369576a4f 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp index aaccb6329acf..db60981d88c0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -50,4 +49,4 @@ int main (int argc, const char * argv[]) int dummy = 1; return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp index 82ffb2c20d47..665c9fe75d1c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/main.cpp @@ -54,4 +54,4 @@ int main() DeepData_2 data2; return 0; // Set break point at this line. -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py index 0c4730177616..54e9c346df31 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py @@ -17,10 +17,6 @@ class SmartArrayDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") - @decorators.skipIf(debug_info=["gmodules"]) # rdar://36996703 def test_with_run_command(self): """Test data formatter commands.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp index 9279e414be31..b9a517d8cebb 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp index 0eb2418c628a..516331efdde5 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py index e44ea61d120f..0254bf54d916 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py @@ -44,13 +44,13 @@ def test(self): substrs=['f1 = Function = foo(int, int)']) self.expect("frame variable f2", - substrs=['f2 = Lambda in File main.cpp at Line 27']) + substrs=['f2 = Lambda in File main.cpp at Line 26']) self.expect("frame variable f3", - substrs=['f3 = Lambda in File main.cpp at Line 31']) + substrs=['f3 = Lambda in File main.cpp at Line 30']) self.expect("frame variable f4", - substrs=['f4 = Function in File main.cpp at Line 17']) + substrs=['f4 = Function in File main.cpp at Line 16']) self.expect("frame variable f5", substrs=['f5 = Function = Bar::add_num(int) const']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp index 541fdaca2afa..b78161df2c1e 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp index 9109a20cb510..6e5fa43a6b9b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index 90a7e119fb84..86248d1cac24 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -190,6 +190,7 @@ def cleanup(): self.runCmd("n") # This gets us past the printf self.runCmd("n") + self.runCmd("n") # check access-by-index self.expect("frame variable text_list[0]", diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp index 6247ca8b2412..da6eca985d20 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp @@ -74,4 +74,4 @@ int main() ss.clear(); thefoo_rw(1); // Set break point at this line. return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp index e8385994125d..27bdc0a57729 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp @@ -74,4 +74,4 @@ int main() ss.clear(); thefoo_rw(1); // Set break point at this line. return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py index d52fb72ab294..e1f6961b465d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py @@ -12,7 +12,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxOptionalDataFormatterTestCase(TestBase): +class LibcxxVariantDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py index 237e27fe1f31..06d3cda61be2 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py @@ -51,8 +51,6 @@ def check_numbers(self, var_name): substrs=['1234']) @add_test_categories(["libc++"]) - @skipIf(debug_info="gmodules", - bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() @@ -180,8 +178,6 @@ def cleanup(): substrs=['vector has 0 items']) @add_test_categories(["libc++"]) - @skipIf(debug_info="gmodules", - bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_ref_and_ptr(self): """Test that that file and class static variables display correctly.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp index d7b046c5bff8..7ddffd19012e 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp @@ -35,4 +35,4 @@ int main() svter svI = sv.begin(); return 0; // Set break point at this line. -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp index 568c35efe072..d5e5b212782d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp @@ -52,4 +52,4 @@ int main() ss.clear();// Set break point at this line. return 0;// Set break point at this line. -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp index 4a9b4fc7d0db..f6e56cf12456 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp @@ -9,4 +9,4 @@ int main() std::string Q("quite a long std::strin with lots of info inside it"); S.assign(L"!!!!!"); // Set break point at this line. return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py index 5d05418a8b49..f782a2a8baea 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py @@ -66,6 +66,7 @@ def test_with_run_command(self): @skipIfWindows # libstdcpp not ported to Windows @skipIfDarwin # doesn't compile on Darwin @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_recursive_unique_ptr(self): # Tests that LLDB can handle when we have a loop in the unique_ptr # reference chain and that it correctly handles the different options diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp index bac38d84fae3..acb90323b6ce 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py index 08768a61bd9d..138b32802951 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py @@ -24,9 +24,6 @@ def setUp(self): self.line = line_number('main.cpp', 'break here') @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test using Python synthetic children provider to provide a value.""" self.build() @@ -107,7 +104,7 @@ def cleanup(): # check that an aptly defined synthetic provider does not affect # one-lining self.expect( - "expression struct S { myInt theInt{12}; }; S()", + "expression struct Struct { myInt theInt{12}; }; Struct()", substrs=['(theInt = 12)']) # check that we can use a synthetic value in a summary diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp index bc8e05829316..c59e9f0ee728 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp index 120ef0ea0910..a77f2c42e8dd 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp index 5ee113c17b28..fc4204b19848 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp index ac77e537b80a..86ee8d5a8e8c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m index 1b4a6e03857a..e65ee6f0c85f 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m index fdc533aeaf24..65faaeaba097 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m index 7bc49583606f..207e23f51f91 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm index 8d22659374a7..18d37b70dfdc 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/main.mm @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp index b2d6309947ad..5d52383819a0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm index 9ef61e6a73f2..be822dd7ab02 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm @@ -1,9 +1,8 @@ //===-- main.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp index 219f398da3f5..4520165758d5 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/main.cpp index 6745366fb121..4e7c633b5919 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m index 3dd455081007..e66c6b15e7f5 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/main.m @@ -1,9 +1,8 @@ //===-- main.m ---------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #import diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp index 4a449e9716c3..2631171ebf89 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp index 03a9f278b7ec..9d483ebb4701 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp index fec7907e0031..90571b59f81e 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp @@ -59,4 +59,4 @@ int main() 256*256*256*'D'); return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m index a7e94d29d469..eb27ff9d1e3c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp index 5b43102c268c..cb6dc18655f2 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// typedef int Foo; diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp index 41c934aec0c3..b7ac006eb68d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp index 72c7e138205d..e35f7f359e3b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py index d3c04afe91eb..670edad37f9e 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py @@ -14,7 +14,7 @@ from lldbsuite.test import lldbutil -class PythonSynthDataFormatterTestCase(TestBase): +class DataFormatterVarScriptFormatting(TestBase): mydir = TestBase.compute_mydir(__file__) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp index 4dc94af3566c..e9a36f911964 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/main.cpp @@ -5,4 +5,4 @@ int main() { something x; something y; return 0; // Set breakpoint here. -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp index b9d67ad20ab2..5470147f08af 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/dead-strip/main.c b/packages/Python/lldbsuite/test/functionalities/dead-strip/main.c index fe8e7c7de582..cde8c18ba366 100644 --- a/packages/Python/lldbsuite/test/functionalities/dead-strip/main.c +++ b/packages/Python/lldbsuite/test/functionalities/dead-strip/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/deleted-executable/Makefile b/packages/Python/lldbsuite/test/functionalities/deleted-executable/Makefile new file mode 100644 index 000000000000..8a7102e347af --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/deleted-executable/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py b/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py new file mode 100644 index 000000000000..1eeaeeffa87b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py @@ -0,0 +1,31 @@ +""" +Test process attach/resume. +""" + +from __future__ import print_function + + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestDeletedExecutable(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + @skipIfWindows # cannot delete a running executable + @expectedFailureAll(oslist=["linux"]) # determining the architecture of the process fails + def test(self): + self.build() + exe = self.getBuildArtifact("a.out") + + popen = self.spawnSubprocess(exe) + self.addTearDownHook(self.cleanupSubprocesses) + os.remove(exe) + + self.runCmd("process attach -p " + str(popen.pid)) + self.runCmd("kill") diff --git a/packages/Python/lldbsuite/test/functionalities/deleted-executable/main.cpp b/packages/Python/lldbsuite/test/functionalities/deleted-executable/main.cpp new file mode 100644 index 000000000000..ad5d18732eac --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/deleted-executable/main.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main(int argc, char const *argv[]) +{ + lldb_enable_attach(); + + std::this_thread::sleep_for(std::chrono::seconds(30)); +} diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py index 52f9daf6bd45..91b858b4665a 100644 --- a/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py @@ -18,9 +18,6 @@ class DisassemblyTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) NO_DEBUG_INFO_TESTCASE = True - @expectedFailureAll( - oslist=["windows"], - bugnumber="function names print fully demangled instead of name-only") def test(self): self.build() target, _, _, bkpt = lldbutil.run_to_source_breakpoint(self, diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp index c68e3f1b3212..93d4b1cbd39c 100644 --- a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py b/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py deleted file mode 100644 index 0f130b3ecbab..000000000000 --- a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py +++ /dev/null @@ -1,108 +0,0 @@ -"""Test convenience variables when you drop in from lldb prompt into an embedded interpreter.""" - -from __future__ import print_function - - -import os -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class ConvenienceVariablesCase(TestBase): - - mydir = TestBase.compute_mydir(__file__) - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break on inside main.cpp. - self.line = line_number('main.c', 'Hello world.') - - @skipIfFreeBSD # llvm.org/pr17228 - @skipIfRemote - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - def test_with_run_commands(self): - """Test convenience variables lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame.""" - self.build() - import pexpect - exe = self.getBuildArtifact("a.out") - prompt = "(lldb) " - python_prompt = ">>> " - - # So that the child gets torn down after the test. - self.child = pexpect.spawn( - '%s %s %s' % - (lldbtest_config.lldbExec, self.lldbOption, exe)) - child = self.child - # Turn on logging for what the child sends back. - if self.TraceOn(): - child.logfile_read = sys.stdout - - # Set the breakpoint, run the inferior, when it breaks, issue print on - # the various convenience variables. - child.expect_exact(prompt) - child.sendline('breakpoint set -f main.c -l %d' % self.line) - child.expect_exact(prompt) - child.sendline('run') - child.expect_exact("stop reason = breakpoint 1.1") - child.expect_exact(prompt) - child.sendline('script') - child.expect_exact(python_prompt) - - # Set a flag so that we know during teardown time, we need to exit the - # Python interpreter, then the lldb interpreter. - self.child_in_script_interpreter = True - - child.sendline('print(lldb.debugger)') - child.expect_exact(python_prompt) - self.expect(child.before, exe=False, - patterns=['Debugger \(instance: .*, id: \d\)']) - - child.sendline('print(lldb.target)') - child.expect_exact(python_prompt) - self.expect(child.before, exe=False, - substrs=['a.out']) - - child.sendline('print(lldb.process)') - child.expect_exact(python_prompt) - self.expect(child.before, exe=False, patterns=[ - 'SBProcess: pid = \d+, state = stopped, threads = \d, executable = a.out']) - - child.sendline('print(lldb.thread.GetStopDescription(100))') - child.expect_exact(python_prompt) - self.expect( - child.before, - exe=False, - patterns=[ - 'breakpoint 1\.1']) - - child.sendline('lldb.frame.GetLineEntry().GetLine()') - child.expect_exact(python_prompt) - line_number = "%d"%(self.line) - self.expect( - child.before, - exe=False, - substrs=[ - line_number]) - - child.sendline('lldb.frame.GetLineEntry().GetFileSpec().GetFilename()') - child.expect_exact(python_prompt) - line_number = "%d"%(self.line) - self.expect( - child.before, - exe=False, - substrs=[ - "main.c"]) - - child.sendline('lldb.frame.GetFunctionName()') - child.expect_exact(python_prompt) - line_number = "%d"%(self.line) - self.expect( - child.before, - exe=False, - substrs=[ - "main"]) diff --git a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/main.c b/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/main.c deleted file mode 100644 index 277aa54a4eea..000000000000 --- a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/main.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char const *argv[]) { - printf("Hello world.\n"); - return 0; -} diff --git a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py index 579bd9b6f51b..7980cbdb3f04 100644 --- a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py +++ b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py @@ -7,21 +7,11 @@ import lldb import os import time -from lldbsuite.support import seven from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -def execute_command(command): - #print('%% %s' % (command)) - (exit_status, output) = seven.get_command_status_output(command) - # if output: - # print(output) - #print('status = %u' % (exit_status)) - return exit_status - - class ExecTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -31,12 +21,14 @@ class ExecTestCase(TestBase): @skipUnlessDarwin @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532") @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems + @skipIfSanitized # rdar://problem/43756823 def test_hitting_exec (self): self.do_test(False) @skipUnlessDarwin @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532") @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems + @skipIfSanitized # rdar://problem/43756823 def test_skipping_exec (self): self.do_test(False) @@ -61,6 +53,8 @@ def do_test(self, skip_exec): None, None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) + if self.TraceOn(): + self.runCmd("settings show target.process.stop-on-exec", check=False) if skip_exec: self.dbg.HandleCommand("settings set target.process.stop-on-exec false") def cleanup(): @@ -94,6 +88,8 @@ def cleanup(): process.Continue() if not skip_exec: + self.assertFalse(process.GetState() == lldb.eStateExited, + "Process should not have exited!") self.assertTrue(process.GetState() == lldb.eStateStopped, "Process should be stopped at __dyld_start") diff --git a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/Makefile b/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/Makefile similarity index 100% rename from packages/Python/lldbsuite/test/functionalities/embedded_interpreter/Makefile rename to packages/Python/lldbsuite/test/functionalities/expr-entry-bp/Makefile diff --git a/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/TestExprEntryBP.py b/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/TestExprEntryBP.py new file mode 100644 index 000000000000..56abc19f4f30 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/TestExprEntryBP.py @@ -0,0 +1,34 @@ +""" +Tests expressions evaluation when the breakpoint on module's entry is set. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +class ExprEntryBPTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test_expr_entry_bp(self): + """Tests expressions evaluation when the breakpoint on module's entry is set.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here", self.main_source_file) + + self.assertEqual(1, bkpt.GetNumLocations()) + entry = bkpt.GetLocationAtIndex(0).GetAddress().GetModule().GetObjectFileEntryPointAddress() + self.assertTrue(entry.IsValid(), "Can't get a module entry point") + + entry_bp = target.BreakpointCreateBySBAddress(entry) + self.assertTrue(entry_bp.IsValid(), "Can't set a breakpoint on the module entry point") + + result = target.EvaluateExpression("sum(7, 1)") + self.assertTrue(result.IsValid(), "Can't evaluate expression") + self.assertEqual(8, result.GetValueAsSigned()) + + def setUp(self): + TestBase.setUp(self) diff --git a/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/main.c b/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/main.c new file mode 100644 index 000000000000..168fc9c8ccbf --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/expr-entry-bp/main.c @@ -0,0 +1,10 @@ +#include + +int sum(int x, int y) { + return x + y; +} + +int main() { + printf("Set a breakpoint here.\n"); + return sum(-1, 1); +} diff --git a/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py b/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py index 80240534c368..1c237bb1cc84 100644 --- a/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py +++ b/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py @@ -7,7 +7,6 @@ import lldb import os import time -import lldbsuite.support.seven as seven from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil diff --git a/packages/Python/lldbsuite/test/functionalities/format/main.c b/packages/Python/lldbsuite/test/functionalities/format/main.c index 1dfc8ef1f3aa..b37bb22de774 100644 --- a/packages/Python/lldbsuite/test/functionalities/format/main.c +++ b/packages/Python/lldbsuite/test/functionalities/format/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py b/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py index abd4ae8b3828..1162157bad57 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py @@ -67,9 +67,24 @@ def test_frame_recognizer_1(self): self.expect("frame variable", substrs=['(int) a = 42', '(int) b = 56']) - opts = lldb.SBVariablesOptions(); - opts.SetIncludeRecognizedArguments(True); - variables = frame.GetVariables(opts); + # Recognized arguments don't show up by default... + variables = frame.GetVariables(lldb.SBVariablesOptions()) + self.assertEqual(variables.GetSize(), 0) + + # ...unless you set target.display-recognized-arguments to 1... + self.runCmd("settings set target.display-recognized-arguments 1") + variables = frame.GetVariables(lldb.SBVariablesOptions()) + self.assertEqual(variables.GetSize(), 2) + + # ...and you can reset it back to 0 to hide them again... + self.runCmd("settings set target.display-recognized-arguments 0") + variables = frame.GetVariables(lldb.SBVariablesOptions()) + self.assertEqual(variables.GetSize(), 0) + + # ... or explicitly ask for them with SetIncludeRecognizedArguments(True). + opts = lldb.SBVariablesOptions() + opts.SetIncludeRecognizedArguments(True) + variables = frame.GetVariables(opts) self.assertEqual(variables.GetSize(), 2) self.assertEqual(variables.GetValueAtIndex(0).name, "a") diff --git a/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m b/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m index 51103ae038ac..9c6ce9d21023 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m +++ b/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/frame_var_scope/main.c b/packages/Python/lldbsuite/test/functionalities/frame_var_scope/main.c index 80beb29cf34f..71f4cb234e32 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame_var_scope/main.c +++ b/packages/Python/lldbsuite/test/functionalities/frame_var_scope/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestStopPCs.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestStopPCs.py new file mode 100644 index 000000000000..7b733e77e679 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestStopPCs.py @@ -0,0 +1,46 @@ +from __future__ import print_function +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestStopPCs(GDBRemoteTestBase): + + @skipIfXmlSupportMissing + def test(self): + class MyResponder(MockGDBServerResponder): + def haltReason(self): + return "T02thread:1ff0d;threads:1ff0d,2ff0d;thread-pcs:10001bc00,10002bc00;" + + def threadStopInfo(self, threadnum): + if threadnum == 0x1ff0d: + return "T02thread:1ff0d;threads:1ff0d,2ff0d;thread-pcs:10001bc00,10002bc00;" + if threadnum == 0x2ff0d: + return "T00thread:2ff0d;threads:1ff0d,2ff0d;thread-pcs:10001bc00,10002bc00;" + + def qXferRead(self, obj, annex, offset, length): + if annex == "target.xml": + return """ + + i386:x86-64 + + + + """, False + else: + return None, False + + self.server.responder = MyResponder() + target = self.dbg.CreateTarget('') + if self.TraceOn(): + self.runCmd("log enable gdb-remote packets") + process = self.connect(target) + + self.assertEqual(process.GetNumThreads(), 2) + th0 = process.GetThreadAtIndex(0) + th1 = process.GetThreadAtIndex(1) + self.assertEqual(th0.GetThreadID(), 0x1ff0d) + self.assertEqual(th1.GetThreadID(), 0x2ff0d) + self.assertEqual(th0.GetFrameAtIndex(0).GetPC(), 0x10001bc00) + self.assertEqual(th1.GetFrameAtIndex(0).GetPC(), 0x10002bc00) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py index 184867e480b4..57c5ff0aac25 100644 --- a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py @@ -121,4 +121,4 @@ def readRegister(self, register): if self.TraceOn(): interp.HandleCommand("target list", result) print(result.GetOutput()) - self.assertTrue(target.GetTriple().startswith('x86_64--')) + self.assertTrue(target.GetTriple().startswith('x86_64-unknown-unknown')) diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-assert/main.c b/packages/Python/lldbsuite/test/functionalities/inferior-assert/main.c index 6aec4c1023a9..ad2ca5634240 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-assert/main.c +++ b/packages/Python/lldbsuite/test/functionalities/inferior-assert/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-changed/main.c b/packages/Python/lldbsuite/test/functionalities/inferior-changed/main.c index 9d0706a0862d..ec4824ad4ad7 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-changed/main.c +++ b/packages/Python/lldbsuite/test/functionalities/inferior-changed/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-changed/main2.c b/packages/Python/lldbsuite/test/functionalities/inferior-changed/main2.c index 9173e8c30b59..a3c68f0f03d9 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-changed/main2.c +++ b/packages/Python/lldbsuite/test/functionalities/inferior-changed/main2.c @@ -1,9 +1,8 @@ //===-- main2.c -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py index 4f54f5d4103b..528192519513 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py @@ -16,59 +16,42 @@ class CrashingInferiorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_inferior_crashing(self): """Test that lldb reliably catches the inferior crashing (command).""" self.build() self.inferior_crashing() - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_inferior_crashing_register(self): """Test that lldb reliably reads registers from the inferior after crashing (command).""" self.build() self.inferior_crashing_registers() @add_test_categories(['pyapi']) - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing_python(self): """Test that lldb reliably catches the inferior crashing (Python API).""" self.build() self.inferior_crashing_python() - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") def test_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.build() self.inferior_crashing_expr() - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_inferior_crashing_step(self): """Test that stepping after a crash behaves correctly.""" self.build() self.inferior_crashing_step() - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") @skipIfTargetAndroid() # debuggerd interferes with this test on Android + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_inferior_crashing_step_after_break(self): """Test that lldb functions correctly after stepping through a crash.""" self.build() self.inferior_crashing_step_after_break() - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API") # Inferior exits after stepping after a segfault. This is working as # intended IMHO. @skipIfLinux diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/main.c b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/main.c index 3b7cfe4012bd..3423ea42bee8 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/main.c +++ b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py index d8efe65dc7f6..2cd4d46a7ca8 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py @@ -29,13 +29,11 @@ def test_recursive_inferior_crashing_register(self): self.recursive_inferior_crashing_registers() @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_recursive_inferior_crashing_python(self): """Test that lldb reliably catches the inferior crashing (Python API).""" self.build() self.recursive_inferior_crashing_python() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_recursive_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read from the inferior after crashing (command).""" self.build() @@ -47,8 +45,8 @@ def test_recursive_inferior_crashing_step(self): self.build() self.recursive_inferior_crashing_step() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @skipIfTargetAndroid() # debuggerd interferes with this test on Android + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_recursive_inferior_crashing_step_after_break(self): """Test that lldb functions correctly after stepping through a crash.""" self.build() @@ -58,7 +56,6 @@ def test_recursive_inferior_crashing_step_after_break(self): # intended IMHO. @skipIfLinux @skipIfFreeBSD - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_recursive_inferior_crashing_expr_step_and_expr(self): """Test that lldb expressions work before and after stepping after a crash.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index d3072066ebad..7bc5d205a94f 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -158,6 +158,7 @@ def test_modules_search_paths(self): @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @expectedFailureAndroid # wrong source file shows up for hidden library @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + @skipIfDarwinEmbedded def test_dyld_library_path(self): """Test (DY)LD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else.""" self.copy_shlibs_to_remote(hidden_dir=True) @@ -220,7 +221,6 @@ def test_dyld_library_path(self): triple='.*-android') @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently - @expectedFailureAll(bugnumber="rdar://38484268") def test_lldb_process_load_and_unload_commands(self): """Test that lldb process load/unload command work correctly.""" self.copy_shlibs_to_remote() diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp b/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp index 235749aef74a..ec34f9b974d1 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp @@ -1,9 +1,8 @@ //===-- a.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// extern int b_function (); diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp b/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp index 4d383169b79c..9db93841ab79 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp @@ -1,9 +1,8 @@ //===-- b.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp b/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp index f0dfb4ec0d38..cf0c146621e3 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp @@ -1,9 +1,8 @@ //===-- c.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// extern "C" int diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp b/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp index 55f2a6b404b3..a2135c50713f 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp @@ -1,9 +1,8 @@ //===-- c.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp b/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp index 6a7642c08b93..d03d3c9f8c7c 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp @@ -1,9 +1,8 @@ //===-- c.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp b/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp index bff9a3176060..815f030d8579 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp b/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp index 6a7642c08b93..d03d3c9f8c7c 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp @@ -1,9 +1,8 @@ //===-- c.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp b/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp index 4b3320479c25..432774d36b53 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/longjmp/main.c b/packages/Python/lldbsuite/test/functionalities/longjmp/main.c index 3879311eb452..ce1af7038c2e 100644 --- a/packages/Python/lldbsuite/test/functionalities/longjmp/main.c +++ b/packages/Python/lldbsuite/test/functionalities/longjmp/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/memory-region/Makefile b/packages/Python/lldbsuite/test/functionalities/memory-region/Makefile new file mode 100644 index 000000000000..9d4f3b7f1412 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/memory-region/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules + +clean:: + rm -rf $(wildcard *.o *.d *.dSYM) diff --git a/packages/Python/lldbsuite/test/functionalities/memory-region/TestMemoryRegion.py b/packages/Python/lldbsuite/test/functionalities/memory-region/TestMemoryRegion.py new file mode 100644 index 000000000000..4d10e68672e0 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/memory-region/TestMemoryRegion.py @@ -0,0 +1,59 @@ +""" +Test the 'memory region' command. +""" + +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class MemoryCommandRegion(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def setUp(self): + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number( + 'main.cpp', + '// Run here before printing memory regions') + + def test(self): + self.build() + + # Set breakpoint in main and run + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + interp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + + # Test that the first 'memory region' command prints the usage. + interp.HandleCommand("memory region", result) + self.assertFalse(result.Succeeded()) + self.assertRegexpMatches(result.GetError(), "Usage: memory region ADDR") + + # Now let's print the memory region starting at 0 which should always work. + interp.HandleCommand("memory region 0x0", result) + self.assertTrue(result.Succeeded()) + self.assertRegexpMatches(result.GetOutput(), "\\[0x0+-") + + # Keep printing memory regions until we printed all of them. + while True: + interp.HandleCommand("memory region", result) + if not result.Succeeded(): + break + + # Now that we reached the end, 'memory region' should again print the usage. + interp.HandleCommand("memory region", result) + self.assertFalse(result.Succeeded()) + self.assertRegexpMatches(result.GetError(), "Usage: memory region ADDR") diff --git a/packages/Python/lldbsuite/test/functionalities/memory-region/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory-region/main.cpp new file mode 100644 index 000000000000..116c10a6c3ea --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/memory-region/main.cpp @@ -0,0 +1,6 @@ +#include + +int main (int argc, char const **argv) { + std::cout << "Program with sections" << std::endl; + return 0; // Run here before printing memory regions +} diff --git a/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py b/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py index f45479bee0bf..56984885104e 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py +++ b/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py @@ -24,7 +24,7 @@ def setUp(self): # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFlakeyOS(oslist=["windows"]) + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test_memory_cache(self): """Test the MemoryCache class with a sequence of 'memory read' and 'memory write' operations.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp index 7f25e2f4bf68..d47107cef878 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py b/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py index 8e0fbaa32018..245aaa819c7f 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py +++ b/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py @@ -24,7 +24,6 @@ def setUp(self): # Find the line number to break inside main(). self.line = line_number('main.cpp', '// break here') - @expectedFailureAll(oslist=["windows"]) def test_memory_find(self): """Test the 'memory find' command.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp index 250f359c76e0..5f4545daabd5 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp index fdc7b8bdba18..3c1ab5e3f334 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp b/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp index 4424cf30c3a4..4df7eed40a50 100644 --- a/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp b/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp index 2171a2648bde..2b8406a631b8 100644 --- a/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template b/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template index 393e9feec796..1667c0d721ed 100644 --- a/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template +++ b/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template @@ -1,9 +1,8 @@ //===-- plugin.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py index 879f1adebc6a..2c25ccc253fd 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -6,6 +6,7 @@ import shutil import struct +import os import lldb from lldbsuite.test.decorators import * @@ -203,6 +204,30 @@ def test_FPR_SSE(self): for regname, value in values.iteritems(): self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)]) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") + def test_i386_sysroot(self): + """Test that lldb can find the exe for an i386 linux core file using the sysroot.""" + + # Copy linux-i386.out to tmp_sysroot/home/labath/test/a.out (since it was compiled as + # /home/labath/test/a.out) + tmp_sysroot = os.path.join(self.getBuildDir(), "lldb_i386_mock_sysroot") + executable = os.path.join(tmp_sysroot, "home", "labath", "test", "a.out") + lldbutil.mkdir_p(os.path.dirname(executable)) + shutil.copyfile("linux-i386.out", executable) + + # Set sysroot and load core + self.runCmd("platform select remote-linux --sysroot '%s'" % tmp_sysroot) + target = self.dbg.CreateTarget(None) + self.assertTrue(target, VALID_TARGET) + process = target.LoadCore("linux-i386.core") + + # Check that we found a.out from the sysroot + self.check_all(process, self._i386_pid, self._i386_regions, "a.out") + + self.dbg.DeleteTarget(target) + def check_memory_regions(self, process, region_count): region_list = process.GetMemoryRegions() self.assertEqual(region_list.GetSize(), region_count) @@ -299,15 +324,7 @@ def check_state(self, process): self.dbg.SetOutputFileHandle(None, False) self.dbg.SetErrorFileHandle(None, False) - def do_test(self, filename, pid, region_count, thread_name): - target = self.dbg.CreateTarget(filename + ".out") - process = target.LoadCore(filename + ".core") - self.assertTrue(process, PROCESS_IS_VALID) - self.assertEqual(process.GetNumThreads(), 1) - self.assertEqual(process.GetProcessID(), pid) - - self.check_state(process) - + def check_stack(self, process, pid, thread_name): thread = process.GetSelectedThread() self.assertTrue(thread) self.assertEqual(thread.GetThreadID(), pid) @@ -324,6 +341,21 @@ def do_test(self, filename, pid, region_count, thread_name): frame.FindVariable("F").GetValueAsUnsigned(), ord( backtrace[i][0])) + def check_all(self, process, pid, region_count, thread_name): + self.assertTrue(process, PROCESS_IS_VALID) + self.assertEqual(process.GetNumThreads(), 1) + self.assertEqual(process.GetProcessID(), pid) + + self.check_state(process) + + self.check_stack(process, pid, thread_name) + self.check_memory_regions(process, region_count) + def do_test(self, filename, pid, region_count, thread_name): + target = self.dbg.CreateTarget(filename + ".out") + process = target.LoadCore(filename + ".core") + + self.check_all(process, pid, region_count, thread_name) + self.dbg.DeleteTarget(target) diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp index f53ce2f35924..a8e5f34d14e7 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp index 7e09662edb2d..dd83558bd690 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 5960215f8047..46398e39a0e0 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -88,6 +88,36 @@ def test_process_info_in_minidump(self): self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid) self.check_state() + def test_memory_region_name(self): + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + self.process = self.target.LoadCore("regions-linux-map.dmp") + result = lldb.SBCommandReturnObject() + addr_region_name_pairs = [ + ("0x400d9000", "/system/bin/app_process"), + ("0x400db000", "/system/bin/app_process"), + ("0x400dd000", "/system/bin/linker"), + ("0x400ed000", "/system/bin/linker"), + ("0x400ee000", "/system/bin/linker"), + ("0x400fb000", "/system/lib/liblog.so"), + ("0x400fc000", "/system/lib/liblog.so"), + ("0x400fd000", "/system/lib/liblog.so"), + ("0x400ff000", "/system/lib/liblog.so"), + ("0x40100000", "/system/lib/liblog.so"), + ("0x40101000", "/system/lib/libc.so"), + ("0x40122000", "/system/lib/libc.so"), + ("0x40123000", "/system/lib/libc.so"), + ("0x40167000", "/system/lib/libc.so"), + ("0x40169000", "/system/lib/libc.so"), + ] + ci = self.dbg.GetCommandInterpreter() + for (addr, region_name) in addr_region_name_pairs: + command = 'memory region ' + addr + ci.HandleCommand(command, result, False) + message = 'Ensure memory "%s" shows up in output for "%s"' % ( + region_name, command) + self.assertTrue(region_name in result.GetOutput(), message) + def test_modules_in_mini_dump(self): """Test that lldb can read the list of modules from the minidump.""" # target create -c linux-x86_64.dmp @@ -97,13 +127,17 @@ def test_modules_in_mini_dump(self): self.assertTrue(self.process, PROCESS_IS_VALID) expected_modules = [ { - 'filename' : 'linux-gate.so', - 'uuid' : '4EAD28F8-88EF-3520-872B-73C6F2FE7306-C41AF22F', + 'filename' : 'linux-x86_64', + 'uuid' : 'E35C283B-C327-C287-62DB-788BF5A4078B-E2351448', }, { 'filename' : 'libm-2.19.so', 'uuid' : 'D144258E-6149-00B2-55A3-1F3FD2283A87-8670D5BC', }, + { + 'filename' : 'libgcc_s.so.1', + 'uuid' : '36311B44-5771-0AE5-578C-4BF00791DED7-359DBB92', + }, { 'filename' : 'libstdc++.so.6.0.19', 'uuid' : '76190E92-2AF7-457D-078F-75C9B15FA184-E83EB506', @@ -112,25 +146,21 @@ def test_modules_in_mini_dump(self): 'filename' : 'libc-2.19.so', 'uuid' : 'CF699A15-CAAE-64F5-0311-FC4655B86DC3-9A479789', }, - { - 'filename' : 'linux-x86_64', - 'uuid' : 'E35C283B-C327-C287-62DB-788BF5A4078B-E2351448', - }, - { - 'filename' : 'libgcc_s.so.1', - 'uuid' : '36311B44-5771-0AE5-578C-4BF00791DED7-359DBB92', - }, { 'filename' : 'libpthread-2.19.so', 'uuid' : '31E9F21A-E8C1-0396-171F-1E13DA157809-86FA696C', }, + { + 'filename' : 'libbreakpad.so', + 'uuid' : '784FD549-332D-826E-D23F-18C17C6F320A', + }, { 'filename' : 'ld-2.19.so', 'uuid' : 'D0F53790-4076-D73F-29E4-A37341F8A449-E2EF6CD0', }, { - 'filename' : 'libbreakpad.so', - 'uuid' : '784FD549-332D-826E-D23F-18C17C6F320A', + 'filename' : 'linux-gate.so', + 'uuid' : '4EAD28F8-88EF-3520-872B-73C6F2FE7306-C41AF22F', }, ] self.assertEqual(self.target.GetNumModules(), len(expected_modules)) @@ -189,6 +219,161 @@ def test_snapshot_minidump(self): stop_description = thread.GetStopDescription(256) self.assertEqual(stop_description, "") + def check_register_unsigned(self, set, name, expected): + reg_value = set.GetChildMemberWithName(name) + self.assertTrue(reg_value.IsValid(), + 'Verify we have a register named "%s"' % (name)) + self.assertEqual(reg_value.GetValueAsUnsigned(), expected, + 'Verify "%s" == %i' % (name, expected)) + + def check_register_string_value(self, set, name, expected, format): + reg_value = set.GetChildMemberWithName(name) + self.assertTrue(reg_value.IsValid(), + 'Verify we have a register named "%s"' % (name)) + if format is not None: + reg_value.SetFormat(format) + self.assertEqual(reg_value.GetValue(), expected, + 'Verify "%s" has string value "%s"' % (name, + expected)) + + def test_arm64_registers(self): + """Test ARM64 registers from a breakpad created minidump.""" + # target create -c arm64-macos.dmp + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + self.process = self.target.LoadCore("arm64-macos.dmp") + self.check_state() + self.assertEqual(self.process.GetNumThreads(), 1) + thread = self.process.GetThreadAtIndex(0) + self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + stop_description = thread.GetStopDescription(256) + self.assertEqual(stop_description, "") + registers = thread.GetFrameAtIndex(0).GetRegisters() + # Verify the GPR registers are all correct + # Verify x0 - x31 register values + gpr = registers.GetValueAtIndex(0) + for i in range(32): + v = i+1 | i+2 << 32 | i+3 << 48 + w = i+1 + self.check_register_unsigned(gpr, 'x%i' % (i), v) + self.check_register_unsigned(gpr, 'w%i' % (i), w) + # Verify arg1 - arg8 register values + for i in range(1, 9): + v = i | i+1 << 32 | i+2 << 48 + self.check_register_unsigned(gpr, 'arg%i' % (i), v) + i = 29 + v = i+1 | i+2 << 32 | i+3 << 48 + self.check_register_unsigned(gpr, 'fp', v) + i = 30 + v = i+1 | i+2 << 32 | i+3 << 48 + self.check_register_unsigned(gpr, 'lr', v) + i = 31 + v = i+1 | i+2 << 32 | i+3 << 48 + self.check_register_unsigned(gpr, 'sp', v) + self.check_register_unsigned(gpr, 'pc', 0x1000) + self.check_register_unsigned(gpr, 'cpsr', 0x11223344) + self.check_register_unsigned(gpr, 'psr', 0x11223344) + + # Verify the FPR registers are all correct + fpr = registers.GetValueAtIndex(1) + for i in range(32): + v = "0x" + d = "0x" + s = "0x" + h = "0x" + for j in range(i+15, i-1, -1): + v += "%2.2x" % (j) + for j in range(i+7, i-1, -1): + d += "%2.2x" % (j) + for j in range(i+3, i-1, -1): + s += "%2.2x" % (j) + for j in range(i+1, i-1, -1): + h += "%2.2x" % (j) + self.check_register_string_value(fpr, "v%i" % (i), v, + lldb.eFormatHex) + self.check_register_string_value(fpr, "d%i" % (i), d, + lldb.eFormatHex) + self.check_register_string_value(fpr, "s%i" % (i), s, + lldb.eFormatHex) + self.check_register_string_value(fpr, "h%i" % (i), h, + lldb.eFormatHex) + self.check_register_unsigned(gpr, 'fpsr', 0x55667788) + self.check_register_unsigned(gpr, 'fpcr', 0x99aabbcc) + + def verify_arm_registers(self, apple=False): + """ + Verify values of all ARM registers from a breakpad created + minidump. + """ + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + if apple: + self.process = self.target.LoadCore("arm-macos.dmp") + else: + self.process = self.target.LoadCore("arm-linux.dmp") + self.check_state() + self.assertEqual(self.process.GetNumThreads(), 1) + thread = self.process.GetThreadAtIndex(0) + self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + stop_description = thread.GetStopDescription(256) + self.assertEqual(stop_description, "") + registers = thread.GetFrameAtIndex(0).GetRegisters() + # Verify the GPR registers are all correct + # Verify x0 - x31 register values + gpr = registers.GetValueAtIndex(0) + for i in range(1, 16): + self.check_register_unsigned(gpr, 'r%i' % (i), i+1) + # Verify arg1 - arg4 register values + for i in range(1, 5): + self.check_register_unsigned(gpr, 'arg%i' % (i), i) + if apple: + self.check_register_unsigned(gpr, 'fp', 0x08) + else: + self.check_register_unsigned(gpr, 'fp', 0x0c) + self.check_register_unsigned(gpr, 'lr', 0x0f) + self.check_register_unsigned(gpr, 'sp', 0x0e) + self.check_register_unsigned(gpr, 'pc', 0x10) + self.check_register_unsigned(gpr, 'cpsr', 0x11223344) + + # Verify the FPR registers are all correct + fpr = registers.GetValueAtIndex(1) + # Check d0 - d31 + self.check_register_unsigned(gpr, 'fpscr', 0x55667788aabbccdd) + for i in range(32): + value = (i+1) | (i+1) << 8 | (i+1) << 32 | (i+1) << 48 + self.check_register_unsigned(fpr, "d%i" % (i), value) + # Check s0 - s31 + for i in range(32): + i_val = (i >> 1) + 1 + if i & 1: + value = "%#8.8x" % (i_val | i_val << 16) + else: + value = "%#8.8x" % (i_val | i_val << 8) + self.check_register_string_value(fpr, "s%i" % (i), value, + lldb.eFormatHex) + # Check q0 - q15 + for i in range(15): + a = i * 2 + 1 + b = a + 1 + value = ("0x00%2.2x00%2.2x0000%2.2x%2.2x" + "00%2.2x00%2.2x0000%2.2x%2.2x") % (b, b, b, b, a, a, a, a) + self.check_register_string_value(fpr, "q%i" % (i), value, + lldb.eFormatHex) + + def test_linux_arm_registers(self): + """Test Linux ARM registers from a breakpad created minidump. + + The frame pointer is R11 for linux. + """ + self.verify_arm_registers(apple=False) + + def test_apple_arm_registers(self): + """Test Apple ARM registers from a breakpad created minidump. + + The frame pointer is R7 for linux. + """ + self.verify_arm_registers(apple=True) + def do_test_deeper_stack(self, binary, core, pid): target = self.dbg.CreateTarget(binary) process = target.LoadCore(core) @@ -263,3 +448,65 @@ def test_local_variables_in_minidump(self): frame = thread.GetFrameAtIndex(1) value = frame.EvaluateExpression('x') self.assertEqual(value.GetValueAsSigned(), 3) + + def test_memory_regions_in_minidump(self): + """Test memory regions from a Minidump""" + # target create -c regions-linux-map.dmp + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + self.process = self.target.LoadCore("regions-linux-map.dmp") + self.check_state() + + regions_count = 19 + region_info_list = self.process.GetMemoryRegions() + self.assertEqual(region_info_list.GetSize(), regions_count) + + def check_region(index, start, end, read, write, execute, mapped, name): + region_info = lldb.SBMemoryRegionInfo() + self.assertTrue( + self.process.GetMemoryRegionInfo(start, region_info).Success()) + self.assertEqual(start, region_info.GetRegionBase()) + self.assertEqual(end, region_info.GetRegionEnd()) + self.assertEqual(read, region_info.IsReadable()) + self.assertEqual(write, region_info.IsWritable()) + self.assertEqual(execute, region_info.IsExecutable()) + self.assertEqual(mapped, region_info.IsMapped()) + self.assertEqual(name, region_info.GetName()) + + # Ensure we have the same regions as SBMemoryRegionInfoList contains. + if index >= 0 and index < regions_count: + region_info_from_list = lldb.SBMemoryRegionInfo() + self.assertTrue(region_info_list.GetMemoryRegionAtIndex( + index, region_info_from_list)) + self.assertEqual(region_info_from_list, region_info) + + a = "/system/bin/app_process" + b = "/system/bin/linker" + c = "/system/lib/liblog.so" + d = "/system/lib/libc.so" + n = None + max_int = 0xffffffffffffffff + + # Test address before the first entry comes back with nothing mapped up + # to first valid region info + check_region(-1, 0x00000000, 0x400d9000, False, False, False, False, n) + check_region( 0, 0x400d9000, 0x400db000, True, False, True, True, a) + check_region( 1, 0x400db000, 0x400dc000, True, False, False, True, a) + check_region( 2, 0x400dc000, 0x400dd000, True, True, False, True, n) + check_region( 3, 0x400dd000, 0x400ec000, True, False, True, True, b) + check_region( 4, 0x400ec000, 0x400ed000, True, False, False, True, n) + check_region( 5, 0x400ed000, 0x400ee000, True, False, False, True, b) + check_region( 6, 0x400ee000, 0x400ef000, True, True, False, True, b) + check_region( 7, 0x400ef000, 0x400fb000, True, True, False, True, n) + check_region( 8, 0x400fb000, 0x400fc000, True, False, True, True, c) + check_region( 9, 0x400fc000, 0x400fd000, True, True, True, True, c) + check_region(10, 0x400fd000, 0x400ff000, True, False, True, True, c) + check_region(11, 0x400ff000, 0x40100000, True, False, False, True, c) + check_region(12, 0x40100000, 0x40101000, True, True, False, True, c) + check_region(13, 0x40101000, 0x40122000, True, False, True, True, d) + check_region(14, 0x40122000, 0x40123000, True, True, True, True, d) + check_region(15, 0x40123000, 0x40167000, True, False, True, True, d) + check_region(16, 0x40167000, 0x40169000, True, False, False, True, d) + check_region(17, 0x40169000, 0x4016b000, True, True, False, True, d) + check_region(18, 0x4016b000, 0x40176000, True, True, False, True, n) + check_region(-1, 0x40176000, max_int, False, False, False, False, n) diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp new file mode 100644 index 000000000000..3b0cb8268def Binary files /dev/null and b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp differ diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp new file mode 100644 index 000000000000..9ff6a8396ec5 Binary files /dev/null and b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp differ diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp new file mode 100644 index 000000000000..ba658dd48feb Binary files /dev/null and b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp differ diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.dmp b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.dmp new file mode 100644 index 000000000000..3f1dd53d98fa Binary files /dev/null and b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.dmp differ diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py index 61e2adee41d5..fe13871ddac9 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py @@ -49,29 +49,29 @@ def test_modules_in_mini_dump(self): self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp") self.assertTrue(self.process, PROCESS_IS_VALID) expected_modules = [ - { - 'filename' : r"C:\Windows\System32/MSVCP120D.dll", - 'uuid' : '6E51053C-E757-EB40-8D3F-9722C5BD80DD-01000000', - }, - { - 'filename' : r"C:\Windows\SysWOW64/kernel32.dll", - 'uuid' : '1B7ECBE5-5E00-1341-AB98-98D6913B52D8-02000000', - }, { 'filename' : r"C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug/fizzbuzz.exe", 'uuid' : '91B7450F-969A-F946-BF8F-2D6076EA421A-11000000', }, { - 'filename' : r"C:\Windows\System32/MSVCR120D.dll", - 'uuid' : '86FB8263-C446-4640-AE42-8D97B3F91FF2-01000000', + 'filename' : r"C:\Windows\SysWOW64/ntdll.dll", + 'uuid' : '6A84B0BB-2C40-5240-A16B-67650BBFE6B0-02000000', + }, + { + 'filename' : r"C:\Windows\SysWOW64/kernel32.dll", + 'uuid' : '1B7ECBE5-5E00-1341-AB98-98D6913B52D8-02000000', }, { 'filename' : r"C:\Windows\SysWOW64/KERNELBASE.dll", 'uuid' : '4152F90B-0DCB-D44B-AC5D-186A6452E522-01000000', }, { - 'filename' : r"C:\Windows\SysWOW64/ntdll.dll", - 'uuid' : '6A84B0BB-2C40-5240-A16B-67650BBFE6B0-02000000', + 'filename' : r"C:\Windows\System32/MSVCP120D.dll", + 'uuid' : '6E51053C-E757-EB40-8D3F-9722C5BD80DD-01000000', + }, + { + 'filename' : r"C:\Windows\System32/MSVCR120D.dll", + 'uuid' : '86FB8263-C446-4640-AE42-8D97B3F91FF2-01000000', }, ] self.assertEqual(self.target.GetNumModules(), len(expected_modules)) @@ -80,7 +80,6 @@ def test_modules_in_mini_dump(self): self.assertEqual(module.file.fullpath, expected['filename']) self.assertEqual(module.GetUUIDString(), expected['uuid']) - @expectedFailureAll(bugnumber="llvm.org/pr35193", hostoslist=["windows"]) def test_stack_info_in_mini_dump(self): """Test that we can see a trivial stack in a VS-generate mini dump.""" # target create -c fizzbuzz_no_heap.dmp diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py b/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py index 617b4bcfaec3..f485c13fa9f1 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py +++ b/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py @@ -23,7 +23,6 @@ class ProcessAttachTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @skipIfiOSSimulator - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_attach_to_process_by_id(self): """Test attach by process id""" self.build() @@ -40,7 +39,6 @@ def test_attach_to_process_by_id(self): process = target.GetProcess() self.assertTrue(process, PROCESS_IS_VALID) - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_attach_to_process_from_different_dir_by_id(self): """Test attach by process id""" newdir = self.getBuildArtifact("newdir") @@ -67,7 +65,6 @@ def test_attach_to_process_from_different_dir_by_id(self): process = target.GetProcess() self.assertTrue(process, PROCESS_IS_VALID) - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_attach_to_process_by_name(self): """Test attach by process name""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py b/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py index 06aa7b498db0..50b9fd24d0e1 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py +++ b/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py @@ -27,7 +27,6 @@ def setUp(self): @skipIfWindows # setpgid call does not exist on Windows @expectedFailureAndroid("http://llvm.org/pr23762", api_levels=[16]) @expectedFailureAll(oslist=["linux"], bugnumber="rdar://29054632") - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_setpgid(self): self.build() exe = self.getBuildArtifact("a.out") diff --git a/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c b/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c index 4053f9997276..f46862efd8b6 100644 --- a/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c +++ b/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/recursion/main.cpp b/packages/Python/lldbsuite/test/functionalities/recursion/main.cpp index f75a7f8698bb..bd5278ace7dd 100644 --- a/packages/Python/lldbsuite/test/functionalities/recursion/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/recursion/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py index d362e6a8ae3d..122afdca4be5 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py @@ -21,7 +21,6 @@ class TestYMMRegister(TestBase): @skipIfiOSSimulator @skipIfTargetAndroid() @skipIf(archs=no_match(['i386', 'x86_64'])) - @expectedFailureAll(oslist=["linux"], bugnumber="rdar://30523153") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") def test(self): self.build(dictionary={"CFLAGS_EXTRAS": "-march=haswell"}) @@ -58,7 +57,7 @@ def test(self): else: register_range = 8 for i in range(register_range): - j = i - ((i / 8) * 8) + j = i - ((i // 8) * 8) self.runCmd("thread step-inst") register_byte = (byte_pattern1 | j) diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c index 671331fe450f..c7c3a0408011 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c @@ -1,9 +1,8 @@ //===-- main.c ------------------------------------------------*- C -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp index 3e528d281eee..97b50585a525 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// //// -//// The LLVM Compiler Infrastructure -//// -//// This file is distributed under the University of Illinois Open Source -//// License. See LICENSE.TXT for details. +//// 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 //// ////===----------------------------------------------------------------------===// // diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/main.cpp b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/main.cpp index b78eb9e5a2a2..3c5ef07e4b6d 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// //// -//// The LLVM Compiler Infrastructure -//// -//// This file is distributed under the University of Illinois Open Source -//// License. See LICENSE.TXT for details. +//// 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 //// ////===----------------------------------------------------------------------===// // diff --git a/packages/Python/lldbsuite/test/functionalities/register/register_command/a.cpp b/packages/Python/lldbsuite/test/functionalities/register/register_command/a.cpp index fbacec1918e8..79f111aa2473 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/register_command/a.cpp +++ b/packages/Python/lldbsuite/test/functionalities/register/register_command/a.cpp @@ -1,9 +1,8 @@ //===-- a.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/register/register_command/main.cpp b/packages/Python/lldbsuite/test/functionalities/register/register_command/main.cpp index 156515768ddb..493a09e034da 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/register_command/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/register/register_command/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/show_location/TestShowLocationDwarf5.py b/packages/Python/lldbsuite/test/functionalities/show_location/TestShowLocationDwarf5.py new file mode 100644 index 000000000000..a56282efd77d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/show_location/TestShowLocationDwarf5.py @@ -0,0 +1,34 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + +# This test checks that source code location is shown correctly +# when DWARF5 debug information is used. + +class TestTargetSourceMap(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_source_map(self): + # Set the target soure map to map "./" to the current test directory. + yaml_path = os.path.join(self.getSourceDir(), "a.yaml") + yaml_base, ext = os.path.splitext(yaml_path) + obj_path = self.getBuildArtifact(yaml_base) + self.yaml2obj(yaml_path, obj_path) + + def cleanup(): + if os.path.exists(obj_path): + os.unlink(obj_path) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + # Create a target with the object file we just created from YAML + target = self.dbg.CreateTarget(obj_path) + + # Check we are able to show the locations properly. + self.expect("b main", VALID_BREAKPOINT_LOCATION, + substrs=['main + 13 at test.cpp:2:3, address = 0x000000000040052d']) + + self.expect("b foo", VALID_BREAKPOINT_LOCATION, + substrs=['foo() + 4 at test.cpp:6:1, address = 0x0000000000400534']) diff --git a/packages/Python/lldbsuite/test/functionalities/show_location/a.yaml b/packages/Python/lldbsuite/test/functionalities/show_location/a.yaml new file mode 100644 index 000000000000..27b119d3df63 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/show_location/a.yaml @@ -0,0 +1,58 @@ +# This file is a shorten version of the output +# produced with the following invocations and input: +# ./clang test.cpp -g -gdwarf-5 -o test.exe +# ./obj2yaml test.exe > test.yaml +# +# // test.cpp +# int main() { +# return 0; +# } +# +# void foo() { +# } + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400440 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400440 + AddressAlign: 0x0000000000000010 + Content: 31ED4989D15E4889E24883E4F0505449C7C0B005400048C7C14005400048C7C720054000E8B7FFFFFFF4660F1F44000055B820204000483D202040004889E57417B8000000004885C0740D5DBF20204000FFE00F1F4400005DC3660F1F440000BE20204000554881EE202040004889E548C1FE034889F048C1E83F4801C648D1FE7415B8000000004885C0740B5DBF20204000FFE00F1F005DC3660F1F440000803D391B0000007517554889E5E87EFFFFFFC605271B0000015DC30F1F440000F3C30F1F4000662E0F1F840000000000554889E55DEB89660F1F840000000000554889E531C0C745FC000000005DC390554889E55DC3662E0F1F840000000000415741564189FF415541544C8D25B618000055488D2DB6180000534989F64989D54C29E54883EC0848C1FD03E87FFEFFFF4885ED742031DB0F1F8400000000004C89EA4C89F64489FF41FF14DC4883C3014839EB75EA4883C4085B5D415C415D415E415FC390662E0F1F840000000000F3C3 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 200000000500000000000000230000002C0000004A0000004F000000530000005B000000 + - Name: .debug_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 636C616E672076657273696F6E20382E302E3020287472756E6B203334313935382900746573742E637070002F686F6D652F756D622F4C4C564D2F6275696C645F6C6C64622F62696E006D61696E00696E74005F5A33666F6F7600666F6F00 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 011101252513050325721710171B25110112060000022E0011011206401803253A0B3B0B49133F190000032E001101120640186E2503253A0B3B0B3F19000004240003253E0B0B0B000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 50000000050001080000000001000400010800000000000000022005400000000000160000000220054000000000000F00000001560301014F000000033005400000000000060000000156050601050404050400 + - Name: .debug_macinfo + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: '00' + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 70000000050008004C000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E021E00000000FD7C0F2E46BA561F7BDA351B04E677091E00000000FD7C0F2E46BA561F7BDA351B04E6770900090220054000000000000105030AC905003F05010A4B0202000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x0000000000000001 + Content: 2F686F6D652F756D622F4C4C564D2F6275696C645F6C6C64622F62696E00746573742E63707000 +... diff --git a/packages/Python/lldbsuite/test/functionalities/step_scripted/Makefile b/packages/Python/lldbsuite/test/functionalities/step_scripted/Makefile new file mode 100644 index 000000000000..0d70f2595019 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/step_scripted/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py b/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py new file mode 100644 index 000000000000..1383a03f4647 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py @@ -0,0 +1,37 @@ +import lldb + +class StepWithChild: + def __init__(self, thread_plan): + self.thread_plan = thread_plan + self.child_thread_plan = self.queue_child_thread_plan() + + def explains_stop(self, event): + return False + + def should_stop(self, event): + if not self.child_thread_plan.IsPlanComplete(): + return False + + self.thread_plan.SetPlanComplete(True) + + return True + + def should_step(self): + return False + + def queue_child_thread_plan(self): + return None + +class StepOut(StepWithChild): + def __init__(self, thread_plan, dict): + StepWithChild.__init__(self, thread_plan) + + def queue_child_thread_plan(self): + return self.thread_plan.QueueThreadPlanForStepOut(0) + +class StepScripted(StepWithChild): + def __init__(self, thread_plan, dict): + StepWithChild.__init__(self, thread_plan) + + def queue_child_thread_plan(self): + return self.thread_plan.QueueThreadPlanForStepScripted("Steps.StepOut") diff --git a/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py b/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py new file mode 100644 index 000000000000..a111ede6739c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py @@ -0,0 +1,41 @@ +""" +Tests stepping with scripted thread plans. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +class StepScriptedTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test_standard_step_out(self): + """Tests stepping with the scripted thread plan laying over a standard thread plan for stepping out.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + self.step_out_with_scripted_plan("Steps.StepOut") + + def test_scripted_step_out(self): + """Tests stepping with the scripted thread plan laying over an another scripted thread plan for stepping out.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + self.step_out_with_scripted_plan("Steps.StepScripted") + + def setUp(self): + TestBase.setUp(self) + self.runCmd("command script import Steps.py") + + def step_out_with_scripted_plan(self, name): + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, "Set a breakpoint here", self.main_source_file) + + frame = thread.GetFrameAtIndex(0) + self.assertEqual("foo", frame.GetFunctionName()) + + err = thread.StepUsingScriptedThreadPlan(name) + self.assertTrue(err.Success(), err.GetCString()) + + frame = thread.GetFrameAtIndex(0) + self.assertEqual("main", frame.GetFunctionName()) diff --git a/packages/Python/lldbsuite/test/functionalities/step_scripted/main.c b/packages/Python/lldbsuite/test/functionalities/step_scripted/main.c new file mode 100644 index 000000000000..88b3c17125db --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/step_scripted/main.c @@ -0,0 +1,10 @@ +#include + +void foo() { + printf("Set a breakpoint here.\n"); +} + +int main() { + foo(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp index 48190184be10..b59c063ade24 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp index 1651db2ea4a1..21c89199b9fc 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp index d3aef19f7a4f..d4578c67a261 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp index 5189218c4ef4..6284ef40811d 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp index 3c723b8a3ee3..7816385dda06 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp index e4504ad151fa..a592d51169d4 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py index 0e475a4c0068..6af6aeb0c80a 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py @@ -4,16 +4,15 @@ import lldb import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * class TestTailCallFrameSBAPI(TestBase): mydir = TestBase.compute_mydir(__file__) - # If your test case doesn't stress debug info, the - # set this to true. That way it won't be run once for - # each debug info format. - NO_DEBUG_INFO_TESTCASE = True - + @skipIf(compiler="clang", compiler_version=['<', '8.0']) + @skipIf(dwarf_version=['<', '4']) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265") def test_tail_call_frame_sbapi(self): self.build() self.do_test() @@ -43,11 +42,11 @@ def do_test(self): # Did we hit our breakpoint? threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) - self.assertTrue( - len(threads) == 1, + self.assertEqual( + len(threads), 1, "There should be a thread stopped at our breakpoint") - self.assertTrue(breakpoint.GetHitCount() == 1) + self.assertEqual(breakpoint.GetHitCount(), 1) thread = threads[0] @@ -57,9 +56,14 @@ def do_test(self): # frame #2: ... a.out`func2() at main.cpp:18:62 [opt] # frame #3: ... a.out`func1() at main.cpp:18:85 [opt] [artificial] # frame #4: ... a.out`main at main.cpp:23:3 [opt] - names = ["sink()", "func3()", "func2()", "func1()", "main"] + names = ["sink", "func3", "func2", "func1", "main"] artificiality = [False, True, False, True, False] for idx, (name, is_artificial) in enumerate(zip(names, artificiality)): frame = thread.GetFrameAtIndex(idx) - self.assertTrue(frame.GetDisplayFunctionName() == name) - self.assertTrue(frame.IsArtificial() == is_artificial) + + # Use a relaxed substring check because function dislpay names are + # platform-dependent. E.g we see "void sink(void)" on Windows, but + # "sink()" on Darwin. This seems like a bug -- just work around it + # for now. + self.assertTrue(name in frame.GetDisplayFunctionName()) + self.assertEqual(frame.IsArtificial(), is_artificial) diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp index f9e84da51739..5a2775b0deac 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp index f2f11365df7a..df43bcc98eaa 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py index c1806f62ef70..2b432e56a740 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py @@ -4,6 +4,7 @@ import lldb import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * class TestArtificialFrameThreadStepOut1(TestBase): @@ -35,11 +36,11 @@ def prepare_thread(self): # Did we hit our breakpoint? threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) - self.assertTrue( - len(threads) == 1, + self.assertEqual( + len(threads), 1, "There should be a thread stopped at our breakpoint") - self.assertTrue(breakpoint.GetHitCount() == 1) + self.assertEqual(breakpoint.GetHitCount(), 1) thread = threads[0] @@ -51,6 +52,7 @@ def prepare_thread(self): # frame #4: ... a.out`main at main.cpp:23:3 [opt] return thread + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265") def test_stepping_out_past_artificial_frame(self): self.build() thread = self.prepare_thread() @@ -59,15 +61,16 @@ def test_stepping_out_past_artificial_frame(self): # frame #2, because we behave as-if artificial frames were not present. thread.StepOut() frame2 = thread.GetSelectedFrame() - self.assertTrue(frame2.GetDisplayFunctionName() == "func2()") + self.assertEqual(frame2.GetDisplayFunctionName(), "func2()") self.assertFalse(frame2.IsArtificial()) # Ditto: stepping out of frame #2 should move to frame #4. thread.StepOut() frame4 = thread.GetSelectedFrame() - self.assertTrue(frame4.GetDisplayFunctionName() == "main") + self.assertEqual(frame4.GetDisplayFunctionName(), "main") self.assertFalse(frame2.IsArtificial()) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265") def test_return_past_artificial_frame(self): self.build() thread = self.prepare_thread() @@ -78,13 +81,13 @@ def test_return_past_artificial_frame(self): # to frame #2. thread.ReturnFromFrame(thread.GetSelectedFrame(), value) frame2 = thread.GetSelectedFrame() - self.assertTrue(frame2.GetDisplayFunctionName() == "func2()") + self.assertEqual(frame2.GetDisplayFunctionName(), "func2()") self.assertFalse(frame2.IsArtificial()) # Ditto: stepping out of frame #2 should move to frame #4. thread.ReturnFromFrame(thread.GetSelectedFrame(), value) frame4 = thread.GetSelectedFrame() - self.assertTrue(frame4.GetDisplayFunctionName() == "main") + self.assertEqual(frame4.GetDisplayFunctionName(), "main") self.assertFalse(frame2.IsArtificial()) def setUp(self): diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp index f7a81873906e..4a647031ef15 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp index c180d45b9de6..edfe59777c6c 100644 --- a/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/target_command/a.c b/packages/Python/lldbsuite/test/functionalities/target_command/a.c index 9d0706a0862d..ec4824ad4ad7 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_command/a.c +++ b/packages/Python/lldbsuite/test/functionalities/target_command/a.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/target_command/b.c b/packages/Python/lldbsuite/test/functionalities/target_command/b.c index 62ec97f43284..bcc466c8f968 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_command/b.c +++ b/packages/Python/lldbsuite/test/functionalities/target_command/b.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/target_command/c.c b/packages/Python/lldbsuite/test/functionalities/target_command/c.c index 7c362cc437af..a2cb5995aa59 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_command/c.c +++ b/packages/Python/lldbsuite/test/functionalities/target_command/c.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/target_command/globals.c b/packages/Python/lldbsuite/test/functionalities/target_command/globals.c index 6902bc415681..421b34c0cbc2 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_command/globals.c +++ b/packages/Python/lldbsuite/test/functionalities/target_command/globals.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py b/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py index 1baa30624e41..b29009ac3aa5 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py +++ b/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py @@ -10,7 +10,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - +@skipIfWindows # Windows deals differently with shared libs. class TargetDependentsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -31,14 +31,14 @@ def has_exactly_one_image(self, matching, msg=""): self.expect( "image list", msg, matching=should_match, substrs=['[ 1]']) - @skipIf(bugnumber='rdar://44831253', oslist=['linux']) + @expectedFailureAll(oslist=["linux"]) #linux does not support loading dependent files def test_dependents_implicit_default_exe(self): """Test default behavior""" exe = self.getBuildArtifact("a.out") self.runCmd("target create " + exe, CURRENT_EXECUTABLE_SET) self.has_exactly_one_image(False) - @skipIf(bugnumber='rdar://44831253', oslist=['linux']) + @expectedFailureAll(oslist=["linux"]) #linux does not support loading dependent files def test_dependents_explicit_default_exe(self): """Test default behavior""" exe = self.getBuildArtifact("a.out") @@ -52,7 +52,7 @@ def test_dependents_explicit_true_exe(self): self.runCmd("target create -dtrue " + exe, CURRENT_EXECUTABLE_SET) self.has_exactly_one_image(True) - @skipIf(bugnumber='rdar://44831253', oslist=['linux']) + @expectedFailureAll(oslist=["linux"]) #linux does not support loading dependent files def test_dependents_explicit_false_exe(self): """Test default behavior""" exe = self.getBuildArtifact("a.out") @@ -90,7 +90,7 @@ def test_dependents_explicit_true_lib(self): self.runCmd("target create -dtrue " + lib, CURRENT_EXECUTABLE_SET) self.has_exactly_one_image(True) - @skipIf(bugnumber='rdar://44831253', oslist=['linux']) + @expectedFailureAll(oslist=["linux"]) #linux does not support loading dependent files def test_dependents_explicit_false_lib(self): ctx = self.platformContext dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension diff --git a/packages/Python/lldbsuite/test/functionalities/target_create_deps/a.cpp b/packages/Python/lldbsuite/test/functionalities/target_create_deps/a.cpp index c0dac40d0eed..e80612bd5ccd 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_create_deps/a.cpp +++ b/packages/Python/lldbsuite/test/functionalities/target_create_deps/a.cpp @@ -1,9 +1,8 @@ //===-- b.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/target_create_deps/main.cpp b/packages/Python/lldbsuite/test/functionalities/target_create_deps/main.cpp index 08fbb59d8a58..7ee1981a4c27 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_create_deps/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/target_create_deps/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py b/packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py index 7a46877488fc..d3afacca72f5 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py +++ b/packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py @@ -16,6 +16,7 @@ class targetCommandTestCase(TestBase): @skipUnlessDarwin @skipIfDarwinEmbedded # needs x86_64 @skipIf(debug_info="gmodules") # not relevant + @skipIf(compiler="clang", compiler_version=['<', '7.0']) def testTargetVarExpr(self): self.build() lldbutil.run_to_name_breakpoint(self, 'main') diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp index f06761936d12..a589d979003b 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp index 8e1f8af709e1..b9499ffc1694 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py index b20b738825a2..fa96db06a59d 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py @@ -20,7 +20,6 @@ def setUp(self): TestBase.setUp(self) self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") # IO error due to breakpoint at invalid address @expectedFailureAll(triple=re.compile('^mips')) def test_step_inst_with(self): diff --git a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/main.cpp index 02f3ce338229..34cccf4dc2a4 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py index 3f26d8c76579..2afa77d34b5e 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py @@ -23,7 +23,6 @@ class CreateAfterAttachTestCase(TestBase): # Occasionally hangs on Windows, may be same as other issues. @skipIfWindows @skipIfiOSSimulator - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_create_after_attach_with_popen(self): """Test thread creation after process attach.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -34,7 +33,6 @@ def test_create_after_attach_with_popen(self): @skipIfRemote @skipIfWindows # Windows doesn't have fork. @skipIfiOSSimulator - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_create_after_attach_with_fork(self): """Test thread creation after process attach.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp index f927e3d9d496..d09bdb0ddfc9 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py index c62990ccc93a..76c2c47da2cf 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py @@ -23,9 +23,6 @@ def setUp(self): # Find the line number for our breakpoint. self.breakpoint = line_number('main.cpp', '// Set breakpoint here') - @expectedFailureAll( - oslist=["linux"], - bugnumber="llvm.org/pr15824 thread states not properly maintained") def test(self): """Test thread exit during breakpoint handling.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp index 8fc1e42e96d0..ec28678c5d60 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py index 0343a888a0f1..76488a7185de 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py @@ -18,6 +18,7 @@ class ExitDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfFreeBSD # llvm.org/pr21411: test is hanging + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test(self): """Test thread exit during step handling.""" self.build(dictionary=self.getBuildFlags()) @@ -27,6 +28,7 @@ def test(self): True) @skipIfFreeBSD # llvm.org/pr21411: test is hanging + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test_step_over(self): """Test thread exit during step-over handling.""" self.build(dictionary=self.getBuildFlags()) @@ -36,6 +38,7 @@ def test_step_over(self): False) @skipIfFreeBSD # llvm.org/pr21411: test is hanging + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test_step_in(self): """Test thread exit during step-in handling.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp index c7affd2a59ab..0e2ae00576cb 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py index 3300078e8c60..7194dafe0ac1 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py @@ -17,7 +17,6 @@ class ThreadJumpTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test(self): """Test thread jump handling.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp index 3497155a98f2..e0580bd25429 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp b/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp index 8108a52c163d..3ce9ad6548ba 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp @@ -1,9 +1,8 @@ //===-- other.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py index cff9b5a8d5e5..3d7e26816f84 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py @@ -32,9 +32,7 @@ def setUp(self): @expectedFailureAll( oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @skipIfWindows # This is flakey on Windows: llvm.org/pr24668, llvm.org/pr38373 def test(self): """Test simultaneous breakpoints in multiple threads.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp index d46038109fc2..5f884d758666 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py index 724b9d8be907..9aa4a831a745 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py @@ -64,7 +64,7 @@ def test_number_of_threads(self): 'Number of expected threads and actual threads do not match.') @skipIfDarwin # rdar://33462362 - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37658") + @skipIfWindows # This is flakey on Windows: llvm.org/pr37658, llvm.org/pr38373 def test_unique_stacks(self): """Test backtrace unique with multiple threads executing the same stack.""" self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index 0cbd94e199dc..4b1247316e18 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -51,17 +51,6 @@ def test_state_after_expression(self): self.build(dictionary=self.getBuildFlags(use_cpp11=False)) self.thread_state_after_expression_test() - # thread states not properly maintained - @unittest2.expectedFailure("llvm.org/pr16712") - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") - @skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and - def test_process_interrupt(self): - """Test process interrupt.""" - self.build(dictionary=self.getBuildFlags(use_cpp11=False)) - self.process_interrupt_test() - # thread states not properly maintained @unittest2.expectedFailure("llvm.org/pr15824 and ") @expectedFailureAll( @@ -198,13 +187,19 @@ def thread_state_after_expression_test(self): # Let the process run to completion self.runCmd("process continue") - def process_interrupt_test(self): + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and + @no_debug_info_test + def test_process_interrupt(self): """Test process interrupt and continue.""" + self.build(dictionary=self.getBuildFlags(use_cpp11=False)) exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. - lldbutil.run_break_set_by_file_and_line( + bpno = lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.break_1, num_expected_locations=1) # Run the program. @@ -218,6 +213,10 @@ def process_interrupt_test(self): process, lldb.eStopReasonBreakpoint) self.assertIsNotNone(thread) + # Remove the breakpoint to avoid the single-step-over-bkpt dance in the + # "continue" below + self.assertTrue(target.BreakpointDelete(bpno)) + # Continue, the inferior will go into an infinite loop waiting for # 'g_test' to change. self.dbg.SetAsync(True) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/state/main.cpp index 081203da8da9..63b50494bd0f 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/state/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/state/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py index 238b18837884..e786e8d7ff1e 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py @@ -25,6 +25,7 @@ class ThreadStepOutTestCase(TestBase): @expectedFailureAll( oslist=["freebsd"], bugnumber="llvm.org/pr18066 inferior does not exit") + @skipIfWindows # This test will hang on windows llvm.org/pr21753 @expectedFailureAll(oslist=["windows"]) def test_step_single_thread(self): """Test thread step out on one thread via command interpreter. """ @@ -39,6 +40,7 @@ def test_step_single_thread(self): @expectedFailureAll( oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") + @skipIfWindows # This test will hang on windows llvm.org/pr21753 @expectedFailureAll(oslist=["windows"]) @expectedFailureAll(oslist=["watchos"], archs=['armv7k'], bugnumber="rdar://problem/34674488") # stop reason is trace when it should be step-out def test_step_all_threads(self): @@ -54,6 +56,7 @@ def test_step_all_threads(self): @expectedFailureAll( oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") + @skipIfWindows # This test will hang on windows llvm.org/pr21753 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24681") def test_python(self): """Test thread step out on one thread via Python API (dwarf).""" diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp index ecc0571f2bd3..96cea183ac66 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py index 6e47c258a777..c8b6e675b8a9 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py @@ -8,7 +8,7 @@ import os import time import lldb -from lldbsuite.test import decorators +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil @@ -26,9 +26,7 @@ def setUp(self): self.break_3 = line_number('main.cpp', '// Set third breakpoint here') self.break_4 = line_number('main.cpp', '// Set fourth breakpoint here') - @decorators.expectedFailureAll( - oslist=['linux'], - bugnumber="bugs.swift.org/SR-2141") + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test(self): """Test thread exit handling.""" self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp index 432adc0ea00e..7510dd3a7ff6 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c index c082b01a57c7..108ae74d4aaa 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c +++ b/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp index 80f72ae83cf7..04735ef86ff4 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c index caa2c3cb43cd..4c88d9f0cc01 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c +++ b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m index f7c48b45422b..d15bdaa33006 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m +++ b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c index 3c17e228487b..0c3a2cf84f5f 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c index 04ebb723c3b7..5bc821314026 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py b/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py index 425166ee6ded..c4d31df0989b 100644 --- a/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py +++ b/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py @@ -33,7 +33,6 @@ class LaunchInTerminalTestCase(TestBase): 'TERM_PROGRAM' in os.environ, "test must be run on local system") @no_debug_info_test - @expectedFailureDarwin("rdar://23590073") def test_launch_in_terminal(self): self.build() exe = self.getBuildArtifact("a.out") diff --git a/packages/Python/lldbsuite/test/functionalities/type_completion/main.cpp b/packages/Python/lldbsuite/test/functionalities/type_completion/main.cpp index 80329737928e..a361df0849ad 100644 --- a/packages/Python/lldbsuite/test/functionalities/type_completion/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/type_completion/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/type_lookup/main.mm b/packages/Python/lldbsuite/test/functionalities/type_lookup/main.mm index f62e5cb5b8c9..7b005a2086d0 100644 --- a/packages/Python/lldbsuite/test/functionalities/type_lookup/main.mm +++ b/packages/Python/lldbsuite/test/functionalities/type_lookup/main.mm @@ -1,9 +1,8 @@ //===-- main.mm -----------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/divmod.cpp b/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/divmod.cpp index 75df6ba89372..b2da92e992e6 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/divmod.cpp +++ b/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/divmod.cpp @@ -1,9 +1,8 @@ //===-- divmod.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/fprintf.cpp b/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/fprintf.cpp index 188738cb9bab..f8be1aa0d400 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/fprintf.cpp +++ b/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/fprintf.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/new_delete.cpp b/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/new_delete.cpp index d240b89e50ab..b609ea366dec 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/new_delete.cpp +++ b/packages/Python/lldbsuite/test/functionalities/unwind/standard/hand_written/new_delete.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/value_md5_crash/main.cpp b/packages/Python/lldbsuite/test/functionalities/value_md5_crash/main.cpp index ba596b8653cf..b641049f2726 100644 --- a/packages/Python/lldbsuite/test/functionalities/value_md5_crash/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/value_md5_crash/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp index e20a6d988c84..ac8cf6be1660 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/main.c index 11a738a0de43..173162dd3530 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/main.c +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/main.c index fd14a9b353fc..76ad27a43145 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/main.c +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py index 7302f76c1fbc..a6d77924892b 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py @@ -22,6 +22,7 @@ class MultipleHitsTestCase(TestBase): oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") @skipIf(bugnumber="llvm.org/pr30758", oslist=["linux"], archs=["arm", "aarch64", "powerpc64le"]) + @skipIfwatchOS def test(self): self.build() exe = self.getBuildArtifact("a.out") diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp index 430c02cc052a..f99c12597eee 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp index 1bfc3b2538b2..1e6266d28770 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp index 6cb80c62217e..43e4c1a7a347 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp index f4c3527f8af2..3f7c5f5be966 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c index b20eaf494fbf..a9d1cf28da0a 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c index ac2370e32d2a..04d8a06a3546 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// typedef signed char v4i8 __attribute__ ((vector_size(4))); diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp index 796c0ef359df..e1542bc14838 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c index ed9fed1e2113..4edcf877e74c 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp b/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp index 933911f7b28d..6d1e02360563 100644 --- a/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp +++ b/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp @@ -1,9 +1,8 @@ //===-- main.cpp --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// typedef int Foo; diff --git a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py index 930a09412eab..e3ae93d3a5ba 100644 --- a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py +++ b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py @@ -70,7 +70,6 @@ def test_expr_parent(self): self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(type_y) $", "dummy = 2"]) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21550") def test_expr_null(self): self.build() self.common_setup(self.line2) diff --git a/packages/Python/lldbsuite/test/lang/c/array_types/main.c b/packages/Python/lldbsuite/test/lang/c/array_types/main.c index 5f0680a43b84..eda7dc3d6ac2 100644 --- a/packages/Python/lldbsuite/test/lang/c/array_types/main.c +++ b/packages/Python/lldbsuite/test/lang/c/array_types/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// int main (int argc, char const *argv[]) diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c index fe972dbbe856..c21cfc9a9fbe 100644 --- a/packages/Python/lldbsuite/test/lang/c/bitfields/main.c +++ b/packages/Python/lldbsuite/test/lang/c/bitfields/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py index fa14e5ef62e6..b0fde47a2c0b 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py @@ -93,6 +93,7 @@ def test_conflicting_symbols(self): "Multiple internal symbols"]) @expectedFailureAll(bugnumber="llvm.org/pr35043") + @skipIfWindows # This test is "passing" on Windows, but it is a false positive. def test_shadowed(self): self.build() exe = self.getBuildArtifact("a.out") diff --git a/packages/Python/lldbsuite/test/lang/c/enum_types/main.c b/packages/Python/lldbsuite/test/lang/c/enum_types/main.c index 59ea21300693..924336e97e0e 100644 --- a/packages/Python/lldbsuite/test/lang/c/enum_types/main.c +++ b/packages/Python/lldbsuite/test/lang/c/enum_types/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/c/function_types/main.c b/packages/Python/lldbsuite/test/lang/c/function_types/main.c index 8be3c4d46b3c..f8710f67720f 100644 --- a/packages/Python/lldbsuite/test/lang/c/function_types/main.c +++ b/packages/Python/lldbsuite/test/lang/c/function_types/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/c/global_variables/a.c b/packages/Python/lldbsuite/test/lang/c/global_variables/a.c index d169d5d63240..ce3e6f9a2d40 100644 --- a/packages/Python/lldbsuite/test/lang/c/global_variables/a.c +++ b/packages/Python/lldbsuite/test/lang/c/global_variables/a.c @@ -1,9 +1,8 @@ //===-- a.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// int g_a = 123; diff --git a/packages/Python/lldbsuite/test/lang/c/global_variables/main.c b/packages/Python/lldbsuite/test/lang/c/global_variables/main.c index b37c97bad9db..ea54eb927c0c 100644 --- a/packages/Python/lldbsuite/test/lang/c/global_variables/main.c +++ b/packages/Python/lldbsuite/test/lang/c/global_variables/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py b/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py index 576e9ecd52ad..311c5ec8e120 100644 --- a/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py +++ b/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py @@ -3,9 +3,7 @@ lldbinline.MakeInlineTest(__file__, globals(), - [decorators.expectedFailureAll(oslist=["windows"], - bugnumber="llvm.org/pr27845"), - decorators.expectedFailureAll(compiler="clang", - compiler_version=["<", - "3.5"], - bugnumber="llvm.org/pr27845")]) + [decorators.expectedFailureAll(compiler="clang", + compiler_version=["<", + "3.5"], + bugnumber="llvm.org/pr27845")]) diff --git a/packages/Python/lldbsuite/test/lang/c/set_values/main.c b/packages/Python/lldbsuite/test/lang/c/set_values/main.c index 64f01a97a286..64bc95fb5a82 100644 --- a/packages/Python/lldbsuite/test/lang/c/set_values/main.c +++ b/packages/Python/lldbsuite/test/lang/c/set_values/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py b/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py index f53a19138356..d1595163f6e3 100644 --- a/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py +++ b/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py @@ -35,12 +35,10 @@ def common_test_expr(self, preload_symbols): "expression GetMeASubFoo(my_foo_ptr)", startstr="(sub_foo *) $") - @expectedFailureAll(oslist=["windows"]) def test_expr(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.common_test_expr(True) - @expectedFailureAll(oslist=["windows"]) def test_expr_no_preload(self): """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled""" self.common_test_expr(False) diff --git a/packages/Python/lldbsuite/test/lang/c/stepping/main.c b/packages/Python/lldbsuite/test/lang/c/stepping/main.c index d8b4a2da761e..fce61bfd93ea 100644 --- a/packages/Python/lldbsuite/test/lang/c/stepping/main.c +++ b/packages/Python/lldbsuite/test/lang/c/stepping/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py index b1c8a5ecf4bf..597a247178e4 100644 --- a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py +++ b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py @@ -11,7 +11,6 @@ class CStringsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_with_run_command(self): """Tests that C strings work as expected in expressions""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/c/strings/main.c b/packages/Python/lldbsuite/test/lang/c/strings/main.c index e02580b407f5..3e7ead084786 100644 --- a/packages/Python/lldbsuite/test/lang/c/strings/main.c +++ b/packages/Python/lldbsuite/test/lang/c/strings/main.c @@ -1,9 +1,8 @@ //===-- main.c ----------------------------------------------------*- C -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py b/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py index af362f5be5d7..c8308c16011e 100644 --- a/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py +++ b/packages/Python/lldbsuite/test/lang/c/struct_types/TestStructTypes.py @@ -1,7 +1,4 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest( - __file__, globals(), [ - decorators.expectedFailureAll( - oslist=["windows"], bugnumber="llvm.org/pr24764")]) +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/packages/Python/lldbsuite/test/lang/c/struct_types/main.c b/packages/Python/lldbsuite/test/lang/c/struct_types/main.c index 02fefd36ceee..f166232b755a 100644 --- a/packages/Python/lldbsuite/test/lang/c/struct_types/main.c +++ b/packages/Python/lldbsuite/test/lang/c/struct_types/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c b/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c index ab1022514d1e..00803964e612 100644 --- a/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c +++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/a.c @@ -1,9 +1,8 @@ //===-- a.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c b/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c index 73e32ca39a58..c9c1e681dc0e 100644 --- a/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c +++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/c/typedef/main.c b/packages/Python/lldbsuite/test/lang/c/typedef/main.c index 62f8a00e6644..467612e9b37b 100644 --- a/packages/Python/lldbsuite/test/lang/c/typedef/main.c +++ b/packages/Python/lldbsuite/test/lang/c/typedef/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// void test() diff --git a/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py b/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py index 2024009e4717..beb87728404d 100644 --- a/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py +++ b/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py @@ -10,6 +10,7 @@ class TestUnicodeSymbols(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(compiler="clang", compiler_version=['<', '7.0'], debug_info="dsym") + def test_union_members(self): self.build() spec = lldb.SBModuleSpec() diff --git a/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py b/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py index 0d3a0a69a505..f6341ec24fa6 100644 --- a/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py +++ b/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py @@ -1,5 +1,6 @@ import lldb from lldbsuite.test.lldbtest import * +from lldbsuite.test import decorators import lldbsuite.test.lldbutil as lldbutil @@ -7,6 +8,7 @@ class TestVLA(TestBase): mydir = TestBase.compute_mydir(__file__) + @decorators.skipIf(compiler="clang", compiler_version=['<', '8.0']) def test_vla(self): self.build() _, process, _, _ = lldbutil.run_to_source_breakpoint( diff --git a/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp index 6aee25c21608..d411af679119 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/bool/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/bool/main.cpp index 88d02d5b2894..a14cc690da78 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/bool/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/bool/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py index 9b227bc8d3c8..b6274b3d2669 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py +++ b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py @@ -16,9 +16,6 @@ def setUp(self): TestBase.setUp(self) self.line = line_number('main.cpp', '// breakpoint') - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test calling a function by basename""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py index a344c4f7d18a..080c051de98f 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py +++ b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py @@ -8,7 +8,6 @@ class TestCppChainedCalls(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_with_run_command(self): self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp index b92c2d572923..8cd0cfc77c5a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py index 61850e5b9c33..c16cc4a71698 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py @@ -3,9 +3,7 @@ lldbinline.MakeInlineTest( __file__, globals(), [ - decorators.expectedFailureAll( - oslist=["windows"], bugnumber="llvm.org/pr24764"), decorators.expectedFailureAll( compiler="gcc"), decorators.expectedFailureAll( - bugnumber="rdar://problem/31811802")]) + bugnumber="rdar://47370292")]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp index 90e63b40f417..1f25b0206b30 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LIDENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py index 97b0bfd8aee0..eead3c509ff0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py @@ -23,7 +23,6 @@ def setUp(self): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_run_command(self): """Test that file and class static variables display correctly.""" self.build() @@ -63,7 +62,6 @@ def test_with_run_command(self): compiler=["clang"], compiler_version=["<", "3.9"], bugnumber='llvm.org/pr20550') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_run_command_complete(self): """ Test that file and class static variables display correctly with @@ -108,8 +106,8 @@ def test_with_run_command_complete(self): compiler=["clang"], compiler_version=["<", "3.9"], bugnumber='llvm.org/pr20550') - @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + @add_test_categories(['pyapi']) def test_with_python_api(self): """Test Python APIs on file and class static variables.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_static/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class_static/main.cpp index 2068eadcac5f..319a05a7beec 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_static/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/class_static/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp index 2d02cbe0f055..179f21777932 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp index 7614977b245f..c244e1bf44e5 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/const_this/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/diamond/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/diamond/main.cpp index bfe098a089f5..31329b271e2a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/diamond/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/diamond/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp index 00fd7dad438c..9e03594a7346 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp @@ -1,9 +1,8 @@ //===-- sbvalue-cast.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #ifdef DO_VIRTUAL_INHERITANCE diff --git a/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py b/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py index fbd1832080c7..a8a2f5f6b1bd 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py @@ -16,6 +16,7 @@ class CPP11EnumTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_int8_t(self): """Test C++11 enumeration class types as int8_t types.""" self.build( @@ -24,6 +25,7 @@ def test_int8_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_int16_t(self): """Test C++11 enumeration class types as int16_t types.""" self.build( @@ -32,6 +34,7 @@ def test_int16_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_int32_t(self): """Test C++11 enumeration class types as int32_t types.""" self.build( @@ -40,6 +43,7 @@ def test_int32_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_int64_t(self): """Test C++11 enumeration class types as int64_t types.""" self.build( @@ -48,6 +52,7 @@ def test_int64_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_uint8_t(self): """Test C++11 enumeration class types as uint8_t types.""" self.build( @@ -56,6 +61,7 @@ def test_uint8_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_uint16_t(self): """Test C++11 enumeration class types as uint16_t types.""" self.build( @@ -64,6 +70,7 @@ def test_uint16_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_uint32_t(self): """Test C++11 enumeration class types as uint32_t types.""" self.build( @@ -72,6 +79,7 @@ def test_uint32_t(self): self.image_lookup_for_enum_type() @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') + @skipIf(dwarf_version=['<', '4']) def test_uint64_t(self): """Test C++11 enumeration class types as uint64_t types.""" self.build( diff --git a/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp index 8595050afbbf..31d130cce904 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/enum_types/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp index a4006c2f7ed1..47769014d493 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/extern_c/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/main.cpp index 494b846336ff..2489506b2803 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp index e802d40e5f8b..eea2830aef8d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LIDENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/function_refs/TestFunctionRefs.py b/packages/Python/lldbsuite/test/lang/cpp/function_refs/TestFunctionRefs.py index c8308c16011e..293e91396370 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/function_refs/TestFunctionRefs.py +++ b/packages/Python/lldbsuite/test/lang/cpp/function_refs/TestFunctionRefs.py @@ -1,4 +1,5 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals()) +lldbinline.MakeInlineTest(__file__, globals(), + lldbinline.expectedFailureAll(oslist=["windows"])) diff --git a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py index fa68d0a15021..4ead709cf565 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py +++ b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py @@ -49,7 +49,6 @@ def prepare_executable_and_get_frame(self): return thread.GetSelectedFrame() - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_equals_operator(self): frame = self.prepare_executable_and_get_frame() @@ -87,7 +86,6 @@ def do_new_test(self, frame, expr, expected_value_name): self.assertTrue(got_type.IsPointerType()) self.assertEqual(got_type.GetPointeeType().GetName(), "Struct") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") def test_operator_new(self): frame = self.prepare_executable_and_get_frame() diff --git a/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py b/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py index 284caabbc17b..c8308c16011e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py +++ b/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py @@ -1,7 +1,4 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest( - __file__, globals(), [ - lldbinline.expectedFailureAll( - oslist=["windows"])]) +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp index 0432cc1357da..5870c877f4a9 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/lambdas/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/llvm-style/TestLLVMStyle.py b/packages/Python/lldbsuite/test/lang/cpp/llvm-style/TestLLVMStyle.py index af362f5be5d7..c8308c16011e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/llvm-style/TestLLVMStyle.py +++ b/packages/Python/lldbsuite/test/lang/cpp/llvm-style/TestLLVMStyle.py @@ -1,7 +1,4 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest( - __file__, globals(), [ - decorators.expectedFailureAll( - oslist=["windows"], bugnumber="llvm.org/pr24764")]) +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/llvm-style/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/llvm-style/main.cpp index 21ce8ca7080c..048eeb2d27bb 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/llvm-style/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/llvm-style/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LIDENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py index 2837cfd9244e..9c65966b348a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py @@ -42,11 +42,9 @@ def runToBkpt(self, command): 'stop reason = breakpoint']) @expectedFailureAll( - oslist=[ - "windows", - "linux", - "freebsd"], + oslist=["freebsd"], bugnumber="llvm.org/pr25819") + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test_scope_lookup_with_run_command(self): """Test scope lookup of functions in lldb.""" self.build() @@ -185,6 +183,7 @@ def test_function_scope_lookup_with_run_command(self): self.expect("expr -- foo()", startstr="(int) $2 = 42") @unittest2.expectedFailure("lldb file scope lookup bugs") + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test_file_scope_lookup_with_run_command(self): """Test file scope lookup in lldb.""" self.build() @@ -204,7 +203,7 @@ def test_file_scope_lookup_with_run_command(self): # finds the global ::func(). self.expect("expr -- func()", startstr="(int) $0 = 2") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr25819") + @skipIfWindows # This is flakey on Windows: llvm.org/pr38373 def test_scope_lookup_before_using_with_run_command(self): """Test scope lookup before using in lldb.""" self.build() @@ -230,10 +229,7 @@ def test_scope_lookup_before_using_with_run_command(self): oslist=["linux"], debug_info=["dwo"]) # Skip to avoid crash @expectedFailureAll( - oslist=[ - "windows", - "linux", - "freebsd"], + oslist=["freebsd"], bugnumber="llvm.org/pr25819") def test_scope_after_using_directive_lookup_with_run_command(self): """Test scope lookup after using directive in lldb.""" @@ -297,10 +293,7 @@ def test_scope_ambiguity_after_using_lookup_with_run_command(self): self.expect("expr -- func()", startstr="error") @expectedFailureAll( - oslist=[ - "windows", - "linux", - "freebsd"], + oslist=["freebsd"], bugnumber="llvm.org/pr25819") def test_scope_lookup_shadowed_by_using_with_run_command(self): """Test scope lookup shadowed by using in lldb.""" diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp index 9f5eb06cccd4..22c0309695c9 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp index bb7731cf87b8..481a9866fcb6 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp @@ -1,9 +1,8 @@ //===-- ns.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h index a0f9be88216a..d04b45a7d7ab 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h @@ -1,9 +1,8 @@ //===-- ns.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp index 0051d478395d..9aae5d0a495c 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp @@ -1,9 +1,8 @@ //===-- ns2.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp index 205e1931f3e0..0f7a5050fde4 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp @@ -1,9 +1,8 @@ //===-- ns3.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/TestNamespaceConflicts.py b/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/TestNamespaceConflicts.py index af362f5be5d7..c8308c16011e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/TestNamespaceConflicts.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/TestNamespaceConflicts.py @@ -1,7 +1,4 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators -lldbinline.MakeInlineTest( - __file__, globals(), [ - decorators.expectedFailureAll( - oslist=["windows"], bugnumber="llvm.org/pr24764")]) +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/main.cpp index 062c4430be70..192a7ae8664e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_conflicts/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp index 2ea0d2df2eca..2795b206e8e7 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.cpp @@ -1,9 +1,8 @@ //===-- a.cpp ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp index 6e7b41e00164..b676865c4d2a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.cpp @@ -1,9 +1,8 @@ //===-- b.cpp ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h index 76b8e70880ec..a2c64ab59289 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/foo.h @@ -1,9 +1,8 @@ //===-- foo.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp index 076814eae1de..8703cd99246a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py index 7f68eb8923eb..ad969ef3d088 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py @@ -16,9 +16,6 @@ def setUp(self): TestBase.setUp(self) self.line = line_number('main.cpp', '// breakpoint') - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test that functions with the same name are resolved correctly""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp index badf1be0b41f..27395eb6f41d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/printf/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py index cc79366c7149..5e31d93eb163 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py +++ b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py @@ -16,9 +16,6 @@ class RvalueReferencesTestCase(TestBase): @expectedFailureAll( compiler="icc", bugnumber="ICC (13.1, 14-beta) do not emit DW_TAG_rvalue_reference_type.") - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_with_run_command(self): """Test that rvalues are supported in the C++ expression parser""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py index c7afeb2dbb6f..213e7fbe9022 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py +++ b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py @@ -15,7 +15,7 @@ class TestCppScopes(TestBase): def test_all_but_c(self): self.do_test(False) - @expectedFailureAll(oslist=["windows"]) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_c(self): self.do_test(True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/signed_types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/signed_types/main.cpp index dbf3606aeba8..4f180bbbd136 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/signed_types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/signed_types/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_members/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/static_members/main.cpp index 7ccc2f9a328b..ab8ae1b645f1 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_members/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/static_members/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py index 404ef22a0b8c..4b422674134c 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py @@ -16,7 +16,6 @@ def setUp(self): TestBase.setUp(self) self.line = line_number('main.cpp', '// Break at this line') - @expectedFailureAll(oslist=["windows"]) def test_with_run_command(self): """Test that static methods are properly distinguished from regular methods""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_methods/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/static_methods/main.cpp index 5141a407d111..4c57e09296c9 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_methods/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/static_methods/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py b/packages/Python/lldbsuite/test/lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py index 3a9c9bb05b1f..abd35acd15bb 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py +++ b/packages/Python/lldbsuite/test/lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py @@ -12,7 +12,7 @@ from lldbsuite.test import lldbutil -class LibCxxFunctionTestCase(TestBase): +class LibCxxFunctionSteppingIntoCallableTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py index 42c372489c63..d11004e66d0a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py @@ -26,6 +26,7 @@ def setUp(self): self.line = line_number( self.source, '// Set break point at this line.') + @skipIf @expectedFailureAll(bugnumber="llvm.org/PR36713") def test(self): """Test some expressions involving STL data types.""" diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp index cfdb7b2d3db5..89895196b15d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/cpp/symbols/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/symbols/main.cpp index 292f9f64bcca..cbd3ab253d6a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/symbols/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/symbols/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LIDENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py index 7dd2bbc215ce..08132702b8d8 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py +++ b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py @@ -47,7 +47,6 @@ def prepareProcess(self): # Get frame for current thread return thread.GetSelectedFrame() - @expectedFailureAll(oslist=["windows"]) def test_integer_args(self): frame = self.prepareProcess() @@ -111,12 +110,10 @@ def test_template_template_args(self): self.assertTrue(f4.GetType().GetName() == 'int') self.assertTrue(f4.GetValue() == '42') - # Gcc does not generate the necessary DWARF attribute for enum template # parameters. @expectedFailureAll(bugnumber="llvm.org/pr28354", compiler="gcc") - @expectedFailureAll(oslist=["windows"]) - @expectedFailureAll + @skipIf(dwarf_version=['<', '4']) def test_enum_args(self): frame = self.prepareProcess() diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp index 40825cd7c1a6..445a34fe0676 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp index 4448a5cadf57..4026de0222fc 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py index 94d52e368e8c..7fa3f95ae9a7 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py @@ -52,23 +52,23 @@ def test_namespace_only(self): self.assertTrue(expr_result.GetError().Fail(), "'namespace_only' exists in namespace only") - # Make sure we can find the correct type in a namespace "a" - expr_result = frame.EvaluateExpression("*((a::namespace_only *)&i)") + # Make sure we can find the correct type in a namespace "nsp_a" + expr_result = frame.EvaluateExpression("*((nsp_a::namespace_only *)&i)") self.check_value(expr_result, "a", 123) - # Make sure we can find the correct type in a namespace "b" - expr_result = frame.EvaluateExpression("*((b::namespace_only *)&i)") + # Make sure we can find the correct type in a namespace "nsp_b" + expr_result = frame.EvaluateExpression("*((nsp_b::namespace_only *)&i)") self.check_value(expr_result, "b", 123) # Make sure we can find the correct type in the root namespace expr_result = frame.EvaluateExpression("*((namespace_and_file *)&i)") self.check_value(expr_result, "ff", 123) - # Make sure we can find the correct type in a namespace "a" + # Make sure we can find the correct type in a namespace "nsp_a" expr_result = frame.EvaluateExpression( - "*((a::namespace_and_file *)&i)") + "*((nsp_a::namespace_and_file *)&i)") self.check_value(expr_result, "aa", 123) - # Make sure we can find the correct type in a namespace "b" + # Make sure we can find the correct type in a namespace "nsp_b" expr_result = frame.EvaluateExpression( - "*((b::namespace_and_file *)&i)") + "*((nsp_b::namespace_and_file *)&i)") self.check_value(expr_result, "bb", 123) # Make sure we don't accidentally accept structures that exist only @@ -84,11 +84,11 @@ def test_namespace_only(self): expr_result = frame.EvaluateExpression( "*((contains_type::in_contains_type *)&i)") self.check_value(expr_result, "fff", 123) - # Make sure we can find the correct type in a namespace "a" + # Make sure we can find the correct type in a namespace "nsp_a" expr_result = frame.EvaluateExpression( - "*((a::contains_type::in_contains_type *)&i)") + "*((nsp_a::contains_type::in_contains_type *)&i)") self.check_value(expr_result, "aaa", 123) - # Make sure we can find the correct type in a namespace "b" + # Make sure we can find the correct type in a namespace "nsp_b" expr_result = frame.EvaluateExpression( - "*((b::contains_type::in_contains_type *)&i)") + "*((nsp_b::contains_type::in_contains_type *)&i)") self.check_value(expr_result, "bbb", 123) diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp index b244e80962c8..f2803e361525 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,7 +10,7 @@ // levels in the code and test that we can properly locate these types with // a varienty of different expressions. -namespace a { +namespace nsp_a { struct namespace_only { int a; }; @@ -24,7 +23,7 @@ namespace a { }; }; }; -namespace b { +namespace nsp_b { struct namespace_only { int b; }; @@ -50,12 +49,12 @@ struct contains_type { int main (int argc, char const *argv[]) { - a::namespace_only a_namespace_only = { 1 }; - a::namespace_and_file a_namespace_and_file = { 2 }; - a::contains_type::in_contains_type a_in_contains_type = { 3 }; - b::namespace_only b_namespace_only = { 11 }; - b::namespace_and_file b_namespace_and_file = { 22 }; - b::contains_type::in_contains_type b_in_contains_type = { 33 }; + nsp_a::namespace_only a_namespace_only = { 1 }; + nsp_a::namespace_and_file a_namespace_and_file = { 2 }; + nsp_a::contains_type::in_contains_type a_in_contains_type = { 3 }; + nsp_b::namespace_only b_namespace_only = { 11 }; + nsp_b::namespace_and_file b_namespace_and_file = { 22 }; + nsp_b::contains_type::in_contains_type b_in_contains_type = { 33 }; namespace_and_file file_namespace_and_file = { 44 }; contains_type::in_contains_type file_in_contains_type = { 55 }; int i = 123; // Provide an integer that can be used for casting diff --git a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py index 216f86064dca..1a50c9dfc69f 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py @@ -31,25 +31,16 @@ class UnicodeLiteralsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_expr1(self): """Test that the expression parser returns proper Unicode strings.""" self.build() self.rdar12991846(expr=1) - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_expr2(self): """Test that the expression parser returns proper Unicode strings.""" self.build() self.rdar12991846(expr=2) - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") def test_expr3(self): """Test that the expression parser returns proper Unicode strings.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/main.cpp index fda951a78991..a98fb44e5f48 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/cpp/unique-types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/unique-types/main.cpp index c551c0e2c0d4..839fd93f764c 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unique-types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/unique-types/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/main.cpp index b0d68377e983..8d0a0c386e31 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// int main (int argc, char const *argv[]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py index b3fe9c40c198..365eb829ba64 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py @@ -36,6 +36,7 @@ def setUp(self): @expectedFailureAll( compiler="icc", bugnumber="llvm.org/pr16808 lldb does not call the correct virtual function with icc.") + @skipIfWindows # This test will hang on windows llvm.org/pr21753 def test_virtual_madness(self): """Test that expression works correctly with virtual inheritance as well as virtual function.""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/cpp/wchar_t/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/wchar_t/main.cpp index e249c37b678f..4d6a1072d695 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/wchar_t/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/wchar_t/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py b/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py index 2ba57e61349f..a69e8a7aa1f9 100644 --- a/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py +++ b/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py @@ -35,7 +35,7 @@ def cleanup(): self.format_string = m.group(1) # Change the default format to print the language. - format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, lang=${language}}\n" + format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n" self.runCmd("settings set frame-format %s" % format_string) self.expect("settings show frame-format", SETTING_MSG("frame-format"), substrs=[format_string]) diff --git a/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m index 9ee3bbe66770..e19f291ecf98 100644 --- a/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m +++ b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/main.m @@ -1,9 +1,8 @@ //===-- main.m -------------------------------------------*- Objective-C-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py b/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py index d69a171bc7b8..d2798d601f78 100644 --- a/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py +++ b/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py @@ -25,6 +25,7 @@ def setUp(self): @skipUnlessDarwin @add_test_categories(['pyapi']) + @skipIf(dwarf_version=['<', '4']) @expectedFailureAll( archs=["i[3-6]86"], bugnumber="This test requires the 2.0 runtime, so it will fail on i386") diff --git a/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile b/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile new file mode 100644 index 000000000000..261658b10ae8 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile @@ -0,0 +1,9 @@ +LEVEL = ../../../make + +OBJCXX_SOURCES := main.mm + +CFLAGS_EXTRAS += -w + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py b/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py new file mode 100644 index 000000000000..aa64606968f8 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py @@ -0,0 +1,205 @@ +# encoding: utf-8 +""" +Test lldb Obj-C exception support. +""" + +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ObjCExceptionsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test_objc_exceptions_at_throw(self): + self.build() + + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + launch_info = lldb.SBLaunchInfo(["a.out", "0"]) + lldbutil.run_to_name_breakpoint(self, "objc_exception_throw", launch_info=launch_info) + + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + self.expect('thread exception', substrs=[ + '(NSException *) exception = ', + 'name: "ThrownException" - reason: "SomeReason"', + ]) + + target = self.dbg.GetSelectedTarget() + thread = target.GetProcess().GetSelectedThread() + frame = thread.GetSelectedFrame() + + opts = lldb.SBVariablesOptions() + opts.SetIncludeRecognizedArguments(True) + variables = frame.GetVariables(opts) + + self.assertEqual(variables.GetSize(), 1) + self.assertEqual(variables.GetValueAtIndex(0).name, "exception") + + lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.mm"), launch_info=launch_info) + + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + target = self.dbg.GetSelectedTarget() + thread = target.GetProcess().GetSelectedThread() + frame = thread.GetSelectedFrame() + + # No exception being currently thrown/caught at this point + self.assertFalse(thread.GetCurrentException().IsValid()) + self.assertFalse(thread.GetCurrentExceptionBacktrace().IsValid()) + + self.expect( + 'frame variable e1', + substrs=[ + '(NSException *) e1 = ', + 'name: "ExceptionName" - reason: "SomeReason"' + ]) + + self.expect( + 'frame variable --dynamic-type no-run-target *e1', + substrs=[ + '(NSException) *e1 = ', + 'name = ', '"ExceptionName"', + 'reason = ', '"SomeReason"', + 'userInfo = ', '1 key/value pair', + 'reserved = ', 'nil', + ]) + + e1 = frame.FindVariable("e1") + self.assertTrue(e1) + self.assertEqual(e1.type.name, "NSException *") + self.assertEqual(e1.GetSummary(), 'name: "ExceptionName" - reason: "SomeReason"') + self.assertEqual(e1.GetChildMemberWithName("name").description, "ExceptionName") + self.assertEqual(e1.GetChildMemberWithName("reason").description, "SomeReason") + userInfo = e1.GetChildMemberWithName("userInfo").dynamic + self.assertEqual(userInfo.summary, "1 key/value pair") + self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(0).description, "some_key") + self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(1).description, "some_value") + self.assertEqual(e1.GetChildMemberWithName("reserved").description, "") + + self.expect( + 'frame variable e2', + substrs=[ + '(NSException *) e2 = ', + 'name: "ThrownException" - reason: "SomeReason"' + ]) + + self.expect( + 'frame variable --dynamic-type no-run-target *e2', + substrs=[ + '(NSException) *e2 = ', + 'name = ', '"ThrownException"', + 'reason = ', '"SomeReason"', + 'userInfo = ', '1 key/value pair', + 'reserved = ', + ]) + + e2 = frame.FindVariable("e2") + self.assertTrue(e2) + self.assertEqual(e2.type.name, "NSException *") + self.assertEqual(e2.GetSummary(), 'name: "ThrownException" - reason: "SomeReason"') + self.assertEqual(e2.GetChildMemberWithName("name").description, "ThrownException") + self.assertEqual(e2.GetChildMemberWithName("reason").description, "SomeReason") + userInfo = e2.GetChildMemberWithName("userInfo").dynamic + self.assertEqual(userInfo.summary, "1 key/value pair") + self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(0).description, "some_key") + self.assertEqual(userInfo.GetChildAtIndex(0).GetChildAtIndex(1).description, "some_value") + reserved = e2.GetChildMemberWithName("reserved").dynamic + self.assertGreater(reserved.num_children, 0) + callStackReturnAddresses = [reserved.GetChildAtIndex(i).GetChildAtIndex(1) for i in range(0, reserved.GetNumChildren()) + if reserved.GetChildAtIndex(i).GetChildAtIndex(0).description == "callStackReturnAddresses"][0].dynamic + children = [callStackReturnAddresses.GetChildAtIndex(i) for i in range(0, callStackReturnAddresses.num_children)] + + pcs = [i.unsigned for i in children] + names = [target.ResolveSymbolContextForAddress(lldb.SBAddress(pc, target), lldb.eSymbolContextSymbol).GetSymbol().name for pc in pcs] + for n in ["objc_exception_throw", "foo(int)", "main"]: + self.assertTrue(n in names, "%s is in the exception backtrace (%s)" % (n, names)) + + @skipUnlessDarwin + def test_objc_exceptions_at_abort(self): + self.build() + + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + self.runCmd("run 0") + + # We should be stopped at pthread_kill because of an unhandled exception + self.expect("thread list", + substrs=['stopped', 'stop reason = signal SIGABRT']) + + self.expect('thread exception', substrs=[ + '(NSException *) exception = ', + 'name: "ThrownException" - reason: "SomeReason"', + 'libobjc.A.dylib`objc_exception_throw', + 'a.out`foo', 'at main.mm:24', + 'a.out`rethrow', 'at main.mm:35', + 'a.out`main', + ]) + + process = self.dbg.GetSelectedTarget().process + thread = process.GetSelectedThread() + + # There is an exception being currently processed at this point + self.assertTrue(thread.GetCurrentException().IsValid()) + self.assertTrue(thread.GetCurrentExceptionBacktrace().IsValid()) + + history_thread = thread.GetCurrentExceptionBacktrace() + self.assertGreaterEqual(history_thread.num_frames, 4) + for n in ["objc_exception_throw", "foo(int)", "rethrow(int)", "main"]: + self.assertEqual(len([f for f in history_thread.frames if f.GetFunctionName() == n]), 1) + + self.runCmd("kill") + + self.runCmd("run 1") + # We should be stopped at pthread_kill because of an unhandled exception + self.expect("thread list", + substrs=['stopped', 'stop reason = signal SIGABRT']) + + self.expect('thread exception', substrs=[ + '(MyCustomException *) exception = ', + 'libobjc.A.dylib`objc_exception_throw', + 'a.out`foo', 'at main.mm:26', + 'a.out`rethrow', 'at main.mm:35', + 'a.out`main', + ]) + + process = self.dbg.GetSelectedTarget().process + thread = process.GetSelectedThread() + + history_thread = thread.GetCurrentExceptionBacktrace() + self.assertGreaterEqual(history_thread.num_frames, 4) + for n in ["objc_exception_throw", "foo(int)", "rethrow(int)", "main"]: + self.assertEqual(len([f for f in history_thread.frames if f.GetFunctionName() == n]), 1) + + @skipUnlessDarwin + def test_cxx_exceptions_at_abort(self): + self.build() + + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + self.runCmd("run 2") + + # We should be stopped at pthread_kill because of an unhandled exception + self.expect("thread list", + substrs=['stopped', 'stop reason = signal SIGABRT']) + + self.expect('thread exception', substrs=[]) + + process = self.dbg.GetSelectedTarget().process + thread = process.GetSelectedThread() + + # C++ exceptions are not exposed in the API (yet). + self.assertFalse(thread.GetCurrentException().IsValid()) + self.assertFalse(thread.GetCurrentExceptionBacktrace().IsValid()) diff --git a/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm b/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm new file mode 100644 index 000000000000..b5c71f9fcf9f --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm @@ -0,0 +1,62 @@ +//===-- main.m ------------------------------------------------*- ObjC -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#import + +#import +#import + +@interface MyCustomException: NSException +@end +@implementation MyCustomException +@end + +void foo(int n) +{ + NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"some_value", @"some_key", nil]; + switch (n) { + case 0: + @throw [[NSException alloc] initWithName:@"ThrownException" reason:@"SomeReason" userInfo:info]; + case 1: + @throw [[MyCustomException alloc] initWithName:@"ThrownException" reason:@"SomeReason" userInfo:info]; + case 2: + throw std::runtime_error("C++ exception"); + } +} + +void rethrow(int n) +{ + @try { + foo(n); + } @catch(NSException *e) { + @throw; + } +} + +int main(int argc, const char * argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"some_value", @"some_key", nil]; + NSException *e1 = [[NSException alloc] initWithName:@"ExceptionName" reason:@"SomeReason" userInfo:info]; + NSException *e2; + + @try { + foo(atoi(argv[1])); + } @catch(NSException *e) { + e2 = e; + } + + NSLog(@"1"); // Set break point at this line. + + rethrow(atoi(argv[1])); + + [pool drain]; + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py index 7831827c4c55..bffe5d15e940 100644 --- a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py @@ -10,11 +10,11 @@ import re import lldb -from lldbsuite.support import seven from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ObjCiVarIMPTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py index 29d386253fb4..e9dbe6af864f 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py @@ -23,8 +23,6 @@ class ModulesInlineFunctionsTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break inside main(). - self.line = line_number('main.m', '// Set breakpoint here.') @skipUnlessDarwin @skipIf(macos_version=["<", "10.12"], debug_info=no_match(["gmodules"])) @@ -34,19 +32,8 @@ def test_expr(self): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. - lldbutil.run_break_set_by_file_and_line( - self, "main.m", self.line, num_expected_locations=1, loc_exact=True) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) - - # The breakpoint should have a hit count of 1. - self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs=[' resolved, hit count = 1']) + lldbutil.run_to_source_breakpoint( + self, '// Set breakpoint here.', lldb.SBFileSpec('main.m')) self.runCmd( "settings set target.clang-module-search-paths \"" + diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py b/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py index 340d8849efa9..c7e012db1461 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py @@ -1,7 +1,6 @@ """ Test that objective-c expression parser continues to work for optimized build. -http://llvm.org/viewvc/llvm-project?rev=126973&view=rev Fixed a bug in the expression parser where the 'this' or 'self' variable was not properly read if the compiler optimized it into a register. diff --git a/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m b/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m index ba2497554444..587712640620 100644 --- a/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m +++ b/packages/Python/lldbsuite/test/lang/objc/print-obj/blocked.m @@ -1,9 +1,8 @@ //===-- blocked.m --------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m index 8203165e4971..94bf0fb9fc55 100644 --- a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m +++ b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h b/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h index 20a81faa1017..5ee6acb2425e 100644 --- a/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h +++ b/packages/Python/lldbsuite/test/lang/objc/real-definition/Bar.h @@ -9,4 +9,4 @@ - (NSString *)description; -@end \ No newline at end of file +@end diff --git a/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h b/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h index 14ff9eed50fd..d58da600765a 100644 --- a/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h +++ b/packages/Python/lldbsuite/test/lang/objc/real-definition/Foo.h @@ -8,4 +8,4 @@ - (NSString *)description; -@end \ No newline at end of file +@end diff --git a/packages/Python/lldbsuite/test/lang/objc/self/main.m b/packages/Python/lldbsuite/test/lang/objc/self/main.m index 928aaf2ff024..8f4e61202a35 100644 --- a/packages/Python/lldbsuite/test/lang/objc/self/main.m +++ b/packages/Python/lldbsuite/test/lang/objc/self/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------*- Objective-C -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m b/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m index f48710e880f3..609d783dd595 100644 --- a/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m +++ b/packages/Python/lldbsuite/test/lang/objc/variadic_methods/main.m @@ -1,9 +1,8 @@ //===-- main.m -------------------------------------------*- Objective-C-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lang/swift/any/TestSwiftAnyType.py b/packages/Python/lldbsuite/test/lang/swift/any/TestSwiftAnyType.py index 95e6f798d1f7..15db3d2f88ee 100644 --- a/packages/Python/lldbsuite/test/lang/swift/any/TestSwiftAnyType.py +++ b/packages/Python/lldbsuite/test/lang/swift/any/TestSwiftAnyType.py @@ -25,7 +25,6 @@ class TestSwiftAnyType(lldbtest.TestBase): mydir = lldbtest.TestBase.compute_mydir(__file__) @swiftTest - @expectedFailureAll(oslist=["linux"], bugnumber="rdar://35671239") def test_any_type(self): """Test the Any type""" self.build() diff --git a/packages/Python/lldbsuite/test/lang/swift/backwards_compatibility/simple/TestSwiftBackwardsCompatibilitySimple.py b/packages/Python/lldbsuite/test/lang/swift/backwards_compatibility/simple/TestSwiftBackwardsCompatibilitySimple.py index 04c20d925968..80ef773ae419 100644 --- a/packages/Python/lldbsuite/test/lang/swift/backwards_compatibility/simple/TestSwiftBackwardsCompatibilitySimple.py +++ b/packages/Python/lldbsuite/test/lang/swift/backwards_compatibility/simple/TestSwiftBackwardsCompatibilitySimple.py @@ -14,6 +14,7 @@ import lldbsuite.test.lldbtest as lldbtest import lldbsuite.test.lldbutil as lldbutil import os +import swift import unittest2 @@ -25,7 +26,11 @@ class TestSwiftBackwardsCompatibilitySimple(lldbtest.TestBase): @skipIf(compiler="swiftc", compiler_version=['<', '5.0']) @add_test_categories(["swiftpr", "swift-history"]) def test_simple(self): - version = self.getCompilerVersion(os.environ['SWIFTC']) + if 'SWIFTC' in os.environ: + compiler = os.environ['SWIFTC'] + else: + compiler = swift.getSwiftCompiler() + version = self.getCompilerVersion(compiler) if version < '5.0': self.skipTest('Swift compiler predates stable ABI') self.build() diff --git a/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/Makefile b/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/Makefile index ed84586b3cdc..681ddc85fc06 100644 --- a/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/Makefile +++ b/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/Makefile @@ -34,6 +34,8 @@ libFoo.dylib: Foo.swift echo ' '>>$$PLIST; \ echo " $(BOTDIR)">>$$PLIST; \ echo " $(USERDIR)">>$$PLIST; \ + echo " /nonexisting-rootdir">>$$PLIST; \ + echo " $(USERDIR)">>$$PLIST; \ echo ' '>>$$PLIST; \ echo ''>>$$PLIST; \ echo ''>>$$PLIST diff --git a/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/TestSwiftRewriteClangPaths.py b/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/TestSwiftRewriteClangPaths.py index 0eb831b9ccf7..c7cc070998f9 100644 --- a/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/TestSwiftRewriteClangPaths.py +++ b/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/TestSwiftRewriteClangPaths.py @@ -66,25 +66,15 @@ def dotest(self, remap): plist = self.find_plist() self.assertTrue(os.path.isfile(plist)) if remap: - self.runCmd("settings set target.source-map %s %s" % - (botdir, userdir)) + self.runCmd("settings set target.source-map %s %s %s %s" % + (botdir, userdir, '/nonexisting-rootdir', userdir)) else: # Also delete the remapping plist from the .dSYM to verify # that this doesn't work by happy accident without it. os.remove(plist) - - exe_name = "a.out" - exe = self.getBuildArtifact(exe_name) - # Create the target - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Set the breakpoints - foo_breakpoint = target.BreakpointCreateBySourceRegex( - 'break here', lldb.SBFileSpec('Foo.swift')) - - process = target.LaunchSimple(None, None, os.getcwd()) + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( + self, 'break here', lldb.SBFileSpec('Foo.swift')) if remap: comment = "returns correct value" @@ -101,9 +91,13 @@ def dotest(self, remap): found_i1 = 0 found_i2 = 0 found_rel = 0 + found_abs = 0 logfile = open(log, "r") for line in logfile: - if " remapped " in line: continue + self.assertFalse("remapped -iquote" in line) + if " remapped " in line: + if line[:-1].endswith('/user'): found_abs += 1; + continue if "error: missing required module 'CFoo'" in line: errs += 1 continue @@ -122,6 +116,7 @@ def dotest(self, remap): self.assertEqual(found_i2, 2) self.assertEqual(found_f, 4) self.assertEqual(found_rel, 0) + self.assertEqual(found_abs, 1) else: self.assertTrue(errs > 0, "expected module import error") diff --git a/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/dylib.mk b/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/dylib.mk index cd999ffaaecb..3463acf3c367 100644 --- a/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/dylib.mk +++ b/packages/Python/lldbsuite/test/lang/swift/clangimporter/rewrite_clang_paths/dylib.mk @@ -9,6 +9,7 @@ SWIFTFLAGS_EXTRAS = \ -Xcc -I./buildbot/I-single \ -Xcc -F./buildbot/Frameworks \ -Xcc -F -Xcc buildbot/Frameworks \ + -Xcc -iquote -Xcc /nonexisting-rootdir \ -import-objc-header $(BOTDIR)/Foo/bridge.h include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/swift/generic_extension/main.swift b/packages/Python/lldbsuite/test/lang/swift/generic_extension/main.swift index 325738c4ad14..34c55b84a5ca 100644 --- a/packages/Python/lldbsuite/test/lang/swift/generic_extension/main.swift +++ b/packages/Python/lldbsuite/test/lang/swift/generic_extension/main.swift @@ -11,6 +11,7 @@ // ----------------------------------------------------------------------------- extension Array { func test() { + print("PATPAT") //% self.expect("p self", substrs=['[0] = 1', '[1] = 2', '[2] = 3']) return //% self.expect("frame variable -d run -- self", substrs=['[0] = 1', '[1] = 2', '[2] = 3']) } } diff --git a/packages/Python/lldbsuite/test/lang/swift/swiftieformatting/TestSwiftieFormatting.py b/packages/Python/lldbsuite/test/lang/swift/swiftieformatting/TestSwiftieFormatting.py index 616d3eb2eab4..f35bccbbde8f 100644 --- a/packages/Python/lldbsuite/test/lang/swift/swiftieformatting/TestSwiftieFormatting.py +++ b/packages/Python/lldbsuite/test/lang/swift/swiftieformatting/TestSwiftieFormatting.py @@ -76,8 +76,12 @@ def do_test(self): ns_d = swcla.GetChildMemberWithName("ns_d") self.assertTrue(ns_d.GetSummary() == '0 bytes', "ns_d summary wrong") + IntWidth = 64 + if self.getArchitecture() in ['arm', 'armv7', 'armv7k', 'i386']: + IntWidth = 32 + ns_n = swcla.GetChildMemberWithName("ns_n") - self.assertTrue(ns_n.GetSummary() == 'Int64(30)', "ns_n summary wrong") + self.assertTrue(ns_n.GetSummary() == ("Int%d(30)" % IntWidth), "ns_n summary wrong") swcla = self.frame.EvaluateExpression("swcla") swcla.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) @@ -92,7 +96,7 @@ def do_test(self): self.assertTrue(ns_d.GetSummary() == '0 bytes', "ns_d summary wrong") ns_n = swcla.GetChildMemberWithName("ns_n") - self.assertTrue(ns_n.GetSummary() == 'Int64(30)', "ns_n summary wrong") + self.assertTrue(ns_n.GetSummary() == ("Int%d(30)" % IntWidth), "ns_n summary wrong") nsarr = self.frame.FindVariable("nsarr") nsarr.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) @@ -109,13 +113,13 @@ def do_test(self): nsarr3.SetPreferSyntheticValue(True) self.assertTrue( - nsarr0.GetSummary() == 'Int64(2)', + nsarr0.GetSummary() == ("Int%d(2)" % IntWidth), 'nsarr[0] summary wrong') self.assertTrue( - nsarr1.GetSummary() == 'Int64(3)', + nsarr1.GetSummary() == ("Int%d(3)" % IntWidth), 'nsarr[1] summary wrong') self.assertTrue( - nsarr3.GetSummary() == 'Int64(5)', + nsarr3.GetSummary() == ("Int%d(5)" % IntWidth), 'nsarr[3] summary wrong') self.expect( @@ -127,9 +131,9 @@ def do_test(self): self.expect( 'frame variable -d run nsarr[5] --ptr-depth=1', substrs=[ - 'Int64(1)', - 'Int64(2)', - 'Int64(3)']) + ("Int%d(1)" % IntWidth), + ("Int%d(2)" % IntWidth), + ("Int%d(3)" % IntWidth)]) if __name__ == '__main__': import atexit diff --git a/packages/Python/lldbsuite/test/lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py b/packages/Python/lldbsuite/test/lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py index 482e59fb6804..05f9d7de8d04 100644 --- a/packages/Python/lldbsuite/test/lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py +++ b/packages/Python/lldbsuite/test/lang/swift/variables/dict_nsobj_anyobj/TestSwiftDictionaryNSObjectAnyObject.py @@ -65,13 +65,22 @@ def do_test(self): self.frame = self.thread.frames[0] self.assertTrue(self.frame, "Frame 0 is valid.") - self.expect( - "frame variable -d run -- d2", - substrs=[ - 'Int64(1)', - 'Int64(2)', - 'Int64(3)', - 'Int64(4)']) + if self.getArchitecture() in ['arm', 'armv7', 'armv7k', 'i386']: + self.expect( + "frame variable -d run -- d2", + substrs=[ + 'Int32(1)', + 'Int32(2)', + 'Int32(3)', + 'Int32(4)']) + else: + self.expect( + "frame variable -d run -- d2", + substrs=[ + 'Int64(1)', + 'Int64(2)', + 'Int64(3)', + 'Int64(4)']) self.expect( "frame variable -d run -- d3", diff --git a/packages/Python/lldbsuite/test/linux/builtin_trap/main.cpp b/packages/Python/lldbsuite/test/linux/builtin_trap/main.cpp index 84156ef2ac4f..f005e697c8ee 100644 --- a/packages/Python/lldbsuite/test/linux/builtin_trap/main.cpp +++ b/packages/Python/lldbsuite/test/linux/builtin_trap/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/main.cpp b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/main.cpp index 079e8b13798c..4488f2310d52 100644 --- a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/main.cpp +++ b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/lldb_pylint_helper.py b/packages/Python/lldbsuite/test/lldb_pylint_helper.py index 1cc09441a2d6..c8b25dfb5ca1 100644 --- a/packages/Python/lldbsuite/test/lldb_pylint_helper.py +++ b/packages/Python/lldbsuite/test/lldb_pylint_helper.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Sync lldb and related source from a local machine to a remote machine. diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py index 19b4c9e3b53a..130fcd8a998e 100644 --- a/packages/Python/lldbsuite/test/lldbtest.py +++ b/packages/Python/lldbsuite/test/lldbtest.py @@ -37,6 +37,7 @@ # System modules import abc import collections +from distutils.version import LooseVersion from functools import wraps import gc import glob @@ -72,8 +73,7 @@ from lldbsuite.support import funcutils # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables -# LLDB_COMMAND_TRACE and LLDB_DO_CLEANUP are set from '-t' and '-r dir' -# options. +# LLDB_COMMAND_TRACE is set from '-t' option. # By default, traceAlways is False. if "LLDB_COMMAND_TRACE" in os.environ and os.environ[ @@ -740,6 +740,11 @@ def setUp(self): else: self.lldbMiExec = None + if "LLDBVSCODE_EXEC" in os.environ: + self.lldbVSCodeExec = os.environ["LLDBVSCODE_EXEC"] + else: + self.lldbVSCodeExec = None + # If we spawn an lldb process for test (via pexpect), do not load the # init file unless told otherwise. if "NO_LLDBINIT" in os.environ and "NO" == os.environ["NO_LLDBINIT"]: @@ -1215,12 +1220,15 @@ def dumpSessionInfo(self): if os.path.isfile(src): dst = src.replace(self.log_basename, dst_log_basename) if os.name == "nt" and os.path.isfile(dst): - # On Windows, renaming a -> b will throw an exception if b exists. On non-Windows platforms - # it silently replaces the destination. Ultimately this means that atomic renames are not - # guaranteed to be possible on Windows, but we need this to work anyway, so just remove the - # destination first if it already exists. + # On Windows, renaming a -> b will throw an exception if + # b exists. On non-Windows platforms it silently + # replaces the destination. Ultimately this means that + # atomic renames are not guaranteed to be possible on + # Windows, but we need this to work anyway, so just + # remove the destination first if it already exists. remove_file(dst) + lldbutil.mkdir_p(os.path.dirname(dst)) os.rename(src, dst) else: # success! (and we don't want log files) delete log files @@ -1302,6 +1310,20 @@ def getCompilerVersion(self, compiler=None): version = m.group(1) return version + def getDwarfVersion(self): + """ Returns the dwarf version generated by clang or '0'. """ + if 'clang' in self.getCompiler(): + try: + driver_output = check_output( + [self.getCompiler()] + '-g -c -x c - -o - -###'.split(), + stderr=STDOUT) + for line in driver_output.split(os.linesep): + m = re.search('dwarf-version=([0-9])', line) + if m: + return m.group(1) + except: pass + return '0' + def platformIsDarwin(self): """Returns true if the OS triple for the selected platform is any valid apple OS""" return lldbplatformutil.platformIsDarwin() @@ -1331,13 +1353,13 @@ def expectedCompilerVersion(self, compiler_version): if (version is None): return True if (operator == '>'): - return self.getCompilerVersion() > version + return LooseVersion(self.getCompilerVersion()) > LooseVersion(version) if (operator == '>=' or operator == '=>'): - return self.getCompilerVersion() >= version + return LooseVersion(self.getCompilerVersion()) >= LooseVersion(version) if (operator == '<'): - return self.getCompilerVersion() < version + return LooseVersion(self.getCompilerVersion()) < LooseVersion(version) if (operator == '<=' or operator == '=<'): - return self.getCompilerVersion() <= version + return LooseVersion(self.getCompilerVersion()) <= LooseVersion(version) if (operator == '!=' or operator == '!' or operator == 'not'): return str(version) not in str(self.getCompilerVersion()) return str(version) in str(self.getCompilerVersion()) @@ -2128,6 +2150,75 @@ def match( return match_object + def check_completion_with_desc(self, str_input, match_desc_pairs): + interp = self.dbg.GetCommandInterpreter() + match_strings = lldb.SBStringList() + description_strings = lldb.SBStringList() + num_matches = interp.HandleCompletionWithDescriptions(str_input, len(str_input), 0, -1, match_strings, description_strings) + self.assertEqual(len(description_strings), len(match_strings)) + + missing_pairs = [] + for pair in match_desc_pairs: + found_pair = False + for i in range(num_matches + 1): + match_candidate = match_strings.GetStringAtIndex(i) + description_candidate = description_strings.GetStringAtIndex(i) + if match_candidate == pair[0] and description_candidate == pair[1]: + found_pair = True + break + if not found_pair: + missing_pairs.append(pair) + + if len(missing_pairs): + error_msg = "Missing pairs:\n" + for pair in missing_pairs: + error_msg += " [" + pair[0] + ":" + pair[1] + "]\n" + error_msg += "Got the following " + str(num_matches) + " completions back:\n" + for i in range(num_matches + 1): + match_candidate = match_strings.GetStringAtIndex(i) + description_candidate = description_strings.GetStringAtIndex(i) + error_msg += "[" + match_candidate + ":" + description_candidate + "]\n" + self.assertEqual(0, len(missing_pairs), error_msg) + + def complete_exactly(self, str_input, patterns): + self.complete_from_to(str_input, patterns, True) + + def complete_from_to(self, str_input, patterns, turn_off_re_match=False): + """Test that the completion mechanism completes str_input to patterns, + where patterns could be a pattern-string or a list of pattern-strings""" + # Patterns should not be None in order to proceed. + self.assertFalse(patterns is None) + # And should be either a string or list of strings. Check for list type + # below, if not, make a list out of the singleton string. If patterns + # is not a string or not a list of strings, there'll be runtime errors + # later on. + if not isinstance(patterns, list): + patterns = [patterns] + + interp = self.dbg.GetCommandInterpreter() + match_strings = lldb.SBStringList() + num_matches = interp.HandleCompletion(str_input, len(str_input), 0, -1, match_strings) + common_match = match_strings.GetStringAtIndex(0) + if num_matches == 0: + compare_string = str_input + else: + if common_match != None and len(common_match) > 0: + compare_string = str_input + common_match + else: + compare_string = "" + for idx in range(1, num_matches+1): + compare_string += match_strings.GetStringAtIndex(idx) + "\n" + + for p in patterns: + if turn_off_re_match: + self.expect( + compare_string, msg=COMPLETION_MSG( + str_input, p, match_strings), exe=False, substrs=[p]) + else: + self.expect( + compare_string, msg=COMPLETION_MSG( + str_input, p, match_strings), exe=False, patterns=[p]) + def filecheck( self, command, @@ -2156,7 +2247,7 @@ def filecheck( filecheck_args = [filecheck_bin, check_file_abs] if filecheck_options: filecheck_args.append(filecheck_options) - subproc = Popen(filecheck_args, stdin=PIPE, stdout=PIPE, stderr=PIPE) + subproc = Popen(filecheck_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines = True) cmd_stdout, cmd_stderr = subproc.communicate(input=output) cmd_status = subproc.returncode diff --git a/packages/Python/lldbsuite/test/lldbtest_config.py b/packages/Python/lldbsuite/test/lldbtest_config.py index 30546afe17bd..29184dd7831c 100644 --- a/packages/Python/lldbsuite/test/lldbtest_config.py +++ b/packages/Python/lldbsuite/test/lldbtest_config.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - - This file is distributed under the University of Illinois Open Source - License. See LICENSE.TXT for details. + 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 Configuration options for lldbtest.py set by dotest.py during initialization """ diff --git a/packages/Python/lldbsuite/test/lldbutil.py b/packages/Python/lldbsuite/test/lldbutil.py index 30424c9850b3..89ff2f633cdd 100644 --- a/packages/Python/lldbsuite/test/lldbutil.py +++ b/packages/Python/lldbsuite/test/lldbutil.py @@ -737,6 +737,8 @@ def is_thread_crashed(test, thread): elif test.getPlatform() == "linux": return thread.GetStopReason() == lldb.eStopReasonSignal and thread.GetStopReasonDataAtIndex( 0) == thread.GetProcess().GetUnixSignals().GetSignalNumberFromName("SIGSEGV") + elif test.getPlatform() == "windows": + return "Exception 0xc0000005" in thread.GetStopDescription(100) else: return "invalid address" in thread.GetStopDescription(100) diff --git a/packages/Python/lldbsuite/test/logging/main.cpp b/packages/Python/lldbsuite/test/logging/main.cpp index 7af4e3de2d0b..f5f1687695b8 100644 --- a/packages/Python/lldbsuite/test/logging/main.cpp +++ b/packages/Python/lldbsuite/test/logging/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c index 402a6270c9c7..4d57868c3205 100644 --- a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c @@ -1,9 +1,8 @@ //===-- a.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// int __a_global = 1; diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c index c5b1cc2f0d1c..1525a1a5e389 100644 --- a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c index 814d4e8b44e8..e90218c9676c 100644 --- a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c @@ -1,9 +1,8 @@ //===-- a.c -----------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// static int __b_global = 2; diff --git a/packages/Python/lldbsuite/test/macosx/load-kext/TestLoadKext.py b/packages/Python/lldbsuite/test/macosx/load-kext/TestLoadKext.py new file mode 100644 index 000000000000..1bd5ec020dbe --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/load-kext/TestLoadKext.py @@ -0,0 +1,38 @@ +""" +Test loading of a kext binary. +""" + +from __future__ import print_function + +import shutil +import struct + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LoadKextTestCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + #super(LoadKextTestCase, self).setUp() + #self._initial_platform = lldb.DBG.GetSelectedPlatform() + + def test_load_kext(self): + """Test that lldb can load a kext binary.""" + + # Create kext from YAML. + self.yaml2obj("mykext.yaml", self.getBuildArtifact("mykext")) + + target = self.dbg.CreateTarget(self.getBuildArtifact("mykext")) + + self.assertTrue(target.IsValid()) + + self.assertEqual(target.GetNumModules(), 1) + mod = target.GetModuleAtIndex(0) + self.assertEqual(mod.GetFileSpec().GetFilename(), "mykext") diff --git a/packages/Python/lldbsuite/test/macosx/load-kext/mykext.yaml b/packages/Python/lldbsuite/test/macosx/load-kext/mykext.yaml new file mode 100644 index 000000000000..ccf016304c84 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/load-kext/mykext.yaml @@ -0,0 +1,222 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x0000000B + ncmds: 7 + sizeofcmds: 520 + flags: 0x00000085 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 152 + segname: __TEXT + vmaddr: 0 + vmsize: 4096 + fileoff: 0 + filesize: 4096 + maxprot: 7 + initprot: 5 + nsects: 1 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000F60 + size: 158 + offset: 0x00000F60 + align: 4 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_SEGMENT_64 + cmdsize: 152 + segname: __DATA + vmaddr: 4096 + vmsize: 4096 + fileoff: 4096 + filesize: 4096 + maxprot: 7 + initprot: 3 + nsects: 1 + flags: 0 + Sections: + - sectname: __data + segname: __DATA + addr: 0x0000000000001000 + size: 220 + offset: 0x00001000 + align: 3 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __LINKEDIT + vmaddr: 8192 + vmsize: 4096 + fileoff: 8192 + filesize: 800 + maxprot: 7 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 8224 + nsyms: 19 + stroff: 8528 + strsize: 464 + - cmd: LC_DYSYMTAB + cmdsize: 80 + ilocalsym: 0 + nlocalsym: 16 + iextdefsym: 16 + nextdefsym: 3 + iundefsym: 19 + nundefsym: 0 + tocoff: 0 + ntoc: 0 + modtaboff: 0 + nmodtab: 0 + extrefsymoff: 0 + nextrefsyms: 0 + indirectsymoff: 0 + nindirectsyms: 0 + extreloff: 0 + nextrel: 0 + locreloff: 8192 + nlocrel: 4 + - cmd: LC_UUID + cmdsize: 24 + uuid: 17A97B33-09B7-3195-9408-DBD965D578A5 + - cmd: LC_SOURCE_VERSION + cmdsize: 16 + version: 0 +LinkEditData: + NameList: + - n_strx: 40 + n_type: 0x64 + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 141 + n_type: 0x64 + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 155 + n_type: 0x66 + n_sect: 3 + n_desc: 1 + n_value: 1543540349 + - n_strx: 276 + n_type: 0x20 + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 287 + n_type: 0x20 + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 298 + n_type: 0x20 + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 309 + n_type: 0x20 + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 1 + n_type: 0x64 + n_sect: 1 + n_desc: 0 + n_value: 0 + - n_strx: 325 + n_type: 0x1E + n_sect: 1 + n_desc: 0 + n_value: 3992 + - n_strx: 333 + n_type: 0x1E + n_sect: 1 + n_desc: 0 + n_value: 4018 + - n_strx: 361 + n_type: 0x1E + n_sect: 1 + n_desc: 0 + n_value: 4035 + - n_strx: 392 + n_type: 0x1E + n_sect: 1 + n_desc: 0 + n_value: 4052 + - n_strx: 417 + n_type: 0x1E + n_sect: 1 + n_desc: 0 + n_value: 4068 + - n_strx: 424 + n_type: 0x1E + n_sect: 2 + n_desc: 0 + n_value: 4296 + - n_strx: 435 + n_type: 0x1E + n_sect: 2 + n_desc: 0 + n_value: 4304 + - n_strx: 446 + n_type: 0x1E + n_sect: 2 + n_desc: 0 + n_value: 4312 + - n_strx: 2 + n_type: 0x0F + n_sect: 2 + n_desc: 0 + n_value: 4096 + - n_strx: 13 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 3936 + - n_strx: 27 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 3968 + StringTable: + - ' ' + - _kmod_info + - _mykext_start + - _mykext_stop + - /tmp/mykext/build/mykext/Build/Intermediates.noindex/mykext.build/Debug/mykext.build/DerivedSources/ + - mykext_info.c + - /tmp/mykext/build/mykext/Build/Intermediates.noindex/mykext.build/Debug/mykext.build/Objects-normal/x86_64/mykext_info.o + - _kmod_info + - __realmain + - __antimain + - __kext_apple_cc + - __start + - _OSKextGetCurrentIdentifier + - _OSKextGetCurrentVersionString + - _OSKextGetCurrentLoadTag + - __stop + - __realmain + - __antimain + - __kext_apple_cc + - '' + - '' +... diff --git a/packages/Python/lldbsuite/test/macosx/nslog/main.m b/packages/Python/lldbsuite/test/macosx/nslog/main.m index dab4089e9273..d48536496b88 100644 --- a/packages/Python/lldbsuite/test/macosx/nslog/main.m +++ b/packages/Python/lldbsuite/test/macosx/nslog/main.m @@ -1,9 +1,8 @@ //===-- main.m --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/macosx/order/main.c b/packages/Python/lldbsuite/test/macosx/order/main.c index cd1ea581876f..18ee77685c94 100644 --- a/packages/Python/lldbsuite/test/macosx/order/main.c +++ b/packages/Python/lldbsuite/test/macosx/order/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py index 8c93889e782b..cdc9606c377a 100644 --- a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py +++ b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py @@ -280,7 +280,7 @@ def queues_with_libBacktraceRecording(self): process = target.LaunchSimple( [], [ - 'DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib', + 'DYLD_INSERT_LIBRARIES=%s' % (libbtr_path), 'DYLD_LIBRARY_PATH=/usr/lib/system/introspection'], self.get_process_working_directory()) diff --git a/packages/Python/lldbsuite/test/make/Makefile.rules b/packages/Python/lldbsuite/test/make/Makefile.rules index cda8f46dcda9..224ee5c254ef 100644 --- a/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/packages/Python/lldbsuite/test/make/Makefile.rules @@ -50,6 +50,33 @@ ifeq "$(OS)" "" OS = $(HOST_OS) endif +#---------------------------------------------------------------------- +# If OS is Windows, force SHELL to be cmd +# +# Some versions of make on Windows will search for other shells such as +# C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons +# so default to using cmd.exe. +#---------------------------------------------------------------------- +ifeq "$(OS)" "Windows_NT" + SHELL = $(WINDIR)\system32\cmd.exe +endif + +#---------------------------------------------------------------------- +# If the OS is Windows use double-quotes in commands +# +# For other operating systems, single-quotes work fine, but on Windows +# we strictly required double-quotes +#---------------------------------------------------------------------- +ifeq "$(HOST_OS)" "Windows_NT" + JOIN_CMD = & + QUOTE = " + FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = " +else + JOIN_CMD = ; + QUOTE = ' + FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = ' +endif + #---------------------------------------------------------------------- # If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more # from the triple alone @@ -65,8 +92,8 @@ ifneq "$(TRIPLE)" "" TRIPLE_SWIFTFLAGS :=-target $(TRIPLE) ifeq "$(TRIPLE_VENDOR)" "apple" ifeq "$(TRIPLE_OS)" "ios" - CODESIGN := codesign - ifeq "$(SDKROOT)" "" + CODESIGN := codesign + ifeq "$(SDKROOT)" "" # Set SDKROOT if it wasn't set ifneq (,$(findstring arm,$(ARCH))) SDKROOT = $(shell xcrun --sdk iphoneos --show-sdk-path) @@ -285,6 +312,12 @@ CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) SWIFTFLAGS += $(TRIPLE_SWIFTFLAGS) SWIFTFLAGS += $(SWIFTFLAGS_EXTRAS) +# If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will build +# with codeview by default but all the tests rely on dwarf. +ifeq "$(OS)" "Windows_NT" + CFLAGS += -gdwarf +endif + # Use this one if you want to build one part of the result without debug information: ifeq "$(OS)" "Darwin" CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) @@ -297,14 +330,11 @@ ifeq "$(MAKE_DWO)" "YES" endif # Use a shared module cache when building in the default test build directory. +CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed $(QUOTE)s/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/$(QUOTE)) + ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" "" CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache -else -CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 's/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/') -endif - -ifeq "$(CLANG_MODULE_CACHE_DIR)" "" -$(error failed to set the shared clang module cache dir) +$(warning failed to set the shared clang module cache dir) endif SWIFT_MODULE_CACHE_FLAGS = -module-cache-path $(CLANG_MODULE_CACHE_DIR) @@ -314,6 +344,10 @@ MANDATORY_MODULE_BUILD_CFLAGS := -fmodules -gmodules -fmodules-cache-path=$(CLAN ifeq "$(MAKE_GMODULES)" "YES" CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) + CXXFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) + ifeq "$(OS)" "Darwin" + CXXFLAGS += -fcxx-modules + endif endif CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) @@ -384,7 +418,7 @@ ifneq "$(OS)" "Darwin" endif ifdef PIE - LDFLAGS += -pie + LDFLAGS += -pie endif #---------------------------------------------------------------------- @@ -449,17 +483,17 @@ ifneq "$(strip $(DYLIB_OBJC_SOURCES))" "" endif ifneq "$(strip $(DYLIB_CXX_SOURCES))" "" - DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o)) - CXX = $(call cxx_compiler,$(CC)) - LD = $(call cxx_linker,$(CC)) + DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o)) + CXX = $(call cxx_compiler,$(CC)) + LD = $(call cxx_linker,$(CC)) endif #---------------------------------------------------------------------- # Check if we have a precompiled header #---------------------------------------------------------------------- ifneq "$(strip $(PCH_CXX_SOURCE))" "" - PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch) - PCHFLAGS = -include $(PCH_CXX_SOURCE) + PCH_OUTPUT = $(PCH_CXX_SOURCE:.h=.h.pch) + PCHFLAGS = -include $(PCH_CXX_SOURCE) endif #---------------------------------------------------------------------- @@ -586,21 +620,21 @@ ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" "" ifneq "$(filter g++,$(CXX))" "" CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3) ifeq "$(CXXVERSION)" "4.6" - # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x - # instead. FIXME: remove once GCC version is upgraded. + # GCC 4.6 cannot handle -std=c++11, so replace it with -std=c++0x + # instead. FIXME: remove once GCC version is upgraded. override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS)) endif endif endif ifeq ($(findstring clang, $(CXX)), clang) - CXXFLAGS += --driver-mode=g++ + CXXFLAGS += --driver-mode=g++ endif ifneq "$(CXX)" "" - ifeq ($(findstring clang, $(LD)), clang) - LDFLAGS += --driver-mode=g++ - endif + ifeq ($(findstring clang, $(LD)), clang) + LDFLAGS += --driver-mode=g++ + endif endif #---------------------------------------------------------------------- @@ -770,14 +804,6 @@ endif # the compiler -MM option. The -M option will list all system headers, # and the -MM option will list all non-system dependencies. #---------------------------------------------------------------------- -ifeq "$(HOST_OS)" "Windows_NT" - JOIN_CMD = & - QUOTE = " -else - JOIN_CMD = ; - QUOTE = ' -endif - %.d: %.c @rm -f $@ $(JOIN_CMD) \ $(CC) -M $(CFLAGS) $< > $@.tmp && \ diff --git a/packages/Python/lldbsuite/test/plugins/swift.py b/packages/Python/lldbsuite/test/plugins/swift.py index 38956294d178..7008071b362a 100755 --- a/packages/Python/lldbsuite/test/plugins/swift.py +++ b/packages/Python/lldbsuite/test/plugins/swift.py @@ -44,10 +44,18 @@ def getSwiftCompiler(): os.path.join( lldb_root_path, "llvm-build/ReleaseAssert/swift-macosx-x86_64/bin/swiftc")) + candidates.append( + os.path.join( + lldb_root_path, + "llvm-build/Release+Asserts/swift-macosx-x86_64/bin/swiftc")) candidates.append( os.path.join( lldb_root_path, "llvm-build/DebugAssert/swift-macosx-x86_64/bin/swiftc")) + candidates.append( + os.path.join( + lldb_root_path, + "llvm-build/Debug+Asserts/swift-macosx-x86_64/bin/swiftc")) candidates.append( os.path.join( lldb_root_path, diff --git a/packages/Python/lldbsuite/test/python_api/class_members/main.mm b/packages/Python/lldbsuite/test/python_api/class_members/main.mm index ff61b369ee1f..48a2c59ad4a9 100644 --- a/packages/Python/lldbsuite/test/python_api/class_members/main.mm +++ b/packages/Python/lldbsuite/test/python_api/class_members/main.mm @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py index 8a9e456f3458..f5d143fbd40b 100644 --- a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py +++ b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py @@ -119,7 +119,6 @@ def run(self): @add_test_categories(['pyapi']) @expectedFlakeyLinux("llvm.org/pr23730") # Flaky, fails ~1/100 cases - @expectedFlakeyOS(oslist=["windows"]) def test_wait_for_event(self): """Exercise SBListener.WaitForEvent() API.""" self.build() @@ -198,7 +197,6 @@ def run(self): @expectedFailureAll( oslist=["linux"], bugnumber="llvm.org/pr23617 Flaky, fails ~1/10 cases") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_add_listener_to_broadcaster(self): """Exercise some SBBroadcaster APIs.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/event/main.c b/packages/Python/lldbsuite/test/python_api/event/main.c index 343526542d7e..57369520dd16 100644 --- a/packages/Python/lldbsuite/test/python_api/event/main.c +++ b/packages/Python/lldbsuite/test/python_api/event/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/main.mm b/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/main.mm index 9d4630dc7c4c..365fe12dd60e 100644 --- a/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/main.mm +++ b/packages/Python/lldbsuite/test/python_api/exprpath_synthetic/main.mm @@ -1,9 +1,8 @@ //===-- main.mm --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #import diff --git a/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py index 85e915ad3a48..fc2f03f9e617 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py +++ b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py @@ -20,7 +20,6 @@ class FrameAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_get_arg_vals_for_call_stack(self): """Exercise SBFrame.GetVariables() API to get argument vals.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c b/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c index 7fecfc0293c3..7606e2ac9090 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c +++ b/packages/Python/lldbsuite/test/python_api/frame/get-variables/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/frame/main.c b/packages/Python/lldbsuite/test/python_api/frame/main.c index 35209db1812e..75f4448758b9 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/main.c +++ b/packages/Python/lldbsuite/test/python_api/frame/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/main.c b/packages/Python/lldbsuite/test/python_api/function_symbol/main.c index b60b2faf18dc..33eea200bc47 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/main.c +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py index b0f09d2fa7b5..33f4a790aacf 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py +++ b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py @@ -10,8 +10,7 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - +import lldbsuite.test.lldbutil as lldbutil class HelloWorldTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True @@ -35,7 +34,7 @@ def tearDown(self): def test_with_process_launch_api(self): """Create target, breakpoint, launch a process, and then kill it.""" # Get the full path to our executable to be attached/debugged. - exe = self.getBuildArtifact(self.testMethodName) + exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid()) d = {'EXE': exe} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) @@ -77,23 +76,22 @@ def test_with_process_launch_api(self): self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE) @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24600") @skipIfiOSSimulator - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_with_attach_to_process_with_id_api(self): """Create target, spawn a process, and attach to it with process id.""" - exe = self.getBuildArtifact(self.testMethodName) + exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid()) d = {'EXE': exe} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.dbg.CreateTarget(exe) # Spawn a new process - popen = self.spawnSubprocess(exe, ["abc", "xyz"]) + token = exe+'.token' + if os.path.exists(token): + os.remove(token) + popen = self.spawnSubprocess(exe, [token]) self.addTearDownHook(self.cleanupSubprocesses) - - # Give the subprocess time to start and wait for user input - time.sleep(0.25) + lldbutil.wait_for_file_on_target(self, token) listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() @@ -102,30 +100,29 @@ def test_with_attach_to_process_with_id_api(self): self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # Let's check the stack traces of the attached process. - import lldbsuite.test.lldbutil as lldbutil stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) self.expect(stacktraces, exe=False, substrs=['main.c:%d' % self.line2, - '(int)argc=3']) + '(int)argc=2']) @add_test_categories(['pyapi']) - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24600") @skipIfiOSSimulator - @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails + @skipIfSanitized # FIXME: Hangs indefinitely. def test_with_attach_to_process_with_name_api(self): """Create target, spawn a process, and attach to it with process name.""" - exe = self.getBuildArtifact(self.testMethodName) + exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid()) d = {'EXE': exe} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.dbg.CreateTarget(exe) - # Spawn a new process - popen = self.spawnSubprocess(exe, ["abc", "xyz"]) + # Spawn a new process. + token = exe+'.token' + if os.path.exists(token): + os.remove(token) + popen = self.spawnSubprocess(exe, [token]) self.addTearDownHook(self.cleanupSubprocesses) - - # Give the subprocess time to start and wait for user input - time.sleep(0.25) + lldbutil.wait_for_file_on_target(self, token) listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() @@ -140,7 +137,6 @@ def test_with_attach_to_process_with_name_api(self): target.ConnectRemote(listener, None, None, error) process = target.AttachToProcessWithName(listener, name, False, error) - self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # Verify that after attach, our selected target indeed matches name. @@ -150,8 +146,7 @@ def test_with_attach_to_process_with_name_api(self): startstr=name) # Let's check the stack traces of the attached process. - import lldbsuite.test.lldbutil as lldbutil stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) self.expect(stacktraces, exe=False, substrs=['main.c:%d' % self.line2, - '(int)argc=3']) + '(int)argc=2']) diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/main.c b/packages/Python/lldbsuite/test/python_api/hello_world/main.c index 32b0446517c5..c516f923614f 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/main.c +++ b/packages/Python/lldbsuite/test/python_api/hello_world/main.c @@ -8,16 +8,22 @@ int main(int argc, char const *argv[]) { - lldb_enable_attach(); + lldb_enable_attach(); - printf("Hello world.\n"); // Set break point at this line. - if (argc == 1) - return 0; + printf("Hello world.\n"); // Set break point at this line. + if (argc == 1) + return 1; - // Waiting to be attached by the debugger, otherwise. - char line[100]; - while (1) - sleep (1); // Waiting to be attached... + // Create the synchronization token. + FILE *f; + if (f = fopen(argv[1], "wx")) { + fputs("\n", f); + fflush(f); + fclose(f); + } else + return 1; - printf("Exiting now\n"); + // Waiting to be attached by the debugger, otherwise. + while (1) + sleep(1); // Waiting to be attached... } diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/main.c b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/main.c index e6eeef5b46d9..f83709616e58 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/main.c +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/main.cpp b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/main.cpp index 8fb45f94b1ef..eb4969d41088 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/process/main.cpp b/packages/Python/lldbsuite/test/python_api/lldbutil/process/main.cpp index 6b87c3d649e6..da94b2714a27 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/process/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/process/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/module_section/main.cpp b/packages/Python/lldbsuite/test/python_api/module_section/main.cpp index 6b87c3d649e6..da94b2714a27 100644 --- a/packages/Python/lldbsuite/test/python_api/module_section/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/module_section/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp b/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp index 79aa2d0452f4..b38208ce2a35 100644 --- a/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp @@ -51,4 +51,4 @@ int main (int argc, char const *argv[]) g.unique_function_name(); g.unique_function_name(argc); return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/python_api/objc_type/main.m b/packages/Python/lldbsuite/test/python_api/objc_type/main.m index 6ae54ade09ac..a2a7b0b4bcea 100644 --- a/packages/Python/lldbsuite/test/python_api/objc_type/main.m +++ b/packages/Python/lldbsuite/test/python_api/objc_type/main.m @@ -1,9 +1,8 @@ //===-- main.m ------------------------------------------------*- ObjC -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/process/main.cpp b/packages/Python/lldbsuite/test/python_api/process/main.cpp index 9610936e0534..32c6dee8044c 100644 --- a/packages/Python/lldbsuite/test/python_api/process/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/process/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/rdar-12481949/main.cpp b/packages/Python/lldbsuite/test/python_api/rdar-12481949/main.cpp index e8ebf36f6190..f6ec2b860648 100644 --- a/packages/Python/lldbsuite/test/python_api/rdar-12481949/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/rdar-12481949/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/sbdata/main.cpp b/packages/Python/lldbsuite/test/python_api/sbdata/main.cpp index 6018475d83c0..78e071c931ed 100644 --- a/packages/Python/lldbsuite/test/python_api/sbdata/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/sbdata/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/main.m b/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/main.m index 6ac70d1d06b7..8e9601e42eb9 100644 --- a/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/main.m +++ b/packages/Python/lldbsuite/test/python_api/sbtype_typeclass/main.m @@ -1,9 +1,8 @@ //===-- main.m --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #import diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp index 650d87acd6e6..c54339f3bba6 100644 --- a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/main.cpp @@ -11,4 +11,4 @@ int main() { f(); // break here f(); // break here return 0; -} \ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/python_api/section/main.c b/packages/Python/lldbsuite/test/python_api/section/main.c index 746681d721a9..f12ef5afb7ab 100644 --- a/packages/Python/lldbsuite/test/python_api/section/main.c +++ b/packages/Python/lldbsuite/test/python_api/section/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/signals/main.cpp b/packages/Python/lldbsuite/test/python_api/signals/main.cpp index 81924f435a1a..c4c5a00dd09d 100644 --- a/packages/Python/lldbsuite/test/python_api/signals/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/signals/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/main.c b/packages/Python/lldbsuite/test/python_api/symbol-context/main.c index 3ac1825d8d21..4e68fb764b8f 100644 --- a/packages/Python/lldbsuite/test/python_api/symbol-context/main.c +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/target/main.c b/packages/Python/lldbsuite/test/python_api/target/main.c index ba82a5437ae3..d075f2cf2d36 100644 --- a/packages/Python/lldbsuite/test/python_api/target/main.c +++ b/packages/Python/lldbsuite/test/python_api/target/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/thread/main.cpp b/packages/Python/lldbsuite/test/python_api/thread/main.cpp index 8d8069036898..01c8404a3872 100644 --- a/packages/Python/lldbsuite/test/python_api/thread/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/thread/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/thread/main2.cpp b/packages/Python/lldbsuite/test/python_api/thread/main2.cpp index a95d7d7aec1a..57c485c08c68 100644 --- a/packages/Python/lldbsuite/test/python_api/thread/main2.cpp +++ b/packages/Python/lldbsuite/test/python_api/thread/main2.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/type/main.cpp b/packages/Python/lldbsuite/test/python_api/type/main.cpp index b7f3dcc7fbea..8f5b93927c7f 100644 --- a/packages/Python/lldbsuite/test/python_api/type/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/type/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py index 8a4af0cc2b94..2299f1f1432d 100644 --- a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py @@ -152,6 +152,9 @@ def test(self): val_i = target.EvaluateExpression('i') val_s = target.EvaluateExpression('s') val_a = target.EvaluateExpression('a') + self.assertTrue( + val_s.GetChildMemberWithName('a').GetAddress().IsValid(), + VALID_VARIABLE) self.assertTrue( val_s.GetChildMemberWithName('a').AddressOf(), VALID_VARIABLE) diff --git a/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp b/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp index 96b203526dbd..483a57ee5c0d 100644 --- a/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/value/empty_class/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/python_api/value/linked_list/main.cpp b/packages/Python/lldbsuite/test/python_api/value/linked_list/main.cpp index 50517f487749..edd175ae2663 100644 --- a/packages/Python/lldbsuite/test/python_api/value/linked_list/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/value/linked_list/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/value/main.c b/packages/Python/lldbsuite/test/python_api/value/main.c index 2ebe3ad303cf..68b3c12cce41 100644 --- a/packages/Python/lldbsuite/test/python_api/value/main.c +++ b/packages/Python/lldbsuite/test/python_api/value/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/main.cpp b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/main.cpp index f4c3527f8af2..3f7c5f5be966 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/main.cpp @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/main.c b/packages/Python/lldbsuite/test/python_api/watchpoint/main.c index 4753edfba991..6cda6d7c886e 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/main.c +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/main.c @@ -1,9 +1,8 @@ //===-- main.c --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index d5862d274ceb..3c19c589b7a7 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -108,7 +108,6 @@ def test_watch_address(self): # No size constraint on MIPS for watches @skipIf(archs=['mips', 'mipsel', 'mips64', 'mips64el']) @skipIf(archs=['s390x']) # Likewise on SystemZ - @expectedFailureAll(oslist=["windows"]) def test_watch_address_with_invalid_watch_size(self): """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" self.build() diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/main.cpp b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/main.cpp index a197a92a4814..e455331bc163 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/main.cpp +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/settings/TestSettings.py b/packages/Python/lldbsuite/test/settings/TestSettings.py index f1e8fc3e3a69..b46e3b4103c6 100644 --- a/packages/Python/lldbsuite/test/settings/TestSettings.py +++ b/packages/Python/lldbsuite/test/settings/TestSettings.py @@ -132,7 +132,7 @@ def cleanup(): # Change the default format to print function.name rather than # function.name-with-args - format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n" + format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n" self.runCmd("settings set frame-format %s" % format_string) # Immediately test the setting. diff --git a/packages/Python/lldbsuite/test/settings/main.cpp b/packages/Python/lldbsuite/test/settings/main.cpp index cf2b16b0089b..5159eaa65b5a 100644 --- a/packages/Python/lldbsuite/test/settings/main.cpp +++ b/packages/Python/lldbsuite/test/settings/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/test_result.py b/packages/Python/lldbsuite/test/test_result.py index 242362faac2e..e0b830fbaeca 100644 --- a/packages/Python/lldbsuite/test/test_result.py +++ b/packages/Python/lldbsuite/test/test_result.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides the LLDBTestResult class, which holds information about progress and results of a single test run. diff --git a/packages/Python/lldbsuite/test/test_runner/process_control.py b/packages/Python/lldbsuite/test/test_runner/process_control.py index d6eaae3340e9..97de1f42ee26 100644 --- a/packages/Python/lldbsuite/test/test_runner/process_control.py +++ b/packages/Python/lldbsuite/test/test_runner/process_control.py @@ -1,8 +1,7 @@ """ -The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides classes used by the test results reporting infrastructure within the LLDB test suite. diff --git a/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py b/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py index 88ad961be2b9..d1f7da67dc1b 100755 --- a/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py +++ b/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py @@ -1,9 +1,8 @@ #!/usr/bin/env python """ -The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides classes used by the test results reporting infrastructure within the LLDB test suite. diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp index 366c53c3143f..d81365ff415c 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp index ae0c3d9800a7..03f5b85ed385 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp index 85c38634f84b..5cac8fcc3909 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp index 0c042d466988..131b5d596d39 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp index b9a7bff37af1..facaa919b92d 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py index 7b6ee55b250e..59a5b324465f 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py @@ -40,7 +40,7 @@ def tearDown(self): pass Base.tearDown(self) - def spawnLldbMi(self, args=None): + def spawnLldbMi(self, exe=None, args=None, preconfig=True): import pexpect self.child = pexpect.spawn("%s --interpreter %s" % ( self.lldbMiExec, args if args else ""), cwd=self.getBuildDir()) @@ -49,6 +49,14 @@ def spawnLldbMi(self, args=None): self.child.logfile_read = open(self.mylog, "w") # wait until lldb-mi has started up and is ready to go self.expect(self.child_prompt, exactly=True) + if preconfig: + self.runCmd("settings set symbols.enable-external-lookup false") + self.expect("\^done") + self.expect(self.child_prompt, exactly=True) + if exe: + self.runCmd("-file-exec-and-symbols \"%s\"" % exe) + # Testcases expect to be able to match output of this command, + # see test_lldbmi_specialchars. def runCmd(self, cmd): self.child.sendline(cmd) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp index 0215b428925b..10cd97eb1494 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp index 7f6eeca70c01..a0c5637b8244 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp index 32db32d2fd16..b054753a95c7 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py index 467952db7eba..b78f4762ddf9 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py @@ -22,7 +22,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): def test_lldbmi_executable_option_file(self): """Test that 'lldb-mi --interpreter %s' loads executable file.""" - self.spawnLldbMi(args="%s" % self.myexe) + self.spawnLldbMi(exe=self.myexe) # Test that the executable is loaded when file was specified self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) @@ -52,7 +52,7 @@ def test_lldbmi_executable_option_unknown_file(self): # Prepare path to executable path = "unknown_file" - self.spawnLldbMi(args="%s" % path) + self.spawnLldbMi(exe=path) # Test that the executable isn't loaded when unknown file was specified self.expect("-file-exec-and-symbols \"%s\"" % path) @@ -71,7 +71,7 @@ def test_lldbmi_executable_option_absolute_path(self): """Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path.""" # Prepare path to executable - self.spawnLldbMi(args="%s" % self.myexe) + self.spawnLldbMi(exe=self.myexe) # Test that the executable is loaded when file was specified using # absolute path @@ -95,7 +95,7 @@ def test_lldbmi_executable_option_relative_path(self): # Prepare path to executable path = os.path.relpath(self.myexe, self.getBuildDir()) - self.spawnLldbMi(args="%s" % path) + self.spawnLldbMi(exe=path) # Test that the executable is loaded when file was specified using # relative path @@ -119,7 +119,7 @@ def test_lldbmi_executable_option_unknown_path(self): # Prepare path to executable path = "unknown_dir" + self.myexe - self.spawnLldbMi(args="%s" % path) + self.spawnLldbMi(exe=path) # Test that the executable isn't loaded when file was specified using # unknown path @@ -237,7 +237,11 @@ def test_lldbmi_source_option_start_script_error(self): # Prepared source file sourceFile = self.copyScript("start_script_error") - self.spawnLldbMi(args="--source %s" % sourceFile) + self.spawnLldbMi(args="--source %s" % sourceFile, preconfig=False) + + # After 'settings set symbols.enable-external-lookup false' + self.expect("settings set symbols.enable-external-lookup false") + self.expect("\^done") # After '-file-exec-and-symbols a.out' self.expect("-file-exec-and-symbols %s" % self.myexe) @@ -259,7 +263,7 @@ def test_lldbmi_log_option(self): """Test that 'lldb-mi --log' creates a log file in the current directory.""" logDirectory = self.getBuildDir() - self.spawnLldbMi(args="%s --log" % self.myexe) + self.spawnLldbMi(exe=self.myexe, args="--log") # Test that the executable is loaded when file was specified self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) @@ -296,9 +300,8 @@ def test_lldbmi_log_directory_option(self): import tempfile logDirectory = tempfile.gettempdir() - self.spawnLldbMi( - args="%s --log --log-dir=%s" % - (self.myexe, logDirectory)) + self.spawnLldbMi(exe=self.myexe, + args="--log --log-dir=%s" % logDirectory) # Test that the executable is loaded when file was specified self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp index 7f2d5246faf9..4a5aef94946f 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error index d834e7407c57..a1c581b08e0e 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error @@ -1,2 +1,3 @@ +settings set symbols.enable-external-lookup false -file-exec-and-symbols a.out -break-ins -f main diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py index 50a94b53a18b..74d194e6dee2 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py @@ -53,7 +53,7 @@ def test_lldbmi_specialchars(self): os.symlink(self.myexe, complicated_myexe) self.addTearDownHook(lambda: os.unlink(complicated_myexe)) - self.spawnLldbMi(args="\"%s\"" % complicated_myexe) + self.spawnLldbMi(exe=complicated_myexe) # Test that the executable was loaded self.expect( diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp index d2935b08f872..08afcc483d5e 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp index caaf33a46faf..8dca63fe5524 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp index 8c79539d4d85..43ae8be2118e 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py index 79ea3a7b26eb..7561da2ccc2a 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py @@ -41,7 +41,7 @@ def check_simulator_ostype(self, sdk, platform, arch='x86_64'): self.assertIsNotNone(deviceUDID) exe_name = 'test_simulator_platform_{}'.format(platform) sdkroot = subprocess.check_output(['xcrun', '--show-sdk-path', '--sdk', - sdk]) + sdk]).decode("utf-8") self.build(dictionary={ 'EXE': exe_name, 'SDKROOT': sdkroot.strip(), 'ARCH': arch }) exe_path = self.getBuildArtifact(exe_name) @@ -52,7 +52,7 @@ def check_simulator_ostype(self, sdk, platform, arch='x86_64'): # Get the PID from the process output pid = None while not pid: - stderr = sim_launcher.stderr.readline() + stderr = sim_launcher.stderr.readline().decode("utf-8") if stderr == '': continue m = re.match(r"PID: (.*)", stderr) diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py index 76910758fa91..cfadbc8f7d0f 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py @@ -35,6 +35,7 @@ def run_test_g_packet(self): @skipIfOutOfTreeDebugserver @debugserver_test + @skipIfDarwinEmbedded def test_g_packet_debugserver(self): self.init_debugserver_test() self.run_test_g_packet() diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index b0e67bf253d9..468f6147418b 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -590,7 +590,7 @@ def expect_socket_recv( if can_read and sock in can_read: recv_bytes = sock.recv(4096) if recv_bytes: - response += recv_bytes + response += recv_bytes.decode("utf-8") self.assertTrue(expected_content_regex.match(response)) @@ -601,7 +601,7 @@ def expect_socket_send(self, sock, content, timeout_seconds): while len(request_bytes_remaining) > 0 and time.time() < timeout_time: _, can_write, _ = select.select([], [sock], [], timeout_seconds) if can_write and sock in can_write: - written_byte_count = sock.send(request_bytes_remaining) + written_byte_count = sock.send(request_bytes_remaining.encode()) request_bytes_remaining = request_bytes_remaining[ written_byte_count:] self.assertEqual(len(request_bytes_remaining), 0) @@ -612,7 +612,7 @@ def do_handshake(self, stub_socket, timeout_seconds=5): # Send the start no ack mode packet. NO_ACK_MODE_REQUEST = "$QStartNoAckMode#b0" - bytes_sent = stub_socket.send(NO_ACK_MODE_REQUEST) + bytes_sent = stub_socket.send(NO_ACK_MODE_REQUEST.encode()) self.assertEqual(bytes_sent, len(NO_ACK_MODE_REQUEST)) # Receive the ack and "OK" diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py b/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py index c89cd301899a..b0cf6ec61e81 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py @@ -221,7 +221,7 @@ def expect_lldb_gdbserver_replay( packet_desc = send_packet logger.info( "sending packet to remote: {}".format(packet_desc)) - sock.sendall(send_packet) + sock.sendall(send_packet.encode()) else: # This is an entry expecting to receive content from the remote # debug monitor. @@ -921,7 +921,7 @@ def process_is_running(pid, unknown_value=True): elif platform.system() in ['Darwin', 'Linux', 'FreeBSD', 'NetBSD']: # Build the list of running process ids output = subprocess.check_output( - "ps ax | awk '{ print $1; }'", shell=True) + "ps ax | awk '{ print $1; }'", shell=True).decode("utf-8") text_process_ids = output.split('\n')[1:] # Convert text pids to ints process_ids = [int(text_pid) diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp index ca032c120beb..81114a2e58e9 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp index 4991259fe46e..fe33c2919582 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/.categories b/packages/Python/lldbsuite/test/tools/lldb-vscode/.categories new file mode 100644 index 000000000000..ce2cfd048e38 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/.categories @@ -0,0 +1 @@ +lldb-vscode diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/Makefile b/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/Makefile new file mode 100644 index 000000000000..b09a579159d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py new file mode 100644 index 000000000000..67cd05b83c3b --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/TestVSCode_attach.py @@ -0,0 +1,192 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os +import shutil +import subprocess +import tempfile +import threading +import time + + +def spawn_and_wait(program, delay): + if delay: + time.sleep(delay) + process = subprocess.Popen([program], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + process.wait() + + +class TestVSCode_attach(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + def set_and_hit_breakpoint(self, continueToExit=True): + source = 'main.c' + breakpoint1_line = line_number(source, '// breakpoint 1') + lines = [breakpoint1_line] + # Set breakoint in the thread function so we can step the threads + breakpoint_ids = self.set_source_breakpoints(source, lines) + self.assertEqual(len(breakpoint_ids), len(lines), + "expect correct number of breakpoints") + self.continue_to_breakpoints(breakpoint_ids) + if continueToExit: + self.continue_to_exit() + + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_by_pid(self): + ''' + Tests attaching to a process by process ID. + ''' + self.build_and_create_debug_adaptor() + program = self.getBuildArtifact("a.out") + self.process = subprocess.Popen([program], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + self.attach(pid=self.process.pid) + self.set_and_hit_breakpoint(continueToExit=True) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_by_name(self): + ''' + Tests attaching to a process by process name. + ''' + self.build_and_create_debug_adaptor() + orig_program = self.getBuildArtifact("a.out") + # Since we are going to attach by process name, we need a unique + # process name that has minimal chance to match a process that is + # already running. To do this we use tempfile.mktemp() to give us a + # full path to a location where we can copy our executable. We then + # run this copy to ensure we don't get the error "more that one + # process matches 'a.out'". + program = tempfile.mktemp() + shutil.copyfile(orig_program, program) + shutil.copymode(orig_program, program) + + def cleanup(): + if os.path.exists(program): + os.unlink(program) + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.process = subprocess.Popen([program], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + # Wait for a bit to ensure the process is launched + time.sleep(5) + self.attach(program=program) + self.set_and_hit_breakpoint(continueToExit=True) + + @skipUnlessDarwin + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_by_name_waitFor(self): + ''' + Tests attaching to a process by process name and waiting for the + next instance of a process to be launched, ingoring all current + ones. + ''' + self.build_and_create_debug_adaptor() + program = self.getBuildArtifact("a.out") + self.spawn_thread = threading.Thread(target=spawn_and_wait, + args=(program, 1.0,)) + self.spawn_thread.start() + self.attach(program=program, waitFor=True) + self.set_and_hit_breakpoint(continueToExit=True) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_commands(self): + ''' + Tests the "initCommands", "preRunCommands", "stopCommands", + "exitCommands", and "attachCommands" that can be passed during + attach. + + "initCommands" are a list of LLDB commands that get executed + before the targt is created. + "preRunCommands" are a list of LLDB commands that get executed + after the target has been created and before the launch. + "stopCommands" are a list of LLDB commands that get executed each + time the program stops. + "exitCommands" are a list of LLDB commands that get executed when + the process exits + "attachCommands" are a list of LLDB commands that get executed and + must have a valid process in the selected target in LLDB after + they are done executing. This allows custom commands to create any + kind of debug session. + ''' + self.build_and_create_debug_adaptor() + program = self.getBuildArtifact("a.out") + # Here we just create a target and launch the process as a way to test + # if we are able to use attach commands to create any kind of a target + # and use it for debugging + attachCommands = [ + 'target create -d "%s"' % (program), + 'process launch -- arg1' + ] + initCommands = ['target list', 'platform list'] + preRunCommands = ['image list a.out', 'image dump sections a.out'] + stopCommands = ['frame variable', 'bt'] + exitCommands = ['expr 2+3', 'expr 3+4'] + self.attach(program=program, + attachCommands=attachCommands, + initCommands=initCommands, + preRunCommands=preRunCommands, + stopCommands=stopCommands, + exitCommands=exitCommands) + + # Get output from the console. This should contain both the + # "initCommands" and the "preRunCommands". + output = self.get_console() + # Verify all "initCommands" were found in console output + self.verify_commands('initCommands', output, initCommands) + # Verify all "preRunCommands" were found in console output + self.verify_commands('preRunCommands', output, preRunCommands) + + functions = ['main'] + breakpoint_ids = self.set_function_breakpoints(functions) + self.assertTrue(len(breakpoint_ids) == len(functions), + "expect one breakpoint") + self.continue_to_breakpoints(breakpoint_ids) + output = self.get_console(timeout=1.0) + self.verify_commands('stopCommands', output, stopCommands) + + # Continue after launch and hit the "pause()" call and stop the target. + # Get output from the console. This should contain both the + # "stopCommands" that were run after we stop. + self.vscode.request_continue() + time.sleep(0.5) + self.vscode.request_pause() + self.vscode.wait_for_stopped() + output = self.get_console(timeout=1.0) + self.verify_commands('stopCommands', output, stopCommands) + + # Continue until the program exits + self.continue_to_exit() + # Get output from the console. This should contain both the + # "exitCommands" that were run after the second breakpoint was hit + output = self.get_console(timeout=1.0) + self.verify_commands('exitCommands', output, exitCommands) diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c b/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c new file mode 100644 index 000000000000..a078d42203eb --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/attach/main.c @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char const *argv[]) { + printf("pid = %i\n", getpid()); + sleep(5); + return 0; // breakpoint 1 +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/Makefile b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py new file mode 100644 index 000000000000..1ebf2b8981ab --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py @@ -0,0 +1,211 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import pprint +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os + + +class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_set_and_clear(self): + '''Tests setting and clearing source file and line breakpoints. + This packet is a bit tricky on the debug adaptor side since there + is no "clearBreakpoints" packet. Source file and line breakpoints + are set by sending a "setBreakpoints" packet with a source file + specified and zero or more source lines. If breakpoints have been + set in the source file before, any exising breakpoints must remain + set, and any new breakpoints must be created, and any breakpoints + that were in previous requests and are not in the current request + must be removed. This function tests this setting and clearing + and makes sure things happen correctly. It doesn't test hitting + breakpoints and the functionality of each breakpoint, like + 'conditions' and 'hitCondition' settings.''' + source_basename = 'main.cpp' + source_path = os.path.join(os.getcwd(), source_basename) + first_line = line_number('main.cpp', 'break 12') + second_line = line_number('main.cpp', 'break 13') + third_line = line_number('main.cpp', 'break 14') + lines = [first_line, second_line, third_line] + + # Visual Studio Code Debug Adaptors have no way to specify the file + # without launching or attaching to a process, so we must start a + # process in order to be able to set breakpoints. + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + + # Set 3 breakoints and verify that they got set correctly + response = self.vscode.request_setBreakpoints(source_path, lines) + line_to_id = {} + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + for breakpoint in breakpoints: + line = breakpoint['line'] + # Store the "id" of the breakpoint that was set for later + line_to_id[line] = breakpoint['id'] + self.assertTrue(line in lines, "line expected in lines array") + self.assertTrue(breakpoint['verified'], + "expect breakpoint verified") + + # There is no breakpoint delete packet, clients just send another + # setBreakpoints packet with the same source file with fewer lines. + # Below we remove the second line entry and call the setBreakpoints + # function again. We want to verify that any breakpoints that were set + # before still have the same "id". This means we didn't clear the + # breakpoint and set it again at the same location. We also need to + # verify that the second line location was actually removed. + lines.remove(second_line) + # Set 2 breakoints and verify that the previous breakoints that were + # set above are still set. + response = self.vscode.request_setBreakpoints(source_path, lines) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + for breakpoint in breakpoints: + line = breakpoint['line'] + # Verify the same breakpoints are still set within LLDB by + # making sure the breakpoint ID didn't change + self.assertTrue(line_to_id[line] == breakpoint['id'], + "verify previous breakpoints stayed the same") + self.assertTrue(line in lines, "line expected in lines array") + self.assertTrue(breakpoint['verified'], + "expect breakpoint still verified") + + # Now get the full list of breakpoints set in the target and verify + # we have only 2 breakpoints set. The response above could have told + # us about 2 breakpoints, but we want to make sure we don't have the + # third one still set in the target + response = self.vscode.request_testGetTargetBreakpoints() + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + for breakpoint in breakpoints: + line = breakpoint['line'] + # Verify the same breakpoints are still set within LLDB by + # making sure the breakpoint ID didn't change + self.assertTrue(line_to_id[line] == breakpoint['id'], + "verify previous breakpoints stayed the same") + self.assertTrue(line in lines, "line expected in lines array") + self.assertTrue(breakpoint['verified'], + "expect breakpoint still verified") + + # Now clear all breakpoints for the source file by passing down an + # empty lines array + lines = [] + response = self.vscode.request_setBreakpoints(source_path, lines) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + + # Verify with the target that all breakpoints have been cleared + response = self.vscode.request_testGetTargetBreakpoints() + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + + # Now set a breakpoint again in the same source file and verify it + # was added. + lines = [second_line] + response = self.vscode.request_setBreakpoints(source_path, lines) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + for breakpoint in breakpoints: + line = breakpoint['line'] + self.assertTrue(line in lines, "line expected in lines array") + self.assertTrue(breakpoint['verified'], + "expect breakpoint still verified") + + # Now get the full list of breakpoints set in the target and verify + # we have only 2 breakpoints set. The response above could have told + # us about 2 breakpoints, but we want to make sure we don't have the + # third one still set in the target + response = self.vscode.request_testGetTargetBreakpoints() + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(lines), + "expect %u source breakpoints" % (len(lines))) + for breakpoint in breakpoints: + line = breakpoint['line'] + self.assertTrue(line in lines, "line expected in lines array") + self.assertTrue(breakpoint['verified'], + "expect breakpoint still verified") + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_functionality(self): + '''Tests hitting breakpoints and the functionality of a single + breakpoint, like 'conditions' and 'hitCondition' settings.''' + source_basename = 'main.cpp' + source_path = os.path.join(os.getcwd(), source_basename) + loop_line = line_number('main.cpp', '// break loop') + + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + # Set a breakpoint at the loop line with no condition and no + # hitCondition + breakpoint_ids = self.set_source_breakpoints(source_path, [loop_line]) + self.assertTrue(len(breakpoint_ids) == 1, "expect one breakpoint") + self.vscode.request_continue() + + # Verify we hit the breakpoint we just set + self.verify_breakpoint_hit(breakpoint_ids) + + # Make sure i is zero at first breakpoint + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 0, 'i != 0 after hitting breakpoint') + + # Update the condition on our breakpoint + new_breakpoint_ids = self.set_source_breakpoints(source_path, + [loop_line], + condition="i==4") + self.assertTrue(breakpoint_ids == new_breakpoint_ids, + "existing breakpoint should have its condition " + "updated") + + self.continue_to_breakpoints(breakpoint_ids) + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 4, + 'i != 4 showing conditional works') + + new_breakpoint_ids = self.set_source_breakpoints(source_path, + [loop_line], + hitCondition="2") + + self.assertTrue(breakpoint_ids == new_breakpoint_ids, + "existing breakpoint should have its condition " + "updated") + + # Continue with a hitContidtion of 2 and expect it to skip 1 value + self.continue_to_breakpoints(breakpoint_ids) + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 6, + 'i != 6 showing hitCondition works') + + # continue after hitting our hitCondition and make sure it only goes + # up by 1 + self.continue_to_breakpoints(breakpoint_ids) + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 7, + 'i != 7 showing post hitCondition hits every time') diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.py new file mode 100644 index 000000000000..fdba683760e0 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.py @@ -0,0 +1,51 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import pprint +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os + + +class TestVSCode_setExceptionBreakpoints( + lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_functionality(self): + '''Tests setting and clearing exception breakpoints. + This packet is a bit tricky on the debug adaptor side since there + is no "clear exception breakpoints" packet. Exception breakpoints + are set by sending a "setExceptionBreakpoints" packet with zero or + more exception filters. If exception breakpoints have been set + before, any exising breakpoints must remain set, and any new + breakpoints must be created, and any breakpoints that were in + previous requests and are not in the current request must be + removed. This exception tests this setting and clearing and makes + sure things happen correctly. It doesn't test hitting breakpoints + and the functionality of each breakpoint, like 'conditions' and + x'hitCondition' settings. + ''' + # Visual Studio Code Debug Adaptors have no way to specify the file + # without launching or attaching to a process, so we must start a + # process in order to be able to set breakpoints. + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + + filters = ['cpp_throw', 'cpp_catch'] + response = self.vscode.request_setExceptionBreakpoints(filters) + if response: + self.assertTrue(response['success']) + + self.continue_to_exception_breakpoint('C++ Throw') + self.continue_to_exception_breakpoint('C++ Catch') diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py new file mode 100644 index 000000000000..c7c67597c86b --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py @@ -0,0 +1,167 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import pprint +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os + + +class TestVSCode_setFunctionBreakpoints( + lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # test hangs on linux under heavy load + @no_debug_info_test + def test_set_and_clear(self): + '''Tests setting and clearing function breakpoints. + This packet is a bit tricky on the debug adaptor side since there + is no "clearFunction Breakpoints" packet. Function breakpoints + are set by sending a "setFunctionBreakpoints" packet with zero or + more function names. If function breakpoints have been set before, + any exising breakpoints must remain set, and any new breakpoints + must be created, and any breakpoints that were in previous requests + and are not in the current request must be removed. This function + tests this setting and clearing and makes sure things happen + correctly. It doesn't test hitting breakpoints and the functionality + of each breakpoint, like 'conditions' and 'hitCondition' settings. + ''' + # Visual Studio Code Debug Adaptors have no way to specify the file + # without launching or attaching to a process, so we must start a + # process in order to be able to set breakpoints. + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + bp_id_12 = None + functions = ['twelve'] + # Set a function breakpoint at 'twelve' + response = self.vscode.request_setFunctionBreakpoints(functions) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(functions), + "expect %u source breakpoints" % (len(functions))) + for breakpoint in breakpoints: + bp_id_12 = breakpoint['id'] + self.assertTrue(breakpoint['verified'], + "expect breakpoint verified") + + # Add an extra name and make sure we have two breakpoints after this + functions.append('thirteen') + response = self.vscode.request_setFunctionBreakpoints(functions) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(functions), + "expect %u source breakpoints" % (len(functions))) + for breakpoint in breakpoints: + self.assertTrue(breakpoint['verified'], + "expect breakpoint verified") + + # There is no breakpoint delete packet, clients just send another + # setFunctionBreakpoints packet with the different function names. + functions.remove('thirteen') + response = self.vscode.request_setFunctionBreakpoints(functions) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(functions), + "expect %u source breakpoints" % (len(functions))) + for breakpoint in breakpoints: + bp_id = breakpoint['id'] + self.assertTrue(bp_id == bp_id_12, + 'verify "twelve" breakpoint ID is same') + self.assertTrue(breakpoint['verified'], + "expect breakpoint still verified") + + # Now get the full list of breakpoints set in the target and verify + # we have only 1 breakpoints set. The response above could have told + # us about 1 breakpoints, but we want to make sure we don't have the + # second one still set in the target + response = self.vscode.request_testGetTargetBreakpoints() + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(functions), + "expect %u source breakpoints" % (len(functions))) + for breakpoint in breakpoints: + bp_id = breakpoint['id'] + self.assertTrue(bp_id == bp_id_12, + 'verify "twelve" breakpoint ID is same') + self.assertTrue(breakpoint['verified'], + "expect breakpoint still verified") + + # Now clear all breakpoints for the source file by passing down an + # empty lines array + functions = [] + response = self.vscode.request_setFunctionBreakpoints(functions) + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(functions), + "expect %u source breakpoints" % (len(functions))) + + # Verify with the target that all breakpoints have been cleared + response = self.vscode.request_testGetTargetBreakpoints() + if response: + breakpoints = response['body']['breakpoints'] + self.assertTrue(len(breakpoints) == len(functions), + "expect %u source breakpoints" % (len(functions))) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_functionality(self): + '''Tests hitting breakpoints and the functionality of a single + breakpoint, like 'conditions' and 'hitCondition' settings.''' + + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + # Set a breakpoint on "twelve" with no condition and no hitCondition + functions = ['twelve'] + breakpoint_ids = self.set_function_breakpoints(functions) + + self.assertTrue(len(breakpoint_ids) == len(functions), + "expect one breakpoint") + + # Verify we hit the breakpoint we just set + self.continue_to_breakpoints(breakpoint_ids) + + # Make sure i is zero at first breakpoint + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 0, 'i != 0 after hitting breakpoint') + + # Update the condition on our breakpoint + new_breakpoint_ids = self.set_function_breakpoints(functions, + condition="i==4") + self.assertTrue(breakpoint_ids == new_breakpoint_ids, + "existing breakpoint should have its condition " + "updated") + + self.continue_to_breakpoints(breakpoint_ids) + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 4, + 'i != 4 showing conditional works') + new_breakpoint_ids = self.set_function_breakpoints(functions, + hitCondition="2") + + self.assertTrue(breakpoint_ids == new_breakpoint_ids, + "existing breakpoint should have its condition " + "updated") + + # Continue with a hitContidtion of 2 and expect it to skip 1 value + self.continue_to_breakpoints(breakpoint_ids) + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 6, + 'i != 6 showing hitCondition works') + + # continue after hitting our hitCondition and make sure it only goes + # up by 1 + self.continue_to_breakpoints(breakpoint_ids) + i = int(self.vscode.get_local_variable_value('i')) + self.assertTrue(i == 7, + 'i != 7 showing post hitCondition hits every time') diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/main.cpp new file mode 100644 index 000000000000..e859b04e3a99 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/breakpoint/main.cpp @@ -0,0 +1,27 @@ +#include +#include + +int twelve(int i) { + return 12 + i; // break 12 +} + +int thirteen(int i) { + return 13 + i; // break 13 +} + +namespace a { + int fourteen(int i) { + return 14 + i; // break 14 + } +} +int main(int argc, char const *argv[]) { + for (int i=0; i<10; ++i) { + int x = twelve(i) + thirteen(i) + a::fourteen(i); // break loop + } + try { + throw std::invalid_argument( "throwing exception for testing" ); + } catch (...) { + puts("caught exception..."); + } + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/Makefile b/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/Makefile new file mode 100644 index 000000000000..b09a579159d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py new file mode 100644 index 000000000000..064cf9a6783e --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py @@ -0,0 +1,352 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import pprint +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os +import time + + +class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_default(self): + ''' + Tests the default launch of a simple program. No arguments, + environment, or anything else is specified. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + self.continue_to_exit() + # Now get the STDOUT and verify our program argument is correct + output = self.get_stdout() + self.assertTrue(output and len(output) > 0, + "expect program output") + lines = output.splitlines() + self.assertTrue(program in lines[0], + "make sure program path is in first argument") + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_stopOnEntry(self): + ''' + Tests the default launch of a simple program that stops at the + entry point instead of continuing. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program, stopOnEntry=True) + self.set_function_breakpoints(['main']) + stopped_events = self.continue_to_next_stop() + for stopped_event in stopped_events: + if 'body' in stopped_event: + body = stopped_event['body'] + if 'reason' in body: + reason = body['reason'] + self.assertTrue( + reason != 'breakpoint', + 'verify stop isn\'t "main" breakpoint') + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_cwd(self): + ''' + Tests the default launch of a simple program with a current working + directory. + ''' + program = self.getBuildArtifact("a.out") + program_parent_dir = os.path.split(os.path.split(program)[0])[0] + self.build_and_launch(program, + cwd=program_parent_dir) + self.continue_to_exit() + # Now get the STDOUT and verify our program argument is correct + output = self.get_stdout() + self.assertTrue(output and len(output) > 0, + "expect program output") + lines = output.splitlines() + found = False + for line in lines: + if line.startswith('cwd = \"'): + quote_path = '"%s"' % (program_parent_dir) + found = True + self.assertTrue(quote_path in line, + "working directory '%s' not in '%s'" % ( + program_parent_dir, line)) + self.assertTrue(found, "verified program working directory") + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_debuggerRoot(self): + ''' + Tests the "debuggerRoot" will change the working directory of + the lldb-vscode debug adaptor. + ''' + program = self.getBuildArtifact("a.out") + program_parent_dir = os.path.split(os.path.split(program)[0])[0] + commands = ['platform shell echo cwd = $PWD'] + self.build_and_launch(program, + debuggerRoot=program_parent_dir, + initCommands=commands) + output = self.get_console() + self.assertTrue(output and len(output) > 0, + "expect console output") + lines = output.splitlines() + prefix = 'cwd = ' + found = False + for line in lines: + if line.startswith(prefix): + found = True + self.assertTrue(program_parent_dir == line[len(prefix):], + "lldb-vscode working dir '%s' == '%s'" % ( + program_parent_dir, line[6:])) + self.assertTrue(found, "verified lldb-vscode working directory") + self.continue_to_exit() + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_sourcePath(self): + ''' + Tests the "sourcePath" will set the target.source-map. + ''' + program = self.getBuildArtifact("a.out") + program_dir = os.path.split(program)[0] + self.build_and_launch(program, + sourcePath=program_dir) + output = self.get_console() + self.assertTrue(output and len(output) > 0, + "expect console output") + lines = output.splitlines() + prefix = '(lldb) settings set target.source-map "." ' + found = False + for line in lines: + if line.startswith(prefix): + found = True + quoted_path = '"%s"' % (program_dir) + self.assertTrue(quoted_path == line[len(prefix):], + "lldb-vscode working dir %s == %s" % ( + quoted_path, line[6:])) + self.assertTrue(found, 'found "sourcePath" in console output') + self.continue_to_exit() + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_disableSTDIO(self): + ''' + Tests the default launch of a simple program with STDIO disabled. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program, + disableSTDIO=True) + self.continue_to_exit() + # Now get the STDOUT and verify our program argument is correct + output = self.get_stdout() + self.assertTrue(output is None or len(output) == 0, + "expect no program output") + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_shellExpandArguments_enabled(self): + ''' + Tests the default launch of a simple program with shell expansion + enabled. + ''' + program = self.getBuildArtifact("a.out") + program_dir = os.path.split(program)[0] + glob = os.path.join(program_dir, '*.out') + self.build_and_launch(program, args=[glob], shellExpandArguments=True) + self.continue_to_exit() + # Now get the STDOUT and verify our program argument is correct + output = self.get_stdout() + self.assertTrue(output and len(output) > 0, + "expect no program output") + lines = output.splitlines() + for line in lines: + quote_path = '"%s"' % (program) + if line.startswith("arg[1] ="): + self.assertTrue(quote_path in line, + 'verify "%s" expanded to "%s"' % ( + glob, program)) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_shellExpandArguments_disabled(self): + ''' + Tests the default launch of a simple program with shell expansion + disabled. + ''' + program = self.getBuildArtifact("a.out") + program_dir = os.path.split(program)[0] + glob = os.path.join(program_dir, '*.out') + self.build_and_launch(program, + args=[glob], + shellExpandArguments=False) + self.continue_to_exit() + # Now get the STDOUT and verify our program argument is correct + output = self.get_stdout() + self.assertTrue(output and len(output) > 0, + "expect no program output") + lines = output.splitlines() + for line in lines: + quote_path = '"%s"' % (glob) + if line.startswith("arg[1] ="): + self.assertTrue(quote_path in line, + 'verify "%s" stayed to "%s"' % ( + glob, glob)) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_args(self): + ''' + Tests launch of a simple program with arguments + ''' + program = self.getBuildArtifact("a.out") + args = ["one", "with space", "'with single quotes'", + '"with double quotes"'] + self.build_and_launch(program, + args=args) + self.continue_to_exit() + + # Now get the STDOUT and verify our arguments got passed correctly + output = self.get_stdout() + self.assertTrue(output and len(output) > 0, + "expect program output") + lines = output.splitlines() + # Skip the first argument that contains the program name + lines.pop(0) + # Make sure arguments we specified are correct + for (i, arg) in enumerate(args): + quoted_arg = '"%s"' % (arg) + self.assertTrue(quoted_arg in lines[i], + 'arg[%i] "%s" not in "%s"' % (i+1, quoted_arg, lines[i])) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_environment(self): + ''' + Tests launch of a simple program with environment variables + ''' + program = self.getBuildArtifact("a.out") + env = ["NO_VALUE", "WITH_VALUE=BAR", "EMPTY_VALUE=", + "SPACE=Hello World"] + self.build_and_launch(program, + env=env) + self.continue_to_exit() + + # Now get the STDOUT and verify our arguments got passed correctly + output = self.get_stdout() + self.assertTrue(output and len(output) > 0, + "expect program output") + lines = output.splitlines() + # Skip the all arguments so we have only environment vars left + while len(lines) and lines[0].startswith("arg["): + lines.pop(0) + # Make sure each environment variable in "env" is actually set in the + # program environment that was printed to STDOUT + for var in env: + found = False + for program_var in lines: + if var in program_var: + found = True + break + self.assertTrue(found, + '"%s" must exist in program environment (%s)' % ( + var, lines)) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @skipIfLinux # This test is timing out and/or failing on Linux as well as Darwin + @no_debug_info_test + def test_commands(self): + ''' + Tests the "initCommands", "preRunCommands", "stopCommands" and + "exitCommands" that can be passed during launch. + + "initCommands" are a list of LLDB commands that get executed + before the targt is created. + "preRunCommands" are a list of LLDB commands that get executed + after the target has been created and before the launch. + "stopCommands" are a list of LLDB commands that get executed each + time the program stops. + "exitCommands" are a list of LLDB commands that get executed when + the process exits + ''' + program = self.getBuildArtifact("a.out") + initCommands = ['target list', 'platform list'] + preRunCommands = ['image list a.out', 'image dump sections a.out'] + stopCommands = ['frame variable', 'bt'] + exitCommands = ['expr 2+3', 'expr 3+4'] + self.build_and_launch(program, + initCommands=initCommands, + preRunCommands=preRunCommands, + stopCommands=stopCommands, + exitCommands=exitCommands) + + # Get output from the console. This should contain both the + # "initCommands" and the "preRunCommands". + output = self.get_console() + # Verify all "initCommands" were found in console output + self.verify_commands('initCommands', output, initCommands) + # Verify all "preRunCommands" were found in console output + self.verify_commands('preRunCommands', output, preRunCommands) + + source = 'main.c' + first_line = line_number(source, '// breakpoint 1') + second_line = line_number(source, '// breakpoint 2') + lines = [first_line, second_line] + + # Set 2 breakoints so we can verify that "stopCommands" get run as the + # breakpoints get hit + breakpoint_ids = self.set_source_breakpoints(source, lines) + self.assertTrue(len(breakpoint_ids) == len(lines), + "expect correct number of breakpoints") + + # Continue after launch and hit the first breakpoint. + # Get output from the console. This should contain both the + # "stopCommands" that were run after the first breakpoint was hit + self.continue_to_breakpoints(breakpoint_ids) + output = self.get_console(timeout=1.0) + self.verify_commands('stopCommands', output, stopCommands) + + # Continue again and hit the second breakpoint. + # Get output from the console. This should contain both the + # "stopCommands" that were run after the second breakpoint was hit + self.continue_to_breakpoints(breakpoint_ids) + output = self.get_console(timeout=1.0) + self.verify_commands('stopCommands', output, stopCommands) + + # Continue until the program exits + self.continue_to_exit() + # Get output from the console. This should contain both the + # "exitCommands" that were run after the second breakpoint was hit + output = self.get_console(timeout=1.0) + self.verify_commands('exitCommands', output, exitCommands) diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/main.c b/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/main.c new file mode 100644 index 000000000000..aed2af9828f3 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/main.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int main(int argc, char const *argv[], char const *envp[]) { + for (int i=0; i> 32 + bp_loc_id = response_id & 0xffffffff + breakpoint_ids.append('%i.%i' % (bp_id, bp_loc_id)) + return breakpoint_ids + + def set_function_breakpoints(self, functions, condition=None, + hitCondition=None): + '''Sets breakpoints by function name given an array of function names + and returns an array of strings containing the breakpoint location + IDs ("1.1", "1.2") for each breakpoint that was set. + ''' + response = self.vscode.request_setFunctionBreakpoints( + functions, condition=condition, hitCondition=hitCondition) + if response is None: + return [] + breakpoints = response['body']['breakpoints'] + breakpoint_ids = [] + for breakpoint in breakpoints: + response_id = breakpoint['id'] + bp_id = response_id >> 32 + bp_loc_id = response_id & 0xffffffff + breakpoint_ids.append('%i.%i' % (bp_id, bp_loc_id)) + return breakpoint_ids + + def verify_breakpoint_hit(self, breakpoint_ids): + '''Wait for the process we are debugging to stop, and verify we hit + any breakpoint location in the "breakpoint_ids" array. + "breakpoint_ids" should be a list of breakpoint location ID strings + (["1.1", "2.1"]). The return value from + self.set_source_breakpoints() can be passed to this function''' + stopped_events = self.vscode.wait_for_stopped() + for stopped_event in stopped_events: + if 'body' in stopped_event: + body = stopped_event['body'] + if 'reason' not in body: + continue + if body['reason'] != 'breakpoint': + continue + if 'description' not in body: + continue + # Description is "breakpoint 1.1", so look for any location id + # ("1.1") in the description field as verification that one of + # the breakpoint locations was hit + description = body['description'] + for breakpoint_id in breakpoint_ids: + if breakpoint_id in description: + return True + return False + + def verify_exception_breakpoint_hit(self, filter_label): + '''Wait for the process we are debugging to stop, and verify the stop + reason is 'exception' and that the description matches + 'filter_label' + ''' + stopped_events = self.vscode.wait_for_stopped() + for stopped_event in stopped_events: + if 'body' in stopped_event: + body = stopped_event['body'] + if 'reason' not in body: + continue + if body['reason'] != 'exception': + continue + if 'description' not in body: + continue + description = body['description'] + if filter_label == description: + return True + return False + + def verify_commands(self, flavor, output, commands): + self.assertTrue(output and len(output) > 0, "expect console output") + lines = output.splitlines() + prefix = '(lldb) ' + for cmd in commands: + found = False + for line in lines: + if line.startswith(prefix) and cmd in line: + found = True + break + self.assertTrue(found, + "verify '%s' found in console output for '%s'" % ( + cmd, flavor)) + + def get_dict_value(self, d, key_path): + '''Verify each key in the key_path array is in contained in each + dictionary within "d". Assert if any key isn't in the + corresponding dictionary. This is handy for grabbing values from VS + Code response dictionary like getting + response['body']['stackFrames'] + ''' + value = d + for key in key_path: + if key in value: + value = value[key] + else: + self.assertTrue(key in value, + 'key "%s" from key_path "%s" not in "%s"' % ( + key, key_path, d)) + return value + + def get_stackFrames(self, threadId=None, startFrame=None, levels=None, + dump=False): + response = self.vscode.request_stackTrace(threadId=threadId, + startFrame=startFrame, + levels=levels, + dump=dump) + if response: + return self.get_dict_value(response, ['body', 'stackFrames']) + return None + + def get_source_and_line(self, threadId=None, frameIndex=0): + stackFrames = self.get_stackFrames(threadId=threadId, + startFrame=frameIndex, + levels=1) + if stackFrames is not None: + stackFrame = stackFrames[0] + ['source', 'path'] + if 'source' in stackFrame: + source = stackFrame['source'] + if 'path' in source: + if 'line' in stackFrame: + return (source['path'], stackFrame['line']) + return ('', 0) + + def get_stdout(self, timeout=0.0): + return self.vscode.get_output('stdout', timeout=timeout) + + def get_console(self, timeout=0.0): + return self.vscode.get_output('console', timeout=timeout) + + def get_local_as_int(self, name, threadId=None): + value = self.vscode.get_local_variable_value(name, threadId=threadId) + if value.startswith('0x'): + return int(value, 16) + elif value.startswith('0'): + return int(value, 8) + else: + return int(value) + + def set_local(self, name, value, id=None): + '''Set a top level local variable only.''' + return self.vscode.request_setVariable(1, name, str(value), id=id) + + def set_global(self, name, value, id=None): + '''Set a top level global variable only.''' + return self.vscode.request_setVariable(2, name, str(value), id=id) + + def stepIn(self, threadId=None, waitForStop=True): + self.vscode.request_stepIn(threadId=threadId) + if waitForStop: + return self.vscode.wait_for_stopped() + return None + + def stepOver(self, threadId=None, waitForStop=True): + self.vscode.request_next(threadId=threadId) + if waitForStop: + return self.vscode.wait_for_stopped() + return None + + def stepOut(self, threadId=None, waitForStop=True): + self.vscode.request_stepOut(threadId=threadId) + if waitForStop: + return self.vscode.wait_for_stopped() + return None + + def continue_to_next_stop(self): + self.vscode.request_continue() + return self.vscode.wait_for_stopped() + + def continue_to_breakpoints(self, breakpoint_ids): + self.vscode.request_continue() + self.verify_breakpoint_hit(breakpoint_ids) + + def continue_to_exception_breakpoint(self, filter_label): + self.vscode.request_continue() + self.assertTrue(self.verify_exception_breakpoint_hit(filter_label), + 'verify we got "%s"' % (filter_label)) + + def continue_to_exit(self, exitCode=0): + self.vscode.request_continue() + stopped_events = self.vscode.wait_for_stopped() + self.assertTrue(len(stopped_events) == 1, + "expecting single 'exited' event") + self.assertTrue(stopped_events[0]['event'] == 'exited', + 'make sure program ran to completion') + self.assertTrue(stopped_events[0]['body']['exitCode'] == exitCode, + 'exitCode == %i' % (exitCode)) + + def attach(self, program=None, pid=None, waitFor=None, trace=None, + initCommands=None, preRunCommands=None, stopCommands=None, + exitCommands=None, attachCommands=None): + '''Build the default Makefile target, create the VSCode debug adaptor, + and attach to the process. + ''' + # Make sure we disconnect and terminate the VSCode debug adaptor even + # if we throw an exception during the test case. + def cleanup(): + self.vscode.request_disconnect(terminateDebuggee=True) + self.vscode.terminate() + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + # Initialize and launch the program + self.vscode.request_initialize() + response = self.vscode.request_attach( + program=program, pid=pid, waitFor=waitFor, trace=trace, + initCommands=initCommands, preRunCommands=preRunCommands, + stopCommands=stopCommands, exitCommands=exitCommands, + attachCommands=attachCommands) + if not (response and response['success']): + self.assertTrue(response['success'], + 'attach failed (%s)' % (response['message'])) + + def build_and_launch(self, program, args=None, cwd=None, env=None, + stopOnEntry=False, disableASLR=True, + disableSTDIO=False, shellExpandArguments=False, + trace=False, initCommands=None, preRunCommands=None, + stopCommands=None, exitCommands=None, + sourcePath=None, debuggerRoot=None): + '''Build the default Makefile target, create the VSCode debug adaptor, + and launch the process. + ''' + self.build_and_create_debug_adaptor() + self.assertTrue(os.path.exists(program), 'executable must exist') + + # Make sure we disconnect and terminate the VSCode debug adaptor even + # if we throw an exception during the test case. + def cleanup(): + self.vscode.request_disconnect(terminateDebuggee=True) + self.vscode.terminate() + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + # Initialize and launch the program + self.vscode.request_initialize() + response = self.vscode.request_launch( + program, + args=args, + cwd=cwd, + env=env, + stopOnEntry=stopOnEntry, + disableASLR=disableASLR, + disableSTDIO=disableSTDIO, + shellExpandArguments=shellExpandArguments, + trace=trace, + initCommands=initCommands, + preRunCommands=preRunCommands, + stopCommands=stopCommands, + exitCommands=exitCommands, + sourcePath=sourcePath, + debuggerRoot=debuggerRoot) + if not (response and response['success']): + self.assertTrue(response['success'], + 'launch failed (%s)' % (response['message'])) diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/Makefile b/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/Makefile new file mode 100644 index 000000000000..b09a579159d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py new file mode 100644 index 000000000000..4bb061881c47 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py @@ -0,0 +1,160 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os + + +class TestVSCode_stackTrace(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + name_key_path = ['name'] + source_key_path = ['source', 'path'] + line_key_path = ['line'] + + def verify_stackFrames(self, start_idx, stackFrames): + frame_idx = start_idx + for stackFrame in stackFrames: + # Don't care about frame above main + if frame_idx > 20: + return + self.verify_stackFrame(frame_idx, stackFrame) + frame_idx += 1 + + def verify_stackFrame(self, frame_idx, stackFrame): + frame_name = self.get_dict_value(stackFrame, self.name_key_path) + frame_source = self.get_dict_value(stackFrame, self.source_key_path) + frame_line = self.get_dict_value(stackFrame, self.line_key_path) + if frame_idx == 0: + expected_line = self.recurse_end + expected_name = 'recurse' + elif frame_idx < 20: + expected_line = self.recurse_call + expected_name = 'recurse' + else: + expected_line = self.recurse_invocation + expected_name = 'main' + self.assertTrue(frame_name == expected_name, + 'frame #%i name "%s" == "%s"' % ( + frame_idx, frame_name, expected_name)) + self.assertTrue(frame_source == self.source_path, + 'frame #%i source "%s" == "%s"' % ( + frame_idx, frame_source, self.source_path)) + self.assertTrue(frame_line == expected_line, + 'frame #%i line %i == %i' % (frame_idx, frame_line, + expected_line)) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_stackTrace(self): + ''' + Tests the 'stackTrace' packet and all its variants. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = 'main.c' + self.source_path = os.path.join(os.getcwd(), source) + self.recurse_end = line_number(source, 'recurse end') + self.recurse_call = line_number(source, 'recurse call') + self.recurse_invocation = line_number(source, 'recurse invocation') + + lines = [self.recurse_end] + + # Set breakoint at a point of deepest recuusion + breakpoint_ids = self.set_source_breakpoints(source, lines) + self.assertTrue(len(breakpoint_ids) == len(lines), + "expect correct number of breakpoints") + + self.continue_to_breakpoints(breakpoint_ids) + startFrame = 0 + # Verify we get all stack frames with no arguments + stackFrames = self.get_stackFrames() + frameCount = len(stackFrames) + self.assertTrue(frameCount >= 20, + 'verify we get at least 20 frames for all frames') + self.verify_stackFrames(startFrame, stackFrames) + + # Verify all stack frames by specifying startFrame = 0 and levels not + # specified + stackFrames = self.get_stackFrames(startFrame=startFrame) + self.assertTrue(frameCount == len(stackFrames), + ('verify same number of frames with startFrame=%i') % ( + startFrame)) + self.verify_stackFrames(startFrame, stackFrames) + + # Verify all stack frames by specifying startFrame = 0 and levels = 0 + levels = 0 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(frameCount == len(stackFrames), + ('verify same number of frames with startFrame=%i and' + ' levels=%i') % (startFrame, levels)) + self.verify_stackFrames(startFrame, stackFrames) + + # Get only the first stack frame by sepcifying startFrame = 0 and + # levels = 1 + levels = 1 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(levels == len(stackFrames), + ('verify one frame with startFrame=%i and' + ' levels=%i') % (startFrame, levels)) + self.verify_stackFrames(startFrame, stackFrames) + + # Get only the first 3 stack frames by sepcifying startFrame = 0 and + # levels = 3 + levels = 3 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(levels == len(stackFrames), + ('verify %i frames with startFrame=%i and' + ' levels=%i') % (levels, startFrame, levels)) + self.verify_stackFrames(startFrame, stackFrames) + + # Get only the first 15 stack frames by sepcifying startFrame = 5 and + # levels = 16 + startFrame = 5 + levels = 16 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(levels == len(stackFrames), + ('verify %i frames with startFrame=%i and' + ' levels=%i') % (levels, startFrame, levels)) + self.verify_stackFrames(startFrame, stackFrames) + + # Verify we cap things correctly when we ask for too many frames + startFrame = 5 + levels = 1000 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(len(stackFrames) == frameCount - startFrame, + ('verify less than 1000 frames with startFrame=%i and' + ' levels=%i') % (startFrame, levels)) + self.verify_stackFrames(startFrame, stackFrames) + + # Verify level=0 works with non-zerp start frame + startFrame = 5 + levels = 0 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(len(stackFrames) == frameCount - startFrame, + ('verify less than 1000 frames with startFrame=%i and' + ' levels=%i') % (startFrame, levels)) + self.verify_stackFrames(startFrame, stackFrames) + + # Verify we get not frames when startFrame is too high + startFrame = 1000 + levels = 1 + stackFrames = self.get_stackFrames(startFrame=startFrame, + levels=levels) + self.assertTrue(0 == len(stackFrames), + 'verify zero frames with startFrame out of bounds') diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/main.c b/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/main.c new file mode 100644 index 000000000000..85b41c492817 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/stackTrace/main.c @@ -0,0 +1,13 @@ +#include +#include + +int recurse(int x) { + if (x <= 1) + return 1; // recurse end + return recurse(x-1) + x; // recurse call +} + +int main(int argc, char const *argv[]) { + recurse(20); // recurse invocation + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile b/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile new file mode 100644 index 000000000000..f24bb9f4d267 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +ENABLE_THREADS := YES + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py new file mode 100644 index 000000000000..87ec71a513f6 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py @@ -0,0 +1,79 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os + + +class TestVSCode_step(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_step(self): + ''' + Tests the stepping in/out/over in threads. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = 'main.cpp' + # source_path = os.path.join(os.getcwd(), source) + breakpoint1_line = line_number(source, '// breakpoint 1') + lines = [breakpoint1_line] + # Set breakoint in the thread function so we can step the threads + breakpoint_ids = self.set_source_breakpoints(source, lines) + self.assertTrue(len(breakpoint_ids) == len(lines), + "expect correct number of breakpoints") + self.continue_to_breakpoints(breakpoint_ids) + threads = self.vscode.get_threads() + for thread in threads: + if 'reason' in thread: + reason = thread['reason'] + if reason == 'breakpoint': + # We have a thread that is stopped at our breakpoint. + # Get the value of "x" and get the source file and line. + # These will help us determine if we are stepping + # correctly. If we step a thread correctly we will verify + # the correct falue for x as it progresses through the + # program. + tid = thread['id'] + x1 = self.get_local_as_int('x', threadId=tid) + (src1, line1) = self.get_source_and_line(threadId=tid) + + # Now step into the "recurse()" function call again and + # verify, using the new value of "x" and the source file + # and line if we stepped correctly + self.stepIn(threadId=tid, waitForStop=True) + x2 = self.get_local_as_int('x', threadId=tid) + (src2, line2) = self.get_source_and_line(threadId=tid) + self.assertTrue(x1 == x2 + 1, 'verify step in variable') + self.assertTrue(line2 < line1, 'verify step in line') + self.assertTrue(src1 == src2, 'verify step in source') + + # Now step out and verify + self.stepOut(threadId=tid, waitForStop=True) + x3 = self.get_local_as_int('x', threadId=tid) + (src3, line3) = self.get_source_and_line(threadId=tid) + self.assertTrue(x1 == x3, 'verify step out variable') + self.assertTrue(line3 >= line1, 'verify step out line') + self.assertTrue(src1 == src3, 'verify step in source') + + # Step over and verify + self.stepOver(threadId=tid, waitForStop=True) + x4 = self.get_local_as_int('x', threadId=tid) + (src4, line4) = self.get_source_and_line(threadId=tid) + self.assertTrue(x4 == x3, 'verify step over variable') + self.assertTrue(line4 > line3, 'verify step over line') + self.assertTrue(src1 == src4, 'verify step over source') + # only step one thread that is at the breakpoint and stop + break diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp new file mode 100644 index 000000000000..2fd063113875 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp @@ -0,0 +1,16 @@ +#include + +int function(int x) { + if ((x % 2) == 0) + return function(x-1) + x; // breakpoint 1 + else + return x; +} + +int main(int argc, char const *argv[]) { + std::thread thread1(function, 2); + std::thread thread2(function, 4); + thread1.join(); + thread2.join(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/Makefile b/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py b/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py new file mode 100644 index 000000000000..0a8906f1c6c8 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py @@ -0,0 +1,225 @@ +""" +Test lldb-vscode setBreakpoints request +""" + +from __future__ import print_function + +import unittest2 +import vscode +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +import lldbvscode_testcase +import os + + +def make_buffer_verify_dict(start_idx, count, offset=0): + verify_dict = {} + for i in range(start_idx, start_idx + count): + verify_dict['[%i]' % (i)] = {'type': 'int', 'value': str(i+offset)} + return verify_dict + + +class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + def verify_values(self, verify_dict, actual, varref_dict=None): + if 'equals' in verify_dict: + verify = verify_dict['equals'] + for key in verify: + verify_value = verify[key] + actual_value = actual[key] + self.assertTrue(verify_value == actual_value, + '"%s" keys don\'t match (%s != %s)' % ( + key, actual_value, verify_value)) + if 'startswith' in verify_dict: + verify = verify_dict['startswith'] + for key in verify: + verify_value = verify[key] + actual_value = actual[key] + startswith = actual_value.startswith(verify_value) + self.assertTrue(startswith, + ('"%s" value "%s" doesn\'t start with' + ' "%s")') % ( + key, actual_value, + verify_value)) + hasVariablesReference = 'variablesReference' in actual + varRef = None + if hasVariablesReference: + # Remember variable references in case we want to test further + # by using the evaluate name. + varRef = actual['variablesReference'] + if varRef != 0 and varref_dict is not None: + varref_dict[actual['evaluateName']] = varRef + if ('hasVariablesReference' in verify_dict and + verify_dict['hasVariablesReference']): + self.assertTrue(hasVariablesReference, + "verify variable reference") + if 'children' in verify_dict: + self.assertTrue(hasVariablesReference and varRef is not None and + varRef != 0, + ("children verify values specified for " + "variable without children")) + + response = self.vscode.request_variables(varRef) + self.verify_variables(verify_dict['children'], + response['body']['variables'], + varref_dict) + + def verify_variables(self, verify_dict, variables, varref_dict=None): + for variable in variables: + name = variable['name'] + self.assertTrue(name in verify_dict, + 'variable "%s" in verify dictionary' % (name)) + self.verify_values(verify_dict[name], variable, varref_dict) + + @skipIfWindows + @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + @no_debug_info_test + def test_scopes_variables_setVariable_evaluate(self): + ''' + Tests the "scopes", "variables", "setVariable", and "evaluate" + packets. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program) + source = 'main.cpp' + breakpoint1_line = line_number(source, '// breakpoint 1') + lines = [breakpoint1_line] + # Set breakoint in the thread function so we can step the threads + breakpoint_ids = self.set_source_breakpoints(source, lines) + self.assertTrue(len(breakpoint_ids) == len(lines), + "expect correct number of breakpoints") + self.continue_to_breakpoints(breakpoint_ids) + locals = self.vscode.get_local_variables() + globals = self.vscode.get_global_variables() + buffer_children = make_buffer_verify_dict(0, 32) + verify_locals = { + 'argc': { + 'equals': {'type': 'int', 'value': '1'} + }, + 'argv': { + 'equals': {'type': 'const char **'}, + 'startswith': {'value': '0x'}, + 'hasVariablesReference': True + }, + 'pt': { + 'equals': {'type': 'PointType'}, + 'hasVariablesReference': True, + 'children': { + 'x': {'equals': {'type': 'int', 'value': '11'}}, + 'y': {'equals': {'type': 'int', 'value': '22'}}, + 'buffer': {'children': buffer_children} + } + } + } + verify_globals = { + 's_local': { + 'equals': {'type': 'float', 'value': '2.25'} + }, + '::g_global': { + 'equals': {'type': 'int', 'value': '123'} + }, + 's_global': { + 'equals': {'type': 'int', 'value': '234'} + }, + } + varref_dict = {} + self.verify_variables(verify_locals, locals, varref_dict) + self.verify_variables(verify_globals, globals, varref_dict) + # pprint.PrettyPrinter(indent=4).pprint(varref_dict) + # We need to test the functionality of the "variables" request as it + # has optional parameters like "start" and "count" to limit the number + # of variables that are fetched + varRef = varref_dict['pt.buffer'] + response = self.vscode.request_variables(varRef) + self.verify_variables(buffer_children, response['body']['variables']) + # Verify setting start=0 in the arguments still gets all children + response = self.vscode.request_variables(varRef, start=0) + self.verify_variables(buffer_children, response['body']['variables']) + # Verify setting count=0 in the arguments still gets all children. + # If count is zero, it means to get all children. + response = self.vscode.request_variables(varRef, count=0) + self.verify_variables(buffer_children, response['body']['variables']) + # Verify setting count to a value that is too large in the arguments + # still gets all children, and no more + response = self.vscode.request_variables(varRef, count=1000) + self.verify_variables(buffer_children, response['body']['variables']) + # Verify setting the start index and count gets only the children we + # want + response = self.vscode.request_variables(varRef, start=5, count=5) + self.verify_variables(make_buffer_verify_dict(5, 5), + response['body']['variables']) + # Verify setting the start index to a value that is out of range + # results in an empty list + response = self.vscode.request_variables(varRef, start=32, count=1) + self.assertTrue(len(response['body']['variables']) == 0, + 'verify we get no variable back for invalid start') + + # Test evaluate + expressions = { + 'pt.x': { + 'equals': {'result': '11', 'type': 'int'}, + 'hasVariablesReference': False + }, + 'pt.buffer[2]': { + 'equals': {'result': '2', 'type': 'int'}, + 'hasVariablesReference': False + }, + 'pt': { + 'equals': {'type': 'PointType'}, + 'startswith': {'result': 'PointType @ 0x'}, + 'hasVariablesReference': True + }, + 'pt.buffer': { + 'equals': {'type': 'int [32]'}, + 'startswith': {'result': 'int [32] @ 0x'}, + 'hasVariablesReference': True + }, + 'argv': { + 'equals': {'type': 'const char **'}, + 'startswith': {'result': '0x'}, + 'hasVariablesReference': True + }, + 'argv[0]': { + 'equals': {'type': 'const char *'}, + 'startswith': {'result': '0x'}, + 'hasVariablesReference': True + }, + '2+3': { + 'equals': {'result': '5', 'type': 'int'}, + 'hasVariablesReference': False + }, + } + for expression in expressions: + response = self.vscode.request_evaluate(expression) + self.verify_values(expressions[expression], response['body']) + + # Test setting variables + self.set_local('argc', 123) + argc = self.get_local_as_int('argc') + self.assertTrue(argc == 123, + 'verify argc was set to 123 (123 != %i)' % (argc)) + + self.set_local('argv', 0x1234) + argv = self.get_local_as_int('argv') + self.assertTrue(argv == 0x1234, + 'verify argv was set to 0x1234 (0x1234 != %#x)' % ( + argv)) + + # Set a variable value whose name is synthetic, like a variable index + # and verify the value by reading it + self.vscode.request_setVariable(varRef, "[0]", 100) + response = self.vscode.request_variables(varRef, start=0, count=1) + self.verify_variables(make_buffer_verify_dict(0, 1, 100), + response['body']['variables']) + + # Set a variable value whose name is a real child value, like "pt.x" + # and verify the value by reading it + varRef = varref_dict['pt'] + self.vscode.request_setVariable(varRef, "x", 111) + response = self.vscode.request_variables(varRef, start=0, count=1) + value = response['body']['variables'][0]['value'] + self.assertTrue(value == '111', + 'verify pt.x got set to 111 (111 != %s)' % (value)) diff --git a/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/main.cpp new file mode 100644 index 000000000000..0223bd0a75ea --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/main.cpp @@ -0,0 +1,18 @@ + +#define BUFFER_SIZE 32 +struct PointType { + int x; + int y; + int buffer[BUFFER_SIZE]; +}; + +int g_global = 123; +static int s_global = 234; + +int main(int argc, char const *argv[]) { + static float s_local = 2.25; + PointType pt = { 11,22, {0}}; + for (int i=0; i= num_per_line: + curr_data_len = num_per_line + else: + curr_data_len = bytes_left + hex_start_idx = i * 2 + hex_end_idx = hex_start_idx + curr_data_len * 2 + curr_hex_str = hex_string[hex_start_idx:hex_end_idx] + # 'curr_hex_str' now contains the hex byte string for the + # current line with no spaces between bytes + t = iter(curr_hex_str) + # Print hex bytes separated by space + outfile.write(' '.join(a + b for a, b in zip(t, t))) + # Print two spaces + outfile.write(' ') + # Calculate ASCII string for bytes into 'ascii_str' + ascii_str = '' + for j in range(i, i + curr_data_len): + ch = data[j] + if ch in string.printable and ch not in string.whitespace: + ascii_str += '%c' % (ch) + else: + ascii_str += '.' + # Print ASCII representation and newline + outfile.write(ascii_str) + i = i + curr_data_len + outfile.write('\n') + + +def read_packet(f, verbose=False, trace_file=None): + '''Decode a JSON packet that starts with the content length and is + followed by the JSON bytes from a file 'f' + ''' + line = f.readline() + if len(line) == 0: + return None + + # Watch for line that starts with the prefix + prefix = 'Content-Length: ' + if line.startswith(prefix): + # Decode length of JSON bytes + if verbose: + print('content: "%s"' % (line)) + length = int(line[len(prefix):]) + if verbose: + print('length: "%u"' % (length)) + # Skip empty line + line = f.readline() + if verbose: + print('empty: "%s"' % (line)) + # Read JSON bytes + json_str = f.read(length) + if verbose: + print('json: "%s"' % (json_str)) + if trace_file: + trace_file.write('from adaptor:\n%s\n' % (json_str)) + # Decode the JSON bytes into a python dictionary + return json.loads(json_str) + + return None + + +def packet_type_is(packet, packet_type): + return 'type' in packet and packet['type'] == packet_type + + +def read_packet_thread(vs_comm): + done = False + while not done: + packet = read_packet(vs_comm.recv, trace_file=vs_comm.trace_file) + if packet: + done = not vs_comm.handle_recv_packet(packet) + else: + done = True + + +class DebugCommunication(object): + + def __init__(self, recv, send): + self.trace_file = None + self.send = send + self.recv = recv + self.recv_packets = [] + self.recv_condition = threading.Condition() + self.recv_thread = threading.Thread(target=read_packet_thread, + args=(self,)) + self.process_event_body = None + self.exit_status = None + self.initialize_body = None + self.thread_stop_reasons = {} + self.sequence = 1 + self.threads = None + self.recv_thread.start() + self.output_condition = threading.Condition() + self.output = {} + self.configuration_done_sent = False + self.frame_scopes = {} + + @classmethod + def encode_content(cls, s): + return "Content-Length: %u\r\n\r\n%s" % (len(s), s) + + @classmethod + def validate_response(cls, command, response): + if command['command'] != response['command']: + raise ValueError('command mismatch in response') + if command['seq'] != response['request_seq']: + raise ValueError('seq mismatch in response') + + def get_output(self, category, timeout=0.0, clear=True): + self.output_condition.acquire() + output = None + if category in self.output: + output = self.output[category] + if clear: + del self.output[category] + elif timeout != 0.0: + self.output_condition.wait(timeout) + if category in self.output: + output = self.output[category] + if clear: + del self.output[category] + self.output_condition.release() + return output + + def handle_recv_packet(self, packet): + '''Called by the read thread that is waiting for all incoming packets + to store the incoming packet in "self.recv_packets" in a thread safe + way. This function will then signal the "self.recv_condition" to + indicate a new packet is available. Returns True if the caller + should keep calling this function for more packets. + ''' + # Check the packet to see if is an event packet + keepGoing = True + packet_type = packet['type'] + if packet_type == 'event': + event = packet['event'] + body = None + if 'body' in packet: + body = packet['body'] + # Handle the event packet and cache information from these packets + # as they come in + if event == 'output': + # Store any output we receive so clients can retrieve it later. + category = body['category'] + output = body['output'] + self.output_condition.acquire() + if category in self.output: + self.output[category] += output + else: + self.output[category] = output + self.output_condition.notify() + self.output_condition.release() + # no need to add 'output' packets to our packets list + return keepGoing + elif event == 'process': + # When a new process is attached or launched, remember the + # details that are available in the body of the event + self.process_event_body = body + elif event == 'stopped': + # Each thread that stops with a reason will send a + # 'stopped' event. We need to remember the thread stop + # reasons since the 'threads' command doesn't return + # that information. + self._process_stopped() + tid = body['threadId'] + self.thread_stop_reasons[tid] = body + elif packet_type == 'response': + if packet['command'] == 'disconnect': + keepGoing = False + self.recv_condition.acquire() + self.recv_packets.append(packet) + self.recv_condition.notify() + self.recv_condition.release() + return keepGoing + + def send_packet(self, command_dict, set_sequence=True): + '''Take the "command_dict" python dictionary and encode it as a JSON + string and send the contents as a packet to the VSCode debug + adaptor''' + # Set the sequence ID for this command automatically + if set_sequence: + command_dict['seq'] = self.sequence + self.sequence += 1 + # Encode our command dictionary as a JSON string + json_str = json.dumps(command_dict, separators=(',', ':')) + if self.trace_file: + self.trace_file.write('to adaptor:\n%s\n' % (json_str)) + length = len(json_str) + if length > 0: + # Send the encoded JSON packet and flush the 'send' file + self.send.write(self.encode_content(json_str)) + self.send.flush() + + def recv_packet(self, filter_type=None, filter_event=None, timeout=None): + '''Get a JSON packet from the VSCode debug adaptor. This function + assumes a thread that reads packets is running and will deliver + any received packets by calling handle_recv_packet(...). This + function will wait for the packet to arrive and return it when + it does.''' + while True: + self.recv_condition.acquire() + packet = None + while True: + for (i, curr_packet) in enumerate(self.recv_packets): + packet_type = curr_packet['type'] + if filter_type is None or packet_type in filter_type: + if (filter_event is None or + (packet_type == 'event' and + curr_packet['event'] in filter_event)): + packet = self.recv_packets.pop(i) + break + if packet: + break + # Sleep until packet is received + len_before = len(self.recv_packets) + self.recv_condition.wait(timeout) + len_after = len(self.recv_packets) + if len_before == len_after: + return None # Timed out + self.recv_condition.release() + return packet + + return None + + def send_recv(self, command): + '''Send a command python dictionary as JSON and receive the JSON + response. Validates that the response is the correct sequence and + command in the reply. Any events that are received are added to the + events list in this object''' + self.send_packet(command) + done = False + while not done: + response = self.recv_packet(filter_type='response') + if response is None: + desc = 'no response for "%s"' % (command['command']) + raise ValueError(desc) + self.validate_response(command, response) + return response + return None + + def wait_for_event(self, filter=None, timeout=None): + while True: + return self.recv_packet(filter_type='event', filter_event=filter, + timeout=timeout) + return None + + def wait_for_stopped(self, timeout=None): + stopped_events = [] + stopped_event = self.wait_for_event(filter=['stopped', 'exited'], + timeout=timeout) + exited = False + while stopped_event: + stopped_events.append(stopped_event) + # If we exited, then we are done + if stopped_event['event'] == 'exited': + self.exit_status = stopped_event['body']['exitCode'] + exited = True + break + # Otherwise we stopped and there might be one or more 'stopped' + # events for each thread that stopped with a reason, so keep + # checking for more 'stopped' events and return all of them + stopped_event = self.wait_for_event(filter='stopped', timeout=0.25) + if exited: + self.threads = [] + return stopped_events + + def wait_for_exited(self): + event_dict = self.wait_for_event('exited') + if event_dict is None: + raise ValueError("didn't get stopped event") + return event_dict + + def get_initialize_value(self, key): + '''Get a value for the given key if it there is a key/value pair in + the "initialize" request response body. + ''' + if self.initialize_body and key in self.initialize_body: + return self.initialize_body[key] + return None + + def get_threads(self): + if self.threads is None: + self.request_threads() + return self.threads + + def get_thread_id(self, threadIndex=0): + '''Utility function to get the first thread ID in the thread list. + If the thread list is empty, then fetch the threads. + ''' + if self.threads is None: + self.request_threads() + if self.threads and threadIndex < len(self.threads): + return self.threads[threadIndex]['id'] + return None + + def get_stackFrame(self, frameIndex=0, threadId=None): + '''Get a single "StackFrame" object from a "stackTrace" request and + return the "StackFrame as a python dictionary, or None on failure + ''' + if threadId is None: + threadId = self.get_thread_id() + if threadId is None: + print('invalid threadId') + return None + response = self.request_stackTrace(threadId, startFrame=frameIndex, + levels=1) + if response: + return response['body']['stackFrames'][0] + print('invalid response') + return None + + def get_scope_variables(self, scope_name, frameIndex=0, threadId=None): + stackFrame = self.get_stackFrame(frameIndex=frameIndex, + threadId=threadId) + if stackFrame is None: + return [] + frameId = stackFrame['id'] + if frameId in self.frame_scopes: + frame_scopes = self.frame_scopes[frameId] + else: + scopes_response = self.request_scopes(frameId) + frame_scopes = scopes_response['body']['scopes'] + self.frame_scopes[frameId] = frame_scopes + for scope in frame_scopes: + if scope['name'] == scope_name: + varRef = scope['variablesReference'] + variables_response = self.request_variables(varRef) + if variables_response: + if 'body' in variables_response: + body = variables_response['body'] + if 'variables' in body: + vars = body['variables'] + return vars + return [] + + def get_global_variables(self, frameIndex=0, threadId=None): + return self.get_scope_variables('Globals', frameIndex=frameIndex, + threadId=threadId) + + def get_local_variables(self, frameIndex=0, threadId=None): + return self.get_scope_variables('Locals', frameIndex=frameIndex, + threadId=threadId) + + def get_local_variable(self, name, frameIndex=0, threadId=None): + locals = self.get_local_variables(frameIndex=frameIndex, + threadId=threadId) + for local in locals: + if 'name' in local and local['name'] == name: + return local + return None + + def get_local_variable_value(self, name, frameIndex=0, threadId=None): + variable = self.get_local_variable(name, frameIndex=frameIndex, + threadId=threadId) + if variable and 'value' in variable: + return variable['value'] + return None + + def replay_packets(self, replay_file_path): + f = open(replay_file_path, 'r') + mode = 'invalid' + set_sequence = False + command_dict = None + while mode != 'eof': + if mode == 'invalid': + line = f.readline() + if line.startswith('to adapter:'): + mode = 'send' + elif line.startswith('from adapter:'): + mode = 'recv' + elif mode == 'send': + command_dict = read_packet(f) + # Skip the end of line that follows the JSON + f.readline() + if command_dict is None: + raise ValueError('decode packet failed from replay file') + print('Sending:') + pprint.PrettyPrinter(indent=2).pprint(command_dict) + # raw_input('Press ENTER to send:') + self.send_packet(command_dict, set_sequence) + mode = 'invalid' + elif mode == 'recv': + print('Replay response:') + replay_response = read_packet(f) + # Skip the end of line that follows the JSON + f.readline() + pprint.PrettyPrinter(indent=2).pprint(replay_response) + actual_response = self.recv_packet() + if actual_response: + type = actual_response['type'] + print('Actual response:') + if type == 'response': + self.validate_response(command_dict, actual_response) + pprint.PrettyPrinter(indent=2).pprint(actual_response) + else: + print("error: didn't get a valid response") + mode = 'invalid' + + def request_attach(self, program=None, pid=None, waitFor=None, trace=None, + initCommands=None, preRunCommands=None, + stopCommands=None, exitCommands=None, + attachCommands=None): + args_dict = {} + if pid is not None: + args_dict['pid'] = pid + if program is not None: + args_dict['program'] = program + if waitFor is not None: + args_dict['waitFor'] = waitFor + if trace: + args_dict['trace'] = trace + if initCommands: + args_dict['initCommands'] = initCommands + if preRunCommands: + args_dict['preRunCommands'] = preRunCommands + if stopCommands: + args_dict['stopCommands'] = stopCommands + if exitCommands: + args_dict['exitCommands'] = exitCommands + if attachCommands: + args_dict['attachCommands'] = attachCommands + command_dict = { + 'command': 'attach', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_configurationDone(self): + command_dict = { + 'command': 'configurationDone', + 'type': 'request', + 'arguments': {} + } + response = self.send_recv(command_dict) + if response: + self.configuration_done_sent = True + return response + + def _process_stopped(self): + self.threads = None + self.frame_scopes = {} + + def request_continue(self, threadId=None): + if self.exit_status is not None: + raise ValueError('request_continue called after process exited') + # If we have launched or attached, then the first continue is done by + # sending the 'configurationDone' request + if not self.configuration_done_sent: + return self.request_configurationDone() + args_dict = {} + if threadId is None: + threadId = self.get_thread_id() + args_dict['threadId'] = threadId + command_dict = { + 'command': 'continue', + 'type': 'request', + 'arguments': args_dict + } + response = self.send_recv(command_dict) + recv_packets = [] + self.recv_condition.acquire() + for event in self.recv_packets: + if event['event'] != 'stopped': + recv_packets.append(event) + self.recv_packets = recv_packets + self.recv_condition.release() + return response + + def request_disconnect(self, terminateDebuggee=None): + args_dict = {} + if terminateDebuggee is not None: + if terminateDebuggee: + args_dict['terminateDebuggee'] = True + else: + args_dict['terminateDebuggee'] = False + command_dict = { + 'command': 'disconnect', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_evaluate(self, expression, frameIndex=0, threadId=None): + stackFrame = self.get_stackFrame(frameIndex=frameIndex, + threadId=threadId) + if stackFrame is None: + return [] + args_dict = { + 'expression': expression, + 'frameId': stackFrame['id'], + } + command_dict = { + 'command': 'evaluate', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_initialize(self): + command_dict = { + 'command': 'initialize', + 'type': 'request', + 'arguments': { + 'adapterID': 'lldb-native', + 'clientID': 'vscode', + 'columnsStartAt1': True, + 'linesStartAt1': True, + 'locale': 'en-us', + 'pathFormat': 'path', + 'supportsRunInTerminalRequest': True, + 'supportsVariablePaging': True, + 'supportsVariableType': True + } + } + response = self.send_recv(command_dict) + if response: + if 'body' in response: + self.initialize_body = response['body'] + return response + + def request_launch(self, program, args=None, cwd=None, env=None, + stopOnEntry=False, disableASLR=True, + disableSTDIO=False, shellExpandArguments=False, + trace=False, initCommands=None, preRunCommands=None, + stopCommands=None, exitCommands=None, sourcePath=None, + debuggerRoot=None): + args_dict = { + 'program': program + } + if args: + args_dict['args'] = args + if cwd: + args_dict['cwd'] = cwd + if env: + args_dict['env'] = env + if stopOnEntry: + args_dict['stopOnEntry'] = stopOnEntry + if disableASLR: + args_dict['disableASLR'] = disableASLR + if disableSTDIO: + args_dict['disableSTDIO'] = disableSTDIO + if shellExpandArguments: + args_dict['shellExpandArguments'] = shellExpandArguments + if trace: + args_dict['trace'] = trace + if initCommands: + args_dict['initCommands'] = initCommands + if preRunCommands: + args_dict['preRunCommands'] = preRunCommands + if stopCommands: + args_dict['stopCommands'] = stopCommands + if exitCommands: + args_dict['exitCommands'] = exitCommands + if sourcePath: + args_dict['sourcePath'] = sourcePath + if debuggerRoot: + args_dict['debuggerRoot'] = debuggerRoot + command_dict = { + 'command': 'launch', + 'type': 'request', + 'arguments': args_dict + } + response = self.send_recv(command_dict) + + # Wait for a 'process' and 'initialized' event in any order + self.wait_for_event(filter=['process', 'initialized']) + self.wait_for_event(filter=['process', 'initialized']) + return response + + def request_next(self, threadId): + if self.exit_status is not None: + raise ValueError('request_continue called after process exited') + args_dict = {'threadId': threadId} + command_dict = { + 'command': 'next', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_stepIn(self, threadId): + if self.exit_status is not None: + raise ValueError('request_continue called after process exited') + args_dict = {'threadId': threadId} + command_dict = { + 'command': 'stepIn', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_stepOut(self, threadId): + if self.exit_status is not None: + raise ValueError('request_continue called after process exited') + args_dict = {'threadId': threadId} + command_dict = { + 'command': 'stepOut', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_pause(self, threadId=None): + if self.exit_status is not None: + raise ValueError('request_continue called after process exited') + if threadId is None: + threadId = self.get_thread_id() + args_dict = {'threadId': threadId} + command_dict = { + 'command': 'pause', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_scopes(self, frameId): + args_dict = {'frameId': frameId} + command_dict = { + 'command': 'scopes', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_setBreakpoints(self, file_path, line_array, condition=None, + hitCondition=None): + (dir, base) = os.path.split(file_path) + breakpoints = [] + for line in line_array: + bp = {'line': line} + if condition is not None: + bp['condition'] = condition + if hitCondition is not None: + bp['hitCondition'] = hitCondition + breakpoints.append(bp) + source_dict = { + 'name': base, + 'path': file_path + } + args_dict = { + 'source': source_dict, + 'breakpoints': breakpoints, + 'lines': '%s' % (line_array), + 'sourceModified': False, + } + command_dict = { + 'command': 'setBreakpoints', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_setExceptionBreakpoints(self, filters): + args_dict = {'filters': filters} + command_dict = { + 'command': 'setExceptionBreakpoints', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_setFunctionBreakpoints(self, names, condition=None, + hitCondition=None): + breakpoints = [] + for name in names: + bp = {'name': name} + if condition is not None: + bp['condition'] = condition + if hitCondition is not None: + bp['hitCondition'] = hitCondition + breakpoints.append(bp) + args_dict = {'breakpoints': breakpoints} + command_dict = { + 'command': 'setFunctionBreakpoints', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_stackTrace(self, threadId=None, startFrame=None, levels=None, + dump=False): + if threadId is None: + threadId = self.get_thread_id() + args_dict = {'threadId': threadId} + if startFrame is not None: + args_dict['startFrame'] = startFrame + if levels is not None: + args_dict['levels'] = levels + command_dict = { + 'command': 'stackTrace', + 'type': 'request', + 'arguments': args_dict + } + response = self.send_recv(command_dict) + if dump: + for (idx, frame) in enumerate(response['body']['stackFrames']): + name = frame['name'] + if 'line' in frame and 'source' in frame: + source = frame['source'] + if 'sourceReference' not in source: + if 'name' in source: + source_name = source['name'] + line = frame['line'] + print("[%3u] %s @ %s:%u" % (idx, name, source_name, + line)) + continue + print("[%3u] %s" % (idx, name)) + return response + + def request_threads(self): + '''Request a list of all threads and combine any information from any + "stopped" events since those contain more information about why a + thread actually stopped. Returns an array of thread dictionaries + with information about all threads''' + command_dict = { + 'command': 'threads', + 'type': 'request', + 'arguments': {} + } + response = self.send_recv(command_dict) + body = response['body'] + # Fill in "self.threads" correctly so that clients that call + # self.get_threads() or self.get_thread_id(...) can get information + # on threads when the process is stopped. + if 'threads' in body: + self.threads = body['threads'] + for thread in self.threads: + # Copy the thread dictionary so we can add key/value pairs to + # it without affecfting the original info from the "threads" + # command. + tid = thread['id'] + if tid in self.thread_stop_reasons: + thread_stop_info = self.thread_stop_reasons[tid] + copy_keys = ['reason', 'description', 'text'] + for key in copy_keys: + if key in thread_stop_info: + thread[key] = thread_stop_info[key] + else: + self.threads = None + return response + + def request_variables(self, variablesReference, start=None, count=None): + args_dict = {'variablesReference': variablesReference} + if start is not None: + args_dict['start'] = start + if count is not None: + args_dict['count'] = count + command_dict = { + 'command': 'variables', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_setVariable(self, containingVarRef, name, value, id=None): + args_dict = { + 'variablesReference': containingVarRef, + 'name': name, + 'value': str(value) + } + if id is not None: + args_dict['id'] = id + command_dict = { + 'command': 'setVariable', + 'type': 'request', + 'arguments': args_dict + } + return self.send_recv(command_dict) + + def request_testGetTargetBreakpoints(self): + '''A request packet used in the LLDB test suite to get all currently + set breakpoint infos for all breakpoints currently set in the + target. + ''' + command_dict = { + 'command': '_testGetTargetBreakpoints', + 'type': 'request', + 'arguments': {} + } + return self.send_recv(command_dict) + + def terminate(self): + self.send.close() + # self.recv.close() + + +class DebugAdaptor(DebugCommunication): + def __init__(self, executable=None, port=None): + self.process = None + if executable is not None: + self.process = subprocess.Popen([executable], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + DebugCommunication.__init__(self, self.process.stdout, + self.process.stdin) + elif port is not None: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect(('127.0.0.1', port)) + DebugCommunication.__init__(self, s.makefile('r'), s.makefile('w')) + + def get_pid(self): + if self.process: + return self.process.pid + return -1 + + def terminate(self): + super(DebugAdaptor, self).terminate() + if self.process is not None: + self.process.terminate() + self.process.wait() + self.process = None + + +def attach_options_specified(options): + if options.pid is not None: + return True + if options.waitFor: + return True + if options.attach: + return True + if options.attachCmds: + return True + return False + + +def run_vscode(dbg, args, options): + dbg.request_initialize() + if attach_options_specified(options): + response = dbg.request_attach(program=options.program, + pid=options.pid, + waitFor=options.waitFor, + attachCommands=options.attachCmds, + initCommands=options.initCmds, + preRunCommands=options.preRunCmds, + stopCommands=options.stopCmds, + exitCommands=options.exitCmds) + else: + response = dbg.request_launch(options.program, + args=args, + env=options.envs, + cwd=options.workingDir, + debuggerRoot=options.debuggerRoot, + sourcePath=options.sourcePath, + initCommands=options.initCmds, + preRunCommands=options.preRunCmds, + stopCommands=options.stopCmds, + exitCommands=options.exitCmds) + + if response['success']: + if options.sourceBreakpoints: + source_to_lines = {} + for file_line in options.sourceBreakpoints: + (path, line) = file_line.split(':') + if len(path) == 0 or len(line) == 0: + print('error: invalid source with line "%s"' % + (file_line)) + + else: + if path in source_to_lines: + source_to_lines[path].append(int(line)) + else: + source_to_lines[path] = [int(line)] + for source in source_to_lines: + dbg.request_setBreakpoints(source, source_to_lines[source]) + if options.funcBreakpoints: + dbg.request_setFunctionBreakpoints(options.funcBreakpoints) + dbg.request_configurationDone() + dbg.wait_for_stopped() + else: + if 'message' in response: + print(response['message']) + dbg.request_disconnect(terminateDebuggee=True) + + +def main(): + parser = optparse.OptionParser( + description=('A testing framework for the Visual Studio Code Debug ' + 'Adaptor protocol')) + + parser.add_option( + '--vscode', + type='string', + dest='vscode_path', + help=('The path to the command line program that implements the ' + 'Visual Studio Code Debug Adaptor protocol.'), + default=None) + + parser.add_option( + '--program', + type='string', + dest='program', + help='The path to the program to debug.', + default=None) + + parser.add_option( + '--workingDir', + type='string', + dest='workingDir', + default=None, + help='Set the working directory for the process we launch.') + + parser.add_option( + '--sourcePath', + type='string', + dest='sourcePath', + default=None, + help=('Set the relative source root for any debug info that has ' + 'relative paths in it.')) + + parser.add_option( + '--debuggerRoot', + type='string', + dest='debuggerRoot', + default=None, + help=('Set the working directory for lldb-vscode for any object files ' + 'with relative paths in the Mach-o debug map.')) + + parser.add_option( + '-r', '--replay', + type='string', + dest='replay', + help=('Specify a file containing a packet log to replay with the ' + 'current Visual Studio Code Debug Adaptor executable.'), + default=None) + + parser.add_option( + '-g', '--debug', + action='store_true', + dest='debug', + default=False, + help='Pause waiting for a debugger to attach to the debug adaptor') + + parser.add_option( + '--port', + type='int', + dest='port', + help="Attach a socket to a port instead of using STDIN for VSCode", + default=None) + + parser.add_option( + '--pid', + type='int', + dest='pid', + help="The process ID to attach to", + default=None) + + parser.add_option( + '--attach', + action='store_true', + dest='attach', + default=False, + help=('Specify this option to attach to a process by name. The ' + 'process name is the basanme of the executable specified with ' + 'the --program option.')) + + parser.add_option( + '-f', '--function-bp', + type='string', + action='append', + dest='funcBreakpoints', + help=('Specify the name of a function to break at. ' + 'Can be specified more than once.'), + default=[]) + + parser.add_option( + '-s', '--source-bp', + type='string', + action='append', + dest='sourceBreakpoints', + default=[], + help=('Specify source breakpoints to set in the format of ' + ':. ' + 'Can be specified more than once.')) + + parser.add_option( + '--attachCommand', + type='string', + action='append', + dest='attachCmds', + default=[], + help=('Specify a LLDB command that will attach to a process. ' + 'Can be specified more than once.')) + + parser.add_option( + '--initCommand', + type='string', + action='append', + dest='initCmds', + default=[], + help=('Specify a LLDB command that will be executed before the target ' + 'is created. Can be specified more than once.')) + + parser.add_option( + '--preRunCommand', + type='string', + action='append', + dest='preRunCmds', + default=[], + help=('Specify a LLDB command that will be executed after the target ' + 'has been created. Can be specified more than once.')) + + parser.add_option( + '--stopCommand', + type='string', + action='append', + dest='stopCmds', + default=[], + help=('Specify a LLDB command that will be executed each time the' + 'process stops. Can be specified more than once.')) + + parser.add_option( + '--exitCommand', + type='string', + action='append', + dest='exitCmds', + default=[], + help=('Specify a LLDB command that will be executed when the process ' + 'exits. Can be specified more than once.')) + + parser.add_option( + '--env', + type='string', + action='append', + dest='envs', + default=[], + help=('Specify environment variables to pass to the launched ' + 'process.')) + + parser.add_option( + '--waitFor', + action='store_true', + dest='waitFor', + default=False, + help=('Wait for the next process to be launched whose name matches ' + 'the basename of the program specified with the --program ' + 'option')) + + (options, args) = parser.parse_args(sys.argv[1:]) + + if options.vscode_path is None and options.port is None: + print('error: must either specify a path to a Visual Studio Code ' + 'Debug Adaptor vscode executable path using the --vscode ' + 'option, or a port to attach to for an existing lldb-vscode ' + 'using the --port option') + return + dbg = DebugAdaptor(executable=options.vscode_path, port=options.port) + if options.debug: + raw_input('Waiting for debugger to attach pid "%i"' % ( + dbg.get_pid())) + if options.replay: + dbg.replay_packets(options.replay) + else: + run_vscode(dbg, args, options) + dbg.terminate() + + +if __name__ == '__main__': + main() diff --git a/packages/Python/lldbsuite/test/warnings/uuid/main.cpp.template b/packages/Python/lldbsuite/test/warnings/uuid/main.cpp.template index d952c9686b57..d486b3dd8b9b 100644 --- a/packages/Python/lldbsuite/test/warnings/uuid/main.cpp.template +++ b/packages/Python/lldbsuite/test/warnings/uuid/main.cpp.template @@ -1,9 +1,8 @@ //===-- main.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/packages/Python/lldbsuite/test_event/dotest_channels.py b/packages/Python/lldbsuite/test_event/dotest_channels.py index 4f79193514bb..a5aa9c774c4b 100644 --- a/packages/Python/lldbsuite/test_event/dotest_channels.py +++ b/packages/Python/lldbsuite/test_event/dotest_channels.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Sync lldb and related source from a local machine to a remote machine. diff --git a/packages/Python/lldbsuite/test_event/event_builder.py b/packages/Python/lldbsuite/test_event/event_builder.py index a7cb57c7f9c0..8759011abe5e 100644 --- a/packages/Python/lldbsuite/test_event/event_builder.py +++ b/packages/Python/lldbsuite/test_event/event_builder.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides a class to build Python test event data structures. """ diff --git a/packages/Python/lldbsuite/test_event/formatter/__init__.py b/packages/Python/lldbsuite/test_event/formatter/__init__.py index d1b441dffc3a..337b3c5843b0 100644 --- a/packages/Python/lldbsuite/test_event/formatter/__init__.py +++ b/packages/Python/lldbsuite/test_event/formatter/__init__.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ from __future__ import print_function diff --git a/packages/Python/lldbsuite/test_event/formatter/curses.py b/packages/Python/lldbsuite/test_event/formatter/curses.py index f415575ded8a..05b773f9e696 100644 --- a/packages/Python/lldbsuite/test_event/formatter/curses.py +++ b/packages/Python/lldbsuite/test_event/formatter/curses.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - - This file is distributed under the University of Illinois Open Source - License. See LICENSE.TXT for details. + 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 """ from __future__ import absolute_import diff --git a/packages/Python/lldbsuite/test_event/formatter/dump_formatter.py b/packages/Python/lldbsuite/test_event/formatter/dump_formatter.py index d42dcb18bb4f..2a0cda14c3bf 100644 --- a/packages/Python/lldbsuite/test_event/formatter/dump_formatter.py +++ b/packages/Python/lldbsuite/test_event/formatter/dump_formatter.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ from __future__ import print_function diff --git a/packages/Python/lldbsuite/test_event/formatter/pickled.py b/packages/Python/lldbsuite/test_event/formatter/pickled.py index 588614e2f7b4..acb5c56e0287 100644 --- a/packages/Python/lldbsuite/test_event/formatter/pickled.py +++ b/packages/Python/lldbsuite/test_event/formatter/pickled.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 """ from __future__ import print_function diff --git a/packages/Python/lldbsuite/test_event/formatter/results_formatter.py b/packages/Python/lldbsuite/test_event/formatter/results_formatter.py index 8e341cb2ce84..ac2778e55def 100644 --- a/packages/Python/lldbsuite/test_event/formatter/results_formatter.py +++ b/packages/Python/lldbsuite/test_event/formatter/results_formatter.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides classes used by the test results reporting infrastructure within the LLDB test suite. diff --git a/packages/Python/lldbsuite/test_event/formatter/xunit.py b/packages/Python/lldbsuite/test_event/formatter/xunit.py index 30940ff2b6a1..231b096c24a8 100644 --- a/packages/Python/lldbsuite/test_event/formatter/xunit.py +++ b/packages/Python/lldbsuite/test_event/formatter/xunit.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Provides an xUnit ResultsFormatter for integrating the LLDB test suite with the Jenkins xUnit aggregator and other xUnit-compliant diff --git a/resources/LLDB-Info.plist.in b/resources/LLDB-Info.plist.in new file mode 100644 index 000000000000..93af4df68cc3 --- /dev/null +++ b/resources/LLDB-Info.plist.in @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + LLDB + CFBundleIdentifier + ${MACOSX_FRAMEWORK_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleShortVersionString + ${MACOSX_FRAMEWORK_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_FRAMEWORK_BUNDLE_VERSION} + CFBundleName + LLDB + + diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index d88be37420d5..bb72b989b8a2 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -11,42 +11,25 @@ set(SWIG_HEADERS include(FindPythonInterp) -if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") - set(SWIG_PYTHON_DIR - ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -else() - set(SWIG_PYTHON_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/site-packages) -endif() - -set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX}) - -# Generating the LLDB framework correctly is a bit complicated because the -# framework depends on the swig output. if(LLDB_BUILD_FRAMEWORK) set(framework_arg --framework --target-platform Darwin) - set(SWIG_PYTHON_DIR - ${LLDB_PYTHON_TARGET_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}/Python) - set(SWIG_INSTALL_DIR - ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR}) endif() -get_filename_component(CFGBLDDIR ${LLDB_WRAP_PYTHON} DIRECTORY) - find_package(SWIG) -if( ${SWIG_FOUND} ) +if(${SWIG_FOUND}) set(PREPARE_BINDINGS_ARGS "--swig-executable=${SWIG_EXECUTABLE}") -elseif( ${LLDB_ALLOW_STATIC_BINDINGS} ) +elseif(${LLDB_ALLOW_STATIC_BINDINGS}) set(PREPARE_BINDINGS_ARGS --find-swig --allow-static-binding) else() - message( FATAL_ERROR "swig not found and static bindings not permitted - install swig or specify -DLLDB_ALLOW_STATIC_BINDINGS=1") + message(FATAL_ERROR "swig not found and static bindings not permitted - install swig or specify -DLLDB_ALLOW_STATIC_BINDINGS=1") endif() add_custom_command( - OUTPUT ${LLDB_WRAP_PYTHON} - OUTPUT ${LLDB_PYTHON_TARGET_DIR}/lldb.py + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py DEPENDS ${SWIG_SOURCES} DEPENDS ${SWIG_INTERFACES} DEPENDS ${SWIG_HEADERS} @@ -55,19 +38,31 @@ add_custom_command( COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/prepare_bindings.py ${framework_arg} --srcRoot=${LLDB_SOURCE_DIR} - --targetDir=${LLDB_PYTHON_TARGET_DIR} - --cfgBldDir=${CFGBLDDIR} + --targetDir=${CMAKE_CURRENT_BINARY_DIR} + --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR} --prefix=${CMAKE_BINARY_DIR} ${PREPARE_BINDINGS_ARGS} VERBATIM COMMENT "Python script building LLDB Python wrapper") -add_custom_target(swig_wrapper ALL DEPENDS ${LLDB_WRAP_PYTHON}) -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lldb.py PROPERTIES GENERATED 1) +add_custom_target(swig_wrapper ALL DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp + ${CMAKE_CURRENT_BINARY_DIR}/lldb.py +) + +if(NOT LLDB_BUILD_FRAMEWORK) + if(CMAKE_SYSTEM_NAME MATCHES "Windows") + set(swig_python_subdir site-packages) + else() + set(swig_python_subdir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) + endif() + set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir}) + set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX}) -# Install the LLDB python module -install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR}) + # Install the LLDB python module + install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR}) +endif() # build Python modules add_subdirectory(Python/modules) diff --git a/scripts/Python/prepare_binding_Python.py b/scripts/Python/prepare_binding_Python.py index 796aeff9b5f2..809a3014539f 100644 --- a/scripts/Python/prepare_binding_Python.py +++ b/scripts/Python/prepare_binding_Python.py @@ -1,8 +1,7 @@ """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Python binding preparation script. """ diff --git a/scripts/Python/python-extensions.swig b/scripts/Python/python-extensions.swig index 5543bee95d47..892e1af4bae5 100644 --- a/scripts/Python/python-extensions.swig +++ b/scripts/Python/python-extensions.swig @@ -1,5 +1,6 @@ %extend lldb::SBAddress { + %nothreadallow; PyObject *lldb::SBAddress::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -12,8 +13,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBBlock { + %nothreadallow; PyObject *lldb::SBBlock::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -26,8 +29,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBBreakpoint { + %nothreadallow; PyObject *lldb::SBBreakpoint::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -40,6 +45,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -57,6 +63,7 @@ } %extend lldb::SBBreakpointLocation { + %nothreadallow; PyObject *lldb::SBBreakpointLocation::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelFull); @@ -69,9 +76,11 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBBreakpointName { + %nothreadallow; PyObject *lldb::SBBreakpointName::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -84,6 +93,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBBroadcaster { @@ -103,6 +113,7 @@ } %extend lldb::SBCommandReturnObject { + %nothreadallow; PyObject *lldb::SBCommandReturnObject::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -115,6 +126,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort @@ -130,6 +142,7 @@ {} } %extend lldb::SBCompileUnit { + %nothreadallow; PyObject *lldb::SBCompileUnit::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -142,6 +155,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -157,6 +171,7 @@ %} } %extend lldb::SBData { + %nothreadallow; PyObject *lldb::SBData::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -169,8 +184,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBDebugger { + %nothreadallow; PyObject *lldb::SBDebugger::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -183,8 +200,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBDeclaration { + %nothreadallow; PyObject *lldb::SBDeclaration::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -197,6 +216,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -214,6 +234,7 @@ } %extend lldb::SBError { + %nothreadallow; PyObject *lldb::SBError::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -226,8 +247,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBFileSpec { + %nothreadallow; PyObject *lldb::SBFileSpec::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -240,8 +263,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBFrame { + %nothreadallow; PyObject *lldb::SBFrame::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -254,8 +279,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBFunction { + %nothreadallow; PyObject *lldb::SBFunction::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -268,6 +295,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -285,6 +313,7 @@ } %extend lldb::SBInstruction { + %nothreadallow; PyObject *lldb::SBInstruction::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -297,8 +326,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBInstructionList { + %nothreadallow; PyObject *lldb::SBInstructionList::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -311,8 +342,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBLineEntry { + %nothreadallow; PyObject *lldb::SBLineEntry::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -325,6 +358,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -342,6 +376,7 @@ } %extend lldb::SBMemoryRegionInfo { + %nothreadallow; PyObject *lldb::SBMemoryRegionInfo::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -354,9 +389,11 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBModule { + %nothreadallow; PyObject *lldb::SBModule::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -369,6 +406,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -386,6 +424,7 @@ } %extend lldb::SBModuleSpec { + %nothreadallow; PyObject *lldb::SBModuleSpec::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -398,9 +437,11 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBModuleSpecList { + %nothreadallow; PyObject *lldb::SBModuleSpecList::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -413,9 +454,11 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBProcess { + %nothreadallow; PyObject *lldb::SBProcess::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -428,8 +471,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBSection { + %nothreadallow; PyObject *lldb::SBSection::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -442,6 +487,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -472,6 +518,7 @@ {} } %extend lldb::SBSymbol { + %nothreadallow; PyObject *lldb::SBSymbol::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -484,6 +531,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -499,6 +547,7 @@ %} } %extend lldb::SBSymbolContext { + %nothreadallow; PyObject *lldb::SBSymbolContext::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -511,8 +560,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBSymbolContextList { + %nothreadallow; PyObject *lldb::SBSymbolContextList::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -525,9 +576,11 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTarget { + %nothreadallow; PyObject *lldb::SBTarget::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -540,6 +593,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): @@ -557,6 +611,7 @@ } %extend lldb::SBType { + %nothreadallow; PyObject *lldb::SBType::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -569,8 +624,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTypeCategory { + %nothreadallow; PyObject *lldb::SBTypeCategory::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -583,8 +640,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTypeFilter { + %nothreadallow; PyObject *lldb::SBTypeFilter::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -597,6 +656,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -612,6 +672,7 @@ %} } %extend lldb::SBTypeFormat { + %nothreadallow; PyObject *lldb::SBTypeFormat::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -624,8 +685,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTypeMember { + %nothreadallow; PyObject *lldb::SBTypeMember::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -638,8 +701,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTypeMemberFunction { + %nothreadallow; PyObject *lldb::SBTypeMemberFunction::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -652,8 +717,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTypeEnumMember { + %nothreadallow; PyObject *lldb::SBTypeEnumMember::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -666,8 +733,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBTypeNameSpecifier { + %nothreadallow; PyObject *lldb::SBTypeNameSpecifier::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -680,6 +749,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -695,6 +765,7 @@ %} } %extend lldb::SBTypeSummary { + %nothreadallow; PyObject *lldb::SBTypeSummary::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -707,6 +778,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -722,6 +794,7 @@ %} } %extend lldb::SBTypeSynthetic { + %nothreadallow; PyObject *lldb::SBTypeSynthetic::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelBrief); @@ -734,6 +807,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -749,6 +823,7 @@ %} } %extend lldb::SBThread { + %nothreadallow; PyObject *lldb::SBThread::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -761,6 +836,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; %pythoncode %{ def __eq__(self, rhs): if not isinstance(rhs, type(self)): @@ -776,6 +852,7 @@ %} } %extend lldb::SBValue { + %nothreadallow; PyObject *lldb::SBValue::__str__ (){ lldb::SBStream description; $self->GetDescription (description); @@ -788,8 +865,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBValueList { + %nothreadallow; PyObject *lldb::SBValueList::__str__ (){ lldb::SBStream description; const size_t n = $self->GetSize(); @@ -811,8 +890,10 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } %extend lldb::SBWatchpoint { + %nothreadallow; PyObject *lldb::SBWatchpoint::__str__ (){ lldb::SBStream description; $self->GetDescription (description, lldb::eDescriptionLevelVerbose); @@ -825,6 +906,7 @@ else return lldb_private::PythonString("").release(); } + %clearnothreadallow; } diff --git a/scripts/Python/python-swigsafecast.swig b/scripts/Python/python-swigsafecast.swig index 1c83fb6144bb..1bc8e1de967c 100644 --- a/scripts/Python/python-swigsafecast.swig +++ b/scripts/Python/python-swigsafecast.swig @@ -25,15 +25,6 @@ SBTypeToSWIGWrapper (PyObject* py_object) return py_object; } -template <> -PyObject* -SBTypeToSWIGWrapper (const char* c_str) -{ - if (c_str) - return PyString_FromString(c_str); - return NULL; -} - template <> PyObject* SBTypeToSWIGWrapper (unsigned int* c_int) diff --git a/scripts/Python/python-typemaps.swig b/scripts/Python/python-typemaps.swig index b36104209a0b..56cab6c58163 100644 --- a/scripts/Python/python-typemaps.swig +++ b/scripts/Python/python-typemaps.swig @@ -139,30 +139,9 @@ // typemap for an outgoing buffer // See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len). -%typemap(in) (const char *cstr, uint32_t cstr_len) { - using namespace lldb_private; - if (PythonString::Check($input)) { - PythonString str(PyRefType::Borrowed, $input); - $1 = (char*)str.GetString().data(); - $2 = str.GetSize(); - } - else if(PythonByteArray::Check($input)) { - PythonByteArray bytearray(PyRefType::Borrowed, $input); - $1 = (char*)bytearray.GetBytes().data(); - $2 = bytearray.GetSize(); - } - else if (PythonBytes::Check($input)) { - PythonBytes bytes(PyRefType::Borrowed, $input); - $1 = (char*)bytes.GetBytes().data(); - $2 = bytes.GetSize(); - } - else { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } -} // Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len). -%typemap(in) (const char *src, size_t src_len) { +%typemap(in) (const char *cstr, uint32_t cstr_len), + (const char *src, size_t src_len) { using namespace lldb_private; if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); @@ -184,32 +163,9 @@ return NULL; } } -// And SBProcess::WriteMemory. -%typemap(in) (const void *buf, size_t size) { - using namespace lldb_private; - if (PythonString::Check($input)) { - PythonString str(PyRefType::Borrowed, $input); - $1 = (void*)str.GetString().data(); - $2 = str.GetSize(); - } - else if(PythonByteArray::Check($input)) { - PythonByteArray bytearray(PyRefType::Borrowed, $input); - $1 = (void*)bytearray.GetBytes().data(); - $2 = bytearray.GetSize(); - } - else if (PythonBytes::Check($input)) { - PythonBytes bytes(PyRefType::Borrowed, $input); - $1 = (void*)bytes.GetBytes().data(); - $2 = bytes.GetSize(); - } - else { - PyErr_SetString(PyExc_ValueError, "Expecting a buffer"); - return NULL; - } -} - -// For SBDebugger::DispatchInput -%typemap(in) (const void *data, size_t data_len) { +// For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. +%typemap(in) (const void *buf, size_t size), + (const void *data, size_t data_len) { using namespace lldb_private; if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); @@ -264,142 +220,70 @@ free($1); } -// these typemaps allow Python users to pass list objects -// and have them turn into C++ arrays (this is useful, for instance -// when creating SBData objects from lists of numbers) -%typemap(in) (uint64_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (uint64_t*) malloc(size * sizeof(uint64_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - $1[i] = PyLong_AsUnsignedLongLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } - - if (PyErr_Occurred()) { - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - $2 = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } +%{ +namespace { +template +T PyLongAsT(PyObject *obj) { + static_assert(true, "unsupported type"); } -%typemap(freearg) (uint64_t* array, size_t array_len) { - free($1); +template <> uint64_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsUnsignedLongLong(obj)); } -%typemap(in) (uint32_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (uint32_t*) malloc(size * sizeof(uint32_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - $1[i] = PyLong_AsUnsignedLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } +template <> uint32_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsUnsignedLong(obj)); +} - if (PyErr_Occurred()) { - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - $2 = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } +template <> int64_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsLongLong(obj)); } -%typemap(freearg) (uint32_t* array, size_t array_len) { - free($1); +template <> int32_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsLong(obj)); } -%typemap(in) (int64_t* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (int64_t*) malloc(size * sizeof(int64_t)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - $1[i] = PyLong_AsLongLong(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain numbers"); - free($1); - return NULL; - } +template +bool SetNumberFromPyObject(T &number, PyObject *obj) { + if (PyInt_Check(obj)) + number = static_cast(PyInt_AsLong(obj)); + else if (PyLong_Check(obj)) + number = PyLongAsT(obj); + else return false; - if (PyErr_Occurred()) { - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - $2 = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } + return true; } -%typemap(freearg) (int64_t* array, size_t array_len) { - free($1); +template <> +bool SetNumberFromPyObject(double &number, PyObject *obj) { + if (PyFloat_Check(obj)) { + number = PyFloat_AsDouble(obj); + return true; + } + + return false; } -%typemap(in) (int32_t* array, size_t array_len) { +} // namespace +%} + +// these typemaps allow Python users to pass list objects +// and have them turn into C++ arrays (this is useful, for instance +// when creating SBData objects from lists of numbers) +%typemap(in) (uint64_t* array, size_t array_len), + (uint32_t* array, size_t array_len), + (int64_t* array, size_t array_len), + (int32_t* array, size_t array_len), + (double* array, size_t array_len) { /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); int i = 0; $2 = size; - $1 = (int32_t*) malloc(size * sizeof(int32_t)); + $1 = ($1_type) malloc(size * sizeof($*1_type)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) { - $1[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - $1[i] = PyLong_AsLong(o); - } - else { + if (!SetNumberFromPyObject($1[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free($1); return NULL; @@ -419,38 +303,11 @@ } } -%typemap(freearg) (int32_t* array, size_t array_len) { - free($1); -} - -%typemap(in) (double* array, size_t array_len) { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $2 = size; - $1 = (double*) malloc(size * sizeof(double)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyFloat_Check(o)) { - $1[i] = PyFloat_AsDouble(o); - } - else { - PyErr_SetString(PyExc_TypeError,"list must contain floating-point numbers"); - free($1); - return NULL; - } - } - } else if ($input == Py_None) { - $1 = NULL; - $2 = 0; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) (double* array, size_t array_len) { +%typemap(freearg) (uint64_t* array, size_t array_len), + (uint32_t* array, size_t array_len), + (int64_t* array, size_t array_len), + (int32_t* array, size_t array_len), + (double* array, size_t array_len) { free($1); } diff --git a/scripts/Python/python-wrapper.swig b/scripts/Python/python-wrapper.swig index e6a6b7afb8ea..8509899df27b 100644 --- a/scripts/Python/python-wrapper.swig +++ b/scripts/Python/python-wrapper.swig @@ -826,7 +826,9 @@ LLDBSwigPython_GetRecognizedArguments lldb::SBFrame frame_sb(frame_sp); PyObject *arg = SBTypeToSWIGWrapper(frame_sb); - PyObject* result = PyObject_CallMethodObjArgs(implementor, PyString_FromString(callee_name), arg, NULL); + PythonString str(callee_name); + PyObject* result = PyObject_CallMethodObjArgs(implementor, str.get(), arg, + NULL); return result; } diff --git a/scripts/Python/static-binding/LLDBWrapPython.cpp b/scripts/Python/static-binding/LLDBWrapPython.cpp index 10bc34089353..ad0eb1ed657d 100644 --- a/scripts/Python/static-binding/LLDBWrapPython.cpp +++ b/scripts/Python/static-binding/LLDBWrapPython.cpp @@ -2775,104 +2775,104 @@ void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton); #define SWIGTYPE_p_lldb__SBFrame swig_types[30] #define SWIGTYPE_p_lldb__SBFunction swig_types[31] #define SWIGTYPE_p_lldb__SBHostOS swig_types[32] -#define SWIGTYPE_p_lldb__SBInstruction swig_types[33] -#define SWIGTYPE_p_lldb__SBInstructionList swig_types[34] -#define SWIGTYPE_p_lldb__SBLanguageRuntime swig_types[35] -#define SWIGTYPE_p_lldb__SBLaunchInfo swig_types[36] -#define SWIGTYPE_p_lldb__SBLineEntry swig_types[37] -#define SWIGTYPE_p_lldb__SBListener swig_types[38] -#define SWIGTYPE_p_lldb__SBMemoryRegionInfo swig_types[39] -#define SWIGTYPE_p_lldb__SBMemoryRegionInfoList swig_types[40] -#define SWIGTYPE_p_lldb__SBModule swig_types[41] -#define SWIGTYPE_p_lldb__SBModuleSpec swig_types[42] -#define SWIGTYPE_p_lldb__SBModuleSpecList swig_types[43] -#define SWIGTYPE_p_lldb__SBPlatform swig_types[44] -#define SWIGTYPE_p_lldb__SBPlatformConnectOptions swig_types[45] -#define SWIGTYPE_p_lldb__SBPlatformShellCommand swig_types[46] -#define SWIGTYPE_p_lldb__SBProcess swig_types[47] -#define SWIGTYPE_p_lldb__SBProcessInfo swig_types[48] -#define SWIGTYPE_p_lldb__SBQueue swig_types[49] -#define SWIGTYPE_p_lldb__SBQueueItem swig_types[50] -#define SWIGTYPE_p_lldb__SBSection swig_types[51] -#define SWIGTYPE_p_lldb__SBSourceManager swig_types[52] -#define SWIGTYPE_p_lldb__SBStream swig_types[53] -#define SWIGTYPE_p_lldb__SBStringList swig_types[54] -#define SWIGTYPE_p_lldb__SBStructuredData swig_types[55] -#define SWIGTYPE_p_lldb__SBSymbol swig_types[56] -#define SWIGTYPE_p_lldb__SBSymbolContext swig_types[57] -#define SWIGTYPE_p_lldb__SBSymbolContextList swig_types[58] -#define SWIGTYPE_p_lldb__SBTarget swig_types[59] -#define SWIGTYPE_p_lldb__SBThread swig_types[60] -#define SWIGTYPE_p_lldb__SBThreadCollection swig_types[61] -#define SWIGTYPE_p_lldb__SBThreadPlan swig_types[62] -#define SWIGTYPE_p_lldb__SBTrace swig_types[63] -#define SWIGTYPE_p_lldb__SBTraceOptions swig_types[64] -#define SWIGTYPE_p_lldb__SBType swig_types[65] -#define SWIGTYPE_p_lldb__SBTypeCategory swig_types[66] -#define SWIGTYPE_p_lldb__SBTypeEnumMember swig_types[67] -#define SWIGTYPE_p_lldb__SBTypeEnumMemberList swig_types[68] -#define SWIGTYPE_p_lldb__SBTypeFilter swig_types[69] -#define SWIGTYPE_p_lldb__SBTypeFormat swig_types[70] -#define SWIGTYPE_p_lldb__SBTypeList swig_types[71] -#define SWIGTYPE_p_lldb__SBTypeMember swig_types[72] -#define SWIGTYPE_p_lldb__SBTypeMemberFunction swig_types[73] -#define SWIGTYPE_p_lldb__SBTypeNameSpecifier swig_types[74] -#define SWIGTYPE_p_lldb__SBTypeSummary swig_types[75] -#define SWIGTYPE_p_lldb__SBTypeSummaryOptions swig_types[76] -#define SWIGTYPE_p_lldb__SBTypeSynthetic swig_types[77] -#define SWIGTYPE_p_lldb__SBUnixSignals swig_types[78] -#define SWIGTYPE_p_lldb__SBValue swig_types[79] -#define SWIGTYPE_p_lldb__SBValueList swig_types[80] -#define SWIGTYPE_p_lldb__SBVariablesOptions swig_types[81] -#define SWIGTYPE_p_lldb__SBWatchpoint swig_types[82] -#define SWIGTYPE_p_lldb_private__SharingPtrT_lldb_private__ValueObject_t swig_types[83] -#define SWIGTYPE_p_long_double swig_types[84] -#define SWIGTYPE_p_long_long swig_types[85] -#define SWIGTYPE_p_p_void swig_types[86] -#define SWIGTYPE_p_pthread_rwlock_t swig_types[87] -#define SWIGTYPE_p_pthread_t swig_types[88] -#define SWIGTYPE_p_short swig_types[89] -#define SWIGTYPE_p_signed_char swig_types[90] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ABI_t swig_types[91] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Baton_t swig_types[92] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Block_t swig_types[93] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointLocation_t swig_types[94] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointResolver_t swig_types[95] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointSite_t swig_types[96] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Breakpoint_t swig_types[97] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BroadcasterManager_t swig_types[98] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Broadcaster_t swig_types[99] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ClangASTImporter_t swig_types[100] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CommandObject_t swig_types[101] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Communication_t swig_types[102] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CompileUnit_t swig_types[103] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Connection_t swig_types[104] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataBuffer_t swig_types[105] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataExtractor_t swig_types[106] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Debugger_t swig_types[107] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Disassembler_t swig_types[108] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DynamicLoader_t swig_types[109] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventDataStructuredData_t swig_types[110] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventData_t swig_types[111] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t swig_types[112] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExecutionContextRef_t swig_types[113] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExpressionVariable_t swig_types[114] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__File_t swig_types[115] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FuncUnwinders_t swig_types[116] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FunctionCaller_t swig_types[117] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Function_t swig_types[118] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOHandler_t swig_types[119] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOObject_t swig_types[120] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IRExecutionUnit_t swig_types[121] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InlineFunctionInfo_t swig_types[122] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Instruction_t swig_types[123] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InstrumentationRuntime_t swig_types[124] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__JITLoader_t swig_types[125] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__LanguageRuntime_t swig_types[126] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__LineTable_t swig_types[127] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Listener_t swig_types[128] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryHistory_t swig_types[129] -#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t swig_types[130] +#define SWIGTYPE_p_lldb__SBInitializerOptions swig_types[33] +#define SWIGTYPE_p_lldb__SBInstruction swig_types[34] +#define SWIGTYPE_p_lldb__SBInstructionList swig_types[35] +#define SWIGTYPE_p_lldb__SBLanguageRuntime swig_types[36] +#define SWIGTYPE_p_lldb__SBLaunchInfo swig_types[37] +#define SWIGTYPE_p_lldb__SBLineEntry swig_types[38] +#define SWIGTYPE_p_lldb__SBListener swig_types[39] +#define SWIGTYPE_p_lldb__SBMemoryRegionInfo swig_types[40] +#define SWIGTYPE_p_lldb__SBMemoryRegionInfoList swig_types[41] +#define SWIGTYPE_p_lldb__SBModule swig_types[42] +#define SWIGTYPE_p_lldb__SBModuleSpec swig_types[43] +#define SWIGTYPE_p_lldb__SBModuleSpecList swig_types[44] +#define SWIGTYPE_p_lldb__SBPlatform swig_types[45] +#define SWIGTYPE_p_lldb__SBPlatformConnectOptions swig_types[46] +#define SWIGTYPE_p_lldb__SBPlatformShellCommand swig_types[47] +#define SWIGTYPE_p_lldb__SBProcess swig_types[48] +#define SWIGTYPE_p_lldb__SBProcessInfo swig_types[49] +#define SWIGTYPE_p_lldb__SBQueue swig_types[50] +#define SWIGTYPE_p_lldb__SBQueueItem swig_types[51] +#define SWIGTYPE_p_lldb__SBSection swig_types[52] +#define SWIGTYPE_p_lldb__SBSourceManager swig_types[53] +#define SWIGTYPE_p_lldb__SBStream swig_types[54] +#define SWIGTYPE_p_lldb__SBStringList swig_types[55] +#define SWIGTYPE_p_lldb__SBStructuredData swig_types[56] +#define SWIGTYPE_p_lldb__SBSymbol swig_types[57] +#define SWIGTYPE_p_lldb__SBSymbolContext swig_types[58] +#define SWIGTYPE_p_lldb__SBSymbolContextList swig_types[59] +#define SWIGTYPE_p_lldb__SBTarget swig_types[60] +#define SWIGTYPE_p_lldb__SBThread swig_types[61] +#define SWIGTYPE_p_lldb__SBThreadCollection swig_types[62] +#define SWIGTYPE_p_lldb__SBThreadPlan swig_types[63] +#define SWIGTYPE_p_lldb__SBTrace swig_types[64] +#define SWIGTYPE_p_lldb__SBTraceOptions swig_types[65] +#define SWIGTYPE_p_lldb__SBType swig_types[66] +#define SWIGTYPE_p_lldb__SBTypeCategory swig_types[67] +#define SWIGTYPE_p_lldb__SBTypeEnumMember swig_types[68] +#define SWIGTYPE_p_lldb__SBTypeEnumMemberList swig_types[69] +#define SWIGTYPE_p_lldb__SBTypeFilter swig_types[70] +#define SWIGTYPE_p_lldb__SBTypeFormat swig_types[71] +#define SWIGTYPE_p_lldb__SBTypeList swig_types[72] +#define SWIGTYPE_p_lldb__SBTypeMember swig_types[73] +#define SWIGTYPE_p_lldb__SBTypeMemberFunction swig_types[74] +#define SWIGTYPE_p_lldb__SBTypeNameSpecifier swig_types[75] +#define SWIGTYPE_p_lldb__SBTypeSummary swig_types[76] +#define SWIGTYPE_p_lldb__SBTypeSummaryOptions swig_types[77] +#define SWIGTYPE_p_lldb__SBTypeSynthetic swig_types[78] +#define SWIGTYPE_p_lldb__SBUnixSignals swig_types[79] +#define SWIGTYPE_p_lldb__SBValue swig_types[80] +#define SWIGTYPE_p_lldb__SBValueList swig_types[81] +#define SWIGTYPE_p_lldb__SBVariablesOptions swig_types[82] +#define SWIGTYPE_p_lldb__SBWatchpoint swig_types[83] +#define SWIGTYPE_p_lldb_private__SharingPtrT_lldb_private__ValueObject_t swig_types[84] +#define SWIGTYPE_p_long_double swig_types[85] +#define SWIGTYPE_p_long_long swig_types[86] +#define SWIGTYPE_p_p_void swig_types[87] +#define SWIGTYPE_p_pthread_rwlock_t swig_types[88] +#define SWIGTYPE_p_pthread_t swig_types[89] +#define SWIGTYPE_p_short swig_types[90] +#define SWIGTYPE_p_signed_char swig_types[91] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ABI_t swig_types[92] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Baton_t swig_types[93] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Block_t swig_types[94] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointLocation_t swig_types[95] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointResolver_t swig_types[96] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointSite_t swig_types[97] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Breakpoint_t swig_types[98] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BroadcasterManager_t swig_types[99] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Broadcaster_t swig_types[100] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ClangASTImporter_t swig_types[101] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CommandObject_t swig_types[102] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Communication_t swig_types[103] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CompileUnit_t swig_types[104] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Connection_t swig_types[105] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataBuffer_t swig_types[106] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataExtractor_t swig_types[107] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Debugger_t swig_types[108] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Disassembler_t swig_types[109] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DynamicLoader_t swig_types[110] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventDataStructuredData_t swig_types[111] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventData_t swig_types[112] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t swig_types[113] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExecutionContextRef_t swig_types[114] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExpressionVariable_t swig_types[115] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__File_t swig_types[116] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FuncUnwinders_t swig_types[117] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FunctionCaller_t swig_types[118] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Function_t swig_types[119] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOHandler_t swig_types[120] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOObject_t swig_types[121] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IRExecutionUnit_t swig_types[122] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InlineFunctionInfo_t swig_types[123] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Instruction_t swig_types[124] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InstrumentationRuntime_t swig_types[125] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__JITLoader_t swig_types[126] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__LanguageRuntime_t swig_types[127] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__LineTable_t swig_types[128] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Listener_t swig_types[129] +#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryHistory_t swig_types[130] #define SWIGTYPE_p_std__shared_ptrT_lldb_private__Module_t swig_types[131] #define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[132] #define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectFile_t swig_types[133] @@ -3096,6 +3096,52 @@ namespace swig { } +namespace { +template +T PyLongAsT(PyObject *obj) { + static_assert(true, "unsupported type"); +} + +template <> uint64_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsUnsignedLongLong(obj)); +} + +template <> uint32_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsUnsignedLong(obj)); +} + +template <> int64_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsLongLong(obj)); +} + +template <> int32_t PyLongAsT(PyObject *obj) { + return static_cast(PyLong_AsLong(obj)); +} + +template +bool SetNumberFromPyObject(T &number, PyObject *obj) { + if (PyInt_Check(obj)) + number = static_cast(PyInt_AsLong(obj)); + else if (PyLong_Check(obj)) + number = PyLongAsT(obj); + else return false; + + return true; +} + +template <> +bool SetNumberFromPyObject(double &number, PyObject *obj) { + if (PyFloat_Check(obj)) { + number = PyFloat_AsDouble(obj); + return true; + } + + return false; +} + +} // namespace + + #include #include @@ -5057,9 +5103,7 @@ SWIGINTERN PyObject *_wrap_SBAddress___str__(PyObject *SWIGUNUSEDPARM(self), PyO } arg1 = reinterpret_cast< lldb::SBAddress * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBAddress___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -7145,9 +7189,7 @@ SWIGINTERN PyObject *_wrap_SBBlock___str__(PyObject *SWIGUNUSEDPARM(self), PyObj } arg1 = reinterpret_cast< lldb::SBBlock * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBBlock___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -8889,9 +8931,7 @@ SWIGINTERN PyObject *_wrap_SBBreakpoint___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBBreakpoint * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBBreakpoint___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -10189,9 +10229,7 @@ SWIGINTERN PyObject *_wrap_SBBreakpointLocation___str__(PyObject *SWIGUNUSEDPARM } arg1 = reinterpret_cast< lldb::SBBreakpointLocation * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBBreakpointLocation___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -11548,9 +11586,7 @@ SWIGINTERN PyObject *_wrap_SBBreakpointName___str__(PyObject *SWIGUNUSEDPARM(sel } arg1 = reinterpret_cast< lldb::SBBreakpointName * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBBreakpointName___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -14035,6 +14071,95 @@ SWIGINTERN PyObject *_wrap_SBCommandInterpreter_HandleCompletion(PyObject *SWIGU } +SWIGINTERN PyObject *_wrap_SBCommandInterpreter_HandleCompletionWithDescriptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ; + char *arg2 = (char *) 0 ; + uint32_t arg3 ; + int arg4 ; + int arg5 ; + lldb::SBStringList *arg6 = 0 ; + lldb::SBStringList *arg7 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + unsigned int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + void *argp7 = 0 ; + int res7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + int result; + + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:SBCommandInterpreter_HandleCompletionWithDescriptions",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBCommandInterpreter, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "1"" of type '" "lldb::SBCommandInterpreter *""'"); + } + arg1 = reinterpret_cast< lldb::SBCommandInterpreter * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + ecode3 = SWIG_AsVal_unsigned_SS_int(obj2, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "3"" of type '" "uint32_t""'"); + } + arg3 = static_cast< uint32_t >(val3); + ecode4 = SWIG_AsVal_int(obj3, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int(obj4, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + res6 = SWIG_ConvertPtr(obj5, &argp6, SWIGTYPE_p_lldb__SBStringList, 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "6"" of type '" "lldb::SBStringList &""'"); + } + if (!argp6) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "6"" of type '" "lldb::SBStringList &""'"); + } + arg6 = reinterpret_cast< lldb::SBStringList * >(argp6); + res7 = SWIG_ConvertPtr(obj6, &argp7, SWIGTYPE_p_lldb__SBStringList, 0 ); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "7"" of type '" "lldb::SBStringList &""'"); + } + if (!argp7) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SBCommandInterpreter_HandleCompletionWithDescriptions" "', argument " "7"" of type '" "lldb::SBStringList &""'"); + } + arg7 = reinterpret_cast< lldb::SBStringList * >(argp7); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)(arg1)->HandleCompletionWithDescriptions((char const *)arg2,arg3,arg4,arg5,*arg6,*arg7); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_From_int(static_cast< int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBCommandInterpreter_IsActive(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ; @@ -15269,9 +15394,7 @@ SWIGINTERN PyObject *_wrap_SBCommandReturnObject___str__(PyObject *SWIGUNUSEDPAR } arg1 = reinterpret_cast< lldb::SBCommandReturnObject * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBCommandReturnObject___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -16742,9 +16865,7 @@ SWIGINTERN PyObject *_wrap_SBCompileUnit___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBCompileUnit * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBCompileUnit___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -17990,16 +18111,10 @@ SWIGINTERN PyObject *_wrap_SBData_CreateDataFromUInt64Array(PyObject *SWIGUNUSED int size = PyList_Size(obj2); int i = 0; arg4 = size; - arg3 = (uint64_t*) malloc(size * sizeof(uint64_t)); + arg3 = (uint64_t *) malloc(size * sizeof(uint64_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj2,i); - if (PyInt_Check(o)) { - arg3[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg3[i] = PyLong_AsUnsignedLongLong(o); - } - else { + if (!SetNumberFromPyObject(arg3[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg3); return NULL; @@ -18068,16 +18183,10 @@ SWIGINTERN PyObject *_wrap_SBData_CreateDataFromUInt32Array(PyObject *SWIGUNUSED int size = PyList_Size(obj2); int i = 0; arg4 = size; - arg3 = (uint32_t*) malloc(size * sizeof(uint32_t)); + arg3 = (uint32_t *) malloc(size * sizeof(uint32_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj2,i); - if (PyInt_Check(o)) { - arg3[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg3[i] = PyLong_AsUnsignedLong(o); - } - else { + if (!SetNumberFromPyObject(arg3[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg3); return NULL; @@ -18146,16 +18255,10 @@ SWIGINTERN PyObject *_wrap_SBData_CreateDataFromSInt64Array(PyObject *SWIGUNUSED int size = PyList_Size(obj2); int i = 0; arg4 = size; - arg3 = (int64_t*) malloc(size * sizeof(int64_t)); + arg3 = (int64_t *) malloc(size * sizeof(int64_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj2,i); - if (PyInt_Check(o)) { - arg3[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg3[i] = PyLong_AsLongLong(o); - } - else { + if (!SetNumberFromPyObject(arg3[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg3); return NULL; @@ -18224,16 +18327,10 @@ SWIGINTERN PyObject *_wrap_SBData_CreateDataFromSInt32Array(PyObject *SWIGUNUSED int size = PyList_Size(obj2); int i = 0; arg4 = size; - arg3 = (int32_t*) malloc(size * sizeof(int32_t)); + arg3 = (int32_t *) malloc(size * sizeof(int32_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj2,i); - if (PyInt_Check(o)) { - arg3[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg3[i] = PyLong_AsLong(o); - } - else { + if (!SetNumberFromPyObject(arg3[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg3); return NULL; @@ -18302,14 +18399,16 @@ SWIGINTERN PyObject *_wrap_SBData_CreateDataFromDoubleArray(PyObject *SWIGUNUSED int size = PyList_Size(obj2); int i = 0; arg4 = size; - arg3 = (double*) malloc(size * sizeof(double)); + arg3 = (double *) malloc(size * sizeof(double)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj2,i); - if (PyFloat_Check(o)) { - arg3[i] = PyFloat_AsDouble(o); + if (!SetNumberFromPyObject(arg3[i], o)) { + PyErr_SetString(PyExc_TypeError,"list must contain numbers"); + free(arg3); + return NULL; } - else { - PyErr_SetString(PyExc_TypeError,"list must contain floating-point numbers"); + + if (PyErr_Occurred()) { free(arg3); return NULL; } @@ -18401,16 +18500,10 @@ SWIGINTERN PyObject *_wrap_SBData_SetDataFromUInt64Array(PyObject *SWIGUNUSEDPAR int size = PyList_Size(obj1); int i = 0; arg3 = size; - arg2 = (uint64_t*) malloc(size * sizeof(uint64_t)); + arg2 = (uint64_t *) malloc(size * sizeof(uint64_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj1,i); - if (PyInt_Check(o)) { - arg2[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg2[i] = PyLong_AsUnsignedLongLong(o); - } - else { + if (!SetNumberFromPyObject(arg2[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg2); return NULL; @@ -18470,16 +18563,10 @@ SWIGINTERN PyObject *_wrap_SBData_SetDataFromUInt32Array(PyObject *SWIGUNUSEDPAR int size = PyList_Size(obj1); int i = 0; arg3 = size; - arg2 = (uint32_t*) malloc(size * sizeof(uint32_t)); + arg2 = (uint32_t *) malloc(size * sizeof(uint32_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj1,i); - if (PyInt_Check(o)) { - arg2[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg2[i] = PyLong_AsUnsignedLong(o); - } - else { + if (!SetNumberFromPyObject(arg2[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg2); return NULL; @@ -18539,16 +18626,10 @@ SWIGINTERN PyObject *_wrap_SBData_SetDataFromSInt64Array(PyObject *SWIGUNUSEDPAR int size = PyList_Size(obj1); int i = 0; arg3 = size; - arg2 = (int64_t*) malloc(size * sizeof(int64_t)); + arg2 = (int64_t *) malloc(size * sizeof(int64_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj1,i); - if (PyInt_Check(o)) { - arg2[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg2[i] = PyLong_AsLongLong(o); - } - else { + if (!SetNumberFromPyObject(arg2[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg2); return NULL; @@ -18608,16 +18689,10 @@ SWIGINTERN PyObject *_wrap_SBData_SetDataFromSInt32Array(PyObject *SWIGUNUSEDPAR int size = PyList_Size(obj1); int i = 0; arg3 = size; - arg2 = (int32_t*) malloc(size * sizeof(int32_t)); + arg2 = (int32_t *) malloc(size * sizeof(int32_t)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj1,i); - if (PyInt_Check(o)) { - arg2[i] = PyInt_AsLong(o); - } - else if (PyLong_Check(o)) { - arg2[i] = PyLong_AsLong(o); - } - else { + if (!SetNumberFromPyObject(arg2[i], o)) { PyErr_SetString(PyExc_TypeError,"list must contain numbers"); free(arg2); return NULL; @@ -18677,14 +18752,16 @@ SWIGINTERN PyObject *_wrap_SBData_SetDataFromDoubleArray(PyObject *SWIGUNUSEDPAR int size = PyList_Size(obj1); int i = 0; arg3 = size; - arg2 = (double*) malloc(size * sizeof(double)); + arg2 = (double *) malloc(size * sizeof(double)); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem(obj1,i); - if (PyFloat_Check(o)) { - arg2[i] = PyFloat_AsDouble(o); + if (!SetNumberFromPyObject(arg2[i], o)) { + PyErr_SetString(PyExc_TypeError,"list must contain numbers"); + free(arg2); + return NULL; } - else { - PyErr_SetString(PyExc_TypeError,"list must contain floating-point numbers"); + + if (PyErr_Occurred()) { free(arg2); return NULL; } @@ -18730,9 +18807,7 @@ SWIGINTERN PyObject *_wrap_SBData___str__(PyObject *SWIGUNUSEDPARM(self), PyObje } arg1 = reinterpret_cast< lldb::SBData * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBData___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -18748,7 +18823,7 @@ SWIGINTERN PyObject *SBData_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObjec return SWIG_Py_Void(); } -SWIGINTERN PyObject *_wrap_SBDebugger_Initialize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_SBDebugger_Initialize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; if (!PyArg_ParseTuple(args,(char *)":SBDebugger_Initialize")) SWIG_fail; @@ -18764,6 +18839,66 @@ SWIGINTERN PyObject *_wrap_SBDebugger_Initialize(PyObject *SWIGUNUSEDPARM(self), } +SWIGINTERN PyObject *_wrap_SBDebugger_Initialize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SBDebugger_Initialize",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_lldb__SBInitializerOptions, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBDebugger_Initialize" "', argument " "1"" of type '" "lldb::SBInitializerOptions &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SBDebugger_Initialize" "', argument " "1"" of type '" "lldb::SBInitializerOptions &""'"); + } + arg1 = reinterpret_cast< lldb::SBInitializerOptions * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + lldb::SBDebugger::Initialize(*arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SBDebugger_Initialize(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[2]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = (int)PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 1); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_SBDebugger_Initialize__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_lldb__SBInitializerOptions, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_SBDebugger_Initialize__SWIG_1(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'SBDebugger_Initialize'.\n" + " Possible C/C++ prototypes are:\n" + " Initialize()\n" + " lldb::SBDebugger::Initialize(lldb::SBInitializerOptions &)\n"); + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBDebugger_Terminate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; @@ -20917,17 +21052,29 @@ SWIGINTERN PyObject *_wrap_SBDebugger_GetVersionString(PyObject *SWIGUNUSEDPARM( SWIGINTERN PyObject *_wrap_SBDebugger_StateAsCString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::StateType arg1 ; - int val1 ; - int ecode1 = 0 ; PyObject * obj0 = 0 ; char *result = 0 ; if (!PyArg_ParseTuple(args,(char *)"O:SBDebugger_StateAsCString",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SBDebugger_StateAsCString" "', argument " "1"" of type '" "lldb::StateType""'"); - } - arg1 = static_cast< lldb::StateType >(val1); + { + using namespace lldb_private; + if (PythonInteger::Check(obj0)) + { + PythonInteger py_int(PyRefType::Borrowed, obj0); + int64_t state_type_value = py_int.GetInteger() ; + + if (state_type_value > lldb::StateType::kLastStateType) { + PyErr_SetString(PyExc_ValueError, "Not a valid StateType value"); + return nullptr; + } + arg1 = static_cast(state_type_value); + } + else + { + PyErr_SetString(PyExc_ValueError, "Expecting an integer"); + return nullptr; + } + } { SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (char *)lldb::SBDebugger::StateAsCString(arg1); @@ -20960,17 +21107,29 @@ SWIGINTERN PyObject *_wrap_SBDebugger_GetBuildConfiguration(PyObject *SWIGUNUSED SWIGINTERN PyObject *_wrap_SBDebugger_StateIsRunningState(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::StateType arg1 ; - int val1 ; - int ecode1 = 0 ; PyObject * obj0 = 0 ; bool result; if (!PyArg_ParseTuple(args,(char *)"O:SBDebugger_StateIsRunningState",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SBDebugger_StateIsRunningState" "', argument " "1"" of type '" "lldb::StateType""'"); - } - arg1 = static_cast< lldb::StateType >(val1); + { + using namespace lldb_private; + if (PythonInteger::Check(obj0)) + { + PythonInteger py_int(PyRefType::Borrowed, obj0); + int64_t state_type_value = py_int.GetInteger() ; + + if (state_type_value > lldb::StateType::kLastStateType) { + PyErr_SetString(PyExc_ValueError, "Not a valid StateType value"); + return nullptr; + } + arg1 = static_cast(state_type_value); + } + else + { + PyErr_SetString(PyExc_ValueError, "Expecting an integer"); + return nullptr; + } + } { SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (bool)lldb::SBDebugger::StateIsRunningState(arg1); @@ -20986,17 +21145,29 @@ SWIGINTERN PyObject *_wrap_SBDebugger_StateIsRunningState(PyObject *SWIGUNUSEDPA SWIGINTERN PyObject *_wrap_SBDebugger_StateIsStoppedState(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::StateType arg1 ; - int val1 ; - int ecode1 = 0 ; PyObject * obj0 = 0 ; bool result; if (!PyArg_ParseTuple(args,(char *)"O:SBDebugger_StateIsStoppedState",&obj0)) SWIG_fail; - ecode1 = SWIG_AsVal_int(obj0, &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SBDebugger_StateIsStoppedState" "', argument " "1"" of type '" "lldb::StateType""'"); - } - arg1 = static_cast< lldb::StateType >(val1); + { + using namespace lldb_private; + if (PythonInteger::Check(obj0)) + { + PythonInteger py_int(PyRefType::Borrowed, obj0); + int64_t state_type_value = py_int.GetInteger() ; + + if (state_type_value > lldb::StateType::kLastStateType) { + PyErr_SetString(PyExc_ValueError, "Not a valid StateType value"); + return nullptr; + } + arg1 = static_cast(state_type_value); + } + else + { + PyErr_SetString(PyExc_ValueError, "Expecting an integer"); + return nullptr; + } + } { SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (bool)lldb::SBDebugger::StateIsStoppedState(arg1); @@ -21558,6 +21729,32 @@ SWIGINTERN PyObject *_wrap_SBDebugger_SetPrompt(PyObject *SWIGUNUSEDPARM(self), } +SWIGINTERN PyObject *_wrap_SBDebugger_GetReproducerPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SBDebugger_GetReproducerPath",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBDebugger, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBDebugger_GetReproducerPath" "', argument " "1"" of type '" "lldb::SBDebugger const *""'"); + } + arg1 = reinterpret_cast< lldb::SBDebugger * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)((lldb::SBDebugger const *)arg1)->GetReproducerPath(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBDebugger_GetScriptLanguage(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ; @@ -22287,9 +22484,7 @@ SWIGINTERN PyObject *_wrap_SBDebugger___str__(PyObject *SWIGUNUSEDPARM(self), Py } arg1 = reinterpret_cast< lldb::SBDebugger * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBDebugger___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -22750,9 +22945,7 @@ SWIGINTERN PyObject *_wrap_SBDeclaration___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBDeclaration * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBDeclaration___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -23672,9 +23865,7 @@ SWIGINTERN PyObject *_wrap_SBError___str__(PyObject *SWIGUNUSEDPARM(self), PyObj } arg1 = reinterpret_cast< lldb::SBError * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBError___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -27289,9 +27480,7 @@ SWIGINTERN PyObject *_wrap_SBFileSpec___str__(PyObject *SWIGUNUSEDPARM(self), Py } arg1 = reinterpret_cast< lldb::SBFileSpec * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBFileSpec___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -29793,9 +29982,7 @@ SWIGINTERN PyObject *_wrap_SBFrame___str__(PyObject *SWIGUNUSEDPARM(self), PyObj } arg1 = reinterpret_cast< lldb::SBFrame * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBFrame___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -30537,9 +30724,7 @@ SWIGINTERN PyObject *_wrap_SBFunction___str__(PyObject *SWIGUNUSEDPARM(self), Py } arg1 = reinterpret_cast< lldb::SBFunction * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBFunction___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -30900,6 +31085,220 @@ SWIGINTERN PyObject *SBHostOS_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObj return SWIG_Py_Void(); } +SWIGINTERN PyObject *_wrap_new_SBInitializerOptions__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)":new_SBInitializerOptions")) SWIG_fail; + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (lldb::SBInitializerOptions *)new lldb::SBInitializerOptions(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_lldb__SBInitializerOptions, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SBInitializerOptions__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *arg1 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + lldb::SBInitializerOptions *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:new_SBInitializerOptions",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_lldb__SBInitializerOptions, 0 | 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_SBInitializerOptions" "', argument " "1"" of type '" "lldb::SBInitializerOptions const &""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_SBInitializerOptions" "', argument " "1"" of type '" "lldb::SBInitializerOptions const &""'"); + } + arg1 = reinterpret_cast< lldb::SBInitializerOptions * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (lldb::SBInitializerOptions *)new lldb::SBInitializerOptions((lldb::SBInitializerOptions const &)*arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_lldb__SBInitializerOptions, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_SBInitializerOptions(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[2]; + int ii; + + if (!PyTuple_Check(args)) SWIG_fail; + argc = (int)PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 1); ii++) { + argv[ii] = PyTuple_GET_ITEM(args,ii); + } + if (argc == 0) { + return _wrap_new_SBInitializerOptions__SWIG_0(self, args); + } + if (argc == 1) { + int _v; + int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_lldb__SBInitializerOptions, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_new_SBInitializerOptions__SWIG_1(self, args); + } + } + +fail: + SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_SBInitializerOptions'.\n" + " Possible C/C++ prototypes are:\n" + " lldb::SBInitializerOptions()\n" + " lldb::SBInitializerOptions(lldb::SBInitializerOptions const &)\n"); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_SBInitializerOptions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *arg1 = (lldb::SBInitializerOptions *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:delete_SBInitializerOptions",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBInitializerOptions, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SBInitializerOptions" "', argument " "1"" of type '" "lldb::SBInitializerOptions *""'"); + } + arg1 = reinterpret_cast< lldb::SBInitializerOptions * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + delete arg1; + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SBInitializerOptions_SetCaptureReproducer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *arg1 = (lldb::SBInitializerOptions *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SBInitializerOptions_SetCaptureReproducer",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBInitializerOptions, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBInitializerOptions_SetCaptureReproducer" "', argument " "1"" of type '" "lldb::SBInitializerOptions *""'"); + } + arg1 = reinterpret_cast< lldb::SBInitializerOptions * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SBInitializerOptions_SetCaptureReproducer" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + (arg1)->SetCaptureReproducer(arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SBInitializerOptions_SetReplayReproducer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *arg1 = (lldb::SBInitializerOptions *) 0 ; + bool arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + bool val2 ; + int ecode2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SBInitializerOptions_SetReplayReproducer",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBInitializerOptions, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBInitializerOptions_SetReplayReproducer" "', argument " "1"" of type '" "lldb::SBInitializerOptions *""'"); + } + arg1 = reinterpret_cast< lldb::SBInitializerOptions * >(argp1); + ecode2 = SWIG_AsVal_bool(obj1, &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SBInitializerOptions_SetReplayReproducer" "', argument " "2"" of type '" "bool""'"); + } + arg2 = static_cast< bool >(val2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + (arg1)->SetReplayReproducer(arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SBInitializerOptions_SetReproducerPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBInitializerOptions *arg1 = (lldb::SBInitializerOptions *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:SBInitializerOptions_SetReproducerPath",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBInitializerOptions, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBInitializerOptions_SetReproducerPath" "', argument " "1"" of type '" "lldb::SBInitializerOptions *""'"); + } + arg1 = reinterpret_cast< lldb::SBInitializerOptions * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SBInitializerOptions_SetReproducerPath" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + (arg1)->SetReproducerPath((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + +SWIGINTERN PyObject *SBInitializerOptions_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_lldb__SBInitializerOptions, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + SWIGINTERN PyObject *_wrap_new_SBInstruction__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBInstruction *result = 0 ; @@ -31577,9 +31976,7 @@ SWIGINTERN PyObject *_wrap_SBInstruction___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBInstruction * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBInstruction___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -32060,9 +32457,7 @@ SWIGINTERN PyObject *_wrap_SBInstructionList___str__(PyObject *SWIGUNUSEDPARM(se } arg1 = reinterpret_cast< lldb::SBInstructionList * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBInstructionList___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -34072,9 +34467,7 @@ SWIGINTERN PyObject *_wrap_SBLineEntry___str__(PyObject *SWIGUNUSEDPARM(self), P } arg1 = reinterpret_cast< lldb::SBLineEntry * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBLineEntry___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -35326,6 +35719,32 @@ SWIGINTERN PyObject *_wrap_SBMemoryRegionInfo_IsMapped(PyObject *SWIGUNUSEDPARM( } +SWIGINTERN PyObject *_wrap_SBMemoryRegionInfo_GetName(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBMemoryRegionInfo *arg1 = (lldb::SBMemoryRegionInfo *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:SBMemoryRegionInfo_GetName",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBMemoryRegionInfo, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBMemoryRegionInfo_GetName" "', argument " "1"" of type '" "lldb::SBMemoryRegionInfo *""'"); + } + arg1 = reinterpret_cast< lldb::SBMemoryRegionInfo * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (char *)(arg1)->GetName(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBMemoryRegionInfo___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBMemoryRegionInfo *arg1 = (lldb::SBMemoryRegionInfo *) 0 ; @@ -35455,9 +35874,7 @@ SWIGINTERN PyObject *_wrap_SBMemoryRegionInfo___str__(PyObject *SWIGUNUSEDPARM(s } arg1 = reinterpret_cast< lldb::SBMemoryRegionInfo * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBMemoryRegionInfo___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -37604,6 +38021,32 @@ SWIGINTERN PyObject *_wrap_SBModule_IsTypeSystemCompatible(PyObject *SWIGUNUSEDP } +SWIGINTERN PyObject *_wrap_SBModule_GetObjectFileEntryPointAddress(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBModule *arg1 = (lldb::SBModule *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + lldb::SBAddress result; + + if (!PyArg_ParseTuple(args,(char *)"O:SBModule_GetObjectFileEntryPointAddress",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBModule, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBModule_GetObjectFileEntryPointAddress" "', argument " "1"" of type '" "lldb::SBModule const *""'"); + } + arg1 = reinterpret_cast< lldb::SBModule * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = ((lldb::SBModule const *)arg1)->GetObjectFileEntryPointAddress(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj((new lldb::SBAddress(static_cast< const lldb::SBAddress& >(result))), SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBModule___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBModule *arg1 = (lldb::SBModule *) 0 ; @@ -37695,9 +38138,7 @@ SWIGINTERN PyObject *_wrap_SBModule___str__(PyObject *SWIGUNUSEDPARM(self), PyOb } arg1 = reinterpret_cast< lldb::SBModule * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBModule___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -38330,9 +38771,7 @@ SWIGINTERN PyObject *_wrap_SBModuleSpec___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBModuleSpec * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBModuleSpec___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -38789,9 +39228,7 @@ SWIGINTERN PyObject *_wrap_SBModuleSpecList___str__(PyObject *SWIGUNUSEDPARM(sel } arg1 = reinterpret_cast< lldb::SBModuleSpecList * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBModuleSpecList___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -43532,9 +43969,7 @@ SWIGINTERN PyObject *_wrap_SBProcess___str__(PyObject *SWIGUNUSEDPARM(self), PyO } arg1 = reinterpret_cast< lldb::SBProcess * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBProcess___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -45546,9 +45981,7 @@ SWIGINTERN PyObject *_wrap_SBSection___str__(PyObject *SWIGUNUSEDPARM(self), PyO } arg1 = reinterpret_cast< lldb::SBSection * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBSection___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -48136,9 +48569,7 @@ SWIGINTERN PyObject *_wrap_SBSymbol___str__(PyObject *SWIGUNUSEDPARM(self), PyOb } arg1 = reinterpret_cast< lldb::SBSymbol * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBSymbol___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -48793,9 +49224,7 @@ SWIGINTERN PyObject *_wrap_SBSymbolContext___str__(PyObject *SWIGUNUSEDPARM(self } arg1 = reinterpret_cast< lldb::SBSymbolContext * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBSymbolContext___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -49200,9 +49629,7 @@ SWIGINTERN PyObject *_wrap_SBSymbolContextList___str__(PyObject *SWIGUNUSEDPARM( } arg1 = reinterpret_cast< lldb::SBSymbolContextList * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBSymbolContextList___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -50455,6 +50882,67 @@ SWIGINTERN PyObject *_wrap_SBTarget_GetExecutable(PyObject *SWIGUNUSEDPARM(self) } +SWIGINTERN PyObject *_wrap_SBTarget_AppendImageSearchPath(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + lldb::SBError *arg4 = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OOOO:SBTarget_AppendImageSearchPath",&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBTarget, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBTarget_AppendImageSearchPath" "', argument " "1"" of type '" "lldb::SBTarget *""'"); + } + arg1 = reinterpret_cast< lldb::SBTarget * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SBTarget_AppendImageSearchPath" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "SBTarget_AppendImageSearchPath" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_lldb__SBError, 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "SBTarget_AppendImageSearchPath" "', argument " "4"" of type '" "lldb::SBError &""'"); + } + if (!argp4) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SBTarget_AppendImageSearchPath" "', argument " "4"" of type '" "lldb::SBError &""'"); + } + arg4 = reinterpret_cast< lldb::SBError * >(argp4); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + (arg1)->AppendImageSearchPath((char const *)arg2,(char const *)arg3,*arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBTarget_AddModule__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ; @@ -56603,9 +57091,7 @@ SWIGINTERN PyObject *_wrap_SBTarget___str__(PyObject *SWIGUNUSEDPARM(self), PyOb } arg1 = reinterpret_cast< lldb::SBTarget * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTarget___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -59485,6 +59971,58 @@ SWIGINTERN PyObject *_wrap_SBThread_GetExtendedBacktraceOriginatingIndexID(PyObj } +SWIGINTERN PyObject *_wrap_SBThread_GetCurrentException(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBThread *arg1 = (lldb::SBThread *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + lldb::SBValue result; + + if (!PyArg_ParseTuple(args,(char *)"O:SBThread_GetCurrentException",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBThread, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBThread_GetCurrentException" "', argument " "1"" of type '" "lldb::SBThread *""'"); + } + arg1 = reinterpret_cast< lldb::SBThread * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (arg1)->GetCurrentException(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj((new lldb::SBValue(static_cast< const lldb::SBValue& >(result))), SWIGTYPE_p_lldb__SBValue, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_SBThread_GetCurrentExceptionBacktrace(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBThread *arg1 = (lldb::SBThread *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + lldb::SBThread result; + + if (!PyArg_ParseTuple(args,(char *)"O:SBThread_GetCurrentExceptionBacktrace",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBThread, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBThread_GetCurrentExceptionBacktrace" "', argument " "1"" of type '" "lldb::SBThread *""'"); + } + arg1 = reinterpret_cast< lldb::SBThread * >(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (arg1)->GetCurrentExceptionBacktrace(); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj((new lldb::SBThread(static_cast< const lldb::SBThread& >(result))), SWIGTYPE_p_lldb__SBThread, SWIG_POINTER_OWN | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_SBThread_SafeToCallFunctions(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBThread *arg1 = (lldb::SBThread *) 0 ; @@ -59526,9 +60064,7 @@ SWIGINTERN PyObject *_wrap_SBThread___str__(PyObject *SWIGUNUSEDPARM(self), PyOb } arg1 = reinterpret_cast< lldb::SBThread * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBThread___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -60559,6 +61095,44 @@ SWIGINTERN PyObject *_wrap_SBThreadPlan_QueueThreadPlanForRunToAddress(PyObject } +SWIGINTERN PyObject *_wrap_SBThreadPlan_QueueThreadPlanForStepScripted(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + lldb::SBThreadPlan result; + + if (!PyArg_ParseTuple(args,(char *)"OO:SBThreadPlan_QueueThreadPlanForStepScripted",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBThreadPlan, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBThreadPlan_QueueThreadPlanForStepScripted" "', argument " "1"" of type '" "lldb::SBThreadPlan *""'"); + } + arg1 = reinterpret_cast< lldb::SBThreadPlan * >(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SBThreadPlan_QueueThreadPlanForStepScripted" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (arg1)->QueueThreadPlanForStepScripted((char const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj((new lldb::SBThreadPlan(static_cast< const lldb::SBThreadPlan& >(result))), SWIGTYPE_p_lldb__SBThreadPlan, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return NULL; +} + + SWIGINTERN PyObject *SBThreadPlan_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL; @@ -61645,9 +62219,7 @@ SWIGINTERN PyObject *_wrap_SBTypeMember___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBTypeMember * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeMember___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -62070,9 +62642,7 @@ SWIGINTERN PyObject *_wrap_SBTypeMemberFunction___str__(PyObject *SWIGUNUSEDPARM } arg1 = reinterpret_cast< lldb::SBTypeMemberFunction * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeMemberFunction___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -63387,9 +63957,7 @@ SWIGINTERN PyObject *_wrap_SBType___str__(PyObject *SWIGUNUSEDPARM(self), PyObje } arg1 = reinterpret_cast< lldb::SBType * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBType___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -64922,9 +65490,7 @@ SWIGINTERN PyObject *_wrap_SBTypeCategory___str__(PyObject *SWIGUNUSEDPARM(self) } arg1 = reinterpret_cast< lldb::SBTypeCategory * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeCategory___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -65234,9 +65800,7 @@ SWIGINTERN PyObject *_wrap_SBTypeEnumMember___str__(PyObject *SWIGUNUSEDPARM(sel } arg1 = reinterpret_cast< lldb::SBTypeEnumMember * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeEnumMember___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -66061,9 +66625,7 @@ SWIGINTERN PyObject *_wrap_SBTypeFilter___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBTypeFilter * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeFilter___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -66746,9 +67308,7 @@ SWIGINTERN PyObject *_wrap_SBTypeFormat___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBTypeFormat * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeFormat___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -67280,9 +67840,7 @@ SWIGINTERN PyObject *_wrap_SBTypeNameSpecifier___str__(PyObject *SWIGUNUSEDPARM( } arg1 = reinterpret_cast< lldb::SBTypeNameSpecifier * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeNameSpecifier___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -68459,9 +69017,7 @@ SWIGINTERN PyObject *_wrap_SBTypeSummary___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBTypeSummary * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeSummary___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -69185,9 +69741,7 @@ SWIGINTERN PyObject *_wrap_SBTypeSynthetic___str__(PyObject *SWIGUNUSEDPARM(self } arg1 = reinterpret_cast< lldb::SBTypeSynthetic * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBTypeSynthetic___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -72733,9 +73287,7 @@ SWIGINTERN PyObject *_wrap_SBValue___str__(PyObject *SWIGUNUSEDPARM(self), PyObj } arg1 = reinterpret_cast< lldb::SBValue * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBValue___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -73173,9 +73725,7 @@ SWIGINTERN PyObject *_wrap_SBValueList___str__(PyObject *SWIGUNUSEDPARM(self), P } arg1 = reinterpret_cast< lldb::SBValueList * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBValueList___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -73382,20 +73932,32 @@ SWIGINTERN PyObject *_wrap_SBVariablesOptions_SetIncludeArguments(PyObject *SWIG SWIGINTERN PyObject *_wrap_SBVariablesOptions_GetIncludeRecognizedArguments(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; lldb::SBVariablesOptions *arg1 = (lldb::SBVariablesOptions *) 0 ; + lldb::SBTarget *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; bool result; - if (!PyArg_ParseTuple(args,(char *)"O:SBVariablesOptions_GetIncludeRecognizedArguments",&obj0)) SWIG_fail; + if (!PyArg_ParseTuple(args,(char *)"OO:SBVariablesOptions_GetIncludeRecognizedArguments",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_lldb__SBVariablesOptions, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SBVariablesOptions_GetIncludeRecognizedArguments" "', argument " "1"" of type '" "lldb::SBVariablesOptions const *""'"); } arg1 = reinterpret_cast< lldb::SBVariablesOptions * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_lldb__SBTarget, 0 | 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SBVariablesOptions_GetIncludeRecognizedArguments" "', argument " "2"" of type '" "lldb::SBTarget const &""'"); + } + if (!argp2) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SBVariablesOptions_GetIncludeRecognizedArguments" "', argument " "2"" of type '" "lldb::SBTarget const &""'"); + } + arg2 = reinterpret_cast< lldb::SBTarget * >(argp2); { SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (bool)((lldb::SBVariablesOptions const *)arg1)->GetIncludeRecognizedArguments(); + result = (bool)((lldb::SBVariablesOptions const *)arg1)->GetIncludeRecognizedArguments((lldb::SBTarget const &)*arg2); SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = SWIG_From_bool(static_cast< bool >(result)); @@ -74362,9 +74924,7 @@ SWIGINTERN PyObject *_wrap_SBWatchpoint___str__(PyObject *SWIGUNUSEDPARM(self), } arg1 = reinterpret_cast< lldb::SBWatchpoint * >(argp1); { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; result = (PyObject *)lldb_SBWatchpoint___str__(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; } resultobj = result; return resultobj; @@ -76399,6 +76959,11 @@ static PyMethodDef SwigMethods[] = { " int match_start_point, int max_return_elements, \n" " SBStringList matches) -> int\n" ""}, + { (char *)"SBCommandInterpreter_HandleCompletionWithDescriptions", _wrap_SBCommandInterpreter_HandleCompletionWithDescriptions, METH_VARARGS, (char *)"\n" + "SBCommandInterpreter_HandleCompletionWithDescriptions(SBCommandInterpreter self, char current_line, uint32_t cursor_pos, \n" + " int match_start_point, int max_return_elements, \n" + " SBStringList matches, SBStringList descriptions) -> int\n" + ""}, { (char *)"SBCommandInterpreter_IsActive", _wrap_SBCommandInterpreter_IsActive, METH_VARARGS, (char *)"SBCommandInterpreter_IsActive(SBCommandInterpreter self) -> bool"}, { (char *)"SBCommandInterpreter_WasInterrupted", _wrap_SBCommandInterpreter_WasInterrupted, METH_VARARGS, (char *)"SBCommandInterpreter_WasInterrupted(SBCommandInterpreter self) -> bool"}, { (char *)"SBCommandInterpreter_swigregister", SBCommandInterpreter_swigregister, METH_VARARGS, NULL}, @@ -76561,7 +77126,10 @@ static PyMethodDef SwigMethods[] = { { (char *)"SBData_SetDataFromDoubleArray", _wrap_SBData_SetDataFromDoubleArray, METH_VARARGS, (char *)"SBData_SetDataFromDoubleArray(SBData self, double array) -> bool"}, { (char *)"SBData___str__", _wrap_SBData___str__, METH_VARARGS, (char *)"SBData___str__(SBData self) -> PyObject"}, { (char *)"SBData_swigregister", SBData_swigregister, METH_VARARGS, NULL}, - { (char *)"SBDebugger_Initialize", _wrap_SBDebugger_Initialize, METH_VARARGS, (char *)"SBDebugger_Initialize()"}, + { (char *)"SBDebugger_Initialize", _wrap_SBDebugger_Initialize, METH_VARARGS, (char *)"\n" + "Initialize()\n" + "SBDebugger_Initialize(SBInitializerOptions options)\n" + ""}, { (char *)"SBDebugger_Terminate", _wrap_SBDebugger_Terminate, METH_VARARGS, (char *)"SBDebugger_Terminate()"}, { (char *)"SBDebugger_Create", _wrap_SBDebugger_Create, METH_VARARGS, (char *)"\n" "Create() -> SBDebugger\n" @@ -76674,6 +77242,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"SBDebugger_GetID", _wrap_SBDebugger_GetID, METH_VARARGS, (char *)"SBDebugger_GetID(SBDebugger self) -> user_id_t"}, { (char *)"SBDebugger_GetPrompt", _wrap_SBDebugger_GetPrompt, METH_VARARGS, (char *)"SBDebugger_GetPrompt(SBDebugger self) -> char"}, { (char *)"SBDebugger_SetPrompt", _wrap_SBDebugger_SetPrompt, METH_VARARGS, (char *)"SBDebugger_SetPrompt(SBDebugger self, char prompt)"}, + { (char *)"SBDebugger_GetReproducerPath", _wrap_SBDebugger_GetReproducerPath, METH_VARARGS, (char *)"SBDebugger_GetReproducerPath(SBDebugger self) -> char"}, { (char *)"SBDebugger_GetScriptLanguage", _wrap_SBDebugger_GetScriptLanguage, METH_VARARGS, (char *)"SBDebugger_GetScriptLanguage(SBDebugger self) -> ScriptLanguage"}, { (char *)"SBDebugger_SetScriptLanguage", _wrap_SBDebugger_SetScriptLanguage, METH_VARARGS, (char *)"SBDebugger_SetScriptLanguage(SBDebugger self, ScriptLanguage script_lang)"}, { (char *)"SBDebugger_GetCloseInputOnEOF", _wrap_SBDebugger_GetCloseInputOnEOF, METH_VARARGS, (char *)"SBDebugger_GetCloseInputOnEOF(SBDebugger self) -> bool"}, @@ -77156,6 +77725,15 @@ static PyMethodDef SwigMethods[] = { { (char *)"new_SBHostOS", _wrap_new_SBHostOS, METH_VARARGS, (char *)"new_SBHostOS() -> SBHostOS"}, { (char *)"delete_SBHostOS", _wrap_delete_SBHostOS, METH_VARARGS, (char *)"delete_SBHostOS(SBHostOS self)"}, { (char *)"SBHostOS_swigregister", SBHostOS_swigregister, METH_VARARGS, NULL}, + { (char *)"new_SBInitializerOptions", _wrap_new_SBInitializerOptions, METH_VARARGS, (char *)"\n" + "SBInitializerOptions()\n" + "new_SBInitializerOptions(SBInitializerOptions rhs) -> SBInitializerOptions\n" + ""}, + { (char *)"delete_SBInitializerOptions", _wrap_delete_SBInitializerOptions, METH_VARARGS, (char *)"delete_SBInitializerOptions(SBInitializerOptions self)"}, + { (char *)"SBInitializerOptions_SetCaptureReproducer", _wrap_SBInitializerOptions_SetCaptureReproducer, METH_VARARGS, (char *)"SBInitializerOptions_SetCaptureReproducer(SBInitializerOptions self, bool b)"}, + { (char *)"SBInitializerOptions_SetReplayReproducer", _wrap_SBInitializerOptions_SetReplayReproducer, METH_VARARGS, (char *)"SBInitializerOptions_SetReplayReproducer(SBInitializerOptions self, bool b)"}, + { (char *)"SBInitializerOptions_SetReproducerPath", _wrap_SBInitializerOptions_SetReproducerPath, METH_VARARGS, (char *)"SBInitializerOptions_SetReproducerPath(SBInitializerOptions self, char path)"}, + { (char *)"SBInitializerOptions_swigregister", SBInitializerOptions_swigregister, METH_VARARGS, NULL}, { (char *)"new_SBInstruction", _wrap_new_SBInstruction, METH_VARARGS, (char *)"\n" "SBInstruction()\n" "new_SBInstruction(SBInstruction rhs) -> SBInstruction\n" @@ -77316,6 +77894,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"SBMemoryRegionInfo_IsWritable", _wrap_SBMemoryRegionInfo_IsWritable, METH_VARARGS, (char *)"SBMemoryRegionInfo_IsWritable(SBMemoryRegionInfo self) -> bool"}, { (char *)"SBMemoryRegionInfo_IsExecutable", _wrap_SBMemoryRegionInfo_IsExecutable, METH_VARARGS, (char *)"SBMemoryRegionInfo_IsExecutable(SBMemoryRegionInfo self) -> bool"}, { (char *)"SBMemoryRegionInfo_IsMapped", _wrap_SBMemoryRegionInfo_IsMapped, METH_VARARGS, (char *)"SBMemoryRegionInfo_IsMapped(SBMemoryRegionInfo self) -> bool"}, + { (char *)"SBMemoryRegionInfo_GetName", _wrap_SBMemoryRegionInfo_GetName, METH_VARARGS, (char *)"SBMemoryRegionInfo_GetName(SBMemoryRegionInfo self) -> char"}, { (char *)"SBMemoryRegionInfo___eq__", _wrap_SBMemoryRegionInfo___eq__, METH_VARARGS, (char *)"SBMemoryRegionInfo___eq__(SBMemoryRegionInfo self, SBMemoryRegionInfo rhs) -> bool"}, { (char *)"SBMemoryRegionInfo___ne__", _wrap_SBMemoryRegionInfo___ne__, METH_VARARGS, (char *)"SBMemoryRegionInfo___ne__(SBMemoryRegionInfo self, SBMemoryRegionInfo rhs) -> bool"}, { (char *)"SBMemoryRegionInfo_GetDescription", _wrap_SBMemoryRegionInfo_GetDescription, METH_VARARGS, (char *)"SBMemoryRegionInfo_GetDescription(SBMemoryRegionInfo self, SBStream description) -> bool"}, @@ -77514,6 +78093,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"SBModule_GetSymbolFileSpec", _wrap_SBModule_GetSymbolFileSpec, METH_VARARGS, (char *)"SBModule_GetSymbolFileSpec(SBModule self) -> SBFileSpec"}, { (char *)"SBModule_GetObjectFileHeaderAddress", _wrap_SBModule_GetObjectFileHeaderAddress, METH_VARARGS, (char *)"SBModule_GetObjectFileHeaderAddress(SBModule self) -> SBAddress"}, { (char *)"SBModule_IsTypeSystemCompatible", _wrap_SBModule_IsTypeSystemCompatible, METH_VARARGS, (char *)"SBModule_IsTypeSystemCompatible(SBModule self, LanguageType language) -> SBError"}, + { (char *)"SBModule_GetObjectFileEntryPointAddress", _wrap_SBModule_GetObjectFileEntryPointAddress, METH_VARARGS, (char *)"SBModule_GetObjectFileEntryPointAddress(SBModule self) -> SBAddress"}, { (char *)"SBModule___eq__", _wrap_SBModule___eq__, METH_VARARGS, (char *)"SBModule___eq__(SBModule self, SBModule rhs) -> bool"}, { (char *)"SBModule___ne__", _wrap_SBModule___ne__, METH_VARARGS, (char *)"SBModule___ne__(SBModule self, SBModule rhs) -> bool"}, { (char *)"SBModule___str__", _wrap_SBModule___str__, METH_VARARGS, (char *)"SBModule___str__(SBModule self) -> PyObject"}, @@ -78390,6 +78970,12 @@ static PyMethodDef SwigMethods[] = { "\n" ""}, { (char *)"SBTarget_GetExecutable", _wrap_SBTarget_GetExecutable, METH_VARARGS, (char *)"SBTarget_GetExecutable(SBTarget self) -> SBFileSpec"}, + { (char *)"SBTarget_AppendImageSearchPath", _wrap_SBTarget_AppendImageSearchPath, METH_VARARGS, (char *)"\n" + "SBTarget_AppendImageSearchPath(SBTarget self, char _from, char to, SBError error)\n" + "\n" + "/// Append the path mapping (from -> to) to the target's paths mapping list.\n" + "\n" + ""}, { (char *)"SBTarget_AddModule", _wrap_SBTarget_AddModule, METH_VARARGS, (char *)"\n" "AddModule(SBModule module) -> bool\n" "AddModule(char path, char triple, char uuid) -> SBModule\n" @@ -79043,6 +79629,20 @@ static PyMethodDef SwigMethods[] = { "In that case, this ExtendedBacktrace thread's IndexID will be returned.\n" "\n" ""}, + { (char *)"SBThread_GetCurrentException", _wrap_SBThread_GetCurrentException, METH_VARARGS, (char *)"\n" + "Returns an SBValue object represeting the current exception for the thread,\n" + "if there is any. Currently, this works for Obj-C code and returns an SBValue\n" + "representing the NSException object at the throw site or that's currently\n" + "being processes.\n" + "\n" + ""}, + { (char *)"SBThread_GetCurrentExceptionBacktrace", _wrap_SBThread_GetCurrentExceptionBacktrace, METH_VARARGS, (char *)"\n" + "Returns a historical (fake) SBThread representing the stack trace of an\n" + "exception, if there is one for the thread. Currently, this works for Obj-C\n" + "code, and can retrieve the throw-site backtrace of an NSException object\n" + "even when the program is no longer at the throw site.\n" + "\n" + ""}, { (char *)"SBThread_SafeToCallFunctions", _wrap_SBThread_SafeToCallFunctions, METH_VARARGS, (char *)"\n" "Takes no arguments, returns a bool.\n" "lldb may be able to detect that function calls should not be executed\n" @@ -79089,6 +79689,7 @@ static PyMethodDef SwigMethods[] = { "SBThreadPlan_QueueThreadPlanForStepOut(SBThreadPlan self, uint32_t frame_idx_to_step_to) -> SBThreadPlan\n" ""}, { (char *)"SBThreadPlan_QueueThreadPlanForRunToAddress", _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress, METH_VARARGS, (char *)"SBThreadPlan_QueueThreadPlanForRunToAddress(SBThreadPlan self, SBAddress address) -> SBThreadPlan"}, + { (char *)"SBThreadPlan_QueueThreadPlanForStepScripted", _wrap_SBThreadPlan_QueueThreadPlanForStepScripted, METH_VARARGS, (char *)"SBThreadPlan_QueueThreadPlanForStepScripted(SBThreadPlan self, char script_class_name) -> SBThreadPlan"}, { (char *)"SBThreadPlan_swigregister", SBThreadPlan_swigregister, METH_VARARGS, NULL}, { (char *)"new_SBTrace", _wrap_new_SBTrace, METH_VARARGS, (char *)"new_SBTrace() -> SBTrace"}, { (char *)"SBTrace_GetTraceData", _wrap_SBTrace_GetTraceData, METH_VARARGS, (char *)"\n" @@ -79606,7 +80207,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"SBVariablesOptions_IsValid", _wrap_SBVariablesOptions_IsValid, METH_VARARGS, (char *)"SBVariablesOptions_IsValid(SBVariablesOptions self) -> bool"}, { (char *)"SBVariablesOptions_GetIncludeArguments", _wrap_SBVariablesOptions_GetIncludeArguments, METH_VARARGS, (char *)"SBVariablesOptions_GetIncludeArguments(SBVariablesOptions self) -> bool"}, { (char *)"SBVariablesOptions_SetIncludeArguments", _wrap_SBVariablesOptions_SetIncludeArguments, METH_VARARGS, (char *)"SBVariablesOptions_SetIncludeArguments(SBVariablesOptions self, bool arg1)"}, - { (char *)"SBVariablesOptions_GetIncludeRecognizedArguments", _wrap_SBVariablesOptions_GetIncludeRecognizedArguments, METH_VARARGS, (char *)"SBVariablesOptions_GetIncludeRecognizedArguments(SBVariablesOptions self) -> bool"}, + { (char *)"SBVariablesOptions_GetIncludeRecognizedArguments", _wrap_SBVariablesOptions_GetIncludeRecognizedArguments, METH_VARARGS, (char *)"SBVariablesOptions_GetIncludeRecognizedArguments(SBVariablesOptions self, SBTarget arg1) -> bool"}, { (char *)"SBVariablesOptions_SetIncludeRecognizedArguments", _wrap_SBVariablesOptions_SetIncludeRecognizedArguments, METH_VARARGS, (char *)"SBVariablesOptions_SetIncludeRecognizedArguments(SBVariablesOptions self, bool arg1)"}, { (char *)"SBVariablesOptions_GetIncludeLocals", _wrap_SBVariablesOptions_GetIncludeLocals, METH_VARARGS, (char *)"SBVariablesOptions_GetIncludeLocals(SBVariablesOptions self) -> bool"}, { (char *)"SBVariablesOptions_SetIncludeLocals", _wrap_SBVariablesOptions_SetIncludeLocals, METH_VARARGS, (char *)"SBVariablesOptions_SetIncludeLocals(SBVariablesOptions self, bool arg1)"}, @@ -79721,6 +80322,7 @@ static swig_type_info _swigt__p_lldb__SBFileSpecList = {"_p_lldb__SBFileSpecList static swig_type_info _swigt__p_lldb__SBFrame = {"_p_lldb__SBFrame", "lldb::SBFrame *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_lldb__SBFunction = {"_p_lldb__SBFunction", "lldb::SBFunction *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_lldb__SBHostOS = {"_p_lldb__SBHostOS", "lldb::SBHostOS *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_lldb__SBInitializerOptions = {"_p_lldb__SBInitializerOptions", "lldb::SBInitializerOptions *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_lldb__SBInstruction = {"_p_lldb__SBInstruction", "lldb::SBInstruction *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_lldb__SBInstructionList = {"_p_lldb__SBInstructionList", "lldb::SBInstructionList *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_lldb__SBLanguageRuntime = {"_p_lldb__SBLanguageRuntime", "lldb::SBLanguageRuntime *", 0, 0, (void*)0, 0}; @@ -79818,7 +80420,6 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__LanguageRuntime_t static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__LineTable_t = {"_p_std__shared_ptrT_lldb_private__LineTable_t", "lldb::LineTableSP *|std::shared_ptr< lldb_private::LineTable > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Listener_t = {"_p_std__shared_ptrT_lldb_private__Listener_t", "std::shared_ptr< lldb_private::Listener > *|lldb::ListenerSP *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__MemoryHistory_t = {"_p_std__shared_ptrT_lldb_private__MemoryHistory_t", "lldb::MemoryHistorySP *|std::shared_ptr< lldb_private::MemoryHistory > *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t = {"_p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t", "std::shared_ptr< lldb_private::MemoryRegionInfo > *|lldb::MemoryRegionInfoSP *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Module_t = {"_p_std__shared_ptrT_lldb_private__Module_t", "lldb::ModuleSP *|std::shared_ptr< lldb_private::Module > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t = {"_p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t", "lldb::ObjectFileJITDelegateSP *|std::shared_ptr< lldb_private::ObjectFileJITDelegate > *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ObjectFile_t = {"_p_std__shared_ptrT_lldb_private__ObjectFile_t", "lldb::ObjectFileSP *|std::shared_ptr< lldb_private::ObjectFile > *", 0, 0, (void*)0, 0}; @@ -79979,6 +80580,7 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_lldb__SBFrame, &_swigt__p_lldb__SBFunction, &_swigt__p_lldb__SBHostOS, + &_swigt__p_lldb__SBInitializerOptions, &_swigt__p_lldb__SBInstruction, &_swigt__p_lldb__SBInstructionList, &_swigt__p_lldb__SBLanguageRuntime, @@ -80076,7 +80678,6 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_std__shared_ptrT_lldb_private__LineTable_t, &_swigt__p_std__shared_ptrT_lldb_private__Listener_t, &_swigt__p_std__shared_ptrT_lldb_private__MemoryHistory_t, - &_swigt__p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t, &_swigt__p_std__shared_ptrT_lldb_private__Module_t, &_swigt__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t, &_swigt__p_std__shared_ptrT_lldb_private__ObjectFile_t, @@ -80237,6 +80838,7 @@ static swig_cast_info _swigc__p_lldb__SBFileSpecList[] = { {&_swigt__p_lldb__SB static swig_cast_info _swigc__p_lldb__SBFrame[] = { {&_swigt__p_lldb__SBFrame, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_lldb__SBFunction[] = { {&_swigt__p_lldb__SBFunction, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_lldb__SBHostOS[] = { {&_swigt__p_lldb__SBHostOS, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_lldb__SBInitializerOptions[] = { {&_swigt__p_lldb__SBInitializerOptions, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_lldb__SBInstruction[] = { {&_swigt__p_lldb__SBInstruction, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_lldb__SBInstructionList[] = { {&_swigt__p_lldb__SBInstructionList, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_lldb__SBLanguageRuntime[] = { {&_swigt__p_lldb__SBLanguageRuntime, 0, 0, 0},{0, 0, 0, 0}}; @@ -80334,7 +80936,6 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__LanguageRuntime_t static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__LineTable_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__LineTable_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Listener_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Listener_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__MemoryHistory_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__MemoryHistory_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Module_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Module_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ObjectFile_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ObjectFile_t, 0, 0, 0},{0, 0, 0, 0}}; @@ -80495,6 +81096,7 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_lldb__SBFrame, _swigc__p_lldb__SBFunction, _swigc__p_lldb__SBHostOS, + _swigc__p_lldb__SBInitializerOptions, _swigc__p_lldb__SBInstruction, _swigc__p_lldb__SBInstructionList, _swigc__p_lldb__SBLanguageRuntime, @@ -80592,7 +81194,6 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_std__shared_ptrT_lldb_private__LineTable_t, _swigc__p_std__shared_ptrT_lldb_private__Listener_t, _swigc__p_std__shared_ptrT_lldb_private__MemoryHistory_t, - _swigc__p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t, _swigc__p_std__shared_ptrT_lldb_private__Module_t, _swigc__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t, _swigc__p_std__shared_ptrT_lldb_private__ObjectFile_t, @@ -81376,6 +81977,7 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "eStateDetached",SWIG_From_int(static_cast< int >(lldb::eStateDetached))); SWIG_Python_SetConstant(d, "eStateExited",SWIG_From_int(static_cast< int >(lldb::eStateExited))); SWIG_Python_SetConstant(d, "eStateSuspended",SWIG_From_int(static_cast< int >(lldb::eStateSuspended))); + SWIG_Python_SetConstant(d, "kLastStateType",SWIG_From_int(static_cast< int >(lldb::kLastStateType))); SWIG_Python_SetConstant(d, "eLaunchFlagNone",SWIG_From_int(static_cast< int >(lldb::eLaunchFlagNone))); SWIG_Python_SetConstant(d, "eLaunchFlagExec",SWIG_From_int(static_cast< int >(lldb::eLaunchFlagExec))); SWIG_Python_SetConstant(d, "eLaunchFlagDebug",SWIG_From_int(static_cast< int >(lldb::eLaunchFlagDebug))); @@ -81789,6 +82391,13 @@ SWIG_init(void) { SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugTypes",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugTypes))); SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugNames",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugNames))); SWIG_Python_SetConstant(d, "eSectionTypeOther",SWIG_From_int(static_cast< int >(lldb::eSectionTypeOther))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugLineStr",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugLineStr))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugRngLists",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugRngLists))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugLocLists",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugLocLists))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugAbbrevDwo",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugAbbrevDwo))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugInfoDwo",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugInfoDwo))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugStrDwo",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugStrDwo))); + SWIG_Python_SetConstant(d, "eSectionTypeDWARFDebugStrOffsetsDwo",SWIG_From_int(static_cast< int >(lldb::eSectionTypeDWARFDebugStrOffsetsDwo))); SWIG_Python_SetConstant(d, "eEmulateInstructionOptionNone",SWIG_From_int(static_cast< int >(lldb::eEmulateInstructionOptionNone))); SWIG_Python_SetConstant(d, "eEmulateInstructionOptionAutoAdvancePC",SWIG_From_int(static_cast< int >(lldb::eEmulateInstructionOptionAutoAdvancePC))); SWIG_Python_SetConstant(d, "eEmulateInstructionOptionIgnoreConditions",SWIG_From_int(static_cast< int >(lldb::eEmulateInstructionOptionIgnoreConditions))); diff --git a/scripts/Python/static-binding/lldb.py b/scripts/Python/static-binding/lldb.py index f69c64919bf6..a75dcf0bbb74 100644 --- a/scripts/Python/static-binding/lldb.py +++ b/scripts/Python/static-binding/lldb.py @@ -162,6 +162,7 @@ class _object : pass eStateDetached = _lldb.eStateDetached eStateExited = _lldb.eStateExited eStateSuspended = _lldb.eStateSuspended +kLastStateType = _lldb.kLastStateType eLaunchFlagNone = _lldb.eLaunchFlagNone eLaunchFlagExec = _lldb.eLaunchFlagExec eLaunchFlagDebug = _lldb.eLaunchFlagDebug @@ -575,6 +576,13 @@ class _object : pass eSectionTypeDWARFDebugTypes = _lldb.eSectionTypeDWARFDebugTypes eSectionTypeDWARFDebugNames = _lldb.eSectionTypeDWARFDebugNames eSectionTypeOther = _lldb.eSectionTypeOther +eSectionTypeDWARFDebugLineStr = _lldb.eSectionTypeDWARFDebugLineStr +eSectionTypeDWARFDebugRngLists = _lldb.eSectionTypeDWARFDebugRngLists +eSectionTypeDWARFDebugLocLists = _lldb.eSectionTypeDWARFDebugLocLists +eSectionTypeDWARFDebugAbbrevDwo = _lldb.eSectionTypeDWARFDebugAbbrevDwo +eSectionTypeDWARFDebugInfoDwo = _lldb.eSectionTypeDWARFDebugInfoDwo +eSectionTypeDWARFDebugStrDwo = _lldb.eSectionTypeDWARFDebugStrDwo +eSectionTypeDWARFDebugStrOffsetsDwo = _lldb.eSectionTypeDWARFDebugStrOffsetsDwo eEmulateInstructionOptionNone = _lldb.eEmulateInstructionOptionNone eEmulateInstructionOptionAutoAdvancePC = _lldb.eEmulateInstructionOptionAutoAdvancePC eEmulateInstructionOptionIgnoreConditions = _lldb.eEmulateInstructionOptionIgnoreConditions @@ -2527,6 +2535,14 @@ def HandleCompletion(self, *args): """ return _lldb.SBCommandInterpreter_HandleCompletion(self, *args) + def HandleCompletionWithDescriptions(self, *args): + """ + HandleCompletionWithDescriptions(self, str current_line, uint32_t cursor_pos, int match_start_point, + int max_return_elements, SBStringList matches, + SBStringList descriptions) -> int + """ + return _lldb.SBCommandInterpreter_HandleCompletionWithDescriptions(self, *args) + def IsActive(self): """IsActive(self) -> bool""" return _lldb.SBCommandInterpreter_IsActive(self) @@ -3350,7 +3366,7 @@ def disassemble_instructions (insts): # Create a new debugger instance debugger = lldb.SBDebugger.Create() - # When we step or continue, don't return from the function until the process + # When we step or continue, don't return from the function until the process # stops. We do this by setting the async mode to false. debugger.SetAsync (False) @@ -3368,7 +3384,7 @@ def disassemble_instructions (insts): # Launch the process. Since we specified synchronous mode, we won't return # from this function until we hit the breakpoint at main process = target.LaunchSimple (None, None, os.getcwd()) - + # Make sure the launch went ok if process: # Print some simple process info @@ -3445,9 +3461,12 @@ def disassemble_instructions (insts): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, SBDebugger, name) __repr__ = _swig_repr - def Initialize(): - """Initialize()""" - return _lldb.SBDebugger_Initialize() + def Initialize(*args): + """ + Initialize() + Initialize(SBInitializerOptions options) + """ + return _lldb.SBDebugger_Initialize(*args) if _newclass:Initialize = staticmethod(Initialize) __swig_getmethods__["Initialize"] = lambda x: Initialize @@ -3796,6 +3815,10 @@ def SetPrompt(self, *args): """SetPrompt(self, str prompt)""" return _lldb.SBDebugger_SetPrompt(self, *args) + def GetReproducerPath(self): + """GetReproducerPath(self) -> str""" + return _lldb.SBDebugger_GetReproducerPath(self) + def GetScriptLanguage(self): """GetScriptLanguage(self) -> ScriptLanguage""" return _lldb.SBDebugger_GetScriptLanguage(self) @@ -3874,9 +3897,12 @@ def __str__(self): SBDebugger_swigregister = _lldb.SBDebugger_swigregister SBDebugger_swigregister(SBDebugger) -def SBDebugger_Initialize(): - """SBDebugger_Initialize()""" - return _lldb.SBDebugger_Initialize() +def SBDebugger_Initialize(*args): + """ + Initialize() + SBDebugger_Initialize(SBInitializerOptions options) + """ + return _lldb.SBDebugger_Initialize(*args) def SBDebugger_Terminate(): """SBDebugger_Terminate()""" @@ -5524,6 +5550,38 @@ def SBHostOS_ThreadJoin(*args): """SBHostOS_ThreadJoin(thread_t thread, thread_result_t result, SBError err) -> bool""" return _lldb.SBHostOS_ThreadJoin(*args) +class SBInitializerOptions(_object): + """Proxy of C++ lldb::SBInitializerOptions class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, SBInitializerOptions, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, SBInitializerOptions, name) + __repr__ = _swig_repr + def __init__(self, *args): + """ + __init__(self) -> SBInitializerOptions + __init__(self, SBInitializerOptions rhs) -> SBInitializerOptions + """ + this = _lldb.new_SBInitializerOptions(*args) + try: self.this.append(this) + except: self.this = this + __swig_destroy__ = _lldb.delete_SBInitializerOptions + __del__ = lambda self : None; + def SetCaptureReproducer(self, *args): + """SetCaptureReproducer(self, bool b)""" + return _lldb.SBInitializerOptions_SetCaptureReproducer(self, *args) + + def SetReplayReproducer(self, *args): + """SetReplayReproducer(self, bool b)""" + return _lldb.SBInitializerOptions_SetReplayReproducer(self, *args) + + def SetReproducerPath(self, *args): + """SetReproducerPath(self, str path)""" + return _lldb.SBInitializerOptions_SetReproducerPath(self, *args) + +SBInitializerOptions_swigregister = _lldb.SBInitializerOptions_swigregister +SBInitializerOptions_swigregister(SBInitializerOptions) + class SBInstruction(_object): """Proxy of C++ lldb::SBInstruction class""" __swig_setmethods__ = {} @@ -6221,6 +6279,10 @@ def IsMapped(self): """IsMapped(self) -> bool""" return _lldb.SBMemoryRegionInfo_IsMapped(self) + def GetName(self): + """GetName(self) -> str""" + return _lldb.SBMemoryRegionInfo_GetName(self) + def __eq__(self, *args): """__eq__(self, SBMemoryRegionInfo rhs) -> bool""" return _lldb.SBMemoryRegionInfo___eq__(self, *args) @@ -6653,6 +6715,10 @@ def IsTypeSystemCompatible(self, *args): """IsTypeSystemCompatible(self, LanguageType language) -> SBError""" return _lldb.SBModule_IsTypeSystemCompatible(self, *args) + def GetObjectFileEntryPointAddress(self): + """GetObjectFileEntryPointAddress(self) -> SBAddress""" + return _lldb.SBModule_GetObjectFileEntryPointAddress(self) + def __eq__(self, *args): """__eq__(self, SBModule rhs) -> bool""" return _lldb.SBModule___eq__(self, *args) @@ -9389,6 +9455,14 @@ def GetExecutable(self): """GetExecutable(self) -> SBFileSpec""" return _lldb.SBTarget_GetExecutable(self) + def AppendImageSearchPath(self, *args): + """ + AppendImageSearchPath(self, str _from, str to, SBError error) + + Append the path mapping (from -> to) to the target's paths mapping list. + """ + return _lldb.SBTarget_AppendImageSearchPath(self, *args) + def AddModule(self, *args): """ AddModule(self, SBModule module) -> bool @@ -10553,6 +10627,24 @@ def GetExtendedBacktraceOriginatingIndexID(self): """ return _lldb.SBThread_GetExtendedBacktraceOriginatingIndexID(self) + def GetCurrentException(self): + """ + Returns an SBValue object represeting the current exception for the thread, + if there is any. Currently, this works for Obj-C code and returns an SBValue + representing the NSException object at the throw site or that's currently + being processes. + """ + return _lldb.SBThread_GetCurrentException(self) + + def GetCurrentExceptionBacktrace(self): + """ + Returns a historical (fake) SBThread representing the stack trace of an + exception, if there is one for the thread. Currently, this works for Obj-C + code, and can retrieve the throw-site backtrace of an NSException object + even when the program is no longer at the throw site. + """ + return _lldb.SBThread_GetCurrentExceptionBacktrace(self) + def SafeToCallFunctions(self): """ Takes no arguments, returns a bool. @@ -10778,6 +10870,10 @@ def QueueThreadPlanForRunToAddress(self, *args): """QueueThreadPlanForRunToAddress(self, SBAddress address) -> SBThreadPlan""" return _lldb.SBThreadPlan_QueueThreadPlanForRunToAddress(self, *args) + def QueueThreadPlanForStepScripted(self, *args): + """QueueThreadPlanForStepScripted(self, str script_class_name) -> SBThreadPlan""" + return _lldb.SBThreadPlan_QueueThreadPlanForStepScripted(self, *args) + SBThreadPlan_swigregister = _lldb.SBThreadPlan_swigregister SBThreadPlan_swigregister(SBThreadPlan) @@ -13323,9 +13419,9 @@ def SetIncludeArguments(self, *args): """SetIncludeArguments(self, bool arg0)""" return _lldb.SBVariablesOptions_SetIncludeArguments(self, *args) - def GetIncludeRecognizedArguments(self): - """GetIncludeRecognizedArguments(self) -> bool""" - return _lldb.SBVariablesOptions_GetIncludeRecognizedArguments(self) + def GetIncludeRecognizedArguments(self, *args): + """GetIncludeRecognizedArguments(self, SBTarget arg0) -> bool""" + return _lldb.SBVariablesOptions_GetIncludeRecognizedArguments(self, *args) def SetIncludeRecognizedArguments(self, *args): """SetIncludeRecognizedArguments(self, bool arg0)""" diff --git a/scripts/Xcode/lldbbuild.py b/scripts/Xcode/lldbbuild.py index 318fa2c436f9..2527d9c54973 100644 --- a/scripts/Xcode/lldbbuild.py +++ b/scripts/Xcode/lldbbuild.py @@ -28,8 +28,6 @@ def building_with_ubsan_enabled(): def build_dir_san_suffix(): if building_with_asan_enabled(): return "+asan" - elif building_with_ubsan_enabled(): - return "+ubsan" else: return "" @@ -237,5 +235,4 @@ def library_paths(): def package_build_path(): return os.path.join( llvm_build_dirtree(), - LLVM_BUILD_DIRS()[ - lldb_configuration()]) + LLVM_BUILD_DIRS()[lldb_configuration()]) diff --git a/scripts/Xcode/package-swift-resources.py b/scripts/Xcode/package-swift-resources.py index 5a2e80ce5a73..718034fc061e 100755 --- a/scripts/Xcode/package-swift-resources.py +++ b/scripts/Xcode/package-swift-resources.py @@ -42,6 +42,7 @@ target_dir = sys.argv[1] swift_build_dir = lldbbuild.expected_package_build_path_for("swift") +print("JSMTMP lldbbuild build path for swift: %s" % swift_build_dir) if not os.path.isdir(target_dir): print target_dir + " doesn't exist" @@ -81,6 +82,8 @@ swift_resources = os.path.join(resources, "Swift") +print("JSMTMP swift resources diretctory: %s" % swift_resources) + if os.path.isdir(swift_resources): shutil.rmtree(swift_resources) diff --git a/scripts/Xcode/repos/swift-github-swift-5.1-branch.json b/scripts/Xcode/repos/swift-github-swift-5.1-branch.json new file mode 100644 index 000000000000..47f92f3e8147 --- /dev/null +++ b/scripts/Xcode/repos/swift-github-swift-5.1-branch.json @@ -0,0 +1,29 @@ +{ + "regexs" : [".*github.*apple.*swift-lldb.*swift-5.1-branch.*"], + "repos" : [ + {"name": "llvm", + "vcs": "git", + "url": "https://github.com/apple/swift-llvm.git", + "ref": "swift-5.1-branch"}, + + {"name": "clang", + "vcs": "git", + "url": "https://github.com/apple/swift-clang.git", + "ref": "swift-5.1-branch"}, + + {"name": "swift", + "vcs": "git", + "url": "https://github.com/apple/swift.git", + "ref": "swift-5.1-branch"}, + + {"name": "cmark", + "vcs": "git", + "url": "https://github.com/apple/swift-cmark.git", + "ref": "master"}, + + {"name": "ninja", + "vcs": "git", + "url": "https://github.com/ninja-build/ninja.git", + "ref": "master"} + ] +} diff --git a/scripts/analyze-project-deps.py b/scripts/analyze-project-deps.py index 52a880d3b3c8..b7f6e6803d02 100755 --- a/scripts/analyze-project-deps.py +++ b/scripts/analyze-project-deps.py @@ -90,7 +90,7 @@ def is_existing_cycle(path, cycles): # at the end), then A -> B -> C is also a cycle. This is an important # optimization which reduces the search space by multiple orders of # magnitude. - for i in xrange(0,len(path)): + for i in range(0,len(path)): if any(is_sublist(x, path) for x in cycles): return True path = [path[-1]] + path[0:-1] @@ -129,23 +129,23 @@ def expand(path_queue, path_lengths, cycles, src_map): cycles = [] -path_queue = [[x] for x in src_map.iterkeys()] +path_queue = [[x] for x in iter(src_map)] path_lens = [1] * len(path_queue) -items = list(src_map.iteritems()) -items.sort(lambda A, B : cmp(A[0], B[0])) +items = list(src_map.items()) +items.sort(key = lambda A : A[0]) for (path, deps) in items: - print path + ":" - sorted_deps = list(deps.iteritems()) + print(path + ":") + sorted_deps = list(deps.items()) if args.show_counts: - sorted_deps.sort(lambda A, B: cmp(A[1], B[1])) + sorted_deps.sort(key = lambda A: (A[1], A[0])) for dep in sorted_deps: - print "\t{} [{}]".format(dep[0], dep[1]) + print("\t{} [{}]".format(dep[0], dep[1])) else: - sorted_deps.sort(lambda A, B: cmp(A[0], B[0])) + sorted_deps.sort(key = lambda A: A[0]) for dep in sorted_deps: - print "\t{}".format(dep[0]) + print("\t{}".format(dep[0])) def iter_cycles(cycles): global src_map @@ -161,16 +161,16 @@ def iter_cycles(cycles): yield (total, smallest, result) if args.discover_cycles: - print "Analyzing cycles..." + print("Analyzing cycles...") expand(path_queue, path_lens, cycles, src_map) average = sum([len(x)+1 for x in cycles]) / len(cycles) - print "Found {} cycles. Average cycle length = {}.".format(len(cycles), average) + print("Found {} cycles. Average cycle length = {}.".format(len(cycles), average)) counted = list(iter_cycles(cycles)) if args.show_counts: - counted.sort(lambda A, B: cmp(A[0], B[0])) + counted.sort(key = lambda A: A[0]) for (total, smallest, cycle) in counted: sys.stdout.write("{} deps to break: ".format(total)) sys.stdout.write(cycle[0][0]) @@ -180,9 +180,9 @@ def iter_cycles(cycles): else: for cycle in cycles: cycle.append(cycle[0]) - print " -> ".join(cycle) + print(" -> ".join(cycle)) - print "Analyzing islands..." + print("Analyzing islands...") islands = [] outgoing_counts = defaultdict(int) incoming_counts = defaultdict(int) @@ -195,14 +195,14 @@ def iter_cycles(cycles): disjoints = [x for x in islands if this_cycle.isdisjoint(x)] overlaps = [x for x in islands if not this_cycle.isdisjoint(x)] islands = disjoints + [set.union(this_cycle, *overlaps)] - print "Found {} disjoint cycle islands...".format(len(islands)) + print("Found {} disjoint cycle islands...".format(len(islands))) for island in islands: - print "Island ({} elements)".format(len(island)) + print("Island ({} elements)".format(len(island))) sorted = [] for node in island: sorted.append((node, incoming_counts[node], outgoing_counts[node])) - sorted.sort(lambda x, y: cmp(x[1]+x[2], y[1]+y[2])) + sorted.sort(key = lambda x: x[1]+x[2]) for (node, inc, outg) in sorted: - print " {} [{} in, {} out]".format(node, inc, outg) + print(" {} [{} in, {} out]".format(node, inc, outg)) sys.stdout.flush() pass diff --git a/scripts/check-ast-context.py b/scripts/check-ast-context.py index b721df19b3a4..701313f3f792 100755 --- a/scripts/check-ast-context.py +++ b/scripts/check-ast-context.py @@ -291,6 +291,11 @@ def printtree(node, depth=0): clang.cindex.Cursor.dump = lambda self: printtree(self, depth=0) return True +def compute_libcpp_include_path(): + clang = subprocess.check_output(['xcrun', '-f', 'clang']).strip() + # Remove /bin/clang + base = os.path.dirname(os.path.dirname(clang)) + return os.path.join(base, "include", "c++", "v1") def main(): args = get_args() @@ -322,6 +327,7 @@ def main(): os.path.join(os.path.abspath(args.llvmbuild), 'include'), os.path.join(os.path.abspath(args.llvmbuild), 'tools', 'clang', 'include'), os.path.join(os.path.abspath(args.swiftbuild), 'include'), + compute_libcpp_include_path(), ]] lang = [CPP11()] sdk = [SDKRoot(args.sdk)] diff --git a/scripts/framework-header-fix.sh b/scripts/framework-header-fix.sh index c09d1458ff82..3459dd91c9ec 100755 --- a/scripts/framework-header-fix.sh +++ b/scripts/framework-header-fix.sh @@ -1,13 +1,17 @@ #!/bin/sh # Usage: framework-header-fix.sh + +set -e + for file in `find $1 -name "*.h"` do - sed -i '' 's/\(#include\)[ ]*"lldb\/\(API\/\)\{0,1\}\(.*\)"/\1 /1' "$file" - sed -i '' 's|/1' "$file" + /usr/bin/sed -i.bak 's| to) to the target's paths mapping list. + ") AppendImageSearchPath; + void + AppendImageSearchPath (const char *from, + const char *to, + SBError &error); + bool AddModule (lldb::SBModule &module); diff --git a/scripts/interface/SBThread.i b/scripts/interface/SBThread.i index 6ca17523bd3a..363142b22b2c 100644 --- a/scripts/interface/SBThread.i +++ b/scripts/interface/SBThread.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -420,6 +419,24 @@ public: ") GetExtendedBacktraceOriginatingIndexID; uint32_t GetExtendedBacktraceOriginatingIndexID(); + + %feature("autodoc"," + Returns an SBValue object represeting the current exception for the thread, + if there is any. Currently, this works for Obj-C code and returns an SBValue + representing the NSException object at the throw site or that's currently + being processes. + ") GetCurrentException; + lldb::SBValue + GetCurrentException(); + + %feature("autodoc"," + Returns a historical (fake) SBThread representing the stack trace of an + exception, if there is one for the thread. Currently, this works for Obj-C + code, and can retrieve the throw-site backtrace of an NSException object + even when the program is no longer at the throw site. + ") GetCurrentExceptionBacktrace; + lldb::SBThread + GetCurrentExceptionBacktrace(); %feature("autodoc"," Takes no arguments, returns a bool. diff --git a/scripts/interface/SBThreadCollection.i b/scripts/interface/SBThreadCollection.i index 824f6923acce..bbdf25fbcae9 100644 --- a/scripts/interface/SBThreadCollection.i +++ b/scripts/interface/SBThreadCollection.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBThreadCollection -------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBThreadPlan.i b/scripts/interface/SBThreadPlan.i index 9910314e873b..d70c37ac1664 100644 --- a/scripts/interface/SBThreadPlan.i +++ b/scripts/interface/SBThreadPlan.i @@ -1,9 +1,8 @@ //===-- SBThread.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -106,6 +105,9 @@ public: SBThreadPlan QueueThreadPlanForRunToAddress (SBAddress address); + SBThreadPlan + QueueThreadPlanForStepScripted(const char *script_class_name); + protected: friend class SBBreakpoint; diff --git a/scripts/interface/SBTrace.i b/scripts/interface/SBTrace.i index 799fd717c21d..d72ece30d9f1 100644 --- a/scripts/interface/SBTrace.i +++ b/scripts/interface/SBTrace.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTrace.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTraceOptions.i b/scripts/interface/SBTraceOptions.i index 2fe6590842e3..30cceab3257b 100644 --- a/scripts/interface/SBTraceOptions.i +++ b/scripts/interface/SBTraceOptions.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTraceOptions -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBType.i b/scripts/interface/SBType.i index 999941a4b8f6..fc0afa7a276b 100644 --- a/scripts/interface/SBType.i +++ b/scripts/interface/SBType.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBType -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeCategory.i b/scripts/interface/SBTypeCategory.i index 924c7f6976db..fd4a495327d8 100644 --- a/scripts/interface/SBTypeCategory.i +++ b/scripts/interface/SBTypeCategory.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeEnumMember.i b/scripts/interface/SBTypeEnumMember.i index 02d89f17a28b..0a3b3022a1fe 100644 --- a/scripts/interface/SBTypeEnumMember.i +++ b/scripts/interface/SBTypeEnumMember.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeEnumMember ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeFilter.i b/scripts/interface/SBTypeFilter.i index 083dfa8433af..dd86e5afab00 100644 --- a/scripts/interface/SBTypeFilter.i +++ b/scripts/interface/SBTypeFilter.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeFilter----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeFormat.i b/scripts/interface/SBTypeFormat.i index 4e4b69c3f1fc..85f11cb57271 100644 --- a/scripts/interface/SBTypeFormat.i +++ b/scripts/interface/SBTypeFormat.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeFormat----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeNameSpecifier.i b/scripts/interface/SBTypeNameSpecifier.i index 97d23ca172ef..e226912c5f89 100644 --- a/scripts/interface/SBTypeNameSpecifier.i +++ b/scripts/interface/SBTypeNameSpecifier.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeNameSpecifier---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeSummary.i b/scripts/interface/SBTypeSummary.i index 924256111aee..0db5a14c88f3 100644 --- a/scripts/interface/SBTypeSummary.i +++ b/scripts/interface/SBTypeSummary.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeSummary---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBTypeSynthetic.i b/scripts/interface/SBTypeSynthetic.i index e040cd55c975..86febc668d09 100644 --- a/scripts/interface/SBTypeSynthetic.i +++ b/scripts/interface/SBTypeSynthetic.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBTypeSynthetic-------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBUnixSignals.i b/scripts/interface/SBUnixSignals.i index 2cb45371070b..ccab7614f690 100644 --- a/scripts/interface/SBUnixSignals.i +++ b/scripts/interface/SBUnixSignals.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBUnixSignals ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBValue.i b/scripts/interface/SBValue.i index 6d06c6ab67c9..f62041724e31 100644 --- a/scripts/interface/SBValue.i +++ b/scripts/interface/SBValue.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBValueList.i b/scripts/interface/SBValueList.i index 80e8f0ec999e..fe8f920102e6 100644 --- a/scripts/interface/SBValueList.i +++ b/scripts/interface/SBValueList.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/interface/SBVariablesOptions.i b/scripts/interface/SBVariablesOptions.i index 1d58a4d3b858..1774966103bc 100644 --- a/scripts/interface/SBVariablesOptions.i +++ b/scripts/interface/SBVariablesOptions.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBVariablesOptions ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -28,7 +27,7 @@ public: SetIncludeArguments (bool); bool - GetIncludeRecognizedArguments () const; + GetIncludeRecognizedArguments (const lldb::SBTarget &) const; void SetIncludeRecognizedArguments (bool); diff --git a/scripts/interface/SBWatchpoint.i b/scripts/interface/SBWatchpoint.i index 9a40131f5186..5356c109753e 100644 --- a/scripts/interface/SBWatchpoint.i +++ b/scripts/interface/SBWatchpoint.i @@ -1,9 +1,8 @@ //===-- SWIG Interface for SBWatchpoint -----------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/scripts/lldb.swig b/scripts/lldb.swig index dc987040e768..e8553d075d46 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -41,12 +41,12 @@ Older swig versions will simply ignore this setting. */ %define MODULEIMPORT "try: - # Try a relative import first - from . import $module + # Try an absolute import first. If we're being loaded from lldb, + # _lldb should be a built-in module. + import $module except ImportError: - # Maybe absolute import will work (if we're being loaded from lldb, it - # should). - import $module" + # Relative import should work if we are being loaded by Python. + from . import $module" %enddef // These versions will not generate working python modules, so error out early. #if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011 @@ -187,6 +187,7 @@ import six %include "./interface/SBFrame.i" %include "./interface/SBFunction.i" %include "./interface/SBHostOS.i" +%include "./interface/SBInitializerOptions.i" %include "./interface/SBInstruction.i" %include "./interface/SBInstructionList.i" %include "./interface/SBLanguageRuntime.i" diff --git a/scripts/prepare_bindings.py b/scripts/prepare_bindings.py index 29ca7df790f8..ba75b95b3821 100755 --- a/scripts/prepare_bindings.py +++ b/scripts/prepare_bindings.py @@ -1,9 +1,8 @@ #!/usr/bin/env python """ - The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. +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 Prepares language bindings for LLDB build process. Run with --help to see a description of the supported command line arguments. diff --git a/scripts/utilsOsType.py b/scripts/utilsOsType.py index 5595541e1a19..dfc5cec340d4 100644 --- a/scripts/utilsOsType.py +++ b/scripts/utilsOsType.py @@ -35,8 +35,9 @@ class EnumOsType(Enum): FreeBSD = 2 Linux = 3 NetBSD = 4 - Windows = 5 - kFreeBSD = 6 + OpenBSD = 5 + Windows = 6 + kFreeBSD = 7 else: class EnumOsType(object): values = ["Unknown", diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt index aea6646e9d12..17aba97e711c 100644 --- a/source/API/CMakeLists.txt +++ b/source/API/CMakeLists.txt @@ -9,6 +9,11 @@ endif() get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) +if(NOT LLDB_DISABLE_PYTHON) + get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR) + set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp) +endif() + add_lldb_library(liblldb SHARED SBAddress.cpp SBAttachInfo.cpp @@ -34,6 +39,7 @@ add_lldb_library(liblldb SHARED SBFrame.cpp SBFunction.cpp SBHostOS.cpp + SBInitializerOptions.cpp SBInstruction.cpp SBInstructionList.cpp SBLanguageRuntime.cpp @@ -77,7 +83,7 @@ add_lldb_library(liblldb SHARED SBWatchpoint.cpp SBUnixSignals.cpp SystemInitializerFull.cpp - ${LLDB_WRAP_PYTHON} + ${lldb_python_wrapper} LINK_LIBS lldbBase @@ -97,24 +103,26 @@ add_lldb_library(liblldb SHARED Support ) -add_dependencies(lldb-suite liblldb) +if(lldb_python_wrapper) + add_dependencies(liblldb swig_wrapper) -if (MSVC) - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") -else() - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") -endif() + if (MSVC) + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") + else() + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") + endif() -set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) -if (CLANG_CL) - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING - PROPERTY COMPILE_FLAGS " -Wno-unused-function") + set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON) + if (CLANG_CL) + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING + PROPERTY COMPILE_FLAGS " -Wno-unused-function") + endif() + if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND + NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING + PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual") + endif () endif() -if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND - NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING - PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual") -endif () set_target_properties(liblldb PROPERTIES @@ -149,19 +157,8 @@ else() ) endif() -if (LLDB_BUILD_FRAMEWORK) - set_target_properties(liblldb - PROPERTIES - OUTPUT_NAME LLDB - FRAMEWORK On - FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} - MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist - LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_DIR} - ) -endif() - -if (LLDB_WRAP_PYTHON) - add_dependencies(liblldb swig_wrapper) +if(LLDB_BUILD_FRAMEWORK) + include(LLDBFramework) endif() set(lib_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}") diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp index d12197e66ddd..0cad2b7fddf2 100644 --- a/source/API/SBAddress.cpp +++ b/source/API/SBAddress.cpp @@ -1,9 +1,8 @@ //===-- SBAddress.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -62,7 +61,7 @@ bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { } bool SBAddress::IsValid() const { - return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); + return m_opaque_ap != NULL && m_opaque_ap->IsValid(); } void SBAddress::Clear() { m_opaque_ap.reset(new Address()); } @@ -156,7 +155,7 @@ Address *SBAddress::operator->() { return m_opaque_ap.get(); } const Address *SBAddress::operator->() const { return m_opaque_ap.get(); } Address &SBAddress::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new Address()); return *m_opaque_ap; } @@ -198,8 +197,9 @@ SBModule SBAddress::GetModule() { SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) { SBSymbolContext sb_sc; + SymbolContextItem scope = static_cast(resolve_scope); if (m_opaque_ap->IsValid()) - m_opaque_ap->CalculateSymbolContext(&sb_sc.ref(), resolve_scope); + m_opaque_ap->CalculateSymbolContext(&sb_sc.ref(), scope); return sb_sc; } diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp index d6cb212dedf8..12f63b858a63 100644 --- a/source/API/SBAttachInfo.cpp +++ b/source/API/SBAttachInfo.cpp @@ -1,9 +1,8 @@ //===-- SBAttachInfo.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,16 +25,14 @@ SBAttachInfo::SBAttachInfo(lldb::pid_t pid) SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) : m_opaque_sp(new ProcessAttachInfo()) { if (path && path[0]) - m_opaque_sp->GetExecutableFile().SetFile(path, false, - FileSpec::Style::native); + m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); m_opaque_sp->SetWaitForLaunch(wait_for); } SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) : m_opaque_sp(new ProcessAttachInfo()) { if (path && path[0]) - m_opaque_sp->GetExecutableFile().SetFile(path, false, - FileSpec::Style::native); + m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); m_opaque_sp->SetWaitForLaunch(wait_for); m_opaque_sp->SetAsync(async); } @@ -79,8 +76,7 @@ void SBAttachInfo::SetProcessPluginName(const char *plugin_name) { void SBAttachInfo::SetExecutable(const char *path) { if (path && path[0]) - m_opaque_sp->GetExecutableFile().SetFile(path, false, - FileSpec::Style::native); + m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); else m_opaque_sp->GetExecutableFile().Clear(); } diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp index cd453872201a..4f131cd2429c 100644 --- a/source/API/SBBlock.cpp +++ b/source/API/SBBlock.cpp @@ -1,9 +1,8 @@ //===-- SBBlock.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index fd039b557801..9b040f36349f 100644 --- a/source/API/SBBreakpoint.cpp +++ b/source/API/SBBreakpoint.cpp @@ -1,16 +1,11 @@ //===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" diff --git a/source/API/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp index 99ac0277e700..a11f0d22a985 100644 --- a/source/API/SBBreakpointLocation.cpp +++ b/source/API/SBBreakpointLocation.cpp @@ -1,9 +1,8 @@ //===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBBreakpointName.cpp b/source/API/SBBreakpointName.cpp index a6742e3b89ec..f02732e2a87c 100644 --- a/source/API/SBBreakpointName.cpp +++ b/source/API/SBBreakpointName.cpp @@ -1,16 +1,11 @@ //===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBBreakpointName.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" @@ -168,11 +163,11 @@ const SBBreakpointName &SBBreakpointName::operator=(const SBBreakpointName &rhs) } bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) { - return *m_impl_up.get() == *rhs.m_impl_up.get(); + return *m_impl_up == *rhs.m_impl_up; } bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) { - return *m_impl_up.get() != *rhs.m_impl_up.get(); + return *m_impl_up != *rhs.m_impl_up; } bool SBBreakpointName::IsValid() const { diff --git a/source/API/SBBreakpointOptionCommon.cpp b/source/API/SBBreakpointOptionCommon.cpp index 569b860a4235..e491106ca426 100644 --- a/source/API/SBBreakpointOptionCommon.cpp +++ b/source/API/SBBreakpointOptionCommon.cpp @@ -1,16 +1,11 @@ //===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBBreakpointName.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" diff --git a/source/API/SBBreakpointOptionCommon.h b/source/API/SBBreakpointOptionCommon.h index fe276ac636fe..b030cc0221b7 100644 --- a/source/API/SBBreakpointOptionCommon.h +++ b/source/API/SBBreakpointOptionCommon.h @@ -1,9 +1,8 @@ //===-- SBBreakpointOptionCommon.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBBroadcaster.cpp b/source/API/SBBroadcaster.cpp index 278576b5ddcd..2252e4026719 100644 --- a/source/API/SBBroadcaster.cpp +++ b/source/API/SBBroadcaster.cpp @@ -1,13 +1,12 @@ //===-- SBBroadcaster.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/Broadcaster.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Log.h" #include "lldb/API/SBBroadcaster.h" diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp index 4389968bf445..e3332a82498b 100644 --- a/source/API/SBCommandInterpreter.cpp +++ b/source/API/SBCommandInterpreter.cpp @@ -1,23 +1,18 @@ //===-- SBCommandInterpreter.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-types.h" -#include "lldb/Core/Listener.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Listener.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" @@ -102,7 +97,7 @@ SBCommandInterpreterRunOptions::get() const { lldb_private::CommandInterpreterRunOptions & SBCommandInterpreterRunOptions::ref() const { - return *m_opaque_up.get(); + return *m_opaque_up; } class CommandPluginInterfaceImplementation : public CommandObjectParsed { @@ -277,6 +272,16 @@ void SBCommandInterpreter::HandleCommandsFromFile( int SBCommandInterpreter::HandleCompletion( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, SBStringList &matches) { + SBStringList dummy_descriptions; + return HandleCompletionWithDescriptions( + current_line, cursor, last_char, match_start_point, max_return_elements, + matches, dummy_descriptions); +} + +int SBCommandInterpreter::HandleCompletionWithDescriptions( + const char *current_line, const char *cursor, const char *last_char, + int match_start_point, int max_return_elements, SBStringList &matches, + SBStringList &descriptions) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int num_completions = 0; @@ -304,13 +309,15 @@ int SBCommandInterpreter::HandleCompletion( match_start_point, max_return_elements); if (IsValid()) { - lldb_private::StringList lldb_matches; + lldb_private::StringList lldb_matches, lldb_descriptions; num_completions = m_opaque_ptr->HandleCompletion( current_line, cursor, last_char, match_start_point, max_return_elements, - lldb_matches); + lldb_matches, lldb_descriptions); - SBStringList temp_list(&lldb_matches); - matches.AppendList(temp_list); + SBStringList temp_matches_list(&lldb_matches); + matches.AppendList(temp_matches_list); + SBStringList temp_descriptions_list(&lldb_descriptions); + descriptions.AppendList(temp_descriptions_list); } if (log) log->Printf( @@ -320,6 +327,17 @@ int SBCommandInterpreter::HandleCompletion( return num_completions; } +int SBCommandInterpreter::HandleCompletionWithDescriptions( + const char *current_line, uint32_t cursor_pos, int match_start_point, + int max_return_elements, SBStringList &matches, + SBStringList &descriptions) { + const char *cursor = current_line + cursor_pos; + const char *last_char = current_line + strlen(current_line); + return HandleCompletionWithDescriptions( + current_line, cursor, last_char, match_start_point, max_return_elements, + matches, descriptions); +} + int SBCommandInterpreter::HandleCompletion(const char *current_line, uint32_t cursor_pos, int match_start_point, diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp index 5a8909b98e53..6d7fae12e0ea 100644 --- a/source/API/SBCommandReturnObject.cpp +++ b/source/API/SBCommandReturnObject.cpp @@ -1,16 +1,11 @@ //===-- SBCommandReturnObject.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" @@ -52,9 +47,7 @@ operator=(const SBCommandReturnObject &rhs) { return *this; } -bool SBCommandReturnObject::IsValid() const { - return m_opaque_ap.get() != nullptr; -} +bool SBCommandReturnObject::IsValid() const { return m_opaque_ap != nullptr; } const char *SBCommandReturnObject::GetOutput() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); diff --git a/source/API/SBCommunication.cpp b/source/API/SBCommunication.cpp index 63b672efe3c0..2fc217432c0f 100644 --- a/source/API/SBCommunication.cpp +++ b/source/API/SBCommunication.cpp @@ -1,9 +1,8 @@ //===-- SBCommunication.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp index 149d587913e9..17623af09c4e 100644 --- a/source/API/SBCompileUnit.cpp +++ b/source/API/SBCompileUnit.cpp @@ -1,9 +1,8 @@ //===-- SBCompileUnit.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -135,17 +134,21 @@ uint32_t SBCompileUnit::GetNumSupportFiles() const { lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) { SBTypeList sb_type_list; - if (m_opaque_ptr) { - ModuleSP module_sp(m_opaque_ptr->GetModule()); - if (module_sp) { - SymbolVendor *vendor = module_sp->GetSymbolVendor(); - if (vendor) { - TypeList type_list; - vendor->GetTypes(m_opaque_ptr, type_mask, type_list); - sb_type_list.m_opaque_ap->Append(type_list); - } - } - } + if (!m_opaque_ptr) + return sb_type_list; + + ModuleSP module_sp(m_opaque_ptr->GetModule()); + if (!module_sp) + return sb_type_list; + + SymbolVendor *vendor = module_sp->GetSymbolVendor(); + if (!vendor) + return sb_type_list; + + TypeClass type_class = static_cast(type_mask); + TypeList type_list; + vendor->GetTypes(m_opaque_ptr, type_class, type_list); + sb_type_list.m_opaque_ap->Append(type_list); return sb_type_list; } diff --git a/source/API/SBData.cpp b/source/API/SBData.cpp index a8ba5808d4f6..d808ff22f918 100644 --- a/source/API/SBData.cpp +++ b/source/API/SBData.cpp @@ -1,13 +1,12 @@ //===-- SBData.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include // PRIu64 +#include #include "lldb/API/SBData.h" #include "lldb/API/SBError.h" diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp index 713c613d6774..92ca723a92d0 100644 --- a/source/API/SBDebugger.cpp +++ b/source/API/SBDebugger.cpp @@ -1,16 +1,11 @@ //===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "SystemInitializerFull.h" @@ -41,7 +36,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -53,6 +47,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" @@ -90,7 +85,7 @@ static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, "lldb::PluginInitialize(lldb::SBDebugger)"); } } else { - if (spec.Exists()) + if (FileSystem::Instance().Exists(spec)) error.SetErrorString("this file does not represent a loadable dylib"); else error.SetErrorString("no such file"); @@ -129,13 +124,23 @@ SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { } void SBDebugger::Initialize() { + SBInitializerOptions options; + SBDebugger::Initialize(options); +} + +lldb::SBError SBDebugger::Initialize(SBInitializerOptions &options) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) log->Printf("SBDebugger::Initialize ()"); - g_debugger_lifetime->Initialize(llvm::make_unique(), - LoadPlugin); + SBError error; + if (auto e = g_debugger_lifetime->Initialize( + llvm::make_unique(), *options.m_opaque_up, + LoadPlugin)) { + error.SetError(Status(std::move(e))); + } + return error; } void SBDebugger::Terminate() { g_debugger_lifetime->Terminate(); } @@ -735,7 +740,7 @@ SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name); TargetSP target_sp( m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture( - FileSpec(filename, false), arch_name ? &arch : nullptr)); + FileSpec(filename), arch_name ? &arch : nullptr)); sb_target.SetSP(target_sp); } return sb_target; @@ -1055,6 +1060,12 @@ void SBDebugger::SetPrompt(const char *prompt) { m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); } +const char *SBDebugger::GetReproducerPath() const { + return (m_opaque_sp + ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString() + : nullptr); +} + ScriptLanguage SBDebugger::GetScriptLanguage() const { return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); } diff --git a/source/API/SBDeclaration.cpp b/source/API/SBDeclaration.cpp index d6e61e32582d..a943c2cd8bba 100644 --- a/source/API/SBDeclaration.cpp +++ b/source/API/SBDeclaration.cpp @@ -1,9 +1,8 @@ //===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -75,7 +74,7 @@ uint32_t SBDeclaration::GetLine() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t line = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) line = m_opaque_ap->GetLine(); if (log) @@ -86,7 +85,7 @@ uint32_t SBDeclaration::GetLine() const { } uint32_t SBDeclaration::GetColumn() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetColumn(); return 0; } @@ -126,7 +125,7 @@ const lldb_private::Declaration *SBDeclaration::operator->() const { } lldb_private::Declaration &SBDeclaration::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new lldb_private::Declaration()); return *m_opaque_ap; } @@ -138,7 +137,7 @@ const lldb_private::Declaration &SBDeclaration::ref() const { bool SBDeclaration::GetDescription(SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { char file_path[PATH_MAX * 2]; m_opaque_ap->GetFile().GetPath(file_path, sizeof(file_path)); strm.Printf("%s:%u", file_path, GetLine()); diff --git a/source/API/SBError.cpp b/source/API/SBError.cpp index b2811d0ac381..5220ac4d30b3 100644 --- a/source/API/SBError.cpp +++ b/source/API/SBError.cpp @@ -1,9 +1,8 @@ //===-- SBError.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -28,7 +27,7 @@ SBError::~SBError() {} const SBError &SBError::operator=(const SBError &rhs) { if (rhs.IsValid()) { - if (m_opaque_ap.get()) + if (m_opaque_ap) *m_opaque_ap = *rhs; else m_opaque_ap.reset(new Status(*rhs)); @@ -39,13 +38,13 @@ const SBError &SBError::operator=(const SBError &rhs) { } const char *SBError::GetCString() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->AsCString(); return NULL; } void SBError::Clear() { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(); } @@ -53,7 +52,7 @@ bool SBError::Fail() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); bool ret_value = false; - if (m_opaque_ap.get()) + if (m_opaque_ap) ret_value = m_opaque_ap->Fail(); if (log) @@ -66,7 +65,7 @@ bool SBError::Fail() const { bool SBError::Success() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); bool ret_value = true; - if (m_opaque_ap.get()) + if (m_opaque_ap) ret_value = m_opaque_ap->Success(); if (log) @@ -80,7 +79,7 @@ uint32_t SBError::GetError() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t err = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) err = m_opaque_ap->GetError(); if (log) @@ -93,7 +92,7 @@ uint32_t SBError::GetError() const { ErrorType SBError::GetType() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ErrorType err_type = eErrorTypeInvalid; - if (m_opaque_ap.get()) + if (m_opaque_ap) err_type = m_opaque_ap->GetType(); if (log) @@ -137,10 +136,10 @@ int SBError::SetErrorStringWithFormat(const char *format, ...) { return num_chars; } -bool SBError::IsValid() const { return m_opaque_ap.get() != NULL; } +bool SBError::IsValid() const { return m_opaque_ap != NULL; } void SBError::CreateIfNeeded() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new Status()); } @@ -159,7 +158,7 @@ const lldb_private::Status &SBError::operator*() const { } bool SBError::GetDescription(SBStream &description) { - if (m_opaque_ap.get()) { + if (m_opaque_ap) { if (m_opaque_ap->Success()) description.Printf("success"); else { diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp index 65eb71c09285..2ea6c91523fb 100644 --- a/source/API/SBEvent.cpp +++ b/source/API/SBEvent.cpp @@ -1,9 +1,8 @@ //===-- SBEvent.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,11 +11,11 @@ #include "lldb/API/SBStream.h" #include "lldb/Breakpoint/Breakpoint.h" -#include "lldb/Core/Event.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Stream.h" using namespace lldb; diff --git a/source/API/SBExecutionContext.cpp b/source/API/SBExecutionContext.cpp index 74a543c77d2d..e2e04081a256 100644 --- a/source/API/SBExecutionContext.cpp +++ b/source/API/SBExecutionContext.cpp @@ -1,10 +1,9 @@ //===-- SBExecutionContext.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBExpressionOptions.cpp b/source/API/SBExpressionOptions.cpp index a9669cb1908d..e19b2d748eeb 100644 --- a/source/API/SBExpressionOptions.cpp +++ b/source/API/SBExpressionOptions.cpp @@ -1,10 +1,9 @@ //===-- SBExpressionOptions.cpp ---------------------------------------------*- //C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp index 011b88225ef9..6ce105d42640 100644 --- a/source/API/SBFileSpec.cpp +++ b/source/API/SBFileSpec.cpp @@ -1,17 +1,17 @@ //===-- SBFileSpec.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include // PRIu64 +#include #include #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/PosixApi.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" @@ -31,11 +31,15 @@ SBFileSpec::SBFileSpec(const lldb_private::FileSpec &fspec) : m_opaque_ap(new lldb_private::FileSpec(fspec)) {} // Deprecated!!! -SBFileSpec::SBFileSpec(const char *path) - : m_opaque_ap(new FileSpec(path, true)) {} +SBFileSpec::SBFileSpec(const char *path) : m_opaque_ap(new FileSpec(path)) { + FileSystem::Instance().Resolve(*m_opaque_ap); +} SBFileSpec::SBFileSpec(const char *path, bool resolve) - : m_opaque_ap(new FileSpec(path, resolve)) {} + : m_opaque_ap(new FileSpec(path)) { + if (resolve) + FileSystem::Instance().Resolve(*m_opaque_ap); +} SBFileSpec::~SBFileSpec() {} @@ -50,7 +54,7 @@ bool SBFileSpec::IsValid() const { return m_opaque_ap->operator bool(); } bool SBFileSpec::Exists() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - bool result = m_opaque_ap->Exists(); + bool result = FileSystem::Instance().Exists(*m_opaque_ap); if (log) log->Printf("SBFileSpec(%p)::Exists () => %s", @@ -61,13 +65,13 @@ bool SBFileSpec::Exists() const { } bool SBFileSpec::ResolveExecutableLocation() { - return m_opaque_ap->ResolveExecutableLocation(); + return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_ap); } int SBFileSpec::ResolvePath(const char *src_path, char *dst_path, size_t dst_len) { llvm::SmallString<64> result(src_path); - lldb_private::FileSpec::Resolve(result); + FileSystem::Instance().Resolve(result); ::snprintf(dst_path, dst_len, "%s", result.c_str()); return std::min(dst_len - 1, result.size()); } @@ -143,12 +147,10 @@ const lldb_private::FileSpec *SBFileSpec::get() const { } const lldb_private::FileSpec &SBFileSpec::operator*() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } -const lldb_private::FileSpec &SBFileSpec::ref() const { - return *m_opaque_ap.get(); -} +const lldb_private::FileSpec &SBFileSpec::ref() const { return *m_opaque_ap; } void SBFileSpec::SetFileSpec(const lldb_private::FileSpec &fs) { *m_opaque_ap = fs; diff --git a/source/API/SBFileSpecList.cpp b/source/API/SBFileSpecList.cpp index 67d28dcbe111..4717f888335e 100644 --- a/source/API/SBFileSpecList.cpp +++ b/source/API/SBFileSpecList.cpp @@ -1,9 +1,8 @@ //===-- SBFileSpecList.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,7 +25,7 @@ SBFileSpecList::SBFileSpecList() : m_opaque_ap(new FileSpecList()) {} SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_ap() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (rhs.m_opaque_ap.get()) + if (rhs.m_opaque_ap) m_opaque_ap.reset(new FileSpecList(*(rhs.get()))); if (log) { @@ -78,17 +77,17 @@ const lldb_private::FileSpecList *SBFileSpecList::get() const { } const lldb_private::FileSpecList &SBFileSpecList::operator*() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } const lldb_private::FileSpecList &SBFileSpecList::ref() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } bool SBFileSpecList::GetDescription(SBStream &description) const { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { uint32_t num_files = m_opaque_ap->GetSize(); strm.Printf("%d files: ", num_files); for (uint32_t i = 0; i < num_files; i++) { diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp index 39e8a744de6f..0e4434e2e099 100644 --- a/source/API/SBFrame.cpp +++ b/source/API/SBFrame.cpp @@ -1,20 +1,15 @@ //===-- SBFrame.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/API/SBFrame.h" #include "lldb/lldb-types.h" @@ -114,7 +109,7 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { SBSymbolContext sb_sym_ctx; std::unique_lock lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - + SymbolContextItem scope = static_cast(resolve_scope); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -123,7 +118,7 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); if (frame) { - sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(resolve_scope)); + sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(scope)); } else { if (log) log->Printf("SBFrame::GetVariables () => error: could not " @@ -962,7 +957,8 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { const bool statics = options.GetIncludeStatics(); const bool arguments = options.GetIncludeArguments(); - const bool recognized_arguments = options.GetIncludeRecognizedArguments(); + const bool recognized_arguments = + options.GetIncludeRecognizedArguments(SBTarget(exe_ctx.GetTargetSP())); const bool locals = options.GetIncludeLocals(); const bool in_scope_only = options.GetInScopeOnly(); const bool include_runtime_support_values = diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp index 5aa3f90a3ca2..aed2cca224fb 100644 --- a/source/API/SBFunction.cpp +++ b/source/API/SBFunction.cpp @@ -1,9 +1,8 @@ //===-- SBFunction.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp index e56951df43be..3ab43bca08e2 100644 --- a/source/API/SBHostOS.cpp +++ b/source/API/SBHostOS.cpp @@ -1,9 +1,8 @@ //===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,8 +10,9 @@ #include "Plugins/ScriptInterpreter/Python/lldb-python.h" #endif -#include "lldb/API/SBHostOS.h" #include "lldb/API/SBError.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThread.h" @@ -74,6 +74,10 @@ SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { case ePathTypeClangDir: fspec = GetClangResourceDir(); break; + + case ePathTypeSupportFileDir: + case ePathTypeSwiftDir: + break; } SBFileSpec sb_fspec; @@ -86,7 +90,8 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() { llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec homedir(home_dir_path.c_str(), true); + FileSpec homedir(home_dir_path.c_str()); + FileSystem::Instance().Resolve(homedir); sb_fspec.SetFileSpec(homedir); return sb_fspec; diff --git a/source/API/SBInitializerOptions.cpp b/source/API/SBInitializerOptions.cpp new file mode 100644 index 000000000000..654e72c4a447 --- /dev/null +++ b/source/API/SBInitializerOptions.cpp @@ -0,0 +1,48 @@ +//===-- SBInitializerOptions.cpp --------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBInitializerOptions.h" +#include "lldb/Initialization/SystemInitializer.h" + +using namespace lldb; +using namespace lldb_private; + +SBInitializerOptions::SBInitializerOptions(const SBInitializerOptions &rhs) { + m_opaque_up.reset(new InitializerOptions()); + *(m_opaque_up.get()) = rhs.ref(); +} + +const SBInitializerOptions &SBInitializerOptions:: +operator=(const SBInitializerOptions &rhs) { + if (this != &rhs) { + this->ref() = rhs.ref(); + } + return *this; +} + +SBInitializerOptions::~SBInitializerOptions() {} + +SBInitializerOptions::SBInitializerOptions() { + m_opaque_up.reset(new InitializerOptions()); +} + +void SBInitializerOptions::SetCaptureReproducer(bool b) { + m_opaque_up->reproducer_capture = b; +} + +void SBInitializerOptions::SetReplayReproducer(bool b) { + m_opaque_up->reproducer_replay = b; +} + +void SBInitializerOptions::SetReproducerPath(const char *path) { + m_opaque_up->reproducer_path = path; +} + +InitializerOptions &SBInitializerOptions::ref() const { + return *(m_opaque_up.get()); +} diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp index 462f08288092..5b3c0aac2ff5 100644 --- a/source/API/SBInstruction.cpp +++ b/source/API/SBInstruction.cpp @@ -1,9 +1,8 @@ //===-- SBInstruction.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBInstructionList.cpp b/source/API/SBInstructionList.cpp index 29e0c96075fd..5f66625b5e00 100644 --- a/source/API/SBInstructionList.cpp +++ b/source/API/SBInstructionList.cpp @@ -1,9 +1,8 @@ //===-- SBInstructionList.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBLanguageRuntime.cpp b/source/API/SBLanguageRuntime.cpp index d3b7514346aa..64149ee85d44 100644 --- a/source/API/SBLanguageRuntime.cpp +++ b/source/API/SBLanguageRuntime.cpp @@ -1,9 +1,8 @@ //===-- SBLanguageRuntime.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBLaunchInfo.cpp b/source/API/SBLaunchInfo.cpp index aa1759ab3d00..1063f55598c6 100644 --- a/source/API/SBLaunchInfo.cpp +++ b/source/API/SBLaunchInfo.cpp @@ -1,9 +1,8 @@ //===-- SBLaunchInfo.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -128,7 +127,7 @@ const char *SBLaunchInfo::GetWorkingDirectory() const { } void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) { - m_opaque_sp->SetWorkingDirectory(FileSpec{working_dir, false}); + m_opaque_sp->SetWorkingDirectory(FileSpec(working_dir)); } uint32_t SBLaunchInfo::GetLaunchFlags() { @@ -155,7 +154,7 @@ const char *SBLaunchInfo::GetShell() { } void SBLaunchInfo::SetShell(const char *path) { - m_opaque_sp->SetShell(FileSpec(path, false)); + m_opaque_sp->SetShell(FileSpec(path)); } bool SBLaunchInfo::GetShellExpandArguments() { @@ -184,8 +183,7 @@ bool SBLaunchInfo::AddDuplicateFileAction(int fd, int dup_fd) { bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read, bool write) { - return m_opaque_sp->AppendOpenFileAction(fd, FileSpec{path, false}, read, - write); + return m_opaque_sp->AppendOpenFileAction(fd, FileSpec(path), read, write); } bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) { diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp index 7341d3603dfe..66cc9cc6ee11 100644 --- a/source/API/SBLineEntry.cpp +++ b/source/API/SBLineEntry.cpp @@ -1,9 +1,8 @@ //===-- SBLineEntry.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -50,7 +49,7 @@ SBLineEntry::~SBLineEntry() {} SBAddress SBLineEntry::GetStartAddress() const { SBAddress sb_address; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -70,7 +69,7 @@ SBAddress SBLineEntry::GetStartAddress() const { SBAddress SBLineEntry::GetEndAddress() const { SBAddress sb_address; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize()); } @@ -114,7 +113,7 @@ uint32_t SBLineEntry::GetLine() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t line = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) line = m_opaque_ap->line; if (log) @@ -125,7 +124,7 @@ uint32_t SBLineEntry::GetLine() const { } uint32_t SBLineEntry::GetColumn() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->column; return 0; } @@ -165,7 +164,7 @@ const lldb_private::LineEntry *SBLineEntry::operator->() const { } lldb_private::LineEntry &SBLineEntry::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new lldb_private::LineEntry()); return *m_opaque_ap; } @@ -175,7 +174,7 @@ const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_ap; } bool SBLineEntry::GetDescription(SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { char file_path[PATH_MAX * 2]; m_opaque_ap->file.GetPath(file_path, sizeof(file_path)); strm.Printf("%s:%u", file_path, GetLine()); diff --git a/source/API/SBListener.cpp b/source/API/SBListener.cpp index 50fed4e1ee7b..cde879dbeadd 100644 --- a/source/API/SBListener.cpp +++ b/source/API/SBListener.cpp @@ -1,9 +1,8 @@ //===-- SBListener.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,9 +11,9 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Listener.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Listener.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" diff --git a/source/API/SBMemoryRegionInfo.cpp b/source/API/SBMemoryRegionInfo.cpp index c4dbaec707bb..26778d973bb7 100644 --- a/source/API/SBMemoryRegionInfo.cpp +++ b/source/API/SBMemoryRegionInfo.cpp @@ -1,9 +1,8 @@ //===-- SBMemoryRegionInfo.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBMemoryRegionInfoList.cpp b/source/API/SBMemoryRegionInfoList.cpp index fff4044f73e0..290804a9cd6f 100644 --- a/source/API/SBMemoryRegionInfoList.cpp +++ b/source/API/SBMemoryRegionInfoList.cpp @@ -1,9 +1,8 @@ //===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -32,31 +31,47 @@ class MemoryRegionInfoListImpl { return *this; } - uint32_t GetSize() { return m_regions.size(); } + size_t GetSize() const { return m_regions.size(); } + + void Reserve(size_t capacity) { return m_regions.reserve(capacity); } - void Append(const lldb::SBMemoryRegionInfo &sb_region) { + void Append(const MemoryRegionInfo &sb_region) { m_regions.push_back(sb_region); } void Append(const MemoryRegionInfoListImpl &list) { - for (auto val : list.m_regions) + Reserve(GetSize() + list.GetSize()); + + for (const auto &val : list.m_regions) Append(val); } void Clear() { m_regions.clear(); } - bool GetMemoryRegionInfoAtIndex(uint32_t index, - SBMemoryRegionInfo ®ion_info) { + bool GetMemoryRegionInfoAtIndex(size_t index, + MemoryRegionInfo ®ion_info) { if (index >= GetSize()) return false; region_info = m_regions[index]; return true; } + MemoryRegionInfos &Ref() { return m_regions; } + + const MemoryRegionInfos &Ref() const { return m_regions; } + private: - std::vector m_regions; + MemoryRegionInfos m_regions; }; +MemoryRegionInfos &SBMemoryRegionInfoList::ref() { + return m_opaque_ap->Ref(); +} + +const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const { + return m_opaque_ap->Ref(); +} + SBMemoryRegionInfoList::SBMemoryRegionInfoList() : m_opaque_ap(new MemoryRegionInfoListImpl()) {} @@ -82,7 +97,7 @@ bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex( uint32_t idx, SBMemoryRegionInfo ®ion_info) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info); + bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info.ref()); if (log) { SBStream sstr; @@ -100,7 +115,7 @@ bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex( void SBMemoryRegionInfoList::Clear() { m_opaque_ap->Clear(); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) { - m_opaque_ap->Append(sb_region); + m_opaque_ap->Append(sb_region.ref()); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) { @@ -113,5 +128,5 @@ const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const { const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const { assert(m_opaque_ap.get()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp index 23323d56ae9a..cf01b878a705 100644 --- a/source/API/SBModule.cpp +++ b/source/API/SBModule.cpp @@ -1,9 +1,8 @@ //===-- SBModule.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -218,9 +217,9 @@ SBModule::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { SBSymbolContext sb_sc; ModuleSP module_sp(GetSP()); + SymbolContextItem scope = static_cast(resolve_scope); if (module_sp && addr.IsValid()) - module_sp->ResolveSymbolContextForAddress(addr.ref(), resolve_scope, - *sb_sc); + module_sp->ResolveSymbolContextForAddress(addr.ref(), scope, *sb_sc); return sb_sc; } @@ -366,8 +365,9 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, const bool append = true; const bool symbols_ok = true; const bool inlines_ok = true; - module_sp->FindFunctions(ConstString(name), NULL, name_type_mask, - symbols_ok, inlines_ok, append, *sb_sc_list); + FunctionNameType type = static_cast(name_type_mask); + module_sp->FindFunctions(ConstString(name), NULL, type, symbols_ok, + inlines_ok, append, *sb_sc_list); } return sb_sc_list; } @@ -440,13 +440,12 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) { ModuleSP module_sp(GetSP()); if (type && module_sp) { - SymbolContext sc; TypeList type_list; const bool exact_match = false; ConstString name(type); llvm::DenseSet searched_symbol_files; const uint32_t num_matches = module_sp->FindTypes( - sc, name, exact_match, UINT32_MAX, searched_symbol_files, type_list); + name, exact_match, UINT32_MAX, searched_symbol_files, type_list); if (num_matches > 0) { for (size_t idx = 0; idx < num_matches; idx++) { @@ -485,14 +484,16 @@ lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) { SBTypeList sb_type_list; ModuleSP module_sp(GetSP()); - if (module_sp) { - SymbolVendor *vendor = module_sp->GetSymbolVendor(); - if (vendor) { - TypeList type_list; - vendor->GetTypes(NULL, type_mask, type_list); - sb_type_list.m_opaque_ap->Append(type_list); - } - } + if (!module_sp) + return sb_type_list; + SymbolVendor *vendor = module_sp->GetSymbolVendor(); + if (!vendor) + return sb_type_list; + + TypeClass type_class = static_cast(type_mask); + TypeList type_list; + vendor->GetTypes(NULL, type_class, type_list); + sb_type_list.m_opaque_ap->Append(type_list); return sb_type_list; } @@ -585,7 +586,7 @@ lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { if (module_sp) { ObjectFile *objfile_ptr = module_sp->GetObjectFile(); if (objfile_ptr) - sb_addr.ref() = objfile_ptr->GetHeaderAddress(); + sb_addr.ref() = objfile_ptr->GetBaseAddress(); } return sb_addr; } @@ -607,3 +608,14 @@ lldb::SBError SBModule::IsTypeSystemCompatible(lldb::LanguageType language) { } return sb_error; } + +lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { + lldb::SBAddress sb_addr; + ModuleSP module_sp(GetSP()); + if (module_sp) { + ObjectFile *objfile_ptr = module_sp->GetObjectFile(); + if (objfile_ptr) + sb_addr.ref() = objfile_ptr->GetEntryPointAddress(); + } + return sb_addr; +} diff --git a/source/API/SBModuleSpec.cpp b/source/API/SBModuleSpec.cpp index afabd9ace2b9..882b312e4aad 100644 --- a/source/API/SBModuleSpec.cpp +++ b/source/API/SBModuleSpec.cpp @@ -1,9 +1,8 @@ //===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -114,7 +113,8 @@ SBModuleSpecList::~SBModuleSpecList() {} SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) { SBModuleSpecList specs; - FileSpec file_spec(path, true); + FileSpec file_spec(path); + FileSystem::Instance().Resolve(file_spec); Host::ResolveExecutableInBundle(file_spec); ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap); return specs; diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp index 5f29f0033988..46a2bff8af0d 100644 --- a/source/API/SBPlatform.cpp +++ b/source/API/SBPlatform.cpp @@ -1,9 +1,8 @@ //===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -244,9 +243,9 @@ bool SBPlatform::SetWorkingDirectory(const char *path) { PlatformSP platform_sp(GetSP()); if (platform_sp) { if (path) - platform_sp->SetWorkingDirectory(FileSpec{path, false}); + platform_sp->SetWorkingDirectory(FileSpec(path)); else - platform_sp->SetWorkingDirectory(FileSpec{}); + platform_sp->SetWorkingDirectory(FileSpec()); return true; } return false; @@ -364,9 +363,9 @@ SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { if (src.Exists()) { - uint32_t permissions = src.ref().GetPermissions(); + uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref()); if (permissions == 0) { - if (llvm::sys::fs::is_directory(src.ref().GetPath())) + if (FileSystem::Instance().IsDirectory(src.ref())) permissions = eFilePermissionsDirectoryDefault; else permissions = eFilePermissionsFileDefault; @@ -406,7 +405,7 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { if (working_dir) shell_command.SetWorkingDirectory(working_dir); } - return platform_sp->RunShellCommand(command, FileSpec{working_dir, false}, + return platform_sp->RunShellCommand(command, FileSpec(working_dir), &shell_command.m_opaque_ptr->m_status, &shell_command.m_opaque_ptr->m_signo, &shell_command.m_opaque_ptr->m_output, @@ -449,7 +448,7 @@ SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { PlatformSP platform_sp(GetSP()); if (platform_sp) { sb_error.ref() = - platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions); + platform_sp->MakeDirectory(FileSpec(path), file_permissions); } else { sb_error.SetErrorString("invalid platform"); } @@ -460,7 +459,7 @@ uint32_t SBPlatform::GetFilePermissions(const char *path) { PlatformSP platform_sp(GetSP()); if (platform_sp) { uint32_t file_permissions = 0; - platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions); + platform_sp->GetFilePermissions(FileSpec(path), file_permissions); return file_permissions; } return 0; @@ -471,8 +470,8 @@ SBError SBPlatform::SetFilePermissions(const char *path, SBError sb_error; PlatformSP platform_sp(GetSP()); if (platform_sp) { - sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false}, - file_permissions); + sb_error.ref() = + platform_sp->SetFilePermissions(FileSpec(path), file_permissions); } else { sb_error.SetErrorString("invalid platform"); } diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp index 4d5ddc86ccf9..8bd5691302c8 100644 --- a/source/API/SBProcess.cpp +++ b/source/API/SBProcess.cpp @@ -1,15 +1,13 @@ //===-- SBProcess.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/API/SBProcess.h" -// C Includes #include #include "lldb/lldb-defines.h" @@ -18,7 +16,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" @@ -28,9 +25,9 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" -// Project includes #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandReturnObject.h" @@ -130,10 +127,9 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp, if (process_sp->GetState() == eStateConnected) { if (stop_at_entry) launch_flags |= eLaunchFlagStopAtEntry; - ProcessLaunchInfo launch_info( - FileSpec{stdin_path, false}, FileSpec{stdout_path, false}, - FileSpec{stderr_path, false}, FileSpec{working_directory, false}, - launch_flags); + ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path), + FileSpec(stderr_path), + FileSpec(working_directory), launch_flags); Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); if (exe_module) launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); @@ -1351,7 +1347,7 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { return error; } - FileSpec core_file(file_name, false); + FileSpec core_file(file_name); error.ref() = PluginManager::SaveCore(process_sp, core_file); return error; } @@ -1361,18 +1357,14 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, SBMemoryRegionInfo &sb_region_info) { lldb::SBError sb_error; ProcessSP process_sp(GetSP()); - MemoryRegionInfoSP region_info_sp = - std::make_shared(); if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { std::lock_guard guard( process_sp->GetTarget().GetAPIMutex()); + sb_error.ref() = - process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp); - if (sb_error.Success()) { - sb_region_info.ref() = *region_info_sp; - } + process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref()); } else { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) @@ -1388,35 +1380,23 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, } lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() { - lldb::SBError sb_error; lldb::SBMemoryRegionInfoList sb_region_list; + ProcessSP process_sp(GetSP()); - if (process_sp) { - Process::StopLocker stop_locker; - if (stop_locker.TryLock(&process_sp->GetRunLock())) { - std::lock_guard guard( - process_sp->GetTarget().GetAPIMutex()); - std::vector region_list; - sb_error.ref() = process_sp->GetMemoryRegions(region_list); - if (sb_error.Success()) { - std::vector::iterator end = region_list.end(); - for (std::vector::iterator it = region_list.begin(); - it != end; it++) { - SBMemoryRegionInfo sb_region_info(it->get()); - sb_region_list.Append(sb_region_info); - } - } - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running", - static_cast(process_sp.get())); - sb_error.SetErrorString("process is running"); - } + Process::StopLocker stop_locker; + if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) { + std::lock_guard guard( + process_sp->GetTarget().GetAPIMutex()); + + process_sp->GetMemoryRegions(sb_region_list.ref()); } else { - sb_error.SetErrorString("SBProcess is invalid"); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf( + "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running", + static_cast(process_sp.get())); } + return sb_region_list; } diff --git a/source/API/SBProcessInfo.cpp b/source/API/SBProcessInfo.cpp index 38f6c1d1e699..a786a5e0d49d 100644 --- a/source/API/SBProcessInfo.cpp +++ b/source/API/SBProcessInfo.cpp @@ -1,9 +1,8 @@ //===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -36,7 +35,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { } ProcessInstanceInfo &SBProcessInfo::ref() { - if (m_opaque_ap.get() == nullptr) { + if (m_opaque_ap == nullptr) { m_opaque_ap.reset(new ProcessInstanceInfo()); } return *m_opaque_ap; @@ -46,7 +45,7 @@ void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) { ref() = proc_info_ref; } -bool SBProcessInfo::IsValid() const { return m_opaque_ap.get() != nullptr; } +bool SBProcessInfo::IsValid() const { return m_opaque_ap != nullptr; } const char *SBProcessInfo::GetName() { const char *name = nullptr; diff --git a/source/API/SBQueue.cpp b/source/API/SBQueue.cpp index 5f852111e077..f73a20208f53 100644 --- a/source/API/SBQueue.cpp +++ b/source/API/SBQueue.cpp @@ -1,9 +1,8 @@ //===-- SBQueue.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -107,7 +106,7 @@ class QueueImpl { } void FetchThreads() { - if (m_thread_list_fetched == false) { + if (!m_thread_list_fetched) { lldb::QueueSP queue_sp = m_queue_wp.lock(); if (queue_sp) { Process::StopLocker stop_locker; @@ -127,7 +126,7 @@ class QueueImpl { } void FetchItems() { - if (m_pending_items_fetched == false) { + if (!m_pending_items_fetched) { QueueSP queue_sp = m_queue_wp.lock(); if (queue_sp) { Process::StopLocker stop_locker; @@ -178,7 +177,7 @@ class QueueImpl { uint32_t result = 0; QueueSP queue_sp = m_queue_wp.lock(); - if (m_pending_items_fetched == false && queue_sp) { + if (!m_pending_items_fetched && queue_sp) { result = queue_sp->GetNumPendingWorkItems(); } else { result = m_pending_items.size(); diff --git a/source/API/SBQueueItem.cpp b/source/API/SBQueueItem.cpp index aac5844240fb..398c74b55e46 100644 --- a/source/API/SBQueueItem.cpp +++ b/source/API/SBQueueItem.cpp @@ -1,9 +1,8 @@ //===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBSection.cpp b/source/API/SBSection.cpp index 9da5d170da9e..b76714bb175b 100644 --- a/source/API/SBSection.cpp +++ b/source/API/SBSection.cpp @@ -1,9 +1,8 @@ //===-- SBSection.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,7 +13,6 @@ #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataBuffer.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" @@ -166,7 +164,7 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { else file_size = 0; } - auto data_buffer_sp = DataBufferLLVM::CreateSliceFromPath( + auto data_buffer_sp = FileSystem::Instance().CreateDataBuffer( objfile->GetFileSpec().GetPath(), file_size, file_offset); if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) { DataExtractorSP data_extractor_sp( diff --git a/source/API/SBSourceManager.cpp b/source/API/SBSourceManager.cpp index 5804c22bacb8..9a469b1e4534 100644 --- a/source/API/SBSourceManager.cpp +++ b/source/API/SBSourceManager.cpp @@ -1,9 +1,8 @@ //===-- SBSourceManager.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -107,7 +106,7 @@ size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn( const SBFileSpec &file, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, SBStream &s) { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) return 0; return m_opaque_ap->DisplaySourceLinesWithLineNumbers( diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp index d1af77a40fa3..2e7098511a6c 100644 --- a/source/API/SBStream.cpp +++ b/source/API/SBStream.cpp @@ -1,15 +1,15 @@ //===-- SBStream.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/API/SBStream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -24,12 +24,12 @@ SBStream::SBStream(SBStream &&rhs) SBStream::~SBStream() {} -bool SBStream::IsValid() const { return (m_opaque_ap.get() != NULL); } +bool SBStream::IsValid() const { return (m_opaque_ap != NULL); } // If this stream is not redirected to a file, it will maintain a local cache // for the stream data which can be accessed using this accessor. const char *SBStream::GetData() { - if (m_is_file || m_opaque_ap.get() == NULL) + if (m_is_file || m_opaque_ap == NULL) return NULL; return static_cast(m_opaque_ap.get())->GetData(); @@ -38,7 +38,7 @@ const char *SBStream::GetData() { // If this stream is not redirected to a file, it will maintain a local cache // for the stream output whose length can be accessed using this accessor. size_t SBStream::GetSize() { - if (m_is_file || m_opaque_ap.get() == NULL) + if (m_is_file || m_opaque_ap == NULL) return 0; return static_cast(m_opaque_ap.get())->GetSize(); @@ -58,7 +58,7 @@ void SBStream::RedirectToFile(const char *path, bool append) { return; std::string local_data; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) @@ -70,12 +70,12 @@ void SBStream::RedirectToFile(const char *path, bool append) { open_options |= File::eOpenOptionAppend; else open_options |= File::eOpenOptionTruncate; - stream_file->GetFile().Open(path, open_options, - lldb::eFilePermissionsFileDefault); + FileSystem::Instance().Open(stream_file->GetFile(), FileSpec(path), + open_options); m_opaque_ap.reset(stream_file); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to @@ -91,7 +91,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { return; std::string local_data; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) @@ -99,7 +99,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { } m_opaque_ap.reset(new StreamFile(fh, transfer_fh_ownership)); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to @@ -112,7 +112,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { std::string local_data; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) @@ -120,7 +120,7 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { } m_opaque_ap.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership)); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to @@ -136,13 +136,13 @@ lldb_private::Stream *SBStream::operator->() { return m_opaque_ap.get(); } lldb_private::Stream *SBStream::get() { return m_opaque_ap.get(); } lldb_private::Stream &SBStream::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new StreamString()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } void SBStream::Clear() { - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (m_is_file) diff --git a/source/API/SBStringList.cpp b/source/API/SBStringList.cpp index 9ac69b15ebb7..8a4cc0419c76 100644 --- a/source/API/SBStringList.cpp +++ b/source/API/SBStringList.cpp @@ -1,9 +1,8 @@ //===-- SBStringList.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -47,7 +46,7 @@ const lldb_private::StringList &SBStringList::operator*() const { return *m_opaque_ap; } -bool SBStringList::IsValid() const { return (m_opaque_ap.get() != NULL); } +bool SBStringList::IsValid() const { return (m_opaque_ap != NULL); } void SBStringList::AppendString(const char *str) { if (str != NULL) { diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp index d901f915dad4..35fe77f47bfa 100644 --- a/source/API/SBStructuredData.cpp +++ b/source/API/SBStructuredData.cpp @@ -1,9 +1,8 @@ //===-- SBStructuredData.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,9 +10,9 @@ #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" -#include "lldb/Core/Event.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/StructuredDataPlugin.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/API/SBSymbol.cpp b/source/API/SBSymbol.cpp index 5be20a124982..981c9864f44c 100644 --- a/source/API/SBSymbol.cpp +++ b/source/API/SBSymbol.cpp @@ -1,9 +1,8 @@ //===-- SBSymbol.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp index 45dfffd916e7..e64c0610a951 100644 --- a/source/API/SBSymbolContext.cpp +++ b/source/API/SBSymbolContext.cpp @@ -1,9 +1,8 @@ //===-- SBSymbolContext.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -27,7 +26,7 @@ SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_ap() { SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_ap() { if (rhs.IsValid()) { - if (m_opaque_ap.get()) + if (m_opaque_ap) *m_opaque_ap = *rhs.m_opaque_ap; else ref() = *rhs.m_opaque_ap; @@ -39,32 +38,31 @@ SBSymbolContext::~SBSymbolContext() {} const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) { if (this != &rhs) { if (rhs.IsValid()) - m_opaque_ap.reset( - new lldb_private::SymbolContext(*rhs.m_opaque_ap.get())); + m_opaque_ap.reset(new lldb_private::SymbolContext(*rhs.m_opaque_ap)); } return *this; } void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) { if (sc_ptr) { - if (m_opaque_ap.get()) + if (m_opaque_ap) *m_opaque_ap = *sc_ptr; else m_opaque_ap.reset(new SymbolContext(*sc_ptr)); } else { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(true); } } -bool SBSymbolContext::IsValid() const { return m_opaque_ap.get() != NULL; } +bool SBSymbolContext::IsValid() const { return m_opaque_ap != NULL; } SBModule SBSymbolContext::GetModule() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBModule sb_module; ModuleSP module_sp; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { module_sp = m_opaque_ap->module_sp; sb_module.SetSP(module_sp); } @@ -81,7 +79,7 @@ SBModule SBSymbolContext::GetModule() { } SBCompileUnit SBSymbolContext::GetCompileUnit() { - return SBCompileUnit(m_opaque_ap.get() ? m_opaque_ap->comp_unit : NULL); + return SBCompileUnit(m_opaque_ap ? m_opaque_ap->comp_unit : NULL); } SBFunction SBSymbolContext::GetFunction() { @@ -89,7 +87,7 @@ SBFunction SBSymbolContext::GetFunction() { Function *function = NULL; - if (m_opaque_ap.get()) + if (m_opaque_ap) function = m_opaque_ap->function; SBFunction sb_function(function); @@ -103,14 +101,14 @@ SBFunction SBSymbolContext::GetFunction() { } SBBlock SBSymbolContext::GetBlock() { - return SBBlock(m_opaque_ap.get() ? m_opaque_ap->block : NULL); + return SBBlock(m_opaque_ap ? m_opaque_ap->block : NULL); } SBLineEntry SBSymbolContext::GetLineEntry() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBLineEntry sb_line_entry; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_line_entry.SetLineEntry(m_opaque_ap->line_entry); if (log) { @@ -127,7 +125,7 @@ SBSymbol SBSymbolContext::GetSymbol() { Symbol *symbol = NULL; - if (m_opaque_ap.get()) + if (m_opaque_ap) symbol = m_opaque_ap->symbol; SBSymbol sb_symbol(symbol); @@ -173,19 +171,19 @@ lldb_private::SymbolContext *SBSymbolContext::operator->() const { const lldb_private::SymbolContext &SBSymbolContext::operator*() const { assert(m_opaque_ap.get()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } lldb_private::SymbolContext &SBSymbolContext::operator*() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new SymbolContext); - return *m_opaque_ap.get(); + return *m_opaque_ap; } lldb_private::SymbolContext &SBSymbolContext::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new SymbolContext); - return *m_opaque_ap.get(); + return *m_opaque_ap; } lldb_private::SymbolContext *SBSymbolContext::get() const { @@ -195,7 +193,7 @@ lldb_private::SymbolContext *SBSymbolContext::get() const { bool SBSymbolContext::GetDescription(SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); } else strm.PutCString("No value"); diff --git a/source/API/SBSymbolContextList.cpp b/source/API/SBSymbolContextList.cpp index 8cc29c3422d0..b078aab10ee2 100644 --- a/source/API/SBSymbolContextList.cpp +++ b/source/API/SBSymbolContextList.cpp @@ -1,9 +1,8 @@ //===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -31,14 +30,14 @@ operator=(const SBSymbolContextList &rhs) { } uint32_t SBSymbolContextList::GetSize() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetSize(); return 0; } SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { SBSymbolContext sb_sc; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { SymbolContext sc; if (m_opaque_ap->GetContextAtIndex(idx, sc)) { sb_sc.SetSymbolContext(&sc); @@ -48,7 +47,7 @@ SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { } void SBSymbolContextList::Clear() { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(); } @@ -62,7 +61,7 @@ void SBSymbolContextList::Append(SBSymbolContextList &sc_list) { m_opaque_ap->Append(*sc_list); } -bool SBSymbolContextList::IsValid() const { return m_opaque_ap.get() != NULL; } +bool SBSymbolContextList::IsValid() const { return m_opaque_ap != NULL; } lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { return m_opaque_ap.get(); @@ -70,12 +69,12 @@ lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { lldb_private::SymbolContextList &SBSymbolContextList::operator*() const { assert(m_opaque_ap.get()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } bool SBSymbolContextList::GetDescription(lldb::SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); return true; } diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp index d229788ef63b..9b52c62d331c 100644 --- a/source/API/SBTarget.cpp +++ b/source/API/SBTarget.cpp @@ -1,9 +1,8 @@ //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -227,7 +226,8 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { SBProcess sb_process; TargetSP target_sp(GetSP()); if (target_sp) { - FileSpec filespec(core_file, true); + FileSpec filespec(core_file); + FileSystem::Instance().Resolve(filespec); ProcessSP process_sp(target_sp->CreateProcess( target_sp->GetDebugger().GetListener(), "", &filespec)); if (process_sp) { @@ -326,10 +326,9 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) launch_flags |= eLaunchFlagDisableSTDIO; - ProcessLaunchInfo launch_info( - FileSpec{stdin_path, false}, FileSpec{stdout_path, false}, - FileSpec{stderr_path, false}, FileSpec{working_directory, false}, - launch_flags); + ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path), + FileSpec(stderr_path), + FileSpec(working_directory), launch_flags); Module *exe_module = target_sp->GetExecutableModulePointer(); if (exe_module) @@ -517,8 +516,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithName( if (name && target_sp) { ProcessAttachInfo attach_info; - attach_info.GetExecutableFile().SetFile(name, false, - FileSpec::Style::native); + attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); attach_info.SetWaitForLaunch(wait_for); if (listener.IsValid()) attach_info.SetListener(listener.GetSP()); @@ -661,11 +659,12 @@ SBSymbolContext SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { SBSymbolContext sc; + SymbolContextItem scope = static_cast(resolve_scope); if (addr.IsValid()) { TargetSP target_sp(GetSP()); if (target_sp) - target_sp->GetImages().ResolveSymbolContextForAddress( - addr.ref(), resolve_scope, sc.ref()); + target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope, + sc.ref()); } return sc; } @@ -766,7 +765,7 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const lldb::addr_t offset = 0; if (module_name && module_name[0]) { FileSpecList module_spec_list; - module_spec_list.Append(FileSpec(module_name, false)); + module_spec_list.Append(FileSpec(module_name)); sb_bp = target_sp->CreateBreakpoint( &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); @@ -790,7 +789,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - uint32_t name_type_mask = eFunctionNameTypeAuto; + lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto; return BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list); @@ -817,9 +816,10 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; std::lock_guard guard(target_sp->GetAPIMutex()); - sb_bp = target_sp->CreateBreakpoint( - module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask, - symbol_language, 0, skip_prologue, internal, hardware); + FunctionNameType mask = static_cast(name_type_mask); + sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(), + symbol_name, mask, symbol_language, 0, + skip_prologue, internal, hardware); } if (log) @@ -860,11 +860,11 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( std::lock_guard guard(target_sp->GetAPIMutex()); const bool internal = false; const bool hardware = false; + FunctionNameType mask = static_cast(name_type_mask); const LazyBool skip_prologue = eLazyBoolCalculate; sb_bp = target_sp->CreateBreakpoint( - module_list.get(), comp_unit_list.get(), symbol_names, num_names, - name_type_mask, symbol_language, offset, skip_prologue, internal, - hardware); + module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask, + symbol_language, offset, skip_prologue, internal, hardware); } if (log) { @@ -893,7 +893,7 @@ SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, SBFileSpecList module_spec_list; SBFileSpecList comp_unit_list; if (module_name && module_name[0]) { - module_spec_list.Append(FileSpec(module_name, false)); + module_spec_list.Append(FileSpec(module_name)); } return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, module_spec_list, comp_unit_list); @@ -994,7 +994,7 @@ SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, SBFileSpecList module_spec_list; if (module_name && module_name[0]) { - module_spec_list.Append(FileSpec(module_name, false)); + module_spec_list.Append(FileSpec(module_name)); } SBFileSpecList source_file_list; @@ -1541,6 +1541,26 @@ bool SBTarget::DeleteAllWatchpoints() { return false; } +void SBTarget::AppendImageSearchPath(const char *from, const char *to, + lldb::SBError &error) { + TargetSP target_sp(GetSP()); + if (!target_sp) + return error.SetErrorString("invalid target"); + + const ConstString csFrom(from), csTo(to); + if (!csFrom) + return error.SetErrorString(" path can't be empty"); + if (!csTo) + return error.SetErrorString(" path can't be empty"); + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf("SBTarget(%p)::%s: '%s' -> '%s'", + static_cast(target_sp.get()), __FUNCTION__, + from, to); + target_sp->GetImageSearchPathList().Append(csFrom, csTo, true); +} + lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, const char *uuid_cstr) { return AddModule(path, triple, uuid_cstr, NULL); @@ -1553,7 +1573,7 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, if (target_sp) { ModuleSpec module_spec; if (path) - module_spec.GetFileSpec().SetFile(path, false, FileSpec::Style::native); + module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native); if (uuid_cstr) module_spec.GetUUID().SetFromStringRef(uuid_cstr); @@ -1565,8 +1585,7 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, module_spec.GetArchitecture() = target_sp->GetArchitecture(); if (symfile) - module_spec.GetSymbolFileSpec().SetFile(symfile, false, - FileSpec::Style::native); + module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native); sb_module.SetSP(target_sp->GetSharedModule(module_spec)); } @@ -1740,17 +1759,19 @@ bool SBTarget::GetDescription(SBStream &description, lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, uint32_t name_type_mask) { lldb::SBSymbolContextList sb_sc_list; - if (name && name[0]) { - TargetSP target_sp(GetSP()); - if (target_sp) { - const bool symbols_ok = true; - const bool inlines_ok = true; - const bool append = true; - target_sp->GetImages().FindFunctions(ConstString(name), name_type_mask, - symbols_ok, inlines_ok, append, - *sb_sc_list); - } - } + if (!name | !name[0]) + return sb_sc_list; + + TargetSP target_sp(GetSP()); + if (!target_sp) + return sb_sc_list; + + const bool symbols_ok = true; + const bool inlines_ok = true; + const bool append = true; + FunctionNameType mask = static_cast(name_type_mask); + target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok, + inlines_ok, append, *sb_sc_list); return sb_sc_list; } @@ -1854,11 +1875,10 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { ModuleList &images = target_sp->GetImages(); ConstString const_typename(typename_cstr); bool exact_match = false; - SymbolContext sc; TypeList type_list; llvm::DenseSet searched_symbol_files; uint32_t num_matches = - images.FindTypes(sc, const_typename, exact_match, UINT32_MAX, + images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX, searched_symbol_files, type_list); if (num_matches > 0) { diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index b00d88554bbf..f636e669151f 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -1,9 +1,8 @@ //===-- SBThread.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,7 +13,6 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -32,6 +30,7 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -590,7 +589,7 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { success = true; } if (node->GetType() == eStructuredDataTypeBoolean) { - if (node->GetAsBoolean()->GetValue() == true) + if (node->GetAsBoolean()->GetValue()) strm.Printf("true"); else strm.Printf("false"); @@ -1489,7 +1488,7 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) { } } - if (log && sb_origin_thread.IsValid() == false) + if (log && !sb_origin_thread.IsValid()) log->Printf("SBThread(%p)::GetExtendedBacktraceThread() is not returning a " "Valid thread", static_cast(exe_ctx.GetThreadPtr())); @@ -1503,6 +1502,20 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() { return LLDB_INVALID_INDEX32; } +SBValue SBThread::GetCurrentException() { + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); + if (!thread_sp) return SBValue(); + + return SBValue(thread_sp->GetCurrentException()); +} + +SBThread SBThread::GetCurrentExceptionBacktrace() { + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); + if (!thread_sp) return SBThread(); + + return SBThread(thread_sp->GetCurrentExceptionBacktrace()); +} + bool SBThread::SafeToCallFunctions() { ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) diff --git a/source/API/SBThreadCollection.cpp b/source/API/SBThreadCollection.cpp index c424d47b4098..360e5a0e9530 100644 --- a/source/API/SBThreadCollection.cpp +++ b/source/API/SBThreadCollection.cpp @@ -1,9 +1,8 @@ //===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp index 23b142a961c7..ba645cba3439 100644 --- a/source/API/SBThreadPlan.cpp +++ b/source/API/SBThreadPlan.cpp @@ -1,9 +1,8 @@ //===-- SBThreadPlan.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,7 +13,6 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" @@ -31,6 +29,7 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -263,3 +262,27 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, return SBThreadPlan(); } } + +SBThreadPlan +SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) { + SBError error; + return QueueThreadPlanForStepScripted(script_class_name, error); +} + +SBThreadPlan +SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, + SBError &error) { + if (m_opaque_sp) { + Status plan_status; + SBThreadPlan plan = + SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted( + false, script_class_name, false, plan_status)); + + if (plan_status.Fail()) + error.SetErrorString(plan_status.AsCString()); + + return plan; + } else { + return SBThreadPlan(); + } +} diff --git a/source/API/SBTrace.cpp b/source/API/SBTrace.cpp index 9a5fa4ed4f46..b4e7f654b3bc 100644 --- a/source/API/SBTrace.cpp +++ b/source/API/SBTrace.cpp @@ -1,9 +1,8 @@ //===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBTraceOptions.cpp b/source/API/SBTraceOptions.cpp index 20a8f25a768b..a041f740bc03 100644 --- a/source/API/SBTraceOptions.cpp +++ b/source/API/SBTraceOptions.cpp @@ -1,9 +1,8 @@ //===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp index 89028444f06a..06458168dc6a 100644 --- a/source/API/SBType.cpp +++ b/source/API/SBType.cpp @@ -1,9 +1,8 @@ //===-- SBType.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -47,20 +46,20 @@ SBType::SBType(const SBType &rhs) : m_opaque_sp() { //{} // bool SBType::operator==(SBType &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); - if (rhs.IsValid() == false) + if (!rhs.IsValid()) return false; return *m_opaque_sp.get() == *rhs.m_opaque_sp.get(); } bool SBType::operator!=(SBType &rhs) { - if (IsValid() == false) + if (!IsValid()) return rhs.IsValid(); - if (rhs.IsValid() == false) + if (!rhs.IsValid()) return true; return *m_opaque_sp.get() != *rhs.m_opaque_sp.get(); @@ -104,7 +103,8 @@ bool SBType::IsValid() const { uint64_t SBType::GetByteSize() { if (IsValid()) - if (auto size = m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr)) + if (llvm::Optional size = + m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr)) return *size; return 0; } @@ -463,7 +463,7 @@ SBTypeList::SBTypeList(const SBTypeList &rhs) Append(const_cast(rhs).GetTypeAtIndex(i)); } -bool SBTypeList::IsValid() { return (m_opaque_ap.get() != NULL); } +bool SBTypeList::IsValid() { return (m_opaque_ap != NULL); } SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { if (this != &rhs) { @@ -481,7 +481,7 @@ void SBTypeList::Append(SBType type) { } SBType SBTypeList::GetTypeAtIndex(uint32_t index) { - if (m_opaque_ap.get()) + if (m_opaque_ap) return SBType(m_opaque_ap->GetTypeAtIndex(index)); return SBType(); } @@ -512,39 +512,39 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) { bool SBTypeMember::IsValid() const { return m_opaque_ap.get(); } const char *SBTypeMember::GetName() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetName().GetCString(); return NULL; } SBType SBTypeMember::GetType() { SBType sb_type; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { sb_type.SetSP(m_opaque_ap->GetTypeImpl()); } return sb_type; } uint64_t SBTypeMember::GetOffsetInBytes() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetBitOffset() / 8u; return 0; } uint64_t SBTypeMember::GetOffsetInBits() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetBitOffset(); return 0; } bool SBTypeMember::IsBitfield() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetIsBitfield(); return false; } uint32_t SBTypeMember::GetBitfieldSizeInBits() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetBitfieldBitSize(); return 0; } @@ -553,7 +553,7 @@ bool SBTypeMember::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { const uint32_t bit_offset = m_opaque_ap->GetBitOffset(); const uint32_t byte_offset = bit_offset / 8u; const uint32_t byte_bit_offset = bit_offset % 8u; @@ -583,12 +583,12 @@ void SBTypeMember::reset(TypeMemberImpl *type_member_impl) { } TypeMemberImpl &SBTypeMember::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new TypeMemberImpl()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } -const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap.get(); } +const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap; } SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {} diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp index 30414bd728cb..1d8234a030f9 100644 --- a/source/API/SBTypeCategory.cpp +++ b/source/API/SBTypeCategory.cpp @@ -1,10 +1,9 @@ //===-- SBTypeCategory.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -529,14 +528,14 @@ operator=(const lldb::SBTypeCategory &rhs) { } bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBTypeCategory::operator!=(lldb::SBTypeCategory &rhs) { - if (IsValid() == false) + if (!IsValid()) return rhs.IsValid(); return m_opaque_sp.get() != rhs.m_opaque_sp.get(); diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp index 5ca9db7ce242..44569c31ac1e 100644 --- a/source/API/SBTypeEnumMember.cpp +++ b/source/API/SBTypeEnumMember.cpp @@ -1,9 +1,8 @@ //===-- SBTypeEnumMember.cpp ---------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -94,7 +93,7 @@ SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs) Append(const_cast(rhs).GetTypeEnumMemberAtIndex(i)); } -bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap.get() != NULL); } +bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap != NULL); } SBTypeEnumMemberList &SBTypeEnumMemberList:: operator=(const SBTypeEnumMemberList &rhs) { @@ -116,7 +115,7 @@ void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { SBTypeEnumMember SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index) { - if (m_opaque_ap.get()) + if (m_opaque_ap) return SBTypeEnumMember(m_opaque_ap->GetTypeEnumMemberAtIndex(index)); return SBTypeEnumMember(); } diff --git a/source/API/SBTypeFilter.cpp b/source/API/SBTypeFilter.cpp index 8fa322211384..505affd0d6e1 100644 --- a/source/API/SBTypeFilter.cpp +++ b/source/API/SBTypeFilter.cpp @@ -1,10 +1,9 @@ //===-- SBTypeFilter.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -91,14 +90,14 @@ lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (GetNumberOfExpressionPaths() != rhs.GetNumberOfExpressionPaths()) @@ -113,7 +112,7 @@ bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::operator!=(lldb::SBTypeFilter &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; diff --git a/source/API/SBTypeFormat.cpp b/source/API/SBTypeFormat.cpp index 6fe7625831d2..cce29ea1ccff 100644 --- a/source/API/SBTypeFormat.cpp +++ b/source/API/SBTypeFormat.cpp @@ -1,10 +1,9 @@ //===-- SBTypeFormat.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -88,13 +87,13 @@ lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (GetFormat() == rhs.GetFormat()) @@ -104,7 +103,7 @@ bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp index 2f9deafb68c8..48e1e1e221fd 100644 --- a/source/API/SBTypeNameSpecifier.cpp +++ b/source/API/SBTypeNameSpecifier.cpp @@ -1,10 +1,9 @@ //===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -80,13 +79,13 @@ operator=(const lldb::SBTypeNameSpecifier &rhs) { } bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (IsRegex() != rhs.IsRegex()) @@ -98,7 +97,7 @@ bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { } bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp index cd4edd17f672..23c2781b79a6 100644 --- a/source/API/SBTypeSummary.cpp +++ b/source/API/SBTypeSummary.cpp @@ -1,10 +1,9 @@ //===-- SBTypeSummary.cpp -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,7 +24,7 @@ SBTypeSummaryOptions::SBTypeSummaryOptions() { SBTypeSummaryOptions::SBTypeSummaryOptions( const lldb::SBTypeSummaryOptions &rhs) { if (rhs.m_opaque_ap) - m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap.get())); + m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap)); else m_opaque_ap.reset(new TypeSummaryOptions()); } @@ -70,11 +69,11 @@ lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::get() { } lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() { - return *m_opaque_ap.get(); + return *m_opaque_ap; } const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } SBTypeSummaryOptions::SBTypeSummaryOptions( @@ -261,7 +260,7 @@ lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } @@ -305,7 +304,7 @@ bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBTypeSynthetic.cpp b/source/API/SBTypeSynthetic.cpp index 37b6086f855a..e9a68c60338c 100644 --- a/source/API/SBTypeSynthetic.cpp +++ b/source/API/SBTypeSynthetic.cpp @@ -1,10 +1,9 @@ //===-- SBTypeSynthetic.cpp -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -106,13 +105,13 @@ operator=(const lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) @@ -128,7 +127,7 @@ bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::operator!=(lldb::SBTypeSynthetic &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBUnixSignals.cpp b/source/API/SBUnixSignals.cpp index 14bdd39919c3..88fefcfab7dd 100644 --- a/source/API/SBUnixSignals.cpp +++ b/source/API/SBUnixSignals.cpp @@ -1,10 +1,9 @@ //===-- SBUnixSignals.cpp -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp index a270c0471e9f..31606af4a228 100644 --- a/source/API/SBValue.cpp +++ b/source/API/SBValue.cpp @@ -1,9 +1,8 @@ //===-- SBValue.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,7 +17,6 @@ #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" @@ -38,6 +36,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Stream.h" #include "lldb/API/SBDebugger.h" @@ -98,10 +97,7 @@ class ValueImpl { // they depend on. So I have no good way to make that check without // tracking that in all the ValueObject subclasses. TargetSP target_sp = m_valobj_sp->GetTargetSP(); - if (target_sp && target_sp->IsValid()) - return true; - else - return false; + return target_sp && target_sp->IsValid(); } } diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp index 0adf3bb914aa..b03b86e415be 100644 --- a/source/API/SBValueList.cpp +++ b/source/API/SBValueList.cpp @@ -1,9 +1,8 @@ //===-- SBValueList.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -99,7 +98,7 @@ SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_ap() { SBValueList::~SBValueList() {} -bool SBValueList::IsValid() const { return (m_opaque_ap.get() != NULL); } +bool SBValueList::IsValid() const { return (m_opaque_ap != NULL); } void SBValueList::Clear() { m_opaque_ap.reset(); } @@ -150,7 +149,7 @@ SBValue SBValueList::GetValueAtIndex(uint32_t idx) const { // idx); SBValue sb_value; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_value = m_opaque_ap->GetValueAtIndex(idx); if (log) { @@ -172,7 +171,7 @@ uint32_t SBValueList::GetSize() const { // log->Printf ("SBValueList::GetSize ()"); uint32_t size = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) size = m_opaque_ap->GetSize(); if (log) @@ -183,20 +182,20 @@ uint32_t SBValueList::GetSize() const { } void SBValueList::CreateIfNeeded() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new ValueListImpl()); } SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) { SBValue sb_value; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_value = m_opaque_ap->FindValueByUID(uid); return sb_value; } SBValue SBValueList::GetFirstValueByName(const char *name) const { SBValue sb_value; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_value = m_opaque_ap->GetFirstValueByName(name); return sb_value; } @@ -205,5 +204,5 @@ void *SBValueList::opaque_ptr() { return m_opaque_ap.get(); } ValueListImpl &SBValueList::ref() { CreateIfNeeded(); - return *m_opaque_ap.get(); + return *m_opaque_ap; } diff --git a/source/API/SBVariablesOptions.cpp b/source/API/SBVariablesOptions.cpp index ae069756de15..42eafaa8cd96 100644 --- a/source/API/SBVariablesOptions.cpp +++ b/source/API/SBVariablesOptions.cpp @@ -1,14 +1,17 @@ //===-- SBVariablesOptions.cpp --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/API/SBVariablesOptions.h" +#include "lldb/API/SBTarget.h" +#include "lldb/Target/Target.h" + +#include "lldb/lldb-private.h" using namespace lldb; using namespace lldb_private; @@ -16,9 +19,10 @@ using namespace lldb_private; class VariablesOptionsImpl { public: VariablesOptionsImpl() - : m_include_arguments(false), m_include_recognized_arguments(false), - m_include_locals(false), m_include_statics(false), - m_in_scope_only(false), m_include_runtime_support_values(false), + : m_include_arguments(false), m_include_locals(false), + m_include_statics(false), m_in_scope_only(false), + m_include_runtime_support_values(false), + m_include_recognized_arguments(eLazyBoolCalculate), m_use_dynamic(lldb::eNoDynamicValues) {} VariablesOptionsImpl(const VariablesOptionsImpl &) = default; @@ -31,12 +35,14 @@ class VariablesOptionsImpl { void SetIncludeArguments(bool b) { m_include_arguments = b; } - bool GetIncludeRecognizedArguments() const { - return m_include_recognized_arguments; + bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const { + if (m_include_recognized_arguments != eLazyBoolCalculate) + return m_include_recognized_arguments; + return target_sp ? target_sp->GetDisplayRecognizedArguments() : false; } void SetIncludeRecognizedArguments(bool b) { - m_include_recognized_arguments = b; + m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo; } bool GetIncludeLocals() const { return m_include_locals; } @@ -65,11 +71,11 @@ class VariablesOptionsImpl { private: bool m_include_arguments : 1; - bool m_include_recognized_arguments : 1; bool m_include_locals : 1; bool m_include_statics : 1; bool m_in_scope_only : 1; bool m_include_runtime_support_values : 1; + LazyBool m_include_recognized_arguments; // can be overridden with a setting lldb::DynamicValueType m_use_dynamic; }; @@ -87,9 +93,7 @@ operator=(const SBVariablesOptions &options) { SBVariablesOptions::~SBVariablesOptions() = default; -bool SBVariablesOptions::IsValid() const { - return m_opaque_ap.get() != nullptr; -} +bool SBVariablesOptions::IsValid() const { return m_opaque_ap != nullptr; } bool SBVariablesOptions::GetIncludeArguments() const { return m_opaque_ap->GetIncludeArguments(); @@ -99,8 +103,9 @@ void SBVariablesOptions::SetIncludeArguments(bool arguments) { m_opaque_ap->SetIncludeArguments(arguments); } -bool SBVariablesOptions::GetIncludeRecognizedArguments() const { - return m_opaque_ap->GetIncludeRecognizedArguments(); +bool SBVariablesOptions::GetIncludeRecognizedArguments( + const lldb::SBTarget &target) const { + return m_opaque_ap->GetIncludeRecognizedArguments(target.GetSP()); } void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { diff --git a/source/API/SBWatchpoint.cpp b/source/API/SBWatchpoint.cpp index b7755373abc9..563123734ed1 100644 --- a/source/API/SBWatchpoint.cpp +++ b/source/API/SBWatchpoint.cpp @@ -1,9 +1,8 @@ //===-- SBWatchpoint.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp index c2f15c6a8049..63f7c821f1f7 100644 --- a/source/API/SystemInitializerFull.cpp +++ b/source/API/SystemInitializerFull.cpp @@ -1,9 +1,8 @@ //===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -41,6 +40,7 @@ #include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/Architecture/Arm/ArchitectureArm.h" +#include "Plugins/Architecture/Mips/ArchitectureMips.h" #include "Plugins/Architecture/PPC64/ArchitecturePPC64.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h" @@ -64,6 +64,7 @@ #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" +#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h" #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" @@ -83,6 +84,7 @@ #include "Plugins/Process/mach-core/ProcessMachCore.h" #include "Plugins/Process/minidump/ProcessMinidump.h" #include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h" +#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" @@ -188,6 +190,18 @@ extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver( lldb_private::SymbolContext *sym_ctx ); +extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver( + const char *python_class_name, + const char *session_dictionary_name, + lldb_private::StructuredDataImpl *args, + lldb::BreakpointSP &bkpt_sp); + +extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver( + void *implementor, + const char *method_name, + lldb_private::SymbolContext *sym_ctx +); + extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor, uint32_t max); @@ -284,9 +298,12 @@ static void SwiftTerminate() { #endif } -void SystemInitializerFull::Initialize() { - SystemInitializerCommon::Initialize(); +llvm::Error +SystemInitializerFull::Initialize(const InitializerOptions &options) { + if (auto e = SystemInitializerCommon::Initialize(options)) + return e; + breakpad::ObjectFileBreakpad::Initialize(); ObjectFileELF::Initialize(); ObjectFileMachO::Initialize(); ObjectFilePECOFF::Initialize(); @@ -344,6 +361,7 @@ void SystemInitializerFull::Initialize() { ABISysV_s390x::Initialize(); ArchitectureArm::Initialize(); + ArchitectureMips::Initialize(); ArchitecturePPC64::Initialize(); DisassemblerLLVMC::Initialize(); @@ -360,6 +378,7 @@ void SystemInitializerFull::Initialize() { SwiftRuntimeReporting::Initialize(); SymbolVendorELF::Initialize(); + breakpad::SymbolFileBreakpad::Initialize(); SymbolFileDWARF::Initialize(); SymbolFilePDB::Initialize(); SymbolFileSymtab::Initialize(); @@ -420,6 +439,8 @@ void SystemInitializerFull::Initialize() { // AFTER PluginManager::Initialize is called. Debugger::SettingsInitialize(); + + return llvm::Error::success(); } void SystemInitializerFull::InitializeSWIG() { @@ -459,6 +480,10 @@ void SystemInitializerFull::Terminate() { ClangASTContext::Terminate(); SwiftASTContext::Terminate(); + ArchitectureArm::Terminate(); + ArchitectureMips::Terminate(); + ArchitecturePPC64::Terminate(); + ABIMacOSX_i386::Terminate(); ABIMacOSX_arm::Terminate(); ABIMacOSX_arm64::Terminate(); @@ -485,6 +510,7 @@ void SystemInitializerFull::Terminate() { MainThreadCheckerRuntime::Terminate(); SwiftRuntimeReporting::Terminate(); SymbolVendorELF::Terminate(); + breakpad::SymbolFileBreakpad::Terminate(); SymbolFileDWARF::Terminate(); SymbolFilePDB::Terminate(); SymbolFileSymtab::Terminate(); @@ -549,6 +575,7 @@ void SystemInitializerFull::Terminate() { PlatformDarwinKernel::Terminate(); #endif + breakpad::ObjectFileBreakpad::Terminate(); ObjectFileELF::Terminate(); ObjectFileMachO::Terminate(); ObjectFilePECOFF::Terminate(); diff --git a/source/API/SystemInitializerFull.h b/source/API/SystemInitializerFull.h index 9cfc6896da61..cfeb821b45c5 100644 --- a/source/API/SystemInitializerFull.h +++ b/source/API/SystemInitializerFull.h @@ -1,9 +1,8 @@ //===-- SystemInitializerFull.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,7 +25,7 @@ class SystemInitializerFull : public SystemInitializerCommon { SystemInitializerFull(); ~SystemInitializerFull() override; - void Initialize() override; + llvm::Error Initialize(const InitializerOptions &options) override; void Terminate() override; private: diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp index 53dd15411079..38708e89ea05 100644 --- a/source/Breakpoint/Breakpoint.cpp +++ b/source/Breakpoint/Breakpoint.cpp @@ -1,18 +1,13 @@ //===-- Breakpoint.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" @@ -785,8 +780,8 @@ void Breakpoint::ModuleReplaced(ModuleSP old_module_sp, // we go. if (old_id_vec.size() == new_id_vec.size()) { - llvm::sort(old_id_vec.begin(), old_id_vec.end()); - llvm::sort(new_id_vec.begin(), new_id_vec.end()); + llvm::sort(old_id_vec); + llvm::sort(new_id_vec); size_t num_elements = old_id_vec.size(); for (size_t idx = 0; idx < num_elements; idx++) { BreakpointLocationSP old_loc_sp = diff --git a/source/Breakpoint/BreakpointID.cpp b/source/Breakpoint/BreakpointID.cpp index 3f72f2052b52..dc2e57cb085d 100644 --- a/source/Breakpoint/BreakpointID.cpp +++ b/source/Breakpoint/BreakpointID.cpp @@ -1,18 +1,13 @@ //===-- BreakpointID.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Utility/Status.h" diff --git a/source/Breakpoint/BreakpointIDList.cpp b/source/Breakpoint/BreakpointIDList.cpp index bc4c2a111fd4..d86e238772e6 100644 --- a/source/Breakpoint/BreakpointIDList.cpp +++ b/source/Breakpoint/BreakpointIDList.cpp @@ -1,16 +1,11 @@ //===-- BreakpointIDList.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/Breakpoint/BreakpointIDList.h" diff --git a/source/Breakpoint/BreakpointList.cpp b/source/Breakpoint/BreakpointList.cpp index 4a49b1e105ab..c80fb917b490 100644 --- a/source/Breakpoint/BreakpointList.cpp +++ b/source/Breakpoint/BreakpointList.cpp @@ -1,23 +1,25 @@ //===-- BreakpointList.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointList.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; +static void NotifyChange(const BreakpointSP &bp, BreakpointEventType event) { + Target &target = bp->GetTarget(); + if (target.EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) + target.BroadcastEvent(Target::eBroadcastBitBreakpointChanged, + new Breakpoint::BreakpointEventData(event, bp)); +} + BreakpointList::BreakpointList(bool is_internal) : m_mutex(), m_breakpoints(), m_next_break_id(0), m_is_internal(is_internal) {} @@ -26,37 +28,34 @@ BreakpointList::~BreakpointList() {} break_id_t BreakpointList::Add(BreakpointSP &bp_sp, bool notify) { std::lock_guard guard(m_mutex); + // Internal breakpoint IDs are negative, normal ones are positive bp_sp->SetID(m_is_internal ? --m_next_break_id : ++m_next_break_id); m_breakpoints.push_back(bp_sp); - if (notify) { - if (bp_sp->GetTarget().EventTypeHasListeners( - Target::eBroadcastBitBreakpointChanged)) - bp_sp->GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, - new Breakpoint::BreakpointEventData( - eBreakpointEventTypeAdded, bp_sp)); - } + + if (notify) + NotifyChange(bp_sp, eBreakpointEventTypeAdded); + return bp_sp->GetID(); } bool BreakpointList::Remove(break_id_t break_id, bool notify) { std::lock_guard guard(m_mutex); - bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate - if (pos != m_breakpoints.end()) { - BreakpointSP bp_sp(*pos); - m_breakpoints.erase(pos); - if (notify) { - if (bp_sp->GetTarget().EventTypeHasListeners( - Target::eBroadcastBitBreakpointChanged)) - bp_sp->GetTarget().BroadcastEvent( - Target::eBroadcastBitBreakpointChanged, - new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved, - bp_sp)); - } - return true; - } - return false; + + auto it = std::find_if( + m_breakpoints.begin(), m_breakpoints.end(), + [&](const BreakpointSP &bp) { return bp->GetID() == break_id; }); + + if (it == m_breakpoints.end()) + return false; + + if (notify) + NotifyChange(*it, eBreakpointEventTypeRemoved); + + m_breakpoints.erase(it); + + return true; } void BreakpointList::RemoveInvalidLocations(const ArchSpec &arch) { @@ -83,93 +82,50 @@ void BreakpointList::RemoveAll(bool notify) { ClearAllBreakpointSites(); if (notify) { - bp_collection::iterator pos, end = m_breakpoints.end(); - for (pos = m_breakpoints.begin(); pos != end; ++pos) { - if ((*pos)->GetTarget().EventTypeHasListeners( - Target::eBroadcastBitBreakpointChanged)) { - (*pos)->GetTarget().BroadcastEvent( - Target::eBroadcastBitBreakpointChanged, - new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved, - *pos)); - } - } + for (const auto &bp_sp : m_breakpoints) + NotifyChange(bp_sp, eBreakpointEventTypeRemoved); } - m_breakpoints.erase(m_breakpoints.begin(), m_breakpoints.end()); + + m_breakpoints.clear(); } void BreakpointList::RemoveAllowed(bool notify) { std::lock_guard guard(m_mutex); - bp_collection::iterator pos, end = m_breakpoints.end(); - if (notify) { - for (pos = m_breakpoints.begin(); pos != end; ++pos) { - if(!(*pos)->AllowDelete()) - continue; - if ((*pos)->GetTarget().EventTypeHasListeners( - Target::eBroadcastBitBreakpointChanged)) { - (*pos)->GetTarget().BroadcastEvent( - Target::eBroadcastBitBreakpointChanged, - new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved, - *pos)); - } - } - } - pos = m_breakpoints.begin(); - while ( pos != end) { - auto bp = *pos; - if (bp->AllowDelete()) { - bp->ClearAllBreakpointSites(); - pos = m_breakpoints.erase(pos); - } else - pos++; + for (const auto &bp_sp : m_breakpoints) { + if (bp_sp->AllowDelete()) + bp_sp->ClearAllBreakpointSites(); + if (notify) + NotifyChange(bp_sp, eBreakpointEventTypeRemoved); } -} - -class BreakpointIDMatches { -public: - BreakpointIDMatches(break_id_t break_id) : m_break_id(break_id) {} - bool operator()(const BreakpointSP &bp) const { - return m_break_id == bp->GetID(); - } - -private: - const break_id_t m_break_id; -}; + m_breakpoints.erase( + std::remove_if(m_breakpoints.begin(), m_breakpoints.end(), + [&](const BreakpointSP &bp) { return bp->AllowDelete(); }), + m_breakpoints.end()); +} BreakpointList::bp_collection::iterator BreakpointList::GetBreakpointIDIterator(break_id_t break_id) { - return std::find_if(m_breakpoints.begin(), - m_breakpoints.end(), // Search full range - BreakpointIDMatches(break_id)); // Predicate + return std::find_if( + m_breakpoints.begin(), m_breakpoints.end(), + [&](const BreakpointSP &bp) { return bp->GetID() == break_id; }); } BreakpointList::bp_collection::const_iterator BreakpointList::GetBreakpointIDConstIterator(break_id_t break_id) const { - return std::find_if(m_breakpoints.begin(), - m_breakpoints.end(), // Search full range - BreakpointIDMatches(break_id)); // Predicate -} - -BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) { - std::lock_guard guard(m_mutex); - BreakpointSP stop_sp; - bp_collection::iterator pos = GetBreakpointIDIterator(break_id); - if (pos != m_breakpoints.end()) - stop_sp = *pos; - - return stop_sp; + return std::find_if( + m_breakpoints.begin(), m_breakpoints.end(), + [&](const BreakpointSP &bp) { return bp->GetID() == break_id; }); } -const BreakpointSP -BreakpointList::FindBreakpointByID(break_id_t break_id) const { +BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) const { std::lock_guard guard(m_mutex); - BreakpointSP stop_sp; - bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id); - if (pos != m_breakpoints.end()) - stop_sp = *pos; - return stop_sp; + auto it = GetBreakpointIDConstIterator(break_id); + if (it != m_breakpoints.end()) + return *it; + return {}; } bool BreakpointList::FindBreakpointsByName(const char *name, @@ -186,6 +142,7 @@ bool BreakpointList::FindBreakpointsByName(const char *name, matching_bps.Add(bkpt_sp, false); } } + return true; } @@ -201,30 +158,11 @@ void BreakpointList::Dump(Stream *s) const { s->IndentLess(); } -BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) { +BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) const { std::lock_guard guard(m_mutex); - BreakpointSP stop_sp; - bp_collection::iterator end = m_breakpoints.end(); - bp_collection::iterator pos; - size_t curr_i = 0; - for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i) { - if (curr_i == i) - stop_sp = *pos; - } - return stop_sp; -} - -const BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) const { - std::lock_guard guard(m_mutex); - BreakpointSP stop_sp; - bp_collection::const_iterator end = m_breakpoints.end(); - bp_collection::const_iterator pos; - size_t curr_i = 0; - for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i) { - if (curr_i == i) - stop_sp = *pos; - } - return stop_sp; + if (i < m_breakpoints.size()) + return m_breakpoints[i]; + return {}; } void BreakpointList::UpdateBreakpoints(ModuleList &module_list, bool added, diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp index ecb5728cbf4a..c1f4390faa68 100644 --- a/source/Breakpoint/BreakpointLocation.cpp +++ b/source/Breakpoint/BreakpointLocation.cpp @@ -1,16 +1,11 @@ //===-- BreakpointLocation.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -460,13 +455,11 @@ bool BreakpointLocation::ResolveBreakpointSite() { if (new_id == LLDB_INVALID_BREAK_ID) { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS); if (log) - log->Warning("Tried to add breakpoint site at 0x%" PRIx64 - " but it was already present.\n", + log->Warning("Failed to add breakpoint site at 0x%" PRIx64, m_address.GetOpcodeLoadAddress(&m_owner.GetTarget())); - return false; } - return true; + return IsResolved(); } bool BreakpointLocation::SetBreakpointSite(BreakpointSiteSP &bp_site_sp) { diff --git a/source/Breakpoint/BreakpointLocationCollection.cpp b/source/Breakpoint/BreakpointLocationCollection.cpp index 6536002bda67..8ca6d2f2a675 100644 --- a/source/Breakpoint/BreakpointLocationCollection.cpp +++ b/source/Breakpoint/BreakpointLocationCollection.cpp @@ -1,16 +1,11 @@ //===-- BreakpointLocationCollection.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" diff --git a/source/Breakpoint/BreakpointLocationList.cpp b/source/Breakpoint/BreakpointLocationList.cpp index 23ca89da6ce1..577dcdf808a5 100644 --- a/source/Breakpoint/BreakpointLocationList.cpp +++ b/source/Breakpoint/BreakpointLocationList.cpp @@ -1,16 +1,11 @@ //===-- BreakpointLocationList.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocationList.h" #include "lldb/Breakpoint/Breakpoint.h" diff --git a/source/Breakpoint/BreakpointName.cpp b/source/Breakpoint/BreakpointName.cpp index be4710d7849c..46d877c2f0d3 100644 --- a/source/Breakpoint/BreakpointName.cpp +++ b/source/Breakpoint/BreakpointName.cpp @@ -1,18 +1,13 @@ //===-- Breakpoint.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details-> +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp index b5869fc34dfc..6467d261961b 100644 --- a/source/Breakpoint/BreakpointOptions.cpp +++ b/source/Breakpoint/BreakpointOptions.cpp @@ -1,16 +1,11 @@ //===-- BreakpointOptions.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" diff --git a/source/Breakpoint/BreakpointResolver.cpp b/source/Breakpoint/BreakpointResolver.cpp index 61a204aff94c..53131ff27341 100644 --- a/source/Breakpoint/BreakpointResolver.cpp +++ b/source/Breakpoint/BreakpointResolver.cpp @@ -1,18 +1,13 @@ //===-- BreakpointResolver.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointResolver.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" // Have to include the other breakpoint resolver types here so the static @@ -242,10 +237,10 @@ void BreakpointResolver::SetSCMatchesByLine(SearchFilter &filter, worklist_begin, worklist_end, [&](const SymbolContext &sc) { return SourceLoc(sc) < requested; }); // Sort the remaining entries by (line, column). - std::sort(worklist_begin, worklist_end, - [](const SymbolContext &a, const SymbolContext &b) { - return SourceLoc(a) < SourceLoc(b); - }); + llvm::sort(worklist_begin, worklist_end, + [](const SymbolContext &a, const SymbolContext &b) { + return SourceLoc(a) < SourceLoc(b); + }); // Filter out all locations with a source location after the closest match. if (worklist_begin != worklist_end) @@ -265,11 +260,11 @@ void BreakpointResolver::SetSCMatchesByLine(SearchFilter &filter, } // Sort by file address. - std::sort(worklist_begin, worklist_end, - [](const SymbolContext &a, const SymbolContext &b) { - return a.line_entry.range.GetBaseAddress().GetFileAddress() < - b.line_entry.range.GetBaseAddress().GetFileAddress(); - }); + llvm::sort(worklist_begin, worklist_end, + [](const SymbolContext &a, const SymbolContext &b) { + return a.line_entry.range.GetBaseAddress().GetFileAddress() < + b.line_entry.range.GetBaseAddress().GetFileAddress(); + }); // Go through and see if there are line table entries that are // contiguous, and if so keep only the first of the contiguous range. diff --git a/source/Breakpoint/BreakpointResolverAddress.cpp b/source/Breakpoint/BreakpointResolverAddress.cpp index 194a7d1c7da6..09ad45d3396f 100644 --- a/source/Breakpoint/BreakpointResolverAddress.cpp +++ b/source/Breakpoint/BreakpointResolverAddress.cpp @@ -1,18 +1,13 @@ //===-- BreakpointResolverAddress.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointResolverAddress.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" @@ -66,7 +61,7 @@ BreakpointResolver *BreakpointResolverAddress::CreateFromStructuredData( error.SetErrorString("BRA::CFSD: Couldn't read module name entry."); return nullptr; } - module_filespec.SetFile(module_name, false, FileSpec::Style::native); + module_filespec.SetFile(module_name, FileSpec::Style::native); } return new BreakpointResolverAddress(bkpt, address, module_filespec); } diff --git a/source/Breakpoint/BreakpointResolverFileLine.cpp b/source/Breakpoint/BreakpointResolverFileLine.cpp index dab57c1b8fcf..e82f6a92f5c5 100644 --- a/source/Breakpoint/BreakpointResolverFileLine.cpp +++ b/source/Breakpoint/BreakpointResolverFileLine.cpp @@ -1,18 +1,13 @@ //===-- BreakpointResolverFileLine.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointResolverFileLine.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/CompileUnit.h" @@ -93,7 +88,7 @@ BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData( return nullptr; } - FileSpec file_spec(filename, false); + FileSpec file_spec(filename); return new BreakpointResolverFileLine(bkpt, file_spec, line_no, column, offset, check_inlines, skip_prologue, @@ -193,8 +188,12 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list, // inline int foo2() { ... } // // but that's the best we can do for now. + // One complication, if the line number returned from GetStartLineSourceInfo + // is 0, then we can't do this calculation. That can happen if + // GetStartLineSourceInfo gets an error, or if the first line number in + // the function really is 0 - which happens for some languages. const int decl_line_is_too_late_fudge = 1; - if (m_line_number < line - decl_line_is_too_late_fudge) { + if (line && m_line_number < line - decl_line_is_too_late_fudge) { LLDB_LOG(log, "removing symbol context at {0}:{1}", file, line); sc_list.RemoveContextAtIndex(i); --i; diff --git a/source/Breakpoint/BreakpointResolverFileRegex.cpp b/source/Breakpoint/BreakpointResolverFileRegex.cpp index 8a15f8ec7e47..583a7093af5a 100644 --- a/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -1,18 +1,13 @@ //===-- BreakpointResolverFileRegex.cpp -------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/SourceManager.h" #include "lldb/Symbol/CompileUnit.h" diff --git a/source/Breakpoint/BreakpointResolverName.cpp b/source/Breakpoint/BreakpointResolverName.cpp index 762ad11be0e8..cae939bdbbfe 100644 --- a/source/Breakpoint/BreakpointResolverName.cpp +++ b/source/Breakpoint/BreakpointResolverName.cpp @@ -1,16 +1,11 @@ //===-- BreakpointResolverName.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolverName.h" #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" @@ -31,7 +26,7 @@ using namespace lldb; using namespace lldb_private; BreakpointResolverName::BreakpointResolverName( - Breakpoint *bkpt, const char *name_cstr, uint32_t name_type_mask, + Breakpoint *bkpt, const char *name_cstr, FunctionNameType name_type_mask, LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue) : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset), @@ -52,7 +47,7 @@ BreakpointResolverName::BreakpointResolverName( BreakpointResolverName::BreakpointResolverName( Breakpoint *bkpt, const char *names[], size_t num_names, - uint32_t name_type_mask, LanguageType language, lldb::addr_t offset, + FunctionNameType name_type_mask, LanguageType language, lldb::addr_t offset, bool skip_prologue) : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset), m_match_type(Breakpoint::Exact), m_language(language), @@ -62,9 +57,12 @@ BreakpointResolverName::BreakpointResolverName( } } -BreakpointResolverName::BreakpointResolverName( - Breakpoint *bkpt, std::vector names, uint32_t name_type_mask, - LanguageType language, lldb::addr_t offset, bool skip_prologue) +BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt, + std::vector names, + FunctionNameType name_type_mask, + LanguageType language, + lldb::addr_t offset, + bool skip_prologue) : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset), m_match_type(Breakpoint::Exact), m_language(language), m_skip_prologue(skip_prologue) { @@ -162,9 +160,8 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData( return nullptr; } std::vector names; - std::vector name_masks; + std::vector name_masks; for (size_t i = 0; i < num_elem; i++) { - uint32_t name_mask; llvm::StringRef name; success = names_array->GetItemAtIndexAsString(i, name); @@ -172,13 +169,14 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData( error.SetErrorString("BRN::CFSD: name entry is not a string."); return nullptr; } - success = names_mask_array->GetItemAtIndexAsInteger(i, name_mask); + std::underlying_type::type fnt; + success = names_mask_array->GetItemAtIndexAsInteger(i, fnt); if (!success) { error.SetErrorString("BRN::CFSD: name mask entry is not an integer."); return nullptr; } names.push_back(name); - name_masks.push_back(name_mask); + name_masks.push_back(static_cast(fnt)); } BreakpointResolverName *resolver = new BreakpointResolverName( @@ -221,7 +219,7 @@ StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() { } void BreakpointResolverName::AddNameLookup(const ConstString &name, - uint32_t name_type_mask) { + FunctionNameType name_type_mask) { ObjCLanguage::MethodName objc_method(name.GetCString(), false); if (objc_method.IsValid(false)) { std::vector objc_names; diff --git a/source/Breakpoint/BreakpointResolverScripted.cpp b/source/Breakpoint/BreakpointResolverScripted.cpp index 7a8a29cedba8..330cee8711dc 100644 --- a/source/Breakpoint/BreakpointResolverScripted.cpp +++ b/source/Breakpoint/BreakpointResolverScripted.cpp @@ -1,18 +1,13 @@ //===-- BreakpointResolverScripted.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointResolverScripted.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" diff --git a/source/Breakpoint/BreakpointSite.cpp b/source/Breakpoint/BreakpointSite.cpp index a5c5136eb7a6..8151f3008c8c 100644 --- a/source/Breakpoint/BreakpointSite.cpp +++ b/source/Breakpoint/BreakpointSite.cpp @@ -1,18 +1,13 @@ //===-- BreakpointSite.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Breakpoint/Breakpoint.h" diff --git a/source/Breakpoint/BreakpointSiteList.cpp b/source/Breakpoint/BreakpointSiteList.cpp index 9bb9aa366106..579c933d99fd 100644 --- a/source/Breakpoint/BreakpointSiteList.cpp +++ b/source/Breakpoint/BreakpointSiteList.cpp @@ -1,18 +1,13 @@ //===-- BreakpointSiteList.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/BreakpointSiteList.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Stream.h" #include diff --git a/source/Breakpoint/Stoppoint.cpp b/source/Breakpoint/Stoppoint.cpp index dbc832b4307a..681877efed18 100644 --- a/source/Breakpoint/Stoppoint.cpp +++ b/source/Breakpoint/Stoppoint.cpp @@ -1,19 +1,14 @@ //===-- Stoppoint.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/Stoppoint.h" #include "lldb/lldb-private.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; diff --git a/source/Breakpoint/StoppointCallbackContext.cpp b/source/Breakpoint/StoppointCallbackContext.cpp index 3d24eb78c455..584bf0060a4a 100644 --- a/source/Breakpoint/StoppointCallbackContext.cpp +++ b/source/Breakpoint/StoppointCallbackContext.cpp @@ -1,16 +1,11 @@ //===-- StoppointCallbackContext.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/StoppointCallbackContext.h" using namespace lldb_private; diff --git a/source/Breakpoint/StoppointLocation.cpp b/source/Breakpoint/StoppointLocation.cpp index d624ddbfa519..a7f4aab8e433 100644 --- a/source/Breakpoint/StoppointLocation.cpp +++ b/source/Breakpoint/StoppointLocation.cpp @@ -1,18 +1,13 @@ //===-- StoppointLocation.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Breakpoint/StoppointLocation.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; diff --git a/source/Breakpoint/Watchpoint.cpp b/source/Breakpoint/Watchpoint.cpp index 820b953947d9..00a471dc1763 100644 --- a/source/Breakpoint/Watchpoint.cpp +++ b/source/Breakpoint/Watchpoint.cpp @@ -1,16 +1,11 @@ //===-- Watchpoint.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -135,10 +130,7 @@ void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() { bool Watchpoint::ShouldStop(StoppointCallbackContext *context) { IncrementHitCount(); - if (!IsEnabled()) - return false; - - return true; + return IsEnabled(); } void Watchpoint::GetDescription(Stream *s, lldb::DescriptionLevel level) { diff --git a/source/Breakpoint/WatchpointList.cpp b/source/Breakpoint/WatchpointList.cpp index 6497780084d9..b1c1e6f253eb 100644 --- a/source/Breakpoint/WatchpointList.cpp +++ b/source/Breakpoint/WatchpointList.cpp @@ -1,16 +1,11 @@ //===-- WatchpointList.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Breakpoint/Watchpoint.h" diff --git a/source/Breakpoint/WatchpointOptions.cpp b/source/Breakpoint/WatchpointOptions.cpp index 402fee943a02..1898486221bb 100644 --- a/source/Breakpoint/WatchpointOptions.cpp +++ b/source/Breakpoint/WatchpointOptions.cpp @@ -1,16 +1,11 @@ //===-- WatchpointOptions.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/WatchpointOptions.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" diff --git a/source/Commands/CMakeLists.txt b/source/Commands/CMakeLists.txt index 2319c5e432e4..da57ad6404ec 100644 --- a/source/Commands/CMakeLists.txt +++ b/source/Commands/CMakeLists.txt @@ -18,6 +18,7 @@ add_lldb_library(lldbCommands CommandObjectProcess.cpp CommandObjectQuit.cpp CommandObjectRegister.cpp + CommandObjectReproducer.cpp CommandObjectSettings.cpp CommandObjectSource.cpp CommandObjectStats.cpp diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp index fbc9a33f5013..4add5446e789 100644 --- a/source/Commands/CommandCompletions.cpp +++ b/source/Commands/CommandCompletions.cpp @@ -1,24 +1,19 @@ //===-- CommandCompletions.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #if defined(__APPLE__) || defined(__linux__) #include #endif -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSet.h" -// Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" @@ -105,7 +100,6 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, if (CompletionBuffer.size() >= PATH_MAX) return matches.GetSize(); - namespace fs = llvm::sys::fs; namespace path = llvm::sys::path; llvm::StringRef SearchDir; @@ -121,7 +115,7 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, if (FirstSep != llvm::StringRef::npos) Remainder = Buffer.drop_front(FirstSep + 1); - llvm::SmallString Resolved; + llvm::SmallString<256> Resolved; if (!Resolver.ResolveExact(Username, Resolved)) { // We couldn't resolve it as a full username. If there were no slashes // then this might be a partial username. We try to resolve it as such @@ -182,11 +176,16 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, // SearchDir now contains the directory to search in, and Prefix contains the // text we want to match against items in that directory. + FileSystem &fs = FileSystem::Instance(); std::error_code EC; - fs::directory_iterator Iter(SearchDir, EC, false); - fs::directory_iterator End; + llvm::vfs::directory_iterator Iter = fs.DirBegin(SearchDir, EC); + llvm::vfs::directory_iterator End; for (; Iter != End && !EC; Iter.increment(EC)) { auto &Entry = *Iter; + llvm::ErrorOr Status = fs.GetStatus(Entry.path()); + + if (!Status) + continue; auto Name = path::filename(Entry.path()); @@ -194,20 +193,18 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name, if (Name == "." || Name == ".." || !Name.startswith(PartialItem)) continue; - // We have a match. - - llvm::ErrorOr st = Entry.status(); - if (!st) - continue; + bool is_dir = Status->isDirectory(); // If it's a symlink, then we treat it as a directory as long as the target // is a directory. - bool is_dir = fs::is_directory(*st); - if (fs::is_symlink_file(*st)) { - fs::file_status target_st; - if (!fs::status(Entry.path(), target_st)) - is_dir = fs::is_directory(target_st); + if (Status->isSymlink()) { + FileSpec symlink_filespec(Entry.path()); + FileSpec resolved_filespec; + auto error = fs.ResolveSymbolicLink(symlink_filespec, resolved_filespec); + if (error.Success()) + is_dir = fs.IsDirectory(symlink_filespec); } + if (only_directories && !is_dir) continue; @@ -361,7 +358,7 @@ CommandCompletions::SourceFileCompleter::SourceFileCompleter( CompletionRequest &request) : CommandCompletions::Completer(interpreter, request), m_include_support_files(include_support_files), m_matching_files() { - FileSpec partial_spec(m_request.GetCursorArgumentPrefix(), false); + FileSpec partial_spec(m_request.GetCursorArgumentPrefix()); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } @@ -501,7 +498,7 @@ size_t CommandCompletions::SymbolCompleter::DoCompletion(SearchFilter *filter) { CommandCompletions::ModuleCompleter::ModuleCompleter( CommandInterpreter &interpreter, CompletionRequest &request) : CommandCompletions::Completer(interpreter, request) { - FileSpec partial_spec(m_request.GetCursorArgumentPrefix(), false); + FileSpec partial_spec(m_request.GetCursorArgumentPrefix()); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } diff --git a/source/Commands/CommandObjectApropos.cpp b/source/Commands/CommandObjectApropos.cpp index 047575278faa..eba052df392a 100644 --- a/source/Commands/CommandObjectApropos.cpp +++ b/source/Commands/CommandObjectApropos.cpp @@ -1,17 +1,12 @@ //===-- CommandObjectApropos.cpp ---------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectApropos.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" diff --git a/source/Commands/CommandObjectApropos.h b/source/Commands/CommandObjectApropos.h index 5cad40d5c62d..e64de2276491 100644 --- a/source/Commands/CommandObjectApropos.h +++ b/source/Commands/CommandObjectApropos.h @@ -1,20 +1,15 @@ //===-- CommandObjectApropos.h -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectApropos_h_ #define liblldb_CommandObjectApropos_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp index 6e673bdf830f..593b95938ab6 100644 --- a/source/Commands/CommandObjectBreakpoint.cpp +++ b/source/Commands/CommandObjectBreakpoint.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "CommandObjectBreakpoint.h" #include "CommandObjectBreakpointCommand.h" #include "lldb/Breakpoint/Breakpoint.h" @@ -441,7 +436,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { } break; case 'f': - m_filenames.AppendIfUnique(FileSpec(option_arg, false)); + m_filenames.AppendIfUnique(FileSpec(option_arg)); break; case 'F': @@ -560,7 +555,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { break; case 's': - m_modules.AppendIfUnique(FileSpec(option_arg, false)); + m_modules.AppendIfUnique(FileSpec(option_arg)); break; case 'S': @@ -640,7 +635,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { uint32_t m_column; std::vector m_func_names; std::vector m_breakpoint_names; - uint32_t m_func_name_type_mask; + lldb::FunctionNameType m_func_name_type_mask; std::string m_func_regexp; std::string m_source_text_regexp; FileSpecList m_modules; @@ -769,7 +764,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { } case eSetTypeFunctionName: // Breakpoint by function name { - uint32_t name_type_mask = m_options.m_func_name_type_mask; + FunctionNameType name_type_mask = m_options.m_func_name_type_mask; if (name_type_mask == 0) name_type_mask = eFunctionNameTypeAuto; @@ -2374,7 +2369,8 @@ class CommandObjectBreakpointRead : public CommandObjectParsed { std::unique_lock lock; target->GetBreakpointList().GetListMutex(lock); - FileSpec input_spec(m_options.m_filename, true); + FileSpec input_spec(m_options.m_filename); + FileSystem::Instance().Resolve(input_spec); BreakpointIDList new_bps; Status error = target->CreateBreakpointsFromFile( input_spec, m_options.m_names, new_bps); @@ -2508,8 +2504,10 @@ class CommandObjectBreakpointWrite : public CommandObjectParsed { return false; } } - Status error = target->SerializeBreakpointsToFile( - FileSpec(m_options.m_filename, true), valid_bp_ids, m_options.m_append); + FileSpec file_spec(m_options.m_filename); + FileSystem::Instance().Resolve(file_spec); + Status error = target->SerializeBreakpointsToFile(file_spec, valid_bp_ids, + m_options.m_append); if (!error.Success()) { result.AppendErrorWithFormat("error serializing breakpoints: %s.", error.AsCString()); diff --git a/source/Commands/CommandObjectBreakpoint.h b/source/Commands/CommandObjectBreakpoint.h index 5e1026a6b7ea..c58a3c9a3832 100644 --- a/source/Commands/CommandObjectBreakpoint.h +++ b/source/Commands/CommandObjectBreakpoint.h @@ -1,23 +1,18 @@ //===-- CommandObjectBreakpoint.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectBreakpoint_h_ #define liblldb_CommandObjectBreakpoint_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/BreakpointName.h" #include "lldb/Core/Address.h" diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp index 5b3f7bf09d81..d445cb94c40e 100644 --- a/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/source/Commands/CommandObjectBreakpointCommand.cpp @@ -1,16 +1,11 @@ //===-- CommandObjectBreakpointCommand.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectBreakpointCommand.h" #include "CommandObjectBreakpoint.h" #include "lldb/Breakpoint/Breakpoint.h" @@ -18,13 +13,13 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/State.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/STLExtras.h" diff --git a/source/Commands/CommandObjectBreakpointCommand.h b/source/Commands/CommandObjectBreakpointCommand.h index 048cc5e07c1b..928088928e9e 100644 --- a/source/Commands/CommandObjectBreakpointCommand.h +++ b/source/Commands/CommandObjectBreakpointCommand.h @@ -1,20 +1,15 @@ //===-- CommandObjectBreakpointCommand.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectBreakpointCommand_h_ #define liblldb_CommandObjectBreakpointCommand_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" diff --git a/source/Commands/CommandObjectBugreport.cpp b/source/Commands/CommandObjectBugreport.cpp index 7ba8ab945eae..511af7cabadf 100644 --- a/source/Commands/CommandObjectBugreport.cpp +++ b/source/Commands/CommandObjectBugreport.cpp @@ -1,21 +1,16 @@ //===-- CommandObjectBugreport.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectBugreport.h" -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionGroupOutputFile.h" @@ -72,8 +67,6 @@ class CommandObjectBugreportUnwind : public CommandObjectParsed { const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue(); if (outfile_spec) { - char path[PATH_MAX]; - outfile_spec.GetPath(path, sizeof(path)); uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate | @@ -84,10 +77,13 @@ class CommandObjectBugreportUnwind : public CommandObjectParsed { open_options |= File::eOpenOptionTruncate; StreamFileSP outfile_stream = std::make_shared(); - Status error = outfile_stream->GetFile().Open(path, open_options); + File &file = outfile_stream->GetFile(); + Status error = + FileSystem::Instance().Open(file, outfile_spec, open_options); if (error.Fail()) { + auto path = outfile_spec.GetPath(); result.AppendErrorWithFormat("Failed to open file '%s' for %s: %s\n", - path, append ? "append" : "write", + path.c_str(), append ? "append" : "write", error.AsCString()); result.SetStatus(eReturnStatusFailed); return false; diff --git a/source/Commands/CommandObjectBugreport.h b/source/Commands/CommandObjectBugreport.h index 281ea2dd203e..2615bcbc285c 100644 --- a/source/Commands/CommandObjectBugreport.h +++ b/source/Commands/CommandObjectBugreport.h @@ -1,19 +1,14 @@ //===-- CommandObjectBugreport.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectBugreport_h_ #define liblldb_CommandObjectBugreport_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp index fbb9f03ab9a3..caf4cc8d1540 100644 --- a/source/Commands/CommandObjectCommands.cpp +++ b/source/Commands/CommandObjectCommands.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectCommands.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "CommandObjectCommands.h" #include "CommandObjectHelp.h" #include "lldb/Core/Debugger.h" @@ -308,7 +303,8 @@ class CommandObjectCommandsSource : public CommandObjectParsed { return false; } - FileSpec cmd_file(command[0].ref, true); + FileSpec cmd_file(command[0].ref); + FileSystem::Instance().Resolve(cmd_file); ExecutionContext *exe_ctx = nullptr; // Just use the default context. // If any options were set, then use them diff --git a/source/Commands/CommandObjectCommands.h b/source/Commands/CommandObjectCommands.h index a5ef777aa982..f7be73de2d1b 100644 --- a/source/Commands/CommandObjectCommands.h +++ b/source/Commands/CommandObjectCommands.h @@ -1,20 +1,15 @@ //===-- CommandObjectCommands.h -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectCommands_h_ #define liblldb_CommandObjectCommands_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/STLUtils.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp index 739cc12c1377..73adbc7b7ee5 100644 --- a/source/Commands/CommandObjectDisassemble.cpp +++ b/source/Commands/CommandObjectDisassemble.cpp @@ -1,16 +1,11 @@ //===-- CommandObjectDisassemble.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectDisassemble.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Disassembler.h" diff --git a/source/Commands/CommandObjectDisassemble.h b/source/Commands/CommandObjectDisassemble.h index 04c4cc247ee9..f4d99a4b4d62 100644 --- a/source/Commands/CommandObjectDisassemble.h +++ b/source/Commands/CommandObjectDisassemble.h @@ -1,9 +1,8 @@ //===-- CommandObjectDisassemble.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp index 1a009d4b7b60..869ec85da397 100644 --- a/source/Commands/CommandObjectExpression.cpp +++ b/source/Commands/CommandObjectExpression.cpp @@ -1,15 +1,11 @@ //===-- CommandObjectExpression.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "swift/AST/Identifier.h" #include "swift/AST/Module.h" #include "swift/IDE/REPLCodeCompletion.h" @@ -19,7 +15,6 @@ #include "llvm/IR/Module.h" #include "llvm/Support/MemoryBuffer.h" -// Project includes #include "CommandObjectExpression.h" #include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h" #include "lldb/Core/Debugger.h" @@ -328,6 +323,72 @@ CommandObjectExpression::~CommandObjectExpression() = default; Options *CommandObjectExpression::GetOptions() { return &m_option_group; } +int CommandObjectExpression::HandleCompletion(CompletionRequest &request) { + EvaluateExpressionOptions options; + options.SetCoerceToId(m_varobj_options.use_objc); + options.SetLanguage(m_command_options.language); + options.SetExecutionPolicy(lldb_private::eExecutionPolicyNever); + options.SetAutoApplyFixIts(false); + options.SetGenerateDebugInfo(false); + + // We need a valid execution context with a frame pointer for this + // completion, so if we don't have one we should try to make a valid + // execution context. + if (m_interpreter.GetExecutionContext().GetFramePtr() == nullptr) + m_interpreter.UpdateExecutionContext(nullptr); + + // This didn't work, so let's get out before we start doing things that + // expect a valid frame pointer. + if (m_interpreter.GetExecutionContext().GetFramePtr() == nullptr) + return 0; + + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); + + Target *target = exe_ctx.GetTargetPtr(); + + if (!target) + target = GetDummyTarget(); + + if (!target) + return 0; + + unsigned cursor_pos = request.GetRawCursorPos(); + llvm::StringRef code = request.GetRawLine(); + + const std::size_t original_code_size = code.size(); + + // Remove the first token which is 'expr' or some alias/abbreviation of that. + code = llvm::getToken(code).second.ltrim(); + OptionsWithRaw args(code); + code = args.GetRawPart(); + + // The position where the expression starts in the command line. + assert(original_code_size >= code.size()); + std::size_t raw_start = original_code_size - code.size(); + + // Check if the cursor is actually in the expression string, and if not, we + // exit. + // FIXME: We should complete the options here. + if (cursor_pos < raw_start) + return 0; + + // Make the cursor_pos again relative to the start of the code string. + assert(cursor_pos >= raw_start); + cursor_pos -= raw_start; + + auto language = exe_ctx.GetFrameRef().GetLanguage(); + + Status error; + lldb::UserExpressionSP expr(target->GetUserExpressionForLanguage(exe_ctx, + code, llvm::StringRef(), language, UserExpression::eResultTypeAny, + options, error)); + if (error.Fail()) + return 0; + + expr->Complete(exe_ctx, request, cursor_pos); + return request.GetNumberOfMatches(); +} + static lldb_private::Status CanBeUsedForElementCountPrinting(ValueObject &valobj) { CompilerType type(valobj.GetCompilerType()); @@ -384,8 +445,7 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, if (m_command_options.auto_apply_fixits == eLazyBoolCalculate) auto_apply_fixits = target->GetEnableAutoApplyFixIts(); else - auto_apply_fixits = - m_command_options.auto_apply_fixits == eLazyBoolYes ? true : false; + auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes; options.SetAutoApplyFixIts(auto_apply_fixits); diff --git a/source/Commands/CommandObjectExpression.h b/source/Commands/CommandObjectExpression.h index 881d3da06fa6..f04f55e77ff2 100644 --- a/source/Commands/CommandObjectExpression.h +++ b/source/Commands/CommandObjectExpression.h @@ -1,19 +1,14 @@ //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectExpression_h_ #define liblldb_CommandObjectExpression_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/OptionGroupBoolean.h" @@ -62,6 +57,8 @@ class CommandObjectExpression : public CommandObjectRaw, Options *GetOptions() override; + int HandleCompletion(CompletionRequest &request) override; + protected: //------------------------------------------------------------------ // IOHandler::Delegate functions diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp index 3e8012d2c330..ce02f22cf164 100644 --- a/source/Commands/CommandObjectFrame.cpp +++ b/source/Commands/CommandObjectFrame.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectFrame.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "CommandObjectFrame.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" diff --git a/source/Commands/CommandObjectFrame.h b/source/Commands/CommandObjectFrame.h index 3199399163df..9adc723664e4 100644 --- a/source/Commands/CommandObjectFrame.h +++ b/source/Commands/CommandObjectFrame.h @@ -1,9 +1,8 @@ //===-- CommandObjectFrame.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectGUI.cpp b/source/Commands/CommandObjectGUI.cpp index d65e12e30982..db1cf6da2e6f 100644 --- a/source/Commands/CommandObjectGUI.cpp +++ b/source/Commands/CommandObjectGUI.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectGUI.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/lldb-private.h" diff --git a/source/Commands/CommandObjectGUI.h b/source/Commands/CommandObjectGUI.h index c71558fa1758..3719d53d7366 100644 --- a/source/Commands/CommandObjectGUI.h +++ b/source/Commands/CommandObjectGUI.h @@ -1,19 +1,14 @@ //===-- CommandObjectGUI.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectGUI_h_ #define liblldb_CommandObjectGUI_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectHelp.cpp b/source/Commands/CommandObjectHelp.cpp index 3ddc67da361c..b39323e0acb0 100644 --- a/source/Commands/CommandObjectHelp.cpp +++ b/source/Commands/CommandObjectHelp.cpp @@ -1,16 +1,11 @@ //===-- CommandObjectHelp.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectHelp.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectMultiword.h" diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h index c78682dead1f..d957a43ca2b5 100644 --- a/source/Commands/CommandObjectHelp.h +++ b/source/Commands/CommandObjectHelp.h @@ -1,19 +1,14 @@ //===-- CommandObjectHelp.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectHelp_h_ #define liblldb_CommandObjectHelp_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/Options.h" diff --git a/source/Commands/CommandObjectLanguage.cpp b/source/Commands/CommandObjectLanguage.cpp index f0028d65da37..47c9e2a52023 100644 --- a/source/Commands/CommandObjectLanguage.cpp +++ b/source/Commands/CommandObjectLanguage.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectLanguage.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectLanguage.h b/source/Commands/CommandObjectLanguage.h index b796c511b513..b86457c99af3 100644 --- a/source/Commands/CommandObjectLanguage.h +++ b/source/Commands/CommandObjectLanguage.h @@ -1,20 +1,15 @@ //===-- CommandObjectLanguage.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectLanguage_h_ #define liblldb_CommandObjectLanguage_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/lldb-types.h" diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp index 8cc21ecb795a..db4116283eb4 100644 --- a/source/Commands/CommandObjectLog.cpp +++ b/source/Commands/CommandObjectLog.cpp @@ -1,16 +1,11 @@ //===-- CommandObjectLog.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectLog.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -101,7 +96,8 @@ class CommandObjectLogEnable : public CommandObjectParsed { switch (short_option) { case 'f': - log_file.SetFile(option_arg, true, FileSpec::Style::native); + log_file.SetFile(option_arg, FileSpec::Style::native); + FileSystem::Instance().Resolve(log_file); break; case 't': log_options |= LLDB_LOG_OPTION_THREADSAFE; diff --git a/source/Commands/CommandObjectLog.h b/source/Commands/CommandObjectLog.h index 1e24a4b2ac67..df3db878e396 100644 --- a/source/Commands/CommandObjectLog.h +++ b/source/Commands/CommandObjectLog.h @@ -1,22 +1,17 @@ //===-- CommandObjectLog.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectLog_h_ #define liblldb_CommandObjectLog_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp index ec13e11221f1..439f47557f44 100644 --- a/source/Commands/CommandObjectMemory.cpp +++ b/source/Commands/CommandObjectMemory.cpp @@ -1,20 +1,15 @@ //===-- CommandObjectMemory.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes #include "clang/AST/Decl.h" -// Project includes #include "CommandObjectMemory.h" #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/Debugger.h" @@ -386,7 +381,6 @@ class CommandObjectMemoryRead : public CommandObjectParsed { if (view_as_type_cstr && view_as_type_cstr[0]) { // We are viewing memory as a type - SymbolContext sc; const bool exact_match = false; TypeList type_list; uint32_t reference_count = 0; @@ -471,17 +465,13 @@ class CommandObjectMemoryRead : public CommandObjectParsed { llvm::DenseSet searched_symbol_files; ConstString lookup_type_name(type_str.c_str()); StackFrame *frame = m_exe_ctx.GetFramePtr(); + ModuleSP search_first; if (frame) { - sc = frame->GetSymbolContext(eSymbolContextModule); - if (sc.module_sp) { - sc.module_sp->FindTypes(sc, lookup_type_name, exact_match, 1, - searched_symbol_files, type_list); - } - } - if (type_list.GetSize() == 0) { - target->GetImages().FindTypes(sc, lookup_type_name, exact_match, 1, - searched_symbol_files, type_list); + search_first = frame->GetSymbolContext(eSymbolContextModule).module_sp; } + target->GetImages().FindTypes(search_first.get(), lookup_type_name, + exact_match, 1, searched_symbol_files, + type_list); if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$') { @@ -528,7 +518,7 @@ class CommandObjectMemoryRead : public CommandObjectParsed { --pointer_count; } - auto size = clang_ast_type.GetByteSize(nullptr); + llvm::Optional size = clang_ast_type.GetByteSize(nullptr); if (!size) { result.AppendErrorWithFormat( "unable to get the byte size of the type '%s'\n", @@ -651,7 +641,7 @@ class CommandObjectMemoryRead : public CommandObjectParsed { if (!m_format_options.GetFormatValue().OptionWasSet()) m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault); - auto size = clang_ast_type.GetByteSize(nullptr); + llvm::Optional size = clang_ast_type.GetByteSize(nullptr); if (!size) { result.AppendError("can't get size of type"); return false; @@ -765,9 +755,9 @@ class CommandObjectMemoryRead : public CommandObjectParsed { Stream *output_stream = nullptr; const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue(); + + std::string path = outfile_spec.GetPath(); if (outfile_spec) { - char path[PATH_MAX]; - outfile_spec.GetPath(path, sizeof(path)); uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate; @@ -775,19 +765,21 @@ class CommandObjectMemoryRead : public CommandObjectParsed { if (append) open_options |= File::eOpenOptionAppend; - if (outfile_stream.GetFile().Open(path, open_options).Success()) { + Status error = FileSystem::Instance().Open(outfile_stream.GetFile(), + outfile_spec, open_options); + if (error.Success()) { if (m_memory_options.m_output_as_binary) { const size_t bytes_written = outfile_stream.Write(data_sp->GetBytes(), bytes_read); if (bytes_written > 0) { result.GetOutputStream().Printf( "%zi bytes %s to '%s'\n", bytes_written, - append ? "appended" : "written", path); + append ? "appended" : "written", path.c_str()); return true; } else { result.AppendErrorWithFormat("Failed to write %" PRIu64 " bytes to '%s'.\n", - (uint64_t)bytes_read, path); + (uint64_t)bytes_read, path.c_str()); result.SetStatus(eReturnStatusFailed); return false; } @@ -797,8 +789,8 @@ class CommandObjectMemoryRead : public CommandObjectParsed { output_stream = &outfile_stream; } } else { - result.AppendErrorWithFormat("Failed to open file '%s' for %s.\n", path, - append ? "append" : "write"); + result.AppendErrorWithFormat("Failed to open file '%s' for %s.\n", + path.c_str(), append ? "append" : "write"); result.SetStatus(eReturnStatusFailed); return false; } @@ -1071,7 +1063,8 @@ class CommandObjectMemoryFind : public CommandObjectParsed { m_memory_options.m_expr.GetStringValue(), frame, result_sp)) && result_sp) { uint64_t value = result_sp->GetValueAsUnsigned(0); - auto size = result_sp->GetCompilerType().GetByteSize(nullptr); + llvm::Optional size = + result_sp->GetCompilerType().GetByteSize(nullptr); if (!size) return false; switch (*size) { @@ -1215,8 +1208,9 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { switch (short_option) { case 'i': - m_infile.SetFile(option_value, true, FileSpec::Style::native); - if (!m_infile.Exists()) { + m_infile.SetFile(option_value, FileSpec::Style::native); + FileSystem::Instance().Resolve(m_infile); + if (!FileSystem::Instance().Exists(m_infile)) { m_infile.Clear(); error.SetErrorStringWithFormat("input file does not exist: '%s'", option_value.str().c_str()); @@ -1364,7 +1358,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { size_t length = SIZE_MAX; if (item_byte_size > 1) length = item_byte_size; - auto data_sp = DataBufferLLVM::CreateSliceFromPath( + auto data_sp = FileSystem::Instance().CreateDataBuffer( m_memory_options.m_infile.GetPath(), length, m_memory_options.m_infile_offset); if (data_sp) { @@ -1730,6 +1724,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { error = process_sp->GetMemoryRegionInfo(load_addr, range_info); if (error.Success()) { lldb_private::Address addr; + ConstString name = range_info.GetName(); ConstString section_name; if (process_sp->GetTarget().ResolveLoadAddress(load_addr, addr)) { SectionSP section_sp(addr.GetSection()); @@ -1741,13 +1736,14 @@ class CommandObjectMemoryRegion : public CommandObjectParsed { } } result.AppendMessageWithFormat( - "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s\n", + "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s%s%s\n", range_info.GetRange().GetRangeBase(), range_info.GetRange().GetRangeEnd(), range_info.GetReadable() ? 'r' : '-', range_info.GetWritable() ? 'w' : '-', - range_info.GetExecutable() ? 'x' : '-', section_name ? " " : "", - section_name ? section_name.AsCString() : ""); + range_info.GetExecutable() ? 'x' : '-', + name ? " " : "", name.AsCString(""), + section_name ? " " : "", section_name.AsCString("")); m_prev_end_addr = range_info.GetRange().GetRangeEnd(); result.SetStatus(eReturnStatusSuccessFinishResult); } else { diff --git a/source/Commands/CommandObjectMemory.h b/source/Commands/CommandObjectMemory.h index 9f3978baf76a..f94cdf3287aa 100644 --- a/source/Commands/CommandObjectMemory.h +++ b/source/Commands/CommandObjectMemory.h @@ -1,19 +1,14 @@ //===-- CommandObjectMemory.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectMemory_h_ #define liblldb_CommandObjectMemory_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp index 19fcf60e557c..f71df5d1b025 100644 --- a/source/Commands/CommandObjectMultiword.cpp +++ b/source/Commands/CommandObjectMultiword.cpp @@ -1,16 +1,11 @@ //===-- CommandObjectMultiword.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -193,9 +188,10 @@ int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) { auto arg0 = request.GetParsedLine()[0].ref; if (request.GetCursorIndex() == 0) { - StringList new_matches; - AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches); - request.AddCompletions(new_matches); + StringList new_matches, descriptions; + AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches, + &descriptions); + request.AddCompletions(new_matches, descriptions); if (new_matches.GetSize() == 1 && new_matches.GetStringAtIndex(0) != nullptr && diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp index 45b80aa1feef..39c59c8a0f71 100644 --- a/source/Commands/CommandObjectPlatform.cpp +++ b/source/Commands/CommandObjectPlatform.cpp @@ -1,17 +1,12 @@ //===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "CommandObjectPlatform.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -491,8 +486,7 @@ class CommandObjectPlatformMkDir : public CommandObjectParsed { else mode = lldb::eFilePermissionsUserRWX | lldb::eFilePermissionsGroupRWX | lldb::eFilePermissionsWorldRX; - Status error = - platform_sp->MakeDirectory(FileSpec{cmd_line, false}, mode); + Status error = platform_sp->MakeDirectory(FileSpec(cmd_line), mode); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -545,7 +539,7 @@ class CommandObjectPlatformFOpen : public CommandObjectParsed { perms = lldb::eFilePermissionsUserRW | lldb::eFilePermissionsGroupRW | lldb::eFilePermissionsWorldRead; lldb::user_id_t fd = platform_sp->OpenFile( - FileSpec(cmd_line, false), + FileSpec(cmd_line), File::eOpenOptionRead | File::eOpenOptionWrite | File::eOpenOptionAppend | File::eOpenOptionCanCreate, perms, error); @@ -883,8 +877,8 @@ class CommandObjectPlatformGetFile : public CommandObjectParsed { if (platform_sp) { const char *remote_file_path = args.GetArgumentAtIndex(0); const char *local_file_path = args.GetArgumentAtIndex(1); - Status error = platform_sp->GetFile(FileSpec(remote_file_path, false), - FileSpec(local_file_path, false)); + Status error = platform_sp->GetFile(FileSpec(remote_file_path), + FileSpec(local_file_path)); if (error.Success()) { result.AppendMessageWithFormat( "successfully get-file from %s (remote) to %s (host)\n", @@ -949,8 +943,7 @@ class CommandObjectPlatformGetSize : public CommandObjectParsed { m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { std::string remote_file_path(args.GetArgumentAtIndex(0)); - user_id_t size = - platform_sp->GetFileSize(FileSpec(remote_file_path, false)); + user_id_t size = platform_sp->GetFileSize(FileSpec(remote_file_path)); if (size != UINT64_MAX) { result.AppendMessageWithFormat("File size of %s (remote): %" PRIu64 "\n", @@ -987,8 +980,9 @@ class CommandObjectPlatformPutFile : public CommandObjectParsed { const char *src = args.GetArgumentAtIndex(0); const char *dst = args.GetArgumentAtIndex(1); - FileSpec src_fs(src, true); - FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString(), false); + FileSpec src_fs(src); + FileSystem::Instance().Resolve(src_fs); + FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString()); PlatformSP platform_sp( m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); @@ -1043,7 +1037,7 @@ class CommandObjectPlatformProcessLaunch : public CommandObjectParsed { Module *exe_module = target->GetExecutableModulePointer(); if (exe_module) { m_options.launch_info.GetExecutableFile() = exe_module->GetFileSpec(); - llvm::SmallString exe_path; + llvm::SmallString<128> exe_path; m_options.launch_info.GetExecutableFile().GetPath(exe_path); if (!exe_path.empty()) m_options.launch_info.GetArguments().AppendArgument(exe_path); @@ -1336,31 +1330,31 @@ class CommandObjectPlatformProcessList : public CommandObjectParsed { case 'n': match_info.GetProcessInfo().GetExecutableFile().SetFile( - option_arg, false, FileSpec::Style::native); + option_arg, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::Equals); break; case 'e': match_info.GetProcessInfo().GetExecutableFile().SetFile( - option_arg, false, FileSpec::Style::native); + option_arg, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::EndsWith); break; case 's': match_info.GetProcessInfo().GetExecutableFile().SetFile( - option_arg, false, FileSpec::Style::native); + option_arg, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::StartsWith); break; case 'c': match_info.GetProcessInfo().GetExecutableFile().SetFile( - option_arg, false, FileSpec::Style::native); + option_arg, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::Contains); break; case 'r': match_info.GetProcessInfo().GetExecutableFile().SetFile( - option_arg, false, FileSpec::Style::native); + option_arg, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::RegularExpression); break; @@ -1529,7 +1523,7 @@ class CommandObjectPlatformProcessAttach : public CommandObjectParsed { break; case 'n': - attach_info.GetExecutableFile().SetFile(option_arg, false, + attach_info.GetExecutableFile().SetFile(option_arg, FileSpec::Style::native); break; @@ -1576,7 +1570,7 @@ class CommandObjectPlatformProcessAttach : public CommandObjectParsed { ProcessInstanceInfoMatch match_info; if (partial_name) { match_info.GetProcessInfo().GetExecutableFile().SetFile( - partial_name, false, FileSpec::Style::native); + partial_name, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::StartsWith); } platform_sp->FindProcesses(match_info, process_infos); @@ -1816,9 +1810,10 @@ class CommandObjectPlatformInstall : public CommandObjectParsed { return false; } // TODO: move the bulk of this code over to the platform itself - FileSpec src(args.GetArgumentAtIndex(0), true); - FileSpec dst(args.GetArgumentAtIndex(1), false); - if (!src.Exists()) { + FileSpec src(args.GetArgumentAtIndex(0)); + FileSystem::Instance().Resolve(src); + FileSpec dst(args.GetArgumentAtIndex(1)); + if (!FileSystem::Instance().Exists(src)) { result.AppendError("source location does not exist or is not accessible"); result.SetStatus(eReturnStatusFailed); return false; diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h index 03b8ca00c81d..88e3070b8816 100644 --- a/source/Commands/CommandObjectPlatform.h +++ b/source/Commands/CommandObjectPlatform.h @@ -1,19 +1,14 @@ //===-- CommandObjectPlatform.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectPlatform_h_ #define liblldb_CommandObjectPlatform_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/Options.h" diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp index 13ef6b227c5b..1cc96f14a971 100644 --- a/source/Commands/CommandObjectPlugin.cpp +++ b/source/Commands/CommandObjectPlugin.cpp @@ -1,16 +1,11 @@ //===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectPlugin.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -63,7 +58,8 @@ class CommandObjectPluginLoad : public CommandObjectParsed { Status error; - FileSpec dylib_fspec(command[0].ref, true); + FileSpec dylib_fspec(command[0].ref); + FileSystem::Instance().Resolve(dylib_fspec); if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error)) result.SetStatus(eReturnStatusSuccessFinishResult); diff --git a/source/Commands/CommandObjectPlugin.h b/source/Commands/CommandObjectPlugin.h index d67aa43365d5..0aabb1399407 100644 --- a/source/Commands/CommandObjectPlugin.h +++ b/source/Commands/CommandObjectPlugin.h @@ -1,20 +1,15 @@ //===-- CommandObjectPlugin.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectPlugin_h_ #define liblldb_CommandObjectPlugin_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/lldb-types.h" diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp index 5c402cf60e36..e98688b5139c 100644 --- a/source/Commands/CommandObjectProcess.cpp +++ b/source/Commands/CommandObjectProcess.cpp @@ -1,23 +1,17 @@ //===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "CommandObjectProcess.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" @@ -32,6 +26,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; @@ -352,7 +347,7 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach { break; case 'n': - attach_info.GetExecutableFile().SetFile(option_arg, false, + attach_info.GetExecutableFile().SetFile(option_arg, FileSpec::Style::native); break; @@ -403,7 +398,7 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach { ProcessInstanceInfoMatch match_info; if (partial_name) { match_info.GetProcessInfo().GetExecutableFile().SetFile( - partial_name, false, FileSpec::Style::native); + partial_name, FileSpec::Style::native); match_info.SetNameMatchType(NameMatch::StartsWith); } platform_sp->FindProcesses(match_info, process_infos); @@ -975,7 +970,7 @@ class CommandObjectProcessLoad : public CommandObjectParsed { case 'i': do_install = true; if (!option_arg.empty()) - install_path.SetFile(option_arg, false, FileSpec::Style::native); + install_path.SetFile(option_arg, FileSpec::Style::native); break; default: error.SetErrorStringWithFormat("invalid short option character '%c'", @@ -1023,18 +1018,20 @@ class CommandObjectProcessLoad : public CommandObjectParsed { uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN; if (!m_options.do_install) { - FileSpec image_spec(image_path, false); + FileSpec image_spec(image_path); platform->ResolveRemotePath(image_spec, image_spec); image_token = platform->LoadImage(process, FileSpec(), image_spec, error); } else if (m_options.install_path) { - FileSpec image_spec(image_path, true); + FileSpec image_spec(image_path); + FileSystem::Instance().Resolve(image_spec); platform->ResolveRemotePath(m_options.install_path, m_options.install_path); image_token = platform->LoadImage(process, image_spec, m_options.install_path, error); } else { - FileSpec image_spec(image_path, true); + FileSpec image_spec(image_path); + FileSystem::Instance().Resolve(image_spec); image_token = platform->LoadImage(process, image_spec, FileSpec(), error); } @@ -1281,7 +1278,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { ProcessSP process_sp = m_exe_ctx.GetProcessSP(); if (process_sp) { if (command.GetArgumentCount() == 1) { - FileSpec output_file(command.GetArgumentAtIndex(0), false); + FileSpec output_file(command.GetArgumentAtIndex(0)); Status error = PluginManager::SaveCore(process_sp, output_file); if (error.Success()) { result.SetStatus(eReturnStatusSuccessFinishResult); diff --git a/source/Commands/CommandObjectProcess.h b/source/Commands/CommandObjectProcess.h index 0f520f63e1dd..4be391f636a8 100644 --- a/source/Commands/CommandObjectProcess.h +++ b/source/Commands/CommandObjectProcess.h @@ -1,19 +1,14 @@ //===-- CommandObjectProcess.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectProcess_h_ #define liblldb_CommandObjectProcess_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectQuit.cpp b/source/Commands/CommandObjectQuit.cpp index a9c430ea51c6..9b71945616b3 100644 --- a/source/Commands/CommandObjectQuit.cpp +++ b/source/Commands/CommandObjectQuit.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectQuit.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectQuit.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -35,7 +30,7 @@ CommandObjectQuit::~CommandObjectQuit() {} // if all alive processes will be detached when you quit and false if at least // one process will be killed instead bool CommandObjectQuit::ShouldAskForConfirmation(bool &is_a_detach) { - if (m_interpreter.GetPromptOnQuit() == false) + if (!m_interpreter.GetPromptOnQuit()) return false; bool should_prompt = false; is_a_detach = true; @@ -55,7 +50,7 @@ bool CommandObjectQuit::ShouldAskForConfirmation(bool &is_a_detach) { if (process_sp && process_sp->IsValid() && process_sp->IsAlive() && process_sp->WarnBeforeDetach()) { should_prompt = true; - if (process_sp->GetShouldDetach() == false) { + if (!process_sp->GetShouldDetach()) { // if we need to kill at least one process, just say so and return is_a_detach = false; return should_prompt; diff --git a/source/Commands/CommandObjectQuit.h b/source/Commands/CommandObjectQuit.h index f2998f8690fb..c3f4284695e8 100644 --- a/source/Commands/CommandObjectQuit.h +++ b/source/Commands/CommandObjectQuit.h @@ -1,19 +1,14 @@ //===-- CommandObjectQuit.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectQuit_h_ #define liblldb_CommandObjectQuit_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp index f023e42d2625..d1555cc90d50 100644 --- a/source/Commands/CommandObjectRegister.cpp +++ b/source/Commands/CommandObjectRegister.cpp @@ -1,17 +1,14 @@ //===-- CommandObjectRegister.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectRegister.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpRegisterValue.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -27,6 +24,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Errno.h" using namespace lldb; diff --git a/source/Commands/CommandObjectRegister.h b/source/Commands/CommandObjectRegister.h index 81f2f6bae223..6b6d6c399eb5 100644 --- a/source/Commands/CommandObjectRegister.h +++ b/source/Commands/CommandObjectRegister.h @@ -1,19 +1,14 @@ //===-- CommandObjectRegister.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectRegister_h_ #define liblldb_CommandObjectRegister_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectReproducer.cpp b/source/Commands/CommandObjectReproducer.cpp new file mode 100644 index 000000000000..7d2b7ede9a57 --- /dev/null +++ b/source/Commands/CommandObjectReproducer.cpp @@ -0,0 +1,95 @@ +//===-- CommandObjectReproducer.cpp -----------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectReproducer.h" + +#include "lldb/Utility/Reproducer.h" + +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Interpreter/OptionArgParser.h" +#include "lldb/Interpreter/OptionGroupBoolean.h" + +using namespace lldb; +using namespace lldb_private; + +class CommandObjectReproducerGenerate : public CommandObjectParsed { +public: + CommandObjectReproducerGenerate(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "reproducer generate", + "Generate reproducer on disk.", nullptr) {} + + ~CommandObjectReproducerGenerate() override = default; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override { + if (!command.empty()) { + result.AppendErrorWithFormat("'%s' takes no arguments", + m_cmd_name.c_str()); + return false; + } + + auto &r = repro::Reproducer::Instance(); + if (auto generator = r.GetGenerator()) { + generator->Keep(); + } else { + result.AppendErrorWithFormat("Unable to get the reproducer generator"); + return false; + } + + result.GetOutputStream() + << "Reproducer written to '" << r.GetReproducerPath() << "'\n"; + + result.SetStatus(eReturnStatusSuccessFinishResult); + return result.Succeeded(); + } +}; + +class CommandObjectReproducerStatus : public CommandObjectParsed { +public: + CommandObjectReproducerStatus(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "reproducer status", + "Show the current reproducer status.", nullptr) {} + + ~CommandObjectReproducerStatus() override = default; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override { + if (!command.empty()) { + result.AppendErrorWithFormat("'%s' takes no arguments", + m_cmd_name.c_str()); + return false; + } + + auto &r = repro::Reproducer::Instance(); + if (r.GetGenerator()) { + result.GetOutputStream() << "Reproducer is in capture mode.\n"; + } else if (r.GetLoader()) { + result.GetOutputStream() << "Reproducer is in replay mode.\n"; + } else { + result.GetOutputStream() << "Reproducer is off.\n"; + } + + result.SetStatus(eReturnStatusSuccessFinishResult); + return result.Succeeded(); + } +}; + +CommandObjectReproducer::CommandObjectReproducer( + CommandInterpreter &interpreter) + : CommandObjectMultiword(interpreter, "reproducer", + "Commands controlling LLDB reproducers.", + "log []") { + LoadSubCommand( + "generate", + CommandObjectSP(new CommandObjectReproducerGenerate(interpreter))); + LoadSubCommand("status", CommandObjectSP( + new CommandObjectReproducerStatus(interpreter))); +} + +CommandObjectReproducer::~CommandObjectReproducer() = default; diff --git a/source/Commands/CommandObjectReproducer.h b/source/Commands/CommandObjectReproducer.h new file mode 100644 index 000000000000..f52d8f1a0ab7 --- /dev/null +++ b/source/Commands/CommandObjectReproducer.h @@ -0,0 +1,30 @@ +//===-- CommandObjectReproducer.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_CommandObjectReproducer_h_ +#define liblldb_CommandObjectReproducer_h_ + +#include "lldb/Interpreter/CommandObjectMultiword.h" +#include "lldb/Interpreter/Options.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// CommandObjectReproducer +//------------------------------------------------------------------------- + +class CommandObjectReproducer : public CommandObjectMultiword { +public: + CommandObjectReproducer(CommandInterpreter &interpreter); + + ~CommandObjectReproducer() override; +}; + +} // namespace lldb_private + +#endif // liblldb_CommandObjectReproducer_h_ diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp index 3b3cfa5ddb5a..eea94df89cc3 100644 --- a/source/Commands/CommandObjectSettings.cpp +++ b/source/Commands/CommandObjectSettings.cpp @@ -1,20 +1,15 @@ //===-- CommandObjectSettings.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectSettings.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -30,7 +25,8 @@ using namespace lldb_private; static constexpr OptionDefinition g_settings_set_options[] = { // clang-format off - { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Apply the new value to the global default value." } + { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Apply the new value to the global default value." }, + { LLDB_OPT_SET_2, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Force an empty value to be accepted as the default." } // clang-format on }; @@ -108,6 +104,9 @@ insert-before or insert-after."); const int short_option = m_getopt_table[option_idx].val; switch (short_option) { + case 'f': + m_force = true; + break; case 'g': m_global = true; break; @@ -122,6 +121,7 @@ insert-before or insert-after."); void OptionParsingStarting(ExecutionContext *execution_context) override { m_global = false; + m_force = false; } llvm::ArrayRef GetDefinitions() override { @@ -129,8 +129,8 @@ insert-before or insert-after."); } // Instance variables to hold the values for command options. - bool m_global; + bool m_force; }; int HandleArgumentCompletion( @@ -184,8 +184,10 @@ insert-before or insert-after."); if (!ParseOptions(cmd_args, result)) return false; + const size_t min_argc = m_options.m_force ? 1 : 2; const size_t argc = cmd_args.GetArgumentCount(); - if ((argc < 2) && (!m_options.m_global)) { + + if ((argc < min_argc) && (!m_options.m_global)) { result.AppendError("'settings set' takes more arguments"); result.SetStatus(eReturnStatusFailed); return false; @@ -199,6 +201,19 @@ insert-before or insert-after."); return false; } + // A missing value corresponds to clearing the setting when "force" is + // specified. + if (argc == 1 && m_options.m_force) { + Status error(m_interpreter.GetDebugger().SetPropertyValue( + &m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef())); + if (error.Fail()) { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; + } + return result.Succeeded(); + } + // Split the raw command into var_name and value pair. llvm::StringRef raw_str(command); std::string var_value_string = raw_str.split(var_name).second.str(); @@ -300,6 +315,210 @@ class CommandObjectSettingsShow : public CommandObjectParsed { } }; +//------------------------------------------------------------------------- +// CommandObjectSettingsWrite -- Write settings to file +//------------------------------------------------------------------------- + +static constexpr OptionDefinition g_settings_write_options[] = { + // clang-format off + { LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file into which to write the settings." }, + { LLDB_OPT_SET_ALL, false, "append",'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to saved settings file if it exists."}, + // clang-format on +}; + +class CommandObjectSettingsWrite : public CommandObjectParsed { +public: + CommandObjectSettingsWrite(CommandInterpreter &interpreter) + : CommandObjectParsed( + interpreter, "settings export", + "Write matching debugger settings and their " + "current values to a file that can be read in with " + "\"settings read\". Defaults to writing all settings.", + nullptr), + m_options() { + CommandArgumentEntry arg1; + CommandArgumentData var_name_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the + // argument entry. + arg1.push_back(var_name_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back(arg1); + } + + ~CommandObjectSettingsWrite() override = default; + + Options *GetOptions() override { return &m_options; } + + class CommandOptions : public Options { + public: + CommandOptions() : Options() {} + + ~CommandOptions() override = default; + + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; + const int short_option = m_getopt_table[option_idx].val; + + switch (short_option) { + case 'f': + m_filename.assign(option_arg); + break; + case 'a': + m_append = true; + break; + default: + error.SetErrorStringWithFormat("unrecognized option '%c'", + short_option); + break; + } + + return error; + } + + void OptionParsingStarting(ExecutionContext *execution_context) override { + m_filename.clear(); + m_append = false; + } + + llvm::ArrayRef GetDefinitions() override { + return llvm::makeArrayRef(g_settings_write_options); + } + + // Instance variables to hold the values for command options. + std::string m_filename; + bool m_append = false; + }; + +protected: + bool DoExecute(Args &args, CommandReturnObject &result) override { + FileSpec file_spec(m_options.m_filename); + FileSystem::Instance().Resolve(file_spec); + std::string path(file_spec.GetPath()); + uint32_t options = File::OpenOptions::eOpenOptionWrite | + File::OpenOptions::eOpenOptionCanCreate; + if (m_options.m_append) + options |= File::OpenOptions::eOpenOptionAppend; + else + options |= File::OpenOptions::eOpenOptionTruncate; + + StreamFile out_file(path.c_str(), options, + lldb::eFilePermissionsFileDefault); + + if (!out_file.GetFile().IsValid()) { + result.AppendErrorWithFormat("%s: unable to write to file", path.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + // Exporting should not be context sensitive. + ExecutionContext clean_ctx; + + if (args.empty()) { + m_interpreter.GetDebugger().DumpAllPropertyValues( + &clean_ctx, out_file, OptionValue::eDumpGroupExport); + return result.Succeeded(); + } + + for (const auto &arg : args) { + Status error(m_interpreter.GetDebugger().DumpPropertyValue( + &clean_ctx, out_file, arg.ref, OptionValue::eDumpGroupExport)); + if (!error.Success()) { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + } + } + + return result.Succeeded(); + } + +private: + CommandOptions m_options; +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsRead -- Read settings from file +//------------------------------------------------------------------------- + +static constexpr OptionDefinition g_settings_read_options[] = { + // clang-format off + {LLDB_OPT_SET_ALL, true, "file",'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file from which to read the breakpoints." }, + // clang-format on +}; + +class CommandObjectSettingsRead : public CommandObjectParsed { +public: + CommandObjectSettingsRead(CommandInterpreter &interpreter) + : CommandObjectParsed( + interpreter, "settings read", + "Read settings previously saved to a file with \"settings write\".", + nullptr), + m_options() {} + + ~CommandObjectSettingsRead() override = default; + + Options *GetOptions() override { return &m_options; } + + class CommandOptions : public Options { + public: + CommandOptions() : Options() {} + + ~CommandOptions() override = default; + + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; + const int short_option = m_getopt_table[option_idx].val; + + switch (short_option) { + case 'f': + m_filename.assign(option_arg); + break; + default: + error.SetErrorStringWithFormat("unrecognized option '%c'", + short_option); + break; + } + + return error; + } + + void OptionParsingStarting(ExecutionContext *execution_context) override { + m_filename.clear(); + } + + llvm::ArrayRef GetDefinitions() override { + return llvm::makeArrayRef(g_settings_read_options); + } + + // Instance variables to hold the values for command options. + std::string m_filename; + }; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override { + FileSpec file(m_options.m_filename); + FileSystem::Instance().Resolve(file); + ExecutionContext clean_ctx; + CommandInterpreterRunOptions options; + options.SetAddToHistory(false); + options.SetEchoCommands(false); + options.SetPrintResults(true); + options.SetStopOnError(false); + m_interpreter.HandleCommandsFromFile(file, &clean_ctx, options, result); + return result.Succeeded(); + } + +private: + CommandOptions m_options; +}; + //------------------------------------------------------------------------- // CommandObjectSettingsList -- List settable variables //------------------------------------------------------------------------- @@ -987,6 +1206,10 @@ CommandObjectMultiwordSettings::CommandObjectMultiwordSettings( CommandObjectSP(new CommandObjectSettingsAppend(interpreter))); LoadSubCommand("clear", CommandObjectSP(new CommandObjectSettingsClear(interpreter))); + LoadSubCommand("write", + CommandObjectSP(new CommandObjectSettingsWrite(interpreter))); + LoadSubCommand("read", + CommandObjectSP(new CommandObjectSettingsRead(interpreter))); } CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings() = default; diff --git a/source/Commands/CommandObjectSettings.h b/source/Commands/CommandObjectSettings.h index 3376cccd1799..056810a20369 100644 --- a/source/Commands/CommandObjectSettings.h +++ b/source/Commands/CommandObjectSettings.h @@ -1,19 +1,14 @@ //===-- CommandObjectSettings.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectSettings_h_ #define liblldb_CommandObjectSettings_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/Options.h" diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp index a1e328534d15..cc08e472b485 100644 --- a/source/Commands/CommandObjectSource.cpp +++ b/source/Commands/CommandObjectSource.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectSource.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/FileLineResolver.h" #include "lldb/Core/Module.h" @@ -517,7 +512,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed { // Dump the line entries found in the file specified in the option. bool DumpLinesForFile(CommandReturnObject &result) { - FileSpec file_spec(m_options.file_name, false); + FileSpec file_spec(m_options.file_name); const char *filename = m_options.file_name.c_str(); Target *target = m_exe_ctx.GetTargetPtr(); const ModuleList &module_list = @@ -596,7 +591,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed { m_module_list.Clear(); if (!m_options.modules.empty()) { for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) { - FileSpec module_file_spec(m_options.modules[i], false); + FileSpec module_file_spec(m_options.modules[i]); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); if (target->GetImages().FindModules(module_spec, m_module_list) == 0) @@ -921,7 +916,7 @@ class CommandObjectSourceList : public CommandObjectParsed { if (num_modules > 0) { ModuleList matching_modules; for (size_t i = 0; i < num_modules; ++i) { - FileSpec module_file_spec(m_options.modules[i], false); + FileSpec module_file_spec(m_options.modules[i]); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); matching_modules.Clear(); @@ -946,7 +941,7 @@ class CommandObjectSourceList : public CommandObjectParsed { if (num_modules > 0) { ModuleList matching_modules; for (size_t i = 0; i < num_modules; ++i) { - FileSpec module_file_spec(m_options.modules[i], false); + FileSpec module_file_spec(m_options.modules[i]); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); matching_modules.Clear(); @@ -1203,14 +1198,16 @@ class CommandObjectSourceList : public CommandObjectParsed { if (!m_options.modules.empty()) { ModuleList matching_modules; for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) { - FileSpec module_file_spec(m_options.modules[i], false); + FileSpec module_file_spec(m_options.modules[i]); if (module_file_spec) { ModuleSpec module_spec(module_file_spec); matching_modules.Clear(); target->GetImages().FindModules(module_spec, matching_modules); num_matches += matching_modules.ResolveSymbolContextForFilePath( filename, 0, check_inlines, - eSymbolContextModule | eSymbolContextCompUnit, sc_list); + SymbolContextItem(eSymbolContextModule | + eSymbolContextCompUnit), + sc_list); } } } else { diff --git a/source/Commands/CommandObjectSource.h b/source/Commands/CommandObjectSource.h index e81ac1961d26..909bafa52d0c 100644 --- a/source/Commands/CommandObjectSource.h +++ b/source/Commands/CommandObjectSource.h @@ -1,20 +1,15 @@ //===-- CommandObjectSource.h.h -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectSource_h_ #define liblldb_CommandObjectSource_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/STLUtils.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" diff --git a/source/Commands/CommandObjectStats.cpp b/source/Commands/CommandObjectStats.cpp index 9225a94b70d3..a73c2a8e0409 100644 --- a/source/Commands/CommandObjectStats.cpp +++ b/source/Commands/CommandObjectStats.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectStats.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectStats.h b/source/Commands/CommandObjectStats.h index 3c5c2c04db1f..27e9a6ff865a 100644 --- a/source/Commands/CommandObjectStats.h +++ b/source/Commands/CommandObjectStats.h @@ -1,9 +1,8 @@ //===-- CommandObjectStats.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp index fd8e2c4391fe..547d8f560f16 100644 --- a/source/Commands/CommandObjectTarget.cpp +++ b/source/Commands/CommandObjectTarget.cpp @@ -1,21 +1,18 @@ //===-- CommandObjectTarget.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectTarget.h" -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/OptionParser.h" @@ -51,13 +48,12 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Timer.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FormatAdapters.h" -// C Includes -// C++ Includes #include using namespace lldb; @@ -274,13 +270,13 @@ class CommandObjectTargetCreate : public CommandObjectParsed { FileSpec remote_file(m_remote_file.GetOptionValue().GetCurrentValue()); if (core_file) { - if (!core_file.Exists()) { + if (!FileSystem::Instance().Exists(core_file)) { result.AppendErrorWithFormat("core file '%s' doesn't exist", core_file.GetPath().c_str()); result.SetStatus(eReturnStatusFailed); return false; } - if (!core_file.Readable()) { + if (!FileSystem::Instance().Readable(core_file)) { result.AppendErrorWithFormat("core file '%s' is not readable", core_file.GetPath().c_str()); result.SetStatus(eReturnStatusFailed); @@ -291,8 +287,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed { if (argc == 1 || core_file || remote_file) { FileSpec symfile(m_symbol_file.GetOptionValue().GetCurrentValue()); if (symfile) { - if (symfile.Exists()) { - if (!symfile.Readable()) { + if (FileSystem::Instance().Exists(symfile)) { + if (!FileSystem::Instance().Readable(symfile)) { result.AppendErrorWithFormat("symbol file '%s' is not readable", symfile.GetPath().c_str()); result.SetStatus(eReturnStatusFailed); @@ -313,8 +309,10 @@ class CommandObjectTargetCreate : public CommandObjectParsed { Timer scoped_timer(func_cat, "(lldb) target create '%s'", file_path); FileSpec file_spec; - if (file_path) - file_spec.SetFile(file_path, true, FileSpec::Style::native); + if (file_path) { + file_spec.SetFile(file_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(file_spec); + } bool must_set_platform_path = false; @@ -336,7 +334,7 @@ class CommandObjectTargetCreate : public CommandObjectParsed { if (remote_file) { if (platform_sp) { // I have a remote file.. two possible cases - if (file_spec && file_spec.Exists()) { + if (file_spec && FileSystem::Instance().Exists(file_spec)) { // if the remote file does not exist, push it there if (!platform_sp->GetFileExists(remote_file)) { Status err = platform_sp->PutFile(file_spec, remote_file); @@ -404,8 +402,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed { if (core_file) { char core_path[PATH_MAX]; core_file.GetPath(core_path, sizeof(core_path)); - if (core_file.Exists()) { - if (!core_file.Readable()) { + if (FileSystem::Instance().Exists(core_file)) { + if (!FileSystem::Instance().Readable(core_file)) { result.AppendMessageWithFormat( "Core file '%s' is not readable.\n", core_path); result.SetStatus(eReturnStatusFailed); @@ -1349,7 +1347,7 @@ static void DumpModuleUUID(Stream &strm, Module *module) { static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, - bool load_addresses) { + lldb::DescriptionLevel desc_level) { uint32_t num_matches = 0; if (module) { SymbolContextList sc_list; @@ -1368,7 +1366,7 @@ static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter, if (line_table) line_table->GetDescription( &strm, interpreter.GetExecutionContext().GetTargetPtr(), - lldb::eDescriptionLevelBrief); + desc_level); else strm << "No line table"; } @@ -1674,12 +1672,11 @@ static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm, const uint32_t max_num_matches = UINT32_MAX; size_t num_matches = 0; bool name_is_fully_qualified = false; - SymbolContext sc; ConstString name(name_cstr); llvm::DenseSet searched_symbol_files; num_matches = - module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches, + module->FindTypes(name, name_is_fully_qualified, max_num_matches, searched_symbol_files, type_list); if (num_matches) { @@ -1717,11 +1714,8 @@ static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm, } static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm, - const SymbolContext &sym_ctx, - const char *name_cstr, bool name_is_regex) { - if (!sym_ctx.module_sp) - return 0; - + Module &module, const char *name_cstr, + bool name_is_regex) { TypeList type_list; const uint32_t max_num_matches = UINT32_MAX; size_t num_matches = 1; @@ -1729,14 +1723,13 @@ static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm, ConstString name(name_cstr); llvm::DenseSet searched_symbol_files; - num_matches = sym_ctx.module_sp->FindTypes( - sym_ctx, name, name_is_fully_qualified, max_num_matches, - searched_symbol_files, type_list); + num_matches = module.FindTypes(name, name_is_fully_qualified, max_num_matches, + searched_symbol_files, type_list); if (num_matches) { strm.Indent(); strm.PutCString("Best match found in "); - DumpFullpath(strm, &sym_ctx.module_sp->GetFileSpec(), 0); + DumpFullpath(strm, &module.GetFileSpec(), 0); strm.PutCString(":\n"); TypeSP type_sp(type_list.GetTypeAtIndex(0)); @@ -1794,7 +1787,7 @@ static uint32_t LookupFileAndLineInModule(CommandInterpreter &interpreter, static size_t FindModulesByName(Target *target, const char *module_name, ModuleList &module_list, bool check_global_list) { - FileSpec module_file_spec(module_name, false); + FileSpec module_file_spec(module_name); ModuleSpec module_spec(module_file_spec); const size_t initial_size = module_list.GetSize(); @@ -2240,6 +2233,85 @@ class CommandObjectTargetModulesDumpSections } }; +#pragma mark CommandObjectTargetModulesDumpSections + +//---------------------------------------------------------------------- +// Clang AST dumping command +//---------------------------------------------------------------------- + +class CommandObjectTargetModulesDumpClangAST + : public CommandObjectTargetModulesModuleAutoComplete { +public: + CommandObjectTargetModulesDumpClangAST(CommandInterpreter &interpreter) + : CommandObjectTargetModulesModuleAutoComplete( + interpreter, "target modules dump ast", + "Dump the clang ast for a given module's symbol file.", + //"target modules dump ast [ ...]") + nullptr) {} + + ~CommandObjectTargetModulesDumpClangAST() override = default; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override { + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (target == nullptr) { + result.AppendError("invalid target, create a debug target using the " + "'target create' command"); + result.SetStatus(eReturnStatusFailed); + return false; + } + + const size_t num_modules = target->GetImages().GetSize(); + if (num_modules == 0) { + result.AppendError("the target has no associated executable images"); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (command.GetArgumentCount() == 0) { + // Dump all ASTs for all modules images + result.GetOutputStream().Printf("Dumping clang ast for %" PRIu64 + " modules.\n", + (uint64_t)num_modules); + for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { + if (m_interpreter.WasInterrupted()) + break; + Module *m = target->GetImages().GetModulePointerAtIndex(image_idx); + SymbolFile *sf = m->GetSymbolVendor()->GetSymbolFile(); + sf->DumpClangAST(result.GetOutputStream()); + } + result.SetStatus(eReturnStatusSuccessFinishResult); + return true; + } + + // Dump specified ASTs (by basename or fullpath) + for (const Args::ArgEntry &arg : command.entries()) { + ModuleList module_list; + const size_t num_matches = + FindModulesByName(target, arg.c_str(), module_list, true); + if (num_matches == 0) { + // Check the global list + std::lock_guard guard( + Module::GetAllocationModuleCollectionMutex()); + + result.AppendWarningWithFormat( + "Unable to find an image that matches '%s'.\n", arg.c_str()); + continue; + } + + for (size_t i = 0; i < num_matches; ++i) { + if (m_interpreter.WasInterrupted()) + break; + Module *m = module_list.GetModulePointerAtIndex(i); + SymbolFile *sf = m->GetSymbolVendor()->GetSymbolFile(); + sf->DumpClangAST(result.GetOutputStream()); + } + } + result.SetStatus(eReturnStatusSuccessFinishResult); + return true; + } +}; + #pragma mark CommandObjectTargetModulesDumpSymfile //---------------------------------------------------------------------- @@ -2348,6 +2420,8 @@ class CommandObjectTargetModulesDumpLineTable ~CommandObjectTargetModulesDumpLineTable() override = default; + Options *GetOptions() override { return &m_options; } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { Target *target = m_exe_ctx.GetTargetPtr(); @@ -2367,7 +2441,7 @@ class CommandObjectTargetModulesDumpLineTable for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; ++arg_idx) { - FileSpec file_spec(arg_cstr, false); + FileSpec file_spec(arg_cstr); const ModuleList &target_modules = target->GetImages(); std::lock_guard guard(target_modules.GetMutex()); @@ -2380,8 +2454,9 @@ class CommandObjectTargetModulesDumpLineTable if (DumpCompileUnitLineTable( m_interpreter, result.GetOutputStream(), target_modules.GetModulePointerAtIndexUnlocked(i), - file_spec, m_exe_ctx.GetProcessPtr() && - m_exe_ctx.GetProcessRef().IsAlive())) + file_spec, + m_options.m_verbose ? eDescriptionLevelFull + : eDescriptionLevelBrief)) num_dumped++; } if (num_dumped == 0) @@ -2401,6 +2476,43 @@ class CommandObjectTargetModulesDumpLineTable } return result.Succeeded(); } + + class CommandOptions : public Options { + public: + CommandOptions() : Options() { OptionParsingStarting(nullptr); } + + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + assert(option_idx == 0 && "We only have one option."); + m_verbose = true; + + return Status(); + } + + void OptionParsingStarting(ExecutionContext *execution_context) override { + m_verbose = false; + } + + llvm::ArrayRef GetDefinitions() override { + static constexpr OptionDefinition g_options[] = { + {LLDB_OPT_SET_ALL, + false, + "verbose", + 'v', + OptionParser::eNoArgument, + nullptr, + {}, + 0, + eArgTypeNone, + "Enable verbose dump."}, + }; + return llvm::makeArrayRef(g_options); + } + + bool m_verbose; + }; + + CommandOptions m_options; }; #pragma mark CommandObjectTargetModulesDump @@ -2415,12 +2527,13 @@ class CommandObjectTargetModulesDump : public CommandObjectMultiword { // Constructors and Destructors //------------------------------------------------------------------ CommandObjectTargetModulesDump(CommandInterpreter &interpreter) - : CommandObjectMultiword(interpreter, "target modules dump", - "Commands for dumping information about one or " - "more target modules.", - "target modules dump " - "[headers|symtab|sections|symfile|line-table] " - "[ ...]") { + : CommandObjectMultiword( + interpreter, "target modules dump", + "Commands for dumping information about one or " + "more target modules.", + "target modules dump " + "[headers|symtab|sections|ast|symfile|line-table] " + "[ ...]") { LoadSubCommand("objfile", CommandObjectSP( new CommandObjectTargetModulesDumpObjfile(interpreter))); @@ -2433,6 +2546,9 @@ class CommandObjectTargetModulesDump : public CommandObjectMultiword { LoadSubCommand("symfile", CommandObjectSP( new CommandObjectTargetModulesDumpSymfile(interpreter))); + LoadSubCommand( + "ast", CommandObjectSP( + new CommandObjectTargetModulesDumpClangAST(interpreter))); LoadSubCommand("line-table", CommandObjectSP(new CommandObjectTargetModulesDumpLineTable( interpreter))); @@ -2547,8 +2663,8 @@ class CommandObjectTargetModulesAdd : public CommandObjectParsed { if (entry.ref.empty()) continue; - FileSpec file_spec(entry.ref, true); - if (file_spec.Exists()) { + FileSpec file_spec(entry.ref); + if (FileSystem::Instance().Exists(file_spec)) { ModuleSpec module_spec(file_spec); if (m_uuid_option_group.GetOptionValue().OptionWasSet()) module_spec.GetUUID() = @@ -2815,10 +2931,15 @@ class CommandObjectTargetModulesLoad } if (set_pc) { ThreadList &thread_list = process->GetThreadList(); - ThreadSP curr_thread(thread_list.GetSelectedThread()); RegisterContextSP reg_context( - curr_thread->GetRegisterContext()); - reg_context->SetPC(file_entry.GetLoadAddress(target)); + thread_list.GetSelectedThread()->GetRegisterContext()); + addr_t file_entry_addr = file_entry.GetLoadAddress(target); + if (!reg_context->SetPC(file_entry_addr)) { + result.AppendErrorWithFormat("failed to set PC value to " + "0x%" PRIx64 "\n", + file_entry_addr); + result.SetStatus(eReturnStatusFailed); + } } } } else { @@ -2897,8 +3018,8 @@ static constexpr OptionDefinition g_target_modules_list_options[] = { { LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Display the image at this address." }, { LLDB_OPT_SET_1, false, "arch", 'A', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the architecture when listing images." }, { LLDB_OPT_SET_1, false, "triple", 't', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the triple when listing images." }, - { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image header address as a load address if debugging, a file address otherwise." }, - { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image header address offset from the header file address (the slide amount)." }, + { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image base address as a load address if debugging, a file address otherwise." }, + { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image load address offset from the base file address (the slide amount)." }, { LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the UUID when listing images." }, { LLDB_OPT_SET_1, false, "fullpath", 'f', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the fullpath to the image object file." }, { LLDB_OPT_SET_1, false, "directory", 'd', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the directory with optional width for the image object file." }, @@ -3157,13 +3278,13 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { ObjectFile *objfile = module->GetObjectFile(); if (objfile) { - Address header_addr(objfile->GetHeaderAddress()); - if (header_addr.IsValid()) { + Address base_addr(objfile->GetBaseAddress()); + if (base_addr.IsValid()) { if (target && !target->GetSectionLoadList().IsEmpty()) { - lldb::addr_t header_load_addr = - header_addr.GetLoadAddress(target); - if (header_load_addr == LLDB_INVALID_ADDRESS) { - header_addr.Dump(&strm, target, + lldb::addr_t load_addr = + base_addr.GetLoadAddress(target); + if (load_addr == LLDB_INVALID_ADDRESS) { + base_addr.Dump(&strm, target, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleFileAddress); } else { @@ -3171,18 +3292,18 @@ class CommandObjectTargetModulesList : public CommandObjectParsed { // Show the offset of slide for the image strm.Printf( "0x%*.*" PRIx64, addr_nibble_width, addr_nibble_width, - header_load_addr - header_addr.GetFileAddress()); + load_addr - base_addr.GetFileAddress()); } else { // Show the load address of the image strm.Printf("0x%*.*" PRIx64, addr_nibble_width, - addr_nibble_width, header_load_addr); + addr_nibble_width, load_addr); } } break; } // The address was valid, but the image isn't loaded, output the // address in an appropriate format - header_addr.Dump(&strm, target, Address::DumpStyleFileAddress); + base_addr.Dump(&strm, target, Address::DumpStyleFileAddress); break; } } @@ -3626,7 +3747,7 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { break; case 'f': - m_file.SetFile(option_arg, false, FileSpec::Style::native); + m_file.SetFile(option_arg, FileSpec::Style::native); m_type = eLookupTypeFileLine; break; @@ -3760,8 +3881,9 @@ class CommandObjectTargetModulesLookup : public CommandObjectParsed { return false; case eLookupTypeType: if (!m_options.m_str.empty()) { - if (LookupTypeHere(m_interpreter, result.GetOutputStream(), sym_ctx, - m_options.m_str.c_str(), m_options.m_use_regex)) { + if (LookupTypeHere(m_interpreter, result.GetOutputStream(), + *sym_ctx.module_sp, m_options.m_str.c_str(), + m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; } @@ -4265,7 +4387,8 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed { ModuleSP frame_module_sp( frame->GetSymbolContext(eSymbolContextModule).module_sp); if (frame_module_sp) { - if (frame_module_sp->GetPlatformFileSpec().Exists()) { + if (FileSystem::Instance().Exists( + frame_module_sp->GetPlatformFileSpec())) { module_spec.GetArchitecture() = frame_module_sp->GetArchitecture(); module_spec.GetFileSpec() = @@ -4312,7 +4435,7 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed { module_spec.GetArchitecture() = target->GetArchitecture(); } success |= module_spec.GetUUID().IsValid() || - module_spec.GetFileSpec().Exists(); + FileSystem::Instance().Exists(module_spec.GetFileSpec()); } } @@ -4357,8 +4480,9 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed { for (auto &entry : args.entries()) { if (!entry.ref.empty()) { - module_spec.GetSymbolFileSpec().SetFile(entry.ref, true, - FileSpec::Style::native); + auto &symbol_file_spec = module_spec.GetSymbolFileSpec(); + symbol_file_spec.SetFile(entry.ref, FileSpec::Style::native); + FileSystem::Instance().Resolve(symbol_file_spec); if (file_option_set) { module_spec.GetFileSpec() = m_file_option.GetOptionValue().GetCurrentValue(); @@ -4372,7 +4496,8 @@ class CommandObjectTargetSymbolsAdd : public CommandObjectParsed { } ArchSpec arch; - bool symfile_exists = module_spec.GetSymbolFileSpec().Exists(); + bool symfile_exists = + FileSystem::Instance().Exists(module_spec.GetSymbolFileSpec()); if (symfile_exists) { if (!AddModuleSymbols(target, module_spec, flush, result)) diff --git a/source/Commands/CommandObjectTarget.h b/source/Commands/CommandObjectTarget.h index 643ce547dcb6..4ab2da447697 100644 --- a/source/Commands/CommandObjectTarget.h +++ b/source/Commands/CommandObjectTarget.h @@ -1,9 +1,8 @@ //===-- CommandObjectTarget.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp index f45cf56b1cd2..90926a0ef274 100644 --- a/source/Commands/CommandObjectThread.cpp +++ b/source/Commands/CommandObjectThread.cpp @@ -1,20 +1,14 @@ //===-- CommandObjectThread.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectThread.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/SourceManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" #include "lldb/Host/OptionParser.h" @@ -37,6 +31,7 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/State.h" #include "lldb/lldb-private.h" using namespace lldb; @@ -1523,6 +1518,51 @@ class CommandObjectThreadInfo : public CommandObjectIterateOverThreads { CommandOptions m_options; }; +//------------------------------------------------------------------------- +// CommandObjectThreadException +//------------------------------------------------------------------------- + +class CommandObjectThreadException : public CommandObjectIterateOverThreads { + public: + CommandObjectThreadException(CommandInterpreter &interpreter) + : CommandObjectIterateOverThreads( + interpreter, "thread exception", + "Display the current exception object for a thread. Defaults to " + "the current thread.", + "thread exception", + eCommandRequiresProcess | eCommandTryTargetAPILock | + eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {} + + ~CommandObjectThreadException() override = default; + + bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override { + ThreadSP thread_sp = + m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid); + if (!thread_sp) { + result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n", + tid); + result.SetStatus(eReturnStatusFailed); + return false; + } + + Stream &strm = result.GetOutputStream(); + ValueObjectSP exception_object_sp = thread_sp->GetCurrentException(); + if (exception_object_sp) { + exception_object_sp->Dump(strm); + } + + ThreadSP exception_thread_sp = thread_sp->GetCurrentExceptionBacktrace(); + if (exception_thread_sp && exception_thread_sp->IsValid()) { + const uint32_t num_frames_with_source = 0; + const bool stop_format = false; + exception_thread_sp->GetStatus(strm, 0, UINT32_MAX, + num_frames_with_source, stop_format); + } + + return true; + } +}; + //------------------------------------------------------------------------- // CommandObjectThreadReturn //------------------------------------------------------------------------- @@ -1738,7 +1778,7 @@ class CommandObjectThreadJump : public CommandObjectParsed { switch (short_option) { case 'f': - m_filenames.AppendIfUnique(FileSpec(option_arg, false)); + m_filenames.AppendIfUnique(FileSpec(option_arg)); if (m_filenames.GetSize() > 1) return Status("only one source file expected."); break; @@ -2068,6 +2108,9 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread( CommandObjectSP(new CommandObjectThreadUntil(interpreter))); LoadSubCommand("info", CommandObjectSP(new CommandObjectThreadInfo(interpreter))); + LoadSubCommand( + "exception", + CommandObjectSP(new CommandObjectThreadException(interpreter))); LoadSubCommand("step-in", CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope( interpreter, "thread step-in", diff --git a/source/Commands/CommandObjectThread.h b/source/Commands/CommandObjectThread.h index 589031e0a038..77729ceecd63 100644 --- a/source/Commands/CommandObjectThread.h +++ b/source/Commands/CommandObjectThread.h @@ -1,19 +1,14 @@ //===-- CommandObjectThread.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectThread_h_ #define liblldb_CommandObjectThread_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp index 7f3b20c2dc7e..5bca2cba6338 100644 --- a/source/Commands/CommandObjectType.cpp +++ b/source/Commands/CommandObjectType.cpp @@ -1,24 +1,19 @@ //===-- CommandObjectType.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectType.h" -// C Includes -// C++ Includes #include #include #include -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/State.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -39,9 +34,9 @@ #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StringList.h" -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" using namespace lldb; @@ -1013,6 +1008,7 @@ class CommandObjectTypeFormatClear : public CommandObjectTypeFormatterClear { "type format clear", "Delete all existing format styles.") {} }; + template class CommandObjectTypeFormatterList : public CommandObjectParsed { typedef typename FormatterType::SharedPointer FormatterSharedPointer; @@ -2911,7 +2907,7 @@ class CommandObjectTypeLookup : public CommandObjectRaw { if (StackFrame *frame = m_exe_ctx.GetFramePtr()) { guessed_language = GuessLanguage(frame); if (guessed_language != eLanguageTypeUnknown) { - std::sort( + llvm::sort( languages.begin(), languages.end(), [guessed_language](Language *lang1, Language *lang2) -> bool { if (!lang1 || !lang2) diff --git a/source/Commands/CommandObjectType.h b/source/Commands/CommandObjectType.h index f2f9ce7c1b61..ebb19039e503 100644 --- a/source/Commands/CommandObjectType.h +++ b/source/Commands/CommandObjectType.h @@ -1,20 +1,15 @@ //===-- CommandObjectType.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectType_h_ #define liblldb_CommandObjectType_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/Options.h" diff --git a/source/Commands/CommandObjectVersion.cpp b/source/Commands/CommandObjectVersion.cpp index 8b1f25bfc521..6f5264fe5e1b 100644 --- a/source/Commands/CommandObjectVersion.cpp +++ b/source/Commands/CommandObjectVersion.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectVersion.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectVersion.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/lldb-private.h" diff --git a/source/Commands/CommandObjectVersion.h b/source/Commands/CommandObjectVersion.h index 5f661cc341c0..5fc5499f56b8 100644 --- a/source/Commands/CommandObjectVersion.h +++ b/source/Commands/CommandObjectVersion.h @@ -1,19 +1,14 @@ //===-- CommandObjectVersion.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectVersion_h_ #define liblldb_CommandObjectVersion_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" namespace lldb_private { diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp index 34423156fa5c..fb4a4e23b3dc 100644 --- a/source/Commands/CommandObjectWatchpoint.cpp +++ b/source/Commands/CommandObjectWatchpoint.cpp @@ -1,23 +1,18 @@ //===-- CommandObjectWatchpoint.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectWatchpoint.h" #include "CommandObjectWatchpointCommand.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Core/ValueObject.h" @@ -142,11 +137,9 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs( return false; wp_ids.push_back(beg); } - // It is an error if after the loop, we're still in_range. - if (in_range) - return false; - return true; // Success! + // It is an error if after the loop, we're still in_range. + return !in_range; } //------------------------------------------------------------------------- diff --git a/source/Commands/CommandObjectWatchpoint.h b/source/Commands/CommandObjectWatchpoint.h index adc0a81fa69c..2973bd816ff1 100644 --- a/source/Commands/CommandObjectWatchpoint.h +++ b/source/Commands/CommandObjectWatchpoint.h @@ -1,20 +1,15 @@ //===-- CommandObjectWatchpoint.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectWatchpoint_h_ #define liblldb_CommandObjectWatchpoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/OptionGroupWatchpoint.h" #include "lldb/Interpreter/Options.h" diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp index ceb547034ff6..05bdcb3b9357 100644 --- a/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/source/Commands/CommandObjectWatchpointCommand.cpp @@ -1,30 +1,25 @@ //===-- CommandObjectWatchpointCommand.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "CommandObjectWatchpoint.h" #include "CommandObjectWatchpointCommand.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Core/State.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Commands/CommandObjectWatchpointCommand.h b/source/Commands/CommandObjectWatchpointCommand.h index 63152f2f68a6..22eea2424f12 100644 --- a/source/Commands/CommandObjectWatchpointCommand.h +++ b/source/Commands/CommandObjectWatchpointCommand.h @@ -1,20 +1,15 @@ //===-- CommandObjectWatchpointCommand.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectWatchpointCommand_h_ #define liblldb_CommandObjectWatchpointCommand_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/Options.h" diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp index f183245f7d36..0efe071af095 100644 --- a/source/Core/Address.cpp +++ b/source/Core/Address.cpp @@ -1,52 +1,51 @@ //===-- Address.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Address.h" #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" // for ModuleList +#include "lldb/Core/ModuleList.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/Block.h" -#include "lldb/Symbol/Declaration.h" // for Declaration -#include "lldb/Symbol/LineEntry.h" // for LineEntry +#include "lldb/Symbol/Declaration.h" +#include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/Symbol.h" // for Symbol -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Symbol/Symtab.h" // for Symtab -#include "lldb/Symbol/Type.h" // for Type +#include "lldb/Symbol/Symtab.h" +#include "lldb/Symbol/Type.h" #include "lldb/Symbol/Variable.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ExecutionContextScope.h" // for ExecutionContextScope +#include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/DataExtractor.h" // for DataExtractor -#include "lldb/Utility/Endian.h" // for InlHostByteOrder -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/Utility/Status.h" // for Status -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/Utility/StreamString.h" // for StreamString - -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Endian.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StreamString.h" + +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH +#include "llvm/Support/Compiler.h" -#include // for uint8_t, uint32_t -#include // for shared_ptr, operator!= -#include // for vector +#include +#include +#include -#include // for assert -#include // for PRIu64, PRIx64 -#include // for size_t, strlen +#include +#include +#include namespace lldb_private { class CompileUnit; @@ -779,8 +778,9 @@ bool Address::SectionWasDeletedPrivate() const { m_section_wp.owner_before(empty_section_wp); } -uint32_t Address::CalculateSymbolContext(SymbolContext *sc, - uint32_t resolve_scope) const { +uint32_t +Address::CalculateSymbolContext(SymbolContext *sc, + SymbolContextItem resolve_scope) const { sc->Clear(false); // Absolute addresses don't have enough information to reconstruct even their // target. @@ -987,8 +987,10 @@ AddressClass Address::GetAddressClass() const { if (module_sp) { ObjectFile *obj_file = module_sp->GetObjectFile(); if (obj_file) { - // Give the symbol vendor a chance to add to the unified section list. - module_sp->GetSymbolVendor(); + // Give the symbol vendor a chance to add to the unified section list + // and to symtab from symbol file + if (SymbolVendor *vendor = module_sp->GetSymbolVendor()) + vendor->GetSymtab(); return obj_file->GetAddressClass(GetFileAddress()); } } diff --git a/source/Core/AddressRange.cpp b/source/Core/AddressRange.cpp index e125b693d6f6..f23684047b37 100644 --- a/source/Core/AddressRange.cpp +++ b/source/Core/AddressRange.cpp @@ -1,25 +1,24 @@ //===-- AddressRange.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS +#include "lldb/lldb-defines.h" -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH +#include "llvm/Support/Compiler.h" -#include // for shared_ptr +#include -#include // for PRIx64 +#include namespace lldb_private { class SectionList; diff --git a/source/Core/AddressResolver.cpp b/source/Core/AddressResolver.cpp index 8d7cc9f6a428..c2580c2d4d83 100644 --- a/source/Core/AddressResolver.cpp +++ b/source/Core/AddressResolver.cpp @@ -1,9 +1,8 @@ //===-- AddressResolver.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/AddressResolverFileLine.cpp b/source/Core/AddressResolverFileLine.cpp index 3295ef174a7c..5fd1da6dd533 100644 --- a/source/Core/AddressResolverFileLine.cpp +++ b/source/Core/AddressResolverFileLine.cpp @@ -1,29 +1,28 @@ //===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/AddressResolverFileLine.h" -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/Address.h" +#include "lldb/Core/AddressRange.h" #include "lldb/Symbol/CompileUnit.h" -#include "lldb/Symbol/LineEntry.h" // for LineEntry +#include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet, LIB... -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "lldb/lldb-enumerations.h" // for SymbolContextItem::eSymbolCon... -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-types.h" -#include // for PRIx64 -#include // for vector +#include +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Core/AddressResolverName.cpp b/source/Core/AddressResolverName.cpp index ec03815cf5f6..e861368c0a25 100644 --- a/source/Core/AddressResolverName.cpp +++ b/source/Core/AddressResolverName.cpp @@ -1,33 +1,32 @@ //===-- AddressResolverName.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/AddressResolverName.h" -#include "lldb/Core/Address.h" // for Address, operator== -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/Address.h" +#include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet, LIB... -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/lldb-enumerations.h" // for SymbolType::eSymbolTypeCode -#include "lldb/lldb-forward.h" // for ModuleSP -#include "lldb/lldb-types.h" // for addr_t -#include "llvm/ADT/StringRef.h" // for StringRef - -#include // for shared_ptr -#include // for string -#include // for vector - -#include // for uint32_t +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" +#include "llvm/ADT/StringRef.h" + +#include +#include +#include + +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Core/CMakeLists.txt b/source/Core/CMakeLists.txt index 28e9132fc9ef..079de8500560 100644 --- a/source/Core/CMakeLists.txt +++ b/source/Core/CMakeLists.txt @@ -13,7 +13,6 @@ add_lldb_library(lldbCore AddressResolver.cpp AddressResolverFileLine.cpp AddressResolverName.cpp - Broadcaster.cpp Communication.cpp Debugger.cpp Disassembler.cpp @@ -21,26 +20,21 @@ add_lldb_library(lldbCore DumpRegisterValue.cpp DynamicLoader.cpp EmulateInstruction.cpp - Event.cpp FileLineResolver.cpp FileSpecList.cpp FormatEntity.cpp Highlighter.cpp IOHandler.cpp - Listener.cpp Mangled.cpp Module.cpp ModuleChild.cpp ModuleList.cpp Opcode.cpp PluginManager.cpp - RegisterValue.cpp RichManglingContext.cpp - Scalar.cpp SearchFilter.cpp Section.cpp SourceManager.cpp - State.cpp StreamAsynchronousIO.cpp StreamFile.cpp UserSettingsController.cpp @@ -86,3 +80,7 @@ add_lldb_library(lldbCore # Needed to properly resolve references in a debug build. # TODO: Remove once we have better layering set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 4) + +if (NOT LLDB_DISABLE_LIBEDIT) + target_include_directories(lldbCore PRIVATE ${libedit_INCLUDE_DIRS}) +endif() diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp index 5ca338639de0..ed5f5a559c54 100644 --- a/source/Core/Communication.cpp +++ b/source/Core/Communication.cpp @@ -1,36 +1,35 @@ //===-- Communication.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Communication.h" -#include "lldb/Core/Event.h" -#include "lldb/Core/Listener.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Utility/Connection.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/Listener.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for LogIfAnyCategoriesSet, LIBLLDB... -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Status.h" -#include "llvm/ADT/None.h" // for None -#include "llvm/ADT/Optional.h" // for Optional -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" +#include "llvm/Support/Compiler.h" -#include // for min -#include // for duration, seconds +#include +#include #include -#include // for shared_ptr +#include -#include // for EIO -#include // for PRIu64 -#include // for snprintf +#include +#include +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp index a8b95845e531..2dd0fd478025 100644 --- a/source/Core/Debugger.cpp +++ b/source/Core/Debugger.cpp @@ -1,55 +1,48 @@ //===-- Debugger.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Debugger.h" -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "swift/Basic/Version.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Breakpoint/Breakpoint.h" // for Breakpoint, Brea... -#include "lldb/Core/Event.h" // for Event, EventData... +#include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/FormatEntity.h" -#include "lldb/Core/Listener.h" // for Listener -#include "lldb/Core/Mangled.h" // for Mangled -#include "lldb/Core/ModuleList.h" // for Mangled +#include "lldb/Core/Mangled.h" +#include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamAsynchronousIO.h" #include "lldb/Core/StreamFile.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Expression/REPL.h" -#include "lldb/Host/File.h" // for File, File::kInv... +#include "lldb/Host/File.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Terminal.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/OptionValue.h" // for OptionValue, Opt... +#include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/OptionValueSInt64.h" #include "lldb/Interpreter/OptionValueString.h" -#include "lldb/Interpreter/Property.h" // for PropertyDefinition -#include "lldb/Interpreter/ScriptInterpreter.h" // for ScriptInterpreter +#include "lldb/Interpreter/Property.h" +#include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/Language.h" #include "lldb/Target/Language.h" #include "lldb/Target/Process.h" @@ -57,35 +50,41 @@ #include "lldb/Target/Target.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Thread.h" -#include "lldb/Target/ThreadList.h" // for ThreadList +#include "lldb/Target/ThreadList.h" #include "lldb/Utility/AnsiTerminal.h" -#include "lldb/Utility/Log.h" // for LLDB_LOG_OPTION_... -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Event.h" +#include "lldb/Utility/Listener.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Reproducer.h" +#include "lldb/Utility/State.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamCallback.h" #include "lldb/Utility/StreamString.h" #if defined(_WIN32) -#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX +#include "lldb/Host/windows/PosixApi.h" +#include "lldb/Host/windows/windows.h" #endif -#include "llvm/ADT/None.h" // for None -#include "llvm/ADT/STLExtras.h" // for make_unique +#include "llvm/ADT/None.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator.h" // for iterator_facade_... +#include "llvm/ADT/iterator.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Process.h" #include "llvm/Support/Threading.h" -#include "llvm/Support/raw_ostream.h" // for raw_fd_ostream +#include "llvm/Support/raw_ostream.h" -#include // for list -#include // for make_shared +#include +#include #include -#include // for set -#include // for size_t, NULL -#include // for getenv -#include // for strcmp -#include // for string -#include // for error_code +#include +#include +#include +#include +#include +#include namespace lldb_private { class Address; @@ -242,8 +241,8 @@ static constexpr OptionEnumValueElement g_language_enumerators[] = { // address <+offset>: #define DEFAULT_DISASSEMBLY_FORMAT \ "{${function.initial-function}{${module.file.basename}`}{${function.name-" \ - "without-args}}:\n}{${function.changed}\n{${module.file.basename}`}{${" \ - "function.name-without-args}}:\n}{${current-pc-arrow} " \ + "without-args}}:\\n}{${function.changed}\\n{${module.file.basename}`}{${" \ + "function.name-without-args}}:\\n}{${current-pc-arrow} " \ "}${addr-file-or-load}{ " \ "<${function.concrete-only-addr-offset-no-padding}>}: " @@ -488,6 +487,11 @@ void Debugger::SetPrompt(llvm::StringRef p) { GetCommandInterpreter().UpdatePrompt(new_prompt); } +llvm::StringRef Debugger::GetReproducerPath() const { + auto &r = repro::Reproducer::Instance(); + return r.GetReproducerPath().GetCString(); +} + const FormatEntity::Entry *Debugger::GetThreadFormat() const { const uint32_t idx = ePropertyThreadFormat; return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx); @@ -681,16 +685,16 @@ bool Debugger::LoadPlugin(const FileSpec &spec, Status &error) { return false; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { Status error; static ConstString g_dylibext(".dylib"); static ConstString g_solibext(".so"); if (!baton) - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; Debugger *debugger = (Debugger *)baton; @@ -701,18 +705,18 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, // file type information. if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { - FileSpec plugin_file_spec(file_spec); - plugin_file_spec.ResolvePath(); + FileSpec plugin_file_spec(path); + FileSystem::Instance().Resolve(plugin_file_spec); if (plugin_file_spec.GetFileNameExtension() != g_dylibext && plugin_file_spec.GetFileNameExtension() != g_solibext) { - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } Status plugin_load_error; debugger->LoadPlugin(plugin_file_spec, plugin_load_error); - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } else if (ft == fs::file_type::directory_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { @@ -720,10 +724,10 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, // also do this for unknown as sometimes the directory enumeration might be // enumerating a file system that doesn't have correct file type // information. - return FileSpec::eEnumerateDirectoryResultEnter; + return FileSystem::eEnumerateDirectoryResultEnter; } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } void Debugger::InstanceInitialize() { @@ -732,16 +736,20 @@ void Debugger::InstanceInitialize() { const bool find_other = true; char dir_path[PATH_MAX]; if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) { - if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, this); + if (FileSystem::Instance().Exists(dir_spec) && + dir_spec.GetPath(dir_path, sizeof(dir_path))) { + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, this); } } if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) { - if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, this); + if (FileSystem::Instance().Exists(dir_spec) && + dir_spec.GetPath(dir_path, sizeof(dir_path))) { + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, this); } } @@ -879,6 +887,12 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) // Turn off use-color if we don't write to a terminal with color support. if (!m_output_file_sp->GetFile().GetIsTerminalWithColors()) SetUseColor(false); + +#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) + // Enabling use of ANSI color codes because LLDB is using them to highlight + // text. + llvm::sys::Process::UseANSIEscapeCodes(true); +#endif } Debugger::~Debugger() { Clear(); } diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp index d41a19465280..c67677dbcf6c 100644 --- a/source/Core/Disassembler.cpp +++ b/source/Core/Disassembler.cpp @@ -1,22 +1,21 @@ //===-- Disassembler.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Disassembler.h" -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/AddressRange.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/Mangled.h" // for Mangled, Mangled... +#include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" // for ModuleList +#include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/SourceManager.h" // for SourceManager +#include "lldb/Core/SourceManager.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValueArray.h" @@ -25,31 +24,31 @@ #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Symbol/Function.h" -#include "lldb/Symbol/Symbol.h" // for Symbol -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" -#include "lldb/Target/Thread.h" // for Thread +#include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/Utility/StreamString.h" // for StreamString +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" -#include "lldb/lldb-private-enumerations.h" // for InstructionType:... -#include "lldb/lldb-private-interfaces.h" // for DisassemblerCrea... -#include "lldb/lldb-private-types.h" // for RegisterInfo -#include "llvm/ADT/Triple.h" // for Triple, Triple::... -#include "llvm/Support/Compiler.h" // for LLVM_PRETTY_FUNC... +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-interfaces.h" +#include "lldb/lldb-private-types.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Support/Compiler.h" -#include // for uint32_t, UINT32... +#include #include -#include // for pair +#include -#include // for assert +#include #define DEFAULT_DISASM_BYTE_SIZE 32 @@ -429,9 +428,9 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr, const Address &addr = inst->GetAddress(); ModuleSP module_sp(addr.GetModule()); if (module_sp) { - const uint32_t resolve_mask = eSymbolContextFunction | - eSymbolContextSymbol | - eSymbolContextLineEntry; + const SymbolContextItem resolve_mask = eSymbolContextFunction | + eSymbolContextSymbol | + eSymbolContextLineEntry; uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(addr, resolve_mask, sc); if (resolved_mask) { @@ -452,8 +451,7 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr, if (mixed_source_and_assembly && sc.line_entry.IsValid()) { if (sc.symbol != previous_symbol) { SourceLine decl_line = GetFunctionDeclLineEntry(sc); - if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, decl_line) == - false) + if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, decl_line)) AddLineToSourceLineTables(decl_line, source_lines_seen); } if (sc.line_entry.IsValid()) { @@ -461,8 +459,7 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr, this_line.file = sc.line_entry.file; this_line.line = sc.line_entry.line; this_line.column = sc.line_entry.column; - if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, this_line) == - false) + if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, this_line)) AddLineToSourceLineTables(this_line, source_lines_seen); } } @@ -506,8 +503,8 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr, previous_symbol = sc.symbol; if (sc.function && sc.line_entry.IsValid()) { LineEntry prologue_end_line = sc.line_entry; - if (ElideMixedSourceAndDisassemblyLine( - exe_ctx, sc, prologue_end_line) == false) { + if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, + prologue_end_line)) { FileSpec func_decl_file; uint32_t func_decl_line; sc.function->GetStartLineSourceInfo(func_decl_file, @@ -547,8 +544,8 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr, this_line.file = sc.line_entry.file; this_line.line = sc.line_entry.line; - if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, - this_line) == false) { + if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, + this_line)) { // Only print this source line if it is different from the // last source line we printed. There may have been inlined // functions between these lines that we elided, resulting in @@ -934,7 +931,7 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) { out_stream->Printf("Instruction::TestEmulation: Missing file_name."); return false; } - FILE *test_file = FileSystem::Fopen(file_name, "r"); + FILE *test_file = FileSystem::Instance().Fopen(file_name, "r"); if (!test_file) { out_stream->Printf( "Instruction::TestEmulation: Attempt to open test file failed."); diff --git a/source/Core/DumpDataExtractor.cpp b/source/Core/DumpDataExtractor.cpp index 049f4d3805a1..e96155a215d4 100644 --- a/source/Core/DumpDataExtractor.cpp +++ b/source/Core/DumpDataExtractor.cpp @@ -1,20 +1,19 @@ //===-- DumpDataExtractor.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for TargetSP, DisassemblerSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/ModuleList.h" // for ModuleList +#include "lldb/Core/ModuleList.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ExecutionContextScope.h" @@ -23,22 +22,22 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Stream.h" -#include "clang/AST/ASTContext.h" // for ASTContext -#include "clang/AST/CanonicalType.h" // for CanQualType +#include "clang/AST/ASTContext.h" +#include "clang/AST/CanonicalType.h" -#include "llvm/ADT/APFloat.h" // for APFloat, APFloatBase:... -#include "llvm/ADT/APInt.h" // for APInt -#include "llvm/ADT/ArrayRef.h" // for ArrayRef -#include "llvm/ADT/SmallVector.h" // for SmallVector +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" -#include // for numeric_limits, numer... -#include // for shared_ptr -#include // for string, basic_string +#include +#include +#include -#include // for assert -#include // for isprint -#include // for PRIu64, PRIx64, PRIX64 -#include // for ldexpf +#include +#include +#include +#include #include #include diff --git a/source/Core/DumpRegisterValue.cpp b/source/Core/DumpRegisterValue.cpp index 99334ca78a6d..74b02413f101 100644 --- a/source/Core/DumpRegisterValue.cpp +++ b/source/Core/DumpRegisterValue.cpp @@ -1,16 +1,15 @@ //===-- DumpRegisterValue.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private-types.h" diff --git a/source/Core/DynamicLoader.cpp b/source/Core/DynamicLoader.cpp index 576ec1eaedd3..2e42f55b0dd2 100644 --- a/source/Core/DynamicLoader.cpp +++ b/source/Core/DynamicLoader.cpp @@ -1,31 +1,30 @@ //===-- DynamicLoader.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/DynamicLoader.h" #include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" // for ModuleList +#include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Symbol/ObjectFile.h" // for ObjectFile +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-private-interfaces.h" // for DynamicLoaderCreateInstance +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-private-interfaces.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include // for shared_ptr, unique_ptr +#include -#include // for assert +#include using namespace lldb; using namespace lldb_private; @@ -81,7 +80,7 @@ ModuleSP DynamicLoader::GetTargetExecutable() { ModuleSP executable = target.GetExecutableModule(); if (executable) { - if (executable->GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(executable->GetFileSpec())) { ModuleSpec module_spec(executable->GetFileSpec(), executable->GetArchitecture()); auto module_sp = std::make_shared(module_spec); @@ -195,9 +194,8 @@ ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file, if (error.Success() && memory_info.GetMapped() && memory_info.GetRange().GetRangeBase() == base_addr && !(memory_info.GetName().IsEmpty())) { - ModuleSpec new_module_spec( - FileSpec(memory_info.GetName().AsCString(), false), - target.GetArchitecture()); + ModuleSpec new_module_spec(FileSpec(memory_info.GetName().AsCString()), + target.GetArchitecture()); if ((module_sp = modules.FindFirstModule(new_module_spec))) { UpdateLoadedSections(module_sp, link_map_addr, base_addr, false); diff --git a/source/Core/EmulateInstruction.cpp b/source/Core/EmulateInstruction.cpp index 469022119c9e..3cf68cc61b13 100644 --- a/source/Core/EmulateInstruction.cpp +++ b/source/Core/EmulateInstruction.cpp @@ -1,9 +1,8 @@ //===-- EmulateInstruction.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,27 +11,27 @@ #include "lldb/Core/Address.h" #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/StreamFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" -#include "lldb/Target/StackFrame.h" // for StackFrame -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Target/StackFrame.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" // for Stream, Stream::::eBinary +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "lldb/lldb-forward.h" // for ProcessSP -#include "lldb/lldb-private-interfaces.h" // for EmulateInstructionCreateIn... +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-interfaces.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include -#include // for shared_ptr +#include -#include // for PRIx64, PRId64, PRIu64 -#include // for stdout +#include +#include namespace lldb_private { class Target; diff --git a/source/Core/FileLineResolver.cpp b/source/Core/FileLineResolver.cpp index 083377692ed1..949a4c92a614 100644 --- a/source/Core/FileLineResolver.cpp +++ b/source/Core/FileLineResolver.cpp @@ -1,22 +1,20 @@ //===-- FileLineResolver.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/FileLineResolver.h" -// Project includes -#include "lldb/Core/FileSpecList.h" // for FileSpecList +#include "lldb/Core/FileSpecList.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Stream.h" -#include // for string +#include namespace lldb_private { class Address; diff --git a/source/Core/FileSpecList.cpp b/source/Core/FileSpecList.cpp index 66e27b197447..9c4dd3c60155 100644 --- a/source/Core/FileSpecList.cpp +++ b/source/Core/FileSpecList.cpp @@ -1,20 +1,19 @@ //===-- FileSpecList.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/FileSpecList.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Stream.h" -#include // for find +#include -#include // for UINT32_MAX +#include using namespace lldb_private; using namespace std; diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp index d955c6a33422..f8d6eceb3c78 100644 --- a/source/Core/FormatEntity.cpp +++ b/source/Core/FormatEntity.cpp @@ -1,38 +1,36 @@ //===-- FormatEntity.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/FormatEntity.h" #include "lldb/Core/Address.h" -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/AddressRange.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" // for RegisterValue #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/DataVisualization.h" -#include "lldb/DataFormatters/FormatClasses.h" // for TypeNameSpecifier... +#include "lldb/DataFormatters/FormatClasses.h" #include "lldb/DataFormatters/FormatManager.h" -#include "lldb/DataFormatters/TypeSummary.h" // for TypeSummaryImpl::... +#include "lldb/DataFormatters/TypeSummary.h" #include "lldb/Expression/ExpressionVariable.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/CompileUnit.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/Symbol.h" -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ExecutionContextScope.h" // for ExecutionContextS... +#include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Language.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -42,31 +40,32 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/AnsiTerminal.h" -#include "lldb/Utility/ArchSpec.h" // for ArchSpec -#include "lldb/Utility/ConstString.h" // for ConstString, oper... +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" // for Log -#include "lldb/Utility/Logging.h" // for GetLogIfAllCatego... -#include "lldb/Utility/SharingPtr.h" // for SharingPtr +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/SharingPtr.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "lldb/Utility/StringList.h" // for StringList -#include "lldb/Utility/StructuredData.h" // for StructuredData::O... -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for ValueObjectSP +#include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/Triple.h" // for Triple, Triple::O... -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH - -#include // for isxdigit -#include // for PRIu64, PRIx64 -#include // for shared_ptr, opera... -#include // for sprintf -#include // for strtoul -#include // for size_t, strchr -#include // for move -#include // for pair +#include "llvm/ADT/Triple.h" +#include "llvm/Support/Compiler.h" + +#include +#include +#include +#include +#include +#include +#include +#include namespace lldb_private { class ScriptInterpreter; diff --git a/source/Core/Highlighter.cpp b/source/Core/Highlighter.cpp index c7dd0db83645..0b0aa969bf65 100644 --- a/source/Core/Highlighter.cpp +++ b/source/Core/Highlighter.cpp @@ -1,9 +1,8 @@ //===-- Highlighter.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/IOHandler.cpp b/source/Core/IOHandler.cpp index b4541bb8c2d3..97b331fe5416 100644 --- a/source/Core/IOHandler.cpp +++ b/source/Core/IOHandler.cpp @@ -1,36 +1,31 @@ //===-- IOHandler.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/IOHandler.h" -// C Includes #ifndef LLDB_DISABLE_CURSES #include #include #endif -// C++ Includes #if defined(__APPLE__) #include #endif #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Host/File.h" // for File -#include "lldb/Host/Predicate.h" // for Predicate, ::eBroad... -#include "lldb/Utility/Status.h" // for Status -#include "lldb/Utility/StreamString.h" // for StreamString -#include "lldb/Utility/StringList.h" // for StringList -#include "lldb/lldb-forward.h" // for StreamFileSP +#include "lldb/Host/File.h" +#include "lldb/Utility/Predicate.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StringList.h" +#include "lldb/lldb-forward.h" #ifndef LLDB_DISABLE_LIBEDIT #include "lldb/Host/Editline.h" @@ -40,7 +35,6 @@ #ifndef LLDB_DISABLE_CURSES #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/Block.h" @@ -53,25 +47,26 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" #endif -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #ifdef _MSC_VER #include "lldb/Host/windows/windows.h" #endif -#include // for shared_ptr -#include // for recursive_mutex +#include +#include -#include // for assert -#include // for isspace -#include // for EINTR, errno -#include // for setlocale -#include // for uint32_t, UINT32_MAX -#include // for size_t, fprintf, feof -#include // for strlen -#include // for move +#include +#include +#include +#include +#include +#include +#include +#include using namespace lldb; using namespace lldb_private; @@ -172,12 +167,10 @@ IOHandlerConfirm::IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt, IOHandlerConfirm::~IOHandlerConfirm() = default; -int IOHandlerConfirm::IOHandlerComplete(IOHandler &io_handler, - const char *current_line, - const char *cursor, - const char *last_char, - int skip_first_n_matches, - int max_matches, StringList &matches) { +int IOHandlerConfirm::IOHandlerComplete( + IOHandler &io_handler, const char *current_line, const char *cursor, + const char *last_char, int skip_first_n_matches, int max_matches, + StringList &matches, StringList &descriptions) { if (current_line == cursor) { if (m_default_response) { matches.AppendString("y"); @@ -223,12 +216,10 @@ void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler, } } -int IOHandlerDelegate::IOHandlerComplete(IOHandler &io_handler, - const char *current_line, - const char *cursor, - const char *last_char, - int skip_first_n_matches, - int max_matches, StringList &matches) { +int IOHandlerDelegate::IOHandlerComplete( + IOHandler &io_handler, const char *current_line, const char *cursor, + const char *last_char, int skip_first_n_matches, int max_matches, + StringList &matches, StringList &descriptions) { switch (m_completion) { case Completion::None: break; @@ -236,14 +227,16 @@ int IOHandlerDelegate::IOHandlerComplete(IOHandler &io_handler, case Completion::LLDBCommand: return io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion( current_line, cursor, last_char, skip_first_n_matches, max_matches, - matches); - + matches, descriptions); case Completion::Expression: { + CompletionResult result; CompletionRequest request(current_line, current_line - cursor, - skip_first_n_matches, max_matches, matches); + skip_first_n_matches, max_matches, result); CommandCompletions::InvokeCommonCompletionCallbacks( io_handler.GetDebugger().GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion, request, nullptr); + result.GetMatches(matches); + result.GetDescriptions(descriptions); size_t num_matches = request.GetNumberOfMatches(); if (num_matches > 0) { @@ -433,17 +426,15 @@ int IOHandlerEditline::FixIndentationCallback(Editline *editline, *editline_reader, lines, cursor_position); } -int IOHandlerEditline::AutoCompleteCallback(const char *current_line, - const char *cursor, - const char *last_char, - int skip_first_n_matches, - int max_matches, - StringList &matches, void *baton) { +int IOHandlerEditline::AutoCompleteCallback( + const char *current_line, const char *cursor, const char *last_char, + int skip_first_n_matches, int max_matches, StringList &matches, + StringList &descriptions, void *baton) { IOHandlerEditline *editline_reader = (IOHandlerEditline *)baton; if (editline_reader) return editline_reader->m_delegate.IOHandlerComplete( *editline_reader, current_line, cursor, last_char, skip_first_n_matches, - max_matches, matches); + max_matches, matches, descriptions); return 0; } #endif @@ -1062,7 +1053,7 @@ class Window { Windows::iterator pos, end = m_subwindows.end(); size_t i = 0; for (pos = m_subwindows.begin(); pos != end; ++pos, ++i) { - if ((*pos)->m_name.compare(name) == 0) + if ((*pos)->m_name == name) return *pos; } return WindowSP(); @@ -1754,11 +1745,7 @@ class Application { void Initialize() { ::setlocale(LC_ALL, ""); ::setlocale(LC_CTYPE, ""); -#if 0 - ::initscr(); -#else m_screen = ::newterm(nullptr, m_out, m_in); -#endif ::start_color(); ::curs_set(0); ::noecho(); diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp index 628a4242b6e2..5147e70e7a7c 100644 --- a/source/Core/Mangled.cpp +++ b/source/Core/Mangled.cpp @@ -1,9 +1,8 @@ //===-- Mangled.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,34 +15,32 @@ #pragma comment(lib, "dbghelp.lib") #endif -#include -#include -#include -#include - -#include "swift/Demangling/Demangle.h" -#include "llvm/ADT/DenseMap.h" - #include "lldb/Core/RichManglingContext.h" +#include "lldb/Target/SwiftLanguageRuntime.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" -#include "lldb/Target/SwiftLanguageRuntime.h" -#include -#include -#include #include "lldb/lldb-enumerations.h" #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Demangle/Demangle.h" #include "llvm/Support/Compiler.h" +#include "swift/Demangling/Demangle.h" + +#include +#include +#include + +#include +#include using namespace lldb_private; #if defined(_MSC_VER) @@ -301,9 +298,10 @@ static char *GetMSVCDemangledStr(const char *M) { #endif } -static char *GetItaniumDemangledStr(const char *M, - llvm::ItaniumPartialDemangler &ipd) { +static char *GetItaniumDemangledStr(const char *M) { char *demangled_cstr = nullptr; + + llvm::ItaniumPartialDemangler ipd; bool err = ipd.partialDemangle(M); if (!err) { // Default buffer and size (will realloc in case it's too small). @@ -393,6 +391,7 @@ bool Mangled::DemangleWithRichManglingInfo( } } } + llvm_unreachable("Fully covered switch above!"); } //---------------------------------------------------------------------- @@ -424,8 +423,7 @@ Mangled::GetDemangledName(lldb::LanguageType language) const { demangled_name = GetMSVCDemangledStr(mangled_name); break; case eManglingSchemeItanium: { - llvm::ItaniumPartialDemangler ipd; - demangled_name = GetItaniumDemangledStr(mangled_name, ipd); + demangled_name = GetItaniumDemangledStr(mangled_name); break; } case eManglingSchemeNone: @@ -445,8 +443,8 @@ Mangled::GetDemangledName(lldb::LanguageType language) const { std::string demangled(SwiftLanguageRuntime::DemangleSymbolAsString( mangled_name)); if (!demangled.empty()) { - m_demangled.SetStringWithMangledCounterpart(demangled.c_str(), - m_mangled); + m_demangled.SetStringWithMangledCounterpart(demangled, + m_mangled); if (log) log->Printf("demangle swift: %s -> \"%s\"", mangled_name, demangled.c_str()); @@ -502,9 +500,7 @@ bool Mangled::NameMatches(const RegularExpression ®ex, return true; ConstString demangled = GetDemangledName(language); - if (demangled && regex.Execute(demangled.AsCString())) - return true; - return false; + return demangled && regex.Execute(demangled.AsCString()); } //---------------------------------------------------------------------- diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp index 6def8b6aa7f8..49a1377d2b14 100644 --- a/source/Core/Module.cpp +++ b/source/Core/Module.cpp @@ -1,56 +1,55 @@ //===-- Module.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Module.h" -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/AddressRange.h" #include "lldb/Core/AddressResolverFileLine.h" -#include "lldb/Core/Debugger.h" // for Debugger -#include "lldb/Core/FileSpecList.h" // for FileSpecList -#include "lldb/Core/Mangled.h" // for Mangled +#include "lldb/Core/Debugger.h" +#include "lldb/Core/FileSpecList.h" +#include "lldb/Core/Mangled.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/SearchFilter.h" // for SearchFilt... +#include "lldb/Core/SearchFilter.h" #include "lldb/Core/Section.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Symbol/CompileUnit.h" -#include "lldb/Symbol/Function.h" // for Function +#include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SwiftASTContext.h" -#include "lldb/Symbol/Symbol.h" // for Symbol +#include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Symbol/Symtab.h" // for Symtab -#include "lldb/Symbol/Type.h" // for Type -#include "lldb/Symbol/TypeList.h" // for TypeList +#include "lldb/Symbol/Symtab.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/Language.h" -#include "lldb/Target/Platform.h" // for Platform +#include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/SwiftLanguageRuntime.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAn... +#include "lldb/Utility/Logging.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" #if defined(_WIN32) -#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX +#include "lldb/Host/windows/PosixApi.h" #endif #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" @@ -59,20 +58,20 @@ #include "swift/Basic/LangOptions.h" #include "swift/Frontend/Frontend.h" #include "swift/Serialization/Validation.h" -#include "llvm/ADT/STLExtras.h" // for make_unique -#include "llvm/Support/Compiler.h" // for LLVM_PRETT... +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Signals.h" -#include "llvm/Support/raw_ostream.h" // for raw_string... +#include "llvm/Support/raw_ostream.h" -#include // for assert -#include // for uint32_t -#include // for PRIx64 -#include // for map -#include // for va_end -#include // for size_t -#include // for move -#include // for find, pair +#include +#include +#include +#include +#include +#include +#include +#include namespace lldb_private { class CompilerDeclContext; @@ -167,15 +166,19 @@ Module::Module(const ModuleSpec &module_spec) // fill any ivars in so we don't accidentally grab the wrong file later since // they don't match... ModuleSpec matching_module_spec; - if (modules_specs.FindMatchingModuleSpec(module_spec, matching_module_spec) == - 0) + if (!modules_specs.FindMatchingModuleSpec(module_spec, + matching_module_spec)) { + if (log) { + log->Printf("Found local object file but the specs didn't match"); + } return; + } if (module_spec.GetFileSpec()) - m_mod_time = FileSystem::GetModificationTime(module_spec.GetFileSpec()); + m_mod_time = FileSystem::Instance().GetModificationTime(module_spec.GetFileSpec()); else if (matching_module_spec.GetFileSpec()) m_mod_time = - FileSystem::GetModificationTime(matching_module_spec.GetFileSpec()); + FileSystem::Instance().GetModificationTime(matching_module_spec.GetFileSpec()); // Copy the architecture from the actual spec if we got one back, else use // the one that was specified @@ -220,7 +223,7 @@ Module::Module(const ModuleSpec &module_spec) Module::Module(const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name, lldb::offset_t object_offset, const llvm::sys::TimePoint<> &object_mod_time) - : m_mod_time(FileSystem::GetModificationTime(file_spec)), m_arch(arch), + : m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_arch(arch), m_file(file_spec), m_object_offset(object_offset), m_object_mod_time(object_mod_time), m_file_has_changed(false), m_first_file_changed_log(false) { @@ -310,7 +313,7 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp, // Once we get the object file, update our module with the object // file's architecture since it might differ in vendor/os if some // parts were unknown. - m_objfile_sp->GetArchitecture(m_arch); + m_arch = m_objfile_sp->GetArchitecture(); } else { error.SetErrorString("unable to find suitable object file plug-in"); } @@ -372,24 +375,24 @@ void Module::ParseAllDebugSymbols() { for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) { sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get(); - if (sc.comp_unit) { - sc.function = nullptr; - symbols->ParseVariablesForContext(sc); + if (!sc.comp_unit) + continue; - symbols->ParseCompileUnitFunctions(sc); + symbols->ParseVariablesForContext(sc); - sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) { - sc.function = f.get(); - symbols->ParseFunctionBlocks(sc); - // Parse the variables for this function and all its blocks - symbols->ParseVariablesForContext(sc); - return false; - }); + symbols->ParseFunctions(*sc.comp_unit); - // Parse all types for this compile unit - sc.function = nullptr; - symbols->ParseTypes(sc); - } + sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) { + symbols->ParseBlocksRecursive(*f); + + // Parse the variables for this function and all its blocks + sc.function = f.get(); + symbols->ParseVariablesForContext(sc); + return false; + }); + + // Parse all types for this compile unit + symbols->ParseTypes(*sc.comp_unit); } } @@ -440,8 +443,8 @@ bool Module::ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) { } uint32_t Module::ResolveSymbolContextForAddress( - const Address &so_addr, uint32_t resolve_scope, SymbolContext &sc, - bool resolve_tail_call_address) { + const Address &so_addr, lldb::SymbolContextItem resolve_scope, + SymbolContext &sc, bool resolve_tail_call_address) { std::lock_guard guard(m_mutex); uint32_t resolved_flags = 0; @@ -573,21 +576,17 @@ uint32_t Module::ResolveSymbolContextForAddress( return resolved_flags; } -uint32_t Module::ResolveSymbolContextForFilePath(const char *file_path, - uint32_t line, - bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list) { - FileSpec file_spec(file_path, false); +uint32_t Module::ResolveSymbolContextForFilePath( + const char *file_path, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { + FileSpec file_spec(file_path); return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, resolve_scope, sc_list); } -uint32_t Module::ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, - uint32_t line, - bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list) { +uint32_t Module::ResolveSymbolContextsForFileSpec( + const FileSpec &file_spec, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { std::lock_guard guard(m_mutex); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, @@ -646,9 +645,11 @@ size_t Module::FindCompileUnits(const FileSpec &path, bool append, return sc_list.GetSize() - start_size; } -Module::LookupInfo::LookupInfo(const ConstString &name, uint32_t name_type_mask, - lldb::LanguageType language) - : m_name(name), m_lookup_name(), m_language(language), m_name_type_mask(0), +Module::LookupInfo::LookupInfo(const ConstString &name, + FunctionNameType name_type_mask, + LanguageType language) + : m_name(name), m_lookup_name(), m_language(language), + m_name_type_mask(eFunctionNameTypeNone), m_match_name_after_lookup(false) { const char *name_cstr = name.GetCString(); llvm::StringRef basename; @@ -809,7 +810,7 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list, qualified_name = cpp_method.GetBasename().str(); else qualified_name = cpp_method.GetScopeQualifiedName(); - if (qualified_name.compare(m_name.GetCString()) != 0) { + if (qualified_name != m_name.GetCString()) { sc_list.RemoveContextAtIndex(i); continue; } @@ -823,9 +824,9 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list, size_t Module::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_symbols, - bool include_inlines, bool append, - SymbolContextList &sc_list) { + FunctionNameType name_type_mask, + bool include_symbols, bool include_inlines, + bool append, SymbolContextList &sc_list) { if (!append) sc_list.Clear(); @@ -969,33 +970,33 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp, } size_t Module::FindTypes_Impl( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION); - if (!sc.module_sp || sc.module_sp.get() == this) { - SymbolVendor *symbols = GetSymbolVendor(); - if (symbols) - return symbols->FindTypes(sc, name, parent_decl_ctx, append, max_matches, - searched_symbol_files, types); - } + SymbolVendor *symbols = GetSymbolVendor(); + if (symbols) + return symbols->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); return 0; } -size_t Module::FindTypesInNamespace(const SymbolContext &sc, - const ConstString &type_name, +size_t Module::FindTypesInNamespace(const ConstString &type_name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList &type_list) { const bool append = true; TypeMap types_map; llvm::DenseSet searched_symbol_files; size_t num_types = - FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches, + FindTypes_Impl(type_name, parent_decl_ctx, append, max_matches, searched_symbol_files, types_map); - if (num_types > 0) + if (num_types > 0) { + SymbolContext sc; + sc.module_sp = shared_from_this(); sc.SortTypeList(types_map, type_list); + } return num_types; } @@ -1004,15 +1005,14 @@ lldb::TypeSP Module::FindFirstType(const SymbolContext &sc, TypeList type_list; llvm::DenseSet searched_symbol_files; const size_t num_matches = - FindTypes(sc, name, exact_match, 1, searched_symbol_files, type_list); + FindTypes(name, exact_match, 1, searched_symbol_files, type_list); if (num_matches) return type_list.GetTypeAtIndex(0); return TypeSP(); } size_t Module::FindTypes( - const SymbolContext &sc, const ConstString &name, bool exact_match, - size_t max_matches, + const ConstString &name, bool exact_match, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeList &types) { size_t num_matches = 0; @@ -1032,8 +1032,8 @@ size_t Module::FindTypes( exact_match = type_scope.consume_front("::"); ConstString type_basename_const_str(type_basename); - if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append, - max_matches, searched_symbol_files, typesmap)) { + if (FindTypes_Impl(type_basename_const_str, nullptr, append, max_matches, + searched_symbol_files, typesmap)) { typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class, exact_match); num_matches = typesmap.GetSize(); @@ -1044,13 +1044,13 @@ size_t Module::FindTypes( if (type_class != eTypeClassAny && !type_basename.empty()) { // The "type_name_cstr" will have been modified if we have a valid type // class prefix (like "struct", "class", "union", "typedef" etc). - FindTypes_Impl(sc, ConstString(type_basename), nullptr, append, - UINT_MAX, searched_symbol_files, typesmap); + FindTypes_Impl(ConstString(type_basename), nullptr, append, UINT_MAX, + searched_symbol_files, typesmap); typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class, exact_match); num_matches = typesmap.GetSize(); } else { - num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX, + num_matches = FindTypes_Impl(name, nullptr, append, UINT_MAX, searched_symbol_files, typesmap); if (exact_match) { std::string name_str(name.AsCString("")); @@ -1060,8 +1060,11 @@ size_t Module::FindTypes( } } } - if (num_matches > 0) + if (num_matches > 0) { + SymbolContext sc; + sc.module_sp = shared_from_this(); sc.SortTypeList(typesmap, types); + } return num_matches; } @@ -1088,7 +1091,7 @@ void Module::SetFileSpecAndObjectName(const FileSpec &file, // Container objects whose paths do not specify a file directly can call this // function to correct the file and object names. m_file = file; - m_mod_time = FileSystem::GetModificationTime(file); + m_mod_time = FileSystem::Instance().GetModificationTime(file); m_object_name = object_name; } @@ -1151,7 +1154,7 @@ void Module::ReportError(const char *format, ...) { bool Module::FileHasChanged() const { if (!m_file_has_changed) m_file_has_changed = - (FileSystem::GetModificationTime(m_file) != m_mod_time); + (FileSystem::Instance().GetModificationTime(m_file) != m_mod_time); return m_file_has_changed; } @@ -1278,7 +1281,8 @@ ObjectFile *Module::GetObjectFile() { GetFileSpec().GetFilename().AsCString("")); DataBufferSP data_sp; lldb::offset_t data_offset = 0; - const lldb::offset_t file_size = m_file.GetByteSize(); + const lldb::offset_t file_size = + FileSystem::Instance().GetByteSize(m_file); if (file_size > m_object_offset) { m_did_load_objfile = true; m_objfile_sp = ObjectFile::FindPlugin( @@ -1290,9 +1294,7 @@ ObjectFile *Module::GetObjectFile() { // parts were unknown. But since the matching arch might already be // more specific than the generic COFF architecture, only merge in // those values that overwrite unspecified unknown values. - ArchSpec new_arch; - m_objfile_sp->GetArchitecture(new_arch); - m_arch.MergeFrom(new_arch); + m_arch.MergeFrom(m_objfile_sp->GetArchitecture()); } else { ReportError("failed to load objfile for %s", GetFileSpec().GetPath().c_str()); @@ -1443,7 +1445,7 @@ void Module::PreloadSymbols() { } void Module::SetSymbolFileFileSpec(const FileSpec &file) { - if (!file.Exists()) + if (!FileSystem::Instance().Exists(file)) return; if (m_symfile_ap) { // Remove any sections in the unified section list that come from the @@ -1473,7 +1475,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) { // ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to // check this - if (llvm::sys::fs::is_directory(file.GetPath())) { + if (FileSystem::Instance().IsDirectory(file)) { std::string new_path(file.GetPath()); std::string old_path(obj_file->GetFileSpec().GetPath()); if (old_path.find(new_path) == 0) { @@ -1562,7 +1564,8 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error, if (script_interpreter) { for (uint32_t i = 0; i < num_specs; ++i) { FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i)); - if (scripting_fspec && scripting_fspec.Exists()) { + if (scripting_fspec && + FileSystem::Instance().Exists(scripting_fspec)) { if (should_load == eLoadScriptFromSymFileWarn) { if (feedback_stream) feedback_stream->Printf( diff --git a/source/Core/ModuleChild.cpp b/source/Core/ModuleChild.cpp index 86495742754d..842dcb348a8b 100644 --- a/source/Core/ModuleChild.cpp +++ b/source/Core/ModuleChild.cpp @@ -1,9 +1,8 @@ //===-- ModuleChild.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp index 903c3f8874fe..dc7c101d2e71 100644 --- a/source/Core/ModuleList.cpp +++ b/source/Core/ModuleList.cpp @@ -1,46 +1,45 @@ //===-- ModuleList.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ModuleList.h" -#include "lldb/Core/FileSpecList.h" // for FileSpecList +#include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Symbols.h" -#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/OptionValueFileSpec.h" +#include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/Property.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/SymbolContext.h" // for SymbolContextList, SymbolCon... +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/VariableList.h" -#include "lldb/Utility/ArchSpec.h" // for ArchSpec -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAnyCategoriesSet -#include "lldb/Utility/UUID.h" // for UUID, operator!=, operator== -#include "lldb/lldb-defines.h" // for LLDB_INVALID_INDEX32 +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/UUID.h" +#include "lldb/lldb-defines.h" #if defined(_WIN32) -#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX +#include "lldb/Host/windows/PosixApi.h" #endif -#include "llvm/ADT/StringRef.h" // for StringRef +#include "clang/Driver/Driver.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" -#include "llvm/Support/raw_ostream.h" // for fs -#include "clang/Driver/Driver.h" +#include "llvm/Support/raw_ostream.h" -#include // for operator!=, time_point -#include // for shared_ptr +#include +#include #include -#include // for string -#include // for distance +#include +#include namespace lldb_private { class Function; @@ -71,9 +70,16 @@ namespace { static constexpr PropertyDefinition g_properties[] = { {"enable-external-lookup", OptionValue::eTypeBoolean, true, true, nullptr, {}, - "Control the use of external tools or libraries to locate symbol files. " - "On macOS, Spotlight is used to locate a matching .dSYM bundle based on " - "the UUID of the executable."}, + "Control the use of external tools and repositories to locate symbol " + "files. Directories listed in target.debug-file-search-paths and " + "directory of the executable are always checked first for separate debug " + "info files. Then depending on this setting: " + "On macOS, Spotlight would be also used to locate a matching .dSYM " + "bundle based on the UUID of the executable. " + "On NetBSD, directory /usr/libdata/debug would be also searched. " + "On platforms other than NetBSD directory /usr/lib/debug would be " + "also searched." + }, {"use-swift-dwarfimporter", OptionValue::eTypeBoolean, false, true, nullptr, {}, "Reconstruct Clang module dependencies from DWARF " "when debugging Swift code"}, @@ -353,8 +359,9 @@ ModuleSP ModuleList::GetModuleAtIndexUnlocked(size_t idx) const { } size_t ModuleList::FindFunctions(const ConstString &name, - uint32_t name_type_mask, bool include_symbols, - bool include_inlines, bool append, + FunctionNameType name_type_mask, + bool include_symbols, bool include_inlines, + bool append, SymbolContextList &sc_list) const { if (!append) sc_list.Clear(); @@ -388,7 +395,7 @@ size_t ModuleList::FindFunctions(const ConstString &name, } size_t ModuleList::FindFunctionSymbols(const ConstString &name, - uint32_t name_type_mask, + lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list) { const size_t old_size = sc_list.GetSize(); @@ -619,7 +626,7 @@ ModuleSP ModuleList::FindModule(const UUID &uuid) const { } size_t -ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name, +ModuleList::FindTypes(Module *search_first, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeList &types) const { @@ -627,14 +634,12 @@ ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name, size_t total_matches = 0; collection::const_iterator pos, end = m_modules.end(); - if (sc.module_sp) { - // The symbol context "sc" contains a module so we want to search that one - // first if it is in our list... + if (search_first) { for (pos = m_modules.begin(); pos != end; ++pos) { - if (sc.module_sp.get() == (*pos).get()) { + if (search_first == pos->get()) { total_matches += - (*pos)->FindTypes(sc, name, name_is_fully_qualified, max_matches, - searched_symbol_files, types); + search_first->FindTypes(name, name_is_fully_qualified, max_matches, + searched_symbol_files, types); if (total_matches >= max_matches) break; @@ -643,15 +648,14 @@ ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name, } if (total_matches < max_matches) { - SymbolContext world_sc; for (pos = m_modules.begin(); pos != end; ++pos) { // Search the module if the module is not equal to the one in the symbol // context "sc". If "sc" contains a empty module shared pointer, then the // comparison will always be true (valid_module_ptr != nullptr). - if (sc.module_sp.get() != (*pos).get()) + if (search_first != pos->get()) total_matches += - (*pos)->FindTypes(world_sc, name, name_is_fully_qualified, - max_matches, searched_symbol_files, types); + (*pos)->FindTypes(name, name_is_fully_qualified, max_matches, + searched_symbol_files, types); if (total_matches >= max_matches) break; @@ -747,9 +751,10 @@ bool ModuleList::ResolveFileAddress(lldb::addr_t vm_addr, return false; } -uint32_t ModuleList::ResolveSymbolContextForAddress(const Address &so_addr, - uint32_t resolve_scope, - SymbolContext &sc) const { +uint32_t +ModuleList::ResolveSymbolContextForAddress(const Address &so_addr, + SymbolContextItem resolve_scope, + SymbolContext &sc) const { // The address is already section offset so it has a module uint32_t resolved_flags = 0; ModuleSP module_sp(so_addr.GetModule()); @@ -772,15 +777,15 @@ uint32_t ModuleList::ResolveSymbolContextForAddress(const Address &so_addr, uint32_t ModuleList::ResolveSymbolContextForFilePath( const char *file_path, uint32_t line, bool check_inlines, - uint32_t resolve_scope, SymbolContextList &sc_list) const { - FileSpec file_spec(file_path, false); + SymbolContextItem resolve_scope, SymbolContextList &sc_list) const { + FileSpec file_spec(file_path); return ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, resolve_scope, sc_list); } uint32_t ModuleList::ResolveSymbolContextsForFileSpec( const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, SymbolContextList &sc_list) const { + SymbolContextItem resolve_scope, SymbolContextList &sc_list) const { std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -940,14 +945,13 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec, const auto num_directories = module_search_paths_ptr->GetSize(); for (size_t idx = 0; idx < num_directories; ++idx) { auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx); - if (!search_path_spec.ResolvePath()) - continue; + FileSystem::Instance().Resolve(search_path_spec); namespace fs = llvm::sys::fs; - if (!fs::is_directory(search_path_spec.GetPath())) + if (!FileSystem::Instance().IsDirectory(search_path_spec)) continue; search_path_spec.AppendPathComponent( module_spec.GetFileSpec().GetFilename().AsCString()); - if (!search_path_spec.Exists()) + if (!FileSystem::Instance().Exists(search_path_spec)) continue; auto resolved_module_spec(module_spec); @@ -988,13 +992,15 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec, // Don't look for the file if it appears to be the same one we already // checked for above... if (located_binary_modulespec.GetFileSpec() != module_file_spec) { - if (!located_binary_modulespec.GetFileSpec().Exists()) { + if (!FileSystem::Instance().Exists( + located_binary_modulespec.GetFileSpec())) { located_binary_modulespec.GetFileSpec().GetPath(path, sizeof(path)); if (path[0] == '\0') module_file_spec.GetPath(path, sizeof(path)); // How can this check ever be true? This branch it is false, and we // haven't modified file_spec. - if (located_binary_modulespec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists( + located_binary_modulespec.GetFileSpec())) { std::string uuid_str; if (uuid_ptr && uuid_ptr->IsValid()) uuid_str = uuid_ptr->GetAsString(); @@ -1035,7 +1041,7 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec, // If we didn't have a UUID in mind when looking for the object file, // then we should make sure the modification time hasn't changed! if (platform_module_spec.GetUUIDPtr() == nullptr) { - auto file_spec_mod_time = FileSystem::GetModificationTime( + auto file_spec_mod_time = FileSystem::Instance().GetModificationTime( located_binary_modulespec.GetFileSpec()); if (file_spec_mod_time != llvm::sys::TimePoint<>()) { if (file_spec_mod_time != module_sp->GetModificationTime()) { diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp index e8b8bb96786b..6ca46de40de2 100644 --- a/source/Core/Opcode.cpp +++ b/source/Core/Opcode.cpp @@ -1,9 +1,8 @@ //===-- Opcode.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,11 +12,11 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-forward.h" // for DataBufferSP +#include "lldb/lldb-forward.h" -#include // for make_shared +#include -#include // for PRIx64 +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Core/PluginManager.cpp b/source/Core/PluginManager.cpp index 55affb6a1030..8a03ca1fae0a 100644 --- a/source/Core/PluginManager.cpp +++ b/source/Core/PluginManager.cpp @@ -1,39 +1,39 @@ //===-- PluginManager.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/PluginManager.h" #include "lldb/Core/Debugger.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Interpreter/OptionValueProperties.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/StringList.h" // for StringList +#include "lldb/Utility/StringList.h" #if defined(_WIN32) -#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX +#include "lldb/Host/windows/PosixApi.h" #endif #include "llvm/ADT/StringRef.h" #include "llvm/Support/DynamicLibrary.h" -#include "llvm/Support/FileSystem.h" // for file_type, file_... -#include "llvm/Support/raw_ostream.h" // for fs +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/raw_ostream.h" -#include // for map<>::const_ite... -#include // for shared_ptr +#include +#include #include #include -#include // for pair +#include #include -#include // for assert +#include namespace lldb_private { class CommandInterpreter; @@ -89,9 +89,9 @@ template static FPtrTy CastToFPtr(void *VPtr) { return reinterpret_cast(reinterpret_cast(VPtr)); } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { // PluginManager *plugin_manager = (PluginManager *)baton; Status error; @@ -102,11 +102,11 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, // file type information. if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { - FileSpec plugin_file_spec(file_spec); - plugin_file_spec.ResolvePath(); + FileSpec plugin_file_spec(path); + FileSystem::Instance().Resolve(plugin_file_spec); if (PluginIsLoaded(plugin_file_spec)) - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; else { PluginInfo plugin_info; @@ -138,7 +138,7 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, // plug-in info so we don't try to load it again and again. SetPluginInfo(plugin_file_spec, plugin_info); - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } } } @@ -149,10 +149,10 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, // also do this for unknown as sometimes the directory enumeration might be // enumerating a file system that doesn't have correct file type // information. - return FileSpec::eEnumerateDirectoryResultEnter; + return FileSystem::eEnumerateDirectoryResultEnter; } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } void PluginManager::Initialize() { @@ -162,16 +162,20 @@ void PluginManager::Initialize() { const bool find_other = true; char dir_path[PATH_MAX]; if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) { - if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, nullptr); + if (FileSystem::Instance().Exists(dir_spec) && + dir_spec.GetPath(dir_path, sizeof(dir_path))) { + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, nullptr); } } if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) { - if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, nullptr); + if (FileSystem::Instance().Exists(dir_spec) && + dir_spec.GetPath(dir_path, sizeof(dir_path))) { + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, nullptr); } } #endif @@ -281,7 +285,10 @@ struct ArchitectureInstance { typedef std::vector ArchitectureInstances; -static std::mutex g_architecture_mutex; +static std::mutex &GetArchitectureMutex() { + static std::mutex g_architecture_mutex; + return g_architecture_mutex; +} static ArchitectureInstances &GetArchitectureInstances() { static ArchitectureInstances g_instances; @@ -291,13 +298,13 @@ static ArchitectureInstances &GetArchitectureInstances() { void PluginManager::RegisterPlugin(const ConstString &name, llvm::StringRef description, ArchitectureCreateInstance create_callback) { - std::lock_guard guard(g_architecture_mutex); + std::lock_guard guard(GetArchitectureMutex()); GetArchitectureInstances().push_back({name, description, create_callback}); } void PluginManager::UnregisterPlugin( ArchitectureCreateInstance create_callback) { - std::lock_guard guard(g_architecture_mutex); + std::lock_guard guard(GetArchitectureMutex()); auto &instances = GetArchitectureInstances(); for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) { @@ -311,7 +318,7 @@ void PluginManager::UnregisterPlugin( std::unique_ptr PluginManager::CreateArchitectureInstance(const ArchSpec &arch) { - std::lock_guard guard(g_architecture_mutex); + std::lock_guard guard(GetArchitectureMutex()); for (const auto &instances : GetArchitectureInstances()) { if (auto plugin_up = instances.create_callback(arch)) return plugin_up; diff --git a/source/Core/RichManglingContext.cpp b/source/Core/RichManglingContext.cpp index da009e4ddf43..16c764aef392 100644 --- a/source/Core/RichManglingContext.cpp +++ b/source/Core/RichManglingContext.cpp @@ -1,9 +1,8 @@ //===-- RichManglingContext.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -74,6 +73,7 @@ bool RichManglingContext::IsCtorOrDtor() const { case None: return false; } + llvm_unreachable("Fully covered switch above!"); } bool RichManglingContext::IsFunction() const { @@ -86,40 +86,36 @@ bool RichManglingContext::IsFunction() const { case None: return false; } + llvm_unreachable("Fully covered switch above!"); } void RichManglingContext::processIPDStrResult(char *ipd_res, size_t res_size) { + // Error case: Clear the buffer. if (LLVM_UNLIKELY(ipd_res == nullptr)) { assert(res_size == m_ipd_buf_size && "Failed IPD queries keep the original size in the N parameter"); - // Error case: Clear the buffer. - m_ipd_str_len = 0; - m_ipd_buf[m_ipd_str_len] = '\0'; - } else { - // IPD's res_size includes null terminator. - size_t res_len = res_size - 1; - assert(ipd_res[res_len] == '\0' && - "IPD returns null-terminated strings and we rely on that"); - - if (LLVM_UNLIKELY(ipd_res != m_ipd_buf)) { - // Realloc case: Take over the new buffer. - m_ipd_buf = ipd_res; // std::realloc freed or reused the old buffer. - m_ipd_buf_size = - res_size; // Actual buffer may be bigger, but we can't know. - m_ipd_str_len = res_len; - - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE); - if (log) - log->Printf("ItaniumPartialDemangler Realloc: new buffer size %lu", - m_ipd_buf_size); - } else { - // 99% case: Just remember the string length. - m_ipd_str_len = res_len; - } + m_ipd_buf[0] = '\0'; + m_buffer = llvm::StringRef(m_ipd_buf, 0); + return; + } + + // IPD's res_size includes null terminator. + assert(ipd_res[res_size - 1] == '\0' && + "IPD returns null-terminated strings and we rely on that"); + + // Update buffer/size on realloc. + if (LLVM_UNLIKELY(ipd_res != m_ipd_buf || res_size > m_ipd_buf_size)) { + m_ipd_buf = ipd_res; // std::realloc freed or reused the old buffer. + m_ipd_buf_size = res_size; // May actually be bigger, but we can't know. + + if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) + LLDB_LOG(log, "ItaniumPartialDemangler Realloc: new buffer size is {0}", + m_ipd_buf_size); } - m_buffer = llvm::StringRef(m_ipd_buf, m_ipd_str_len); + // 99% case: Just remember the string length. + m_buffer = llvm::StringRef(m_ipd_buf, res_size - 1); } void RichManglingContext::ParseFunctionBaseName() { diff --git a/source/Core/SearchFilter.cpp b/source/Core/SearchFilter.cpp index 3fd011f0e344..dbaf905e7af1 100644 --- a/source/Core/SearchFilter.cpp +++ b/source/Core/SearchFilter.cpp @@ -1,39 +1,38 @@ //===-- SearchFilter.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/SearchFilter.h" -#include "lldb/Breakpoint/Breakpoint.h" // for Breakpoint +#include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" // for ModuleList +#include "lldb/Core/ModuleList.h" #include "lldb/Symbol/CompileUnit.h" -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-private.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/Status.h" // for Status -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/lldb-enumerations.h" // for SymbolContextItem::eSymbolCo... +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-enumerations.h" -#include "llvm/ADT/StringRef.h" // for StringRef -#include "llvm/Support/ErrorHandling.h" // for llvm_unreachable +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ErrorHandling.h" -#include // for shared_ptr -#include // for recursive_mutex, lock_guard -#include // for string +#include +#include +#include -#include // for PRIu64 -#include // for size_t, strcmp +#include +#include namespace lldb_private { class Address; @@ -332,9 +331,7 @@ SearchFilter::DoCUIteration(const ModuleSP &module_sp, SymbolVendor *sym_vendor = module_sp->GetSymbolVendor(); if (!sym_vendor) continue; - SymbolContext sym_ctx; - cu_sp->CalculateSymbolContext(&sym_ctx); - if (!sym_vendor->ParseCompileUnitFunctions(sym_ctx)) + if (!sym_vendor->ParseFunctions(*cu_sp)) continue; // If we got any functions, use ForeachFunction to do the iteration. cu_sp->ForeachFunction([&](const FunctionSP &func_sp) { @@ -392,10 +389,7 @@ SearchFilterForUnconstrainedSearches::SerializeToStructuredData() { bool SearchFilterForUnconstrainedSearches::ModulePasses( const FileSpec &module_spec) { - if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec)) - return false; - else - return true; + return !m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec); } bool SearchFilterForUnconstrainedSearches::ModulePasses( @@ -528,7 +522,7 @@ SearchFilterSP SearchFilterByModule::CreateFromStructuredData( error.SetErrorString("SFBM::CFSD: filter module item not a string."); return nullptr; } - FileSpec module_spec(module, false); + FileSpec module_spec(module); return std::make_shared(target.shared_from_this(), module_spec); @@ -574,22 +568,15 @@ bool SearchFilterByModuleList::ModulePasses(const ModuleSP &module_sp) { if (m_module_spec_list.GetSize() == 0) return true; - if (module_sp && - m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) != - UINT32_MAX) - return true; - else - return false; + return module_sp && m_module_spec_list.FindFileIndex( + 0, module_sp->GetFileSpec(), false) != UINT32_MAX; } bool SearchFilterByModuleList::ModulePasses(const FileSpec &spec) { if (m_module_spec_list.GetSize() == 0) return true; - if (m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX) - return true; - else - return false; + return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX; } bool SearchFilterByModuleList::AddressPasses(Address &address) { @@ -684,7 +671,7 @@ SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData( "SFBM::CFSD: filter module item %zu not a string.", i); return nullptr; } - modules.Append(FileSpec(module, false)); + modules.Append(FileSpec(module)); } } @@ -749,7 +736,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData( "SFBM::CFSD: filter module item %zu not a string.", i); return result_sp; } - modules.Append(FileSpec(module, false)); + modules.Append(FileSpec(module)); } } @@ -771,7 +758,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData( "SFBM::CFSD: filter cu item %zu not a string.", i); return nullptr; } - cus.Append(FileSpec(cu, false)); + cus.Append(FileSpec(cu)); } return std::make_shared( diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp index d9c5d32ee13c..28e392391360 100644 --- a/source/Core/Section.cpp +++ b/source/Core/Section.cpp @@ -1,25 +1,24 @@ //===-- Section.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Section.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/Utility/VMRange.h" // for VMRange +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/VMRange.h" -#include // for PRIx64 -#include // for numeric_limits -#include // for distance +#include +#include +#include namespace lldb_private { class DataExtractor; @@ -61,6 +60,8 @@ const char *Section::GetTypeAsCString() const { return "objc-cfstrings"; case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev"; + case eSectionTypeDWARFDebugAbbrevDwo: + return "dwarf-abbrev-dwo"; case eSectionTypeDWARFDebugAddr: return "dwarf-addr"; case eSectionTypeDWARFDebugAranges: @@ -71,10 +72,16 @@ const char *Section::GetTypeAsCString() const { return "dwarf-frame"; case eSectionTypeDWARFDebugInfo: return "dwarf-info"; + case eSectionTypeDWARFDebugInfoDwo: + return "dwarf-info-dwo"; case eSectionTypeDWARFDebugLine: return "dwarf-line"; + case eSectionTypeDWARFDebugLineStr: + return "dwarf-line-str"; case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; + case eSectionTypeDWARFDebugLocLists: + return "dwarf-loclists"; case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; case eSectionTypeDWARFDebugMacro: @@ -85,10 +92,16 @@ const char *Section::GetTypeAsCString() const { return "dwarf-pubtypes"; case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; + case eSectionTypeDWARFDebugRngLists: + return "dwarf-rnglists"; case eSectionTypeDWARFDebugStr: return "dwarf-str"; + case eSectionTypeDWARFDebugStrDwo: + return "dwarf-str-dwo"; case eSectionTypeDWARFDebugStrOffsets: return "dwarf-str-offsets"; + case eSectionTypeDWARFDebugStrOffsetsDwo: + return "dwarf-str-offsets-dwo"; case eSectionTypeDWARFDebugTypes: return "dwarf-types"; case eSectionTypeDWARFDebugNames: @@ -125,6 +138,10 @@ const char *Section::GetTypeAsCString() const { return "dwarf-gnu-debugaltlink"; case eSectionTypeOther: return "regular"; + + case eSectionTypeSwiftModules: + case eSectionTypeDWARFAppleExternalTypes: + break; } return "unknown"; } diff --git a/source/Core/SourceManager.cpp b/source/Core/SourceManager.cpp index 143d91413956..4a1f43e129bd 100644 --- a/source/Core/SourceManager.cpp +++ b/source/Core/SourceManager.cpp @@ -1,42 +1,41 @@ //===-- SourceManager.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/SourceManager.h" -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/Address.h" +#include "lldb/Core/AddressRange.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FormatEntity.h" // for FormatEntity +#include "lldb/Core/FormatEntity.h" #include "lldb/Core/Highlighter.h" #include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" // for ModuleList +#include "lldb/Core/ModuleList.h" #include "lldb/Host/FileSystem.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" -#include "lldb/Symbol/LineEntry.h" // for LineEntry +#include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Target/PathMappingList.h" // for PathMappingList +#include "lldb/Target/PathMappingList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-enumerations.h" // for StopShowColumn::eStopSho... +#include "lldb/lldb-enumerations.h" -#include "llvm/ADT/Twine.h" // for Twine +#include "llvm/ADT/Twine.h" #include -#include // for pair +#include -#include // for assert -#include // for size_t, NULL, snprintf +#include +#include namespace lldb_private { class ExecutionContext; @@ -92,7 +91,7 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) { file_sp->UpdateIfNeeded(); // If file_sp is no good or it points to a non-existent file, reset it. - if (!file_sp || !file_sp->GetFileSpec().Exists()) { + if (!file_sp || !FileSystem::Instance().Exists(file_sp->GetFileSpec())) { if (target_sp) file_sp = std::make_shared(file_spec, target_sp.get()); else @@ -158,7 +157,9 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile( const SymbolContextList *bp_locs) { if (count == 0) return 0; - size_t return_value = 0; + + Stream::ByteDelta delta(*s); + if (start_line == 0) { if (m_last_line != 0 && m_last_line != UINT32_MAX) start_line = m_last_line + m_last_count; @@ -193,9 +194,8 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile( ::snprintf(prefix, sizeof(prefix), " "); } - return_value += - s->Printf("%s%2.2s %-4u\t", prefix, - line == curr_line ? current_line_cstr : "", line); + s->Printf("%s%2.2s %-4u\t", prefix, + line == curr_line ? current_line_cstr : "", line); // So far we treated column 0 as a special 'no column value', but // DisplaySourceLines starts counting columns from 0 (and no column is @@ -211,21 +211,20 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile( // Display caret cursor. std::string src_line; m_last_file_sp->GetLine(line, src_line); - return_value += s->Printf(" \t"); + s->Printf(" \t"); // Insert a space for every non-tab character in the source line. for (size_t i = 0; i + 1 < column && i < src_line.length(); ++i) - return_value += s->PutChar(src_line[i] == '\t' ? '\t' : ' '); + s->PutChar(src_line[i] == '\t' ? '\t' : ' '); // Now add the caret. - return_value += s->Printf("^\n"); + s->Printf("^\n"); } if (this_line_size == 0) { m_last_line = UINT32_MAX; break; - } else - return_value += this_line_size; + } } } - return return_value; + return *delta; } size_t SourceManager::DisplaySourceLinesWithLineNumbers( @@ -405,14 +404,14 @@ void SourceManager::FindLinesMatchingRegex(FileSpec &file_spec, SourceManager::File::File(const FileSpec &file_spec, lldb::DebuggerSP debugger_sp) : m_file_spec_orig(file_spec), m_file_spec(file_spec), - m_mod_time(FileSystem::GetModificationTime(file_spec)), + m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_debugger_wp(debugger_sp) { CommonInitializer(file_spec, nullptr); } SourceManager::File::File(const FileSpec &file_spec, Target *target) : m_file_spec_orig(file_spec), m_file_spec(file_spec), - m_mod_time(FileSystem::GetModificationTime(file_spec)), + m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_debugger_wp(target ? target->GetDebugger().shared_from_this() : DebuggerSP()) { CommonInitializer(file_spec, target); @@ -432,7 +431,8 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec, size_t num_matches = target->GetImages().ResolveSymbolContextForFilePath( file_spec.GetFilename().AsCString(), 0, check_inlines, - lldb::eSymbolContextModule | lldb::eSymbolContextCompUnit, + SymbolContextItem(eSymbolContextModule | + eSymbolContextCompUnit), sc_list); bool got_multiple = false; if (num_matches != 0) { @@ -456,12 +456,12 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec, SymbolContext sc; sc_list.GetContextAtIndex(0, sc); m_file_spec = sc.comp_unit; - m_mod_time = FileSystem::GetModificationTime(m_file_spec); + m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec); } } } // Try remapping if m_file_spec does not correspond to an existing file. - if (!m_file_spec.Exists()) { + if (!FileSystem::Instance().Exists(m_file_spec)) { FileSpec new_file_spec; // Check target specific source remappings first, then fall back to // modules objects can have individual path remappings that were @@ -469,14 +469,14 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec, if (target->GetSourcePathMap().FindFile(m_file_spec, new_file_spec) || target->GetImages().FindSourceFile(m_file_spec, new_file_spec)) { m_file_spec = new_file_spec; - m_mod_time = FileSystem::GetModificationTime(m_file_spec); + m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec); } } } } if (m_mod_time != llvm::sys::TimePoint<>()) - m_data_sp = DataBufferLLVM::CreateFromPath(m_file_spec.GetPath()); + m_data_sp = FileSystem::Instance().CreateDataBuffer(m_file_spec); } uint32_t SourceManager::File::GetLineOffset(uint32_t line) { @@ -520,7 +520,7 @@ uint32_t SourceManager::File::GetLineLength(uint32_t line, if (end_offset > start_offset) { uint32_t length = end_offset - start_offset; - if (include_newline_chars == false) { + if (!include_newline_chars) { const char *line_start = (const char *)m_data_sp->GetBytes() + start_offset; while (length > 0) { @@ -549,12 +549,12 @@ void SourceManager::File::UpdateIfNeeded() { // TODO: use host API to sign up for file modifications to anything in our // source cache and only update when we determine a file has been updated. // For now we check each time we want to display info for the file. - auto curr_mod_time = FileSystem::GetModificationTime(m_file_spec); + auto curr_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec); if (curr_mod_time != llvm::sys::TimePoint<>() && m_mod_time != curr_mod_time) { m_mod_time = curr_mod_time; - m_data_sp = DataBufferLLVM::CreateFromPath(m_file_spec.GetPath()); + m_data_sp = FileSystem::Instance().CreateDataBuffer(m_file_spec); m_offsets.clear(); } } diff --git a/source/Core/StreamAsynchronousIO.cpp b/source/Core/StreamAsynchronousIO.cpp index eb8bf3620afc..d283749144e1 100644 --- a/source/Core/StreamAsynchronousIO.cpp +++ b/source/Core/StreamAsynchronousIO.cpp @@ -1,16 +1,15 @@ //===-- StreamAsynchronousIO.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/StreamAsynchronousIO.h" #include "lldb/Core/Debugger.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderBig +#include "lldb/lldb-enumerations.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Core/StreamFile.cpp b/source/Core/StreamFile.cpp index 3e7214032fa8..db184df5856c 100644 --- a/source/Core/StreamFile.cpp +++ b/source/Core/StreamFile.cpp @@ -1,13 +1,13 @@ //===-- StreamFile.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSystem.h" #include @@ -28,14 +28,18 @@ StreamFile::StreamFile(int fd, bool transfer_ownership) StreamFile::StreamFile(FILE *fh, bool transfer_ownership) : Stream(), m_file(fh, transfer_ownership) {} -StreamFile::StreamFile(const char *path) - : Stream(), - m_file(path, File::eOpenOptionWrite | File::eOpenOptionCanCreate | - File::eOpenOptionCloseOnExec, - lldb::eFilePermissionsFileDefault) {} +StreamFile::StreamFile(const char *path) : Stream(), m_file() { + FileSystem::Instance().Open(m_file, FileSpec(path), + File::eOpenOptionWrite | + File::eOpenOptionCanCreate | + File::eOpenOptionCloseOnExec); +} StreamFile::StreamFile(const char *path, uint32_t options, uint32_t permissions) - : Stream(), m_file(path, options, permissions) {} + : Stream(), m_file() { + + FileSystem::Instance().Open(m_file, FileSpec(path), options, permissions); +} StreamFile::~StreamFile() {} diff --git a/source/Core/UserSettingsController.cpp b/source/Core/UserSettingsController.cpp index a4661a6c9e8c..3331ead828d4 100644 --- a/source/Core/UserSettingsController.cpp +++ b/source/Core/UserSettingsController.cpp @@ -1,9 +1,8 @@ //====-- UserSettingsController.cpp ------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,7 +12,7 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" -#include // for shared_ptr +#include namespace lldb_private { class CommandInterpreter; diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp index 1cbb58d65d95..1c107954ef53 100644 --- a/source/Core/Value.cpp +++ b/source/Core/Value.cpp @@ -1,17 +1,15 @@ //===-- Value.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Value.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -21,20 +19,21 @@ #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Endian.h" // for InlHostByteOrder -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/Endian.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for DataBufferSP, ModuleSP -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include // for make_shared -#include // for string +#include +#include -#include // for PRIx64 +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp index 2ef93f3d737a..bdbd6fd74b69 100644 --- a/source/Core/ValueObject.cpp +++ b/source/Core/ValueObject.cpp @@ -1,17 +1,15 @@ //===-- ValueObject.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObject.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" // for Scalar #include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResult.h" @@ -19,52 +17,53 @@ #include "lldb/Core/ValueObjectMemory.h" #include "lldb/Core/ValueObjectSyntheticFilter.h" #include "lldb/DataFormatters/DataVisualization.h" -#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj... -#include "lldb/DataFormatters/FormatManager.h" // for FormatManager +#include "lldb/DataFormatters/DumpValueObjectOptions.h" +#include "lldb/DataFormatters/FormatManager.h" #include "lldb/DataFormatters/StringPrinter.h" -#include "lldb/DataFormatters/TypeFormat.h" // for TypeFormatImpl_F... -#include "lldb/DataFormatters/TypeSummary.h" // for TypeSummaryOptions -#include "lldb/DataFormatters/TypeValidator.h" // for TypeValidatorImp... +#include "lldb/DataFormatters/TypeFormat.h" +#include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/DataFormatters/TypeValidator.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" -#include "lldb/Expression/ExpressionVariable.h" // for ExpressionVariable +#include "lldb/Expression/ExpressionVariable.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/SwiftASTContext.h" -#include "lldb/Symbol/Declaration.h" // for Declaration -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/Declaration.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" -#include "lldb/Target/StackFrame.h" // for StackFrame +#include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" -#include "lldb/Target/ThreadList.h" // for ThreadList -#include "lldb/Utility/DataBuffer.h" // for DataBuffer +#include "lldb/Target/ThreadList.h" +#include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Flags.h" // for Flags +#include "lldb/Utility/Flags.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAllCateg... -#include "lldb/Utility/SharingPtr.h" // for SharingPtr -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/SharingPtr.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "lldb/lldb-private-types.h" // for RegisterInfo +#include "lldb/lldb-private-types.h" -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH +#include "llvm/Support/Compiler.h" -#include // for min -#include // for uint32_t, uint64_t -#include // for size_t, NULL -#include // for shared_ptr, oper... -#include // for tie, tuple +#include +#include +#include +#include +#include -#include // for assert -#include // for PRIu64, PRIx64 -#include // for snprintf -#include // for memcpy, memcmp +#include +#include +#include +#include namespace lldb_private { class ExecutionContextScope; @@ -240,7 +239,7 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) { if (first_update) SetValueDidChange(false); - else if (!m_value_did_change && success == false) { + else if (!m_value_did_change && !success) { // The value wasn't gotten successfully, so we mark this as changed if // the value used to be valid and now isn't SetValueDidChange(value_was_valid); @@ -510,10 +509,7 @@ bool ValueObject::IsLogicalTrue(Status &error) { } bool ret; - if (scalar_value.ULongLong(1) == 0) - ret = false; - else - ret = true; + ret = scalar_value.ULongLong(1) != 0; error.Clear(); return ret; } @@ -711,7 +707,7 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx, bool child_is_deref_of_parent = false; uint64_t language_flags = 0; - const bool transparent_pointers = synthetic_array_member == false; + const bool transparent_pointers = !synthetic_array_member; CompilerType child_compiler_type; ExecutionContext exe_ctx(GetExecutionContextRef()); @@ -734,8 +730,6 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx, child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid, language_flags); - // if (valobj) - // valobj->SetAddressTypeOfChildren(eAddressTypeInvalid); } return valobj; @@ -833,8 +827,9 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx, ExecutionContext exe_ctx(GetExecutionContextRef()); - auto item_type_size = pointee_or_element_compiler_type.GetByteSize( - exe_ctx.GetBestExecutionContextScope()); + llvm::Optional item_type_size = + pointee_or_element_compiler_type.GetByteSize( + exe_ctx.GetBestExecutionContextScope()); if (!item_type_size) return 0; const uint64_t bytes = item_count * *item_type_size; @@ -1927,7 +1922,8 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset( return {}; ExecutionContext exe_ctx(GetExecutionContextRef()); - auto size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); + llvm::Optional size = + type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); if (!size) return {}; ValueObjectChild *synthetic_child = @@ -1968,7 +1964,8 @@ ValueObjectSP ValueObject::GetSyntheticBase(uint32_t offset, const bool is_base_class = true; ExecutionContext exe_ctx(GetExecutionContextRef()); - auto size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); + llvm::Optional size = + type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); if (!size) return {}; ValueObjectChild *synthetic_child = @@ -2026,11 +2023,11 @@ ValueObject::GetSyntheticExpressionPathChild(const char *expression, } void ValueObject::CalculateSyntheticValue(bool use_synthetic) { - if (use_synthetic == false) + if (!use_synthetic) return; TargetSP target_sp(GetTargetSP()); - if (target_sp && target_sp->GetEnableSyntheticValue() == false) { + if (target_sp && !target_sp->GetEnableSyntheticValue()) { m_synthetic_value = NULL; return; } @@ -2081,7 +2078,7 @@ ValueObjectSP ValueObject::GetStaticValue() { return GetSP(); } lldb::ValueObjectSP ValueObject::GetNonSyntheticValue() { return GetSP(); } ValueObjectSP ValueObject::GetSyntheticValue(bool use_synthetic) { - if (use_synthetic == false) + if (!use_synthetic) return ValueObjectSP(); CalculateSyntheticValue(use_synthetic); @@ -2100,10 +2097,7 @@ bool ValueObject::HasSyntheticValue() { CalculateSyntheticValue(true); - if (m_synthetic_value) - return true; - else - return false; + return m_synthetic_value != nullptr; } bool ValueObject::GetBaseClassPath(Stream &s) { @@ -2910,31 +2904,6 @@ ValueObjectSP ValueObject::GetQualifiedRepresentationIfAvailable( return result_sp; } -lldb::addr_t ValueObject::GetCPPVTableAddress(AddressType &address_type) { - CompilerType pointee_type; - CompilerType this_type(GetCompilerType()); - uint32_t type_info = this_type.GetTypeInfo(&pointee_type); - if (type_info) { - bool ptr_or_ref = false; - if (type_info & (eTypeIsPointer | eTypeIsReference)) { - ptr_or_ref = true; - type_info = pointee_type.GetTypeInfo(); - } - - const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus; - if ((type_info & cpp_class) == cpp_class) { - if (ptr_or_ref) { - address_type = GetAddressTypeOfChildren(); - return GetValueAsUnsigned(LLDB_INVALID_ADDRESS); - } else - return GetAddressOf(false, &address_type); - } - } - - address_type = eAddressTypeInvalid; - return LLDB_INVALID_ADDRESS; -} - ValueObjectSP ValueObject::Dereference(Status &error) { if (m_deref_valobj) return m_deref_valobj->GetSP(); @@ -3326,7 +3295,7 @@ ValueObject * ValueObject::FollowParentChain(std::function f) { ValueObject *vo = this; while (vo) { - if (f(vo) == false) + if (!f(vo)) break; vo = vo->m_parent; } @@ -3395,8 +3364,7 @@ bool ValueObject::CanProvideValue() { // board debugging scenarios have no notion of types, but still manage to // have raw numeric values for things like registers. sigh. const CompilerType &type(GetCompilerType()); - return (false == type.IsValid()) || - (0 != (type.GetTypeInfo() & eTypeHasValue)); + return (!type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue)); } bool ValueObject::IsChecksumEmpty() { return m_value_checksum.empty(); } diff --git a/source/Core/ValueObjectCast.cpp b/source/Core/ValueObjectCast.cpp index e7098c9454e7..d588f0308ed4 100644 --- a/source/Core/ValueObjectCast.cpp +++ b/source/Core/ValueObjectCast.cpp @@ -1,20 +1,19 @@ //===-- ValueObjectCast.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectCast.h" -#include "lldb/Core/Scalar.h" // for operator!=, Scalar #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" namespace lldb_private { class ConstString; diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp index f37eb089886a..34370a98981f 100644 --- a/source/Core/ValueObjectChild.cpp +++ b/source/Core/ValueObjectChild.cpp @@ -1,30 +1,29 @@ //===-- ValueObjectChild.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectChild.h" -#include "lldb/Core/Scalar.h" // for Scalar -#include "lldb/Core/Value.h" // for Value, Value::ValueType::e... +#include "lldb/Core/Value.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/Flags.h" // for Flags -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-forward.h" // for ProcessSP, ModuleSP +#include "lldb/Utility/Flags.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-forward.h" -#include // for _Func_impl<>::_Mybase -#include // for shared_ptr -#include // for vector +#include +#include +#include -#include // for snprintf, size_t -#include // for strlen +#include +#include using namespace lldb_private; @@ -125,7 +124,7 @@ bool ValueObjectChild::UpdateValue() { Flags parent_type_flags(parent_type.GetTypeInfo()); const bool is_instance_ptr_base = - ((m_is_base_class == true) && + ((m_is_base_class) && (parent_type_flags.AnySet(lldb::eTypeInstanceIsPointer))); if (parent->GetCompilerType().ShouldTreatScalarValueAsAddress()) { @@ -153,7 +152,7 @@ bool ValueObjectChild::UpdateValue() { switch (addr_type) { case eAddressTypeFile: { lldb::ProcessSP process_sp(GetProcessSP()); - if (process_sp && process_sp->IsAlive() == true) + if (process_sp && process_sp->IsAlive()) m_value.SetValueType(Value::eValueTypeLoadAddress); else m_value.SetValueType(Value::eValueTypeFileAddress); @@ -213,12 +212,9 @@ bool ValueObjectChild::UpdateValue() { ExecutionContext exe_ctx( GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped)); if (GetCompilerType().GetTypeInfo() & lldb::eTypeHasValue) { - if (!is_instance_ptr_base) - m_error = - m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get()); - else - m_error = m_parent->GetValue().GetValueAsData(&exe_ctx, m_data, 0, - GetModule().get()); + Value &value = is_instance_ptr_base ? m_parent->GetValue() : m_value; + m_error = + value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get()); } else { m_error.Clear(); // No value so nothing to read... } diff --git a/source/Core/ValueObjectConstResult.cpp b/source/Core/ValueObjectConstResult.cpp index 15d5ec5a67bf..f69731ba004f 100644 --- a/source/Core/ValueObjectConstResult.cpp +++ b/source/Core/ValueObjectConstResult.cpp @@ -1,23 +1,22 @@ //===-- ValueObjectConstResult.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/Scalar.h" // for Scalar #include "lldb/Core/ValueObjectDynamicValue.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ExecutionContextScope.h" // for ExecutionContextScope +#include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/DataBuffer.h" // for DataBuffer -#include "lldb/Utility/DataBufferHeap.h" // for DataBufferHeap +#include "lldb/Utility/DataBuffer.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" namespace lldb_private { class Module; diff --git a/source/Core/ValueObjectConstResultCast.cpp b/source/Core/ValueObjectConstResultCast.cpp index c04043264af1..2c1264f479bb 100644 --- a/source/Core/ValueObjectConstResultCast.cpp +++ b/source/Core/ValueObjectConstResultCast.cpp @@ -1,9 +1,8 @@ //===-- ValueObjectConstResultCast.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/ValueObjectConstResultChild.cpp b/source/Core/ValueObjectConstResultChild.cpp index 3e9f87684162..747e40911060 100644 --- a/source/Core/ValueObjectConstResultChild.cpp +++ b/source/Core/ValueObjectConstResultChild.cpp @@ -1,15 +1,14 @@ //===-- ValueObjectConstResultChild.cpp --------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectConstResultChild.h" -#include "lldb/lldb-private-enumerations.h" // for AddressType::eAddressType +#include "lldb/lldb-private-enumerations.h" namespace lldb_private { class DataExtractor; } @@ -52,6 +51,11 @@ lldb::ValueObjectSP ValueObjectConstResultChild::AddressOf(Status &error) { return m_impl.AddressOf(error); } +lldb::addr_t ValueObjectConstResultChild::GetAddressOf( + bool scalar_is_load_address, AddressType* address_type) { + return m_impl.GetAddressOf(scalar_is_load_address, address_type); +} + ValueObject *ValueObjectConstResultChild::CreateChildAtIndex( size_t idx, bool synthetic_array_member, int32_t synthetic_index) { return m_impl.CreateChildAtIndex(idx, synthetic_array_member, diff --git a/source/Core/ValueObjectConstResultImpl.cpp b/source/Core/ValueObjectConstResultImpl.cpp index 444390af0c5a..aeea1743682c 100644 --- a/source/Core/ValueObjectConstResultImpl.cpp +++ b/source/Core/ValueObjectConstResultImpl.cpp @@ -1,27 +1,26 @@ //===-- ValueObjectConstResultImpl.cpp ---------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Core/Scalar.h" // for Scalar -#include "lldb/Core/Value.h" // for Value, Value::Val... -#include "lldb/Core/ValueObject.h" // for ValueObject +#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectConstResultCast.h" #include "lldb/Core/ValueObjectConstResultChild.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" -#include "lldb/Utility/DataBufferHeap.h" // for DataBufferHeap -#include "lldb/Utility/Endian.h" // for InlHostByteOrder -#include "lldb/Utility/SharingPtr.h" // for SharingPtr +#include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/Endian.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/SharingPtr.h" -#include // for string +#include namespace lldb_private { class DataExtractor; @@ -66,7 +65,7 @@ ValueObject *ValueObjectConstResultImpl::CreateChildAtIndex( bool child_is_deref_of_parent = false; uint64_t language_flags; - const bool transparent_pointers = synthetic_array_member == false; + const bool transparent_pointers = !synthetic_array_member; CompilerType compiler_type = m_impl_backend->GetCompilerType(); CompilerType child_compiler_type; diff --git a/source/Core/ValueObjectDynamicValue.cpp b/source/Core/ValueObjectDynamicValue.cpp index b6b16f02e7d9..dd17ee9470f9 100644 --- a/source/Core/ValueObjectDynamicValue.cpp +++ b/source/Core/ValueObjectDynamicValue.cpp @@ -1,14 +1,12 @@ //===-- ValueObjectDynamicValue.cpp ------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectDynamicValue.h" -#include "lldb/Core/Scalar.h" // for Scalar, operator!= #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" @@ -17,13 +15,14 @@ #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/DataExtractor.h" // for DataExtractor +#include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-types.h" // for addr_t, offset_t +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-types.h" -#include // for strcmp, size_t +#include namespace lldb_private { class Declaration; } diff --git a/source/Core/ValueObjectList.cpp b/source/Core/ValueObjectList.cpp index 0dd07252888f..3c6ed5206991 100644 --- a/source/Core/ValueObjectList.cpp +++ b/source/Core/ValueObjectList.cpp @@ -1,19 +1,18 @@ //===-- ValueObjectList.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectList.h" -#include "lldb/Core/ValueObject.h" // for ValueObject -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/SharingPtr.h" // for SharingPtr +#include "lldb/Core/ValueObject.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/SharingPtr.h" -#include // for back_insert_iterator, back_ins... +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Core/ValueObjectMemory.cpp b/source/Core/ValueObjectMemory.cpp index 9e71d3da0620..42d1263b3909 100644 --- a/source/Core/ValueObjectMemory.cpp +++ b/source/Core/ValueObjectMemory.cpp @@ -1,26 +1,25 @@ //===-- ValueObjectMemory.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectMemory.h" -#include "lldb/Core/Scalar.h" // for Scalar, operator!= #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/DataExtractor.h" // for DataExtractor -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-types.h" // for addr_t -#include "llvm/Support/ErrorHandling.h" // for llvm_unreachable +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-types.h" +#include "llvm/Support/ErrorHandling.h" -#include // for assert -#include // for shared_ptr +#include +#include namespace lldb_private { class ExecutionContextScope; @@ -137,10 +136,8 @@ size_t ValueObjectMemory::CalculateNumChildren(uint32_t max) { uint64_t ValueObjectMemory::GetByteSize() { if (m_type_sp) - return m_type_sp->GetByteSize(); - if (auto size = m_compiler_type.GetByteSize(nullptr)) - return *size; - return 0; + return m_type_sp->GetByteSize().getValueOr(0); + return m_compiler_type.GetByteSize(nullptr).getValueOr(0); } lldb::ValueType ValueObjectMemory::GetValueType() const { diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp index 0d4de124f08d..ea8afec0e113 100644 --- a/source/Core/ValueObjectRegister.cpp +++ b/source/Core/ValueObjectRegister.cpp @@ -1,32 +1,31 @@ //===-- ValueObjectRegister.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" // for Scalar -#include "lldb/Core/Value.h" // for Value, Value::ContextType:... +#include "lldb/Core/Value.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/TypeSystem.h" // for TypeSystem +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" -#include "lldb/Target/StackFrame.h" // for StackFrame +#include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/DataExtractor.h" // for DataExtractor -#include "lldb/Utility/Status.h" // for Status -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/Stream.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include // for assert -#include // for shared_ptr +#include +#include namespace lldb_private { class ExecutionContextScope; diff --git a/source/Core/ValueObjectSyntheticFilter.cpp b/source/Core/ValueObjectSyntheticFilter.cpp index 044387a4ae12..c0431848f4fc 100644 --- a/source/Core/ValueObjectSyntheticFilter.cpp +++ b/source/Core/ValueObjectSyntheticFilter.cpp @@ -1,22 +1,21 @@ //===-- ValueObjectSyntheticFilter.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectSyntheticFilter.h" -#include "lldb/Core/Value.h" // for Value +#include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/DataFormatters/TypeSynthetic.h" -#include "lldb/Target/ExecutionContext.h" // for ExecutionContext +#include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet -#include "lldb/Utility/SharingPtr.h" // for SharingPtr -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/SharingPtr.h" +#include "lldb/Utility/Status.h" #include "llvm/ADT/STLExtras.h" @@ -119,7 +118,7 @@ bool ValueObjectSynthetic::MightHaveChildren() { if (m_might_have_children == eLazyBoolCalculate) m_might_have_children = (m_synth_filter_ap->MightHaveChildren() ? eLazyBoolYes : eLazyBoolNo); - return (m_might_have_children == eLazyBoolNo ? false : true); + return (m_might_have_children != eLazyBoolNo); } uint64_t ValueObjectSynthetic::GetByteSize() { return m_parent->GetByteSize(); } @@ -174,7 +173,7 @@ bool ValueObjectSynthetic::UpdateValue() { } // let our backend do its update - if (m_synth_filter_ap->Update() == false) { + if (!m_synth_filter_ap->Update()) { if (log) log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic " "filter said caches are stale - clearing", @@ -235,7 +234,7 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx, UpdateValueIfNeeded(); ValueObject *valobj; - if (m_children_byindex.GetValueForKey(idx, valobj) == false) { + if (!m_children_byindex.GetValueForKey(idx, valobj)) { if (can_create && m_synth_filter_ap.get() != nullptr) { if (log) log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp index e5d059575c48..ad32ed215b82 100644 --- a/source/Core/ValueObjectVariable.cpp +++ b/source/Core/ValueObjectVariable.cpp @@ -1,22 +1,19 @@ //===-- ValueObjectVariable.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/ValueObjectVariable.h" -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/AddressRange.h" // for AddressRange +#include "lldb/Core/Address.h" +#include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" // for Scalar, operator!= #include "lldb/Core/Value.h" -#include "lldb/Expression/DWARFExpression.h" // for DWARFExpression -#include "lldb/Symbol/Declaration.h" // for Declaration +#include "lldb/Expression/DWARFExpression.h" +#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -27,15 +24,17 @@ #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/DataExtractor.h" // for DataExtractor -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-private-enumerations.h" // for AddressType::eAddressTy... -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include // for assert -#include // for shared_ptr +#include +#include namespace lldb_private { class ExecutionContextScope; @@ -118,8 +117,7 @@ uint64_t ValueObjectVariable::GetByteSize() { if (!type.IsValid()) return 0; - auto size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); - return size ? *size : 0; + return type.GetByteSize(exe_ctx.GetBestExecutionContextScope()).getValueOr(0); } lldb::ValueType ValueObjectVariable::GetValueType() const { diff --git a/source/DataFormatters/CXXFunctionPointer.cpp b/source/DataFormatters/CXXFunctionPointer.cpp index fad67a9d5b7a..0ca000eb0529 100644 --- a/source/DataFormatters/CXXFunctionPointer.cpp +++ b/source/DataFormatters/CXXFunctionPointer.cpp @@ -1,9 +1,8 @@ //===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -38,7 +37,7 @@ bool lldb_private::formatters::CXXFunctionPointerSummaryProvider( Address so_addr; Target *target = exe_ctx.GetTargetPtr(); - if (target && target->GetSectionLoadList().IsEmpty() == false) { + if (target && !target->GetSectionLoadList().IsEmpty()) { if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, so_addr)) { so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(), diff --git a/source/DataFormatters/DataVisualization.cpp b/source/DataFormatters/DataVisualization.cpp index 2a2d4b8b553e..7ec3a9381d91 100644 --- a/source/DataFormatters/DataVisualization.cpp +++ b/source/DataFormatters/DataVisualization.cpp @@ -1,19 +1,14 @@ //===-- DataVisualization.cpp ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/DataVisualization.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; @@ -149,7 +144,7 @@ void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) { } void DataVisualization::Categories::Disable(const ConstString &category) { - if (GetFormatManager().GetCategory(category)->IsEnabled() == true) + if (GetFormatManager().GetCategory(category)->IsEnabled()) GetFormatManager().DisableCategory(category); } @@ -170,7 +165,7 @@ void DataVisualization::Categories::Enable( void DataVisualization::Categories::Disable( const lldb::TypeCategoryImplSP &category) { - if (category.get() && category->IsEnabled() == true) + if (category.get() && category->IsEnabled()) GetFormatManager().DisableCategory(category); } diff --git a/source/DataFormatters/DumpValueObjectOptions.cpp b/source/DataFormatters/DumpValueObjectOptions.cpp index 7c9d5eb77a01..84f21696e054 100644 --- a/source/DataFormatters/DumpValueObjectOptions.cpp +++ b/source/DataFormatters/DumpValueObjectOptions.cpp @@ -1,19 +1,14 @@ //===-- DumpValueObjectOptions.cpp -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/DumpValueObjectOptions.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ValueObject.h" using namespace lldb; @@ -71,7 +66,7 @@ DumpValueObjectOptions &DumpValueObjectOptions::SetUseObjectiveC(bool use) { } DumpValueObjectOptions &DumpValueObjectOptions::SetShowSummary(bool show) { - if (show == false) + if (!show) SetOmitSummaryDepth(UINT32_MAX); else SetOmitSummaryDepth(0); diff --git a/source/DataFormatters/FormatCache.cpp b/source/DataFormatters/FormatCache.cpp index 0f1b29f1b476..c05b116b6acb 100644 --- a/source/DataFormatters/FormatCache.cpp +++ b/source/DataFormatters/FormatCache.cpp @@ -1,20 +1,15 @@ //===-- FormatCache.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatCache.h" using namespace lldb; diff --git a/source/DataFormatters/FormatClasses.cpp b/source/DataFormatters/FormatClasses.cpp index f657361d3d5d..271963b5f8f4 100644 --- a/source/DataFormatters/FormatClasses.cpp +++ b/source/DataFormatters/FormatClasses.cpp @@ -1,10 +1,9 @@ //===-- FormatClasses.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,13 +11,9 @@ #include "lldb/DataFormatters/FormatManager.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp index 74f8c5af1177..f6db403419d1 100644 --- a/source/DataFormatters/FormatManager.cpp +++ b/source/DataFormatters/FormatManager.cpp @@ -1,9 +1,8 @@ //===-- FormatManager.cpp ----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,6 @@ #include "llvm/ADT/STLExtras.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/ScriptInterpreter/Python/lldb-python.h" #include "lldb/Core/Debugger.h" @@ -298,7 +293,7 @@ FormatManager::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) { uint32_t prio_category = UINT32_MAX; for (uint32_t category_id = 0; category_id < num_categories; category_id++) { category_sp = GetCategoryAtIndex(category_id); - if (category_sp->IsEnabled() == false) + if (!category_sp->IsEnabled()) continue; lldb::TypeFormatImplSP format_current_sp = category_sp->GetFormatForType(type_sp); @@ -322,7 +317,7 @@ FormatManager::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) { uint32_t prio_category = UINT32_MAX; for (uint32_t category_id = 0; category_id < num_categories; category_id++) { category_sp = GetCategoryAtIndex(category_id); - if (category_sp->IsEnabled() == false) + if (!category_sp->IsEnabled()) continue; lldb::TypeSummaryImplSP summary_current_sp = category_sp->GetSummaryForType(type_sp); @@ -346,7 +341,7 @@ FormatManager::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) { uint32_t prio_category = UINT32_MAX; for (uint32_t category_id = 0; category_id < num_categories; category_id++) { category_sp = GetCategoryAtIndex(category_id); - if (category_sp->IsEnabled() == false) + if (!category_sp->IsEnabled()) continue; lldb::TypeFilterImplSP filter_current_sp( (TypeFilterImpl *)category_sp->GetFilterForType(type_sp).get()); @@ -371,7 +366,7 @@ FormatManager::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) { uint32_t prio_category = UINT32_MAX; for (uint32_t category_id = 0; category_id < num_categories; category_id++) { category_sp = GetCategoryAtIndex(category_id); - if (category_sp->IsEnabled() == false) + if (!category_sp->IsEnabled()) continue; lldb::ScriptedSyntheticChildrenSP synth_current_sp( (ScriptedSyntheticChildren *)category_sp->GetSyntheticForType(type_sp) @@ -411,7 +406,7 @@ FormatManager::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) { uint32_t prio_category = UINT32_MAX; for (uint32_t category_id = 0; category_id < num_categories; category_id++) { category_sp = GetCategoryAtIndex(category_id); - if (category_sp->IsEnabled() == false) + if (!category_sp->IsEnabled()) continue; lldb::TypeValidatorImplSP validator_current_sp( category_sp->GetValidatorForType(type_sp).get()); @@ -484,7 +479,7 @@ lldb::Format FormatManager::GetSingleItemFormat(lldb::Format vector_format) { bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) { // if settings say no oneline whatsoever if (valobj.GetTargetSP().get() && - valobj.GetTargetSP()->GetDebugger().GetAutoOneLineSummaries() == false) + !valobj.GetTargetSP()->GetDebugger().GetAutoOneLineSummaries()) return false; // then don't oneline // if this object has a summary, then ask the summary @@ -540,7 +535,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) { if (!synth_sp) return false; // but if we only have them to provide a value, keep going - if (synth_sp->MightHaveChildren() == false && + if (!synth_sp->MightHaveChildren() && synth_sp->DoesProvideSyntheticValue()) is_synth_val = true; else diff --git a/source/DataFormatters/FormattersHelpers.cpp b/source/DataFormatters/FormattersHelpers.cpp index 460a49690d3d..9f8fc72f10aa 100644 --- a/source/DataFormatters/FormattersHelpers.cpp +++ b/source/DataFormatters/FormattersHelpers.cpp @@ -1,20 +1,15 @@ //===-- FormattersHelpers.cpp -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormattersHelpers.h" #include "lldb/Target/StackFrame.h" diff --git a/source/DataFormatters/LanguageCategory.cpp b/source/DataFormatters/LanguageCategory.cpp index 251f0c368e08..969b02556548 100644 --- a/source/DataFormatters/LanguageCategory.cpp +++ b/source/DataFormatters/LanguageCategory.cpp @@ -1,19 +1,14 @@ //===-- LanguageCategory.cpp ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/LanguageCategory.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatManager.h" #include "lldb/DataFormatters/TypeCategory.h" #include "lldb/DataFormatters/TypeFormat.h" diff --git a/source/DataFormatters/StringPrinter.cpp b/source/DataFormatters/StringPrinter.cpp index 89d7a95069ca..0f040e3ddd08 100644 --- a/source/DataFormatters/StringPrinter.cpp +++ b/source/DataFormatters/StringPrinter.cpp @@ -1,10 +1,9 @@ //===-- StringPrinter.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -312,7 +311,7 @@ static bool DumpUTFBufferToStream( utf8_data_end_ptr = utf8_data_ptr + utf8_data_buffer_sp->GetByteSize(); ConvertFunction(&data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, llvm::lenientConversion); - if (false == zero_is_terminator) + if (!zero_is_terminator) utf8_data_end_ptr = utf8_data_ptr; // needed because the ConvertFunction will change the value of the // data_ptr. diff --git a/source/DataFormatters/TypeCategory.cpp b/source/DataFormatters/TypeCategory.cpp index d2150373c7c7..91ddd7f51396 100644 --- a/source/DataFormatters/TypeCategory.cpp +++ b/source/DataFormatters/TypeCategory.cpp @@ -1,19 +1,14 @@ //===-- TypeCategory.cpp -----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/TypeCategory.h" #include "lldb/Target/Language.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; @@ -167,10 +162,7 @@ bool TypeCategoryImpl::Get(ValueObject &valobj, else /*if (filter_sp.get() && synth.get())*/ { - if (filter_sp->GetRevision() > synth->GetRevision()) - pick_synth = false; - else - pick_synth = true; + pick_synth = filter_sp->GetRevision() <= synth->GetRevision(); } if (pick_synth) { if (regex_synth && reason) diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp index d2da672f13dc..51bb01afcc82 100644 --- a/source/DataFormatters/TypeCategoryMap.cpp +++ b/source/DataFormatters/TypeCategoryMap.cpp @@ -1,10 +1,9 @@ //===-- TypeCategoryMap.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,10 +12,6 @@ #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/Utility/Log.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; @@ -122,8 +117,7 @@ void TypeCategoryMap::EnableAllCategories() { void TypeCategoryMap::DisableAllCategories() { std::lock_guard guard(m_map_mutex); - Position p = First; - for (; false == m_active_categories.empty(); p++) { + for (Position p = First; !m_active_categories.empty(); p++) { m_active_categories.front()->SetEnabledPosition(p); Disable(m_active_categories.front()); } diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp index 28143e5fd4e0..929efa59ea95 100644 --- a/source/DataFormatters/TypeFormat.cpp +++ b/source/DataFormatters/TypeFormat.cpp @@ -1,21 +1,16 @@ //===-- TypeFormat.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/TypeFormat.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" @@ -166,11 +161,10 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj, if (!target_sp) return false; const ModuleList &images(target_sp->GetImages()); - SymbolContext sc; TypeList types; llvm::DenseSet searched_symbol_files; - images.FindTypes(sc, m_enum_type, false, UINT32_MAX, searched_symbol_files, - types); + images.FindTypes(nullptr, m_enum_type, false, UINT32_MAX, + searched_symbol_files, types); if (types.GetSize() == 0) return false; for (lldb::TypeSP type_sp : types.Types()) { @@ -185,7 +179,7 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj, } } else valobj_enum_type = iter->second; - if (valobj_enum_type.IsValid() == false) + if (!valobj_enum_type.IsValid()) return false; DataExtractor data; Status error; diff --git a/source/DataFormatters/TypeSummary.cpp b/source/DataFormatters/TypeSummary.cpp index 09a7ff8d7d36..a0bf2111ba8d 100644 --- a/source/DataFormatters/TypeSummary.cpp +++ b/source/DataFormatters/TypeSummary.cpp @@ -1,21 +1,16 @@ //===-- TypeSummary.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/TypeSummary.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" @@ -139,7 +134,7 @@ bool CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj, const TypeSummaryOptions &options) { dest.clear(); StreamString stream; - if (!m_impl || m_impl(*valobj, stream, options) == false) + if (!m_impl || !m_impl(*valobj, stream, options)) return false; dest = stream.GetString(); return true; diff --git a/source/DataFormatters/TypeSynthetic.cpp b/source/DataFormatters/TypeSynthetic.cpp index 28a51dae6b20..2366958b0e0e 100644 --- a/source/DataFormatters/TypeSynthetic.cpp +++ b/source/DataFormatters/TypeSynthetic.cpp @@ -1,20 +1,15 @@ //===-- TypeSynthetic.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/source/DataFormatters/TypeValidator.cpp b/source/DataFormatters/TypeValidator.cpp index 7a5b8d565292..5ce24cacfb55 100644 --- a/source/DataFormatters/TypeValidator.cpp +++ b/source/DataFormatters/TypeValidator.cpp @@ -1,19 +1,14 @@ //===-- TypeValidator.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/TypeValidator.h" #include "lldb/Utility/StreamString.h" diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp index 95bf4d41a73d..4a7fa63ace4c 100644 --- a/source/DataFormatters/ValueObjectPrinter.cpp +++ b/source/DataFormatters/ValueObjectPrinter.cpp @@ -1,18 +1,13 @@ //===-- ValueObjectPrinter.cpp -----------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/DataFormatters/ValueObjectPrinter.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ValueObject.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -133,13 +128,13 @@ bool ValueObjectPrinter::GetMostSpecializedValue() { } if (m_valobj->IsSynthetic()) { - if (m_options.m_use_synthetic == false) { + if (!m_options.m_use_synthetic) { ValueObject *non_synthetic = m_valobj->GetNonSyntheticValue().get(); if (non_synthetic) m_valobj = non_synthetic; } } else { - if (m_options.m_use_synthetic == true) { + if (m_options.m_use_synthetic) { ValueObject *synthetic = m_valobj->GetSyntheticValue().get(); if (synthetic) m_valobj = synthetic; @@ -170,7 +165,7 @@ const char *ValueObjectPrinter::GetRootNameForDisplay(const char *if_fail) { bool ValueObjectPrinter::ShouldPrintValueObject() { if (m_should_print == eLazyBoolCalculate) m_should_print = - (m_options.m_flat_output == false || m_type_flags.Test(eTypeHasValue)) + (!m_options.m_flat_output || m_type_flags.Test(eTypeHasValue)) ? eLazyBoolYes : eLazyBoolNo; return m_should_print == eLazyBoolYes; @@ -330,7 +325,7 @@ bool ValueObjectPrinter::CheckScopeIfNeeded() { } TypeSummaryImpl *ValueObjectPrinter::GetSummaryFormatter(bool null_if_omitted) { - if (m_summary_formatter.second == false) { + if (!m_summary_formatter.second) { TypeSummaryImpl *entry = m_options.m_summary_sp ? m_options.m_summary_sp.get() : m_valobj->GetSummaryFormat().get(); @@ -462,7 +457,7 @@ bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed, else m_stream->Printf("%s\n", object_desc); return true; - } else if (value_printed == false && summary_printed == false) + } else if (!value_printed && !summary_printed) return true; else return false; @@ -651,7 +646,7 @@ bool ValueObjectPrinter::ShouldPrintEmptyBrackets(bool value_printed, if (!IsAggregate()) return false; - if (m_options.m_reveal_empty_aggregates == false) { + if (!m_options.m_reveal_empty_aggregates) { if (value_printed || summary_printed) return false; } diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp index e36156a22789..de59724d1e36 100644 --- a/source/DataFormatters/VectorType.cpp +++ b/source/DataFormatters/VectorType.cpp @@ -1,16 +1,11 @@ //===-- VectorType.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/VectorType.h" #include "lldb/Core/ValueObject.h" @@ -175,8 +170,9 @@ static size_t CalculateNumChildren( lldb_private::ExecutionContextScope *exe_scope = nullptr // does not matter here because all we trade in are basic types ) { - auto container_size = container_type.GetByteSize(exe_scope); - auto element_size = element_type.GetByteSize(exe_scope); + llvm::Optional container_size = + container_type.GetByteSize(exe_scope); + llvm::Optional element_size = element_type.GetByteSize(exe_scope); if (container_size && element_size && *element_size) { if (*container_size % *element_size) @@ -202,7 +198,7 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { if (idx >= CalculateNumChildren()) return {}; - auto size = m_child_type.GetByteSize(nullptr); + llvm::Optional size = m_child_type.GetByteSize(nullptr); if (!size) return {}; auto offset = idx * *size; diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp index 40e2eb579e06..4d002a4f452d 100644 --- a/source/Expression/DWARFExpression.cpp +++ b/source/Expression/DWARFExpression.cpp @@ -1,27 +1,24 @@ //===-- DWARFExpression.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Expression/DWARFExpression.h" -// C Includes #include -// C++ Includes #include #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/dwarf.h" #include "lldb/Utility/DataEncoder.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/VMRange.h" @@ -1841,7 +1838,7 @@ bool DWARFExpression::Evaluate( error_ptr->SetErrorString( "Expression stack needs at least 1 item for DW_OP_abs."); return false; - } else if (stack.back().ResolveValue(exe_ctx).AbsoluteValue() == false) { + } else if (!stack.back().ResolveValue(exe_ctx).AbsoluteValue()) { if (error_ptr) error_ptr->SetErrorString( "Failed to take the absolute value of the first stack item."); @@ -1974,7 +1971,7 @@ bool DWARFExpression::Evaluate( "Expression stack needs at least 1 item for DW_OP_neg."); return false; } else { - if (stack.back().ResolveValue(exe_ctx).UnaryNegate() == false) { + if (!stack.back().ResolveValue(exe_ctx).UnaryNegate()) { if (error_ptr) error_ptr->SetErrorString("Unary negate failed."); return false; @@ -1995,7 +1992,7 @@ bool DWARFExpression::Evaluate( "Expression stack needs at least 1 item for DW_OP_not."); return false; } else { - if (stack.back().ResolveValue(exe_ctx).OnesComplement() == false) { + if (!stack.back().ResolveValue(exe_ctx).OnesComplement()) { if (error_ptr) error_ptr->SetErrorString("Logical NOT failed."); return false; @@ -2102,8 +2099,8 @@ bool DWARFExpression::Evaluate( } else { tmp = stack.back(); stack.pop_back(); - if (stack.back().ResolveValue(exe_ctx).ShiftRightLogical( - tmp.ResolveValue(exe_ctx)) == false) { + if (!stack.back().ResolveValue(exe_ctx).ShiftRightLogical( + tmp.ResolveValue(exe_ctx))) { if (error_ptr) error_ptr->SetErrorString("DW_OP_shr failed."); return false; @@ -3029,7 +3026,9 @@ bool DWARFExpression::AddressRangeForLocationListEntry( if (!debug_loc_data.ValidOffset(*offset_ptr)) return false; - switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) { + DWARFExpression::LocationListFormat format = + dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat(); + switch (format) { case NonLocationList: return false; case RegularLocationList: @@ -3037,6 +3036,7 @@ bool DWARFExpression::AddressRangeForLocationListEntry( high_pc = debug_loc_data.GetAddress(offset_ptr); return true; case SplitDwarfLocationList: + case LocLists: switch (debug_loc_data.GetU8(offset_ptr)) { case DW_LLE_end_of_list: return false; @@ -3050,12 +3050,25 @@ bool DWARFExpression::AddressRangeForLocationListEntry( case DW_LLE_startx_length: { uint64_t index = debug_loc_data.GetULEB128(offset_ptr); low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index); - uint32_t length = debug_loc_data.GetU32(offset_ptr); + uint64_t length = (format == LocLists) + ? debug_loc_data.GetULEB128(offset_ptr) + : debug_loc_data.GetU32(offset_ptr); high_pc = low_pc + length; return true; } + case DW_LLE_start_length: { + low_pc = debug_loc_data.GetAddress(offset_ptr); + high_pc = low_pc + debug_loc_data.GetULEB128(offset_ptr); + return true; + } + case DW_LLE_start_end: { + low_pc = debug_loc_data.GetAddress(offset_ptr); + high_pc = debug_loc_data.GetAddress(offset_ptr); + return true; + } default: // Not supported entry type + lldbassert(false && "Not supported location list type"); return false; } } diff --git a/source/Expression/DiagnosticManager.cpp b/source/Expression/DiagnosticManager.cpp index a98d30339b4a..53d85f8a6d54 100644 --- a/source/Expression/DiagnosticManager.cpp +++ b/source/Expression/DiagnosticManager.cpp @@ -1,9 +1,8 @@ //===-- DiagnosticManager.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Expression/Expression.cpp b/source/Expression/Expression.cpp index 285079a85b43..71369d0b9eec 100644 --- a/source/Expression/Expression.cpp +++ b/source/Expression/Expression.cpp @@ -1,9 +1,8 @@ //===-- Expression.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Expression/ExpressionSourceCode.cpp b/source/Expression/ExpressionSourceCode.cpp index f0a7bacef3ce..8f5ade7048b1 100644 --- a/source/Expression/ExpressionSourceCode.cpp +++ b/source/Expression/ExpressionSourceCode.cpp @@ -1,9 +1,8 @@ //===-- ExpressionSourceCode.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -125,10 +124,7 @@ class AddMacroState { if (m_file_stack.back() != m_current_file) return true; - if (line >= m_current_file_line) - return false; - else - return true; + return line < m_current_file_line; default: return false; } @@ -186,7 +182,7 @@ static void AddMacros(const DebugMacros *dm, CompileUnit *comp_unit, } static bool ExprBodyContainsVar(llvm::StringRef var, llvm::StringRef body) { - int from = 0; + size_t from = 0; while ((from = body.find(var, from)) != llvm::StringRef::npos) { if ((from != 0 && clang::isIdentifierBody(body[from-1])) || (from + var.size() != body.size() && @@ -486,7 +482,6 @@ bool ExpressionSourceCode::GetText( if (triple.isOSDarwin()) { if (auto process_sp = exe_ctx.GetProcessSP()) { os_vers << getAvailabilityName(triple.getOS()) << " "; - uint32_t major, minor, patch; auto platform = target->GetPlatform(); bool is_simulator = platform->GetPluginName().GetStringRef().endswith("-simulator"); @@ -501,7 +496,6 @@ bool ExpressionSourceCode::GetText( } } } - const bool playground = options.GetPlaygroundTransformEnabled(); SwiftPersistentExpressionState *persistent_state = llvm::cast(target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeSwift)); std::vector persistent_results; @@ -556,7 +550,5 @@ bool ExpressionSourceCode::GetOriginalBodyBounds( return false; start_loc += strlen(start_marker); end_loc = transformed_text.find(end_marker); - if (end_loc == std::string::npos) - return false; - return true; + return end_loc != std::string::npos; } diff --git a/source/Expression/ExpressionVariable.cpp b/source/Expression/ExpressionVariable.cpp index f619119ea0e4..3a9b0f9655ac 100644 --- a/source/Expression/ExpressionVariable.cpp +++ b/source/Expression/ExpressionVariable.cpp @@ -1,9 +1,8 @@ //===-- ExpressionVariable.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Expression/FunctionCaller.cpp b/source/Expression/FunctionCaller.cpp index 3efa3516b730..e828369010ac 100644 --- a/source/Expression/FunctionCaller.cpp +++ b/source/Expression/FunctionCaller.cpp @@ -1,20 +1,14 @@ //===-- FunctionCaller.cpp ---------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Expression/FunctionCaller.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/DiagnosticManager.h" @@ -31,6 +25,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb_private; diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp index e0a7dca4113d..8d9100a41af9 100644 --- a/source/Expression/IRDynamicChecks.cpp +++ b/source/Expression/IRDynamicChecks.cpp @@ -1,15 +1,11 @@ //===-- IRDynamicChecks.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" @@ -18,7 +14,6 @@ #include "llvm/IR/Value.h" #include "llvm/Support/raw_ostream.h" -// Project includes #include "lldb/Expression/IRDynamicChecks.h" #include "lldb/Expression/UtilityFunction.h" diff --git a/source/Expression/IRExecutionUnit.cpp b/source/Expression/IRExecutionUnit.cpp index 997de442427f..b11621179a43 100644 --- a/source/Expression/IRExecutionUnit.cpp +++ b/source/Expression/IRExecutionUnit.cpp @@ -1,9 +1,8 @@ //===-- IRExecutionUnit.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -566,6 +565,8 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( sect_type = lldb::eSectionTypeDWARFDebugLine; else if (dwarf_name.equals("loc")) sect_type = lldb::eSectionTypeDWARFDebugLoc; + else if (dwarf_name.equals("loclists")) + sect_type = lldb::eSectionTypeDWARFDebugLocLists; break; case 'm': @@ -720,9 +721,10 @@ FindBestAlternateMangledName(const ConstString &demangled, struct IRExecutionUnit::SearchSpec { ConstString name; - uint32_t mask; + lldb::FunctionNameType mask; - SearchSpec(ConstString n, uint32_t m = lldb::eFunctionNameTypeFull) + SearchSpec(ConstString n, + lldb::FunctionNameType m = lldb::eFunctionNameTypeFull) : name(n), mask(m) {} }; @@ -1023,7 +1025,7 @@ IRExecutionUnit::MemoryManager::getSymbolAddress(const std::string &Name) { Name.c_str()); m_parent.ReportSymbolLookupError(name_cs); - return 0xbad0bad0; + return 0; } else { if (log) log->Printf("IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64, @@ -1101,6 +1103,7 @@ bool IRExecutionUnit::CommitOneAllocation(lldb::ProcessSP &process_sp, case lldb::eSectionTypeDWARFDebugInfo: case lldb::eSectionTypeDWARFDebugLine: case lldb::eSectionTypeDWARFDebugLoc: + case lldb::eSectionTypeDWARFDebugLocLists: case lldb::eSectionTypeDWARFDebugMacInfo: case lldb::eSectionTypeDWARFDebugPubNames: case lldb::eSectionTypeDWARFDebugPubTypes: @@ -1309,14 +1312,11 @@ void IRExecutionUnit::PopulateSectionList( } } -bool IRExecutionUnit::GetArchitecture(lldb_private::ArchSpec &arch) { +ArchSpec IRExecutionUnit::GetArchitecture() { ExecutionContext exe_ctx(GetBestExecutionContextScope()); - Target *target = exe_ctx.GetTargetPtr(); - if (target) - arch = target->GetArchitecture(); - else - arch.Clear(); - return arch.IsValid(); + if(Target *target = exe_ctx.GetTargetPtr()) + return target->GetArchitecture(); + return ArchSpec(); } lldb::ModuleSP IRExecutionUnit::GetJITModule() { diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp index c15589e37d43..484ddde1318a 100644 --- a/source/Expression/IRInterpreter.cpp +++ b/source/Expression/IRInterpreter.cpp @@ -1,16 +1,14 @@ //===-- IRInterpreter.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Expression/IRInterpreter.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/IRExecutionUnit.h" @@ -19,6 +17,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -1592,9 +1591,6 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, // Check if this is a string literal or constant string pointer if (arg_ty->isPointerTy()) { - // Pointer to just one type - assert(arg_ty->getNumContainedTypes() == 1); - lldb::addr_t addr = tmp_op.ULongLong(); size_t dataSize = 0; diff --git a/source/Expression/IRMemoryMap.cpp b/source/Expression/IRMemoryMap.cpp index 1953e80852ff..d82a574ee417 100644 --- a/source/Expression/IRMemoryMap.cpp +++ b/source/Expression/IRMemoryMap.cpp @@ -1,14 +1,12 @@ //===-- IRMemoryMap.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Expression/IRMemoryMap.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -16,6 +14,7 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" using namespace lldb_private; @@ -272,21 +271,17 @@ IRMemoryMap::Allocation::Allocation(lldb::addr_t process_alloc, uint32_t permissions, uint8_t alignment, AllocationPolicy policy) : m_process_alloc(process_alloc), m_process_start(process_start), - m_size(size), m_permissions(permissions), m_alignment(alignment), - m_policy(policy), m_leak(false) { + m_size(size), m_policy(policy), m_leak(false), m_permissions(permissions), + m_alignment(alignment) { switch (policy) { default: assert(0 && "We cannot reach this!"); case eAllocationPolicyHostOnly: + case eAllocationPolicyMirror: m_data.SetByteSize(size); - memset(m_data.GetBytes(), 0, size); break; case eAllocationPolicyProcessOnly: break; - case eAllocationPolicyMirror: - m_data.SetByteSize(size); - memset(m_data.GetBytes(), 0, size); - break; } } @@ -393,9 +388,10 @@ lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment, lldb::addr_t mask = alignment - 1; aligned_address = (allocation_address + mask) & (~mask); - m_allocations[aligned_address] = - Allocation(allocation_address, aligned_address, allocation_size, - permissions, alignment, policy); + m_allocations.emplace( + std::piecewise_construct, std::forward_as_tuple(aligned_address), + std::forward_as_tuple(allocation_address, aligned_address, + allocation_size, permissions, alignment, policy)); if (zero_memory) { Status write_error; diff --git a/source/Expression/LLVMUserExpression.cpp b/source/Expression/LLVMUserExpression.cpp index 8e15d137c6c6..91b9977f1849 100644 --- a/source/Expression/LLVMUserExpression.cpp +++ b/source/Expression/LLVMUserExpression.cpp @@ -1,16 +1,12 @@ //===-- LLVMUserExpression.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Project includes #include "lldb/Expression/LLVMUserExpression.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" diff --git a/source/Expression/Materializer.cpp b/source/Expression/Materializer.cpp index 44fab7db8750..b75e3b32dc65 100644 --- a/source/Expression/Materializer.cpp +++ b/source/Expression/Materializer.cpp @@ -1,19 +1,13 @@ //===-- Materializer.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Expression/Materializer.h" #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/ExpressionVariable.h" @@ -27,6 +21,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; @@ -50,7 +45,7 @@ uint32_t Materializer::AddStructMember(Entity &entity) { } void Materializer::Entity::SetSizeAndAlignmentFromType(CompilerType &type) { - if (auto size = type.GetByteSize(nullptr)) + if (llvm::Optional size = type.GetByteSize(nullptr)) m_size = *size; uint32_t bit_alignment = type.GetTypeBitAlign(); @@ -565,7 +560,7 @@ class EntityVariable : public Materializer::Entity { if (data.GetByteSize() < m_variable_sp->GetType()->GetByteSize()) { if (data.GetByteSize() == 0 && - m_variable_sp->LocationExpression().IsValid() == false) { + !m_variable_sp->LocationExpression().IsValid()) { err.SetErrorStringWithFormat("the variable '%s' has no location, " "it may have been optimized out", m_variable_sp->GetName().AsCString()); @@ -574,7 +569,8 @@ class EntityVariable : public Materializer::Entity { "size of variable %s (%" PRIu64 ") is larger than the ValueObject's size (%" PRIu64 ")", m_variable_sp->GetName().AsCString(), - m_variable_sp->GetType()->GetByteSize(), data.GetByteSize()); + m_variable_sp->GetType()->GetByteSize().getValueOr(0), + data.GetByteSize()); } return; } @@ -865,7 +861,7 @@ class EntityResultVariable : public Materializer::Entity { ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope(); - auto byte_size = m_type.GetByteSize(exe_scope); + llvm::Optional byte_size = m_type.GetByteSize(exe_scope); if (!byte_size) { err.SetErrorString("can't get size of type"); return; @@ -1122,7 +1118,6 @@ class EntityResultVariable : public Materializer::Entity { CompilerType m_type; bool m_is_program_reference; bool m_keep_in_memory; - bool m_is_error_result; lldb::addr_t m_temporary_allocation; size_t m_temporary_allocation_size; diff --git a/source/Expression/REPL.cpp b/source/Expression/REPL.cpp index 9e63cd72a9e8..7fd466b818bf 100644 --- a/source/Expression/REPL.cpp +++ b/source/Expression/REPL.cpp @@ -1,16 +1,11 @@ //===-- REPL.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Expression/REPL.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" @@ -66,7 +61,7 @@ std::string REPL::GetSourcePath() { tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString()); m_repl_source_path = tmpdir_file_spec.GetPath(); } else { - tmpdir_file_spec = FileSpec("/tmp", false); + tmpdir_file_spec = FileSpec("/tmp"); tmpdir_file_spec.AppendPathComponent(file_basename.AsCString()); } @@ -434,11 +429,12 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { // Update our code on disk if (!m_repl_source_path.empty()) { - lldb_private::File file(m_repl_source_path.c_str(), - File::eOpenOptionWrite | - File::eOpenOptionTruncate | - File::eOpenOptionCanCreate, - lldb::eFilePermissionsFileDefault); + lldb_private::File file; + FileSystem::Instance().Open(file, FileSpec(m_repl_source_path), + File::eOpenOptionWrite | + File::eOpenOptionTruncate | + File::eOpenOptionCanCreate, + lldb::eFilePermissionsFileDefault); std::string code(m_code.CopyList()); code.append(1, '\n'); size_t bytes_written = code.size(); @@ -447,7 +443,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { // Now set the default file and line to the REPL source file m_target.GetSourceManager().SetDefaultFileAndLine( - FileSpec(m_repl_source_path, false), new_default_line); + FileSpec(m_repl_source_path), new_default_line); } static_cast(io_handler) .SetBaseLineNumber(m_code.GetSize() + 1); @@ -471,7 +467,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches) { + StringList &matches, StringList &descriptions) { matches.Clear(); llvm::StringRef line(current_line, cursor - current_line); @@ -484,7 +480,7 @@ int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *lldb_current_line = line.substr(1).data(); return debugger.GetCommandInterpreter().HandleCompletion( lldb_current_line, cursor, last_char, skip_first_n_matches, max_matches, - matches); + matches, descriptions); } // Strip spaces from the line and see if we had only spaces diff --git a/source/Expression/UserExpression.cpp b/source/Expression/UserExpression.cpp index a77a9b0c92e1..6a7f4f40e57b 100644 --- a/source/Expression/UserExpression.cpp +++ b/source/Expression/UserExpression.cpp @@ -1,9 +1,8 @@ //===-- UserExpression.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Expression/UtilityFunction.cpp b/source/Expression/UtilityFunction.cpp index 52f3bfc4d128..30c33d2baa4c 100644 --- a/source/Expression/UtilityFunction.cpp +++ b/source/Expression/UtilityFunction.cpp @@ -1,19 +1,16 @@ //===-- UtilityFunction.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #if HAVE_SYS_TYPES_H #include #endif -// C++ Includes #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" diff --git a/source/Host/CMakeLists.txt b/source/Host/CMakeLists.txt index 5a92447edf30..333f109a9a26 100644 --- a/source/Host/CMakeLists.txt +++ b/source/Host/CMakeLists.txt @@ -11,7 +11,9 @@ endmacro() # Objective-C++ files in lldb (which slows down the build process). macro(remove_module_flags) string(REGEX REPLACE "-fmodules-cache-path=[^ ]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REGEX REPLACE "-fmodules-local-submodule-visibility" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REGEX REPLACE "-fmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REGEX REPLACE "-gmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REGEX REPLACE "-fcxx-modules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") endmacro() @@ -28,8 +30,6 @@ add_host_subdirectory(common common/LockFileBase.cpp common/MainLoop.cpp common/MonitoringProcessLauncher.cpp - common/NativeBreakpoint.cpp - common/NativeBreakpointList.cpp common/NativeWatchpointList.cpp common/NativeProcessProtocol.cpp common/NativeRegisterContext.cpp @@ -40,7 +40,6 @@ add_host_subdirectory(common common/PseudoTerminal.cpp common/Socket.cpp common/SocketAddress.cpp - common/SoftwareBreakpoint.cpp common/StringConvert.cpp common/Symbols.cpp common/TaskPool.cpp @@ -92,7 +91,7 @@ else() include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR}) add_subdirectory(macosx/objcxx) set(LLDBObjCLibs lldbHostMacOSXObjCXX) - add_host_subdirectory(maqcosx + add_host_subdirectory(macosx macosx/Symbols.cpp macosx/cfcpp/CFCBundle.cpp macosx/cfcpp/CFCData.cpp @@ -156,7 +155,7 @@ if (HAVE_LIBDL) list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) endif() if (NOT LLDB_DISABLE_LIBEDIT) - list(APPEND EXTRA_LIBS edit) + list(APPEND EXTRA_LIBS ${libedit_LIBRARIES}) endif() add_lldb_library(lldbHost @@ -174,3 +173,7 @@ add_lldb_library(lldbHost Object Support ) + +if (NOT LLDB_DISABLE_LIBEDIT) + target_include_directories(lldbHost PUBLIC ${libedit_INCLUDE_DIRS}) +endif() diff --git a/source/Host/android/HostInfoAndroid.cpp b/source/Host/android/HostInfoAndroid.cpp index a96033283212..9619ec1a837f 100644 --- a/source/Host/android/HostInfoAndroid.cpp +++ b/source/Host/android/HostInfoAndroid.cpp @@ -1,13 +1,13 @@ //===-- HostInfoAndroid.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/android/HostInfoAndroid.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/linux/HostInfoLinux.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -28,7 +28,7 @@ void HostInfoAndroid::ComputeHostArchitectureSupport(ArchSpec &arch_32, } FileSpec HostInfoAndroid::GetDefaultShell() { - return FileSpec("/system/bin/sh", false); + return FileSpec("/system/bin/sh"); } FileSpec HostInfoAndroid::ResolveLibraryPath(const std::string &module_path, @@ -39,8 +39,11 @@ FileSpec HostInfoAndroid::ResolveLibraryPath(const std::string &module_path, static const char *const default_lib64_path[] = {"/vendor/lib64", "/system/lib64", nullptr}; - if (module_path.empty() || module_path[0] == '/') - return FileSpec(module_path.c_str(), true); + if (module_path.empty() || module_path[0] == '/') { + FileSpec file_spec(module_path.c_str()); + FileSystem::Instance().Resolve(file_spec); + return file_spec; + } SmallVector ld_paths; @@ -65,10 +68,11 @@ FileSpec HostInfoAndroid::ResolveLibraryPath(const std::string &module_path, ld_paths.push_back(StringRef(*it)); for (const StringRef &path : ld_paths) { - FileSpec file_candidate(path.str().c_str(), true); + FileSpec file_candidate(path.str().c_str()); + FileSystem::Instance().Resolve(file_candidate); file_candidate.AppendPathComponent(module_path.c_str()); - if (file_candidate.Exists()) + if (FileSystem::Instance().Exists(file_candidate)) return file_candidate; } @@ -83,8 +87,8 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec) { // algorithm will deduce /tmp, which is plain wrong. In that case we have an // invalid directory, we substitute the path with /data/local/tmp, which is // correct at least in some cases (i.e., when running as shell user). - if (!success || !file_spec.Exists()) - file_spec = FileSpec("/data/local/tmp", false); + if (!success || !FileSystem::Instance().Exists(file_spec)) + file_spec = FileSpec("/data/local/tmp"); - return file_spec.Exists(); + return FileSystem::Instance().Exists(file_spec); } diff --git a/source/Host/android/LibcGlue.cpp b/source/Host/android/LibcGlue.cpp index 13437f9704e3..6eac87be10ec 100644 --- a/source/Host/android/LibcGlue.cpp +++ b/source/Host/android/LibcGlue.cpp @@ -1,9 +1,8 @@ //===-- LibcGlue.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/Editline.cpp b/source/Host/common/Editline.cpp index b16c039b6c95..9303fa9f7a03 100644 --- a/source/Host/common/Editline.cpp +++ b/source/Host/common/Editline.cpp @@ -1,9 +1,8 @@ //===-- Editline.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,6 +12,7 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Editline.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBAssert.h" @@ -172,7 +172,8 @@ class EditlineHistory { const char *GetHistoryFilePath() { if (m_path.empty() && m_history && !m_prefix.empty()) { - FileSpec parent_path{"~/.lldb", true}; + FileSpec parent_path("~/.lldb"); + FileSystem::Instance().Resolve(parent_path); char history_path[PATH_MAX]; if (!llvm::sys::fs::create_directory(parent_path.GetPath())) { snprintf(history_path, sizeof(history_path), "~/.lldb/%s-history", @@ -181,7 +182,9 @@ class EditlineHistory { snprintf(history_path, sizeof(history_path), "~/%s-widehistory", m_prefix.c_str()); } - m_path = FileSpec(history_path, true).GetPath(); + auto file_spec = FileSpec(history_path); + FileSystem::Instance().Resolve(file_spec); + m_path = file_spec.GetPath(); } if (m_path.empty()) return NULL; @@ -426,7 +429,7 @@ unsigned char Editline::RecallHistory(bool earlier) { // Treat moving from the "live" entry differently if (!m_in_history) { - if (earlier == false) + if (!earlier) return CC_ERROR; // Can't go newer than the "live" entry if (history_w(pHistory, &history_event, H_FIRST) == -1) return CC_ERROR; @@ -439,7 +442,7 @@ unsigned char Editline::RecallHistory(bool earlier) { m_live_history_lines = m_input_lines; m_in_history = true; } else { - if (history_w(pHistory, &history_event, earlier ? H_NEXT : H_PREV) == -1) { + if (history_w(pHistory, &history_event, earlier ? H_PREV : H_NEXT) == -1) { // Can't move earlier than the earliest entry if (earlier) return CC_ERROR; @@ -526,7 +529,7 @@ int Editline::GetCharacter(EditLineGetCharType *c) { break; case lldb::eConnectionStatusInterrupted: - lldbassert(0 && "Interrupts should have been handled above."); + llvm_unreachable("Interrupts should have been handled above."); case lldb::eConnectionStatusError: // Check GetError() for details case lldb::eConnectionStatusTimedOut: // Request timed out @@ -853,19 +856,45 @@ unsigned char Editline::BufferEndCommand(int ch) { return CC_NEWLINE; } +//------------------------------------------------------------------------------ +/// Prints completions and their descriptions to the given file. Only the +/// completions in the interval [start, end) are printed. +//------------------------------------------------------------------------------ +static void PrintCompletion(FILE *output_file, size_t start, size_t end, + StringList &completions, StringList &descriptions) { + // This is an 'int' because of printf. + int max_len = 0; + + for (size_t i = start; i < end; i++) { + const char *completion_str = completions.GetStringAtIndex(i); + max_len = std::max((int)strlen(completion_str), max_len); + } + + for (size_t i = start; i < end; i++) { + const char *completion_str = completions.GetStringAtIndex(i); + const char *description_str = descriptions.GetStringAtIndex(i); + + fprintf(output_file, "\n\t%-*s", max_len, completion_str); + + // Print the description if we got one. + if (strlen(description_str)) + fprintf(output_file, " -- %s", description_str); + } +} + unsigned char Editline::TabCommand(int ch) { if (m_completion_callback == nullptr) return CC_ERROR; const LineInfo *line_info = el_line(m_editline); - StringList completions; + StringList completions, descriptions; int page_size = 40; const int num_completions = m_completion_callback( line_info->buffer, line_info->cursor, line_info->lastchar, 0, // Don't skip any matches (start at match zero) -1, // Get all the matches - completions, m_completion_callback_baton); + completions, descriptions, m_completion_callback_baton); if (num_completions == 0) return CC_ERROR; @@ -893,10 +922,8 @@ unsigned char Editline::TabCommand(int ch) { int num_elements = num_completions + 1; fprintf(m_output_file, "\n" ANSI_CLEAR_BELOW "Available completions:"); if (num_completions < page_size) { - for (int i = 1; i < num_elements; i++) { - completion_str = completions.GetStringAtIndex(i); - fprintf(m_output_file, "\n\t%s", completion_str); - } + PrintCompletion(m_output_file, 1, num_elements, completions, + descriptions); fprintf(m_output_file, "\n"); } else { int cur_pos = 1; @@ -906,10 +933,10 @@ unsigned char Editline::TabCommand(int ch) { int endpoint = cur_pos + page_size; if (endpoint > num_elements) endpoint = num_elements; - for (; cur_pos < endpoint; cur_pos++) { - completion_str = completions.GetStringAtIndex(cur_pos); - fprintf(m_output_file, "\n\t%s", completion_str); - } + + PrintCompletion(m_output_file, cur_pos, endpoint, completions, + descriptions); + cur_pos = endpoint; if (cur_pos >= num_elements) { fprintf(m_output_file, "\n"); diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp index 800810dfb018..1576f16c643a 100644 --- a/source/Host/common/File.cpp +++ b/source/Host/common/File.cpp @@ -1,9 +1,8 @@ //===-- File.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -27,9 +26,10 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Errno.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors() +#include "llvm/Support/Process.h" #include "lldb/Host/Config.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/FileSpec.h" @@ -71,27 +71,6 @@ static const char *GetStreamOpenModeFromOptions(uint32_t options) { int File::kInvalidDescriptor = -1; FILE *File::kInvalidStream = NULL; -File::File(const char *path, uint32_t options, uint32_t permissions) - : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), - m_stream(kInvalidStream), m_options(), m_own_stream(false), - m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate), - m_supports_colors(eLazyBoolCalculate) { - Open(path, options, permissions); -} - -File::File(const FileSpec &filespec, uint32_t options, uint32_t permissions) - : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), - m_stream(kInvalidStream), m_options(0), m_own_stream(false), - m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate), - m_supports_colors(eLazyBoolCalculate) -{ - if (filespec) { - Open(filespec.GetPath().c_str(), options, permissions); - } -} - File::~File() { Close(); } int File::GetDescriptor() const { @@ -160,108 +139,6 @@ void File::SetStream(FILE *fh, bool transfer_ownership) { m_own_stream = transfer_ownership; } -static int DoOpen(const char *path, int flags, int mode) { -#ifdef _MSC_VER - std::wstring wpath; - if (!llvm::ConvertUTF8toWide(path, wpath)) - return -1; - int result; - ::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode); - return result; -#else - return ::open(path, flags, mode); -#endif -} - -Status File::Open(const char *path, uint32_t options, uint32_t permissions) { - Status error; - if (IsValid()) - Close(); - - int oflag = 0; - const bool read = options & eOpenOptionRead; - const bool write = options & eOpenOptionWrite; - if (write) { - if (read) - oflag |= O_RDWR; - else - oflag |= O_WRONLY; - - if (options & eOpenOptionAppend) - oflag |= O_APPEND; - - if (options & eOpenOptionTruncate) - oflag |= O_TRUNC; - - if (options & eOpenOptionCanCreate) - oflag |= O_CREAT; - - if (options & eOpenOptionCanCreateNewOnly) - oflag |= O_CREAT | O_EXCL; - } else if (read) { - oflag |= O_RDONLY; - -#ifndef _WIN32 - if (options & eOpenOptionDontFollowSymlinks) - oflag |= O_NOFOLLOW; -#endif - } - -#ifndef _WIN32 - if (options & eOpenOptionNonBlocking) - oflag |= O_NONBLOCK; - if (options & eOpenOptionCloseOnExec) - oflag |= O_CLOEXEC; -#else - oflag |= O_BINARY; -#endif - - mode_t mode = 0; - if (oflag & O_CREAT) { - if (permissions & lldb::eFilePermissionsUserRead) - mode |= S_IRUSR; - if (permissions & lldb::eFilePermissionsUserWrite) - mode |= S_IWUSR; - if (permissions & lldb::eFilePermissionsUserExecute) - mode |= S_IXUSR; - if (permissions & lldb::eFilePermissionsGroupRead) - mode |= S_IRGRP; - if (permissions & lldb::eFilePermissionsGroupWrite) - mode |= S_IWGRP; - if (permissions & lldb::eFilePermissionsGroupExecute) - mode |= S_IXGRP; - if (permissions & lldb::eFilePermissionsWorldRead) - mode |= S_IROTH; - if (permissions & lldb::eFilePermissionsWorldWrite) - mode |= S_IWOTH; - if (permissions & lldb::eFilePermissionsWorldExecute) - mode |= S_IXOTH; - } - - m_descriptor = llvm::sys::RetryAfterSignal(-1, DoOpen, path, oflag, mode); - if (!DescriptorIsValid()) - error.SetErrorToErrno(); - else { - m_should_close_fd = true; - m_options = options; - } - - return error; -} - -uint32_t File::GetPermissions(const FileSpec &file_spec, Status &error) { - if (file_spec) { - error.Clear(); - auto Perms = llvm::sys::fs::getPermissions(file_spec.GetPath()); - if (Perms) - return *Perms; - error = Status(Perms.getError()); - return 0; - } else - error.SetErrorString("empty file spec"); - return 0; -} - uint32_t File::GetPermissions(Status &error) const { int fd = GetDescriptor(); if (fd != kInvalidDescriptor) { @@ -316,7 +193,7 @@ Status File::GetFileSpec(FileSpec &file_spec) const { if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1) error.SetErrorToErrno(); else - file_spec.SetFile(path, false, FileSpec::Style::native); + file_spec.SetFile(path, FileSpec::Style::native); } else { error.SetErrorString("invalid file handle"); } @@ -331,7 +208,7 @@ Status File::GetFileSpec(FileSpec &file_spec) const { error.SetErrorToErrno(); else { path[len] = '\0'; - file_spec.SetFile(path, false, FileSpec::Style::native); + file_spec.SetFile(path, FileSpec::Style::native); } } #else @@ -808,6 +685,9 @@ void File::CalculateInteractiveAndTerminal() { if (_isatty(fd)) { m_is_interactive = eLazyBoolYes; m_is_real_terminal = eLazyBoolYes; +#if defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) + m_supports_colors = eLazyBoolYes; +#endif } #else if (isatty(fd)) { diff --git a/source/Host/common/FileCache.cpp b/source/Host/common/FileCache.cpp index b4629255c852..4bd3efda7fb0 100644 --- a/source/Host/common/FileCache.cpp +++ b/source/Host/common/FileCache.cpp @@ -1,15 +1,15 @@ //===-- FileCache.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/FileCache.h" #include "lldb/Host/File.h" +#include "lldb/Host/FileSystem.h" using namespace lldb; using namespace lldb_private; @@ -25,14 +25,13 @@ FileCache &FileCache::GetInstance() { lldb::user_id_t FileCache::OpenFile(const FileSpec &file_spec, uint32_t flags, uint32_t mode, Status &error) { - std::string path(file_spec.GetPath()); - if (path.empty()) { + if (!file_spec) { error.SetErrorString("empty path"); return UINT64_MAX; } FileSP file_sp(new File()); - error = file_sp->Open(path.c_str(), flags, mode); - if (file_sp->IsValid() == false) + error = FileSystem::Instance().Open(*file_sp, file_spec, flags, mode); + if (!file_sp->IsValid()) return UINT64_MAX; lldb::user_id_t fd = file_sp->GetDescriptor(); m_cache[fd] = file_sp; diff --git a/source/Host/common/FileSystem.cpp b/source/Host/common/FileSystem.cpp index 4472aece1daa..6fbd7bc9f5aa 100644 --- a/source/Host/common/FileSystem.cpp +++ b/source/Host/common/FileSystem.cpp @@ -1,15 +1,38 @@ //===-- FileSystem.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/FileSystem.h" +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/TildeExpressionResolver.h" + +#include "llvm/Support/Errc.h" +#include "llvm/Support/Errno.h" +#include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/Threading.h" + +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include "lldb/Host/windows/windows.h" +#else +#include +#include +#include +#include +#endif #include #include @@ -17,12 +40,424 @@ using namespace lldb; using namespace lldb_private; +using namespace llvm; + +FileSystem &FileSystem::Instance() { return *InstanceImpl(); } + +void FileSystem::Initialize() { + lldbassert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(); +} + +void FileSystem::Initialize(FileCollector &collector) { + lldbassert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(collector); +} + +llvm::Error FileSystem::Initialize(const FileSpec &mapping) { + lldbassert(!InstanceImpl() && "Already initialized."); + + llvm::ErrorOr> buffer = + llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath()); + + if (!buffer) + return llvm::errorCodeToError(buffer.getError()); + + InstanceImpl().emplace( + llvm::vfs::getVFSFromYAML(std::move(buffer.get()), nullptr, ""), true); + + return llvm::Error::success(); +} + +void FileSystem::Initialize(IntrusiveRefCntPtr fs) { + lldbassert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(fs); +} + +void FileSystem::Terminate() { + lldbassert(InstanceImpl() && "Already terminated."); + InstanceImpl().reset(); +} + +Optional &FileSystem::InstanceImpl() { + static Optional g_fs; + return g_fs; +} + +vfs::directory_iterator FileSystem::DirBegin(const FileSpec &file_spec, + std::error_code &ec) { + return DirBegin(file_spec.GetPath(), ec); +} + +vfs::directory_iterator FileSystem::DirBegin(const Twine &dir, + std::error_code &ec) { + return m_fs->dir_begin(dir, ec); +} + +llvm::ErrorOr +FileSystem::GetStatus(const FileSpec &file_spec) const { + return GetStatus(file_spec.GetPath()); +} + +llvm::ErrorOr FileSystem::GetStatus(const Twine &path) const { + return m_fs->status(path); +} + +sys::TimePoint<> +FileSystem::GetModificationTime(const FileSpec &file_spec) const { + return GetModificationTime(file_spec.GetPath()); +} + +sys::TimePoint<> FileSystem::GetModificationTime(const Twine &path) const { + ErrorOr status = m_fs->status(path); + if (!status) + return sys::TimePoint<>(); + return status->getLastModificationTime(); +} + +uint64_t FileSystem::GetByteSize(const FileSpec &file_spec) const { + return GetByteSize(file_spec.GetPath()); +} + +uint64_t FileSystem::GetByteSize(const Twine &path) const { + ErrorOr status = m_fs->status(path); + if (!status) + return 0; + return status->getSize(); +} + +uint32_t FileSystem::GetPermissions(const FileSpec &file_spec) const { + return GetPermissions(file_spec.GetPath()); +} + +uint32_t FileSystem::GetPermissions(const FileSpec &file_spec, + std::error_code &ec) const { + return GetPermissions(file_spec.GetPath(), ec); +} + +uint32_t FileSystem::GetPermissions(const Twine &path) const { + std::error_code ec; + return GetPermissions(path, ec); +} + +uint32_t FileSystem::GetPermissions(const Twine &path, + std::error_code &ec) const { + ErrorOr status = m_fs->status(path); + if (!status) { + ec = status.getError(); + return sys::fs::perms::perms_not_known; + } + return status->getPermissions(); +} + +bool FileSystem::Exists(const Twine &path) const { return m_fs->exists(path); } + +bool FileSystem::Exists(const FileSpec &file_spec) const { + return Exists(file_spec.GetPath()); +} + +bool FileSystem::Readable(const Twine &path) const { + return GetPermissions(path) & sys::fs::perms::all_read; +} + +bool FileSystem::Readable(const FileSpec &file_spec) const { + return Readable(file_spec.GetPath()); +} + +bool FileSystem::IsDirectory(const Twine &path) const { + ErrorOr status = m_fs->status(path); + if (!status) + return false; + return status->isDirectory(); +} + +bool FileSystem::IsDirectory(const FileSpec &file_spec) const { + return IsDirectory(file_spec.GetPath()); +} + +bool FileSystem::IsLocal(const Twine &path) const { + bool b = false; + m_fs->isLocal(path, b); + return b; +} + +bool FileSystem::IsLocal(const FileSpec &file_spec) const { + return IsLocal(file_spec.GetPath()); +} + +void FileSystem::EnumerateDirectory(Twine path, bool find_directories, + bool find_files, bool find_other, + EnumerateDirectoryCallbackType callback, + void *callback_baton) { + std::error_code EC; + vfs::recursive_directory_iterator Iter(*m_fs, path, EC); + vfs::recursive_directory_iterator End; + for (; Iter != End && !EC; Iter.increment(EC)) { + const auto &Item = *Iter; + ErrorOr Status = m_fs->status(Item.path()); + if (!Status) + break; + if (!find_files && Status->isRegularFile()) + continue; + if (!find_directories && Status->isDirectory()) + continue; + if (!find_other && Status->isOther()) + continue; + + auto Result = callback(callback_baton, Status->getType(), Item.path()); + if (Result == eEnumerateDirectoryResultQuit) + return; + if (Result == eEnumerateDirectoryResultNext) { + // Default behavior is to recurse. Opt out if the callback doesn't want + // this behavior. + Iter.no_push(); + } + } +} + +std::error_code FileSystem::MakeAbsolute(SmallVectorImpl &path) const { + return m_fs->makeAbsolute(path); +} + +std::error_code FileSystem::MakeAbsolute(FileSpec &file_spec) const { + SmallString<128> path; + file_spec.GetPath(path, false); + + auto EC = MakeAbsolute(path); + if (EC) + return EC; + + FileSpec new_file_spec(path, file_spec.GetPathStyle()); + file_spec = new_file_spec; + return {}; +} + +std::error_code FileSystem::GetRealPath(const Twine &path, + SmallVectorImpl &output) const { + return m_fs->getRealPath(path, output); +} + +void FileSystem::Resolve(SmallVectorImpl &path) { + if (path.empty()) + return; + + // Resolve tilde. + SmallString<128> original_path(path.begin(), path.end()); + StandardTildeExpressionResolver Resolver; + Resolver.ResolveFullPath(original_path, path); + + // Try making the path absolute if it exists. + SmallString<128> absolute_path(path.begin(), path.end()); + MakeAbsolute(path); + if (!Exists(path)) { + path.clear(); + path.append(original_path.begin(), original_path.end()); + } +} + +void FileSystem::Resolve(FileSpec &file_spec) { + // Extract path from the FileSpec. + SmallString<128> path; + file_spec.GetPath(path); + + // Resolve the path. + Resolve(path); + + // Update the FileSpec with the resolved path. + file_spec.SetPath(path); + file_spec.SetIsResolved(true); +} + +std::shared_ptr +FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size, + uint64_t offset) { + if (m_collector) + m_collector->AddFile(path); + + const bool is_volatile = !IsLocal(path); + const ErrorOr external_path = GetExternalPath(path); + + if (!external_path) + return nullptr; + + std::unique_ptr buffer; + if (size == 0) { + auto buffer_or_error = + llvm::WritableMemoryBuffer::getFile(*external_path, -1, is_volatile); + if (!buffer_or_error) + return nullptr; + buffer = std::move(*buffer_or_error); + } else { + auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice( + *external_path, size, offset, is_volatile); + if (!buffer_or_error) + return nullptr; + buffer = std::move(*buffer_or_error); + } + return std::shared_ptr(new DataBufferLLVM(std::move(buffer))); +} + +std::shared_ptr +FileSystem::CreateDataBuffer(const FileSpec &file_spec, uint64_t size, + uint64_t offset) { + return CreateDataBuffer(file_spec.GetPath(), size, offset); +} + +bool FileSystem::ResolveExecutableLocation(FileSpec &file_spec) { + // If the directory is set there's nothing to do. + const ConstString &directory = file_spec.GetDirectory(); + if (directory) + return false; + + // We cannot look for a file if there's no file name. + const ConstString &filename = file_spec.GetFilename(); + if (!filename) + return false; + + // Search for the file on the host. + const std::string filename_str(filename.GetCString()); + llvm::ErrorOr error_or_path = + llvm::sys::findProgramByName(filename_str); + if (!error_or_path) + return false; + + // findProgramByName returns "." if it can't find the file. + llvm::StringRef path = *error_or_path; + llvm::StringRef parent = llvm::sys::path::parent_path(path); + if (parent.empty() || parent == ".") + return false; + + // Make sure that the result exists. + FileSpec result(*error_or_path); + if (!Exists(result)) + return false; + + file_spec = result; + return true; +} + +static int OpenWithFS(const FileSystem &fs, const char *path, int flags, + int mode) { + return const_cast(fs).Open(path, flags, mode); +} + +static int GetOpenFlags(uint32_t options) { + const bool read = options & File::eOpenOptionRead; + const bool write = options & File::eOpenOptionWrite; + + int open_flags = 0; + if (write) { + if (read) + open_flags |= O_RDWR; + else + open_flags |= O_WRONLY; + + if (options & File::eOpenOptionAppend) + open_flags |= O_APPEND; + + if (options & File::eOpenOptionTruncate) + open_flags |= O_TRUNC; + + if (options & File::eOpenOptionCanCreate) + open_flags |= O_CREAT; + + if (options & File::eOpenOptionCanCreateNewOnly) + open_flags |= O_CREAT | O_EXCL; + } else if (read) { + open_flags |= O_RDONLY; + +#ifndef _WIN32 + if (options & File::eOpenOptionDontFollowSymlinks) + open_flags |= O_NOFOLLOW; +#endif + } + +#ifndef _WIN32 + if (options & File::eOpenOptionNonBlocking) + open_flags |= O_NONBLOCK; + if (options & File::eOpenOptionCloseOnExec) + open_flags |= O_CLOEXEC; +#else + open_flags |= O_BINARY; +#endif + + return open_flags; +} + +static mode_t GetOpenMode(uint32_t permissions) { + mode_t mode = 0; + if (permissions & lldb::eFilePermissionsUserRead) + mode |= S_IRUSR; + if (permissions & lldb::eFilePermissionsUserWrite) + mode |= S_IWUSR; + if (permissions & lldb::eFilePermissionsUserExecute) + mode |= S_IXUSR; + if (permissions & lldb::eFilePermissionsGroupRead) + mode |= S_IRGRP; + if (permissions & lldb::eFilePermissionsGroupWrite) + mode |= S_IWGRP; + if (permissions & lldb::eFilePermissionsGroupExecute) + mode |= S_IXGRP; + if (permissions & lldb::eFilePermissionsWorldRead) + mode |= S_IROTH; + if (permissions & lldb::eFilePermissionsWorldWrite) + mode |= S_IWOTH; + if (permissions & lldb::eFilePermissionsWorldExecute) + mode |= S_IXOTH; + return mode; +} + +Status FileSystem::Open(File &File, const FileSpec &file_spec, uint32_t options, + uint32_t permissions) { + if (m_collector) + m_collector->AddFile(file_spec); + + if (File.IsValid()) + File.Close(); + + const int open_flags = GetOpenFlags(options); + const mode_t open_mode = + (open_flags & O_CREAT) ? GetOpenMode(permissions) : 0; + + auto path = GetExternalPath(file_spec); + if (!path) + return Status(path.getError()); + + int descriptor = llvm::sys::RetryAfterSignal( + -1, OpenWithFS, *this, path->c_str(), open_flags, open_mode); + + Status error; + if (!File::DescriptorIsValid(descriptor)) { + File.SetDescriptor(descriptor, false); + error.SetErrorToErrno(); + } else { + File.SetDescriptor(descriptor, true); + File.SetOptions(options); + } + return error; +} + +ErrorOr FileSystem::GetExternalPath(const llvm::Twine &path) { + if (!m_mapped) + return path.str(); + + // If VFS mapped we know the underlying FS is a RedirectingFileSystem. + ErrorOr E = + static_cast(*m_fs).lookupPath(path); + if (!E) { + if (E.getError() == llvm::errc::no_such_file_or_directory) { + return path.str(); + } + return E.getError(); + } + + auto *F = dyn_cast(*E); + if (!F) + return make_error_code(llvm::errc::not_supported); + + return F->getExternalContentsPath().str(); +} -llvm::sys::TimePoint<> -FileSystem::GetModificationTime(const FileSpec &file_spec) { - llvm::sys::fs::file_status status; - std::error_code ec = llvm::sys::fs::status(file_spec.GetPath(), status); - if (ec) - return llvm::sys::TimePoint<>(); - return status.getLastModificationTime(); +ErrorOr FileSystem::GetExternalPath(const FileSpec &file_spec) { + return GetExternalPath(file_spec.GetPath()); } diff --git a/source/Host/common/GetOptInc.cpp b/source/Host/common/GetOptInc.cpp index 1d9b31743736..c682d8b0cb4a 100644 --- a/source/Host/common/GetOptInc.cpp +++ b/source/Host/common/GetOptInc.cpp @@ -1,9 +1,8 @@ //===-- GetOptInc.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index d2848254779e..4e9b3ac2d403 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -1,9 +1,8 @@ //===-- Host.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -45,14 +44,13 @@ #include #endif -// C++ Includes #include +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/MonitoringProcessLauncher.h" -#include "lldb/Host/Predicate.h" #include "lldb/Host/ProcessLauncher.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" @@ -62,6 +60,7 @@ #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-forward.h" #include "llvm/ADT/SmallString.h" @@ -419,8 +418,10 @@ FileSpec Host::GetModuleFileSpecForHostAddress(const void *host_addr) { #if !defined(__ANDROID__) Dl_info info; if (::dladdr(host_addr, &info)) { - if (info.dli_fname) - module_filespec.SetFile(info.dli_fname, true, FileSpec::Style::native); + if (info.dli_fname) { + module_filespec.SetFile(info.dli_fname, FileSpec::Style::native); + FileSystem::Instance().Resolve(module_filespec); + } } #endif return module_filespec; @@ -494,7 +495,7 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, if (working_dir) launch_info.SetWorkingDirectory(working_dir); - llvm::SmallString output_file_path; + llvm::SmallString<64> output_file_path; if (command_output_ptr) { // Create a temporary file to get the stdout/stderr and redirect the output @@ -510,7 +511,7 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, } } - FileSpec output_file_spec{output_file_path.c_str(), false}; + FileSpec output_file_spec(output_file_path.c_str()); launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false); if (output_file_spec) { @@ -554,14 +555,15 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, if (command_output_ptr) { command_output_ptr->clear(); - uint64_t file_size = output_file_spec.GetByteSize(); + uint64_t file_size = + FileSystem::Instance().GetByteSize(output_file_spec); if (file_size > 0) { if (file_size > command_output_ptr->max_size()) { error.SetErrorStringWithFormat( "shell command output is too large to fit into a std::string"); } else { auto Buffer = - DataBufferLLVM::CreateFromPath(output_file_spec.GetPath()); + FileSystem::Instance().CreateDataBuffer(output_file_spec); if (error.Success()) command_output_ptr->assign(Buffer->GetChars(), Buffer->GetByteSize()); diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp index 958d3236f923..1a883b8cc796 100644 --- a/source/Host/common/HostInfoBase.cpp +++ b/source/Host/common/HostInfoBase.cpp @@ -1,9 +1,8 @@ //===-- HostInfoBase.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -42,7 +41,7 @@ namespace { struct HostInfoBaseFields { ~HostInfoBaseFields() { - if (m_lldb_process_tmp_dir.Exists()) { + if (FileSystem::Instance().Exists(m_lldb_process_tmp_dir)) { // Remove the LLDB temporary directory if we have one. Set "recurse" to // true to all files that were created for the LLDB process can be // cleaned up. @@ -239,7 +238,7 @@ bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) { // This is necessary because when running the testsuite the shlib might be a // symbolic link inside the Python resource dir. - FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec); + FileSystem::Instance().ResolveSymbolicLink(lldb_file_spec, lldb_file_spec); // Remove the filename so that this FileSpec only represents the directory. file_spec.GetDirectory() = lldb_file_spec.GetDirectory(); @@ -269,7 +268,8 @@ bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) { bool HostInfoBase::ComputeTempFileBaseDirectory(FileSpec &file_spec) { llvm::SmallVector tmpdir; llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, tmpdir); - file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size()), true); + file_spec = FileSpec(std::string(tmpdir.data(), tmpdir.size())); + FileSystem::Instance().Resolve(file_spec); return true; } diff --git a/source/Host/common/HostNativeThreadBase.cpp b/source/Host/common/HostNativeThreadBase.cpp index 402d3caacfcb..a5f876a7232a 100644 --- a/source/Host/common/HostNativeThreadBase.cpp +++ b/source/Host/common/HostNativeThreadBase.cpp @@ -1,9 +1,8 @@ //===-- HostNativeThreadBase.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -41,6 +40,10 @@ void HostNativeThreadBase::Reset() { m_result = 0; } +bool HostNativeThreadBase::EqualsThread(lldb::thread_t thread) const { + return m_thread == thread; +} + lldb::thread_t HostNativeThreadBase::Release() { lldb::thread_t result = m_thread; m_thread = LLDB_INVALID_HOST_THREAD; diff --git a/source/Host/common/HostProcess.cpp b/source/Host/common/HostProcess.cpp index 154033321514..d8f71af5e650 100644 --- a/source/Host/common/HostProcess.cpp +++ b/source/Host/common/HostProcess.cpp @@ -1,9 +1,8 @@ //===-- HostProcess.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/HostThread.cpp b/source/Host/common/HostThread.cpp index 02882c523908..89cadce5b206 100644 --- a/source/Host/common/HostThread.cpp +++ b/source/Host/common/HostThread.cpp @@ -1,9 +1,8 @@ //===-- HostThread.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -43,5 +42,5 @@ lldb::thread_result_t HostThread::GetResult() const { } bool HostThread::EqualsThread(lldb::thread_t thread) const { - return m_native_thread->GetSystemHandle() == thread; + return m_native_thread->EqualsThread(thread); } diff --git a/source/Host/common/LockFileBase.cpp b/source/Host/common/LockFileBase.cpp index a8d7881ab896..744b1eaabb4e 100644 --- a/source/Host/common/LockFileBase.cpp +++ b/source/Host/common/LockFileBase.cpp @@ -1,9 +1,8 @@ //===-- LockFileBase.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/MainLoop.cpp b/source/Host/common/MainLoop.cpp index 65158c942934..f594d0672aef 100644 --- a/source/Host/common/MainLoop.cpp +++ b/source/Host/common/MainLoop.cpp @@ -1,9 +1,8 @@ //===-- MainLoop.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -309,7 +308,7 @@ MainLoop::RegisterSignal(int signo, const Callback &callback, Status &error) { g_signal_flags[signo] = 0; // Even if using kqueue, the signal handler will still be invoked, so it's - // important to replace it with our "bening" handler. + // important to replace it with our "benign" handler. int ret = sigaction(signo, &new_action, &info.old_action); assert(ret == 0 && "sigaction failed"); @@ -321,7 +320,7 @@ MainLoop::RegisterSignal(int signo, const Callback &callback, Status &error) { #endif // If we're using kqueue, the signal needs to be unblocked in order to - // recieve it. If using pselect/ppoll, we need to block it, and later unblock + // receive it. If using pselect/ppoll, we need to block it, and later unblock // it as a part of the system call. ret = pthread_sigmask(HAVE_SYS_EVENT_H ? SIG_UNBLOCK : SIG_BLOCK, &new_action.sa_mask, &old_set); diff --git a/source/Host/common/MonitoringProcessLauncher.cpp b/source/Host/common/MonitoringProcessLauncher.cpp index 76c11454f573..285182a82cb2 100644 --- a/source/Host/common/MonitoringProcessLauncher.cpp +++ b/source/Host/common/MonitoringProcessLauncher.cpp @@ -1,17 +1,16 @@ //===-- MonitoringProcessLauncher.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/MonitoringProcessLauncher.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostProcess.h" #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Status.h" #include "llvm/Support/FileSystem.h" @@ -29,20 +28,16 @@ MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info, error.Clear(); + FileSystem &fs = FileSystem::Instance(); FileSpec exe_spec(resolved_info.GetExecutableFile()); - llvm::sys::fs::file_status stats; - status(exe_spec.GetPath(), stats); - if (!exists(stats)) { - exe_spec.ResolvePath(); - status(exe_spec.GetPath(), stats); - } - if (!exists(stats)) { - exe_spec.ResolveExecutableLocation(); - status(exe_spec.GetPath(), stats); - } + if (!fs.Exists(exe_spec)) + FileSystem::Instance().Resolve(exe_spec); + + if (!fs.Exists(exe_spec)) + FileSystem::Instance().ResolveExecutableLocation(exe_spec); - if (!exists(stats)) { + if (!fs.Exists(exe_spec)) { error.SetErrorStringWithFormatv("executable doesn't exist: '{0}'", exe_spec); return HostProcess(); diff --git a/source/Host/common/NativeBreakpoint.cpp b/source/Host/common/NativeBreakpoint.cpp deleted file mode 100644 index 5eee3de482c1..000000000000 --- a/source/Host/common/NativeBreakpoint.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//===-- NativeBreakpoint.cpp ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Host/common/NativeBreakpoint.h" - -#include "lldb/Utility/Log.h" -#include "lldb/Utility/Status.h" -#include "lldb/lldb-defines.h" - -using namespace lldb_private; - -NativeBreakpoint::NativeBreakpoint(lldb::addr_t addr) - : m_addr(addr), m_ref_count(1), m_enabled(true) { - assert(addr != LLDB_INVALID_ADDRESS && "breakpoint set for invalid address"); -} - -NativeBreakpoint::~NativeBreakpoint() {} - -void NativeBreakpoint::AddRef() { - ++m_ref_count; - - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 - " bumped up, new ref count %" PRIu32, - __FUNCTION__, m_addr, m_ref_count); -} - -int32_t NativeBreakpoint::DecRef() { - --m_ref_count; - - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 - " ref count decremented, new ref count %" PRIu32, - __FUNCTION__, m_addr, m_ref_count); - - return m_ref_count; -} - -Status NativeBreakpoint::Enable() { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - - if (m_enabled) { - // We're already enabled. Just log and exit. - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 - " already enabled, ignoring.", - __FUNCTION__, m_addr); - return Status(); - } - - // Log and enable. - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enabling...", - __FUNCTION__, m_addr); - - Status error = DoEnable(); - if (error.Success()) { - m_enabled = true; - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable SUCCESS.", - __FUNCTION__, m_addr); - } else { - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable FAIL: %s", - __FUNCTION__, m_addr, error.AsCString()); - } - - return error; -} - -Status NativeBreakpoint::Disable() { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - - if (!m_enabled) { - // We're already disabled. Just log and exit. - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 - " already disabled, ignoring.", - __FUNCTION__, m_addr); - return Status(); - } - - // Log and disable. - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disabling...", - __FUNCTION__, m_addr); - - Status error = DoDisable(); - if (error.Success()) { - m_enabled = false; - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable SUCCESS.", - __FUNCTION__, m_addr); - } else { - if (log) - log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable FAIL: %s", - __FUNCTION__, m_addr, error.AsCString()); - } - - return error; -} diff --git a/source/Host/common/NativeBreakpointList.cpp b/source/Host/common/NativeBreakpointList.cpp deleted file mode 100644 index cfcbe0831064..000000000000 --- a/source/Host/common/NativeBreakpointList.cpp +++ /dev/null @@ -1,229 +0,0 @@ -//===-- NativeBreakpointList.cpp --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Host/common/NativeBreakpointList.h" - -#include "lldb/Utility/Log.h" - -#include "lldb/Host/common/NativeBreakpoint.h" -#include "lldb/Host/common/SoftwareBreakpoint.h" - -using namespace lldb; -using namespace lldb_private; - -NativeBreakpointList::NativeBreakpointList() : m_mutex() {} - -Status NativeBreakpointList::AddRef(lldb::addr_t addr, size_t size_hint, - bool hardware, - CreateBreakpointFunc create_func) { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - ", size_hint = %zu, hardware = %s", - __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); - - std::lock_guard guard(m_mutex); - - // Check if the breakpoint is already set. - auto iter = m_breakpoints.find(addr); - if (iter != m_breakpoints.end()) { - // Yes - bump up ref count. - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- already enabled, upping ref count", - __FUNCTION__, addr); - - iter->second->AddRef(); - return Status(); - } - - // Create a new breakpoint using the given create func. - if (log) - log->Printf( - "NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64 - ", size_hint = %zu, hardware = %s", - __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); - - NativeBreakpointSP breakpoint_sp; - Status error = create_func(addr, size_hint, hardware, breakpoint_sp); - if (error.Fail()) { - if (log) - log->Printf( - "NativeBreakpointList::%s creating breakpoint for addr = 0x%" PRIx64 - ", size_hint = %zu, hardware = %s -- FAILED: %s", - __FUNCTION__, addr, size_hint, hardware ? "true" : "false", - error.AsCString()); - return error; - } - - // Remember the breakpoint. - assert(breakpoint_sp && "NativeBreakpoint create function succeeded but " - "returned NULL breakpoint"); - m_breakpoints.insert(BreakpointMap::value_type(addr, breakpoint_sp)); - - return error; -} - -Status NativeBreakpointList::DecRef(lldb::addr_t addr) { - Status error; - - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, - addr); - - std::lock_guard guard(m_mutex); - - // Check if the breakpoint is already set. - auto iter = m_breakpoints.find(addr); - if (iter == m_breakpoints.end()) { - // Not found! - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", - __FUNCTION__, addr); - error.SetErrorString("breakpoint not found"); - return error; - } - - // Decrement ref count. - const int32_t new_ref_count = iter->second->DecRef(); - assert(new_ref_count >= 0 && "NativeBreakpoint ref count went negative"); - - if (new_ref_count > 0) { - // Still references to this breakpoint. Leave it alone. - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- new breakpoint ref count %" PRIu32, - __FUNCTION__, addr, new_ref_count); - return error; - } - - // Breakpoint has no more references. Disable it if it's not already - // disabled. - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- removing due to no remaining references", - __FUNCTION__, addr); - - // If it's enabled, we need to disable it. - if (iter->second->IsEnabled()) { - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- currently enabled, now disabling", - __FUNCTION__, addr); - error = iter->second->Disable(); - if (error.Fail()) { - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- removal FAILED: %s", - __FUNCTION__, addr, error.AsCString()); - // Continue since we still want to take it out of the breakpoint list. - } - } else { - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- already disabled, nothing to do", - __FUNCTION__, addr); - } - - // Take the breakpoint out of the list. - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 - " -- removed from breakpoint map", - __FUNCTION__, addr); - - m_breakpoints.erase(iter); - return error; -} - -Status NativeBreakpointList::EnableBreakpoint(lldb::addr_t addr) { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, - addr); - - std::lock_guard guard(m_mutex); - - // Ensure we have said breakpoint. - auto iter = m_breakpoints.find(addr); - if (iter == m_breakpoints.end()) { - // Not found! - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", - __FUNCTION__, addr); - return Status("breakpoint not found"); - } - - // Enable it. - return iter->second->Enable(); -} - -Status NativeBreakpointList::DisableBreakpoint(lldb::addr_t addr) { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, - addr); - - std::lock_guard guard(m_mutex); - - // Ensure we have said breakpoint. - auto iter = m_breakpoints.find(addr); - if (iter == m_breakpoints.end()) { - // Not found! - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- NOT FOUND", - __FUNCTION__, addr); - return Status("breakpoint not found"); - } - - // Disable it. - return iter->second->Disable(); -} - -Status NativeBreakpointList::GetBreakpoint(lldb::addr_t addr, - NativeBreakpointSP &breakpoint_sp) { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, - addr); - - std::lock_guard guard(m_mutex); - - // Ensure we have said breakpoint. - auto iter = m_breakpoints.find(addr); - if (iter == m_breakpoints.end()) { - // Not found! - breakpoint_sp.reset(); - return Status("breakpoint not found"); - } - - // Disable it. - breakpoint_sp = iter->second; - return Status(); -} - -Status NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, - size_t size) const { - for (const auto &map : m_breakpoints) { - lldb::addr_t bp_addr = map.first; - // Breapoint not in range, ignore - if (bp_addr < addr || addr + size <= bp_addr) - continue; - const auto &bp_sp = map.second; - // Not software breakpoint, ignore - if (!bp_sp->IsSoftwareBreakpoint()) - continue; - auto software_bp_sp = std::static_pointer_cast(bp_sp); - auto opcode_addr = static_cast(buf) + bp_addr - addr; - auto saved_opcodes = software_bp_sp->m_saved_opcodes; - auto opcode_size = software_bp_sp->m_opcode_size; - ::memcpy(opcode_addr, saved_opcodes, opcode_size); - } - return Status(); -} diff --git a/source/Host/common/NativeProcessProtocol.cpp b/source/Host/common/NativeProcessProtocol.cpp index 3e8648f81473..ac460d549e44 100644 --- a/source/Host/common/NativeProcessProtocol.cpp +++ b/source/Host/common/NativeProcessProtocol.cpp @@ -1,20 +1,19 @@ //===-- NativeProcessProtocol.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/common/NativeProcessProtocol.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" +#include "lldb/Host/common/NativeBreakpointList.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/common/NativeThreadProtocol.h" -#include "lldb/Host/common/SoftwareBreakpoint.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" using namespace lldb; @@ -359,17 +358,271 @@ void NativeProcessProtocol::NotifyDidExec() { Status NativeProcessProtocol::SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("NativeProcessProtocol::%s addr = 0x%" PRIx64, __FUNCTION__, - addr); + LLDB_LOG(log, "addr = {0:x}, size_hint = {1}", addr, size_hint); + + auto it = m_software_breakpoints.find(addr); + if (it != m_software_breakpoints.end()) { + ++it->second.ref_count; + return Status(); + } + auto expected_bkpt = EnableSoftwareBreakpoint(addr, size_hint); + if (!expected_bkpt) + return Status(expected_bkpt.takeError()); + + m_software_breakpoints.emplace(addr, std::move(*expected_bkpt)); + return Status(); +} + +Status NativeProcessProtocol::RemoveSoftwareBreakpoint(lldb::addr_t addr) { + Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); + LLDB_LOG(log, "addr = {0:x}", addr); + auto it = m_software_breakpoints.find(addr); + if (it == m_software_breakpoints.end()) + return Status("Breakpoint not found."); + assert(it->second.ref_count > 0); + if (--it->second.ref_count > 0) + return Status(); + + // This is the last reference. Let's remove the breakpoint. + Status error; + + // Clear a software breakpoint instruction + llvm::SmallVector curr_break_op( + it->second.breakpoint_opcodes.size(), 0); + + // Read the breakpoint opcode + size_t bytes_read = 0; + error = + ReadMemory(addr, curr_break_op.data(), curr_break_op.size(), bytes_read); + if (error.Fail() || bytes_read < curr_break_op.size()) { + return Status("addr=0x%" PRIx64 + ": tried to read %zu bytes but only read %zu", + addr, curr_break_op.size(), bytes_read); + } + const auto &saved = it->second.saved_opcodes; + // Make sure the breakpoint opcode exists at this address + if (makeArrayRef(curr_break_op) != it->second.breakpoint_opcodes) { + if (curr_break_op != it->second.saved_opcodes) + return Status("Original breakpoint trap is no longer in memory."); + LLDB_LOG(log, + "Saved opcodes ({0:@[x]}) have already been restored at {1:x}.", + llvm::make_range(saved.begin(), saved.end()), addr); + } else { + // We found a valid breakpoint opcode at this address, now restore the + // saved opcode. + size_t bytes_written = 0; + error = WriteMemory(addr, saved.data(), saved.size(), bytes_written); + if (error.Fail() || bytes_written < saved.size()) { + return Status("addr=0x%" PRIx64 + ": tried to write %zu bytes but only wrote %zu", + addr, saved.size(), bytes_written); + } + + // Verify that our original opcode made it back to the inferior + llvm::SmallVector verify_opcode(saved.size(), 0); + size_t verify_bytes_read = 0; + error = ReadMemory(addr, verify_opcode.data(), verify_opcode.size(), + verify_bytes_read); + if (error.Fail() || verify_bytes_read < verify_opcode.size()) { + return Status("addr=0x%" PRIx64 + ": tried to read %zu verification bytes but only read %zu", + addr, verify_opcode.size(), verify_bytes_read); + } + if (verify_opcode != saved) + LLDB_LOG(log, "Restoring bytes at {0:x}: {1:@[x]}", addr, + llvm::make_range(saved.begin(), saved.end())); + } - return m_breakpoint_list.AddRef( - addr, size_hint, false, - [this](lldb::addr_t addr, size_t size_hint, bool /* hardware */, - NativeBreakpointSP &breakpoint_sp) -> Status { - return SoftwareBreakpoint::CreateSoftwareBreakpoint( - *this, addr, size_hint, breakpoint_sp); - }); + m_software_breakpoints.erase(it); + return Status(); +} + +llvm::Expected +NativeProcessProtocol::EnableSoftwareBreakpoint(lldb::addr_t addr, + uint32_t size_hint) { + Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); + + auto expected_trap = GetSoftwareBreakpointTrapOpcode(size_hint); + if (!expected_trap) + return expected_trap.takeError(); + + llvm::SmallVector saved_opcode_bytes(expected_trap->size(), 0); + // Save the original opcodes by reading them so we can restore later. + size_t bytes_read = 0; + Status error = ReadMemory(addr, saved_opcode_bytes.data(), + saved_opcode_bytes.size(), bytes_read); + if (error.Fail()) + return error.ToError(); + + // Ensure we read as many bytes as we expected. + if (bytes_read != saved_opcode_bytes.size()) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Failed to read memory while attempting to set breakpoint: attempted " + "to read {0} bytes but only read {1}.", + saved_opcode_bytes.size(), bytes_read); + } + + LLDB_LOG( + log, "Overwriting bytes at {0:x}: {1:@[x]}", addr, + llvm::make_range(saved_opcode_bytes.begin(), saved_opcode_bytes.end())); + + // Write a software breakpoint in place of the original opcode. + size_t bytes_written = 0; + error = WriteMemory(addr, expected_trap->data(), expected_trap->size(), + bytes_written); + if (error.Fail()) + return error.ToError(); + + // Ensure we wrote as many bytes as we expected. + if (bytes_written != expected_trap->size()) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Failed write memory while attempting to set " + "breakpoint: attempted to write {0} bytes but only wrote {1}", + expected_trap->size(), bytes_written); + } + + llvm::SmallVector verify_bp_opcode_bytes(expected_trap->size(), + 0); + size_t verify_bytes_read = 0; + error = ReadMemory(addr, verify_bp_opcode_bytes.data(), + verify_bp_opcode_bytes.size(), verify_bytes_read); + if (error.Fail()) + return error.ToError(); + + // Ensure we read as many verification bytes as we expected. + if (verify_bytes_read != verify_bp_opcode_bytes.size()) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Failed to read memory while " + "attempting to verify breakpoint: attempted to read {0} bytes " + "but only read {1}", + verify_bp_opcode_bytes.size(), verify_bytes_read); + } + + if (llvm::makeArrayRef(verify_bp_opcode_bytes.data(), verify_bytes_read) != + *expected_trap) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Verification of software breakpoint " + "writing failed - trap opcodes not successfully read back " + "after writing when setting breakpoint at {0:x}", + addr); + } + + LLDB_LOG(log, "addr = {0:x}: SUCCESS", addr); + return SoftwareBreakpoint{1, saved_opcode_bytes, *expected_trap}; +} + +llvm::Expected> +NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode(size_t size_hint) { + static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x20, 0xd4}; + static const uint8_t g_i386_opcode[] = {0xCC}; + static const uint8_t g_mips64_opcode[] = {0x00, 0x00, 0x00, 0x0d}; + static const uint8_t g_mips64el_opcode[] = {0x0d, 0x00, 0x00, 0x00}; + static const uint8_t g_s390x_opcode[] = {0x00, 0x01}; + static const uint8_t g_ppc64le_opcode[] = {0x08, 0x00, 0xe0, 0x7f}; // trap + + switch (GetArchitecture().GetMachine()) { + case llvm::Triple::aarch64: + return llvm::makeArrayRef(g_aarch64_opcode); + + case llvm::Triple::x86: + case llvm::Triple::x86_64: + return llvm::makeArrayRef(g_i386_opcode); + + case llvm::Triple::mips: + case llvm::Triple::mips64: + return llvm::makeArrayRef(g_mips64_opcode); + + case llvm::Triple::mipsel: + case llvm::Triple::mips64el: + return llvm::makeArrayRef(g_mips64el_opcode); + + case llvm::Triple::systemz: + return llvm::makeArrayRef(g_s390x_opcode); + + case llvm::Triple::ppc64le: + return llvm::makeArrayRef(g_ppc64le_opcode); + + default: + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "CPU type not supported!"); + } +} + +size_t NativeProcessProtocol::GetSoftwareBreakpointPCOffset() { + switch (GetArchitecture().GetMachine()) { + case llvm::Triple::x86: + case llvm::Triple::x86_64: + case llvm::Triple::systemz: + // These architectures report increment the PC after breakpoint is hit. + return cantFail(GetSoftwareBreakpointTrapOpcode(0)).size(); + + case llvm::Triple::arm: + case llvm::Triple::aarch64: + case llvm::Triple::mips64: + case llvm::Triple::mips64el: + case llvm::Triple::mips: + case llvm::Triple::mipsel: + case llvm::Triple::ppc64le: + // On these architectures the PC doesn't get updated for breakpoint hits. + return 0; + + default: + llvm_unreachable("CPU type not supported!"); + } +} + +void NativeProcessProtocol::FixupBreakpointPCAsNeeded( + NativeThreadProtocol &thread) { + Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS); + + Status error; + + // Find out the size of a breakpoint (might depend on where we are in the + // code). + NativeRegisterContext &context = thread.GetRegisterContext(); + + uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset(); + LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size); + if (breakpoint_size == 0) + return; + + // First try probing for a breakpoint at a software breakpoint location: PC - + // breakpoint size. + const lldb::addr_t initial_pc_addr = context.GetPCfromBreakpointLocation(); + lldb::addr_t breakpoint_addr = initial_pc_addr; + // Do not allow breakpoint probe to wrap around. + if (breakpoint_addr >= breakpoint_size) + breakpoint_addr -= breakpoint_size; + + if (m_software_breakpoints.count(breakpoint_addr) == 0) { + // We didn't find one at a software probe location. Nothing to do. + LLDB_LOG(log, + "pid {0} no lldb software breakpoint found at current pc with " + "adjustment: {1}", + GetID(), breakpoint_addr); + return; + } + + // + // We have a software breakpoint and need to adjust the PC. + // + + // Change the program counter. + LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(), + thread.GetID(), initial_pc_addr, breakpoint_addr); + + error = context.SetPC(breakpoint_addr); + if (error.Fail()) { + // This can happen in case the process was killed between the time we read + // the PC and when we are updating it. There's nothing better to do than to + // swallow the error. + LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(), + thread.GetID(), error); + } } Status NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr, @@ -377,15 +630,35 @@ Status NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr, if (hardware) return RemoveHardwareBreakpoint(addr); else - return m_breakpoint_list.DecRef(addr); -} - -Status NativeProcessProtocol::EnableBreakpoint(lldb::addr_t addr) { - return m_breakpoint_list.EnableBreakpoint(addr); + return RemoveSoftwareBreakpoint(addr); } -Status NativeProcessProtocol::DisableBreakpoint(lldb::addr_t addr) { - return m_breakpoint_list.DisableBreakpoint(addr); +Status NativeProcessProtocol::ReadMemoryWithoutTrap(lldb::addr_t addr, + void *buf, size_t size, + size_t &bytes_read) { + Status error = ReadMemory(addr, buf, size, bytes_read); + if (error.Fail()) + return error; + + auto data = + llvm::makeMutableArrayRef(static_cast(buf), bytes_read); + for (const auto &pair : m_software_breakpoints) { + lldb::addr_t bp_addr = pair.first; + auto saved_opcodes = makeArrayRef(pair.second.saved_opcodes); + + if (bp_addr + saved_opcodes.size() < addr || addr + bytes_read <= bp_addr) + continue; // Breapoint not in range, ignore + + if (bp_addr < addr) { + saved_opcodes = saved_opcodes.drop_front(addr - bp_addr); + bp_addr = addr; + } + auto bp_data = data.drop_front(bp_addr - addr); + std::copy_n(saved_opcodes.begin(), + std::min(saved_opcodes.size(), bp_data.size()), + bp_data.begin()); + } + return Status(); } lldb::StateType NativeProcessProtocol::GetState() const { diff --git a/source/Host/common/NativeRegisterContext.cpp b/source/Host/common/NativeRegisterContext.cpp index 49b8284da970..5b5d717c07ef 100644 --- a/source/Host/common/NativeRegisterContext.cpp +++ b/source/Host/common/NativeRegisterContext.cpp @@ -1,16 +1,15 @@ //===-- NativeRegisterContext.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/common/NativeRegisterContext.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Host/PosixApi.h" #include "lldb/Host/common/NativeProcessProtocol.h" diff --git a/source/Host/common/NativeThreadProtocol.cpp b/source/Host/common/NativeThreadProtocol.cpp index 0c648e40eb5c..e62b1425c891 100644 --- a/source/Host/common/NativeThreadProtocol.cpp +++ b/source/Host/common/NativeThreadProtocol.cpp @@ -1,9 +1,8 @@ //===-- NativeThreadProtocol.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,7 +10,6 @@ #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeRegisterContext.h" -#include "lldb/Host/common/SoftwareBreakpoint.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Host/common/NativeWatchpointList.cpp b/source/Host/common/NativeWatchpointList.cpp index e6ef7300eb22..c3db95fb252e 100644 --- a/source/Host/common/NativeWatchpointList.cpp +++ b/source/Host/common/NativeWatchpointList.cpp @@ -1,9 +1,8 @@ //===-- NativeWatchpointList.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/OptionParser.cpp b/source/Host/common/OptionParser.cpp index d78bf335b408..97704988d36a 100644 --- a/source/Host/common/OptionParser.cpp +++ b/source/Host/common/OptionParser.cpp @@ -1,9 +1,8 @@ //===-- source/Host/common/OptionParser.cpp ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/PipeBase.cpp b/source/Host/common/PipeBase.cpp index 632bfcb3a2e0..2cbadf0c85f6 100644 --- a/source/Host/common/PipeBase.cpp +++ b/source/Host/common/PipeBase.cpp @@ -1,9 +1,8 @@ //===-- source/Host/common/PipeBase.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/ProcessRunLock.cpp b/source/Host/common/ProcessRunLock.cpp index 48dcd62bb939..78366233f7b5 100644 --- a/source/Host/common/ProcessRunLock.cpp +++ b/source/Host/common/ProcessRunLock.cpp @@ -1,9 +1,8 @@ //===-- ProcessRunLock.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -30,7 +29,7 @@ ProcessRunLock::~ProcessRunLock() { bool ProcessRunLock::ReadTryLock() { ::pthread_rwlock_rdlock(&m_rwlock); - if (m_running == false) { + if (!m_running) { return true; } ::pthread_rwlock_unlock(&m_rwlock); diff --git a/source/Host/common/PseudoTerminal.cpp b/source/Host/common/PseudoTerminal.cpp index c9b290078e18..19c7ba9fd25e 100644 --- a/source/Host/common/PseudoTerminal.cpp +++ b/source/Host/common/PseudoTerminal.cpp @@ -1,16 +1,16 @@ //===-- PseudoTerminal.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/PseudoTerminal.h" #include "lldb/Host/Config.h" -#include +#include "llvm/Support/Errno.h" + #include #include #include @@ -26,6 +26,14 @@ int posix_openpt(int flags); using namespace lldb_private; +//---------------------------------------------------------------------- +// Write string describing error number +//---------------------------------------------------------------------- +static void ErrnoToStr(char *error_str, size_t error_len) { + std::string strerror = llvm::sys::StrError(); + ::snprintf(error_str, error_len, "%s", strerror.c_str()); +} + //---------------------------------------------------------------------- // PseudoTerminal constructor //---------------------------------------------------------------------- @@ -88,14 +96,14 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str, m_master_fd = ::posix_openpt(oflag); if (m_master_fd < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); return false; } // Grant access to the slave pseudo terminal if (::grantpt(m_master_fd) < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); CloseMasterFileDescriptor(); return false; } @@ -103,7 +111,7 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str, // Clear the lock flag on the slave pseudo terminal if (::unlockpt(m_master_fd) < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); CloseMasterFileDescriptor(); return false; } @@ -143,7 +151,7 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) { if (m_slave_fd < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); return false; } @@ -175,7 +183,7 @@ const char *PseudoTerminal::GetSlaveName(char *error_str, const char *slave_name = ::ptsname(m_master_fd); if (error_str && slave_name == nullptr) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); return slave_name; } @@ -213,7 +221,7 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) { if (pid < 0) { // Fork failed if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); } else if (pid == 0) { // Child Process ::setsid(); @@ -229,23 +237,23 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) { // Acquire the controlling terminal if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); } #endif // Duplicate all stdio file descriptors to the slave pseudo terminal if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) { if (error_str && !error_str[0]) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); } if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) { if (error_str && !error_str[0]) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); } if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) { if (error_str && !error_str[0]) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); } } } else { diff --git a/source/Host/common/Socket.cpp b/source/Host/common/Socket.cpp index 875291bc115f..5a3b0c1e5daa 100644 --- a/source/Host/common/Socket.cpp +++ b/source/Host/common/Socket.cpp @@ -1,9 +1,8 @@ //===-- Socket.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/SocketAddress.cpp b/source/Host/common/SocketAddress.cpp index def3e0359f01..0868c34972d4 100644 --- a/source/Host/common/SocketAddress.cpp +++ b/source/Host/common/SocketAddress.cpp @@ -1,9 +1,8 @@ //===-- SocketAddress.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -21,7 +20,6 @@ #include #include -// C Includes #if !defined(_WIN32) #include #endif @@ -29,9 +27,6 @@ #include #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/PosixApi.h" // WindowsXP needs an inet_ntop implementation diff --git a/source/Host/common/SoftwareBreakpoint.cpp b/source/Host/common/SoftwareBreakpoint.cpp deleted file mode 100644 index 353dadf6ce6d..000000000000 --- a/source/Host/common/SoftwareBreakpoint.cpp +++ /dev/null @@ -1,350 +0,0 @@ -//===-- SoftwareBreakpoint.cpp ----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Host/common/SoftwareBreakpoint.h" - -#include "lldb/Host/Debug.h" -#include "lldb/Utility/Log.h" -#include "lldb/Utility/Status.h" - -#include "lldb/Host/common/NativeProcessProtocol.h" - -using namespace lldb_private; - -// ------------------------------------------------------------------- static -// members ------------------------------------------------------------------- - -Status SoftwareBreakpoint::CreateSoftwareBreakpoint( - NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint, - NativeBreakpointSP &breakpoint_sp) { - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr); - - // Validate the address. - if (addr == LLDB_INVALID_ADDRESS) - return Status("SoftwareBreakpoint::%s invalid load address specified.", - __FUNCTION__); - - // Ask the NativeProcessProtocol subclass to fill in the correct software - // breakpoint trap for the breakpoint site. - size_t bp_opcode_size = 0; - const uint8_t *bp_opcode_bytes = NULL; - Status error = process.GetSoftwareBreakpointTrapOpcode( - size_hint, bp_opcode_size, bp_opcode_bytes); - - if (error.Fail()) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to retrieve software " - "breakpoint trap opcode: %s", - __FUNCTION__, error.AsCString()); - return error; - } - - // Validate size of trap opcode. - if (bp_opcode_size == 0) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to retrieve any trap opcodes", - __FUNCTION__); - return Status("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned zero, unable to get breakpoint trap for address " - "0x%" PRIx64, - addr); - } - - if (bp_opcode_size > MAX_TRAP_OPCODE_SIZE) { - if (log) - log->Printf("SoftwareBreakpoint::%s cannot support %zu trapcode bytes, " - "max size is %zu", - __FUNCTION__, bp_opcode_size, MAX_TRAP_OPCODE_SIZE); - return Status("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned too many trap opcode bytes: requires %zu but we " - "only support a max of %zu", - bp_opcode_size, MAX_TRAP_OPCODE_SIZE); - } - - // Validate that we received opcodes. - if (!bp_opcode_bytes) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to retrieve trap opcode bytes", - __FUNCTION__); - return Status("SoftwareBreakpoint::GetSoftwareBreakpointTrapOpcode() " - "returned NULL trap opcode bytes, unable to get breakpoint " - "trap for address 0x%" PRIx64, - addr); - } - - // Enable the breakpoint. - uint8_t saved_opcode_bytes[MAX_TRAP_OPCODE_SIZE]; - error = EnableSoftwareBreakpoint(process, addr, bp_opcode_size, - bp_opcode_bytes, saved_opcode_bytes); - if (error.Fail()) { - if (log) - log->Printf("SoftwareBreakpoint::%s: failed to enable new breakpoint at " - "0x%" PRIx64 ": %s", - __FUNCTION__, addr, error.AsCString()); - return error; - } - - if (log) - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", - __FUNCTION__, addr); - - // Set the breakpoint and verified it was written properly. Now create a - // breakpoint remover that understands how to undo this breakpoint. - breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes, - bp_opcode_bytes, bp_opcode_size)); - return Status(); -} - -Status SoftwareBreakpoint::EnableSoftwareBreakpoint( - NativeProcessProtocol &process, lldb::addr_t addr, size_t bp_opcode_size, - const uint8_t *bp_opcode_bytes, uint8_t *saved_opcode_bytes) { - assert(bp_opcode_size <= MAX_TRAP_OPCODE_SIZE && - "bp_opcode_size out of valid range"); - assert(bp_opcode_bytes && "bp_opcode_bytes is NULL"); - assert(saved_opcode_bytes && "saved_opcode_bytes is NULL"); - - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr); - - // Save the original opcodes by reading them so we can restore later. - size_t bytes_read = 0; - - Status error = - process.ReadMemory(addr, saved_opcode_bytes, bp_opcode_size, bytes_read); - if (error.Fail()) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to read memory while " - "attempting to set breakpoint: %s", - __FUNCTION__, error.AsCString()); - return error; - } - - // Ensure we read as many bytes as we expected. - if (bytes_read != bp_opcode_size) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to read memory while " - "attempting to set breakpoint: attempted to read %zu bytes " - "but only read %zu", - __FUNCTION__, bp_opcode_size, bytes_read); - return Status("SoftwareBreakpoint::%s failed to read memory while " - "attempting to set breakpoint: attempted to read %zu bytes " - "but only read %zu", - __FUNCTION__, bp_opcode_size, bytes_read); - } - - // Log what we read. - if (log) { - int i = 0; - for (const uint8_t *read_byte = saved_opcode_bytes; - read_byte < saved_opcode_bytes + bp_opcode_size; ++read_byte) { - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 - " ovewriting byte index %d (was 0x%hhx)", - __FUNCTION__, addr, i++, *read_byte); - } - } - - // Write a software breakpoint in place of the original opcode. - size_t bytes_written = 0; - error = - process.WriteMemory(addr, bp_opcode_bytes, bp_opcode_size, bytes_written); - if (error.Fail()) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to write memory while " - "attempting to set breakpoint: %s", - __FUNCTION__, error.AsCString()); - return error; - } - - // Ensure we wrote as many bytes as we expected. - if (bytes_written != bp_opcode_size) { - error.SetErrorStringWithFormat( - "SoftwareBreakpoint::%s failed write memory while attempting to set " - "breakpoint: attempted to write %zu bytes but only wrote %zu", - __FUNCTION__, bp_opcode_size, bytes_written); - if (log) - log->PutCString(error.AsCString()); - return error; - } - - uint8_t verify_bp_opcode_bytes[MAX_TRAP_OPCODE_SIZE]; - size_t verify_bytes_read = 0; - error = process.ReadMemory(addr, verify_bp_opcode_bytes, bp_opcode_size, - verify_bytes_read); - if (error.Fail()) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to read memory while " - "attempting to verify the breakpoint set: %s", - __FUNCTION__, error.AsCString()); - return error; - } - - // Ensure we read as many verification bytes as we expected. - if (verify_bytes_read != bp_opcode_size) { - if (log) - log->Printf("SoftwareBreakpoint::%s failed to read memory while " - "attempting to verify breakpoint: attempted to read %zu " - "bytes but only read %zu", - __FUNCTION__, bp_opcode_size, verify_bytes_read); - return Status( - "SoftwareBreakpoint::%s failed to read memory while " - "attempting to verify breakpoint: attempted to read %zu bytes " - "but only read %zu", - __FUNCTION__, bp_opcode_size, verify_bytes_read); - } - - if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes, bp_opcode_size) != 0) { - if (log) - log->Printf("SoftwareBreakpoint::%s: verification of software breakpoint " - "writing failed - trap opcodes not successfully read back " - "after writing when setting breakpoint at 0x%" PRIx64, - __FUNCTION__, addr); - return Status("SoftwareBreakpoint::%s: verification of software breakpoint " - "writing failed - trap opcodes not successfully read back " - "after writing when setting breakpoint at 0x%" PRIx64, - __FUNCTION__, addr); - } - - if (log) - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", - __FUNCTION__, addr); - - return Status(); -} - -// ------------------------------------------------------------------- -// instance-level members -// ------------------------------------------------------------------- - -SoftwareBreakpoint::SoftwareBreakpoint(NativeProcessProtocol &process, - lldb::addr_t addr, - const uint8_t *saved_opcodes, - const uint8_t *trap_opcodes, - size_t opcode_size) - : NativeBreakpoint(addr), m_process(process), m_saved_opcodes(), - m_trap_opcodes(), m_opcode_size(opcode_size) { - assert(opcode_size > 0 && "setting software breakpoint with no trap opcodes"); - assert(opcode_size <= MAX_TRAP_OPCODE_SIZE && "trap opcode size too large"); - - ::memcpy(m_saved_opcodes, saved_opcodes, opcode_size); - ::memcpy(m_trap_opcodes, trap_opcodes, opcode_size); -} - -Status SoftwareBreakpoint::DoEnable() { - return EnableSoftwareBreakpoint(m_process, m_addr, m_opcode_size, - m_trap_opcodes, m_saved_opcodes); -} - -Status SoftwareBreakpoint::DoDisable() { - Status error; - assert(m_addr && (m_addr != LLDB_INVALID_ADDRESS) && - "can't remove a software breakpoint for an invalid address"); - - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, - m_addr); - - assert((m_opcode_size > 0) && - "cannot restore opcodes when there are no opcodes"); - - if (m_opcode_size > 0) { - // Clear a software breakpoint instruction - uint8_t curr_break_op[MAX_TRAP_OPCODE_SIZE]; - bool break_op_found = false; - assert(m_opcode_size <= sizeof(curr_break_op)); - - // Read the breakpoint opcode - size_t bytes_read = 0; - error = - m_process.ReadMemory(m_addr, curr_break_op, m_opcode_size, bytes_read); - if (error.Success() && bytes_read < m_opcode_size) { - error.SetErrorStringWithFormat( - "SoftwareBreakpointr::%s addr=0x%" PRIx64 - ": tried to read %zu bytes but only read %zu", - __FUNCTION__, m_addr, m_opcode_size, bytes_read); - } - if (error.Success()) { - bool verify = false; - // Make sure the breakpoint opcode exists at this address - if (::memcmp(curr_break_op, m_trap_opcodes, m_opcode_size) == 0) { - break_op_found = true; - // We found a valid breakpoint opcode at this address, now restore the - // saved opcode. - size_t bytes_written = 0; - error = m_process.WriteMemory(m_addr, m_saved_opcodes, m_opcode_size, - bytes_written); - if (error.Success() && bytes_written < m_opcode_size) { - error.SetErrorStringWithFormat( - "SoftwareBreakpoint::%s addr=0x%" PRIx64 - ": tried to write %zu bytes but only wrote %zu", - __FUNCTION__, m_addr, m_opcode_size, bytes_written); - } - if (error.Success()) { - verify = true; - } - } else { - error.SetErrorString( - "Original breakpoint trap is no longer in memory."); - // Set verify to true and so we can check if the original opcode has - // already been restored - verify = true; - } - - if (verify) { - uint8_t verify_opcode[MAX_TRAP_OPCODE_SIZE]; - assert(m_opcode_size <= sizeof(verify_opcode)); - // Verify that our original opcode made it back to the inferior - - size_t verify_bytes_read = 0; - error = m_process.ReadMemory(m_addr, verify_opcode, m_opcode_size, - verify_bytes_read); - if (error.Success() && verify_bytes_read < m_opcode_size) { - error.SetErrorStringWithFormat( - "SoftwareBreakpoint::%s addr=0x%" PRIx64 - ": tried to read %zu verification bytes but only read %zu", - __FUNCTION__, m_addr, m_opcode_size, verify_bytes_read); - } - if (error.Success()) { - // compare the memory we just read with the original opcode - if (::memcmp(m_saved_opcodes, verify_opcode, m_opcode_size) == 0) { - // SUCCESS - if (log) { - int i = 0; - for (const uint8_t *verify_byte = verify_opcode; - verify_byte < verify_opcode + m_opcode_size; ++verify_byte) { - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 - " replaced byte index %d with 0x%hhx", - __FUNCTION__, m_addr, i++, *verify_byte); - } - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 - " -- SUCCESS", - __FUNCTION__, m_addr); - } - return error; - } else { - if (break_op_found) - error.SetErrorString("Failed to restore original opcode."); - } - } else - error.SetErrorString("Failed to read memory to verify that " - "breakpoint trap was restored."); - } - } - } - - if (log && error.Fail()) - log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- FAILED: %s", - __FUNCTION__, m_addr, error.AsCString()); - return error; -} - -bool SoftwareBreakpoint::IsSoftwareBreakpoint() const { return true; } diff --git a/source/Host/common/StringConvert.cpp b/source/Host/common/StringConvert.cpp index b4171437b7e2..8bf04f0a9ca3 100644 --- a/source/Host/common/StringConvert.cpp +++ b/source/Host/common/StringConvert.cpp @@ -1,18 +1,13 @@ //===-- StringConvert.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/StringConvert.h" namespace lldb_private { diff --git a/source/Host/common/Symbols.cpp b/source/Host/common/Symbols.cpp index 6429f7b2a3d3..3ea112abb703 100644 --- a/source/Host/common/Symbols.cpp +++ b/source/Host/common/Symbols.cpp @@ -1,9 +1,8 @@ //===-- Symbols.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,7 +15,6 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" @@ -29,7 +27,6 @@ typedef int cpu_subtype_t; using namespace lldb; using namespace lldb_private; -using namespace llvm::MachO; #if defined(__APPLE__) @@ -87,17 +84,16 @@ static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec, dsym_directory.AppendPathComponent("Contents"); dsym_directory.AppendPathComponent("Resources"); dsym_directory.AppendPathComponent("DWARF"); - - if (dsym_directory.Exists()) { + + if (FileSystem::Instance().Exists(dsym_directory)) { // See if the binary name exists in the dSYM DWARF // subdir. dsym_fspec = dsym_directory; dsym_fspec.AppendPathComponent(filename.AsCString()); - if (dsym_fspec.Exists() - && FileAtPathContainsArchAndUUID(dsym_fspec, - mod_spec.GetArchitecturePtr(), - mod_spec.GetUUIDPtr())) { + if (FileSystem::Instance().Exists(dsym_fspec) && + FileAtPathContainsArchAndUUID(dsym_fspec, mod_spec.GetArchitecturePtr(), + mod_spec.GetUUIDPtr())) { return true; } @@ -111,15 +107,15 @@ static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec, binary_name.erase(last_dot); dsym_fspec = dsym_directory; dsym_fspec.AppendPathComponent(binary_name); - if (dsym_fspec.Exists() - && FileAtPathContainsArchAndUUID(dsym_fspec, - mod_spec.GetArchitecturePtr(), - mod_spec.GetUUIDPtr())) { + if (FileSystem::Instance().Exists(dsym_fspec) && + FileAtPathContainsArchAndUUID(dsym_fspec, + mod_spec.GetArchitecturePtr(), + mod_spec.GetUUIDPtr())) { return true; } } - } - + } + // See if we have a .dSYM.yaa next to this executable path. FileSpec dsym_yaa_fspec = exec_fspec; dsym_yaa_fspec.RemoveLastPathComponent(); @@ -127,10 +123,10 @@ static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec, dsym_yaa_filename += ".dSYM.yaa"; dsym_yaa_fspec.AppendPathComponent(dsym_yaa_filename); - if (dsym_yaa_fspec.Exists()) { + if (FileSystem::Instance().Exists(dsym_yaa_fspec)) { ModuleSpec mutable_mod_spec = mod_spec; - if (Symbols::DownloadObjectAndSymbolFile (mutable_mod_spec, true) - && mutable_mod_spec.GetSymbolFileSpec().Exists()) { + if (Symbols::DownloadObjectAndSymbolFile(mutable_mod_spec, true) && + FileSystem::Instance().Exists(mutable_mod_spec.GetSymbolFileSpec())) { dsym_fspec = mutable_mod_spec.GetSymbolFileSpec(); return true; } @@ -202,7 +198,7 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, return false; } -FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) { +static FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) { const FileSpec *exec_fspec = module_spec.GetFileSpecPtr(); const ArchSpec *arch = module_spec.GetArchitecturePtr(); const UUID *uuid = module_spec.GetUUIDPtr(); @@ -218,7 +214,7 @@ FileSpec LocateExecutableSymbolFileDsym(const ModuleSpec &module_spec) { ModuleSpec dsym_module_spec; // First try and find the dSYM in the same directory as the executable or in // an appropriate parent directory - if (LocateDSYMInVincinityOfExecutable(module_spec, symbol_fspec) == false) { + if (!LocateDSYMInVincinityOfExecutable(module_spec, symbol_fspec)) { // We failed to easily find the dSYM above, so use DebugSymbols LocateMacOSXFilesUsingDebugSymbols(module_spec, dsym_module_spec); } else { @@ -250,9 +246,12 @@ ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) { return result; } +// Keep "symbols.enable-external-lookup" description in sync with this function. + FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) { FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec(); - if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists()) + if (symbol_file_spec.IsAbsolute() && + FileSystem::Instance().Exists(symbol_file_spec)) return symbol_file_spec; const char *symbol_filename = symbol_file_spec.GetFilename().AsCString(); @@ -263,25 +262,42 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) { // Add module directory. FileSpec module_file_spec = module_spec.GetFileSpec(); // We keep the unresolved pathname if it fails. - FileSystem::ResolveSymbolicLink(module_file_spec, module_file_spec); + FileSystem::Instance().ResolveSymbolicLink(module_file_spec, module_file_spec); const ConstString &file_dir = module_file_spec.GetDirectory(); - debug_file_search_paths.AppendIfUnique( - FileSpec(file_dir.AsCString("."), true)); + { + FileSpec file_spec(file_dir.AsCString(".")); + FileSystem::Instance().Resolve(file_spec); + debug_file_search_paths.AppendIfUnique(file_spec); + } - // Add current working directory. - debug_file_search_paths.AppendIfUnique(FileSpec(".", true)); + if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) { + + // Add current working directory. + { + FileSpec file_spec("."); + FileSystem::Instance().Resolve(file_spec); + debug_file_search_paths.AppendIfUnique(file_spec); + } #ifndef _WIN32 #if defined(__NetBSD__) - // Add /usr/libdata/debug directory. - debug_file_search_paths.AppendIfUnique( - FileSpec("/usr/libdata/debug", true)); + // Add /usr/libdata/debug directory. + { + FileSpec file_spec("/usr/libdata/debug"); + FileSystem::Instance().Resolve(file_spec); + debug_file_search_paths.AppendIfUnique(file_spec); + } #else - // Add /usr/lib/debug directory. - debug_file_search_paths.AppendIfUnique(FileSpec("/usr/lib/debug", true)); + // Add /usr/lib/debug directory. + { + FileSpec file_spec("/usr/lib/debug"); + FileSystem::Instance().Resolve(file_spec); + debug_file_search_paths.AppendIfUnique(file_spec); + } #endif #endif // _WIN32 + } std::string uuid_str; const UUID &module_uuid = module_spec.GetUUID(); @@ -298,8 +314,8 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) { size_t num_directories = debug_file_search_paths.GetSize(); for (size_t idx = 0; idx < num_directories; ++idx) { FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx); - dirspec.ResolvePath(); - if (!llvm::sys::fs::is_directory(dirspec.GetPath())) + FileSystem::Instance().Resolve(dirspec); + if (!FileSystem::Instance().IsDirectory(dirspec)) continue; std::vector files; @@ -317,13 +333,14 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) { const uint32_t num_files = files.size(); for (size_t idx_file = 0; idx_file < num_files; ++idx_file) { const std::string &filename = files[idx_file]; - FileSpec file_spec(filename, true); + FileSpec file_spec(filename); + FileSystem::Instance().Resolve(file_spec); if (llvm::sys::fs::equivalent(file_spec.GetPath(), module_file_spec.GetPath())) continue; - if (file_spec.Exists()) { + if (FileSystem::Instance().Exists(file_spec)) { lldb_private::ModuleSpecList specs; const size_t num_specs = ObjectFile::GetModuleSpecifications(file_spec, 0, 0, specs); diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp index 1a10336f1dfc..7a99167f3e8d 100644 --- a/source/Host/common/TCPSocket.cpp +++ b/source/Host/common/TCPSocket.cpp @@ -1,9 +1,8 @@ //===-- TCPSocket.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/TaskPool.cpp b/source/Host/common/TaskPool.cpp index c54b9a8ae56b..062fa4abd06c 100644 --- a/source/Host/common/TaskPool.cpp +++ b/source/Host/common/TaskPool.cpp @@ -1,18 +1,17 @@ //===--------------------- TaskPool.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/TaskPool.h" #include "lldb/Host/ThreadLauncher.h" -#include // for uint32_t -#include // for queue -#include // for thread +#include +#include +#include namespace lldb_private { diff --git a/source/Host/common/Terminal.cpp b/source/Host/common/Terminal.cpp index be912fbe6155..f61d755ddef0 100644 --- a/source/Host/common/Terminal.cpp +++ b/source/Host/common/Terminal.cpp @@ -1,9 +1,8 @@ //===-- Terminal.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/ThreadLauncher.cpp b/source/Host/common/ThreadLauncher.cpp index f3401016393f..ede864db108f 100644 --- a/source/Host/common/ThreadLauncher.cpp +++ b/source/Host/common/ThreadLauncher.cpp @@ -1,10 +1,9 @@ //===-- ThreadLauncher.cpp ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/UDPSocket.cpp b/source/Host/common/UDPSocket.cpp index 96bcc6a150a9..e1bcd0c18da3 100644 --- a/source/Host/common/UDPSocket.cpp +++ b/source/Host/common/UDPSocket.cpp @@ -1,9 +1,8 @@ //===-- UDPSocket.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/common/XML.cpp b/source/Host/common/XML.cpp index 7468a3d7ac65..006b49f4e106 100644 --- a/source/Host/common/XML.cpp +++ b/source/Host/common/XML.cpp @@ -1,9 +1,8 @@ //===-- XML.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -201,8 +200,7 @@ void XMLNode::ForEachAttribute(AttributeCallback const &callback) const { llvm::StringRef attr_value; if (child->content) attr_value = llvm::StringRef((const char *)child->content); - if (callback(llvm::StringRef((const char *)attr->name), attr_value) == - false) + if (!callback(llvm::StringRef((const char *)attr->name), attr_value)) return; } } @@ -217,7 +215,7 @@ void XMLNode::ForEachSiblingNode(NodeCallback const &callback) const { if (IsValid()) { // iterate through all siblings for (xmlNodePtr node = m_node; node; node = node->next) { - if (callback(XMLNode(node)) == false) + if (!callback(XMLNode(node))) return; } } @@ -234,7 +232,7 @@ void XMLNode::ForEachSiblingElement(NodeCallback const &callback) const { if (node->type != XML_ELEMENT_NODE) continue; - if (callback(XMLNode(node)) == false) + if (!callback(XMLNode(node))) return; } } @@ -263,7 +261,7 @@ void XMLNode::ForEachSiblingElementWithName( // ignore this one } - if (callback(XMLNode(node)) == false) + if (!callback(XMLNode(node))) return; } } @@ -439,7 +437,7 @@ XMLNode ApplePropertyList::GetValueNode(const char *key) const { "key", [key, &value_node](const XMLNode &key_node) -> bool { std::string key_name; if (key_node.GetElementText(key_name)) { - if (key_name.compare(key) == 0) { + if (key_name == key) { value_node = key_node.GetSibling(); while (value_node && !value_node.IsElement()) value_node = value_node.GetSibling(); diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp index 87552bc2a27e..8b3c6ad186b5 100644 --- a/source/Host/freebsd/Host.cpp +++ b/source/Host/freebsd/Host.cpp @@ -1,14 +1,12 @@ //===-- source/Host/freebsd/Host.cpp ------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include @@ -23,9 +21,6 @@ #include #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" @@ -75,11 +70,9 @@ GetFreeBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr, size_t pathname_len = sizeof(pathname); mib[2] = KERN_PROC_PATHNAME; if (::sysctl(mib, 4, pathname, &pathname_len, NULL, 0) == 0) - process_info.GetExecutableFile().SetFile(pathname, false, - FileSpec::Style::native); + process_info.GetExecutableFile().SetFile(pathname, FileSpec::Style::native); else - process_info.GetExecutableFile().SetFile(cstr, false, - FileSpec::Style::native); + process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native); if (!(match_info_ptr == NULL || NameMatches(process_info.GetExecutableFile().GetFilename().GetCString(), diff --git a/source/Host/freebsd/HostInfoFreeBSD.cpp b/source/Host/freebsd/HostInfoFreeBSD.cpp index 18eae3eb7606..e28cf4aa420f 100644 --- a/source/Host/freebsd/HostInfoFreeBSD.cpp +++ b/source/Host/freebsd/HostInfoFreeBSD.cpp @@ -1,9 +1,8 @@ //===-- HostInfoFreeBSD.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -69,7 +68,7 @@ FileSpec HostInfoFreeBSD::GetProgramFileSpec() { if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0) { char *exe_path = new char[exe_path_size]; if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0) - g_program_filespec.SetFile(exe_path, false, FileSpec::Style::native); + g_program_filespec.SetFile(exe_path, FileSpec::Style::native); delete[] exe_path; } } diff --git a/source/Host/linux/AbstractSocket.cpp b/source/Host/linux/AbstractSocket.cpp index 2d6f6adaf1ef..5a47787a5f43 100644 --- a/source/Host/linux/AbstractSocket.cpp +++ b/source/Host/linux/AbstractSocket.cpp @@ -1,9 +1,8 @@ //===-- AbstractSocket.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/linux/Host.cpp b/source/Host/linux/Host.cpp index 1a0eb767eb34..e67558df0adb 100644 --- a/source/Host/linux/Host.cpp +++ b/source/Host/linux/Host.cpp @@ -1,13 +1,11 @@ //===-- source/Host/linux/Host.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include #include @@ -18,20 +16,17 @@ #include #include -// C++ Includes -// Other libraries and framework includes #include "llvm/Object/ELF.h" #include "llvm/Support/ScopedPrinter.h" -// Project includes #include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/linux/Support.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/DataExtractor.h" using namespace lldb; @@ -125,7 +120,7 @@ static bool IsDirNumeric(const char *dname) { static ArchSpec GetELFProcessCPUType(llvm::StringRef exe_path) { Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); - auto buffer_sp = DataBufferLLVM::CreateSliceFromPath(exe_path, 0x20, 0); + auto buffer_sp = FileSystem::Instance().CreateDataBuffer(exe_path, 0x20, 0); if (!buffer_sp) return ArchSpec(); @@ -190,8 +185,7 @@ static bool GetProcessAndStatInfo(::pid_t pid, return false; process_info.SetProcessID(pid); - process_info.GetExecutableFile().SetFile(PathRef, false, - FileSpec::Style::native); + process_info.GetExecutableFile().SetFile(PathRef, FileSpec::Style::native); llvm::StringRef Rest = Environ->getBuffer(); while (!Rest.empty()) { diff --git a/source/Host/linux/HostInfoLinux.cpp b/source/Host/linux/HostInfoLinux.cpp index 1d95010e2f73..2b2207e7afa9 100644 --- a/source/Host/linux/HostInfoLinux.cpp +++ b/source/Host/linux/HostInfoLinux.cpp @@ -1,14 +1,14 @@ //===-- HostInfoLinux.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Host/Config.h" #include "lldb/Host/linux/HostInfoLinux.h" +#include "lldb/Host/Config.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Utility/Log.h" #include "llvm/Support/Threading.h" @@ -20,7 +20,7 @@ #include #include -#include // std::once +#include using namespace lldb_private; @@ -170,7 +170,7 @@ FileSpec HostInfoLinux::GetProgramFileSpec() { ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1); if (len > 0) { exe_path[len] = 0; - g_program_filespec.SetFile(exe_path, false, FileSpec::Style::native); + g_program_filespec.SetFile(exe_path, FileSpec::Style::native); } } @@ -179,14 +179,15 @@ FileSpec HostInfoLinux::GetProgramFileSpec() { bool HostInfoLinux::ComputeSupportExeDirectory(FileSpec &file_spec) { if (HostInfoPosix::ComputeSupportExeDirectory(file_spec) && - file_spec.IsAbsolute() && file_spec.Exists()) + file_spec.IsAbsolute() && FileSystem::Instance().Exists(file_spec)) return true; file_spec.GetDirectory() = GetProgramFileSpec().GetDirectory(); return !file_spec.GetDirectory().IsEmpty(); } bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) { - FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins", true); + FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins"); + FileSystem::Instance().Resolve(temp_file); file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str()); return true; } diff --git a/source/Host/linux/LibcGlue.cpp b/source/Host/linux/LibcGlue.cpp index 93d2a41d2eb1..0acc2064c82b 100644 --- a/source/Host/linux/LibcGlue.cpp +++ b/source/Host/linux/LibcGlue.cpp @@ -1,9 +1,8 @@ //===-- LibcGlue.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/linux/Support.cpp b/source/Host/linux/Support.cpp index 31808401ea61..b9deb21b55eb 100644 --- a/source/Host/linux/Support.cpp +++ b/source/Host/linux/Support.cpp @@ -1,9 +1,8 @@ //===-- Support.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp index 1edec96e39f2..74d526cb4b19 100644 --- a/source/Host/macosx/Symbols.cpp +++ b/source/Host/macosx/Symbols.cpp @@ -1,24 +1,18 @@ //===-- Symbols.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/Symbols.h" -// C Includes -#include "lldb/Utility/SafeMachO.h" #include #include -// C++ Includes -// Other libraries and framework includes #include -// Project includes #include "Host/macosx/cfcpp/CFCBundle.h" #include "Host/macosx/cfcpp/CFCData.h" #include "Host/macosx/cfcpp/CFCReleaser.h" @@ -42,7 +36,6 @@ using namespace lldb; using namespace lldb_private; -using namespace llvm::MachO; #if !defined(__arm__) && !defined(__arm64__) && \ !defined(__aarch64__) // No DebugSymbols on the iOS devices @@ -107,9 +100,11 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, "UUID %s -- looking for the dSYM", path, uuid->GetAsString().c_str()); } - FileSpec dsym_filespec(path, path[0] == '~'); + FileSpec dsym_filespec(path); + if (path[0] == '~') + FileSystem::Instance().Resolve(dsym_filespec); - if (llvm::sys::fs::is_directory(dsym_filespec.GetPath())) { + if (FileSystem::Instance().IsDirectory(dsym_filespec)) { dsym_filespec = Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch); ++items_found; @@ -148,8 +143,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, path, uuid->GetAsString().c_str()); } ++items_found; - FileSpec exec_filespec(path, path[0] == '~'); - if (exec_filespec.Exists()) { + FileSpec exec_filespec(path); + if (path[0] == '~') + FileSystem::Instance().Resolve(exec_filespec); + if (FileSystem::Instance().Exists(exec_filespec)) { success = true; return_module_spec.GetFileSpec() = exec_filespec; } @@ -169,7 +166,8 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, "bundle with name with name %s", path); } - FileSpec file_spec(path, true); + FileSpec file_spec(path); + FileSystem::Instance().Resolve(file_spec); ModuleSpecList module_specs; ModuleSpec matched_module_spec; using namespace llvm::sys::fs; @@ -184,7 +182,8 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, if (::CFURLGetFileSystemRepresentation(bundle_exe_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) { - FileSpec bundle_exe_file_spec(path, true); + FileSpec bundle_exe_file_spec(path); + FileSystem::Instance().Resolve(bundle_exe_file_spec); if (ObjectFile::GetModuleSpecifications( bundle_exe_file_spec, 0, 0, module_specs) && module_specs.FindMatchingModuleSpec( @@ -309,8 +308,8 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict, (CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable")); if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) { if (CFCString::FileSystemRepresentation(cf_str, str)) { - module_spec.GetFileSpec().SetFile(str.c_str(), true, - FileSpec::Style::native); + module_spec.GetFileSpec().SetFile(str.c_str(), FileSpec::Style::native); + FileSystem::Instance().Resolve(module_spec.GetFileSpec()); if (log) { log->Printf( "From dsymForUUID plist: Symbol rich executable is at '%s'", @@ -323,8 +322,9 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict, CFSTR("DBGDSYMPath")); if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) { if (CFCString::FileSystemRepresentation(cf_str, str)) { - module_spec.GetSymbolFileSpec().SetFile(str.c_str(), true, + module_spec.GetSymbolFileSpec().SetFile(str.c_str(), FileSpec::Style::native); + FileSystem::Instance().Resolve(module_spec.GetFileSpec()); success = true; if (log) { log->Printf("From dsymForUUID plist: dSYM is at '%s'", str.c_str()); @@ -398,12 +398,13 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict, // DBGSourcePath values (the "values" half of key-value path pairs) // were wrong. Ignore them and use the universal DBGSourcePath // string from earlier. - if (new_style_source_remapping_dictionary == true && + if (new_style_source_remapping_dictionary && !original_DBGSourcePath_value.empty()) { DBGSourcePath = original_DBGSourcePath_value; } if (DBGSourcePath[0] == '~') { - FileSpec resolved_source_path(DBGSourcePath.c_str(), true); + FileSpec resolved_source_path(DBGSourcePath.c_str()); + FileSystem::Instance().Resolve(resolved_source_path); DBGSourcePath = resolved_source_path.GetPath(); } // With version 2 of DBGSourcePathRemapping, we can chop off the @@ -414,8 +415,8 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict, ConstString(DBGBuildSourcePath.c_str()), ConstString(DBGSourcePath.c_str()), true); if (do_truncate_remapping_names) { - FileSpec build_path(DBGBuildSourcePath.c_str(), false); - FileSpec source_path(DBGSourcePath.c_str(), false); + FileSpec build_path(DBGBuildSourcePath.c_str()); + FileSpec source_path(DBGSourcePath.c_str()); build_path.RemoveLastPathComponent(); build_path.RemoveLastPathComponent(); source_path.RemoveLastPathComponent(); @@ -451,7 +452,8 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict, if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) { if (DBGSourcePath[0] == '~') { - FileSpec resolved_source_path(DBGSourcePath.c_str(), true); + FileSpec resolved_source_path(DBGSourcePath.c_str()); + FileSystem::Instance().Resolve(resolved_source_path); DBGSourcePath = resolved_source_path.GetPath(); } module_spec.GetSourceMappingList().Append( @@ -472,7 +474,7 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec, // it once per lldb run and cache the result. static bool g_have_checked_for_dbgshell_command = false; static const char *g_dbgshell_command = NULL; - if (g_have_checked_for_dbgshell_command == false) { + if (!g_have_checked_for_dbgshell_command) { g_have_checked_for_dbgshell_command = true; CFTypeRef defaults_setting = CFPreferencesCopyAppValue( CFSTR("DBGShellCommands"), CFSTR("com.apple.DebugSymbols")); @@ -492,11 +494,12 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec, // When g_dbgshell_command is NULL, the user has not enabled the use of an // external program to find the symbols, don't run it for them. - if (force_lookup == false && g_dbgshell_command == NULL) { + if (!force_lookup && g_dbgshell_command == NULL) { return false; } - if (uuid_ptr || (file_spec_ptr && file_spec_ptr->Exists())) { + if (uuid_ptr || + (file_spec_ptr && FileSystem::Instance().Exists(*file_spec_ptr))) { static bool g_located_dsym_for_uuid_exe = false; static bool g_dsym_for_uuid_exe_exists = false; static char g_dsym_for_uuid_exe_path[PATH_MAX]; @@ -506,15 +509,18 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec, getenv("LLDB_APPLE_DSYMFORUUID_EXECUTABLE"); FileSpec dsym_for_uuid_exe_spec; if (dsym_for_uuid_exe_path_cstr) { - dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr, true, + dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr, FileSpec::Style::native); - g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists(); + FileSystem::Instance().Resolve(dsym_for_uuid_exe_spec); + g_dsym_for_uuid_exe_exists = + FileSystem::Instance().Exists(dsym_for_uuid_exe_spec); } if (!g_dsym_for_uuid_exe_exists) { - dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", false, + dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID", FileSpec::Style::native); - g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists(); + g_dsym_for_uuid_exe_exists = + FileSystem::Instance().Exists(dsym_for_uuid_exe_spec); if (!g_dsym_for_uuid_exe_exists) { long bufsize; if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) != -1) { @@ -527,17 +533,20 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec, tilde_rc && tilde_rc->pw_dir) { std::string dsymforuuid_path(tilde_rc->pw_dir); dsymforuuid_path += "/bin/dsymForUUID"; - dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(), false, + dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(), FileSpec::Style::native); - g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists(); + g_dsym_for_uuid_exe_exists = + FileSystem::Instance().Exists(dsym_for_uuid_exe_spec); } } } } if (!g_dsym_for_uuid_exe_exists && g_dbgshell_command != NULL) { - dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command, true, + dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command, FileSpec::Style::native); - g_dsym_for_uuid_exe_exists = dsym_for_uuid_exe_spec.Exists(); + FileSystem::Instance().Resolve(dsym_for_uuid_exe_spec); + g_dsym_for_uuid_exe_exists = + FileSystem::Instance().Exists(dsym_for_uuid_exe_spec); } if (g_dsym_for_uuid_exe_exists) diff --git a/source/Host/macosx/cfcpp/CFCBundle.cpp b/source/Host/macosx/cfcpp/CFCBundle.cpp index 08f16701c36f..06057b5ed468 100644 --- a/source/Host/macosx/cfcpp/CFCBundle.cpp +++ b/source/Host/macosx/cfcpp/CFCBundle.cpp @@ -1,9 +1,8 @@ //===-- CFCBundle.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCBundle.h b/source/Host/macosx/cfcpp/CFCBundle.h index 9506b93f6536..12516048f472 100644 --- a/source/Host/macosx/cfcpp/CFCBundle.h +++ b/source/Host/macosx/cfcpp/CFCBundle.h @@ -1,9 +1,8 @@ //===-- CFCBundle.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCData.cpp b/source/Host/macosx/cfcpp/CFCData.cpp index 95cadede8ff6..c3deeca2ce98 100644 --- a/source/Host/macosx/cfcpp/CFCData.cpp +++ b/source/Host/macosx/cfcpp/CFCData.cpp @@ -1,9 +1,8 @@ //===-- CFCData.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCData.h b/source/Host/macosx/cfcpp/CFCData.h index e89d7bec7832..b0b25232b1c7 100644 --- a/source/Host/macosx/cfcpp/CFCData.h +++ b/source/Host/macosx/cfcpp/CFCData.h @@ -1,9 +1,8 @@ //===-- CFCData.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCMutableArray.cpp b/source/Host/macosx/cfcpp/CFCMutableArray.cpp index 0b6258315eb0..75bc12d28ff2 100644 --- a/source/Host/macosx/cfcpp/CFCMutableArray.cpp +++ b/source/Host/macosx/cfcpp/CFCMutableArray.cpp @@ -1,9 +1,8 @@ //===-- CFCMutableArray.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -88,7 +87,7 @@ bool CFCMutableArray::SetValueAtIndex(CFIndex idx, const void *value) { bool CFCMutableArray::AppendValue(const void *value, bool can_create) { CFMutableArrayRef array = get(); if (array == NULL) { - if (can_create == false) + if (!can_create) return false; array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); @@ -106,7 +105,7 @@ bool CFCMutableArray::AppendCStringAsCFString(const char *s, bool can_create) { CFMutableArrayRef array = get(); if (array == NULL) { - if (can_create == false) + if (!can_create) return false; array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); @@ -124,7 +123,7 @@ bool CFCMutableArray::AppendFileSystemRepresentationAsCFString( const char *s, bool can_create) { CFMutableArrayRef array = get(); if (array == NULL) { - if (can_create == false) + if (!can_create) return false; array = ::CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); diff --git a/source/Host/macosx/cfcpp/CFCMutableArray.h b/source/Host/macosx/cfcpp/CFCMutableArray.h index 23d1f932bfc7..ba12301d1fd9 100644 --- a/source/Host/macosx/cfcpp/CFCMutableArray.h +++ b/source/Host/macosx/cfcpp/CFCMutableArray.h @@ -1,9 +1,8 @@ //===-- CFCMutableArray.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp b/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp index 0c52aa3ed051..93094161382d 100644 --- a/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp +++ b/source/Host/macosx/cfcpp/CFCMutableDictionary.cpp @@ -1,9 +1,8 @@ //===-- CFCMutableDictionary.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCMutableDictionary.h b/source/Host/macosx/cfcpp/CFCMutableDictionary.h index b30a2e616cd5..99849f4dd01e 100644 --- a/source/Host/macosx/cfcpp/CFCMutableDictionary.h +++ b/source/Host/macosx/cfcpp/CFCMutableDictionary.h @@ -1,9 +1,8 @@ //===-- CFCMutableDictionary.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCMutableSet.cpp b/source/Host/macosx/cfcpp/CFCMutableSet.cpp index c339e950674b..bcfa7ce291db 100644 --- a/source/Host/macosx/cfcpp/CFCMutableSet.cpp +++ b/source/Host/macosx/cfcpp/CFCMutableSet.cpp @@ -1,18 +1,13 @@ //===-- CFCMutableSet.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CFCMutableSet.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes //---------------------------------------------------------------------- // CFCString constructor @@ -64,7 +59,7 @@ const void *CFCMutableSet::GetValue(const void *value) const { const void *CFCMutableSet::AddValue(const void *value, bool can_create) { CFMutableSetRef set = get(); if (set == NULL) { - if (can_create == false) + if (!can_create) return NULL; set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks); reset(set); diff --git a/source/Host/macosx/cfcpp/CFCMutableSet.h b/source/Host/macosx/cfcpp/CFCMutableSet.h index 1459b7e46328..5aabaffe664d 100644 --- a/source/Host/macosx/cfcpp/CFCMutableSet.h +++ b/source/Host/macosx/cfcpp/CFCMutableSet.h @@ -1,9 +1,8 @@ //===-- CFCMutableSet.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCReleaser.h b/source/Host/macosx/cfcpp/CFCReleaser.h index c596d1e1e7ed..816dba8813b7 100644 --- a/source/Host/macosx/cfcpp/CFCReleaser.h +++ b/source/Host/macosx/cfcpp/CFCReleaser.h @@ -1,9 +1,8 @@ //===-- CFCReleaser.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCString.cpp b/source/Host/macosx/cfcpp/CFCString.cpp index 6191f873c98a..a0768755f11a 100644 --- a/source/Host/macosx/cfcpp/CFCString.cpp +++ b/source/Host/macosx/cfcpp/CFCString.cpp @@ -1,9 +1,8 @@ //===-- CFCString.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CFCString.h b/source/Host/macosx/cfcpp/CFCString.h index a7bb029408fb..2ed860fa20f9 100644 --- a/source/Host/macosx/cfcpp/CFCString.h +++ b/source/Host/macosx/cfcpp/CFCString.h @@ -1,9 +1,8 @@ //===-- CFCString.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/macosx/cfcpp/CoreFoundationCPP.h b/source/Host/macosx/cfcpp/CoreFoundationCPP.h index 88d0f5a23f80..5a2e3996f10f 100644 --- a/source/Host/macosx/cfcpp/CoreFoundationCPP.h +++ b/source/Host/macosx/cfcpp/CoreFoundationCPP.h @@ -1,9 +1,8 @@ //===-- CoreFoundationCPP.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// //---------------------------------------------------------------------- diff --git a/source/Host/macosx/objcxx/Host.mm b/source/Host/macosx/objcxx/Host.mm index 8295ef21a310..0ab432bf381e 100644 --- a/source/Host/macosx/objcxx/Host.mm +++ b/source/Host/macosx/objcxx/Host.mm @@ -1,9 +1,8 @@ //===-- Host.mm -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -55,10 +54,11 @@ #include #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/ThreadLauncher.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Process.h" +#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/DataBufferHeap.h" @@ -100,12 +100,12 @@ bool Host::GetBundleDirectory(const FileSpec &file, FileSpec &bundle_directory) { #if defined(__APPLE__) - if (llvm::sys::fs::is_directory(file.GetPath())) { + if (FileSystem::Instance().IsDirectory(file)) { char path[PATH_MAX]; if (file.GetPath(path, sizeof(path))) { CFCBundle bundle(path); if (bundle.GetPath(path, sizeof(path))) { - bundle_directory.SetFile(path, false, FileSpec::Style::native); + bundle_directory.SetFile(path, FileSpec::Style::native); return true; } } @@ -117,7 +117,7 @@ bool Host::ResolveExecutableInBundle(FileSpec &file) { #if defined(__APPLE__) - if (llvm::sys::fs::is_directory(file.GetPath())) { + if (FileSystem::Instance().IsDirectory(file)) { char path[PATH_MAX]; if (file.GetPath(path, sizeof(path))) { CFCBundle bundle(path); @@ -125,7 +125,7 @@ if (url.get()) { if (::CFURLGetFileSystemRepresentation(url.get(), YES, (UInt8 *)path, sizeof(path))) { - file.SetFile(path, false, FileSpec::Style::native); + file.SetFile(path, FileSpec::Style::native); return true; } } @@ -225,7 +225,7 @@ repeat with the_window in (get windows)\n\ darwin_debug_file_spec.GetFilename().SetCString("darwin-debug"); - if (!darwin_debug_file_spec.Exists()) { + if (!FileSystem::Instance().Exists(darwin_debug_file_spec)) { error.SetErrorStringWithFormat( "the 'darwin-debug' executable doesn't exists at '%s'", darwin_debug_file_spec.GetPath().c_str()); @@ -485,11 +485,9 @@ static bool GetMacOSXProcessCPUType(ProcessInstanceInfo &process_info) { bool host_cpu_is_64bit; uint32_t is64bit_capable; size_t is64bit_capable_len = sizeof(is64bit_capable); - if (sysctlbyname("hw.cpu64bit_capable", &is64bit_capable, - &is64bit_capable_len, NULL, 0) == 0) - host_cpu_is_64bit = true; - else - host_cpu_is_64bit = false; + host_cpu_is_64bit = + sysctlbyname("hw.cpu64bit_capable", &is64bit_capable, + &is64bit_capable_len, NULL, 0) == 0; // if the host is an armv8 device, its cpusubtype will be in // CPU_SUBTYPE_ARM64 numbering @@ -541,8 +539,7 @@ DataExtractor data(arg_data.GetBytes(), arg_data_size, triple_arch == llvm::Triple::x86_64); const char *cstr = data.GetCStr(&offset); if (cstr) { - process_info.GetExecutableFile().SetFile(cstr, false, - FileSpec::Style::native); + process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native); if (match_info_ptr == NULL || NameMatches( @@ -660,7 +657,7 @@ static bool GetMacOSXProcessUserAndGroup(ProcessInstanceInfo &process_info) { if (our_uid == 0) kinfo_user_matches = true; - if (kinfo_user_matches == false || // Make sure the user is acceptable + if (!kinfo_user_matches || // Make sure the user is acceptable static_cast(kinfo.kp_proc.p_pid) == our_pid || // Skip this process kinfo.kp_proc.p_pid == 0 || // Skip kernel (kernel pid is zero) @@ -1273,21 +1270,19 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) { Status error; + + FileSystem &fs = FileSystem::Instance(); FileSpec exe_spec(launch_info.GetExecutableFile()); - llvm::sys::fs::file_status stats; - status(exe_spec.GetPath(), stats); - if (!exists(stats)) { - exe_spec.ResolvePath(); - status(exe_spec.GetPath(), stats); - } - if (!exists(stats)) { - exe_spec.ResolveExecutableLocation(); - status(exe_spec.GetPath(), stats); - } - if (!exists(stats)) { + if (!fs.Exists(exe_spec)) + FileSystem::Instance().Resolve(exe_spec); + + if (!fs.Exists(exe_spec)) + FileSystem::Instance().ResolveExecutableLocation(exe_spec); + + if (!fs.Exists(exe_spec)) { error.SetErrorStringWithFormatv("executable doesn't exist: '{0}'", - launch_info.GetExecutableFile()); + exe_spec); return error; } @@ -1304,12 +1299,15 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; - if (ShouldLaunchUsingXPC(launch_info)) { - error = LaunchProcessXPC(exe_spec.GetPath().c_str(), launch_info, pid); - } else { - error = - LaunchProcessPosixSpawn(exe_spec.GetPath().c_str(), launch_info, pid); - } + // From now on we'll deal with the external (devirtualized) path. + auto exe_path = fs.GetExternalPath(exe_spec); + if (!exe_path) + return Status(exe_path.getError()); + + if (ShouldLaunchUsingXPC(launch_info)) + error = LaunchProcessXPC(exe_path->c_str(), launch_info, pid); + else + error = LaunchProcessPosixSpawn(exe_path->c_str(), launch_info, pid); if (pid != LLDB_INVALID_PROCESS_ID) { // If all went well, then set the process ID into the launch info @@ -1337,7 +1335,7 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { return error; } expand_tool_spec.AppendPathComponent("lldb-argdumper"); - if (!expand_tool_spec.Exists()) { + if (!FileSystem::Instance().Exists(expand_tool_spec)) { error.SetErrorStringWithFormat( "could not find the lldb-argdumper tool: %s", expand_tool_spec.GetPath().c_str()); @@ -1354,14 +1352,14 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) { int status; std::string output; FileSpec cwd(launch_info.GetWorkingDirectory()); - if (!cwd.Exists()) { + if (!FileSystem::Instance().Exists(cwd)) { char *wd = getcwd(nullptr, 0); if (wd == nullptr) { error.SetErrorStringWithFormat( "cwd does not exist; cannot launch with shell argument expansion"); return error; } else { - FileSpec working_dir(wd, false); + FileSpec working_dir(wd); free(wd); launch_info.SetWorkingDirectory(working_dir); } diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm index 3e651b9a0a1a..2050839a037a 100644 --- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -1,17 +1,16 @@ //===-- HostInfoMacOSX.mm ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Host/HostInfo.h" #include "lldb/Host/macosx/HostInfoMacOSX.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SafeMachO.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" @@ -97,14 +96,13 @@ uint32_t len = sizeof(program_fullpath); int err = _NSGetExecutablePath(program_fullpath, &len); if (err == 0) - g_program_filespec.SetFile(program_fullpath, false, - FileSpec::Style::native); + g_program_filespec.SetFile(program_fullpath, FileSpec::Style::native); else if (err == -1) { char *large_program_fullpath = (char *)::malloc(len + 1); err = _NSGetExecutablePath(large_program_fullpath, &len); if (err == 0) - g_program_filespec.SetFile(large_program_fullpath, false, + g_program_filespec.SetFile(large_program_fullpath, FileSpec::Style::native); ::free(large_program_fullpath); @@ -140,8 +138,9 @@ // as in the case of a python script, the executable is python, not // the lldb driver. raw_path.append("/../bin"); - FileSpec support_dir_spec(raw_path, true); - if (!llvm::sys::fs::is_directory(support_dir_spec.GetPath())) { + FileSpec support_dir_spec(raw_path); + FileSystem::Instance().Resolve(support_dir_spec); + if (!FileSystem::Instance().IsDirectory(support_dir_spec)) { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (log) log->Printf("HostInfoMacOSX::%s(): failed to find support directory", @@ -209,7 +208,8 @@ } bool HostInfoMacOSX::ComputeUserPluginsDirectory(FileSpec &file_spec) { - FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns", true); + FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns"); + FileSystem::Instance().Resolve(temp_file); file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str()); return true; } @@ -300,6 +300,6 @@ raw_path.resize(framework_pos); raw_path.append("/Resources/Swift"); } - file_spec.SetFile(raw_path.c_str(), true, FileSpec::Style::native); + file_spec.SetFile(raw_path.c_str(), FileSpec::Style::native); return true; } diff --git a/source/Host/macosx/objcxx/HostThreadMacOSX.mm b/source/Host/macosx/objcxx/HostThreadMacOSX.mm index c5051cdf30d7..d9f32ca498fa 100644 --- a/source/Host/macosx/objcxx/HostThreadMacOSX.mm +++ b/source/Host/macosx/objcxx/HostThreadMacOSX.mm @@ -1,9 +1,8 @@ //===-- HostThreadMacOSX.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/netbsd/Host.cpp b/source/Host/netbsd/Host.cpp index bfd5a74ffcc2..b24ec75ad27a 100644 --- a/source/Host/netbsd/Host.cpp +++ b/source/Host/netbsd/Host.cpp @@ -1,13 +1,11 @@ //===-- source/Host/netbsd/Host.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include #include @@ -22,9 +20,6 @@ #include #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" @@ -70,7 +65,7 @@ static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr, if (!cstr) return false; - process_info.GetExecutableFile().SetFile(cstr, false, + process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native); if (!(match_info_ptr == NULL || diff --git a/source/Host/netbsd/HostInfoNetBSD.cpp b/source/Host/netbsd/HostInfoNetBSD.cpp index dfbce310509d..99d413922327 100644 --- a/source/Host/netbsd/HostInfoNetBSD.cpp +++ b/source/Host/netbsd/HostInfoNetBSD.cpp @@ -1,9 +1,8 @@ //===-- HostInfoNetBSD.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -85,7 +84,7 @@ FileSpec HostInfoNetBSD::GetProgramFileSpec() { len = sizeof(path); if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) { - g_program_filespec.SetFile(path, false, FileSpec::Style::native); + g_program_filespec.SetFile(path, FileSpec::Style::native); } } return g_program_filespec; diff --git a/source/Host/openbsd/Host.cpp b/source/Host/openbsd/Host.cpp index 49e9c290a027..0700c4b15c2a 100644 --- a/source/Host/openbsd/Host.cpp +++ b/source/Host/openbsd/Host.cpp @@ -1,13 +1,11 @@ //===-- source/Host/openbsd/Host.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include @@ -19,9 +17,6 @@ #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" diff --git a/source/Host/openbsd/HostInfoOpenBSD.cpp b/source/Host/openbsd/HostInfoOpenBSD.cpp index 548958899322..950f2ebb86b8 100644 --- a/source/Host/openbsd/HostInfoOpenBSD.cpp +++ b/source/Host/openbsd/HostInfoOpenBSD.cpp @@ -1,9 +1,8 @@ //===-- HostInfoOpenBSD.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,16 +16,17 @@ using namespace lldb_private; -bool HostInfoOpenBSD::GetOSVersion(uint32_t &major, uint32_t &minor, - uint32_t &update) { +llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() { struct utsname un; ::memset(&un, 0, sizeof(utsname)); if (uname(&un) < 0) - return false; + return llvm::VersionTuple(); - int status = sscanf(un.release, "%u.%u", &major, &minor); - return status == 2; + unsigned major, minor; + if (2 == sscanf(un.release, "%u.%u", &major, &minor)) + return llvm::VersionTuple(major, minor); + return llvm::VersionTuple(); } bool HostInfoOpenBSD::GetOSBuildString(std::string &s) { diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp index c21bb786a896..99c73c52e65b 100644 --- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -1,9 +1,8 @@ //===-- ConnectionFileDescriptorPosix.cpp -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -21,7 +20,6 @@ #include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Timeout.h" -// C Includes #include #include #include @@ -33,16 +31,13 @@ #include #endif -// C++ Includes #include -// Other libraries and framework includes #include "llvm/Support/Errno.h" #include "llvm/Support/ErrorHandling.h" #if defined(__APPLE__) #include "llvm/ADT/SmallVector.h" #endif -// Project includes #include "lldb/Host/Host.h" #include "lldb/Host/Socket.h" #include "lldb/Host/common/TCPSocket.h" diff --git a/source/Host/posix/DomainSocket.cpp b/source/Host/posix/DomainSocket.cpp index 3e3abadc2e5a..5d21f800fb09 100644 --- a/source/Host/posix/DomainSocket.cpp +++ b/source/Host/posix/DomainSocket.cpp @@ -1,9 +1,8 @@ //===-- DomainSocket.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/posix/FileSystem.cpp b/source/Host/posix/FileSystem.cpp index 60be642df608..65791cb4c421 100644 --- a/source/Host/posix/FileSystem.cpp +++ b/source/Host/posix/FileSystem.cpp @@ -1,9 +1,8 @@ //===-- FileSystem.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,6 +10,7 @@ // C includes #include +#include #include #include #include @@ -47,7 +47,7 @@ Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { error.SetErrorToErrno(); else { buf[count] = '\0'; // Success - dst.SetFile(buf, false, FileSpec::Style::native); + dst.SetFile(buf, FileSpec::Style::native); } return error; } @@ -65,7 +65,7 @@ Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { return err; } - dst = FileSpec(real_path, false); + dst = FileSpec(real_path); return Status(); } @@ -73,3 +73,7 @@ Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) { FILE *FileSystem::Fopen(const char *path, const char *mode) { return ::fopen(path, mode); } + +int FileSystem::Open(const char *path, int flags, int mode) { + return ::open(path, flags, mode); +} diff --git a/source/Host/posix/HostInfoPosix.cpp b/source/Host/posix/HostInfoPosix.cpp index 002f40f9f7cc..7b21c5b9325a 100644 --- a/source/Host/posix/HostInfoPosix.cpp +++ b/source/Host/posix/HostInfoPosix.cpp @@ -1,9 +1,8 @@ //===-- HostInfoPosix.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -119,7 +118,7 @@ uint32_t HostInfoPosix::GetEffectiveUserID() { return geteuid(); } uint32_t HostInfoPosix::GetEffectiveGroupID() { return getegid(); } -FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh", false); } +FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); } bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec, llvm::StringRef dir) { @@ -175,7 +174,7 @@ bool HostInfoPosix::ComputeSupportExeDirectory(FileSpec &file_spec) { } bool HostInfoPosix::ComputeHeaderDirectory(FileSpec &file_spec) { - FileSpec temp_file("/opt/local/include/lldb", false); + FileSpec temp_file("/opt/local/include/lldb"); file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str()); return true; } diff --git a/source/Host/posix/HostProcessPosix.cpp b/source/Host/posix/HostProcessPosix.cpp index f383bde2fbef..bfc7afba417e 100644 --- a/source/Host/posix/HostProcessPosix.cpp +++ b/source/Host/posix/HostProcessPosix.cpp @@ -1,9 +1,8 @@ //===-- HostProcessPosix.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -62,7 +61,7 @@ Status HostProcessPosix::GetMainModule(FileSpec &file_spec) const { return error; } - error = FileSystem::Readlink(FileSpec{link_path, false}, file_spec); + error = FileSystem::Instance().Readlink(FileSpec(link_path), file_spec); if (!error.Success()) return error; diff --git a/source/Host/posix/HostThreadPosix.cpp b/source/Host/posix/HostThreadPosix.cpp index 13de42f763ec..caa137ae3d02 100644 --- a/source/Host/posix/HostThreadPosix.cpp +++ b/source/Host/posix/HostThreadPosix.cpp @@ -1,9 +1,8 @@ //===-- HostThreadPosix.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/posix/LockFilePosix.cpp b/source/Host/posix/LockFilePosix.cpp index 05423062bd44..0dc9bd5e34f3 100644 --- a/source/Host/posix/LockFilePosix.cpp +++ b/source/Host/posix/LockFilePosix.cpp @@ -1,9 +1,8 @@ //===-- LockFilePosix.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/posix/PipePosix.cpp b/source/Host/posix/PipePosix.cpp index b321cad64275..40d616e15ba5 100644 --- a/source/Host/posix/PipePosix.cpp +++ b/source/Host/posix/PipePosix.cpp @@ -1,9 +1,8 @@ //===-- PipePosix.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -61,12 +60,13 @@ bool SetCloexecFlag(int fd) { std::chrono::time_point Now() { return std::chrono::steady_clock::now(); } -} +} // namespace PipePosix::PipePosix() : m_fds{PipePosix::kInvalidDescriptor, PipePosix::kInvalidDescriptor} {} -PipePosix::PipePosix(int read_fd, int write_fd) : m_fds{read_fd, write_fd} {} +PipePosix::PipePosix(lldb::pipe_t read, lldb::pipe_t write) + : m_fds{read, write} {} PipePosix::PipePosix(PipePosix &&pipe_posix) : PipeBase{std::move(pipe_posix)}, @@ -125,8 +125,8 @@ Status PipePosix::CreateNew(llvm::StringRef name, bool child_process_inherit) { Status PipePosix::CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl &name) { - llvm::SmallString named_pipe_path; - llvm::SmallString pipe_spec((prefix + ".%%%%%%").str()); + llvm::SmallString<128> named_pipe_path; + llvm::SmallString<128> pipe_spec((prefix + ".%%%%%%").str()); FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir(); if (!tmpdir_file_spec) tmpdir_file_spec.AppendPathComponent("/tmp"); diff --git a/source/Host/posix/ProcessLauncherPosixFork.cpp b/source/Host/posix/ProcessLauncherPosixFork.cpp index 46ce3e3d224f..bc1ac78f6991 100644 --- a/source/Host/posix/ProcessLauncherPosixFork.cpp +++ b/source/Host/posix/ProcessLauncherPosixFork.cpp @@ -1,9 +1,8 @@ //===-- ProcessLauncherLinux.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -157,7 +156,7 @@ static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd, #if defined(__linux__) if (errno == ETXTBSY) { - // On android M and earlier we can get this error because the adb deamon + // On android M and earlier we can get this error because the adb daemon // can hold a write handle on the executable even after it has finished // uploading it. This state lasts only a short time and happens only when // there are many concurrent adb commands being issued, such as when diff --git a/source/Host/windows/ConnectionGenericFileWindows.cpp b/source/Host/windows/ConnectionGenericFileWindows.cpp index e59e190dcb2d..66cb59da2a67 100644 --- a/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -1,9 +1,8 @@ //===-- ConnectionGenericFileWindows.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/windows/EditLineWin.cpp b/source/Host/windows/EditLineWin.cpp index 3bccc4e1a2c9..67a7d5417269 100644 --- a/source/Host/windows/EditLineWin.cpp +++ b/source/Host/windows/EditLineWin.cpp @@ -1,9 +1,8 @@ //===-- EditLineWin.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/windows/FileSystem.cpp b/source/Host/windows/FileSystem.cpp index 9309b89f2baf..04dba4476295 100644 --- a/source/Host/windows/FileSystem.cpp +++ b/source/Host/windows/FileSystem.cpp @@ -1,9 +1,8 @@ //===-- FileSystem.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -75,7 +74,7 @@ Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) { else if (!llvm::convertWideToUTF8(buf.data(), path)) error.SetErrorString(PATH_CONVERSION_ERROR); else - dst.SetFile(path, false, FileSpec::Style::native); + dst.SetFile(path, FileSpec::Style::native); ::CloseHandle(h); return error; @@ -96,3 +95,12 @@ FILE *FileSystem::Fopen(const char *path, const char *mode) { return nullptr; return file; } + +int FileSystem::Open(const char *path, int flags, int mode) { + std::wstring wpath; + if (!llvm::ConvertUTF8toWide(path, wpath)) + return -1; + int result; + ::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode); + return result; +} diff --git a/source/Host/windows/Host.cpp b/source/Host/windows/Host.cpp index cc6c454d36b1..32ea39ae1cbb 100644 --- a/source/Host/windows/Host.cpp +++ b/source/Host/windows/Host.cpp @@ -1,20 +1,16 @@ //===-- source/Host/windows/Host.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include "lldb/Host/windows/AutoHandle.h" #include "lldb/Host/windows/windows.h" #include -// C++ Includes -// Other libraries and framework includes -// Project includes +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" @@ -36,8 +32,9 @@ namespace { bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { // Open the PE File as a binary file, and parse just enough information to // determine the machine type. - File imageBinary(executable.GetPath().c_str(), File::eOpenOptionRead, - lldb::eFilePermissionsUserRead); + File imageBinary; + FileSystem::Instance().Open(imageBinary, executable, File::eOpenOptionRead, + lldb::eFilePermissionsUserRead); imageBinary.SeekFromStart(0x3c); int32_t peOffset = 0; uint32_t peHead = 0; @@ -83,7 +80,7 @@ void GetProcessExecutableAndTriple(const AutoHandle &handle, triple.setOS(llvm::Triple::Win32); triple.setArch(llvm::Triple::UnknownArch); if (GetExecutableForProcess(handle, executable)) { - FileSpec executableFile(executable.c_str(), false); + FileSpec executableFile(executable.c_str()); process.SetExecutableFile(executableFile, true); GetTripleForProcess(executableFile, triple); } @@ -122,7 +119,7 @@ FileSpec Host::GetModuleFileSpecForHostAddress(const void *host_addr) { std::string path; if (!llvm::convertWideToUTF8(buffer.data(), path)) return module_filespec; - module_filespec.SetFile(path, false, FileSpec::Style::native); + module_filespec.SetFile(path, FileSpec::Style::native); return module_filespec; } @@ -145,7 +142,7 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfo process; std::string exeFile; llvm::convertWideToUTF8(pe.szExeFile, exeFile); - process.SetExecutableFile(FileSpec(exeFile, false), true); + process.SetExecutableFile(FileSpec(exeFile), true); process.SetProcessID(pe.th32ProcessID); process.SetParentProcessID(pe.th32ParentProcessID); GetProcessExecutableAndTriple(handle, process); @@ -189,7 +186,7 @@ Status Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { return error; } expand_tool_spec.AppendPathComponent("lldb-argdumper.exe"); - if (!expand_tool_spec.Exists()) { + if (!FileSystem::Instance().Exists(expand_tool_spec)) { error.SetErrorString("could not find the lldb-argdumper tool"); return error; } diff --git a/source/Host/windows/HostInfoWindows.cpp b/source/Host/windows/HostInfoWindows.cpp index 0a7c76c841bc..dfdfc73d9d1f 100644 --- a/source/Host/windows/HostInfoWindows.cpp +++ b/source/Host/windows/HostInfoWindows.cpp @@ -1,9 +1,8 @@ //===-- HostInfoWindows.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,7 +10,7 @@ #include -#include // std::once +#include #include "lldb/Host/windows/HostInfoWindows.h" #include "lldb/Host/windows/PosixApi.h" @@ -92,7 +91,7 @@ FileSpec HostInfoWindows::GetProgramFileSpec() { ::GetModuleFileNameW(NULL, buffer.data(), buffer.size()); std::string path; llvm::convertWideToUTF8(buffer.data(), path); - m_program_filespec.SetFile(path, false, FileSpec::Style::native); + m_program_filespec.SetFile(path, FileSpec::Style::native); }); return m_program_filespec; } @@ -103,9 +102,9 @@ FileSpec HostInfoWindows::GetDefaultShell() { std::string shell; if (GetEnvironmentVar("ComSpec", shell)) - return FileSpec(shell, false); + return FileSpec(shell); - return FileSpec("C:\\Windows\\system32\\cmd.exe", false); + return FileSpec("C:\\Windows\\system32\\cmd.exe"); } bool HostInfoWindows::GetEnvironmentVar(const std::string &var_name, diff --git a/source/Host/windows/HostProcessWindows.cpp b/source/Host/windows/HostProcessWindows.cpp index ce75c14cdcf4..6b016bf53dab 100644 --- a/source/Host/windows/HostProcessWindows.cpp +++ b/source/Host/windows/HostProcessWindows.cpp @@ -1,9 +1,8 @@ //===-- HostProcessWindows.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -57,7 +56,7 @@ Status HostProcessWindows::GetMainModule(FileSpec &file_spec) const { if (::GetProcessImageFileNameW(m_process, wpath.data(), wpath.size())) { std::string path; if (llvm::convertWideToUTF8(wpath.data(), path)) - file_spec.SetFile(path, false, FileSpec::Style::native); + file_spec.SetFile(path, FileSpec::Style::native); else error.SetErrorString("Error converting path to UTF-8"); } else diff --git a/source/Host/windows/HostThreadWindows.cpp b/source/Host/windows/HostThreadWindows.cpp index 3d603ff61663..3eaaee280890 100644 --- a/source/Host/windows/HostThreadWindows.cpp +++ b/source/Host/windows/HostThreadWindows.cpp @@ -1,9 +1,8 @@ //===-- HostThreadWindows.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -69,3 +68,7 @@ void HostThreadWindows::Reset() { HostNativeThreadBase::Reset(); } + +bool HostThreadWindows::EqualsThread(lldb::thread_t thread) const { + return GetThreadId() == ::GetThreadId(thread); +} diff --git a/source/Host/windows/LockFileWindows.cpp b/source/Host/windows/LockFileWindows.cpp index 2178fd1f5f6c..6b82796872e4 100644 --- a/source/Host/windows/LockFileWindows.cpp +++ b/source/Host/windows/LockFileWindows.cpp @@ -1,9 +1,8 @@ //===-- LockFileWindows.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/windows/PipeWindows.cpp b/source/Host/windows/PipeWindows.cpp index 1951c9ca193a..920e5a1029f1 100644 --- a/source/Host/windows/PipeWindows.cpp +++ b/source/Host/windows/PipeWindows.cpp @@ -1,9 +1,8 @@ //===-- PipeWindows.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,14 +24,41 @@ using namespace lldb_private; namespace { std::atomic g_pipe_serial(0); +constexpr llvm::StringLiteral g_pipe_name_prefix = "\\\\.\\Pipe\\"; +} // namespace + +PipeWindows::PipeWindows() + : m_read(INVALID_HANDLE_VALUE), m_write(INVALID_HANDLE_VALUE), + m_read_fd(PipeWindows::kInvalidDescriptor), + m_write_fd(PipeWindows::kInvalidDescriptor) { + ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); + ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); } -PipeWindows::PipeWindows() { - m_read = INVALID_HANDLE_VALUE; - m_write = INVALID_HANDLE_VALUE; +PipeWindows::PipeWindows(pipe_t read, pipe_t write) + : m_read((HANDLE)read), m_write((HANDLE)write), + m_read_fd(PipeWindows::kInvalidDescriptor), + m_write_fd(PipeWindows::kInvalidDescriptor) { + assert(read != LLDB_INVALID_PIPE || write != LLDB_INVALID_PIPE); + + // Don't risk in passing file descriptors and getting handles from them by + // _get_osfhandle since the retrieved handles are highly likely unrecognized + // in the current process and usually crashes the program. Pass handles + // instead since the handle can be inherited. + + if (read != LLDB_INVALID_PIPE) { + m_read_fd = _open_osfhandle((intptr_t)read, _O_RDONLY); + // Make sure the fd and native handle are consistent. + if (m_read_fd < 0) + m_read = INVALID_HANDLE_VALUE; + } + + if (write != LLDB_INVALID_PIPE) { + m_write_fd = _open_osfhandle((intptr_t)write, _O_WRONLY); + if (m_write_fd < 0) + m_write = INVALID_HANDLE_VALUE; + } - m_read_fd = -1; - m_write_fd = -1; ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); } @@ -40,6 +66,24 @@ PipeWindows::PipeWindows() { PipeWindows::~PipeWindows() { Close(); } Status PipeWindows::CreateNew(bool child_process_inherit) { + // Create an anonymous pipe with the specified inheritance. + SECURITY_ATTRIBUTES sa{sizeof(SECURITY_ATTRIBUTES), 0, + child_process_inherit ? TRUE : FALSE}; + BOOL result = ::CreatePipe(&m_read, &m_write, &sa, 1024); + if (result == FALSE) + return Status(::GetLastError(), eErrorTypeWin32); + + m_read_fd = _open_osfhandle((intptr_t)m_read, _O_RDONLY); + ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); + m_read_overlapped.hEvent = ::CreateEventA(nullptr, TRUE, FALSE, nullptr); + + m_write_fd = _open_osfhandle((intptr_t)m_write, _O_WRONLY); + ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); + + return Status(); +} + +Status PipeWindows::CreateNewNamed(bool child_process_inherit) { // Even for anonymous pipes, we open a named pipe. This is because you // cannot get overlapped i/o on Windows without using a named pipe. So we // synthesize a unique name. @@ -60,7 +104,7 @@ Status PipeWindows::CreateNew(llvm::StringRef name, if (CanRead() || CanWrite()) return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); - std::string pipe_path = "\\\\.\\Pipe\\"; + std::string pipe_path = g_pipe_name_prefix; pipe_path.append(name); // Always open for overlapped i/o. We implement blocking manually in Read @@ -75,7 +119,8 @@ Status PipeWindows::CreateNew(llvm::StringRef name, ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); m_read_overlapped.hEvent = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); - // Open the write end of the pipe. + // Open the write end of the pipe. Note that closing either the read or + // write end of the pipe could directly close the pipe itself. Status result = OpenNamedPipe(name, child_process_inherit, false); if (!result.Success()) { CloseReadFileDescriptor(); @@ -111,7 +156,7 @@ Status PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, Status PipeWindows::OpenAsReader(llvm::StringRef name, bool child_process_inherit) { - if (CanRead() || CanWrite()) + if (CanRead()) return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); return OpenNamedPipe(name, child_process_inherit, true); @@ -121,7 +166,7 @@ Status PipeWindows::OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) { - if (CanRead() || CanWrite()) + if (CanWrite()) return Status(ERROR_ALREADY_EXISTS, eErrorTypeWin32); return OpenNamedPipe(name, child_process_inherit, false); @@ -137,7 +182,7 @@ Status PipeWindows::OpenNamedPipe(llvm::StringRef name, SECURITY_ATTRIBUTES attributes = {}; attributes.bInheritHandle = child_process_inherit; - std::string pipe_path = "\\\\.\\Pipe\\"; + std::string pipe_path = g_pipe_name_prefix; pipe_path.append(name); if (is_read) { @@ -170,9 +215,9 @@ int PipeWindows::GetWriteFileDescriptor() const { return m_write_fd; } int PipeWindows::ReleaseReadFileDescriptor() { if (!CanRead()) - return -1; + return PipeWindows::kInvalidDescriptor; int result = m_read_fd; - m_read_fd = -1; + m_read_fd = PipeWindows::kInvalidDescriptor; if (m_read_overlapped.hEvent) ::CloseHandle(m_read_overlapped.hEvent); m_read = INVALID_HANDLE_VALUE; @@ -182,9 +227,9 @@ int PipeWindows::ReleaseReadFileDescriptor() { int PipeWindows::ReleaseWriteFileDescriptor() { if (!CanWrite()) - return -1; + return PipeWindows::kInvalidDescriptor; int result = m_write_fd; - m_write_fd = -1; + m_write_fd = PipeWindows::kInvalidDescriptor; m_write = INVALID_HANDLE_VALUE; ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); return result; @@ -196,9 +241,10 @@ void PipeWindows::CloseReadFileDescriptor() { if (m_read_overlapped.hEvent) ::CloseHandle(m_read_overlapped.hEvent); + _close(m_read_fd); m_read = INVALID_HANDLE_VALUE; - m_read_fd = -1; + m_read_fd = PipeWindows::kInvalidDescriptor; ZeroMemory(&m_read_overlapped, sizeof(m_read_overlapped)); } @@ -208,7 +254,7 @@ void PipeWindows::CloseWriteFileDescriptor() { _close(m_write_fd); m_write = INVALID_HANDLE_VALUE; - m_write_fd = -1; + m_write_fd = PipeWindows::kInvalidDescriptor; ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped)); } diff --git a/source/Host/windows/ProcessLauncherWindows.cpp b/source/Host/windows/ProcessLauncherWindows.cpp index 553dd9d286da..b66dff9d11d6 100644 --- a/source/Host/windows/ProcessLauncherWindows.cpp +++ b/source/Host/windows/ProcessLauncherWindows.cpp @@ -1,9 +1,8 @@ //===-- ProcessLauncherWindows.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -76,6 +75,9 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info, if (launch_info.GetFlags().Test(eLaunchFlagDebug)) flags |= DEBUG_ONLY_THIS_PROCESS; + if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO)) + flags &= ~CREATE_NEW_CONSOLE; + LPVOID env_block = nullptr; ::CreateEnvironmentBuffer(launch_info.GetEnvironment(), environment); if (!environment.empty()) diff --git a/source/Host/windows/ProcessRunLock.cpp b/source/Host/windows/ProcessRunLock.cpp index 64276917fc81..85df7826f167 100644 --- a/source/Host/windows/ProcessRunLock.cpp +++ b/source/Host/windows/ProcessRunLock.cpp @@ -1,9 +1,8 @@ //===-- ProcessRunLock.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Host/windows/Windows.cpp b/source/Host/windows/Windows.cpp index 9d0e70e6d126..82f283e2fd45 100644 --- a/source/Host/windows/Windows.cpp +++ b/source/Host/windows/Windows.cpp @@ -1,9 +1,8 @@ //===-- Windows.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Initialization/SystemInitializer.cpp b/source/Initialization/SystemInitializer.cpp index 4a8e10caef9f..1e40c2694464 100644 --- a/source/Initialization/SystemInitializer.cpp +++ b/source/Initialization/SystemInitializer.cpp @@ -1,9 +1,8 @@ //===-- SystemInitializer.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Initialization/SystemInitializerCommon.cpp b/source/Initialization/SystemInitializerCommon.cpp index 54d08b94e022..e14c507ef43d 100644 --- a/source/Initialization/SystemInitializerCommon.cpp +++ b/source/Initialization/SystemInitializerCommon.cpp @@ -1,9 +1,8 @@ //===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -19,11 +18,13 @@ #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h" #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/SwiftASTContext.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Reproducer.h" #include "lldb/Utility/Timer.h" #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) @@ -40,12 +41,14 @@ #include using namespace lldb_private; +using namespace lldb_private::repro; SystemInitializerCommon::SystemInitializerCommon() {} SystemInitializerCommon::~SystemInitializerCommon() {} -void SystemInitializerCommon::Initialize() { +llvm::Error +SystemInitializerCommon::Initialize(const InitializerOptions &options) { #if defined(_MSC_VER) const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG"); if (disable_crash_dialog_var && @@ -68,6 +71,33 @@ void SystemInitializerCommon::Initialize() { } #endif + // Initialize the reproducer. + ReproducerMode mode = ReproducerMode::Off; + if (options.reproducer_capture) + mode = ReproducerMode::Capture; + if (options.reproducer_replay) + mode = ReproducerMode::Replay; + + if (auto e = Reproducer::Initialize(mode, FileSpec(options.reproducer_path))) + return e; + + // Initialize the file system. + auto &r = repro::Reproducer::Instance(); + if (repro::Loader *loader = r.GetLoader()) { + FileSpec vfs_mapping = loader->GetFile(); + if (vfs_mapping) { + if (llvm::Error e = FileSystem::Initialize(vfs_mapping)) + return e; + } else { + FileSystem::Initialize(); + } + } else if (repro::Generator *g = r.GetGenerator()) { + repro::FileProvider &fp = g->GetOrCreate(); + FileSystem::Initialize(fp.GetFileCollector()); + } else { + FileSystem::Initialize(); + } + Log::Initialize(); HostInfo::Initialize(); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); @@ -98,6 +128,8 @@ void SystemInitializerCommon::Initialize() { #if defined(_MSC_VER) ProcessWindowsLog::Initialize(); #endif + + return llvm::Error::success(); } void SystemInitializerCommon::Terminate() { @@ -122,4 +154,6 @@ void SystemInitializerCommon::Terminate() { HostInfo::Terminate(); Log::DisableAllLogChannels(); + FileSystem::Terminate(); + Reproducer::Terminate(); } diff --git a/source/Initialization/SystemLifetimeManager.cpp b/source/Initialization/SystemLifetimeManager.cpp index 4d271787833d..97e696bb5907 100644 --- a/source/Initialization/SystemLifetimeManager.cpp +++ b/source/Initialization/SystemLifetimeManager.cpp @@ -1,9 +1,8 @@ //===-- SystemLifetimeManager.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -24,9 +23,9 @@ SystemLifetimeManager::~SystemLifetimeManager() { "SystemLifetimeManager destroyed without calling Terminate!"); } -void SystemLifetimeManager::Initialize( +llvm::Error SystemLifetimeManager::Initialize( std::unique_ptr initializer, - LoadPluginCallbackType plugin_callback) { + const InitializerOptions &options, LoadPluginCallbackType plugin_callback) { std::lock_guard guard(m_mutex); if (!m_initialized) { assert(!m_initializer && "Attempting to call " @@ -35,9 +34,13 @@ void SystemLifetimeManager::Initialize( m_initialized = true; m_initializer = std::move(initializer); - m_initializer->Initialize(); + if (auto e = m_initializer->Initialize(options)) + return e; + Debugger::Initialize(plugin_callback); } + + return llvm::Error::success(); } void SystemLifetimeManager::Terminate() { diff --git a/source/Interpreter/CMakeLists.txt b/source/Interpreter/CMakeLists.txt index aaa335af39f9..f8fed8b4ac14 100644 --- a/source/Interpreter/CMakeLists.txt +++ b/source/Interpreter/CMakeLists.txt @@ -55,3 +55,7 @@ add_lldb_library(lldbInterpreter LINK_COMPONENTS Support ) + +if (NOT LLDB_DISABLE_LIBEDIT) + target_include_directories(lldbInterpreter PRIVATE ${libedit_INCLUDE_DIRS}) +endif() \ No newline at end of file diff --git a/source/Interpreter/CommandAlias.cpp b/source/Interpreter/CommandAlias.cpp index a4b0a0c55c0e..7d159a3baa07 100644 --- a/source/Interpreter/CommandAlias.cpp +++ b/source/Interpreter/CommandAlias.cpp @@ -1,9 +1,8 @@ //===-- CommandAlias.cpp -----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -158,8 +157,7 @@ void CommandAlias::GetAliasExpansion(StreamString &help_string) const { help_string.Printf(" %s", value.c_str()); } else { help_string.Printf(" %s", opt.c_str()); - if ((value.compare("") != 0) && - (value.compare("AppendString(cmd_str); + if (descriptions) + descriptions->AppendString(command_sp->GetHelp()); } return command_sp; @@ -986,16 +992,16 @@ bool CommandInterpreter::AddUserCommand(llvm::StringRef name, if (!name.empty()) { // do not allow replacement of internal commands if (CommandExists(name)) { - if (can_replace == false) + if (!can_replace) return false; - if (m_command_dict[name]->IsRemovable() == false) + if (!m_command_dict[name]->IsRemovable()) return false; } if (UserCommandExists(name)) { - if (can_replace == false) + if (!can_replace) return false; - if (m_user_dict[name]->IsRemovable() == false) + if (!m_user_dict[name]->IsRemovable()) return false; } @@ -1048,10 +1054,12 @@ CommandObjectSP CommandInterpreter::GetCommandSPExact(llvm::StringRef cmd_str, return ret_val; } -CommandObject *CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str, - StringList *matches) const { +CommandObject * +CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str, + StringList *matches, + StringList *descriptions) const { CommandObject *command_obj = - GetCommandSP(cmd_str, false, true, matches).get(); + GetCommandSP(cmd_str, false, true, matches, descriptions).get(); // If we didn't find an exact match to the command string in the commands, // look in the aliases. @@ -1059,7 +1067,7 @@ CommandObject *CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str, if (command_obj) return command_obj; - command_obj = GetCommandSP(cmd_str, true, true, matches).get(); + command_obj = GetCommandSP(cmd_str, true, true, matches, descriptions).get(); if (command_obj) return command_obj; @@ -1074,10 +1082,12 @@ CommandObject *CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str, if (command_obj) { if (matches) matches->AppendString(command_obj->GetCommandName()); + if (descriptions) + descriptions->AppendString(command_obj->GetHelp()); return command_obj; } - return GetCommandSP(cmd_str, true, false, matches).get(); + return GetCommandSP(cmd_str, true, false, matches, descriptions).get(); } bool CommandInterpreter::CommandExists(llvm::StringRef cmd) const { @@ -1388,7 +1398,7 @@ CommandObject *CommandInterpreter::BuildAliasResult( alias_cmd_obj = desugared.first.get(); std::string alias_name_str = alias_name; if ((cmd_args.GetArgumentCount() == 0) || - (alias_name_str.compare(cmd_args.GetArgumentAtIndex(0)) != 0)) + (alias_name_str != cmd_args.GetArgumentAtIndex(0))) cmd_args.Unshift(alias_name_str); result_str.Printf("%s", alias_cmd_obj->GetCommandName().str().c_str()); @@ -1450,130 +1460,140 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) { size_t start_backtick; size_t pos = 0; while ((start_backtick = command.find('`', pos)) != std::string::npos) { + // Stop if an error was encountered during the previous iteration. + if (error.Fail()) + break; + if (start_backtick > 0 && command[start_backtick - 1] == '\\') { // The backtick was preceded by a '\' character, remove the slash and - // don't treat the backtick as the start of an expression + // don't treat the backtick as the start of an expression. command.erase(start_backtick - 1, 1); - // No need to add one to start_backtick since we just deleted a char + // No need to add one to start_backtick since we just deleted a char. pos = start_backtick; - } else { - const size_t expr_content_start = start_backtick + 1; - const size_t end_backtick = command.find('`', expr_content_start); - if (end_backtick == std::string::npos) - return error; - else if (end_backtick == expr_content_start) { - // Empty expression (two backticks in a row) - command.erase(start_backtick, 2); - } else { - std::string expr_str(command, expr_content_start, - end_backtick - expr_content_start); - - ExecutionContext exe_ctx(GetExecutionContext()); - Target *target = exe_ctx.GetTargetPtr(); - // Get a dummy target to allow for calculator mode while processing - // backticks. This also helps break the infinite loop caused when - // target is null. - if (!target) - target = m_debugger.GetDummyTarget(); - if (target) { - ValueObjectSP expr_result_valobj_sp; - - EvaluateExpressionOptions options; - options.SetCoerceToId(false); - options.SetUnwindOnError(true); - options.SetIgnoreBreakpoints(true); - options.SetKeepInMemory(false); - options.SetTryAllThreads(true); - options.SetTimeout(llvm::None); - - ExpressionResults expr_result = target->EvaluateExpression( - expr_str.c_str(), exe_ctx.GetFramePtr(), expr_result_valobj_sp, - options); - - if (expr_result == eExpressionCompleted) { - Scalar scalar; - if (expr_result_valobj_sp) - expr_result_valobj_sp = - expr_result_valobj_sp->GetQualifiedRepresentationIfAvailable( - expr_result_valobj_sp->GetDynamicValueType(), true); - if (expr_result_valobj_sp->ResolveValue(scalar)) { - command.erase(start_backtick, end_backtick - start_backtick + 1); - StreamString value_strm; - const bool show_type = false; - scalar.GetValue(&value_strm, show_type); - size_t value_string_size = value_strm.GetSize(); - if (value_string_size) { - command.insert(start_backtick, value_strm.GetString()); - pos = start_backtick + value_string_size; - continue; - } else { - error.SetErrorStringWithFormat("expression value didn't result " - "in a scalar value for the " - "expression '%s'", - expr_str.c_str()); - } - } else { - error.SetErrorStringWithFormat("expression value didn't result " - "in a scalar value for the " - "expression '%s'", - expr_str.c_str()); - } - } else { - if (expr_result_valobj_sp) - error = expr_result_valobj_sp->GetError(); - if (error.Success()) { - - switch (expr_result) { - case eExpressionSetupError: - error.SetErrorStringWithFormat( - "expression setup error for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionParseError: - error.SetErrorStringWithFormat( - "expression parse error for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionResultUnavailable: - error.SetErrorStringWithFormat( - "expression error fetching result for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionCompleted: - break; - case eExpressionDiscarded: - error.SetErrorStringWithFormat( - "expression discarded for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionInterrupted: - error.SetErrorStringWithFormat( - "expression interrupted for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionHitBreakpoint: - error.SetErrorStringWithFormat( - "expression hit breakpoint for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionTimedOut: - error.SetErrorStringWithFormat( - "expression timed out for the expression '%s'", - expr_str.c_str()); - break; - case eExpressionStoppedForDebug: - error.SetErrorStringWithFormat("expression stop at entry point " - "for debugging for the " - "expression '%s'", - expr_str.c_str()); - break; - } - } - } + continue; + } + + const size_t expr_content_start = start_backtick + 1; + const size_t end_backtick = command.find('`', expr_content_start); + + if (end_backtick == std::string::npos) { + // Stop if there's no end backtick. + break; + } + + if (end_backtick == expr_content_start) { + // Skip over empty expression. (two backticks in a row) + command.erase(start_backtick, 2); + continue; + } + + std::string expr_str(command, expr_content_start, + end_backtick - expr_content_start); + + ExecutionContext exe_ctx(GetExecutionContext()); + Target *target = exe_ctx.GetTargetPtr(); + + // Get a dummy target to allow for calculator mode while processing + // backticks. This also helps break the infinite loop caused when target is + // null. + if (!target) + target = m_debugger.GetDummyTarget(); + + if (!target) + continue; + + ValueObjectSP expr_result_valobj_sp; + + EvaluateExpressionOptions options; + options.SetCoerceToId(false); + options.SetUnwindOnError(true); + options.SetIgnoreBreakpoints(true); + options.SetKeepInMemory(false); + options.SetTryAllThreads(true); + options.SetTimeout(llvm::None); + + ExpressionResults expr_result = + target->EvaluateExpression(expr_str.c_str(), exe_ctx.GetFramePtr(), + expr_result_valobj_sp, options); + + if (expr_result == eExpressionCompleted) { + Scalar scalar; + if (expr_result_valobj_sp) + expr_result_valobj_sp = + expr_result_valobj_sp->GetQualifiedRepresentationIfAvailable( + expr_result_valobj_sp->GetDynamicValueType(), true); + if (expr_result_valobj_sp->ResolveValue(scalar)) { + command.erase(start_backtick, end_backtick - start_backtick + 1); + StreamString value_strm; + const bool show_type = false; + scalar.GetValue(&value_strm, show_type); + size_t value_string_size = value_strm.GetSize(); + if (value_string_size) { + command.insert(start_backtick, value_strm.GetString()); + pos = start_backtick + value_string_size; + continue; + } else { + error.SetErrorStringWithFormat("expression value didn't result " + "in a scalar value for the " + "expression '%s'", + expr_str.c_str()); + break; } + } else { + error.SetErrorStringWithFormat("expression value didn't result " + "in a scalar value for the " + "expression '%s'", + expr_str.c_str()); + break; } - if (error.Fail()) + + continue; + } + + if (expr_result_valobj_sp) + error = expr_result_valobj_sp->GetError(); + + if (error.Success()) { + switch (expr_result) { + case eExpressionSetupError: + error.SetErrorStringWithFormat( + "expression setup error for the expression '%s'", expr_str.c_str()); + break; + case eExpressionParseError: + error.SetErrorStringWithFormat( + "expression parse error for the expression '%s'", expr_str.c_str()); + break; + case eExpressionResultUnavailable: + error.SetErrorStringWithFormat( + "expression error fetching result for the expression '%s'", + expr_str.c_str()); + break; + case eExpressionCompleted: + break; + case eExpressionDiscarded: + error.SetErrorStringWithFormat( + "expression discarded for the expression '%s'", expr_str.c_str()); + break; + case eExpressionInterrupted: + error.SetErrorStringWithFormat( + "expression interrupted for the expression '%s'", expr_str.c_str()); break; + case eExpressionHitBreakpoint: + error.SetErrorStringWithFormat( + "expression hit breakpoint for the expression '%s'", + expr_str.c_str()); + break; + case eExpressionTimedOut: + error.SetErrorStringWithFormat( + "expression timed out for the expression '%s'", expr_str.c_str()); + break; + case eExpressionStoppedForDebug: + error.SetErrorStringWithFormat("expression stop at entry point " + "for debugging for the " + "expression '%s'", + expr_str.c_str()); + break; + } } } return error; @@ -1763,16 +1783,17 @@ int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) { if (request.GetCursorIndex() == -1) { // We got nothing on the command line, so return the list of commands bool include_aliases = true; - StringList new_matches; - num_command_matches = - GetCommandNamesMatchingPartialString("", include_aliases, new_matches); - request.AddCompletions(new_matches); + StringList new_matches, descriptions; + num_command_matches = GetCommandNamesMatchingPartialString( + "", include_aliases, new_matches, descriptions); + request.AddCompletions(new_matches, descriptions); } else if (request.GetCursorIndex() == 0) { // The cursor is in the first argument, so just do a lookup in the // dictionary. - StringList new_matches; - CommandObject *cmd_obj = GetCommandObject( - request.GetParsedLine().GetArgumentAtIndex(0), &new_matches); + StringList new_matches, new_descriptions; + CommandObject *cmd_obj = + GetCommandObject(request.GetParsedLine().GetArgumentAtIndex(0), + &new_matches, &new_descriptions); if (num_command_matches == 1 && cmd_obj && cmd_obj->IsMultiwordObject() && new_matches.GetStringAtIndex(0) != nullptr && @@ -1784,12 +1805,13 @@ int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) { look_for_subcommand = true; num_command_matches = 0; new_matches.DeleteStringAtIndex(0); + new_descriptions.DeleteStringAtIndex(0); request.GetParsedLine().AppendArgument(llvm::StringRef()); request.SetCursorIndex(request.GetCursorIndex() + 1); request.SetCursorCharPosition(0); } } - request.AddCompletions(new_matches); + request.AddCompletions(new_matches, new_descriptions); num_command_matches = request.GetNumberOfMatches(); } @@ -1813,12 +1835,13 @@ int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) { int CommandInterpreter::HandleCompletion( const char *current_line, const char *cursor, const char *last_char, - int match_start_point, int max_return_elements, StringList &matches) { + int match_start_point, int max_return_elements, StringList &matches, + StringList &descriptions) { llvm::StringRef command_line(current_line, last_char - current_line); + CompletionResult result; CompletionRequest request(command_line, cursor - current_line, - match_start_point, max_return_elements, matches); - + match_start_point, max_return_elements, result); // Don't complete comments, and if the line we are completing is just the // history repeat character, substitute the appropriate history line. const char *first_arg = request.GetParsedLine().GetArgumentAtIndex(0); @@ -1828,6 +1851,7 @@ int CommandInterpreter::HandleCompletion( else if (first_arg[0] == CommandHistory::g_repeat_char) { if (auto hist_str = m_command_history.FindString(first_arg)) { matches.InsertStringAtIndex(0, *hist_str); + descriptions.InsertStringAtIndex(0, "Previous command history event"); return -2; } else return 0; @@ -1838,6 +1862,8 @@ int CommandInterpreter::HandleCompletion( lldbassert(max_return_elements == -1); int num_command_matches = HandleCompletionMatches(request); + result.GetMatches(matches); + result.GetDescriptions(descriptions); if (num_command_matches <= 0) return num_command_matches; @@ -1845,6 +1871,7 @@ int CommandInterpreter::HandleCompletion( if (request.GetParsedLine().GetArgumentCount() == 0) { // If we got an empty string, insert nothing. matches.InsertStringAtIndex(0, ""); + descriptions.InsertStringAtIndex(0, ""); } else { // Now figure out if there is a common substring, and if so put that in // element 0, otherwise put an empty string in element 0. @@ -1866,6 +1893,7 @@ int CommandInterpreter::HandleCompletion( common_prefix.push_back(' '); } matches.InsertStringAtIndex(0, common_prefix.c_str()); + descriptions.InsertStringAtIndex(0, ""); } return num_command_matches; } @@ -1924,7 +1952,7 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj, // Make sure that the alias name is the 0th element in cmd_args std::string alias_name_str = alias_name; - if (alias_name_str.compare(cmd_args.GetArgumentAtIndex(0)) != 0) + if (alias_name_str != cmd_args.GetArgumentAtIndex(0)) cmd_args.Unshift(alias_name_str); Args new_args(alias_cmd_obj->GetCommandName()); @@ -2076,13 +2104,14 @@ void CommandInterpreter::SourceInitFile(bool in_cwd, LoadCWDlldbinitFile should_load = target->TargetProperties::GetLoadCWDlldbinitFile(); if (should_load == eLoadCWDlldbinitWarn) { - FileSpec dot_lldb(".lldbinit", true); + FileSpec dot_lldb(".lldbinit"); + FileSystem::Instance().Resolve(dot_lldb); llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec homedir_dot_lldb(home_dir_path.c_str(), false); + FileSpec homedir_dot_lldb(home_dir_path.c_str()); homedir_dot_lldb.AppendPathComponent(".lldbinit"); - homedir_dot_lldb.ResolvePath(); - if (dot_lldb.Exists() && + FileSystem::Instance().Resolve(homedir_dot_lldb); + if (FileSystem::Instance().Exists(dot_lldb) && dot_lldb.GetDirectory() != homedir_dot_lldb.GetDirectory()) { result.AppendErrorWithFormat( "There is a .lldbinit file in the current directory which is not " @@ -2100,7 +2129,8 @@ void CommandInterpreter::SourceInitFile(bool in_cwd, return; } } else if (should_load == eLoadCWDlldbinitTrue) { - init_file.SetFile("./.lldbinit", true, FileSpec::Style::native); + init_file.SetFile("./.lldbinit", FileSpec::Style::native); + FileSystem::Instance().Resolve(init_file); } } } else { @@ -2112,11 +2142,11 @@ void CommandInterpreter::SourceInitFile(bool in_cwd, // init files. llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec profilePath(home_dir_path.c_str(), false); + FileSpec profilePath(home_dir_path.c_str()); profilePath.AppendPathComponent(".lldbinit"); std::string init_file_path = profilePath.GetPath(); - if (m_skip_app_init_files == false) { + if (!m_skip_app_init_files) { FileSpec program_file_spec(HostInfo::GetProgramFileSpec()); const char *program_name = program_file_spec.GetFilename().AsCString(); @@ -2124,22 +2154,22 @@ void CommandInterpreter::SourceInitFile(bool in_cwd, char program_init_file_name[PATH_MAX]; ::snprintf(program_init_file_name, sizeof(program_init_file_name), "%s-%s", init_file_path.c_str(), program_name); - init_file.SetFile(program_init_file_name, true, - FileSpec::Style::native); - if (!init_file.Exists()) + init_file.SetFile(program_init_file_name, FileSpec::Style::native); + FileSystem::Instance().Resolve(init_file); + if (!FileSystem::Instance().Exists(init_file)) init_file.Clear(); } } if (!init_file && !m_skip_lldbinit_files) - init_file.SetFile(init_file_path, false, FileSpec::Style::native); + init_file.SetFile(init_file_path, FileSpec::Style::native); } // If the file exists, tell HandleCommand to 'source' it; this will do the // actual broadcasting of the commands back to any appropriate listener (see // CommandObjectSource::Execute for more details). - if (init_file.Exists()) { + if (FileSystem::Instance().Exists(init_file)) { const bool saved_batch = SetBatchCommandMode(true); CommandInterpreterRunOptions options; options.SetSilent(true); @@ -2340,13 +2370,12 @@ enum { void CommandInterpreter::HandleCommandsFromFile( FileSpec &cmd_file, ExecutionContext *context, CommandInterpreterRunOptions &options, CommandReturnObject &result) { - if (cmd_file.Exists()) { + if (FileSystem::Instance().Exists(cmd_file)) { StreamFileSP input_file_sp(new StreamFile()); std::string cmd_file_path = cmd_file.GetPath(); - Status error = input_file_sp->GetFile().Open(cmd_file_path.c_str(), - File::eOpenOptionRead); - + Status error = FileSystem::Instance().Open(input_file_sp->GetFile(), + cmd_file, File::eOpenOptionRead); if (error.Success()) { Debugger &debugger = GetDebugger(); @@ -2376,7 +2405,7 @@ void CommandInterpreter::HandleCommandsFromFile( flags |= eHandleCommandFlagStopOnError; } - // stop-on-crash can only be set, if it is present in all levels of + // stop-on-crash can only be set, if it is present in all levels of // pushed flag sets. if (options.GetStopOnCrash()) { if (m_command_source_flags.empty()) { @@ -2755,7 +2784,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler, return; const bool is_interactive = io_handler.GetIsInteractive(); - if (is_interactive == false) { + if (!is_interactive) { // When we are not interactive, don't execute blank lines. This will happen // sourcing a commands file. We don't want blank lines to repeat the // previous command and cause any errors to occur (like redefining an @@ -3004,8 +3033,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line, bool is_alias = GetAliasFullName(next_word, full_name); cmd_obj = GetCommandObject(next_word, &matches); bool is_real_command = - (is_alias == false) || - (cmd_obj != nullptr && cmd_obj->IsAlias() == false); + (!is_alias) || (cmd_obj != nullptr && !cmd_obj->IsAlias()); if (!is_real_command) { matches.Clear(); std::string alias_result; diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp index 324b0b511220..8255f61aaf4a 100644 --- a/source/Interpreter/CommandObject.cpp +++ b/source/Interpreter/CommandObject.cpp @@ -1,9 +1,8 @@ //===-- CommandObject.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -409,15 +408,12 @@ const char *CommandObject::GetArgumentName(CommandArgumentType arg_type) { } bool CommandObject::IsPairType(ArgumentRepetitionType arg_repeat_type) { - if ((arg_repeat_type == eArgRepeatPairPlain) || - (arg_repeat_type == eArgRepeatPairOptional) || - (arg_repeat_type == eArgRepeatPairPlus) || - (arg_repeat_type == eArgRepeatPairStar) || - (arg_repeat_type == eArgRepeatPairRange) || - (arg_repeat_type == eArgRepeatPairRangeOptional)) - return true; - - return false; + return (arg_repeat_type == eArgRepeatPairPlain) || + (arg_repeat_type == eArgRepeatPairOptional) || + (arg_repeat_type == eArgRepeatPairPlus) || + (arg_repeat_type == eArgRepeatPairStar) || + (arg_repeat_type == eArgRepeatPairRange) || + (arg_repeat_type == eArgRepeatPairRangeOptional); } static CommandObject::CommandArgumentEntry diff --git a/source/Interpreter/CommandObjectRegexCommand.cpp b/source/Interpreter/CommandObjectRegexCommand.cpp index ec89ad8fb162..63afd47eb56e 100644 --- a/source/Interpreter/CommandObjectRegexCommand.cpp +++ b/source/Interpreter/CommandObjectRegexCommand.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectRegexCommand.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/CommandObjectRegexCommand.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" diff --git a/source/Interpreter/CommandObjectScript.cpp b/source/Interpreter/CommandObjectScript.cpp index fa1516df60c9..539449c45a45 100644 --- a/source/Interpreter/CommandObjectScript.cpp +++ b/source/Interpreter/CommandObjectScript.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectScript.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommandObjectScript.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" diff --git a/source/Interpreter/CommandObjectScript.h b/source/Interpreter/CommandObjectScript.h index 7a61b06e5b04..d899bd61dc39 100644 --- a/source/Interpreter/CommandObjectScript.h +++ b/source/Interpreter/CommandObjectScript.h @@ -1,19 +1,14 @@ //===-- CommandObjectScript.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommandObjectScript_h_ #define liblldb_CommandObjectScript_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" namespace lldb_private { diff --git a/source/Interpreter/CommandOptionValidators.cpp b/source/Interpreter/CommandOptionValidators.cpp index 1e614a958c76..c41c1566aab9 100644 --- a/source/Interpreter/CommandOptionValidators.cpp +++ b/source/Interpreter/CommandOptionValidators.cpp @@ -1,9 +1,8 @@ //===-- CommandOptionValidators.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Interpreter/CommandReturnObject.cpp b/source/Interpreter/CommandReturnObject.cpp index 7c06e22c3909..3a7a8755d975 100644 --- a/source/Interpreter/CommandReturnObject.cpp +++ b/source/Interpreter/CommandReturnObject.cpp @@ -1,18 +1,13 @@ //===-- CommandReturnObject.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/CommandReturnObject.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" diff --git a/source/Interpreter/OptionArgParser.cpp b/source/Interpreter/OptionArgParser.cpp index b0565b706c5b..efaac0720fd0 100644 --- a/source/Interpreter/OptionArgParser.cpp +++ b/source/Interpreter/OptionArgParser.cpp @@ -1,9 +1,8 @@ //===-- OptionArgParser.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Interpreter/OptionGroupArchitecture.cpp b/source/Interpreter/OptionGroupArchitecture.cpp index 42eafc9872db..2ee1a9c7cf84 100644 --- a/source/Interpreter/OptionGroupArchitecture.cpp +++ b/source/Interpreter/OptionGroupArchitecture.cpp @@ -1,9 +1,8 @@ //===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Interpreter/OptionGroupBoolean.cpp b/source/Interpreter/OptionGroupBoolean.cpp index 37c63f65995d..8a6482c8df25 100644 --- a/source/Interpreter/OptionGroupBoolean.cpp +++ b/source/Interpreter/OptionGroupBoolean.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupBoolean.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" using namespace lldb; diff --git a/source/Interpreter/OptionGroupFile.cpp b/source/Interpreter/OptionGroupFile.cpp index 72ec4cbb8475..cda75ec205ec 100644 --- a/source/Interpreter/OptionGroupFile.cpp +++ b/source/Interpreter/OptionGroupFile.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupFile.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupFile.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" using namespace lldb; diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp index 6345a633635c..d9acfd663dd1 100644 --- a/source/Interpreter/OptionGroupFormat.cpp +++ b/source/Interpreter/OptionGroupFormat.cpp @@ -1,9 +1,8 @@ //===-- OptionGroupFormat.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp index 143a29333b6f..ccb99a8fce4a 100644 --- a/source/Interpreter/OptionGroupOutputFile.cpp +++ b/source/Interpreter/OptionGroupOutputFile.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupOutputFile.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" using namespace lldb; diff --git a/source/Interpreter/OptionGroupPlatform.cpp b/source/Interpreter/OptionGroupPlatform.cpp index c0d24a556eb8..6dc2996bb78a 100644 --- a/source/Interpreter/OptionGroupPlatform.cpp +++ b/source/Interpreter/OptionGroupPlatform.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupPlatform.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Platform.h" diff --git a/source/Interpreter/OptionGroupString.cpp b/source/Interpreter/OptionGroupString.cpp index badcfbecdc31..c01b7065fbd0 100644 --- a/source/Interpreter/OptionGroupString.cpp +++ b/source/Interpreter/OptionGroupString.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupString.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupString.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" using namespace lldb; diff --git a/source/Interpreter/OptionGroupUInt64.cpp b/source/Interpreter/OptionGroupUInt64.cpp index 252308b681fd..53e5674d0296 100644 --- a/source/Interpreter/OptionGroupUInt64.cpp +++ b/source/Interpreter/OptionGroupUInt64.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupUInt64.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupUInt64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" using namespace lldb; diff --git a/source/Interpreter/OptionGroupUUID.cpp b/source/Interpreter/OptionGroupUUID.cpp index b58f269d6087..e32673bc52af 100644 --- a/source/Interpreter/OptionGroupUUID.cpp +++ b/source/Interpreter/OptionGroupUUID.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupUUID.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupUUID.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" using namespace lldb; diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp index e0fec2991d19..a1905a64f0cd 100644 --- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" diff --git a/source/Interpreter/OptionGroupVariable.cpp b/source/Interpreter/OptionGroupVariable.cpp index f35aeb6aa555..d703c3dedcd9 100644 --- a/source/Interpreter/OptionGroupVariable.cpp +++ b/source/Interpreter/OptionGroupVariable.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupVariable.cpp -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupVariable.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -59,8 +54,8 @@ static Status ValidateNamedSummary(const char *str, void *) { if (!str || !str[0]) return Status("must specify a valid named summary"); TypeSummaryImplSP summary_sp; - if (DataVisualization::NamedSummaryFormats::GetSummaryFormat( - ConstString(str), summary_sp) == false) + if (!DataVisualization::NamedSummaryFormats::GetSummaryFormat( + ConstString(str), summary_sp)) return Status("must specify a valid named summary"); return Status(); } diff --git a/source/Interpreter/OptionGroupWatchpoint.cpp b/source/Interpreter/OptionGroupWatchpoint.cpp index 6cfcf1861faf..28e6b817fcc5 100644 --- a/source/Interpreter/OptionGroupWatchpoint.cpp +++ b/source/Interpreter/OptionGroupWatchpoint.cpp @@ -1,18 +1,13 @@ //===-- OptionGroupWatchpoint.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionGroupWatchpoint.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/lldb-enumerations.h" diff --git a/source/Interpreter/OptionValue.cpp b/source/Interpreter/OptionValue.cpp index c3f363b05988..2503d1699ecf 100644 --- a/source/Interpreter/OptionValue.cpp +++ b/source/Interpreter/OptionValue.cpp @@ -1,18 +1,13 @@ //===-- OptionValue.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValue.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValues.h" #include "lldb/Utility/StringList.h" diff --git a/source/Interpreter/OptionValueArch.cpp b/source/Interpreter/OptionValueArch.cpp index d4f1fcb8a70a..92dc45d092be 100644 --- a/source/Interpreter/OptionValueArch.cpp +++ b/source/Interpreter/OptionValueArch.cpp @@ -1,23 +1,18 @@ //===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueArch.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/State.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Interpreter/OptionValueArgs.cpp b/source/Interpreter/OptionValueArgs.cpp index 26e438548ea3..d619dba5678a 100644 --- a/source/Interpreter/OptionValueArgs.cpp +++ b/source/Interpreter/OptionValueArgs.cpp @@ -1,18 +1,13 @@ //===-- OptionValueArgs.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueArgs.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Args.h" using namespace lldb; diff --git a/source/Interpreter/OptionValueArray.cpp b/source/Interpreter/OptionValueArray.cpp index d3fd1cb5db48..30902c0f295a 100644 --- a/source/Interpreter/OptionValueArray.cpp +++ b/source/Interpreter/OptionValueArray.cpp @@ -1,18 +1,13 @@ //===-- OptionValueArray.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueArray.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Stream.h" @@ -31,13 +26,17 @@ void OptionValueArray::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, strm.Printf("(%s)", GetTypeAsCString()); } if (dump_mask & eDumpOptionValue) { - if (dump_mask & eDumpOptionType) - strm.Printf(" =%s", (m_values.size() > 0) ? "\n" : ""); - strm.IndentMore(); + const bool one_line = dump_mask & eDumpOptionCommand; const uint32_t size = m_values.size(); + if (dump_mask & eDumpOptionType) + strm.Printf(" =%s", (m_values.size() > 0 && !one_line) ? "\n" : ""); + if (!one_line) + strm.IndentMore(); for (uint32_t i = 0; i < size; ++i) { - strm.Indent(); - strm.Printf("[%u]: ", i); + if (!one_line) { + strm.Indent(); + strm.Printf("[%u]: ", i); + } const uint32_t extra_dump_options = m_raw_value_dump ? eDumpOptionRaw : 0; switch (array_element_type) { default: @@ -63,10 +62,16 @@ void OptionValueArray::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, extra_dump_options); break; } - if (i < (size - 1)) - strm.EOL(); + + if (!one_line) { + if (i < (size - 1)) + strm.EOL(); + } else { + strm << ' '; + } } - strm.IndentLess(); + if (!one_line) + strm.IndentLess(); } } @@ -215,7 +220,7 @@ Status OptionValueArray::SetArgs(const Args &args, VarSetOperationType op) { if (num_remove_indexes) { // Sort and then erase in reverse so indexes are always valid if (num_remove_indexes > 1) { - std::sort(remove_indexes.begin(), remove_indexes.end()); + llvm::sort(remove_indexes.begin(), remove_indexes.end()); for (std::vector::const_reverse_iterator pos = remove_indexes.rbegin(), end = remove_indexes.rend(); diff --git a/source/Interpreter/OptionValueBoolean.cpp b/source/Interpreter/OptionValueBoolean.cpp index 94c774d69111..8be8220fb306 100644 --- a/source/Interpreter/OptionValueBoolean.cpp +++ b/source/Interpreter/OptionValueBoolean.cpp @@ -1,18 +1,13 @@ //===-- OptionValueBoolean.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueBoolean.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/PosixApi.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Utility/Stream.h" diff --git a/source/Interpreter/OptionValueChar.cpp b/source/Interpreter/OptionValueChar.cpp index 21fe88014724..23012e6e2ec3 100644 --- a/source/Interpreter/OptionValueChar.cpp +++ b/source/Interpreter/OptionValueChar.cpp @@ -1,18 +1,13 @@ //===-- OptionValueChar.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueChar.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" diff --git a/source/Interpreter/OptionValueDictionary.cpp b/source/Interpreter/OptionValueDictionary.cpp index 2e8a8427237b..3268303ba0c2 100644 --- a/source/Interpreter/OptionValueDictionary.cpp +++ b/source/Interpreter/OptionValueDictionary.cpp @@ -1,23 +1,18 @@ //===-- OptionValueDictionary.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueDictionary.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes -#include "lldb/Core/State.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; @@ -33,16 +28,23 @@ void OptionValueDictionary::DumpValue(const ExecutionContext *exe_ctx, strm.Printf("(%s)", GetTypeAsCString()); } if (dump_mask & eDumpOptionValue) { + const bool one_line = dump_mask & eDumpOptionCommand; if (dump_mask & eDumpOptionType) strm.PutCString(" ="); collection::iterator pos, end = m_values.end(); - strm.IndentMore(); + if (!one_line) + strm.IndentMore(); for (pos = m_values.begin(); pos != end; ++pos) { OptionValue *option_value = pos->second.get(); - strm.EOL(); + + if (one_line) + strm << ' '; + else + strm.EOL(); + strm.Indent(pos->first.GetCString()); const uint32_t extra_dump_options = m_raw_value_dump ? eDumpOptionRaw : 0; @@ -74,7 +76,8 @@ void OptionValueDictionary::DumpValue(const ExecutionContext *exe_ctx, break; } } - strm.IndentLess(); + if (!one_line) + strm.IndentLess(); } } diff --git a/source/Interpreter/OptionValueEnumeration.cpp b/source/Interpreter/OptionValueEnumeration.cpp index 25e85c662a79..0b76bd0601aa 100644 --- a/source/Interpreter/OptionValueEnumeration.cpp +++ b/source/Interpreter/OptionValueEnumeration.cpp @@ -1,18 +1,13 @@ //===-- OptionValueEnumeration.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueEnumeration.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/StringList.h" using namespace lldb; diff --git a/source/Interpreter/OptionValueFileSpec.cpp b/source/Interpreter/OptionValueFileSpec.cpp index 2b93628679ce..062d7ccdf2aa 100644 --- a/source/Interpreter/OptionValueFileSpec.cpp +++ b/source/Interpreter/OptionValueFileSpec.cpp @@ -1,21 +1,19 @@ //===-- OptionValueFileSpec.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueFileSpec.h" -#include "lldb/Core/State.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Args.h" -#include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; @@ -75,7 +73,9 @@ Status OptionValueFileSpec::SetValueFromString(llvm::StringRef value, // or whitespace. value = value.trim("\"' \t"); m_value_was_set = true; - m_current_value.SetFile(value.str(), m_resolve, FileSpec::Style::native); + m_current_value.SetFile(value.str(), FileSpec::Style::native); + if (m_resolve) + FileSystem::Instance().Resolve(m_current_value); m_data_sp.reset(); m_data_mod_time = llvm::sys::TimePoint<>(); NotifyValueChanged(); @@ -109,10 +109,11 @@ size_t OptionValueFileSpec::AutoComplete(CommandInterpreter &interpreter, const lldb::DataBufferSP &OptionValueFileSpec::GetFileContents() { if (m_current_value) { - const auto file_mod_time = FileSystem::GetModificationTime(m_current_value); + const auto file_mod_time = FileSystem::Instance().GetModificationTime(m_current_value); if (m_data_sp && m_data_mod_time == file_mod_time) return m_data_sp; - m_data_sp = DataBufferLLVM::CreateFromPath(m_current_value.GetPath()); + m_data_sp = + FileSystem::Instance().CreateDataBuffer(m_current_value.GetPath()); m_data_mod_time = file_mod_time; } return m_data_sp; diff --git a/source/Interpreter/OptionValueFileSpecLIst.cpp b/source/Interpreter/OptionValueFileSpecLIst.cpp index 7fdc3c780239..0e91bc7cf1b4 100644 --- a/source/Interpreter/OptionValueFileSpecLIst.cpp +++ b/source/Interpreter/OptionValueFileSpecLIst.cpp @@ -1,18 +1,13 @@ //===-- OptionValueFileSpecLIst.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueFileSpecList.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Stream.h" @@ -25,16 +20,24 @@ void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx, if (dump_mask & eDumpOptionType) strm.Printf("(%s)", GetTypeAsCString()); if (dump_mask & eDumpOptionValue) { - if (dump_mask & eDumpOptionType) - strm.Printf(" =%s", m_current_value.GetSize() > 0 ? "\n" : ""); - strm.IndentMore(); + const bool one_line = dump_mask & eDumpOptionCommand; const uint32_t size = m_current_value.GetSize(); + if (dump_mask & eDumpOptionType) + strm.Printf(" =%s", + (m_current_value.GetSize() > 0 && !one_line) ? "\n" : ""); + if (!one_line) + strm.IndentMore(); for (uint32_t i = 0; i < size; ++i) { - strm.Indent(); - strm.Printf("[%u]: ", i); + if (!one_line) { + strm.Indent(); + strm.Printf("[%u]: ", i); + } m_current_value.GetFileSpecAtIndex(i).Dump(&strm); + if (one_line) + strm << ' '; } - strm.IndentLess(); + if (!one_line) + strm.IndentLess(); } } @@ -61,7 +64,7 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value, count); } else { for (size_t i = 1; i < argc; ++i, ++idx) { - FileSpec file(args.GetArgumentAtIndex(i), false); + FileSpec file(args.GetArgumentAtIndex(i)); if (idx < count) m_current_value.Replace(idx, file); else @@ -83,7 +86,7 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value, if (argc > 0) { m_value_was_set = true; for (size_t i = 0; i < argc; ++i) { - FileSpec file(args.GetArgumentAtIndex(i), false); + FileSpec file(args.GetArgumentAtIndex(i)); m_current_value.Append(file); } NotifyValueChanged(); @@ -107,7 +110,7 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value, if (op == eVarSetOperationInsertAfter) ++idx; for (size_t i = 1; i < argc; ++i, ++idx) { - FileSpec file(args.GetArgumentAtIndex(i), false); + FileSpec file(args.GetArgumentAtIndex(i)); m_current_value.Insert(idx, file); } NotifyValueChanged(); @@ -136,7 +139,7 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value, size_t num_remove_indexes = remove_indexes.size(); if (num_remove_indexes) { // Sort and then erase in reverse so indexes are always valid - std::sort(remove_indexes.begin(), remove_indexes.end()); + llvm::sort(remove_indexes.begin(), remove_indexes.end()); for (size_t j = num_remove_indexes - 1; j < num_remove_indexes; ++j) { m_current_value.Remove(j); } diff --git a/source/Interpreter/OptionValueFormat.cpp b/source/Interpreter/OptionValueFormat.cpp index 1837804a4622..ba5a44c270da 100644 --- a/source/Interpreter/OptionValueFormat.cpp +++ b/source/Interpreter/OptionValueFormat.cpp @@ -1,18 +1,13 @@ //===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueFormat.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Utility/Stream.h" diff --git a/source/Interpreter/OptionValueFormatEntity.cpp b/source/Interpreter/OptionValueFormatEntity.cpp index ce1a84e8dece..1bb8c9f6955a 100644 --- a/source/Interpreter/OptionValueFormatEntity.cpp +++ b/source/Interpreter/OptionValueFormatEntity.cpp @@ -1,18 +1,13 @@ //===-- OptionValueFormatEntity.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueFormatEntity.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Stream.h" @@ -41,14 +36,30 @@ bool OptionValueFormatEntity::Clear() { return true; } +static void EscapeBackticks(llvm::StringRef str, std::string &dst) { + dst.clear(); + dst.reserve(str.size()); + + for (size_t i = 0, e = str.size(); i != e; ++i) { + char c = str[i]; + if (c == '`') { + if (i == 0 || str[i - 1] != '\\') + dst += '\\'; + } + dst += c; + } +} + void OptionValueFormatEntity::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) { if (dump_mask & eDumpOptionType) strm.Printf("(%s)", GetTypeAsCString()); if (dump_mask & eDumpOptionValue) { if (dump_mask & eDumpOptionType) - strm.PutCString(" = \""); - strm << m_current_format.c_str() << '"'; + strm.PutCString(" = "); + std::string escaped; + EscapeBackticks(m_current_format, escaped); + strm << '"' << escaped << '"'; } } diff --git a/source/Interpreter/OptionValueLanguage.cpp b/source/Interpreter/OptionValueLanguage.cpp index 1a82329bf0f3..d935d5e23496 100644 --- a/source/Interpreter/OptionValueLanguage.cpp +++ b/source/Interpreter/OptionValueLanguage.cpp @@ -1,18 +1,13 @@ //===-- OptionValueLanguage.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueLanguage.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Target/Language.h" #include "lldb/Utility/Args.h" @@ -28,7 +23,8 @@ void OptionValueLanguage::DumpValue(const ExecutionContext *exe_ctx, if (dump_mask & eDumpOptionValue) { if (dump_mask & eDumpOptionType) strm.PutCString(" = "); - strm.PutCString(Language::GetNameForLanguageType(m_current_value)); + if (m_current_value != eLanguageTypeUnknown) + strm.PutCString(Language::GetNameForLanguageType(m_current_value)); } } diff --git a/source/Interpreter/OptionValuePathMappings.cpp b/source/Interpreter/OptionValuePathMappings.cpp index 8390a8cf5aba..75fcf0247475 100644 --- a/source/Interpreter/OptionValuePathMappings.cpp +++ b/source/Interpreter/OptionValuePathMappings.cpp @@ -1,18 +1,14 @@ //===-- OptionValuePathMappings.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValuePathMappings.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes +#include "lldb/Host/FileSystem.h" #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/FileSpec.h" @@ -23,7 +19,7 @@ using namespace lldb_private; namespace { static bool VerifyPathExists(const char *path) { if (path && path[0]) - return FileSpec(path, false).Exists(); + return FileSystem::Instance().Exists(path); else return false; } @@ -180,7 +176,7 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value, size_t num_remove_indexes = remove_indexes.size(); if (num_remove_indexes) { // Sort and then erase in reverse so indexes are always valid - std::sort(remove_indexes.begin(), remove_indexes.end()); + llvm::sort(remove_indexes.begin(), remove_indexes.end()); for (size_t j = num_remove_indexes - 1; j < num_remove_indexes; ++j) { m_path_mappings.Remove(j, m_notify_changes); } diff --git a/source/Interpreter/OptionValueProperties.cpp b/source/Interpreter/OptionValueProperties.cpp index 4a1daecb33e4..63ed4447f429 100644 --- a/source/Interpreter/OptionValueProperties.cpp +++ b/source/Interpreter/OptionValueProperties.cpp @@ -1,18 +1,13 @@ //===-- OptionValueProperties.cpp --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueProperties.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" #include "lldb/Core/UserSettingsController.h" @@ -42,7 +37,7 @@ OptionValueProperties::OptionValueProperties( for (size_t i = 0; i < num_properties; ++i) { // Duplicate any values that are not global when constructing properties // from a global copy - if (m_properties[i].IsGlobal() == false) { + if (!m_properties[i].IsGlobal()) { lldb::OptionValueSP new_value_sp(m_properties[i].GetValue()->DeepCopy()); m_properties[i].SetOptionValue(new_value_sp); } @@ -216,7 +211,7 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx, else { // Don't set an error if the path contained .experimental. - those are // allowed to be missing and should silently fail. - if (name_contains_experimental == false && error.AsCString() == nullptr) { + if (!name_contains_experimental && error.AsCString() == nullptr) { error.SetErrorStringWithFormat("invalid value path '%s'", name.str().c_str()); } } diff --git a/source/Interpreter/OptionValueRegex.cpp b/source/Interpreter/OptionValueRegex.cpp index aee8f97db163..bbe3fa715019 100644 --- a/source/Interpreter/OptionValueRegex.cpp +++ b/source/Interpreter/OptionValueRegex.cpp @@ -1,18 +1,13 @@ //===-- OptionValueRegex.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueRegex.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Stream.h" using namespace lldb; diff --git a/source/Interpreter/OptionValueSInt64.cpp b/source/Interpreter/OptionValueSInt64.cpp index ddd1b9662ca3..d26fc08a3132 100644 --- a/source/Interpreter/OptionValueSInt64.cpp +++ b/source/Interpreter/OptionValueSInt64.cpp @@ -1,18 +1,13 @@ //===-- OptionValueSInt64.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueSInt64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Stream.h" diff --git a/source/Interpreter/OptionValueString.cpp b/source/Interpreter/OptionValueString.cpp index 8383b531270b..a519249ab472 100644 --- a/source/Interpreter/OptionValueString.cpp +++ b/source/Interpreter/OptionValueString.cpp @@ -1,19 +1,14 @@ //===-- OptionValueString.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueString.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Stream.h" diff --git a/source/Interpreter/OptionValueUInt64.cpp b/source/Interpreter/OptionValueUInt64.cpp index c8db1bd532c6..3be0772daa8c 100644 --- a/source/Interpreter/OptionValueUInt64.cpp +++ b/source/Interpreter/OptionValueUInt64.cpp @@ -1,19 +1,14 @@ //===-- OptionValueUInt64.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueUInt64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Stream.h" diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp index 355e07bb2b5f..f39b66b77bb0 100644 --- a/source/Interpreter/OptionValueUUID.cpp +++ b/source/Interpreter/OptionValueUUID.cpp @@ -1,18 +1,13 @@ //===-- OptionValueUUID.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/OptionValueUUID.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Utility/Stream.h" diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp index bdea5b4180e6..bd29d5d832fb 100644 --- a/source/Interpreter/Options.cpp +++ b/source/Interpreter/Options.cpp @@ -1,23 +1,18 @@ //===-- Options.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/Options.h" -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -461,7 +456,7 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, } } - if (options.empty() == false) { + if (!options.empty()) { // We have some required options with no arguments strm.PutCString(" -"); for (i = 0; i < 2; ++i) @@ -480,14 +475,14 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, if (def.usage_mask & opt_set_mask && isprint8(def.short_option)) { // Add current option to the end of out_stream. - if (def.required == false && + if (!def.required && def.option_has_arg == OptionParser::eNoArgument) { options.insert(def.short_option); } } } - if (options.empty() == false) { + if (!options.empty()) { // We have some required options with no arguments strm.PutCString(" [-"); for (i = 0; i < 2; ++i) @@ -831,7 +826,7 @@ bool Options::HandleOptionArgumentCompletion( const char *module_name = request.GetParsedLine().GetArgumentAtIndex(cur_arg_pos); if (module_name) { - FileSpec module_spec(module_name, false); + FileSpec module_spec(module_name); lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget(); // Search filters require a target... diff --git a/source/Interpreter/Property.cpp b/source/Interpreter/Property.cpp index 369029bc570d..4cabc3fd2a63 100644 --- a/source/Interpreter/Property.cpp +++ b/source/Interpreter/Property.cpp @@ -1,18 +1,13 @@ //===-- Property.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/Property.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -102,8 +97,10 @@ Property::Property(const PropertyDefinition &definition) // "definition.default_uint_value" represents if the // "definition.default_cstr_value" should be resolved or not const bool resolve = definition.default_uint_value != 0; - m_value_sp.reset(new OptionValueFileSpec( - FileSpec(definition.default_cstr_value, resolve), resolve)); + FileSpec file_spec = FileSpec(definition.default_cstr_value); + if (resolve) + FileSystem::Instance().Resolve(file_spec); + m_value_sp.reset(new OptionValueFileSpec(file_spec, resolve)); break; } @@ -233,7 +230,10 @@ void Property::Dump(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) const { if (m_value_sp) { const bool dump_desc = dump_mask & OptionValue::eDumpOptionDescription; + const bool dump_cmd = dump_mask & OptionValue::eDumpOptionCommand; const bool transparent = m_value_sp->ValueIsTransparent(); + if (dump_cmd && !transparent) + strm << "settings set -f "; if (dump_desc || !transparent) { if ((dump_mask & OptionValue::eDumpOptionName) && m_name) { DumpQualifiedName(strm); diff --git a/source/Interpreter/ScriptInterpreter.cpp b/source/Interpreter/ScriptInterpreter.cpp index 497ad283f1a4..52fd77e37397 100644 --- a/source/Interpreter/ScriptInterpreter.cpp +++ b/source/Interpreter/ScriptInterpreter.cpp @@ -1,9 +1,8 @@ //===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 5d988d12a91e..7757b9c31db5 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -1,27 +1,20 @@ //===-- ABIMacOSX_arm.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABIMacOSX_arm.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -30,6 +23,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/ARMDefines.h" @@ -1474,7 +1469,7 @@ bool ABIMacOSX_arm::GetArgumentValues(Thread &thread, ValueList &values) const { if (compiler_type) { bool is_signed = false; size_t bit_width = 0; - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (!bit_size) return false; if (compiler_type.IsIntegerOrEnumerationType(is_signed)) @@ -1580,7 +1575,7 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl( const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0); if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { - auto bit_width = compiler_type.GetBitSize(&thread); + llvm::Optional bit_width = compiler_type.GetBitSize(&thread); if (!bit_width) return return_valobj_sp; @@ -1600,7 +1595,8 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl( const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); if (r1_reg_info && r2_reg_info && r3_reg_info) { - auto byte_size = compiler_type.GetByteSize(&thread); + llvm::Optional byte_size = + compiler_type.GetByteSize(&thread); if (!byte_size) return return_valobj_sp; ProcessSP process_sp(thread.GetProcess()); diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h index d3c20e1e618f..74eadae2d586 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -1,19 +1,14 @@ //===-- ABIMacOSX_arm.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABIMacOSX_arm_h_ #define liblldb_ABIMacOSX_arm_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index af2c9e4013ff..00f5dea303c8 100644 --- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -1,26 +1,20 @@ //===-- ABIMacOSX_arm64.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABIMacOSX_arm64.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -30,6 +24,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Utility/ARM64_DWARF_Registers.h" @@ -1765,7 +1761,7 @@ bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread, return false; CompilerType value_type = value->GetCompilerType(); - auto bit_size = value_type.GetBitSize(&thread); + llvm::Optional bit_size = value_type.GetBitSize(&thread); if (!bit_size) return false; @@ -2114,7 +2110,7 @@ static bool LoadValueFromConsecutiveGPRRegisters( uint32_t &NGRN, // NGRN (see ABI documentation) uint32_t &NSRN, // NSRN (see ABI documentation) DataExtractor &data) { - auto byte_size = value_type.GetByteSize(nullptr); + llvm::Optional byte_size = value_type.GetByteSize(nullptr); if (!byte_size || *byte_size == 0) return false; @@ -2131,7 +2127,7 @@ static bool LoadValueFromConsecutiveGPRRegisters( if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) { if (!base_type) return false; - auto base_byte_size = base_type.GetByteSize(nullptr); + llvm::Optional base_byte_size = base_type.GetByteSize(nullptr); if (!base_byte_size) return false; uint32_t data_offset = 0; @@ -2267,7 +2263,8 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl( if (!reg_ctx) return return_valobj_sp; - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h index 2dd7337542db..15b1b8dcfa38 100644 --- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h +++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h @@ -1,19 +1,14 @@ //===-- ABIMacOSX_arm64.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABIMacOSX_arm64_h_ #define liblldb_ABIMacOSX_arm64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index 234cab2995f5..48fca5d59ff8 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -1,27 +1,20 @@ //===-- ABIMacOSX_i386.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABIMacOSX_i386.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Process.h" @@ -29,6 +22,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -828,7 +823,7 @@ bool ABIMacOSX_i386::GetArgumentValues(Thread &thread, // We currently only support extracting values with Clang QualTypes. Do we // care about others? CompilerType compiler_type(value->GetCompilerType()); - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (bit_size) { bool is_signed; if (compiler_type.IsIntegerOrEnumerationType(is_signed)) @@ -937,7 +932,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl(Thread &thread, bool is_signed; if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { - auto bit_width = compiler_type.GetBitSize(&thread); + llvm::Optional bit_width = compiler_type.GetBitSize(&thread); if (!bit_width) return return_valobj_sp; unsigned eax_id = diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h index e026e3248672..20117c4febf7 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -1,19 +1,14 @@ //===-- ABIMacOSX_i386.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABIMacOSX_i386_h_ #define liblldb_ABIMacOSX_i386_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Value.h" #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp index 57f159f99c62..11f2d54c1ea8 100644 --- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -1,27 +1,20 @@ //===-- ABISysV_arm.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_arm.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -30,6 +23,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/ARMDefines.h" @@ -1444,10 +1439,7 @@ bool ABISysV_arm::PrepareTrivialCall(Thread &thread, addr_t sp, ~1ull; // clear bit zero since the CPSR will take care of the mode for us // Set "pc" to the address requested - if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr)) - return false; - - return true; + return reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr); } bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const { @@ -1480,7 +1472,7 @@ bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const { size_t bit_width = 0; if (compiler_type.IsIntegerOrEnumerationType(is_signed) || compiler_type.IsPointerOrReferenceType()) { - if (auto size = compiler_type.GetBitSize(&thread)) + if (llvm::Optional size = compiler_type.GetBitSize(&thread)) bit_width = *size; } else { // We only handle integer, pointer and reference types currently... @@ -1587,8 +1579,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - auto bit_width = compiler_type.GetBitSize(&thread); - auto byte_size = compiler_type.GetByteSize(&thread); + llvm::Optional bit_width = compiler_type.GetBitSize(&thread); + llvm::Optional byte_size = compiler_type.GetByteSize(&thread); if (!bit_width || !byte_size) return return_valobj_sp; @@ -1724,7 +1716,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( compiler_type.IsHomogeneousAggregate(&base_type); if (homogeneous_count > 0 && homogeneous_count <= 4) { - auto base_byte_size = base_type.GetByteSize(nullptr); + llvm::Optional base_byte_size = + base_type.GetByteSize(nullptr); if (base_type.IsVectorType(nullptr, nullptr)) { if (base_byte_size && (*base_byte_size == 8 || *base_byte_size == 16)) { @@ -1752,7 +1745,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( compiler_type.GetFieldAtIndex(index, name, NULL, NULL, NULL); if (base_type.IsFloatingPointType(float_count, is_complex)) { - auto base_byte_size = base_type.GetByteSize(nullptr); + llvm::Optional base_byte_size = + base_type.GetByteSize(nullptr); if (float_count == 2 && is_complex) { if (index != 0 && base_byte_size && vfp_byte_size != *base_byte_size) diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h index f046968c213d..586dc6319629 100644 --- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h +++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h @@ -1,19 +1,14 @@ //===-- ABISysV_arm.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_arm_h_ #define liblldb_ABISysV_arm_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp index c623a1156d54..a84218986d5b 100644 --- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -1,27 +1,20 @@ //===-- ABISysV_arm64.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_arm64.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/UnwindPlan.h" @@ -31,6 +24,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "Utility/ARM64_DWARF_Registers.h" @@ -1771,7 +1766,7 @@ bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const { if (value_type) { bool is_signed = false; size_t bit_width = 0; - auto bit_size = value_type.GetBitSize(&thread); + llvm::Optional bit_size = value_type.GetBitSize(&thread); if (!bit_size) return false; if (value_type.IsIntegerOrEnumerationType(is_signed)) { @@ -2090,7 +2085,7 @@ static bool LoadValueFromConsecutiveGPRRegisters( uint32_t &NGRN, // NGRN (see ABI documentation) uint32_t &NSRN, // NSRN (see ABI documentation) DataExtractor &data) { - auto byte_size = value_type.GetByteSize(nullptr); + llvm::Optional byte_size = value_type.GetByteSize(nullptr); if (byte_size || *byte_size == 0) return false; @@ -2108,7 +2103,7 @@ static bool LoadValueFromConsecutiveGPRRegisters( if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) { if (!base_type) return false; - auto base_byte_size = base_type.GetByteSize(nullptr); + llvm::Optional base_byte_size = base_type.GetByteSize(nullptr); if (!base_byte_size) return false; uint32_t data_offset = 0; @@ -2237,7 +2232,8 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl( if (!reg_ctx) return return_valobj_sp; - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h index 8d23c2419bab..f12b727a4f0d 100644 --- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h +++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h @@ -1,19 +1,14 @@ //===-- ABISysV_arm64.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_arm64_h_ #define liblldb_ABISysV_arm64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp index 571364a3c369..80b7d0198805 100644 --- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -1,24 +1,18 @@ //===-- ABISysV_hexagon.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_hexagon.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/Triple.h" #include "llvm/IR/DerivedTypes.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +26,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h index 5a6809371d9f..46f913f6dacd 100644 --- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h +++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h @@ -1,20 +1,15 @@ //===-- ABISysV_hexagon.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_hexagon_h_ #define liblldb_ABISysV_hexagon_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp index fe3e9e4ea928..1d390bf1f027 100644 --- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -1,23 +1,17 @@ //===----------------------- ABISysV_i386.cpp -------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 //===----------------------------------------------------------------------===// #include "ABISysV_i386.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -31,6 +25,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -312,7 +307,7 @@ bool ABISysV_i386::GetArgumentValues(Thread &thread, ValueList &values) const { // Currently: Support for extracting values with Clang QualTypes only. CompilerType compiler_type(value->GetCompilerType()); - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (bit_size) { bool is_signed; if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { @@ -517,7 +512,8 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple( (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point' { value.SetValueType(Value::eValueTypeScalar); - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; bool success = false; @@ -641,7 +637,8 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple( // ToDo: Yet to be implemented } else if (type_flags & eTypeIsVector) // 'Packed' { - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (byte_size && *byte_size > 0) { const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); if (vec_reg == nullptr) diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h index 4dce54c4f073..9e8fea479d92 100644 --- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h +++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h @@ -1,19 +1,14 @@ //===------------------- ABISysV_i386.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_i386_h_ #define liblldb_ABISysV_i386_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index 22c2c4bd3f07..dee5d26ddd23 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -1,24 +1,18 @@ //===-- ABISysV_mips.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_mips.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +26,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -816,7 +811,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl( // In MIPS register "r2" (v0) holds the integer function return values const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); - auto bit_width = return_compiler_type.GetBitSize(&thread); + llvm::Optional bit_width = return_compiler_type.GetBitSize(&thread); if (!bit_width) return return_valobj_sp; if (return_compiler_type.IsIntegerOrEnumerationType(is_signed)) { diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h index 0de8e7751fce..5964a4464d59 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h @@ -1,19 +1,14 @@ //===-- ABISysV_mips.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_mips_h_ #define liblldb_ABISysV_mips_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index 31be10b081fc..e9be1c824552 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -1,24 +1,18 @@ //===-- ABISysV_mips64.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_mips64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +26,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -766,7 +761,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( Target *target = exe_ctx.GetTargetPtr(); const ArchSpec target_arch = target->GetArchitecture(); ByteOrder target_byte_order = target_arch.GetByteOrder(); - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); @@ -974,7 +970,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); - auto field_byte_width = field_compiler_type.GetByteSize(nullptr); + llvm::Optional field_byte_width = + field_compiler_type.GetByteSize(nullptr); if (!field_byte_width) return return_valobj_sp; @@ -1045,7 +1042,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); - auto field_byte_width = field_compiler_type.GetByteSize(nullptr); + llvm::Optional field_byte_width = + field_compiler_type.GetByteSize(nullptr); // if we don't know the size of the field (e.g. invalid type), just // bail out diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h index 6258c08e35f9..faa0108b5b4a 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h @@ -1,19 +1,14 @@ //===-- ABISysV_mips64.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_mips64_h_ #define liblldb_ABISysV_mips64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index f343b7ea7c9e..c26ccd72de19 100644 --- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -1,24 +1,18 @@ //===-- ABISysV_ppc.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_ppc.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +26,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -402,7 +397,7 @@ bool ABISysV_ppc::GetArgumentValues(Thread &thread, ValueList &values) const { // We currently only support extracting values with Clang QualTypes. Do we // care about others? CompilerType compiler_type = value->GetCompilerType(); - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (!bit_size) return false; bool is_signed; @@ -470,7 +465,8 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, error.SetErrorString( "We don't support returning complex values at present"); else { - auto bit_width = compiler_type.GetBitSize(frame_sp.get()); + llvm::Optional bit_width = + compiler_type.GetBitSize(frame_sp.get()); if (!bit_width) { error.SetErrorString("can't get type size"); return error; @@ -533,7 +529,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple( if (type_flags & eTypeIsInteger) { // Extract the register context so we can read arguments from registers - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -579,7 +576,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple( if (type_flags & eTypeIsComplex) { // Don't handle complex yet. } else { - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (byte_size && *byte_size <= sizeof(long double)) { const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); RegisterValue f1_value; @@ -612,7 +610,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple( return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); } else if (type_flags & eTypeIsVector) { - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (byte_size && *byte_size > 0) { const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0); if (altivec_reg) { @@ -662,7 +661,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl( if (!reg_ctx_sp) return return_valobj_sp; - auto bit_width = return_compiler_type.GetBitSize(&thread); + llvm::Optional bit_width = return_compiler_type.GetBitSize(&thread); if (!bit_width) return return_valobj_sp; if (return_compiler_type.IsAggregateType()) { @@ -706,7 +705,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl( CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); - auto field_bit_width = field_compiler_type.GetBitSize(&thread); + llvm::Optional field_bit_width = + field_compiler_type.GetBitSize(&thread); if (!field_bit_width) return return_valobj_sp; diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h index df3ebe83faf8..ab6493404bad 100644 --- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h +++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h @@ -1,19 +1,14 @@ //===-- ABISysV_ppc.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_ppc_h_ #define liblldb_ABISysV_ppc_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index 435310669104..983cec47896c 100644 --- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -1,26 +1,20 @@ //===-- ABISysV_ppc64.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_ppc64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "Utility/PPC64LE_DWARF_Registers.h" #include "Utility/PPC64_DWARF_Registers.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -35,6 +29,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "clang/AST/ASTContext.h" @@ -284,7 +279,7 @@ bool ABISysV_ppc64::GetArgumentValues(Thread &thread, ValueList &values) const { // We currently only support extracting values with Clang QualTypes. Do we // care about others? CompilerType compiler_type = value->GetCompilerType(); - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (!bit_size) return false; bool is_signed; @@ -354,7 +349,8 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, error.SetErrorString( "We don't support returning complex values at present"); else { - auto bit_width = compiler_type.GetBitSize(frame_sp.get()); + llvm::Optional bit_width = + compiler_type.GetBitSize(frame_sp.get()); if (!bit_width) { error.SetErrorString("can't get size of type"); return error; @@ -580,8 +576,7 @@ class ReturnValueExtractor { ReturnValueExtractor(Thread &thread, CompilerType &type, RegisterContext *reg_ctx, ProcessSP process_sp) : m_thread(thread), m_type(type), - m_byte_size(m_type.GetByteSize(nullptr) ? *m_type.GetByteSize(nullptr) - : 0), + m_byte_size(m_type.GetByteSize(nullptr).getValueOr(0)), m_data_ap(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx), m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()), m_addr_size( @@ -657,7 +652,7 @@ class ReturnValueExtractor { DataExtractor de(&raw_data, sizeof(raw_data), m_byte_order, m_addr_size); offset_t offset = 0; - auto byte_size = type.GetByteSize(nullptr); + llvm::Optional byte_size = type.GetByteSize(nullptr); if (!byte_size) return {}; switch (*byte_size) { @@ -791,7 +786,7 @@ class ReturnValueExtractor { CompilerType elem_type; if (m_type.IsHomogeneousAggregate(&elem_type)) { uint32_t type_flags = elem_type.GetTypeInfo(); - auto elem_size = elem_type.GetByteSize(nullptr); + llvm::Optional elem_size = elem_type.GetByteSize(nullptr); if (!elem_size) return {}; if (type_flags & eTypeIsComplex || !(type_flags & eTypeIsFloat)) { diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h index 52765a773c0b..b832e360b100 100644 --- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h +++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h @@ -1,19 +1,14 @@ //===-- ABISysV_ppc64.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_ppc64_h_ #define liblldb_ABISysV_ppc64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp index 43b51fcab06f..61598201d6aa 100644 --- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -1,24 +1,18 @@ //===-- ABISysV_s390x.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_s390x.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -32,6 +26,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -380,7 +375,7 @@ bool ABISysV_s390x::GetArgumentValues(Thread &thread, ValueList &values) const { // We currently only support extracting values with Clang QualTypes. Do we // care about others? CompilerType compiler_type = value->GetCompilerType(); - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (!bit_size) return false; bool is_signed; @@ -450,7 +445,8 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp, error.SetErrorString( "We don't support returning complex values at present"); else { - auto bit_width = compiler_type.GetBitSize(frame_sp.get()); + llvm::Optional bit_width = + compiler_type.GetBitSize(frame_sp.get()); if (!bit_width) { error.SetErrorString("can't get type size"); return error; @@ -515,9 +511,9 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple( bool success = false; if (type_flags & eTypeIsInteger) { - // Extract the register context so we can read arguments from registers - - auto byte_size = return_compiler_type.GetByteSize(nullptr); + // Extract the register context so we can read arguments from registers. + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -563,7 +559,8 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple( if (type_flags & eTypeIsComplex) { // Don't handle complex yet. } else { - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (byte_size && *byte_size <= sizeof(long double)) { const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); RegisterValue f0_value; diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h index 5e3d20d7898b..026545b085d4 100644 --- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h +++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h @@ -1,19 +1,14 @@ //===-- ABISysV_s390x.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_s390x_h_ #define liblldb_ABISysV_s390x_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" @@ -61,9 +56,7 @@ class ABISysV_s390x : public lldb_private::ABI { bool CodeAddressIsValid(lldb::addr_t pc) override { // Code addressed must be 2 byte aligned - if (pc & 1ull) - return false; - return true; + return (pc & 1ull) == 0; } const lldb_private::RegisterInfo * diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 0b3a6ae6bb53..17a0911e8a95 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -1,25 +1,19 @@ //===-- ABISysV_x86_64.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ABISysV_x86_64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -33,6 +27,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; @@ -1267,7 +1262,7 @@ bool ABISysV_x86_64::GetArgumentValues(Thread &thread, // We currently only support extracting values with Clang QualTypes. Do we // care about others? CompilerType compiler_type = value->GetCompilerType(); - auto bit_size = compiler_type.GetBitSize(&thread); + llvm::Optional bit_size = compiler_type.GetBitSize(&thread); if (!bit_size) return false; bool is_signed; @@ -1337,7 +1332,8 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, error.SetErrorString( "We don't support returning complex values at present"); else { - auto bit_width = compiler_type.GetBitSize(frame_sp.get()); + llvm::Optional bit_width = + compiler_type.GetBitSize(frame_sp.get()); if (!bit_width) { error.SetErrorString("can't get type size"); return error; @@ -1405,7 +1401,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( if (type_flags & eTypeIsInteger) { // Extract the register context so we can read arguments from registers - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (!byte_size) return return_valobj_sp; uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -1451,7 +1448,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( if (type_flags & eTypeIsComplex) { // Don't handle complex yet. } else { - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (byte_size && *byte_size <= sizeof(long double)) { const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0); @@ -1490,7 +1488,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); } else if (type_flags & eTypeIsVector) { - auto byte_size = return_compiler_type.GetByteSize(nullptr); + llvm::Optional byte_size = + return_compiler_type.GetByteSize(nullptr); if (byte_size && *byte_size > 0) { const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); @@ -1813,7 +1812,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( if (!reg_ctx_sp) return return_valobj_sp; - auto bit_width = return_compiler_type.GetBitSize(&thread); + llvm::Optional bit_width = return_compiler_type.GetBitSize(&thread); if (!bit_width) return return_valobj_sp; if (return_compiler_type.IsAggregateType()) { @@ -1899,7 +1898,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); - auto field_bit_width = field_compiler_type.GetBitSize(&thread); + llvm::Optional field_bit_width = + field_compiler_type.GetBitSize(&thread); bool child_is_base_class = false; int32_t child_byte_offset = 0; diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h index 5b67e8656d36..6d21894b5581 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -1,19 +1,14 @@ //===-- ABISysV_x86_64.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ABISysV_x86_64_h_ #define liblldb_ABISysV_x86_64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Architecture/Arm/ArchitectureArm.cpp b/source/Plugins/Architecture/Arm/ArchitectureArm.cpp index 1b7ecc88c35e..5b86df6c5273 100644 --- a/source/Plugins/Architecture/Arm/ArchitectureArm.cpp +++ b/source/Plugins/Architecture/Arm/ArchitectureArm.cpp @@ -1,9 +1,8 @@ //===-- ArchitectureArm.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -126,3 +125,33 @@ void ArchitectureArm::OverrideStopInfo(Thread &thread) const { } } } + +addr_t ArchitectureArm::GetCallableLoadAddress(addr_t code_addr, + AddressClass addr_class) const { + bool is_alternate_isa = false; + + switch (addr_class) { + case AddressClass::eData: + case AddressClass::eDebug: + return LLDB_INVALID_ADDRESS; + case AddressClass::eCodeAlternateISA: + is_alternate_isa = true; + break; + default: break; + } + + if ((code_addr & 2u) || is_alternate_isa) + return code_addr | 1u; + return code_addr; +} + +addr_t ArchitectureArm::GetOpcodeLoadAddress(addr_t opcode_addr, + AddressClass addr_class) const { + switch (addr_class) { + case AddressClass::eData: + case AddressClass::eDebug: + return LLDB_INVALID_ADDRESS; + default: break; + } + return opcode_addr & ~(1ull); +} diff --git a/source/Plugins/Architecture/Arm/ArchitectureArm.h b/source/Plugins/Architecture/Arm/ArchitectureArm.h index 484c4a52fcc6..03e79ce524a7 100644 --- a/source/Plugins/Architecture/Arm/ArchitectureArm.h +++ b/source/Plugins/Architecture/Arm/ArchitectureArm.h @@ -1,9 +1,8 @@ //===-- ArchitectureArm.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,6 +24,12 @@ class ArchitectureArm : public Architecture { void OverrideStopInfo(Thread &thread) const override; + lldb::addr_t GetCallableLoadAddress(lldb::addr_t load_addr, + AddressClass addr_class) const override; + + lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, + AddressClass addr_class) const override; + private: static std::unique_ptr Create(const ArchSpec &arch); ArchitectureArm() = default; diff --git a/source/Plugins/Architecture/CMakeLists.txt b/source/Plugins/Architecture/CMakeLists.txt index 01365a64cf96..14ad91644595 100644 --- a/source/Plugins/Architecture/CMakeLists.txt +++ b/source/Plugins/Architecture/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(Arm) +add_subdirectory(Mips) add_subdirectory(PPC64) diff --git a/source/Plugins/Architecture/Mips/ArchitectureMips.cpp b/source/Plugins/Architecture/Mips/ArchitectureMips.cpp new file mode 100644 index 000000000000..60f1a2eb7572 --- /dev/null +++ b/source/Plugins/Architecture/Mips/ArchitectureMips.cpp @@ -0,0 +1,240 @@ +//===-- ArchitectureMips.cpp -------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "Plugins/Architecture/Mips/ArchitectureMips.h" +#include "lldb/Core/Address.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/SectionLoadList.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Log.h" + +using namespace lldb_private; +using namespace lldb; + +ConstString ArchitectureMips::GetPluginNameStatic() { + return ConstString("mips"); +} + +void ArchitectureMips::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "Mips-specific algorithms", + &ArchitectureMips::Create); +} + +void ArchitectureMips::Terminate() { + PluginManager::UnregisterPlugin(&ArchitectureMips::Create); +} + +std::unique_ptr ArchitectureMips::Create(const ArchSpec &arch) { + return arch.IsMIPS() ? + std::unique_ptr(new ArchitectureMips(arch)) : nullptr; +} + +ConstString ArchitectureMips::GetPluginName() { return GetPluginNameStatic(); } +uint32_t ArchitectureMips::GetPluginVersion() { return 1; } + +addr_t ArchitectureMips::GetCallableLoadAddress(addr_t code_addr, + AddressClass addr_class) const { + bool is_alternate_isa = false; + + switch (addr_class) { + case AddressClass::eData: + case AddressClass::eDebug: + return LLDB_INVALID_ADDRESS; + case AddressClass::eCodeAlternateISA: + is_alternate_isa = true; + break; + default: break; + } + + if ((code_addr & 2ull) || is_alternate_isa) + return code_addr | 1u; + return code_addr; +} + +addr_t ArchitectureMips::GetOpcodeLoadAddress(addr_t opcode_addr, + AddressClass addr_class) const { + switch (addr_class) { + case AddressClass::eData: + case AddressClass::eDebug: + return LLDB_INVALID_ADDRESS; + default: break; + } + return opcode_addr & ~(1ull); +} + +lldb::addr_t ArchitectureMips::GetBreakableLoadAddress(lldb::addr_t addr, + Target &target) const { + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); + + Address resolved_addr; + + SectionLoadList §ion_load_list = target.GetSectionLoadList(); + if (section_load_list.IsEmpty()) + // No sections are loaded, so we must assume we are not running yet and + // need to operate only on file address. + target.ResolveFileAddress(addr, resolved_addr); + else + target.ResolveLoadAddress(addr, resolved_addr); + + addr_t current_offset = 0; + + // Get the function boundaries to make sure we don't scan back before the + // beginning of the current function. + ModuleSP temp_addr_module_sp(resolved_addr.GetModule()); + if (temp_addr_module_sp) { + SymbolContext sc; + SymbolContextItem resolve_scope = + eSymbolContextFunction | eSymbolContextSymbol; + temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, + resolve_scope, sc); + Address sym_addr; + if (sc.function) + sym_addr = sc.function->GetAddressRange().GetBaseAddress(); + else if (sc.symbol) + sym_addr = sc.symbol->GetAddress(); + + addr_t function_start = sym_addr.GetLoadAddress(&target); + if (function_start == LLDB_INVALID_ADDRESS) + function_start = sym_addr.GetFileAddress(); + + if (function_start) + current_offset = addr - function_start; + } + + // If breakpoint address is start of function then we dont have to do + // anything. + if (current_offset == 0) + return addr; + + ExecutionContext ctx; + target.CalculateExecutionContext(ctx); + auto insn = GetInstructionAtAddress(ctx, current_offset, addr); + + if (nullptr == insn || !insn->HasDelaySlot()) + return addr; + + // Adjust the breakable address + uint64_t breakable_addr = addr - insn->GetOpcode().GetByteSize(); + if (log) + log->Printf("Target::%s Breakpoint at 0x%8.8" PRIx64 + " is adjusted to 0x%8.8" PRIx64 " due to delay slot\n", + __FUNCTION__, addr, breakable_addr); + + return breakable_addr; +} + +Instruction *ArchitectureMips::GetInstructionAtAddress( + const ExecutionContext &exe_ctx, const Address &resolved_addr, + addr_t symbol_offset) const { + + auto loop_count = symbol_offset / 2; + + uint32_t arch_flags = m_arch.GetFlags(); + bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16; + bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips; + + if (loop_count > 3) { + // Scan previous 6 bytes + if (IsMips16 | IsMicromips) + loop_count = 3; + // For mips-only, instructions are always 4 bytes, so scan previous 4 + // bytes only. + else + loop_count = 2; + } + + // Create Disassembler Instance + lldb::DisassemblerSP disasm_sp( + Disassembler::FindPlugin(m_arch, nullptr, nullptr)); + + InstructionList instruction_list; + InstructionSP prev_insn; + bool prefer_file_cache = true; // Read from file + uint32_t inst_to_choose = 0; + + Address addr = resolved_addr; + + for (uint32_t i = 1; i <= loop_count; i++) { + // Adjust the address to read from. + addr.Slide(-2); + AddressRange range(addr, i * 2); + uint32_t insn_size = 0; + + disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache); + + uint32_t num_insns = disasm_sp->GetInstructionList().GetSize(); + if (num_insns) { + prev_insn = disasm_sp->GetInstructionList().GetInstructionAtIndex(0); + insn_size = prev_insn->GetOpcode().GetByteSize(); + if (i == 1 && insn_size == 2) { + // This looks like a valid 2-byte instruction (but it could be a part + // of upper 4 byte instruction). + instruction_list.Append(prev_insn); + inst_to_choose = 1; + } + else if (i == 2) { + // Here we may get one 4-byte instruction or two 2-byte instructions. + if (num_insns == 2) { + // Looks like there are two 2-byte instructions above our + // breakpoint target address. Now the upper 2-byte instruction is + // either a valid 2-byte instruction or could be a part of it's + // upper 4-byte instruction. In both cases we don't care because in + // this case lower 2-byte instruction is definitely a valid + // instruction and whatever i=1 iteration has found out is true. + inst_to_choose = 1; + break; + } + else if (insn_size == 4) { + // This instruction claims its a valid 4-byte instruction. But it + // could be a part of it's upper 4-byte instruction. Lets try + // scanning upper 2 bytes to verify this. + instruction_list.Append(prev_insn); + inst_to_choose = 2; + } + } + else if (i == 3) { + if (insn_size == 4) + // FIXME: We reached here that means instruction at [target - 4] has + // already claimed to be a 4-byte instruction, and now instruction + // at [target - 6] is also claiming that it's a 4-byte instruction. + // This can not be true. In this case we can not decide the valid + // previous instruction so we let lldb set the breakpoint at the + // address given by user. + inst_to_choose = 0; + else + // This is straight-forward + inst_to_choose = 2; + break; + } + } + else { + // Decode failed, bytes do not form a valid instruction. So whatever + // previous iteration has found out is true. + if (i > 1) { + inst_to_choose = i - 1; + break; + } + } + } + + // Check if we are able to find any valid instruction. + if (inst_to_choose) { + if (inst_to_choose > instruction_list.GetSize()) + inst_to_choose--; + return instruction_list.GetInstructionAtIndex(inst_to_choose - 1).get(); + } + + return nullptr; +} diff --git a/source/Plugins/Architecture/Mips/ArchitectureMips.h b/source/Plugins/Architecture/Mips/ArchitectureMips.h new file mode 100644 index 000000000000..a15991ff9ebf --- /dev/null +++ b/source/Plugins/Architecture/Mips/ArchitectureMips.h @@ -0,0 +1,51 @@ +//===-- ArchitectureMips.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 LLDB_PLUGIN_ARCHITECTURE_MIPS_H +#define LLDB_PLUGIN_ARCHITECTURE_MIPS_H + +#include "lldb/Core/Architecture.h" +#include "lldb/Utility/ArchSpec.h" + +namespace lldb_private { + +class ArchitectureMips : public Architecture { +public: + static ConstString GetPluginNameStatic(); + static void Initialize(); + static void Terminate(); + + ConstString GetPluginName() override; + uint32_t GetPluginVersion() override; + + void OverrideStopInfo(Thread &thread) const override {} + + lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr, + Target &) const override; + + lldb::addr_t GetCallableLoadAddress(lldb::addr_t load_addr, + AddressClass addr_class) const override; + + lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, + AddressClass addr_class) const override; + +private: + Instruction *GetInstructionAtAddress(const ExecutionContext &exe_ctx, + const Address &resolved_addr, + lldb::addr_t symbol_offset) const; + + + static std::unique_ptr Create(const ArchSpec &arch); + ArchitectureMips(const ArchSpec &arch) : m_arch(arch) {} + + ArchSpec m_arch; +}; + +} // namespace lldb_private + +#endif // LLDB_PLUGIN_ARCHITECTURE_MIPS_H diff --git a/source/Plugins/Architecture/Mips/CMakeLists.txt b/source/Plugins/Architecture/Mips/CMakeLists.txt new file mode 100644 index 000000000000..9734edc6b12b --- /dev/null +++ b/source/Plugins/Architecture/Mips/CMakeLists.txt @@ -0,0 +1,10 @@ +add_lldb_library(lldbPluginArchitectureMips PLUGIN + ArchitectureMips.cpp + + LINK_LIBS + lldbCore + lldbTarget + lldbUtility + LINK_COMPONENTS + Support + ) diff --git a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp index 619de093aacc..d8538f8488b8 100644 --- a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp +++ b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp @@ -1,9 +1,8 @@ //===-- ArchitecturePPC64.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h index 95638853ad3d..be23f8f84bf7 100644 --- a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h +++ b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h @@ -1,9 +1,8 @@ //===-- ArchitecturePPC64.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp index 20209e9ab904..e53d741adb27 100644 --- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -1,18 +1,13 @@ //===-- DisassemblerLLVMC.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Project includes #include "DisassemblerLLVMC.h" -// Other libraries and framework includes #include "llvm-c/Disassembler.h" #include "llvm/ADT/SmallString.h" #include "llvm/MC/MCAsmInfo.h" @@ -1340,10 +1335,7 @@ bool DisassemblerLLVMC::FlavorValidForArchSpec( if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64) { - if (strcmp(flavor, "intel") == 0 || strcmp(flavor, "att") == 0) - return true; - else - return false; + return strcmp(flavor, "intel") == 0 || strcmp(flavor, "att") == 0; } else return false; } @@ -1382,7 +1374,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr, } SymbolContext sym_ctx; - const uint32_t resolve_scope = + const SymbolContextItem resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; if (pc_so_addr.IsValid() && pc_so_addr.GetModule()) { pc_so_addr.GetModule()->ResolveSymbolContextForAddress( diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h index 90555ca24f57..9af873fcd454 100644 --- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h +++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h @@ -1,22 +1,18 @@ //===-- DisassemblerLLVMC.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DisassemblerLLVMC_h_ #define liblldb_DisassemblerLLVMC_h_ -// C Includes -// C++ Includes #include #include #include -// Project includes #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/PluginManager.h" diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index e281da99ade6..f1b8d64b6f62 100644 --- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -1,10 +1,9 @@ //===-- DynamicLoaderDarwinKernel.cpp -----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,7 +14,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/Symbols.h" #include "lldb/Interpreter/OptionValueProperties.h" @@ -29,6 +27,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "DynamicLoaderDarwinKernel.h" @@ -211,13 +210,13 @@ DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr(Process *process) { exe_objfile->GetStrata() != ObjectFile::eStrataKernel) return LLDB_INVALID_ADDRESS; - if (!exe_objfile->GetHeaderAddress().IsValid()) + if (!exe_objfile->GetBaseAddress().IsValid()) return LLDB_INVALID_ADDRESS; if (CheckForKernelImageAtAddress( - exe_objfile->GetHeaderAddress().GetFileAddress(), process) == + exe_objfile->GetBaseAddress().GetFileAddress(), process) == exe_module->GetUUID()) - return exe_objfile->GetHeaderAddress().GetFileAddress(); + return exe_objfile->GetBaseAddress().GetFileAddress(); return LLDB_INVALID_ADDRESS; } @@ -293,6 +292,18 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) { return LLDB_INVALID_ADDRESS; addr_t pc = thread->GetRegisterContext()->GetPC(LLDB_INVALID_ADDRESS); + // The kernel is always loaded in high memory, if the top bit is zero, + // this isn't a kernel. + if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 8) { + if ((pc & (1ULL << 63)) == 0) { + return LLDB_INVALID_ADDRESS; + } + } else { + if ((pc & (1ULL << 31)) == 0) { + return LLDB_INVALID_ADDRESS; + } + } + if (pc == LLDB_INVALID_ADDRESS) return LLDB_INVALID_ADDRESS; @@ -307,12 +318,13 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) { // Search backwards 32 megabytes, looking for the start of the kernel at each // one-megabyte boundary. for (int i = 0; i < 32; i++, addr -= 0x100000) { + // x86_64 kernels are at offset 0 if (CheckForKernelImageAtAddress(addr, process).IsValid()) return addr; + // 32-bit arm kernels are at offset 0x1000 (one 4k page) if (CheckForKernelImageAtAddress(addr + 0x1000, process).IsValid()) return addr + 0x1000; - if (CheckForKernelImageAtAddress(addr + 0x2000, process).IsValid()) - return addr + 0x2000; + // 64-bit arm kernels are at offset 0x4000 (one 16k page) if (CheckForKernelImageAtAddress(addr + 0x4000, process).IsValid()) return addr + 0x4000; } @@ -351,12 +363,13 @@ lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch( addr_t addr = kernel_range_low; while (addr >= kernel_range_low && addr < kernel_range_high) { + // x86_64 kernels are at offset 0 if (CheckForKernelImageAtAddress(addr, process).IsValid()) return addr; + // 32-bit arm kernels are at offset 0x1000 (one 4k page) if (CheckForKernelImageAtAddress(addr + 0x1000, process).IsValid()) return addr + 0x1000; - if (CheckForKernelImageAtAddress(addr + 0x2000, process).IsValid()) - return addr + 0x2000; + // 64-bit arm kernels are at offset 0x4000 (one 16k page) if (CheckForKernelImageAtAddress(addr + 0x4000, process).IsValid()) return addr + 0x4000; addr += 0x100000; @@ -387,8 +400,8 @@ DynamicLoaderDarwinKernel::ReadMachHeader(addr_t addr, Process *process, llvm::M if (::memcmp (&header.magic, &magicks[i], sizeof (uint32_t)) == 0) found_matching_pattern = true; - if (found_matching_pattern == false) - return false; + if (!found_matching_pattern) + return false; if (header.magic == llvm::MachO::MH_CIGAM || header.magic == llvm::MachO::MH_CIGAM_64) { @@ -424,7 +437,7 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr, llvm::MachO::mach_header header; - if (ReadMachHeader (addr, process, header) == false) + if (!ReadMachHeader(addr, process, header)) return UUID(); // First try a quick test -- read the first 4 bytes and see if there is a @@ -435,8 +448,8 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr, if (header.filetype == llvm::MachO::MH_EXECUTE && (header.flags & llvm::MachO::MH_DYLDLINK) == 0) { // Create a full module to get the UUID - ModuleSP memory_module_sp = process->ReadModuleFromMemory( - FileSpec("temp_mach_kernel", false), addr); + ModuleSP memory_module_sp = + process->ReadModuleFromMemory(FileSpec("temp_mach_kernel"), addr); if (!memory_module_sp.get()) return UUID(); @@ -604,16 +617,10 @@ void DynamicLoaderDarwinKernel::KextImageInfo::SetProcessStopId( bool DynamicLoaderDarwinKernel::KextImageInfo:: operator==(const KextImageInfo &rhs) { if (m_uuid.IsValid() || rhs.GetUUID().IsValid()) { - if (m_uuid == rhs.GetUUID()) { - return true; - } - return false; + return m_uuid == rhs.GetUUID(); } - if (m_name == rhs.GetName() && m_load_address == rhs.GetLoadAddress()) - return true; - - return false; + return m_name == rhs.GetName() && m_load_address == rhs.GetLoadAddress(); } void DynamicLoaderDarwinKernel::KextImageInfo::SetName(const char *name) { @@ -646,8 +653,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule( if (m_load_address == LLDB_INVALID_ADDRESS) return false; - FileSpec file_spec; - file_spec.SetFile(m_name.c_str(), false, FileSpec::Style::native); + FileSpec file_spec(m_name.c_str()); llvm::MachO::mach_header mh; size_t size_to_read = 512; @@ -732,7 +738,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule( } bool DynamicLoaderDarwinKernel::KextImageInfo::IsKernel() const { - return m_kernel_image == true; + return m_kernel_image; } void DynamicLoaderDarwinKernel::KextImageInfo::SetIsKernel(bool is_kernel) { @@ -784,7 +790,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( // to do anything useful. This will force a clal to if (IsKernel()) { if (Symbols::DownloadObjectAndSymbolFile(module_spec, true)) { - if (module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) { m_module_sp.reset(new Module(module_spec.GetFileSpec(), target.GetArchitecture())); if (m_module_sp.get() && @@ -807,7 +813,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( PlatformDarwinKernel::GetPluginNameStatic()); if (platform_name == g_platform_name) { ModuleSpec kext_bundle_module_spec(module_spec); - FileSpec kext_filespec(m_name.c_str(), false); + FileSpec kext_filespec(m_name.c_str()); kext_bundle_module_spec.GetFileSpec() = kext_filespec; platform_sp->GetSharedModule( kext_bundle_module_spec, process, m_module_sp, @@ -932,7 +938,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( ObjectFile *kernel_object_file = m_module_sp->GetObjectFile(); if (kernel_object_file) { addr_t file_address = - kernel_object_file->GetHeaderAddress().GetFileAddress(); + kernel_object_file->GetBaseAddress().GetFileAddress(); if (m_load_address != LLDB_INVALID_ADDRESS && file_address != LLDB_INVALID_ADDRESS) { s->Printf("Kernel slid 0x%" PRIx64 " in memory.\n", @@ -1006,10 +1012,10 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { ObjectFile *kernel_object_file = m_kernel.GetModule()->GetObjectFile(); if (kernel_object_file) { addr_t load_address = - kernel_object_file->GetHeaderAddress().GetLoadAddress( + kernel_object_file->GetBaseAddress().GetLoadAddress( &m_process->GetTarget()); addr_t file_address = - kernel_object_file->GetHeaderAddress().GetFileAddress(); + kernel_object_file->GetBaseAddress().GetFileAddress(); if (load_address != LLDB_INVALID_ADDRESS && load_address != 0) { m_kernel.SetLoadAddress(load_address); if (load_address != file_address) { @@ -1281,7 +1287,7 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries( const uint32_t num_of_new_kexts = kext_summaries.size(); for (uint32_t new_kext = 0; new_kext < num_of_new_kexts; new_kext++) { - if (to_be_added[new_kext] == true) { + if (to_be_added[new_kext]) { KextImageInfo &image_info = kext_summaries[new_kext]; if (load_kexts) { if (!image_info.LoadImageUsingMemoryModule(m_process)) { diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h index 75998f1cc3be..894b5521433a 100644 --- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -1,26 +1,21 @@ //===-- DynamicLoaderDarwinKernel.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DynamicLoaderDarwinKernel_h_ #define liblldb_DynamicLoaderDarwinKernel_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -#include "lldb/Utility/SafeMachO.h" +#include "lldb/Host/SafeMachO.h" -// Project includes #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp index e6d3477ed7e4..1e4dc3f60ba3 100644 --- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -1,15 +1,11 @@ //===-- DynamicLoaderHexagonDYLD.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" @@ -179,7 +175,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() { return executable; // The target executable file does not exits - if (!executable->GetFileSpec().Exists()) + if (!FileSystem::Instance().Exists(executable->GetFileSpec())) return executable; // Prep module for loading @@ -367,7 +363,8 @@ void DynamicLoaderHexagonDYLD::RefreshModules() { E = m_rendezvous.loaded_end(); for (I = m_rendezvous.loaded_begin(); I != E; ++I) { - FileSpec file(I->path, true); + FileSpec file(I->path); + FileSystem::Instance().Resolve(file); ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr, true); if (module_sp.get()) { @@ -391,7 +388,8 @@ void DynamicLoaderHexagonDYLD::RefreshModules() { E = m_rendezvous.unloaded_end(); for (I = m_rendezvous.unloaded_begin(); I != E; ++I) { - FileSpec file(I->path, true); + FileSpec file(I->path); + FileSystem::Instance().Resolve(file); ModuleSpec module_spec(file); ModuleSP module_sp = loaded_modules.FindFirstModule(module_spec); @@ -454,7 +452,7 @@ DynamicLoaderHexagonDYLD::GetStepThroughTrampolinePlan(Thread &thread, AddressVector::iterator start = addrs.begin(); AddressVector::iterator end = addrs.end(); - std::sort(start, end); + llvm::sort(start, end); addrs.erase(std::unique(start, end), end); thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop)); } @@ -485,7 +483,7 @@ void DynamicLoaderHexagonDYLD::LoadAllCurrentModules() { for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) { const char *module_path = I->path.c_str(); - FileSpec file(module_path, false); + FileSpec file(module_path); ModuleSP module_sp = LoadModuleAtAddress(file, I->link_addr, I->base_addr, true); if (module_sp.get()) { diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h index 200a4171bd1c..3fa9a47ce6b1 100644 --- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h +++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h @@ -1,19 +1,14 @@ //===-- DynamicLoaderHexagonDYLD.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DynamicLoaderHexagonDYLD_h_ #define liblldb_DynamicLoaderHexagonDYLD_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Target/DynamicLoader.h" diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp index 69158c23e5fb..b980a29e8239 100644 --- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp +++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp @@ -1,9 +1,8 @@ //===-- HexagonDYLDRendezvous.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h index bdf6bae75197..aa1e5c10b8e0 100644 --- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h +++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h @@ -1,23 +1,19 @@ //===-- HexagonDYLDRendezvous.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_HexagonDYLDRendezvous_H_ #define liblldb_HexagonDYLDRendezvous_H_ -// C Includes -#include // for PATH_MAX -// C++ Includes +#include #include #include #include -// Other libraries and framework includes #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 76d7950c82b3..6f7e93d170f0 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -1,9 +1,8 @@ //===-- DynamicLoaderDarwin.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,7 +14,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Host/FileSystem.h" #include "lldb/Symbol/ClangASTContext.h" @@ -32,6 +30,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" //#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF @@ -115,7 +114,7 @@ ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo( // No UUID, we must rely upon the cached module modification time and the // modification time of the file on disk if (module_sp->GetModificationTime() != - FileSystem::GetModificationTime(module_sp->GetFileSpec())) + FileSystem::Instance().GetModificationTime(module_sp->GetFileSpec())) module_sp.reset(); } @@ -351,22 +350,24 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo( if (image_sp.get() == nullptr || image_sp->GetAsDictionary() == nullptr) return false; StructuredData::Dictionary *image = image_sp->GetAsDictionary(); - if (image->HasKey("load_address") == false || - image->HasKey("pathname") == false || - image->HasKey("mod_date") == false || - image->HasKey("mach_header") == false || + // clang-format off + if (!image->HasKey("load_address") || + !image->HasKey("pathname") || + !image->HasKey("mod_date") || + !image->HasKey("mach_header") || image->GetValueForKey("mach_header")->GetAsDictionary() == nullptr || - image->HasKey("segments") == false || + !image->HasKey("segments") || image->GetValueForKey("segments")->GetAsArray() == nullptr || - image->HasKey("uuid") == false) { + !image->HasKey("uuid")) { return false; } + // clang-format on image_infos[i].address = image->GetValueForKey("load_address")->GetAsInteger()->GetValue(); image_infos[i].mod_date = image->GetValueForKey("mod_date")->GetAsInteger()->GetValue(); image_infos[i].file_spec.SetFile( - image->GetValueForKey("pathname")->GetAsString()->GetValue(), false, + image->GetValueForKey("pathname")->GetAsString()->GetValue(), FileSpec::Style::native); StructuredData::Dictionary *mh = @@ -704,11 +705,7 @@ bool DynamicLoaderDarwin::AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) { return false; ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime(); - if (objc_runtime != NULL && objc_runtime->IsModuleObjCLibrary(module_sp)) { - return true; - } - - return false; + return objc_runtime != NULL && objc_runtime->IsModuleObjCLibrary(module_sp); } //---------------------------------------------------------------------- diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h index a02d1ad9bee3..b3e00830fdd9 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h @@ -1,27 +1,22 @@ //===-- DynamicLoaderDarwin.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DynamicLoaderDarwin_h_ #define liblldb_DynamicLoaderDarwin_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes +#include "lldb/Host/SafeMachO.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp index f38aa4c98aeb..27ccb89f4bea 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp @@ -1,9 +1,8 @@ //===-- DynamicLoaderMacOS.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,7 +11,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolVendor.h" @@ -21,6 +19,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "DynamicLoaderDarwin.h" #include "DynamicLoaderMacOS.h" @@ -65,7 +64,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process, } } - if (UseDYLDSPI(process) == false) { + if (!UseDYLDSPI(process)) { create = false; } @@ -79,7 +78,8 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process, //---------------------------------------------------------------------- DynamicLoaderMacOS::DynamicLoaderMacOS(Process *process) : DynamicLoaderDarwin(process), m_image_infos_stop_id(UINT32_MAX), - m_break_id(LLDB_INVALID_BREAK_ID), m_mutex() {} + m_break_id(LLDB_INVALID_BREAK_ID), m_mutex(), + m_maybe_image_infos_address(LLDB_INVALID_ADDRESS) {} //---------------------------------------------------------------------- // Destructor @@ -95,16 +95,31 @@ bool DynamicLoaderMacOS::ProcessDidExec() { if (m_process) { // If we are stopped after an exec, we will have only one thread... if (m_process->GetThreadList().GetSize() == 1) { - // See if we are stopped at '_dyld_start' - ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0)); - if (thread_sp) { - lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0)); - if (frame_sp) { - const Symbol *symbol = - frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol; - if (symbol) { - if (symbol->GetName() == ConstString("_dyld_start")) - did_exec = true; + // Maybe we still have an image infos address around? If so see + // if that has changed, and if so we have exec'ed. + if (m_maybe_image_infos_address != LLDB_INVALID_ADDRESS) { + lldb::addr_t image_infos_address = m_process->GetImageInfoAddress(); + if (image_infos_address != m_maybe_image_infos_address) { + // We don't really have to reset this here, since we are going to + // call DoInitialImageFetch right away to handle the exec. But in + // case anybody looks at it in the meantime, it can't hurt. + m_maybe_image_infos_address = image_infos_address; + did_exec = true; + } + } + + if (!did_exec) { + // See if we are stopped at '_dyld_start' + ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0)); + if (thread_sp) { + lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0)); + if (frame_sp) { + const Symbol *symbol = + frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol; + if (symbol) { + if (symbol->GetName() == ConstString("_dyld_start")) + did_exec = true; + } } } } @@ -180,6 +195,7 @@ void DynamicLoaderMacOS::DoInitialImageFetch() { } m_dyld_image_infos_stop_id = m_process->GetStopID(); + m_maybe_image_infos_address = m_process->GetImageInfoAddress(); } bool DynamicLoaderMacOS::NeedToDoInitialImageFetch() { return true; } @@ -486,8 +502,7 @@ bool DynamicLoaderMacOS::GetSharedCacheInformation( info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue(); if (!uuid_str.empty()) uuid.SetFromStringRef(uuid_str); - if (info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue() == - false) + if (!info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue()) using_shared_cache = eLazyBoolYes; else using_shared_cache = eLazyBoolNo; diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h index dd0a779db1f7..77645e3c4e52 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h @@ -1,9 +1,8 @@ //===-- DynamicLoaderMacOS.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,17 +17,12 @@ #ifndef liblldb_DynamicLoaderMacOS_h_ #define liblldb_DynamicLoaderMacOS_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" @@ -109,6 +103,12 @@ class DynamicLoaderMacOS : public lldb_private::DynamicLoaderDarwin { // loaded/unloaded images lldb::user_id_t m_break_id; mutable std::recursive_mutex m_mutex; + lldb::addr_t m_maybe_image_infos_address; // If dyld is still maintaining the + // all_image_infos address, store it + // here so we can use it to detect + // exec's when talking to + // debugservers that don't support + // the "reason:exec" annotation. private: DISALLOW_COPY_AND_ASSIGN(DynamicLoaderMacOS); diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 6d015695fdd4..58c46d850db6 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -1,9 +1,8 @@ //===-- DynamicLoaderMacOSXDYLD.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,7 +12,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" @@ -27,6 +25,7 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "DynamicLoaderDarwin.h" #include "DynamicLoaderMacOSXDYLD.h" @@ -85,7 +84,7 @@ DynamicLoader *DynamicLoaderMacOSXDYLD::CreateInstance(Process *process, } } - if (UseDYLDSPI(process) == true) { + if (UseDYLDSPI(process)) { create = false; } @@ -122,12 +121,12 @@ bool DynamicLoaderMacOSXDYLD::ProcessDidExec() { // value differs from the Process' image info address. When a process // execs itself it might cause a change if ASLR is enabled. const addr_t shlib_addr = m_process->GetImageInfoAddress(); - if (m_process_image_addr_is_all_images_infos == true && + if (m_process_image_addr_is_all_images_infos && shlib_addr != m_dyld_all_image_infos_addr) { // The image info address from the process is the // 'dyld_all_image_infos' address and it has changed. did_exec = true; - } else if (m_process_image_addr_is_all_images_infos == false && + } else if (!m_process_image_addr_is_all_images_infos && shlib_addr == m_dyld.address) { // The image info address from the process is the mach_header address // for dyld and it has changed. @@ -693,9 +692,7 @@ bool DynamicLoaderMacOSXDYLD::ReadImageInfos( error); // don't resolve the path if (error.Success()) { - const bool resolve_path = false; - image_infos[i].file_spec.SetFile(raw_path, resolve_path, - FileSpec::Style::native); + image_infos[i].file_spec.SetFile(raw_path, FileSpec::Style::native); } } return true; @@ -894,7 +891,8 @@ uint32_t DynamicLoaderMacOSXDYLD::ParseLoadCommands(const DataExtractor &data, const lldb::offset_t name_offset = load_cmd_offset + data.GetU32(&offset); const char *path = data.PeekCStr(name_offset); - lc_id_dylinker->SetFile(path, true, FileSpec::Style::native); + lc_id_dylinker->SetFile(path, FileSpec::Style::native); + FileSystem::Instance().Resolve(*lc_id_dylinker); } break; diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h index 6b83430cca08..10a3f31cd4bf 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -1,9 +1,8 @@ //===-- DynamicLoaderMacOSXDYLD.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -21,17 +20,13 @@ #ifndef liblldb_DynamicLoaderMacOSXDYLD_h_ #define liblldb_DynamicLoaderMacOSXDYLD_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes +#include "lldb/Host/SafeMachO.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp index 7dd2b57da0cb..71d42c8fd99a 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp @@ -1,9 +1,8 @@ //===-- AuxVector.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -100,7 +99,7 @@ const char *AuxVector::GetEntryName(EntryType type) { #define ENTRY_NAME(_type) \ _type: \ - name = #_type + 5 + name = &#_type[5] switch (type) { case ENTRY_NAME(AUXV_AT_NULL); break; case ENTRY_NAME(AUXV_AT_IGNORE); break; diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h index 3b06fe18f0c6..af61958efb86 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h @@ -1,20 +1,16 @@ //===-- AuxVector.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AuxVector_H_ #define liblldb_AuxVector_H_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "lldb/lldb-forward.h" namespace lldb_private { diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp index 3405a7aea5a3..0c4b7acbd656 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -1,9 +1,8 @@ //===-- DYLDRendezvous.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -243,7 +242,7 @@ bool DYLDRendezvous::FillSOEntryFromModuleInfo( entry.base_addr = base_addr; entry.dyn_addr = dyn_addr; - entry.file_spec.SetFile(name, false, FileSpec::Style::native); + entry.file_spec.SetFile(name, FileSpec::Style::native); UpdateBaseAddrIfNecessary(entry, name); @@ -455,14 +454,10 @@ static bool isLoadBiasIncorrect(Target &target, const std::string &file_path) { // On Android L (API 21, 22) the load address of the "/system/bin/linker" // isn't filled in correctly. unsigned os_major = target.GetPlatform()->GetOSVersion().getMajor(); - if (target.GetArchitecture().GetTriple().isAndroid() && - (os_major == 21 || os_major == 22) && - (file_path == "/system/bin/linker" || - file_path == "/system/bin/linker64")) { - return true; - } - - return false; + return target.GetArchitecture().GetTriple().isAndroid() && + (os_major == 21 || os_major == 22) && + (file_path == "/system/bin/linker" || + file_path == "/system/bin/linker64"); } void DYLDRendezvous::UpdateBaseAddrIfNecessary(SOEntry &entry, @@ -517,7 +512,7 @@ bool DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry) { return false; std::string file_path = ReadStringFromMemory(entry.path_addr); - entry.file_spec.SetFile(file_path, false, FileSpec::Style::native); + entry.file_spec.SetFile(file_path, FileSpec::Style::native); UpdateBaseAddrIfNecessary(entry, file_path); diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h index a7071801f569..8c761e781c32 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h @@ -1,21 +1,17 @@ //===-- DYLDRendezvous.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Rendezvous_H_ #define liblldb_Rendezvous_H_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 6edc05d99f32..96d9db5dd50a 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -1,19 +1,16 @@ //===-- DynamicLoaderPOSIXDYLD.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // Main header include #include "DynamicLoaderPOSIXDYLD.h" -// Project includes #include "AuxVector.h" -// Other libraries and framework includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" @@ -29,8 +26,6 @@ #include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Utility/Log.h" -// C++ Includes -// C Includes using namespace lldb; using namespace lldb_private; @@ -121,7 +116,7 @@ void DynamicLoaderPOSIXDYLD::DidAttach() { EvalSpecialModulesStatus(); // if we dont have a load address we cant re-base - bool rebase_exec = (load_offset == LLDB_INVALID_ADDRESS) ? false : true; + bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS; // if we have a valid executable if (executable_sp.get()) { @@ -500,7 +495,7 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, AddressVector::iterator start = addrs.begin(); AddressVector::iterator end = addrs.end(); - std::sort(start, end); + llvm::sort(start, end); addrs.erase(std::unique(start, end), end); thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop)); } @@ -512,7 +507,7 @@ void DynamicLoaderPOSIXDYLD::LoadVDSO() { if (m_vdso_base == LLDB_INVALID_ADDRESS) return; - FileSpec file("[vdso]", false); + FileSpec file("[vdso]"); MemoryRegionInfo info; Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info); @@ -543,7 +538,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() { return nullptr; } - FileSpec file(info.GetName().GetCString(), false); + FileSpec file(info.GetName().GetCString()); ModuleSpec module_spec(file, target.GetArchitecture()); if (ModuleSP module_sp = target.GetSharedModule(module_spec)) { diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h index 0456baf4a658..9141138f5f00 100644 --- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h +++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h @@ -1,22 +1,17 @@ //===-- DynamicLoaderPOSIXDYLD.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DynamicLoaderPOSIXDYLD_h_ #define liblldb_DynamicLoaderPOSIXDYLD_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "DYLDRendezvous.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/ModuleList.h" diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp index 2960e3939461..2d3d7ea5c13f 100644 --- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp +++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp @@ -1,9 +1,8 @@ //===-- DynamicLoaderStatic.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h index 2d18ec86afd3..9075df6832c3 100644 --- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h +++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h @@ -1,19 +1,14 @@ //===-- DynamicLoaderStatic.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DynamicLoaderStatic_h_ #define liblldb_DynamicLoaderStatic_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp index 6502d7a7a58c..727a4ae5cc4b 100644 --- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp +++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp @@ -1,21 +1,22 @@ //===-- DynamicLoaderWindowsDYLD.cpp --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "DynamicLoaderWindowsDYLD.h" +#include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadPlanStepInstruction.h" +#include "lldb/Utility/Log.h" #include "llvm/ADT/Triple.h" @@ -60,7 +61,39 @@ DynamicLoader *DynamicLoaderWindowsDYLD::CreateInstance(Process *process, return nullptr; } -void DynamicLoaderWindowsDYLD::DidAttach() {} +void DynamicLoaderWindowsDYLD::DidAttach() { + Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); + if (log) + log->Printf("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__); + + ModuleSP executable = GetTargetExecutable(); + + if (!executable.get()) + return; + + // Try to fetch the load address of the file from the process, since there + // could be randomization of the load address. + + // It might happen that the remote has a different dir for the file, so we + // only send the basename of the executable in the query. I think this is safe + // because I doubt that two executables with the same basenames are loaded in + // memory... + FileSpec file_spec( + executable->GetPlatformFileSpec().GetFilename().GetCString()); + bool is_loaded; + addr_t base_addr = 0; + lldb::addr_t load_addr; + Status error = m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr); + if (error.Success() && is_loaded) { + base_addr = load_addr; + UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, base_addr, false); + } + + ModuleList module_list; + module_list.Append(executable); + m_process->GetTarget().ModulesDidLoad(module_list); + m_process->LoadModules(); +} void DynamicLoaderWindowsDYLD::DidLaunch() {} diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h index de6e295f7891..5eb390085731 100644 --- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h +++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h @@ -1,19 +1,14 @@ //===-- DynamicLoaderWindowsDYLD.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_ #define liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/DynamicLoader.h" #include "lldb/lldb-forward.h" diff --git a/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp index 0d619e4174e0..3fecb0c7da92 100644 --- a/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp +++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp @@ -1,9 +1,8 @@ //===-- ASTDumper.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ASTDumper.h b/source/Plugins/ExpressionParser/Clang/ASTDumper.h index 58ba19739e5b..ddf055d9c0c3 100644 --- a/source/Plugins/ExpressionParser/Clang/ASTDumper.h +++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.h @@ -1,9 +1,8 @@ //===-- ASTDumper.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index fa49a51f32a6..71e130708976 100644 --- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -1,9 +1,8 @@ //===-- ASTResultSynthesizer.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -87,7 +86,8 @@ void ASTResultSynthesizer::TransformTopLevelDecl(Decl *D) { SynthesizeObjCMethodResult(method_decl); } } else if (FunctionDecl *function_decl = dyn_cast(D)) { - if (m_ast_context && + // When completing user input the body of the function may be a nullptr. + if (m_ast_context && function_decl->hasBody() && !function_decl->getNameInfo().getAsString().compare("$__lldb_expr")) { RecordPersistentTypes(function_decl); SynthesizeFunctionResult(function_decl); diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h index 859a1dfa5f73..bd09650ebc8b 100644 --- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h +++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h @@ -1,9 +1,8 @@ //===-- ASTResultSynthesizer.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp index 2faeecdf724e..1d8e6931cb9a 100644 --- a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp +++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp @@ -1,9 +1,8 @@ //===-- ASTStructExtractor.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h index 65f4b00a8651..0eef6ea0f9d5 100644 --- a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h +++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h @@ -1,9 +1,8 @@ //===-- ASTStructExtractor.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 8a9c3c4d18ca..ccb411cc5816 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -1,9 +1,8 @@ //===-- ClangASTSource.cpp ---------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -332,11 +331,9 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { TypeList types; - SymbolContext null_sc; ConstString name(tag_decl->getName().str().c_str()); - i->first->FindTypesInNamespace(null_sc, name, &i->second, UINT32_MAX, - types); + i->first->FindTypesInNamespace(name, &i->second, UINT32_MAX, types); for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) { lldb::TypeSP type = types.GetTypeAtIndex(ti); @@ -366,7 +363,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { } else { TypeList types; - SymbolContext null_sc; ConstString name(tag_decl->getName().str().c_str()); CompilerDeclContext namespace_decl; @@ -374,7 +370,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) { bool exact_match = false; llvm::DenseSet searched_symbol_files; - module_list.FindTypes(null_sc, name, exact_match, UINT32_MAX, + module_list.FindTypes(nullptr, name, exact_match, UINT32_MAX, searched_symbol_files, types); for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) { @@ -774,18 +770,16 @@ bool ClangASTSource::IgnoreName(const ConstString name, static const ConstString id_name("id"); static const ConstString Class_name("Class"); - if (name == id_name || name == Class_name) - return true; + if (m_ast_context->getLangOpts().ObjC) + if (name == id_name || name == Class_name) + return true; StringRef name_string_ref = name.GetStringRef(); // The ClangASTSource is not responsible for finding $-names. - if (name_string_ref.empty() || - (ignore_all_dollar_names && name_string_ref.startswith("$")) || - name_string_ref.startswith("_$")) - return true; - - return false; + return name_string_ref.empty() || + (ignore_all_dollar_names && name_string_ref.startswith("$")) || + name_string_ref.startswith("_$"); } void ClangASTSource::FindExternalVisibleDecls( @@ -807,10 +801,8 @@ void ClangASTSource::FindExternalVisibleDecls( SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext null_sc; - found_namespace_decl = - symbol_vendor->FindNamespace(null_sc, name, &namespace_decl); + symbol_vendor->FindNamespace(name, &namespace_decl); if (found_namespace_decl) { context.m_namespace_map->push_back( @@ -840,10 +832,8 @@ void ClangASTSource::FindExternalVisibleDecls( if (!symbol_vendor) continue; - SymbolContext null_sc; - found_namespace_decl = - symbol_vendor->FindNamespace(null_sc, name, &namespace_decl); + symbol_vendor->FindNamespace(name, &namespace_decl); if (found_namespace_decl) { context.m_namespace_map->push_back( @@ -863,15 +853,12 @@ void ClangASTSource::FindExternalVisibleDecls( break; TypeList types; - SymbolContext null_sc; const bool exact_match = true; llvm::DenseSet searched_symbol_files; if (module_sp && namespace_decl) - module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types); + module_sp->FindTypesInNamespace(name, &namespace_decl, 1, types); else { - SymbolContext sc; - sc.module_sp = module_sp; - m_target->GetImages().FindTypes(sc, name, exact_match, 1, + m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1, searched_symbol_files, types); } @@ -1658,10 +1645,10 @@ static bool ImportOffsetMap(llvm::DenseMap &destination_map, std::vector sorted_items; sorted_items.reserve(source_map.size()); sorted_items.assign(source_map.begin(), source_map.end()); - std::sort(sorted_items.begin(), sorted_items.end(), - [](const PairType &lhs, const PairType &rhs) { - return lhs.second < rhs.second; - }); + llvm::sort(sorted_items.begin(), sorted_items.end(), + [](const PairType &lhs, const PairType &rhs) { + return lhs.second < rhs.second; + }); for (const auto &item : sorted_items) { DeclFromUser user_decl(const_cast(item.first)); @@ -1886,10 +1873,8 @@ void ClangASTSource::CompleteNamespaceMap( if (!symbol_vendor) continue; - SymbolContext null_sc; - - found_namespace_decl = symbol_vendor->FindNamespace( - null_sc, name, &module_parent_namespace_decl); + found_namespace_decl = + symbol_vendor->FindNamespace(name, &module_parent_namespace_decl); if (!found_namespace_decl) continue; @@ -1921,10 +1906,8 @@ void ClangASTSource::CompleteNamespaceMap( if (!symbol_vendor) continue; - SymbolContext null_sc; - found_namespace_decl = - symbol_vendor->FindNamespace(null_sc, name, &null_namespace_decl); + symbol_vendor->FindNamespace(name, &null_namespace_decl); if (!found_namespace_decl) continue; diff --git a/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index a42422b0f97f..cf305b42d251 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -1,9 +1,8 @@ //===-- ClangASTSource.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h b/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h index 9ea4e3aa7dab..30a7c933166a 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h +++ b/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h @@ -1,9 +1,8 @@ //===-- ClangDiagnostic.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 7da5e03a3809..728d520ed55d 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1,9 +1,8 @@ //===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,7 +16,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/Materializer.h" @@ -44,6 +42,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include "clang/AST/ASTConsumer.h" @@ -689,6 +688,9 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target, case eSymbolTypeASTFile: symbol_load_addr = sym_address.GetLoadAddress(&target); break; + + case eSymbolTypeIVarOffset: + break; } } diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h index cb29731579dc..d8609797fdb4 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -1,27 +1,22 @@ //===-- ClangExpressionDeclMap.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangExpressionDeclMap_h_ #define liblldb_ClangExpressionDeclMap_h_ -// C Includes #include #include -// C++ Includes #include #include "ClangASTSource.h" #include "ClangExpressionVariable.h" -// Other libraries and framework includes -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" #include "lldb/Expression/Materializer.h" diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h index e0d3ace15bd1..7a77c4581fbf 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h @@ -1,23 +1,18 @@ //===-- ClangExpressionHelper.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangExpression_h_ #define liblldb_ClangExpression_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Expression/ExpressionTypeSystemHelper.h" diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 00748531e75a..c32c8444954d 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -1,18 +1,16 @@ //===-- ClangExpressionParser.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes +#include #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" #include "clang/AST/ExternalASTSource.h" +#include "clang/AST/PrettyPrinter.h" #include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceLocation.h" @@ -36,6 +34,8 @@ #include "clang/Parse/ParseAST.h" #include "clang/Rewrite/Core/Rewriter.h" #include "clang/Rewrite/Frontend/FrontendActions.h" +#include "clang/Sema/CodeCompleteConsumer.h" +#include "clang/Sema/Sema.h" #include "clang/Sema/SemaConsumer.h" #include "llvm/ADT/StringRef.h" @@ -57,7 +57,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Signals.h" -// Project includes #include "ClangDiagnostic.h" #include "ClangExpressionParser.h" @@ -263,7 +262,7 @@ class LoggingDiagnosticConsumer : public clang::DiagnosticConsumer { ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope, Expression &expr, bool generate_debug_info) - : ExpressionParser(exe_scope, expr, generate_debug_info), + : ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(), m_pp_callbacks(nullptr) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); @@ -419,6 +418,7 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope, // 5. Set language options. lldb::LanguageType language = expr.Language(); + LangOptions &lang_opts = m_compiler->getLangOpts(); switch (language) { case lldb::eLanguageTypeC: @@ -430,14 +430,13 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope, // For now, the expression parser must use C++ anytime the language is a C // family language, because the expression parser uses features of C++ to // capture values. - m_compiler->getLangOpts().CPlusPlus = true; + lang_opts.CPlusPlus = true; break; case lldb::eLanguageTypeObjC: - m_compiler->getLangOpts().ObjC1 = true; - m_compiler->getLangOpts().ObjC2 = true; + lang_opts.ObjC = true; // FIXME: the following language option is a temporary workaround, // to "ask for ObjC, get ObjC++" (see comment above). - m_compiler->getLangOpts().CPlusPlus = true; + lang_opts.CPlusPlus = true; // Clang now sets as default C++14 as the default standard (with // GNU extensions), so we do the same here to avoid mismatches that @@ -445,69 +444,67 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope, // as it's a C++11 feature). Currently lldb evaluates C++14 as C++11 (see // two lines below) so we decide to be consistent with that, but this could // be re-evaluated in the future. - m_compiler->getLangOpts().CPlusPlus11 = true; + lang_opts.CPlusPlus11 = true; break; case lldb::eLanguageTypeC_plus_plus: case lldb::eLanguageTypeC_plus_plus_11: case lldb::eLanguageTypeC_plus_plus_14: - m_compiler->getLangOpts().CPlusPlus11 = true; + lang_opts.CPlusPlus11 = true; m_compiler->getHeaderSearchOpts().UseLibcxx = true; LLVM_FALLTHROUGH; case lldb::eLanguageTypeC_plus_plus_03: - m_compiler->getLangOpts().CPlusPlus = true; - // FIXME: the following language option is a temporary workaround, - // to "ask for C++, get ObjC++". Apple hopes to remove this requirement on - // non-Apple platforms, but for now it is needed. - m_compiler->getLangOpts().ObjC1 = true; + lang_opts.CPlusPlus = true; + if (process_sp) + lang_opts.ObjC = + process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr; break; case lldb::eLanguageTypeObjC_plus_plus: case lldb::eLanguageTypeUnknown: default: - m_compiler->getLangOpts().ObjC1 = true; - m_compiler->getLangOpts().ObjC2 = true; - m_compiler->getLangOpts().CPlusPlus = true; - m_compiler->getLangOpts().CPlusPlus11 = true; + lang_opts.ObjC = true; + lang_opts.CPlusPlus = true; + lang_opts.CPlusPlus11 = true; m_compiler->getHeaderSearchOpts().UseLibcxx = true; break; } - m_compiler->getLangOpts().Bool = true; - m_compiler->getLangOpts().WChar = true; - m_compiler->getLangOpts().Blocks = true; - m_compiler->getLangOpts().DebuggerSupport = + lang_opts.Bool = true; + lang_opts.WChar = true; + lang_opts.Blocks = true; + lang_opts.DebuggerSupport = true; // Features specifically for debugger clients if (expr.DesiredResultType() == Expression::eResultTypeId) - m_compiler->getLangOpts().DebuggerCastResultToId = true; + lang_opts.DebuggerCastResultToId = true; - m_compiler->getLangOpts().CharIsSigned = - ArchSpec(m_compiler->getTargetOpts().Triple.c_str()) - .CharIsSignedByDefault(); + lang_opts.CharIsSigned = ArchSpec(m_compiler->getTargetOpts().Triple.c_str()) + .CharIsSignedByDefault(); // Spell checking is a nice feature, but it ends up completing a lot of types // that we didn't strictly speaking need to complete. As a result, we spend a // long time parsing and importing debug information. - m_compiler->getLangOpts().SpellChecking = false; + lang_opts.SpellChecking = false; - if (process_sp && m_compiler->getLangOpts().ObjC1) { + if (process_sp && lang_opts.ObjC) { if (process_sp->GetObjCLanguageRuntime()) { if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2) - m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX, - VersionTuple(10, 7)); + lang_opts.ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7)); else - m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX, - VersionTuple(10, 7)); + lang_opts.ObjCRuntime.set(ObjCRuntime::FragileMacOSX, + VersionTuple(10, 7)); if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing()) - m_compiler->getLangOpts().DebuggerObjCLiteral = true; + lang_opts.DebuggerObjCLiteral = true; } } - m_compiler->getLangOpts().ThreadsafeStatics = false; - m_compiler->getLangOpts().AccessControl = - false; // Debuggers get universal access - m_compiler->getLangOpts().DollarIdents = - true; // $ indicates a persistent variable name + lang_opts.ThreadsafeStatics = false; + lang_opts.AccessControl = false; // Debuggers get universal access + lang_opts.DollarIdents = true; // $ indicates a persistent variable name + // We enable all builtin functions beside the builtins from libc/libm (e.g. + // 'fopen'). Those libc functions are already correctly handled by LLDB, and + // additionally enabling them as expandable builtins is breaking Clang. + lang_opts.NoBuiltin = true; // Set CodeGen options m_compiler->getCodeGenOpts().EmitDeclMetadata = true; @@ -563,10 +560,6 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope, // 8. Most of this we get from the CompilerInstance, but we also want to give // the context an ExternalASTSource. - // We enable all builtin functions beside the builtins from libc/libm (e.g. - // 'fopen'). Those libc functions are already correctly handled by LLDB, and - // additionally enabling them as expandable builtins is breaking Clang. - m_compiler->getLangOpts().NoBuiltin = true; auto &PP = m_compiler->getPreprocessor(); auto &builtin_context = PP.getBuiltinInfo(); @@ -602,9 +595,276 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope, ClangExpressionParser::~ClangExpressionParser() {} +namespace { + +//---------------------------------------------------------------------- +/// @class CodeComplete +/// +/// A code completion consumer for the clang Sema that is responsible for +/// creating the completion suggestions when a user requests completion +/// of an incomplete `expr` invocation. +//---------------------------------------------------------------------- +class CodeComplete : public CodeCompleteConsumer { + CodeCompletionTUInfo m_info; + + std::string m_expr; + unsigned m_position = 0; + CompletionRequest &m_request; + /// The printing policy we use when printing declarations for our completion + /// descriptions. + clang::PrintingPolicy m_desc_policy; + + /// Returns true if the given character can be used in an identifier. + /// This also returns true for numbers because for completion we usually + /// just iterate backwards over iterators. + /// + /// Note: lldb uses '$' in its internal identifiers, so we also allow this. + static bool IsIdChar(char c) { + return c == '_' || std::isalnum(c) || c == '$'; + } + + /// Returns true if the given character is used to separate arguments + /// in the command line of lldb. + static bool IsTokenSeparator(char c) { return c == ' ' || c == '\t'; } + + /// Drops all tokens in front of the expression that are unrelated for + /// the completion of the cmd line. 'unrelated' means here that the token + /// is not interested for the lldb completion API result. + StringRef dropUnrelatedFrontTokens(StringRef cmd) { + if (cmd.empty()) + return cmd; + + // If we are at the start of a word, then all tokens are unrelated to + // the current completion logic. + if (IsTokenSeparator(cmd.back())) + return StringRef(); + + // Remove all previous tokens from the string as they are unrelated + // to completing the current token. + StringRef to_remove = cmd; + while (!to_remove.empty() && !IsTokenSeparator(to_remove.back())) { + to_remove = to_remove.drop_back(); + } + cmd = cmd.drop_front(to_remove.size()); + + return cmd; + } + + /// Removes the last identifier token from the given cmd line. + StringRef removeLastToken(StringRef cmd) { + while (!cmd.empty() && IsIdChar(cmd.back())) { + cmd = cmd.drop_back(); + } + return cmd; + } + + /// Attemps to merge the given completion from the given position into the + /// existing command. Returns the completion string that can be returned to + /// the lldb completion API. + std::string mergeCompletion(StringRef existing, unsigned pos, + StringRef completion) { + StringRef existing_command = existing.substr(0, pos); + // We rewrite the last token with the completion, so let's drop that + // token from the command. + existing_command = removeLastToken(existing_command); + // We also should remove all previous tokens from the command as they + // would otherwise be added to the completion that already has the + // completion. + existing_command = dropUnrelatedFrontTokens(existing_command); + return existing_command.str() + completion.str(); + } + +public: + /// Constructs a CodeComplete consumer that can be attached to a Sema. + /// @param[out] matches + /// The list of matches that the lldb completion API expects as a result. + /// This may already contain matches, so it's only allowed to append + /// to this variable. + /// @param[out] expr + /// The whole expression string that we are currently parsing. This + /// string needs to be equal to the input the user typed, and NOT the + /// final code that Clang is parsing. + /// @param[out] position + /// The character position of the user cursor in the `expr` parameter. + /// + CodeComplete(CompletionRequest &request, clang::LangOptions ops, + std::string expr, unsigned position) + : CodeCompleteConsumer(CodeCompleteOptions(), false), + m_info(std::make_shared()), m_expr(expr), + m_position(position), m_request(request), m_desc_policy(ops) { + + // Ensure that the printing policy is producing a description that is as + // short as possible. + m_desc_policy.SuppressScope = true; + m_desc_policy.SuppressTagKeyword = true; + m_desc_policy.FullyQualifiedName = false; + m_desc_policy.TerseOutput = true; + m_desc_policy.IncludeNewlines = false; + m_desc_policy.UseVoidForZeroParams = false; + m_desc_policy.Bool = true; + } + + /// Deregisters and destroys this code-completion consumer. + virtual ~CodeComplete() {} + + /// \name Code-completion filtering + /// Check if the result should be filtered out. + bool isResultFilteredOut(StringRef Filter, + CodeCompletionResult Result) override { + // This code is mostly copied from CodeCompleteConsumer. + switch (Result.Kind) { + case CodeCompletionResult::RK_Declaration: + return !( + Result.Declaration->getIdentifier() && + Result.Declaration->getIdentifier()->getName().startswith(Filter)); + case CodeCompletionResult::RK_Keyword: + return !StringRef(Result.Keyword).startswith(Filter); + case CodeCompletionResult::RK_Macro: + return !Result.Macro->getName().startswith(Filter); + case CodeCompletionResult::RK_Pattern: + return !StringRef(Result.Pattern->getAsString()).startswith(Filter); + } + // If we trigger this assert or the above switch yields a warning, then + // CodeCompletionResult has been enhanced with more kinds of completion + // results. Expand the switch above in this case. + assert(false && "Unknown completion result type?"); + // If we reach this, then we should just ignore whatever kind of unknown + // result we got back. We probably can't turn it into any kind of useful + // completion suggestion with the existing code. + return true; + } + + /// \name Code-completion callbacks + /// Process the finalized code-completion results. + void ProcessCodeCompleteResults(Sema &SemaRef, CodeCompletionContext Context, + CodeCompletionResult *Results, + unsigned NumResults) override { + + // The Sema put the incomplete token we try to complete in here during + // lexing, so we need to retrieve it here to know what we are completing. + StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter(); + + // Iterate over all the results. Filter out results we don't want and + // process the rest. + for (unsigned I = 0; I != NumResults; ++I) { + // Filter the results with the information from the Sema. + if (!Filter.empty() && isResultFilteredOut(Filter, Results[I])) + continue; + + CodeCompletionResult &R = Results[I]; + std::string ToInsert; + std::string Description; + // Handle the different completion kinds that come from the Sema. + switch (R.Kind) { + case CodeCompletionResult::RK_Declaration: { + const NamedDecl *D = R.Declaration; + ToInsert = R.Declaration->getNameAsString(); + // If we have a function decl that has no arguments we want to + // complete the empty parantheses for the user. If the function has + // arguments, we at least complete the opening bracket. + if (const FunctionDecl *F = dyn_cast(D)) { + if (F->getNumParams() == 0) + ToInsert += "()"; + else + ToInsert += "("; + raw_string_ostream OS(Description); + F->print(OS, m_desc_policy, false); + OS.flush(); + } else if (const VarDecl *V = dyn_cast(D)) { + Description = V->getType().getAsString(m_desc_policy); + } else if (const FieldDecl *F = dyn_cast(D)) { + Description = F->getType().getAsString(m_desc_policy); + } else if (const NamespaceDecl *N = dyn_cast(D)) { + // If we try to complete a namespace, then we can directly append + // the '::'. + if (!N->isAnonymousNamespace()) + ToInsert += "::"; + } + break; + } + case CodeCompletionResult::RK_Keyword: + ToInsert = R.Keyword; + break; + case CodeCompletionResult::RK_Macro: + ToInsert = R.Macro->getName().str(); + break; + case CodeCompletionResult::RK_Pattern: + ToInsert = R.Pattern->getTypedText(); + break; + } + // At this point all information is in the ToInsert string. + + // We also filter some internal lldb identifiers here. The user + // shouldn't see these. + if (StringRef(ToInsert).startswith("$__lldb_")) + continue; + if (!ToInsert.empty()) { + // Merge the suggested Token into the existing command line to comply + // with the kind of result the lldb API expects. + std::string CompletionSuggestion = + mergeCompletion(m_expr, m_position, ToInsert); + m_request.AddCompletion(CompletionSuggestion, Description); + } + } + } + + /// \param S the semantic-analyzer object for which code-completion is being + /// done. + /// + /// \param CurrentArg the index of the current argument. + /// + /// \param Candidates an array of overload candidates. + /// + /// \param NumCandidates the number of overload candidates + void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, + OverloadCandidate *Candidates, + unsigned NumCandidates, + SourceLocation OpenParLoc) override { + // At the moment we don't filter out any overloaded candidates. + } + + CodeCompletionAllocator &getAllocator() override { + return m_info.getAllocator(); + } + + CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return m_info; } +}; +} // namespace + +bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line, + unsigned pos, unsigned typed_pos) { + DiagnosticManager mgr; + // We need the raw user expression here because that's what the CodeComplete + // class uses to provide completion suggestions. + // However, the `Text` method only gives us the transformed expression here. + // To actually get the raw user input here, we have to cast our expression to + // the LLVMUserExpression which exposes the right API. This should never fail + // as we always have a ClangUserExpression whenever we call this. + LLVMUserExpression &llvm_expr = *static_cast(&m_expr); + CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr.GetUserText(), + typed_pos); + // We don't need a code generator for parsing. + m_code_generator.reset(); + // Start parsing the expression with our custom code completion consumer. + ParseInternal(mgr, &CC, line, pos); + return true; +} + +// Swift only +// Extra arguments are only used in Swift. We should get rid of them +// to avoid clashes when merging from upstream. +// End Swift only unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager, uint32_t first_line, uint32_t last_line, uint32_t line_offset) { + return ParseInternal(diagnostic_manager); +} + +unsigned +ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager, + CodeCompleteConsumer *completion_consumer, + unsigned completion_line, + unsigned completion_column) { ClangDiagnosticManagerAdapter *adapter = static_cast( m_compiler->getDiagnostics().getClient()); @@ -615,8 +875,9 @@ unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager, const char *expr_text = m_expr.Text(); - clang::SourceManager &SourceMgr = m_compiler->getSourceManager(); + clang::SourceManager &source_mgr = m_compiler->getSourceManager(); bool created_main_file = false; + /* Swift only */ if (m_expr.GetOptions() && m_expr.GetOptions()->GetPoundLineFilePath() == NULL && m_compiler->getCodeGenOpts().getDebugInfo() == @@ -626,17 +887,55 @@ unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager, expr_text, *m_expr.GetOptions(), temp_source_path)) { auto file = m_file_manager->getFile(temp_source_path); if (file) { - SourceMgr.setMainFileID( - SourceMgr.createFileID(file, SourceLocation(), SrcMgr::C_User)); + source_mgr.setMainFileID( + source_mgr.createFileID(file, SourceLocation(), SrcMgr::C_User)); created_main_file = true; } } } + /* end swift only */ + + // Clang wants to do completion on a real file known by Clang's file manager, + // so we have to create one to make this work. + // TODO: We probably could also simulate to Clang's file manager that there + // is a real file that contains our code. + bool should_create_file = completion_consumer != nullptr; + + // We also want a real file on disk if we generate full debug info. + should_create_file |= m_compiler->getCodeGenOpts().getDebugInfo() == + codegenoptions::FullDebugInfo; + + if (should_create_file) { + int temp_fd = -1; + llvm::SmallString<128> result_path; + if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) { + tmpdir_file_spec.AppendPathComponent("lldb-%%%%%%.expr"); + std::string temp_source_path = tmpdir_file_spec.GetPath(); + llvm::sys::fs::createUniqueFile(temp_source_path, temp_fd, result_path); + } else { + llvm::sys::fs::createTemporaryFile("lldb", "expr", temp_fd, result_path); + } + + if (temp_fd != -1) { + lldb_private::File file(temp_fd, true); + const size_t expr_text_len = strlen(expr_text); + size_t bytes_written = expr_text_len; + if (file.Write(expr_text, bytes_written).Success()) { + if (bytes_written == expr_text_len) { + file.Close(); + source_mgr.setMainFileID( + source_mgr.createFileID(m_file_manager->getFile(result_path), + SourceLocation(), SrcMgr::C_User)); + created_main_file = true; + } + } + } + } if (!created_main_file) { std::unique_ptr memory_buffer = MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__); - SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(memory_buffer))); + source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer))); } diag_buf->BeginSourceFile(m_compiler->getLangOpts(), @@ -651,14 +950,30 @@ unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager, if (ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap()) decl_map->InstallCodeGenerator(m_code_generator.get()); + // If we want to parse for code completion, we need to attach our code + // completion consumer to the Sema and specify a completion position. + // While parsing the Sema will call this consumer with the provided + // completion suggestions. + if (completion_consumer) { + auto main_file = source_mgr.getFileEntryForID(source_mgr.getMainFileID()); + auto &PP = m_compiler->getPreprocessor(); + // Lines and columns start at 1 in Clang, but code completion positions are + // indexed from 0, so we need to add 1 to the line and column here. + ++completion_line; + ++completion_column; + PP.SetCodeCompletionPoint(main_file, completion_line, completion_column); + } + if (ast_transformer) { ast_transformer->Initialize(m_compiler->getASTContext()); ParseAST(m_compiler->getPreprocessor(), ast_transformer, - m_compiler->getASTContext()); + m_compiler->getASTContext(), false, TU_Complete, + completion_consumer); } else { m_code_generator->Initialize(m_compiler->getASTContext()); ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(), - m_compiler->getASTContext()); + m_compiler->getASTContext(), false, TU_Complete, + completion_consumer); } diag_buf->EndSourceFile(); @@ -950,9 +1265,9 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution( if (!dynamic_checkers->Install(install_diagnostics, exe_ctx)) { if (install_diagnostics.Diagnostics().size()) - err.SetErrorString("couldn't install checkers, unknown error"); - else err.SetErrorString(install_diagnostics.GetString().c_str()); + else + err.SetErrorString("couldn't install checkers, unknown error"); return err; } diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h index 918551e54301..f5c2907c4ecd 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h @@ -1,9 +1,8 @@ //===-- ClangExpressionParser.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,6 +19,10 @@ #include #include +namespace clang { +class CodeCompleteConsumer; +} + namespace lldb_private { class IRExecutionUnit; @@ -58,6 +61,9 @@ class ClangExpressionParser : public ExpressionParser { //------------------------------------------------------------------ ~ClangExpressionParser() override; + bool Complete(CompletionRequest &request, unsigned line, unsigned pos, + unsigned typed_pos) override; + //------------------------------------------------------------------ /// Parse a single expression and convert it to IR using Clang. Don't wrap /// the expression in anything at all. @@ -145,6 +151,33 @@ class ClangExpressionParser : public ExpressionParser { std::string GetClangTargetABI(const ArchSpec &target_arch); private: + //------------------------------------------------------------------ + /// Parses the expression. + /// + /// @param[in] diagnostic_manager + /// The diagnostic manager that should receive the diagnostics + /// from the parsing process. + /// + /// @param[in] completion + /// The completion consumer that should be used during parsing + /// (or a nullptr if no consumer should be attached). + /// + /// @param[in] completion_line + /// The line in which the completion marker should be placed. + /// The first line is represented by the value 0. + /// + /// @param[in] completion_column + /// The column in which the completion marker should be placed. + /// The first column is represented by the value 0. + /// + /// @return + /// The number of parsing errors. + //------------------------------------------------------------------- + unsigned ParseInternal(DiagnosticManager &diagnostic_manager, + clang::CodeCompleteConsumer *completion = nullptr, + unsigned completion_line = 0, + unsigned completion_column = 0); + std::unique_ptr m_llvm_context; ///< The LLVM context to generate IR into std::unique_ptr diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp index 624cbf2a1a4f..b510cd8b9898 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp @@ -1,9 +1,8 @@ //===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h index 7d5ced5b4705..731ab14dbbde 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h +++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h @@ -1,29 +1,24 @@ //===-- ClangExpressionVariable.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangExpressionVariable_h_ #define liblldb_ClangExpressionVariable_h_ -// C Includes #include #include #include -// C++ Includes #include #include #include -// Other libraries and framework includes #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" #include "lldb/Expression/ExpressionVariable.h" diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp index e3e0ed49181e..27672078c926 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp @@ -1,9 +1,8 @@ //===-- ClangFunctionCaller.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,9 +11,6 @@ #include "ASTStructExtractor.h" #include "ClangExpressionParser.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/AST/ASTContext.h" #include "clang/AST/RecordLayout.h" #include "clang/CodeGen/CodeGenAction.h" @@ -25,9 +21,7 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/IR/Module.h" -// Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/IRExecutionUnit.h" @@ -44,6 +38,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb_private; diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h index 438cf0c713da..d730acdf784a 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h +++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h @@ -1,19 +1,14 @@ //===-- ClangFunctionCaller.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangFunctionCaller_h_ #define liblldb_ClangFunctionCaller_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "ClangExpressionHelper.h" #include "lldb/Core/Address.h" diff --git a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp index 95933754bc06..3b1375db5d15 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp @@ -1,9 +1,8 @@ //===-- ClangHost.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,7 +16,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" -// Project includes +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #if !defined(_WIN32) #include "lldb/Host/posix/HostInfoPosix.h" @@ -44,7 +43,7 @@ static bool DefaultComputeClangDirectory(FileSpec &file_spec) { #if defined(__APPLE__) static bool VerifyClangPath(const llvm::Twine &clang_path) { - if (llvm::sys::fs::is_directory(clang_path)) + if (FileSystem::Instance().IsDirectory(clang_path)) return true; Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (log) @@ -86,7 +85,8 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec, "Developer/Toolchains/XcodeDefault.xctoolchain", swift_clang_resource_dir); if (!verify || VerifyClangPath(clang_path)) { - file_spec.SetFile(clang_path.c_str(), true, FileSpec::Style::native); + file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native); + FileSystem::Instance().Resolve(file_spec); return true; } } else if (parent != r_end && *parent == "PrivateFrameworks" && @@ -100,7 +100,8 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec, raw_path.resize(parent - r_end); llvm::sys::path::append(clang_path, raw_path, swift_clang_resource_dir); if (!verify || VerifyClangPath(clang_path)) { - file_spec.SetFile(clang_path.c_str(), true, FileSpec::Style::native); + file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native); + FileSystem::Instance().Resolve(file_spec); return true; } raw_path = lldb_shlib_spec.GetPath(); @@ -112,7 +113,8 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec, // Fall back to the Clang resource directory inside the framework. raw_path.append("LLDB.framework/Resources/Clang"); - file_spec.SetFile(raw_path.c_str(), true, FileSpec::Style::native); + file_spec.SetFile(raw_path.c_str(), FileSpec::Style::native); + FileSystem::Instance().Resolve(file_spec); return true; } diff --git a/source/Plugins/ExpressionParser/Clang/ClangHost.h b/source/Plugins/ExpressionParser/Clang/ClangHost.h index 4fe423adb1a5..ab75a4334b8c 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangHost.h +++ b/source/Plugins/ExpressionParser/Clang/ClangHost.h @@ -1,9 +1,8 @@ //===-- ClangHost.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 60724b75a46e..319cb4969f2e 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -1,17 +1,13 @@ //===-- ClangModulesDeclVendor.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" @@ -24,7 +20,6 @@ #include "llvm/Support/Path.h" #include "llvm/Support/Threading.h" -// Project includes #include "ClangHost.h" #include "ClangModulesDeclVendor.h" @@ -146,11 +141,6 @@ void StoringDiagnosticConsumer::DumpDiagnostics(Stream &error_stream) { } } -static FileSpec GetResourceDir() { - static FileSpec g_cached_resource_dir = GetClangResourceDir(); - return g_cached_resource_dir; -} - ClangModulesDeclVendor::ClangModulesDeclVendor() {} ClangModulesDeclVendor::~ClangModulesDeclVendor() {} @@ -622,7 +612,7 @@ ClangModulesDeclVendor::Create(Target &target) { { FileSpec clang_resource_dir = GetClangResourceDir(); - if (llvm::sys::fs::is_directory(clang_resource_dir.GetPath())) { + if (FileSystem::Instance().IsDirectory(clang_resource_dir.GetPath())) { compiler_invocation_arguments.push_back("-resource-dir"); compiler_invocation_arguments.push_back(clang_resource_dir.GetPath()); } @@ -633,7 +623,8 @@ ClangModulesDeclVendor::Create(Target &target) { new StoringDiagnosticConsumer); std::vector compiler_invocation_argument_cstrs; - + compiler_invocation_argument_cstrs.reserve( + compiler_invocation_arguments.size()); for (const std::string &arg : compiler_invocation_arguments) { compiler_invocation_argument_cstrs.push_back(arg.c_str()); } diff --git a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h index 9290333a06ec..a386b5f20b3e 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h +++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h @@ -1,9 +1,8 @@ //===-- ClangModulesDeclVendor.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -106,7 +105,7 @@ class ClangModulesDeclVendor : public DeclVendor { //------------------------------------------------------------------ /// Query whether Clang supports modules for a particular language. /// LLDB uses this to decide whether to try to find the modules loaded - /// by a gaiven compile unit. + /// by a given compile unit. /// /// @param[in] language /// The language to query for. diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp index ab79a5c22bd2..fadae390b92c 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -1,9 +1,8 @@ //===-- ClangPersistentVariables.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h index 96122bd57f5e..a0446da241da 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h +++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h @@ -1,21 +1,16 @@ //===-- ClangPersistentVariables.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangPersistentVariables_h_ #define liblldb_ClangPersistentVariables_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes #include "ClangExpressionVariable.h" #include "ClangModulesDeclVendor.h" diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index f770b7574515..b6068b0e5a02 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -1,9 +1,8 @@ //===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -384,9 +383,9 @@ static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) { } } -llvm::Optional ClangUserExpression::GetLanguageForExpr( +void ClangUserExpression::UpdateLanguageForExpr( DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; + m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown; std::string prefix = m_expr_prefix; @@ -398,24 +397,33 @@ llvm::Optional ClangUserExpression::GetLanguageForExpr( m_expr_text.c_str())); if (m_language_flags & eLanguageFlagInCPlusPlusMethod) - lang_type = lldb::eLanguageTypeC_plus_plus; + m_expr_lang = lldb::eLanguageTypeC_plus_plus; else if (m_language_flags & eLanguageFlagInObjectiveCMethod) - lang_type = lldb::eLanguageTypeObjC; + m_expr_lang = lldb::eLanguageTypeObjC; else - lang_type = lldb::eLanguageTypeC; + m_expr_lang = lldb::eLanguageTypeC; - m_options.SetLanguage(lang_type); + m_options.SetLanguage(m_expr_lang); uint32_t first_body_line = 0; - if (!source_code->GetText(m_transformed_text, lang_type, m_language_flags, + if (!source_code->GetText(m_transformed_text, m_expr_lang, m_language_flags, m_options, m_swift_generic_info, exe_ctx, first_body_line)) { diagnostic_manager.PutString(eDiagnosticSeverityError, "couldn't construct expression body"); - return llvm::Optional(); + return; + } + + // Find and store the start position of the original code inside the + // transformed code. We need this later for the code completion. + std::size_t original_start; + std::size_t original_end; + bool found_bounds = source_code->GetOriginalBodyBounds( + m_transformed_text, m_expr_lang, original_start, original_end); + if (found_bounds) { + m_user_expression_start_pos = original_start; } } - return lang_type; } bool ClangUserExpression::PrepareForParsing( @@ -439,6 +447,8 @@ bool ClangUserExpression::PrepareForParsing( ApplyObjcCastHack(m_expr_text); SetupDeclVendor(exe_ctx, m_target); + + UpdateLanguageForExpr(diagnostic_manager, exe_ctx); return true; } @@ -453,11 +463,6 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) { - lang_type = new_lang.getValue(); - } - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); @@ -517,7 +522,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, const std::string &fixed_expression = diagnostic_manager.GetFixedExpression(); if (ExpressionSourceCode::GetOriginalBodyBounds( - fixed_expression, lang_type, fixed_start, fixed_end)) + fixed_expression, m_expr_lang, fixed_start, fixed_end)) m_fixed_text = fixed_expression.substr(fixed_start, fixed_end - fixed_start); } @@ -595,7 +600,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, uint32_t limit_start_line = 0; uint32_t limit_end_line = 0; if (limit_file) { - limit_file_spec.SetFile(limit_file, false, FileSpec::Style::native); + limit_file_spec.SetFile(limit_file, FileSpec::Style::native); limit_start_line = m_options.GetPoundLineLine(); limit_end_line = limit_start_line + std::count(m_expr_text.begin(), m_expr_text.end(), '\n'); @@ -610,6 +615,116 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, return true; } +//------------------------------------------------------------------ +/// Converts an absolute position inside a given code string into +/// a column/line pair. +/// +/// @param[in] abs_pos +/// A absolute position in the code string that we want to convert +/// to a column/line pair. +/// +/// @param[in] code +/// A multi-line string usually representing source code. +/// +/// @param[out] line +/// The line in the code that contains the given absolute position. +/// The first line in the string is indexed as 1. +/// +/// @param[out] column +/// The column in the line that contains the absolute position. +/// The first character in a line is indexed as 0. +//------------------------------------------------------------------ +static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code, + unsigned &line, unsigned &column) { + // Reset to code position to beginning of the file. + line = 0; + column = 0; + + assert(abs_pos <= code.size() && "Absolute position outside code string?"); + + // We have to walk up to the position and count lines/columns. + for (std::size_t i = 0; i < abs_pos; ++i) { + // If we hit a line break, we go back to column 0 and enter a new line. + // We only handle \n because that's what we internally use to make new + // lines for our temporary code strings. + if (code[i] == '\n') { + ++line; + column = 0; + continue; + } + ++column; + } +} + +bool ClangUserExpression::Complete(ExecutionContext &exe_ctx, + CompletionRequest &request, + unsigned complete_pos) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + + // We don't want any visible feedback when completing an expression. Mostly + // because the results we get from an incomplete invocation are probably not + // correct. + DiagnosticManager diagnostic_manager; + + if (!PrepareForParsing(diagnostic_manager, exe_ctx)) + return false; + + if (log) + log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); + + ////////////////////////// + // Parse the expression + // + + m_materializer_ap.reset(new Materializer()); + + ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true); + + OnExit on_exit([this]() { ResetDeclMap(); }); + + if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) { + diagnostic_manager.PutString( + eDiagnosticSeverityError, + "current process state is unsuitable for expression parsing"); + + return false; + } + + if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { + DeclMap()->SetLookupsEnabled(true); + } + + Process *process = exe_ctx.GetProcessPtr(); + ExecutionContextScope *exe_scope = process; + + if (!exe_scope) + exe_scope = exe_ctx.GetTargetPtr(); + + ClangExpressionParser parser(exe_scope, *this, false); + + // We have to find the source code location where the user text is inside + // the transformed expression code. When creating the transformed text, we + // already stored the absolute position in the m_transformed_text string. The + // only thing left to do is to transform it into the line:column format that + // Clang expects. + + // The line and column of the user expression inside the transformed source + // code. + unsigned user_expr_line, user_expr_column; + if (m_user_expression_start_pos.hasValue()) + AbsPosToLineColumnPos(*m_user_expression_start_pos, m_transformed_text, + user_expr_line, user_expr_column); + else + return false; + + // The actual column where we have to complete is the start column of the + // user expression + the offset inside the user code that we were given. + const unsigned completion_column = user_expr_column + complete_pos; + parser.Complete(request, user_expr_line, completion_column, complete_pos); + + return true; +} + bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx, std::vector &args, lldb::addr_t struct_address, diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h index 946912cecdb4..0349c37d71cb 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h +++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h @@ -1,21 +1,16 @@ //===-- ClangUserExpression.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangUserExpression_h_ #define liblldb_ClangUserExpression_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "ASTResultSynthesizer.h" #include "ASTStructExtractor.h" #include "ClangExpressionDeclMap.h" @@ -157,6 +152,9 @@ class ClangUserExpression : public LLVMUserExpression { bool keep_result_in_memory, bool generate_debug_info, uint32_t line_offset = 0) override; + bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request, + unsigned complete_pos) override; + ExpressionTypeSystemHelper *GetTypeSystemHelper() override { return &m_type_system_helper; } @@ -188,8 +186,8 @@ class ClangUserExpression : public LLVMUserExpression { lldb::addr_t struct_address, DiagnosticManager &diagnostic_manager) override; - llvm::Optional GetLanguageForExpr( - DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx); + void UpdateLanguageForExpr(DiagnosticManager &diagnostic_manager, + ExecutionContext &exe_ctx); bool SetupPersistentState(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx); bool PrepareForParsing(DiagnosticManager &diagnostic_manager, @@ -212,6 +210,13 @@ class ClangUserExpression : public LLVMUserExpression { lldb::TargetSP m_target_sp; }; + /// The language type of the current expression. + lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown; + + /// The absolute character position in the transformed source code where the + /// user code (as typed by the user) starts. If the variable is empty, then we + /// were not able to calculate this position. + llvm::Optional m_user_expression_start_pos; ResultDelegate m_result_delegate; }; diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp index b195f543ab8f..083e77bb0904 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp +++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp @@ -1,9 +1,8 @@ //===-- ClangUtilityFunction.cpp ---------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,13 +10,11 @@ #include "ClangExpressionDeclMap.h" #include "ClangExpressionParser.h" -// C Includes #include #if HAVE_SYS_TYPES_H #include #endif -// C++ Includes #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h index a897a2b17087..48e13503417c 100644 --- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h +++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h @@ -1,23 +1,18 @@ //===-- ClangUtilityFunction.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangUtilityFunction_h_ #define liblldb_ClangUtilityFunction_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "ClangExpressionHelper.h" #include "lldb/Core/ClangForward.h" diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 84bf0c2fc2f5..49d96b8fd89f 100644 --- a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -1,9 +1,8 @@ //===-- IRForTarget.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,7 +24,6 @@ #include "clang/AST/ASTContext.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/dwarf.h" #include "lldb/Expression/IRExecutionUnit.h" #include "lldb/Expression/IRInterpreter.h" @@ -36,6 +34,7 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include @@ -310,7 +309,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) { lldb::TargetSP target_sp(m_execution_unit.GetTarget()); lldb_private::ExecutionContext exe_ctx(target_sp, true); - auto bit_size = + llvm::Optional bit_size = m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope()); if (!bit_size) { lldb_private::StreamString type_desc_stream; @@ -337,9 +336,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) { if (log) log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64, m_result_name.GetCString(), - m_result_type.GetByteSize(nullptr) - ? *m_result_type.GetByteSize(nullptr) - : 0); + m_result_type.GetByteSize(nullptr).getValueOr(0)); // Construct a new result global and set up its metadata @@ -783,11 +780,8 @@ bool IRForTarget::RewriteObjCConstStrings() { static bool IsObjCSelectorRef(Value *value) { GlobalVariable *global_variable = dyn_cast(value); - if (!global_variable || !global_variable->hasName() || - !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_")) - return false; - - return true; + return !(!global_variable || !global_variable->hasName() || + !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_")); } // This function does not report errors; its callers are responsible. @@ -958,11 +952,8 @@ bool IRForTarget::RewriteObjCSelectors(BasicBlock &basic_block) { static bool IsObjCClassReference(Value *value) { GlobalVariable *global_variable = dyn_cast(value); - if (!global_variable || !global_variable->hasName() || - !global_variable->getName().startswith("OBJC_CLASS_REFERENCES_")) - return false; - - return true; + return !(!global_variable || !global_variable->hasName() || + !global_variable->getName().startswith("OBJC_CLASS_REFERENCES_")); } // This function does not report errors; its callers are responsible. @@ -1264,12 +1255,9 @@ bool IRForTarget::MaterializeInitializer(uint8_t *data, Constant *initializer) { llvm::NextPowerOf2(constant_size) * 8); lldb_private::Status get_data_error; - if (!scalar.GetAsMemoryData(data, constant_size, - lldb_private::endian::InlHostByteOrder(), - get_data_error)) - return false; - - return true; + return scalar.GetAsMemoryData(data, constant_size, + lldb_private::endian::InlHostByteOrder(), + get_data_error) != 0; } else if (ConstantDataArray *array_initializer = dyn_cast(initializer)) { if (array_initializer->isString()) { @@ -1381,7 +1369,7 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) { value_type = global_variable->getType(); } - auto value_size = compiler_type.GetByteSize(nullptr); + llvm::Optional value_size = compiler_type.GetByteSize(nullptr); if (!value_size) return false; lldb::offset_t value_alignment = diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/source/Plugins/ExpressionParser/Clang/IRForTarget.h index c6c44b46023c..6e54dd92fa7f 100644 --- a/source/Plugins/ExpressionParser/Clang/IRForTarget.h +++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.h @@ -1,10 +1,9 @@ //===-- IRForTarget.h ---------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp b/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp index 2b0197fe0aac..42e240b48c36 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp +++ b/source/Plugins/ExpressionParser/Swift/SwiftASTManipulator.cpp @@ -40,58 +40,6 @@ using namespace lldb_private; -static void DumpGenericNames( - lldb_private::Stream &wrapped_stream, - llvm::ArrayRef generic_bindings) { - if (generic_bindings.empty()) - return; - - wrapped_stream.PutChar('<'); - - bool comma = false; - - for (const Expression::SwiftGenericInfo::Binding &binding : - generic_bindings) { - if (comma) - wrapped_stream.PutCString(", "); - comma = true; - - wrapped_stream.PutCString(binding.name); - } - - wrapped_stream.PutChar('>'); -} - -static void DumpPlaceholderArguments( - lldb_private::Stream &wrapped_stream, - llvm::ArrayRef generic_bindings) { - if (generic_bindings.empty()) - return; - - for (const Expression::SwiftGenericInfo::Binding &binding : - generic_bindings) { - const char *name = binding.name; - - wrapped_stream.Printf(", _ __lldb_placeholder_%s : UnsafePointer<%s>!", - name, name); - } -} - -static void DumpPlaceholdersIntoCall( - lldb_private::Stream &wrapped_stream, - llvm::ArrayRef generic_bindings) { - if (generic_bindings.empty()) - return; - - for (const Expression::SwiftGenericInfo::Binding &binding : - generic_bindings) { - wrapped_stream.Printf( - ",\n" - " (nil as UnsafePointer<$__lldb_typeof_generic_%s>?)", - binding.name); - } -} - swift::VarDecl::Specifier SwiftASTManipulator::VariableInfo::GetVarSpecifier() const { if (m_decl) @@ -1441,7 +1389,6 @@ swift::ValueDecl *SwiftASTManipulator::MakeGlobalTypealias( swift::ASTContext &ast_context = m_source_file.getASTContext(); - llvm::MutableArrayRef inherited; swift::TypeAliasDecl *type_alias_decl = new (ast_context) swift::TypeAliasDecl(source_loc, swift::SourceLoc(), name, source_loc, nullptr, &m_source_file); @@ -1458,8 +1405,8 @@ swift::ValueDecl *SwiftASTManipulator::MakeGlobalTypealias( ss.flush(); log->Printf("Made global type alias for %s (%p) in context (%p):\n%s", - name.get(), GetSwiftType(type).getPointer(), &ast_context, - s.c_str()); + name.get(), static_cast(GetSwiftType(type).getPointer()), + static_cast(&ast_context), s.c_str()); } if (type_alias_decl) { diff --git a/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp b/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp index 4ca0fb9eeaa1..17db7aa49e75 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp +++ b/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp @@ -777,7 +777,9 @@ static void CountLocals( swift_type->dump(ss); ss.flush(); log->Printf("Adding injected self: type (%p) context(%p) is: %s", - swift_type, ast_context.GetASTContext(), s.c_str()); + static_cast(swift_type.getPointer()), + static_cast(ast_context.GetASTContext()), + s.c_str()); } } } @@ -1421,15 +1423,18 @@ ParseAndImport(SwiftASTContext *swift_ast_context, Expression &expr, // turned on. swift::verify(*source_file); - ParsedExpression result = {std::move(code_manipulator), - *ast_context, - module, - *external_lookup, - *source_file, - std::move(main_filename)}; + ParsedExpression result = { + std::move(code_manipulator), *ast_context, module, *external_lookup, + *source_file, std::move(main_filename), /*buffer_id*/0, + }; return std::move(result); } +bool SwiftExpressionParser::Complete(CompletionRequest &request, unsigned line, + unsigned pos, unsigned typed_pos) { + return false; +} + unsigned SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager, uint32_t first_line, uint32_t last_line, uint32_t line_offset) { diff --git a/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.h b/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.h index e8edacb27390..1c540b27bcde 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.h +++ b/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.h @@ -62,6 +62,15 @@ class SwiftExpressionParser : public ExpressionParser { SwiftExpressionParser(ExecutionContextScope *exe_scope, Expression &expr, const EvaluateExpressionOptions &options); + //------------------------------------------------------------------ + /// Attempts to find possible command line completions for the given + /// expression. + /// + /// Currently unimplemented for Swift. + //------------------------------------------------------------------ + bool Complete(CompletionRequest &request, unsigned line, unsigned pos, + unsigned typed_pos) override; + //------------------------------------------------------------------ /// Parse a single expression and convert it to IR using Swift. Don't /// wrap the expression in anything at all. diff --git a/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp b/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp index 7e7d66efc195..98e22c81ff3a 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp +++ b/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp @@ -111,7 +111,7 @@ lldb::REPLSP SwiftREPL::CreateInstanceFromDebugger(Status &err, repl_executable.GetFilename().SetCString("repl_swift"); std::string repl_exe_path(repl_executable.GetPath()); - if (!repl_executable.Exists()) { + if (!FileSystem::Instance().Exists(repl_executable)) { err.SetErrorStringWithFormat("REPL executable does not exist: '%s'", repl_exe_path.c_str()); return nullptr; @@ -347,7 +347,7 @@ lldb::offset_t SwiftREPL::GetDesiredIndentation(const StringList &lines, if (cursor_position == 0 || last_line[cursor_position - 1] == '}') { // The brace must be the first non-space character - const int actual_indent = REPL::CalculateActualIndentation(lines); + const size_t actual_indent = REPL::CalculateActualIndentation(lines); if (last_line.length() > actual_indent && last_line[actual_indent] == '}') { // Stop searching once a reason to unindent was found @@ -419,7 +419,7 @@ bool isThrownError(ValueObjectSP valobj_sp) { return false; if (name_cstr[1] != 'E') return false; - for (int index = 2; index < length; index++) { + for (size_t index = 2; index < length; index++) { char digit = name_cstr[index]; if (digit < '0' || digit > '9') diff --git a/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.cpp b/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.cpp index 0a7b1fd31917..518d77ecfe51 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.cpp +++ b/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.cpp @@ -297,9 +297,9 @@ class EntityREPLPersistentVariable : public Materializer::Entity { EntityREPLPersistentVariable( lldb::ExpressionVariableSP &persistent_variable_sp, SwiftREPLMaterializer *parent, - Materializer::PersistentVariableDelegate *delegate) + Materializer::PersistentVariableDelegate *) : Entity(), m_persistent_variable_sp(persistent_variable_sp), - m_parent(parent), m_delegate(delegate) { + m_parent(parent) { // Hard-coding to maximum size of a pointer since persistent variables are // materialized by reference m_size = 8; @@ -452,7 +452,6 @@ class EntityREPLPersistentVariable : public Materializer::Entity { private: lldb::ExpressionVariableSP m_persistent_variable_sp; SwiftREPLMaterializer *m_parent; - Materializer::PersistentVariableDelegate *m_delegate; }; uint32_t SwiftREPLMaterializer::AddPersistentVariable( diff --git a/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp b/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp index fdfb3b9da5fa..3154a634ab7c 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp +++ b/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.cpp @@ -508,7 +508,7 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager, uint32_t limit_start_line = 0; uint32_t limit_end_line = 0; if (limit_file) { - limit_file_spec.SetFile(limit_file, false, FileSpec::Style::native); + limit_file_spec.SetFile(limit_file, FileSpec::Style::native); limit_start_line = m_options.GetPoundLineLine(); limit_end_line = limit_start_line + std::count(m_expr_text.begin(), m_expr_text.end(), '\n'); @@ -622,9 +622,8 @@ lldb::ExpressionVariableSP SwiftUserExpression::GetResultAfterDematerialization( } SwiftUserExpression::ResultDelegate::ResultDelegate( - lldb::TargetSP target, SwiftUserExpression &user_expression, bool is_error) - : m_target_sp(target), m_user_expression(user_expression), - m_is_error(is_error) {} + lldb::TargetSP target, SwiftUserExpression &, bool is_error) + : m_target_sp(target), m_is_error(is_error) {} ConstString SwiftUserExpression::ResultDelegate::GetName() { auto prefix = m_persistent_state->GetPersistentVariablePrefix(m_is_error); @@ -647,8 +646,7 @@ lldb::ExpressionVariableSP &SwiftUserExpression::ResultDelegate::GetVariable() { } SwiftUserExpression::PersistentVariableDelegate::PersistentVariableDelegate( - SwiftUserExpression &user_expression) - : m_user_expression(user_expression) {} + SwiftUserExpression &) {} ConstString SwiftUserExpression::PersistentVariableDelegate::GetName() { return ConstString(); diff --git a/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.h b/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.h index 65fdc10045f2..0dbd0033344f 100644 --- a/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.h +++ b/source/Plugins/ExpressionParser/Swift/SwiftUserExpression.h @@ -51,13 +51,10 @@ class SwiftUserExpression : public LLVMUserExpression { class SwiftUserExpressionHelper : public ExpressionTypeSystemHelper { public: - SwiftUserExpressionHelper(Target &target) - : ExpressionTypeSystemHelper(eKindSwiftHelper), m_target(target) {} + SwiftUserExpressionHelper(Target &) + : ExpressionTypeSystemHelper(eKindSwiftHelper) {} ~SwiftUserExpressionHelper() {} - - private: - Target &m_target; }; //------------------------------------------------------------------ @@ -166,7 +163,6 @@ class SwiftUserExpression : public LLVMUserExpression { private: lldb::TargetSP m_target_sp; - SwiftUserExpression &m_user_expression; PersistentExpressionState *m_persistent_state; lldb::ExpressionVariableSP m_variable; bool m_is_error; @@ -181,9 +177,6 @@ class SwiftUserExpression : public LLVMUserExpression { PersistentVariableDelegate(SwiftUserExpression &); ConstString GetName() override; void DidDematerialize(lldb::ExpressionVariableSP &variable) override; - - private: - SwiftUserExpression &m_user_expression; }; PersistentVariableDelegate m_persistent_variable_delegate; diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index 708d6d1c318c..dae19f2dbdcd 100644 --- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -1,9 +1,8 @@ //===-- EmulateInstructionARM.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,8 +25,7 @@ #include "Utility/ARM_DWARF_Registers.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/Support/MathExtras.h" // for SignExtend32 template function - // and countTrailingZeros function +#include "llvm/Support/MathExtras.h" using namespace lldb; using namespace lldb_private; @@ -777,10 +775,7 @@ bool EmulateInstructionARM::WriteBits32UnknownToMemory(addr_t address) { uint32_t random_data = rand(); const uint32_t addr_byte_size = GetAddressByteSize(); - if (!MemAWrite(context, address, random_data, addr_byte_size)) - return false; - - return true; + return MemAWrite(context, address, random_data, addr_byte_size); } // Write "bits (32) UNKNOWN" to register n. Helper function for many ARM @@ -3341,10 +3336,7 @@ bool EmulateInstructionARM::EmulateCMNImm(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteFlags(context, res.result, res.carry_out, res.overflow)) - return false; - - return true; + return WriteFlags(context, res.result, res.carry_out, res.overflow); } // Compare Negative (register) adds a register value and an optionally-shifted @@ -3411,10 +3403,7 @@ bool EmulateInstructionARM::EmulateCMNReg(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteFlags(context, res.result, res.carry_out, res.overflow)) - return false; - - return true; + return WriteFlags(context, res.result, res.carry_out, res.overflow); } // Compare (immediate) subtracts an immediate value from a register value. It @@ -3464,10 +3453,7 @@ bool EmulateInstructionARM::EmulateCMPImm(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteFlags(context, res.result, res.carry_out, res.overflow)) - return false; - - return true; + return WriteFlags(context, res.result, res.carry_out, res.overflow); } // Compare (register) subtracts an optionally-shifted register value from a @@ -3543,10 +3529,7 @@ bool EmulateInstructionARM::EmulateCMPReg(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteFlags(context, res.result, res.carry_out, res.overflow)) - return false; - - return true; + return WriteFlags(context, res.result, res.carry_out, res.overflow); } // Arithmetic Shift Right (immediate) shifts a register value right by an @@ -9246,11 +9229,8 @@ bool EmulateInstructionARM::EmulateRSBImm(const uint32_t opcode, context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // Reverse Subtract (register) subtracts a register value from an optionally- @@ -9327,11 +9307,8 @@ bool EmulateInstructionARM::EmulateRSBReg(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // Reverse Subtract with Carry (immediate) subtracts a register value and the @@ -9389,11 +9366,8 @@ bool EmulateInstructionARM::EmulateRSCImm(const uint32_t opcode, context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // Reverse Subtract with Carry (register) subtracts a register value and the @@ -9461,11 +9435,8 @@ bool EmulateInstructionARM::EmulateRSCReg(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // Subtract with Carry (immediate) subtracts an immediate value and the value @@ -9532,11 +9503,8 @@ bool EmulateInstructionARM::EmulateSBCImm(const uint32_t opcode, context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // Subtract with Carry (register) subtracts an optionally-shifted register @@ -9621,11 +9589,8 @@ bool EmulateInstructionARM::EmulateSBCReg(const uint32_t opcode, EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // This instruction subtracts an immediate value from a register value, and @@ -9714,11 +9679,8 @@ bool EmulateInstructionARM::EmulateSUBImmThumb(const uint32_t opcode, context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs(); - if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, - res.carry_out, res.overflow)) - return false; - - return true; + return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags, + res.carry_out, res.overflow); } // This instruction subtracts an immediate value from a register value, and @@ -14154,11 +14116,8 @@ bool EmulateInstructionARM::BranchWritePC(const Context &context, else target = addr & 0xfffffffe; - if (!WriteRegisterUnsigned(context, eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_PC, target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_PC, target); } // As a side effect, BXWritePC sets context.arg2 to eModeARM or eModeThumb by @@ -14192,11 +14151,8 @@ bool EmulateInstructionARM::BXWritePC(Context &context, uint32_t addr) { LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) return false; } - if (!WriteRegisterUnsigned(context, eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_PC, target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_PC, target); } // Dispatches to either BXWritePC or BranchWritePC based on architecture @@ -14409,14 +14365,14 @@ bool EmulateInstructionARM::EvaluateInstruction(uint32_t evaluate_options) { evaluate_options & eEmulateInstructionOptionIgnoreConditions; bool success = false; - if (m_opcode_cpsr == 0 || m_ignore_conditions == false) { + if (m_opcode_cpsr == 0 || !m_ignore_conditions) { m_opcode_cpsr = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_cpsr, 0, &success); } // Only return false if we are unable to read the CPSR if we care about // conditions - if (success == false && m_ignore_conditions == false) + if (!success && !m_ignore_conditions) return false; uint32_t orig_pc_value = 0; diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h index fb1867c6362a..afb1b979872b 100644 --- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h +++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h @@ -1,9 +1,8 @@ //===-- lldb_EmulateInstructionARM.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp index d1032f56f31c..37ec53bba2b3 100644 --- a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp +++ b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp @@ -1,20 +1,19 @@ //===-- EmulationStateARM.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "EmulationStateARM.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Interpreter/OptionValueArray.h" #include "lldb/Interpreter/OptionValueDictionary.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "Utility/ARM_DWARF_Registers.h" diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.h b/source/Plugins/Instruction/ARM/EmulationStateARM.h index f27f4755a177..5685f65c19b6 100644 --- a/source/Plugins/Instruction/ARM/EmulationStateARM.h +++ b/source/Plugins/Instruction/ARM/EmulationStateARM.h @@ -1,9 +1,8 @@ //===-- lldb_EmulationStateARM.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp index 2f484ab5ea97..978eab1882cf 100644 --- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -1,9 +1,8 @@ //===-- EmulateInstructionARM64.cpp ------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,10 +12,10 @@ #include "lldb/Core/Address.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Stream.h" #include "Plugins/Process/Utility/ARMDefines.h" @@ -41,8 +40,7 @@ #include "Plugins/Process/Utility/RegisterInfos_arm64.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/Support/MathExtras.h" // for SignExtend32 template function - // and CountTrailingZeros_32 function +#include "llvm/Support/MathExtras.h" #include "Plugins/Process/Utility/InstructionUtils.h" @@ -437,7 +435,7 @@ bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) { // Only return false if we are unable to read the CPSR if we care about // conditions - if (success == false && m_ignore_conditions == false) + if (!success && !m_ignore_conditions) return false; uint32_t orig_pc_value = 0; @@ -547,11 +545,8 @@ bool EmulateInstructionARM64::BranchTo(const Context &context, uint32_t N, } else return false; - if (!WriteRegisterUnsigned(context, eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_PC, addr)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_PC, addr); } bool EmulateInstructionARM64::ConditionHolds(const uint32_t cond) { @@ -1097,9 +1092,7 @@ bool EmulateInstructionARM64::EmulateB(const uint32_t opcode) { return false; } - if (!BranchTo(context, 64, target)) - return false; - return true; + return BranchTo(context, 64, target); } bool EmulateInstructionARM64::EmulateBcond(const uint32_t opcode) { diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h index 253bb935bca7..22123bfe9333 100644 --- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h +++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h @@ -1,19 +1,14 @@ //===-- EmulateInstructionARM64.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 EmulateInstructionARM64_h_ #define EmulateInstructionARM64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/ARMDefines.h" #include "lldb/Core/EmulateInstruction.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp index 65cda21b5341..ea49f08659ca 100644 --- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -1,9 +1,8 @@ //===-- EmulateInstructionMIPS.cpp -------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,12 +13,12 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Stream.h" #include "llvm-c/Disassembler.h" #include "llvm/MC/MCAsmInfo.h" @@ -35,7 +34,7 @@ #include "llvm/ADT/STLExtras.h" #include "Plugins/Process/Utility/InstructionUtils.h" -#include "Plugins/Process/Utility/RegisterContext_mips.h" //mips32 has same registers nos as mips64 +#include "Plugins/Process/Utility/RegisterContext_mips.h" using namespace lldb; using namespace lldb_private; @@ -220,10 +219,8 @@ EmulateInstructionMIPS::CreateInstance(const ArchSpec &arch, } bool EmulateInstructionMIPS::SetTargetTriple(const ArchSpec &arch) { - if (arch.GetTriple().getArch() == llvm::Triple::mips || - arch.GetTriple().getArch() == llvm::Triple::mipsel) - return true; - return false; + return arch.GetTriple().getArch() == llvm::Triple::mips || + arch.GetTriple().getArch() == llvm::Triple::mipsel; } const char *EmulateInstructionMIPS::GetRegisterName(unsigned reg_num, @@ -1353,10 +1350,7 @@ bool EmulateInstructionMIPS::Emulate_LW(llvm::MCInst &insn) { context.type = eContextPopRegisterOffStack; context.SetAddress(address); - if (!WriteRegister(context, ®_info_src, data_src)) - return false; - - return true; + return WriteRegister(context, ®_info_src, data_src); } return false; @@ -1456,11 +1450,8 @@ bool EmulateInstructionMIPS::Emulate_LUI(llvm::MCInst &insn) { context.SetImmediateSigned(imm); context.type = eContextImmediate; - if (WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips + rt, - imm)) - return true; - - return false; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, + dwarf_zero_mips + rt, imm); } bool EmulateInstructionMIPS::Emulate_ADDIUSP(llvm::MCInst &insn) { @@ -1703,10 +1694,7 @@ bool EmulateInstructionMIPS::Emulate_LWSP(llvm::MCInst &insn) { context.type = eContextPopRegisterOffStack; context.SetAddress(base_address); - if (!WriteRegister(context, ®_info_src, data_src)) - return false; - - return true; + return WriteRegister(context, ®_info_src, data_src); } return false; @@ -1813,11 +1801,8 @@ bool EmulateInstructionMIPS::Emulate_JRADDIUSP(llvm::MCInst &insn) { context.type = eContextAdjustStackPointer; // update SP - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, - result)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, + result); } static int IsAdd64bitOverflow(int32_t a, int32_t b) { @@ -1872,11 +1857,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_3ops(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } /* @@ -1959,11 +1941,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_3ops_C(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(current_inst_size + offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } /* @@ -2140,11 +2119,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_2ops(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } /* @@ -2209,11 +2185,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_2ops_C(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(current_inst_size + offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_B16_MM(llvm::MCInst &insn) { @@ -2234,11 +2207,8 @@ bool EmulateInstructionMIPS::Emulate_B16_MM(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(current_inst_size + offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } /* @@ -2555,11 +2525,8 @@ bool EmulateInstructionMIPS::Emulate_BC(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_J(llvm::MCInst &insn) { @@ -2582,10 +2549,7 @@ bool EmulateInstructionMIPS::Emulate_J(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, pc)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, pc); } bool EmulateInstructionMIPS::Emulate_JAL(llvm::MCInst &insn) { @@ -2714,11 +2678,8 @@ bool EmulateInstructionMIPS::Emulate_JIC(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_JR(llvm::MCInst &insn) { @@ -2739,11 +2700,8 @@ bool EmulateInstructionMIPS::Emulate_JR(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - rs_val)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + rs_val); } /* @@ -2786,11 +2744,8 @@ bool EmulateInstructionMIPS::Emulate_FP_branch(llvm::MCInst &insn) { } Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_BC1EQZ(llvm::MCInst &insn) { @@ -2825,11 +2780,8 @@ bool EmulateInstructionMIPS::Emulate_BC1EQZ(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_BC1NEZ(llvm::MCInst &insn) { @@ -2864,11 +2816,8 @@ bool EmulateInstructionMIPS::Emulate_BC1NEZ(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } /* @@ -2928,11 +2877,8 @@ bool EmulateInstructionMIPS::Emulate_3D_branch(llvm::MCInst &insn) { } Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_BNZB(llvm::MCInst &insn) { @@ -3023,11 +2969,8 @@ bool EmulateInstructionMIPS::Emulate_MSA_Branch_DF(llvm::MCInst &insn, Context context; context.type = eContextRelativeBranchImmediate; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_BNZV(llvm::MCInst &insn) { @@ -3069,11 +3012,8 @@ bool EmulateInstructionMIPS::Emulate_MSA_Branch_V(llvm::MCInst &insn, Context context; context.type = eContextRelativeBranchImmediate; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, + target); } bool EmulateInstructionMIPS::Emulate_LDST_Imm(llvm::MCInst &insn) { diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h index 8d6e0be3cd78..9f1eb5b4ab9b 100644 --- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h +++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h @@ -1,10 +1,9 @@ //===-- EmulateInstructionMIPS.h ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp index 9dac3fd0e2ed..73b5a0bb1d65 100644 --- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -1,9 +1,8 @@ //===-- EmulateInstructionMIPS64.cpp -----------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,12 +13,12 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/PosixApi.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Stream.h" #include "llvm-c/Disassembler.h" #include "llvm/MC/MCAsmInfo.h" @@ -207,10 +206,8 @@ EmulateInstructionMIPS64::CreateInstance(const ArchSpec &arch, } bool EmulateInstructionMIPS64::SetTargetTriple(const ArchSpec &arch) { - if (arch.GetTriple().getArch() == llvm::Triple::mips64 || - arch.GetTriple().getArch() == llvm::Triple::mips64el) - return true; - return false; + return arch.GetTriple().getArch() == llvm::Triple::mips64 || + arch.GetTriple().getArch() == llvm::Triple::mips64el; } const char *EmulateInstructionMIPS64::GetRegisterName(unsigned reg_num, @@ -1243,10 +1240,7 @@ bool EmulateInstructionMIPS64::Emulate_LD(llvm::MCInst &insn) { Context context; context.type = eContextRegisterLoad; - if (!WriteRegister(context, ®_info_src, data_src)) - return false; - - return true; + return WriteRegister(context, ®_info_src, data_src); } return false; @@ -1265,11 +1259,8 @@ bool EmulateInstructionMIPS64::Emulate_LUI(llvm::MCInst &insn) { context.SetImmediateSigned(imm); context.type = eContextImmediate; - if (WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips64 + rt, - imm)) - return true; - - return false; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, + dwarf_zero_mips64 + rt, imm); } bool EmulateInstructionMIPS64::Emulate_DSUBU_DADDU(llvm::MCInst &insn) { @@ -1401,11 +1392,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_3ops(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } /* @@ -1646,11 +1634,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_2ops(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_BC(llvm::MCInst &insn) { @@ -1672,11 +1657,8 @@ bool EmulateInstructionMIPS64::Emulate_BC(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } static int IsAdd64bitOverflow(int64_t a, int64_t b) { @@ -1762,11 +1744,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_3ops_C(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(current_inst_size + offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } /* @@ -1831,11 +1810,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_2ops_C(llvm::MCInst &insn) { context.type = eContextRelativeBranchImmediate; context.SetImmediate(current_inst_size + offset); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_J(llvm::MCInst &insn) { @@ -1858,10 +1834,8 @@ bool EmulateInstructionMIPS64::Emulate_J(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, pc)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + pc); } bool EmulateInstructionMIPS64::Emulate_JAL(llvm::MCInst &insn) { @@ -1990,11 +1964,8 @@ bool EmulateInstructionMIPS64::Emulate_JIC(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_JR(llvm::MCInst &insn) { @@ -2015,11 +1986,8 @@ bool EmulateInstructionMIPS64::Emulate_JR(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - rs_val)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + rs_val); } /* @@ -2071,11 +2039,8 @@ bool EmulateInstructionMIPS64::Emulate_FP_branch(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_BC1EQZ(llvm::MCInst &insn) { @@ -2110,11 +2075,8 @@ bool EmulateInstructionMIPS64::Emulate_BC1EQZ(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_BC1NEZ(llvm::MCInst &insn) { @@ -2149,11 +2111,8 @@ bool EmulateInstructionMIPS64::Emulate_BC1NEZ(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } /* @@ -2214,11 +2173,8 @@ bool EmulateInstructionMIPS64::Emulate_3D_branch(llvm::MCInst &insn) { Context context; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_BNZB(llvm::MCInst &insn) { @@ -2309,11 +2265,8 @@ bool EmulateInstructionMIPS64::Emulate_MSA_Branch_DF(llvm::MCInst &insn, Context context; context.type = eContextRelativeBranchImmediate; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_BNZV(llvm::MCInst &insn) { @@ -2355,11 +2308,8 @@ bool EmulateInstructionMIPS64::Emulate_MSA_Branch_V(llvm::MCInst &insn, Context context; context.type = eContextRelativeBranchImmediate; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, - target)) - return false; - - return true; + return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, + target); } bool EmulateInstructionMIPS64::Emulate_LDST_Imm(llvm::MCInst &insn) { diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h index c2433d59830e..953a0935bd06 100644 --- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h +++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h @@ -1,19 +1,14 @@ //===-- EmulateInstructionMIPS64.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 EmulateInstructionMIPS64_h_ #define EmulateInstructionMIPS64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/EmulateInstruction.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/Status.h" diff --git a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp index f3a9ca570a4a..86507619413c 100644 --- a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp +++ b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp @@ -1,9 +1,8 @@ //===-- EmulateInstructionPPC64.cpp ------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h index be65de9a5063..bf239770b933 100644 --- a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h +++ b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h @@ -1,19 +1,14 @@ //===-- EmulateInstructionPPC64.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 EmulateInstructionPPC64_h_ #define EmulateInstructionPPC64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/EmulateInstruction.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/Log.h" diff --git a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp index 9a6e39be0bfd..74f2fa9d253c 100644 --- a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp +++ b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp @@ -1,9 +1,8 @@ //===-- ASanRuntime.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h index e9af5a6cdc74..dba9e9309387 100644 --- a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h +++ b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h @@ -1,19 +1,14 @@ //===-- AddressSanitizerRuntime.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AddressSanitizerRuntime_h_ #define liblldb_AddressSanitizerRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp index 765822fed631..c5648ab11f3c 100644 --- a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp +++ b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp @@ -1,9 +1,8 @@ //===-- MainThreadCheckerRuntime.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h index 516d9fef5e8e..1dcbc0f6bc89 100644 --- a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h +++ b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h @@ -1,9 +1,8 @@ //===-- MainThreadCheckerRuntime.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/InstrumentationRuntime/SwiftRuntimeReporting/SwiftRuntimeReporting.cpp b/source/Plugins/InstrumentationRuntime/SwiftRuntimeReporting/SwiftRuntimeReporting.cpp index 214dc607e72e..958c5cf87cc7 100644 --- a/source/Plugins/InstrumentationRuntime/SwiftRuntimeReporting/SwiftRuntimeReporting.cpp +++ b/source/Plugins/InstrumentationRuntime/SwiftRuntimeReporting/SwiftRuntimeReporting.cpp @@ -86,7 +86,7 @@ static StructuredData::ArraySP ReadThreads(ProcessSP process_sp, addr_t addr) { uint64_t num_extra_threads = process_sp->ReadUnsignedIntegerFromMemory(addr, ptr_size, 0, read_error); if (num_extra_threads > 16) num_extra_threads = 16; addr_t threads_ptr = process_sp->ReadUnsignedIntegerFromMemory(addr + ptr_size, ptr_size, 0, read_error); - for (int i = 0; i < num_extra_threads; i++) { + for (size_t i = 0; i < num_extra_threads; i++) { StructuredData::ArraySP trace(new StructuredData::Array()); int thread_struct_stride = 3 * ptr_size + 8; addr_t thread_ptr = threads_ptr + i * thread_struct_stride; @@ -105,7 +105,7 @@ static StructuredData::ArraySP ReadThreads(ProcessSP process_sp, addr_t addr) { if (num_frames > 256) num_frames = 256; addr_t frames_ptr = process_sp->ReadUnsignedIntegerFromMemory( thread_ptr + 8 + 2 * ptr_size, ptr_size, 0, read_error); - for (int j = 0; j < num_frames; j++) { + for (size_t j = 0; j < num_frames; j++) { addr_t frame = process_sp->ReadUnsignedIntegerFromMemory( frames_ptr + j * ptr_size, ptr_size, 0, read_error); trace->AddItem( @@ -131,7 +131,7 @@ static StructuredData::ArraySP ReadFixits(ProcessSP process_sp, addr_t addr) { uint64_t num_fixits = process_sp->ReadUnsignedIntegerFromMemory(addr, ptr_size, 0, read_error); if (num_fixits > 16) num_fixits = 16; addr_t fixits_ptr = process_sp->ReadUnsignedIntegerFromMemory(addr + ptr_size, ptr_size, 0, read_error); - for (int i = 0; i < num_fixits; i++) { + for (size_t i = 0; i < num_fixits; i++) { int fixit_struct_stride = 6 * ptr_size; addr_t fixit_ptr = fixits_ptr + i * fixit_struct_stride; @@ -181,7 +181,7 @@ static StructuredData::ArraySP ReadNotes(ProcessSP process_sp, addr_t addr) { uint64_t num_notes = process_sp->ReadUnsignedIntegerFromMemory(addr, ptr_size, 0, read_error); if (num_notes > 16) num_notes = 16; addr_t fixits_ptr = process_sp->ReadUnsignedIntegerFromMemory(addr + ptr_size, ptr_size, 0, read_error); - for (int i = 0; i < num_notes; i++) { + for (size_t i = 0; i < num_notes; i++) { int note_struct_stride = 3 * ptr_size; addr_t note_ptr = fixits_ptr + i * note_struct_stride; @@ -299,7 +299,7 @@ SwiftRuntimeReporting::RetrieveReportData(ExecutionContextRef exe_ctx_ref) { thread->AddStringItem("description", current_stack_description); thread->AddIntegerItem("tid", thread_sp->GetIndexID()); threads->AddItem(thread); - for (int i = 0; i < extra_threads->GetSize(); i++) { + for (size_t i = 0; i < extra_threads->GetSize(); i++) { threads->AddItem(extra_threads->GetItemAtIndex(i)); } diff --git a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp index 1498c069272d..e51d7813ce93 100644 --- a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp +++ b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp @@ -1,9 +1,8 @@ //===-- TSanRuntime.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h index 594cabc03320..eaffb915bab0 100644 --- a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h +++ b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h @@ -1,19 +1,14 @@ //===-- ThreadSanitizerRuntime.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadSanitizerRuntime_h_ #define liblldb_ThreadSanitizerRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp index 1e9280c8c064..e400b8160c49 100644 --- a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp +++ b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp @@ -1,9 +1,8 @@ //===-- UBSanRuntime.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h index 8f138fc12073..7a604b89c80a 100644 --- a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h +++ b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h @@ -1,9 +1,8 @@ //===-- UndefinedBehaviorSanitizerRuntime.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index 48189d249840..7b19ca48476c 100644 --- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -1,13 +1,11 @@ //===-- JITLoaderGDB.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include "llvm/Support/MathExtras.h" @@ -315,7 +313,7 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) { char jit_name[64]; snprintf(jit_name, 64, "JIT(0x%" PRIx64 ")", symbolfile_addr); module_sp = m_process->ReadModuleFromMemory( - FileSpec(jit_name, false), symbolfile_addr, symbolfile_size); + FileSpec(jit_name), symbolfile_addr, symbolfile_size); if (module_sp && module_sp->GetObjectFile()) { // load the symbol table right away diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h index 6269860825db..17498af83d45 100644 --- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h +++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h @@ -1,21 +1,16 @@ //===-- JITLoaderGDB.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_JITLoaderGDB_h_ #define liblldb_JITLoaderGDB_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/JITLoader.h" #include "lldb/Target/Process.h" diff --git a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp index bb1a47c263cf..6086aff4ad9f 100644 --- a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -1,16 +1,11 @@ //===-- BlockPointer.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "BlockPointer.h" #include "lldb/Core/ValueObject.h" diff --git a/source/Plugins/Language/CPlusPlus/BlockPointer.h b/source/Plugins/Language/CPlusPlus/BlockPointer.h index e5008a8f3676..624c17a6a6af 100644 --- a/source/Plugins/Language/CPlusPlus/BlockPointer.h +++ b/source/Plugins/Language/CPlusPlus/BlockPointer.h @@ -1,9 +1,8 @@ //===-- BlockPointer.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/CMakeLists.txt b/source/Plugins/Language/CPlusPlus/CMakeLists.txt index 715334412f8e..bc357aa52b84 100644 --- a/source/Plugins/Language/CPlusPlus/CMakeLists.txt +++ b/source/Plugins/Language/CPlusPlus/CMakeLists.txt @@ -18,6 +18,7 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN LibStdcpp.cpp LibStdcppTuple.cpp LibStdcppUniquePointer.cpp + MSVCUndecoratedNameParser.cpp LINK_LIBS lldbCore diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index eb0c476ecdd3..def6801c4e42 100644 --- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1,29 +1,24 @@ //===-- CPlusPlusLanguage.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CPlusPlusLanguage.h" -// C Includes #include #include -// C++ Includes #include #include #include #include -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -#include "llvm/Demangle/Demangle.h" +#include "llvm/Demangle/ItaniumDemangle.h" -// Project includes #include "lldb/Core/PluginManager.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/DataFormatters/CXXFunctionPointer.h" @@ -41,6 +36,7 @@ #include "LibCxxAtomic.h" #include "LibCxxVariant.h" #include "LibStdcpp.h" +#include "MSVCUndecoratedNameParser.h" using namespace lldb; using namespace lldb_private; @@ -144,10 +140,7 @@ static bool IsTrivialBasename(const llvm::StringRef &basename) { } // We processed all characters. It is a vaild basename. - if (idx == basename.size()) - return true; - - return false; + return idx == basename.size(); } bool CPlusPlusLanguage::MethodName::TrySimplifiedParse() { @@ -265,6 +258,10 @@ bool CPlusPlusLanguage::IsCPPMangledName(const char *name) { bool CPlusPlusLanguage::ExtractContextAndIdentifier( const char *name, llvm::StringRef &context, llvm::StringRef &identifier) { + if (MSVCUndecoratedNameParser::IsMSVCUndecoratedName(name)) + return MSVCUndecoratedNameParser::ExtractContextAndIdentifier(name, context, + identifier); + CPlusPlusNameParser parser(name); if (auto full_name = parser.ParseAsFullName()) { identifier = full_name.getValue().basename; @@ -274,72 +271,89 @@ bool CPlusPlusLanguage::ExtractContextAndIdentifier( return false; } -/// Given a mangled function `mangled`, replace all the primitive function type -/// arguments of `search` with type `replace`. -static ConstString SubsPrimitiveParmItanium(llvm::StringRef mangled, - llvm::StringRef search, - llvm::StringRef replace) { - class PrimitiveParmSubs { - llvm::StringRef mangled; - llvm::StringRef search; - llvm::StringRef replace; - ptrdiff_t read_pos; - std::string output; - std::back_insert_iterator writer; +namespace { +class NodeAllocator { + llvm::BumpPtrAllocator Alloc; - public: - PrimitiveParmSubs(llvm::StringRef m, llvm::StringRef s, llvm::StringRef r) - : mangled(m), search(s), replace(r), read_pos(0), - writer(std::back_inserter(output)) {} - - void Substitute(llvm::StringRef tail) { - assert(tail.data() >= mangled.data() && - tail.data() < mangled.data() + mangled.size() && - "tail must point into range of mangled"); - - if (tail.startswith(search)) { - auto reader = mangled.begin() + read_pos; - ptrdiff_t read_len = tail.data() - (mangled.data() + read_pos); - - // First write the unmatched part of the original. Then write the - // replacement string. Finally skip the search string in the original. - writer = std::copy(reader, reader + read_len, writer); - writer = std::copy(replace.begin(), replace.end(), writer); - read_pos += read_len + search.size(); - } - } +public: + void reset() { Alloc.Reset(); } - ConstString Finalize() { - // If we did a substitution, write the remaining part of the original. - if (read_pos > 0) { - writer = std::copy(mangled.begin() + read_pos, mangled.end(), writer); - read_pos = mangled.size(); - } + template T *makeNode(Args &&... args) { + return new (Alloc.Allocate(sizeof(T), alignof(T))) + T(std::forward(args)...); + } - return ConstString(output); - } + void *allocateNodeArray(size_t sz) { + return Alloc.Allocate(sizeof(llvm::itanium_demangle::Node *) * sz, + alignof(llvm::itanium_demangle::Node *)); + } +}; + +/// Given a mangled function `Mangled`, replace all the primitive function type +/// arguments of `Search` with type `Replace`. +class TypeSubstitutor + : public llvm::itanium_demangle::AbstractManglingParser { + /// Input character until which we have constructed the respective output + /// already + const char *Written; + + llvm::StringRef Search; + llvm::StringRef Replace; + llvm::SmallString<128> Result; + + /// Whether we have performed any substitutions. + bool Substituted; + + void reset(llvm::StringRef Mangled, llvm::StringRef Search, + llvm::StringRef Replace) { + AbstractManglingParser::reset(Mangled.begin(), Mangled.end()); + Written = Mangled.begin(); + this->Search = Search; + this->Replace = Replace; + Result.clear(); + Substituted = false; + } + + void appendUnchangedInput() { + Result += llvm::StringRef(Written, First - Written); + Written = First; + } + +public: + TypeSubstitutor() : AbstractManglingParser(nullptr, nullptr) {} - static void Callback(void *context, const char *match) { - ((PrimitiveParmSubs *)context)->Substitute(llvm::StringRef(match)); + ConstString substitute(llvm::StringRef Mangled, llvm::StringRef From, + llvm::StringRef To) { + Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE); + + reset(Mangled, From, To); + if (parse() == nullptr) { + LLDB_LOG(log, "Failed to substitute mangling in {0}", Mangled); + return ConstString(); } - }; + if (!Substituted) + return ConstString(); - // The demangler will call back for each instance of a primitive type, - // allowing us to perform substitution - PrimitiveParmSubs parmSubs(mangled, search, replace); - assert(mangled.data()[mangled.size()] == '\0' && "Expect C-String"); - bool err = llvm::itaniumFindTypesInMangledName(mangled.data(), &parmSubs, - PrimitiveParmSubs::Callback); - ConstString result = parmSubs.Finalize(); - - if (Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)) { - if (err) - LLDB_LOG(log, "Failed to substitute mangling in {0}", mangled); - else if (result) - LLDB_LOG(log, "Substituted mangling {0} -> {1}", mangled, result); + // Append any trailing unmodified input. + appendUnchangedInput(); + LLDB_LOG(log, "Substituted mangling {0} -> {1}", Mangled, Result); + return ConstString(Result); } - return result; + llvm::itanium_demangle::Node *parseType() { + if (llvm::StringRef(First, numLeft()).startswith(Search)) { + // We found a match. Append unmodified input up to this point. + appendUnchangedInput(); + + // And then perform the replacement. + Result += Replace; + Written += Search.size(); + Substituted = true; + } + return AbstractManglingParser::parseType(); + } +}; } uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings( @@ -368,23 +382,24 @@ uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings( alternates.insert(ConstString(fixed_scratch)); } + TypeSubstitutor TS; // `char` is implementation defined as either `signed` or `unsigned`. As a // result a char parameter has 3 possible manglings: 'c'-char, 'a'-signed // char, 'h'-unsigned char. If we're looking for symbols with a signed char // parameter, try finding matches which have the general case 'c'. if (ConstString char_fixup = - SubsPrimitiveParmItanium(mangled_name.GetStringRef(), "a", "c")) + TS.substitute(mangled_name.GetStringRef(), "a", "c")) alternates.insert(char_fixup); // long long parameter mangling 'x', may actually just be a long 'l' argument if (ConstString long_fixup = - SubsPrimitiveParmItanium(mangled_name.GetStringRef(), "x", "l")) + TS.substitute(mangled_name.GetStringRef(), "x", "l")) alternates.insert(long_fixup); // unsigned long long parameter mangling 'y', may actually just be unsigned // long 'm' argument if (ConstString ulong_fixup = - SubsPrimitiveParmItanium(mangled_name.GetStringRef(), "y", "m")) + TS.substitute(mangled_name.GetStringRef(), "y", "m")) alternates.insert(ulong_fixup); return alternates.size() - start_size; diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h index 505ebb2fa9ea..70a00c06bff7 100644 --- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h +++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h @@ -1,24 +1,19 @@ //===-- CPlusPlusLanguage.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CPlusPlusLanguage_h_ #define liblldb_CPlusPlusLanguage_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "Plugins/Language/ClangCommon/ClangHighlighter.h" #include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp index b32fe9588965..a098f129a1d6 100644 --- a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp +++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp @@ -1,9 +1,8 @@ //===-- CPlusPlusNameParser.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h index fe1d46f32c17..414c3a009157 100644 --- a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h +++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h @@ -1,25 +1,20 @@ //===-- CPlusPlusNameParser.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CPlusPlusNameParser_h_ #define liblldb_CPlusPlusNameParser_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/Lex/Lexer.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp index 6a41ff84e0b6..959079070acc 100644 --- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp +++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp @@ -1,9 +1,8 @@ //===-- CxxStringTypes.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -101,7 +100,7 @@ bool lldb_private::formatters::WCharStringSummaryProvider( return false; // Safe to pass nullptr for exe_scope here. - auto size = wchar_compiler_type.GetBitSize(nullptr); + llvm::Optional size = wchar_compiler_type.GetBitSize(nullptr); if (!size) return false; const uint32_t wchar_size = *size; @@ -198,7 +197,7 @@ bool lldb_private::formatters::WCharSummaryProvider( return false; // Safe to pass nullptr for exe_scope here. - auto size = wchar_compiler_type.GetBitSize(nullptr); + llvm::Optional size = wchar_compiler_type.GetBitSize(nullptr); if (!size) return false; const uint32_t wchar_size = *size; diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h index 8e2ec44dc71c..92bef2382eac 100644 --- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h +++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h @@ -1,10 +1,9 @@ //===-- CxxStringTypes.h ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 6f0ce2471f15..15d34916b661 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1,19 +1,14 @@ //===-- LibCxx.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "LibCxx.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/ScopeExit.h" -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/ValueObject.h" @@ -259,7 +254,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() { ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)}, {"payload", pair_type}}); - auto size = tree_node_type.GetByteSize(nullptr); + llvm::Optional size = tree_node_type.GetByteSize(nullptr); if (!size) return false; DataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.h b/source/Plugins/Language/CPlusPlus/LibCxx.h index 224a540eda04..4b881597b74d 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -1,10 +1,9 @@ //===-- LibCxx.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp index dea52e2f30b6..d3d78e62dba5 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp @@ -1,10 +1,9 @@ //===-- LibCxxAtomic.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h index a9d948bf189c..b72506644552 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h +++ b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h @@ -1,10 +1,9 @@ //===-- LibCxxAtomic.h -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp index 0d39e5a57cf0..440f3597478d 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp @@ -1,9 +1,8 @@ //===-- LibCxxBitset.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -80,7 +79,8 @@ ValueObjectSP BitsetFrontEnd::GetChildAtIndex(size_t idx) { ValueObjectSP chunk; // For small bitsets __first_ is not an array, but a plain size_t. if (m_first->GetCompilerType().IsArrayType(&type, nullptr, nullptr)) { - auto bit_size = type.GetBitSize(ctx.GetBestExecutionContextScope()); + llvm::Optional bit_size = + type.GetBitSize(ctx.GetBestExecutionContextScope()); if (!bit_size || *bit_size == 0) return {}; chunk = m_first->GetChildAtIndex(idx / *bit_size, true); @@ -91,7 +91,8 @@ ValueObjectSP BitsetFrontEnd::GetChildAtIndex(size_t idx) { if (!type || !chunk) return {}; - auto bit_size = type.GetBitSize(ctx.GetBestExecutionContextScope()); + llvm::Optional bit_size = + type.GetBitSize(ctx.GetBestExecutionContextScope()); if (!bit_size || *bit_size == 0) return {}; size_t chunk_idx = idx % *bit_size; diff --git a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp index 17d565c9550a..27eca9e9cc2f 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp @@ -1,16 +1,11 @@ //===-- LibCxxInitializerList.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "LibCxx.h" #include "lldb/Core/ValueObject.h" @@ -98,7 +93,7 @@ bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd:: if (!m_element_type.IsValid()) return false; - if (auto size = m_element_type.GetByteSize(nullptr)) { + if (llvm::Optional size = m_element_type.GetByteSize(nullptr)) { m_element_size = *size; // Store raw pointers or end up with a circular dependency. m_start = m_backend.GetChildMemberWithName(g___begin_, true).get(); diff --git a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp index 6066f14b18cc..ba47e2207622 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -1,16 +1,11 @@ //===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "LibCxx.h" #include "lldb/Core/ValueObject.h" diff --git a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index 8f82bdcbfd59..ad23fc7014ab 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -1,16 +1,11 @@ //===-- LibCxxMap.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "LibCxx.h" #include "lldb/Core/ValueObject.h" diff --git a/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp index 762b824f262a..7ae251b04f34 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp @@ -1,9 +1,8 @@ //===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp index c4e0b66d4272..8401e2f34c33 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp @@ -1,9 +1,8 @@ //===-- LibCxxQueue.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp index 9b412a12f532..276b7037d105 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp @@ -1,9 +1,8 @@ //===-- LibCxxTuple.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index 0f1c2537d651..f4abe931d0ac 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -1,16 +1,11 @@ //===-- LibCxxUnorderedMap.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "LibCxx.h" #include "lldb/Core/ValueObject.h" diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp index 04d8b8044343..11f845e1da78 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp @@ -1,9 +1,8 @@ //===-- LibCxxVariant.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -111,7 +110,7 @@ ValueObjectSP LibcxxVariantGetNthHead(ValueObjectSP &impl_sp, uint64_t index) { } return current_level->GetChildMemberWithName(ConstString("__head"), true); -}; +} } // namespace namespace lldb_private { diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVariant.h b/source/Plugins/Language/CPlusPlus/LibCxxVariant.h index 04834581963f..65db5aeaa99d 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxVariant.h +++ b/source/Plugins/Language/CPlusPlus/LibCxxVariant.h @@ -1,10 +1,9 @@ //===-- LibCxxVariant.h -------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index 06c8d48c3e6b..c3bf9f827d35 100644 --- a/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -1,16 +1,11 @@ //===-- LibCxxVector.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "LibCxx.h" #include "lldb/Core/ValueObject.h" @@ -149,7 +144,7 @@ bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() { if (!data_type_finder_sp) return false; m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType(); - if (auto size = m_element_type.GetByteSize(nullptr)) { + if (llvm::Optional size = m_element_type.GetByteSize(nullptr)) { m_element_size = *size; if (m_element_size > 0) { @@ -217,7 +212,7 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex( return {}; mask = 1 << bit_index; bool bit_set = ((byte & mask) != 0); - auto size = m_bool_type.GetByteSize(nullptr); + llvm::Optional size = m_bool_type.GetByteSize(nullptr); if (!size) return {}; DataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 4ee648ac2500..7f00f3618929 100644 --- a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -1,18 +1,13 @@ //===-- LibStdcpp.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "LibStdcpp.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/StringPrinter.h" @@ -302,7 +297,7 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider( return false; // Safe to pass nullptr for exe_scope here. - auto size = wchar_compiler_type.GetBitSize(nullptr); + llvm::Optional size = wchar_compiler_type.GetBitSize(nullptr); if (!size) return false; const uint32_t wchar_size = *size; diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.h b/source/Plugins/Language/CPlusPlus/LibStdcpp.h index 1400477dcd0d..e7f88d667c14 100644 --- a/source/Plugins/Language/CPlusPlus/LibStdcpp.h +++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.h @@ -1,9 +1,8 @@ //===-- LibStdcpp.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp index 943af6ee81e4..111b28b965a0 100644 --- a/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp +++ b/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp @@ -1,9 +1,8 @@ //===-- LibStdcppTuple.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp index 9d46e3e3ee58..335523e10b26 100644 --- a/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp +++ b/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp @@ -1,9 +1,8 @@ //===-- LibStdcppUniquePointer.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp new file mode 100644 index 000000000000..248c51acea42 --- /dev/null +++ b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp @@ -0,0 +1,98 @@ +//===-- MSVCUndecoratedNameParser.cpp ---------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "MSVCUndecoratedNameParser.h" + +#include + +MSVCUndecoratedNameParser::MSVCUndecoratedNameParser(llvm::StringRef name) { + std::size_t last_base_start = 0; + + std::stack stack; + unsigned int open_angle_brackets = 0; + for (size_t i = 0; i < name.size(); i++) { + switch (name[i]) { + case '<': + // Do not treat `operator<' and `operator<<' as templates + // (sometimes they represented as `<' and `<<' in the name). + if (i == last_base_start || + (i == last_base_start + 1 && name[last_base_start] == '<')) + break; + + stack.push(i); + open_angle_brackets++; + + break; + case '>': + if (!stack.empty() && name[stack.top()] == '<') { + open_angle_brackets--; + stack.pop(); + } + + break; + case '`': + stack.push(i); + + break; + case '\'': + while (!stack.empty()) { + std::size_t top = stack.top(); + if (name[top] == '<') + open_angle_brackets--; + + stack.pop(); + + if (name[top] == '`') + break; + } + + break; + case ':': + if (open_angle_brackets) + break; + if (i == 0 || name[i - 1] != ':') + break; + + m_specifiers.emplace_back(name.take_front(i - 1), + name.slice(last_base_start, i - 1)); + + last_base_start = i + 1; + break; + default: + break; + } + } + + m_specifiers.emplace_back(name, name.drop_front(last_base_start)); +} + +bool MSVCUndecoratedNameParser::IsMSVCUndecoratedName(llvm::StringRef name) { + return name.find('`') != llvm::StringRef::npos; +} + +bool MSVCUndecoratedNameParser::ExtractContextAndIdentifier( + llvm::StringRef name, llvm::StringRef &context, + llvm::StringRef &identifier) { + MSVCUndecoratedNameParser parser(name); + llvm::ArrayRef specs = parser.GetSpecifiers(); + + std::size_t count = specs.size(); + identifier = count > 0 ? specs[count - 1].GetBaseName() : ""; + context = count > 1 ? specs[count - 2].GetFullName() : ""; + + return count; +} + +llvm::StringRef MSVCUndecoratedNameParser::DropScope(llvm::StringRef name) { + MSVCUndecoratedNameParser parser(name); + llvm::ArrayRef specs = parser.GetSpecifiers(); + if (specs.empty()) + return ""; + + return specs[specs.size() - 1].GetBaseName(); +} diff --git a/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h new file mode 100644 index 000000000000..6e20877cae1b --- /dev/null +++ b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h @@ -0,0 +1,50 @@ +//===-- MSVCUndecoratedNameParser.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_MSVCUndecoratedNameParser_h_ +#define liblldb_MSVCUndecoratedNameParser_h_ + +#include + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" + +class MSVCUndecoratedNameSpecifier { +public: + MSVCUndecoratedNameSpecifier(llvm::StringRef full_name, + llvm::StringRef base_name) + : m_full_name(full_name), m_base_name(base_name) {} + + llvm::StringRef GetFullName() const { return m_full_name; } + llvm::StringRef GetBaseName() const { return m_base_name; } + +private: + llvm::StringRef m_full_name; + llvm::StringRef m_base_name; +}; + +class MSVCUndecoratedNameParser { +public: + explicit MSVCUndecoratedNameParser(llvm::StringRef name); + + llvm::ArrayRef GetSpecifiers() const { + return m_specifiers; + } + + static bool IsMSVCUndecoratedName(llvm::StringRef name); + static bool ExtractContextAndIdentifier(llvm::StringRef name, + llvm::StringRef &context, + llvm::StringRef &identifier); + + static llvm::StringRef DropScope(llvm::StringRef name); + +private: + std::vector m_specifiers; +}; + +#endif diff --git a/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp b/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp index 50824d72d655..e70e45c79756 100644 --- a/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp +++ b/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp @@ -1,9 +1,8 @@ //===-- ClangHighlighter.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -155,7 +154,8 @@ void ClangHighlighter::Highlight(const HighlightStyle &options, // Let's just enable the latest ObjC and C++ which should get most tokens // right. LangOptions Opts; - Opts.ObjC2 = true; + Opts.ObjC = true; + // FIXME: This should probably set CPlusPlus, CPlusPlus11, ... too Opts.CPlusPlus17 = true; Opts.LineComment = true; diff --git a/source/Plugins/Language/ClangCommon/ClangHighlighter.h b/source/Plugins/Language/ClangCommon/ClangHighlighter.h index 6390c3249ca4..f459f9424697 100644 --- a/source/Plugins/Language/ClangCommon/ClangHighlighter.h +++ b/source/Plugins/Language/ClangCommon/ClangHighlighter.h @@ -1,22 +1,17 @@ //===-- ClangHighlighter.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ClangHighlighter_h_ #define liblldb_ClangHighlighter_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "lldb/Utility/Stream.h" #include "llvm/ADT/StringSet.h" -// Project includes #include "lldb/Core/Highlighter.h" namespace lldb_private { diff --git a/source/Plugins/Language/ObjC/CF.cpp b/source/Plugins/Language/ObjC/CF.cpp index 9bb8eeab1d2e..99a880f3fe69 100644 --- a/source/Plugins/Language/ObjC/CF.cpp +++ b/source/Plugins/Language/ObjC/CF.cpp @@ -1,10 +1,9 @@ //===-- CF.cpp ----------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -149,7 +148,7 @@ bool lldb_private::formatters::CFBitVectorSummaryProvider( } } - if (is_type_ok == false) + if (!is_type_ok) return false; Status error; diff --git a/source/Plugins/Language/ObjC/CF.h b/source/Plugins/Language/ObjC/CF.h index 6945f9e8c9b1..2abb56d407eb 100644 --- a/source/Plugins/Language/ObjC/CF.h +++ b/source/Plugins/Language/ObjC/CF.h @@ -1,9 +1,8 @@ //===-- CF.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/CMakeLists.txt b/source/Plugins/Language/ObjC/CMakeLists.txt index 93dcc9af82de..03e68e3640e7 100644 --- a/source/Plugins/Language/ObjC/CMakeLists.txt +++ b/source/Plugins/Language/ObjC/CMakeLists.txt @@ -31,6 +31,7 @@ add_lldb_library(lldbPluginObjCLanguage PLUGIN lldbTarget lldbUtility lldbPluginAppleObjCRuntime + lldbPluginClangCommon lldbPluginSwiftLanguage lldbPluginClangCommon diff --git a/source/Plugins/Language/ObjC/Cocoa.cpp b/source/Plugins/Language/ObjC/Cocoa.cpp index c66a8bcee610..c169efadf7b5 100644 --- a/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/source/Plugins/Language/ObjC/Cocoa.cpp @@ -1,16 +1,11 @@ //===-- Cocoa.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Cocoa.h" #include "lldb/Core/Mangled.h" @@ -748,6 +743,59 @@ bool lldb_private::formatters::NSURLSummaryProvider( return false; } +/// Bias value for tagged pointer exponents. +/// Recommended values: +/// 0x3e3: encodes all dates between distantPast and distantFuture +/// except for the range within about 1e-28 second of the reference date. +/// 0x3ef: encodes all dates for a few million years beyond distantPast and +/// distantFuture, except within about 1e-25 second of the reference date. +const int TAGGED_DATE_EXPONENT_BIAS = 0x3ef; + +typedef union { + struct { + uint64_t fraction:52; // unsigned + uint64_t exponent:11; // signed + uint64_t sign:1; + } repr; + uint64_t i; + double d; +} DoubleBits; +typedef union { + struct { + uint64_t fraction:52; // unsigned + uint64_t exponent:7; // signed + uint64_t sign:1; + uint64_t unused:4; // placeholder for pointer tag bits + } repr; + uint64_t i; +} TaggedDoubleBits; + +static uint64_t decodeExponent(uint64_t exp) { + // Tagged exponent field is 7-bit signed. Sign-extend the value to 64 bits + // before performing arithmetic. + return llvm::SignExtend64<7>(exp) + TAGGED_DATE_EXPONENT_BIAS; +} + +static uint64_t decodeTaggedTimeInterval(uint64_t encodedTimeInterval) { + if (encodedTimeInterval == 0) + return 0.0; + if (encodedTimeInterval == std::numeric_limits::max()) + return (uint64_t)-0.0; + + TaggedDoubleBits encodedBits = {}; + encodedBits.i = encodedTimeInterval; + DoubleBits decodedBits; + + // Sign and fraction are represented exactly. + // Exponent is encoded. + assert(encodedBits.repr.unused == 0); + decodedBits.repr.sign = encodedBits.repr.sign; + decodedBits.repr.fraction = encodedBits.repr.fraction; + decodedBits.repr.exponent = decodeExponent(encodedBits.repr.exponent); + + return decodedBits.d; +} + bool lldb_private::formatters::NSDateSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { ProcessSP process_sp = valobj.GetProcessSP(); @@ -787,9 +835,9 @@ bool lldb_private::formatters::NSDateSummaryProvider( if (class_name.IsEmpty()) return false; + uint64_t info_bits = 0, value_bits = 0; if ((class_name == g_NSDate) || (class_name == g___NSDate) || (class_name == g___NSTaggedDate)) { - uint64_t info_bits = 0, value_bits = 0; if (descriptor->GetTaggedPointerInfo(&info_bits, &value_bits)) { date_value_bits = ((value_bits << 8) | (info_bits << 4)); memcpy(&date_value, &date_value_bits, sizeof(date_value_bits)); @@ -819,6 +867,14 @@ bool lldb_private::formatters::NSDateSummaryProvider( stream.Printf("0001-12-30 00:00:00 +0000"); return true; } + + // Accomodate for the __NSTaggedDate format introduced in Foundation 1600. + if (class_name == g___NSTaggedDate) { + auto *runtime = llvm::dyn_cast_or_null(process_sp->GetObjCLanguageRuntime()); + if (runtime && runtime->GetFoundationVersion() >= 1600) + date_value = decodeTaggedTimeInterval(value_bits << 4); + } + // this snippet of code assumes that time_t == seconds since Jan-1-1970 this // is generally true and POSIXly happy, but might break if a library vendor // decides to get creative diff --git a/source/Plugins/Language/ObjC/Cocoa.h b/source/Plugins/Language/ObjC/Cocoa.h index 8d8ed6aff4b4..a23bb2523ebc 100644 --- a/source/Plugins/Language/ObjC/Cocoa.h +++ b/source/Plugins/Language/ObjC/Cocoa.h @@ -1,10 +1,9 @@ //===-- Cocoa.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/CoreMedia.cpp b/source/Plugins/Language/ObjC/CoreMedia.cpp index cbc38c907953..d19290ec56fb 100644 --- a/source/Plugins/Language/ObjC/CoreMedia.cpp +++ b/source/Plugins/Language/ObjC/CoreMedia.cpp @@ -1,10 +1,9 @@ //===-- CoreMedia.cpp --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/CoreMedia.h b/source/Plugins/Language/ObjC/CoreMedia.h index 98561efbf7ed..79abb67b9d7e 100644 --- a/source/Plugins/Language/ObjC/CoreMedia.h +++ b/source/Plugins/Language/ObjC/CoreMedia.h @@ -1,10 +1,9 @@ //===-- CoreMedia.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/NSArray.cpp b/source/Plugins/Language/ObjC/NSArray.cpp index 2bff4bc62ccc..d6e3ff67d67b 100644 --- a/source/Plugins/Language/ObjC/NSArray.cpp +++ b/source/Plugins/Language/ObjC/NSArray.cpp @@ -1,18 +1,13 @@ //===-- NSArray.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/AST/ASTContext.h" -// Project includes #include "Cocoa.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h" @@ -176,13 +171,8 @@ namespace Foundation1437 { PtrType _data; uint32_t _offset; uint32_t _size; - union { - PtrType _mutations; - struct { - uint32_t _muts; - uint32_t _used; - }; - }; + uint32_t _muts; + uint32_t _used; }; using NSArrayMSyntheticFrontEnd = @@ -218,6 +208,25 @@ namespace Foundation1437 { } +namespace CallStackArray { +struct DataDescriptor_32 { + uint32_t _data; + uint32_t _used; + uint32_t _offset; + const uint32_t _size = 0; +}; + +struct DataDescriptor_64 { + uint64_t _data; + uint64_t _used; + uint64_t _offset; + const uint64_t _size = 0; +}; + +using NSCallStackArraySyntheticFrontEnd = + GenericNSArrayMSyntheticFrontEnd; +} // namespace CallStackArray + template class GenericNSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: @@ -368,6 +377,7 @@ bool lldb_private::formatters::NSArraySummaryProvider( static const ConstString g_NSArrayCF("__NSCFArray"); static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy"); static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable"); + static const ConstString g_NSCallStackArray("_NSCallStackArray"); if (class_name.IsEmpty()) return false; @@ -417,7 +427,9 @@ bool lldb_private::formatters::NSArraySummaryProvider( value = 0; } else if (class_name == g_NSArray1) { value = 1; - } else if (class_name == g_NSArrayCF) { + } else if (class_name == g_NSArrayCF || class_name == g_NSCallStackArray) { + // __NSCFArray and _NSCallStackArray store the number of elements as a + // pointer-sized value at offset `2 * ptr_size`. Status error; value = process_sp->ReadUnsignedIntegerFromMemory( valobj_addr + 2 * ptr_size, ptr_size, 0, error); @@ -817,6 +829,7 @@ lldb_private::formatters::NSArraySyntheticFrontEndCreator( static const ConstString g_NSArray1("__NSSingleObjectArrayI"); static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy"); static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable"); + static const ConstString g_NSCallStackArray("_NSCallStackArray"); if (class_name.IsEmpty()) return nullptr; @@ -846,6 +859,8 @@ lldb_private::formatters::NSArraySyntheticFrontEndCreator( return (new Foundation1010::NSArrayMSyntheticFrontEnd(valobj_sp)); else return (new Foundation109::NSArrayMSyntheticFrontEnd(valobj_sp)); + } else if (class_name == g_NSCallStackArray) { + return (new CallStackArray::NSCallStackArraySyntheticFrontEnd(valobj_sp)); } else { auto &map(NSArray_Additionals::GetAdditionalSynthetics()); auto iter = map.find(class_name), end = map.end(); diff --git a/source/Plugins/Language/ObjC/NSDictionary.cpp b/source/Plugins/Language/ObjC/NSDictionary.cpp index 70f1393389e8..8fbde708a632 100644 --- a/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -1,20 +1,15 @@ //===-- NSDictionary.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "clang/AST/DeclCXX.h" -// Project includes #include "NSDictionary.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h" @@ -286,18 +281,11 @@ namespace Foundation1437 { struct DataDescriptor_32 { uint32_t _buffer; - union { - struct { - uint32_t _mutations; - }; - struct { - uint32_t _muts; - uint32_t _used:25; - uint32_t _kvo:1; - uint32_t _szidx:6; - }; - }; - + uint32_t _muts; + uint32_t _used : 25; + uint32_t _kvo : 1; + uint32_t _szidx : 6; + uint64_t GetSize() { return (_szidx) >= NSDictionaryNumSizeBuckets ? 0 : NSDictionaryCapacities[_szidx]; @@ -306,18 +294,11 @@ namespace Foundation1437 { struct DataDescriptor_64 { uint64_t _buffer; - union { - struct { - uint64_t _mutations; - }; - struct { - uint32_t _muts; - uint32_t _used:25; - uint32_t _kvo:1; - uint32_t _szidx:6; - }; - }; - + uint32_t _muts; + uint32_t _used : 25; + uint32_t _kvo : 1; + uint32_t _szidx : 6; + uint64_t GetSize() { return (_szidx) >= NSDictionaryNumSizeBuckets ? 0 : NSDictionaryCapacities[_szidx]; diff --git a/source/Plugins/Language/ObjC/NSDictionary.h b/source/Plugins/Language/ObjC/NSDictionary.h index 6ec9a8eebe13..e69582d6bca8 100644 --- a/source/Plugins/Language/ObjC/NSDictionary.h +++ b/source/Plugins/Language/ObjC/NSDictionary.h @@ -1,10 +1,9 @@ //===-- NSDictionary.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/NSError.cpp b/source/Plugins/Language/ObjC/NSError.cpp index 77721e2db326..f7a20b6cd3bd 100644 --- a/source/Plugins/Language/ObjC/NSError.cpp +++ b/source/Plugins/Language/ObjC/NSError.cpp @@ -1,18 +1,13 @@ //===-- NSError.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/AST/DeclCXX.h" -// Project includes #include "Cocoa.h" #include "lldb/Core/ValueObject.h" diff --git a/source/Plugins/Language/ObjC/NSException.cpp b/source/Plugins/Language/ObjC/NSException.cpp index c6970efae4d3..e24028dd79a2 100644 --- a/source/Plugins/Language/ObjC/NSException.cpp +++ b/source/Plugins/Language/ObjC/NSException.cpp @@ -1,18 +1,13 @@ //===-- NSException.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/AST/DeclCXX.h" -// Project includes #include "Cocoa.h" #include "lldb/Core/ValueObject.h" @@ -33,52 +28,78 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; -bool lldb_private::formatters::NSException_SummaryProvider( - ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { +static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp, + ValueObjectSP *reason_sp, ValueObjectSP *userinfo_sp, + ValueObjectSP *reserved_sp) { ProcessSP process_sp(valobj.GetProcessSP()); if (!process_sp) return false; - lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS; + lldb::addr_t ptr = LLDB_INVALID_ADDRESS; CompilerType valobj_type(valobj.GetCompilerType()); Flags type_flags(valobj_type.GetTypeInfo()); if (type_flags.AllClear(eTypeHasValue)) { if (valobj.IsBaseClass() && valobj.GetParent()) - ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); - } else - ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + ptr = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + } else { + ptr = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + } - if (ptr_value == LLDB_INVALID_ADDRESS) + if (ptr == LLDB_INVALID_ADDRESS) return false; size_t ptr_size = process_sp->GetAddressByteSize(); - lldb::addr_t name_location = ptr_value + 1 * ptr_size; - lldb::addr_t reason_location = ptr_value + 2 * ptr_size; Status error; - lldb::addr_t name = process_sp->ReadPointerFromMemory(name_location, error); + auto name = process_sp->ReadPointerFromMemory(ptr + 1 * ptr_size, error); if (error.Fail() || name == LLDB_INVALID_ADDRESS) return false; - - lldb::addr_t reason = - process_sp->ReadPointerFromMemory(reason_location, error); + auto reason = process_sp->ReadPointerFromMemory(ptr + 2 * ptr_size, error); if (error.Fail() || reason == LLDB_INVALID_ADDRESS) return false; + auto userinfo = process_sp->ReadPointerFromMemory(ptr + 3 * ptr_size, error); + if (error.Fail() || userinfo == LLDB_INVALID_ADDRESS) + return false; + auto reserved = process_sp->ReadPointerFromMemory(ptr + 4 * ptr_size, error); + if (error.Fail() || reserved == LLDB_INVALID_ADDRESS) + return false; InferiorSizedWord name_isw(name, *process_sp); InferiorSizedWord reason_isw(reason, *process_sp); + InferiorSizedWord userinfo_isw(userinfo, *process_sp); + InferiorSizedWord reserved_isw(reserved, *process_sp); CompilerType voidstar = process_sp->GetTarget() .GetScratchClangASTContext() ->GetBasicType(lldb::eBasicTypeVoid) .GetPointerType(); - ValueObjectSP name_sp = ValueObject::CreateValueObjectFromData( - "name_str", name_isw.GetAsData(process_sp->GetByteOrder()), - valobj.GetExecutionContextRef(), voidstar); - ValueObjectSP reason_sp = ValueObject::CreateValueObjectFromData( - "reason_str", reason_isw.GetAsData(process_sp->GetByteOrder()), - valobj.GetExecutionContextRef(), voidstar); + if (name_sp) + *name_sp = ValueObject::CreateValueObjectFromData( + "name", name_isw.GetAsData(process_sp->GetByteOrder()), + valobj.GetExecutionContextRef(), voidstar); + if (reason_sp) + *reason_sp = ValueObject::CreateValueObjectFromData( + "reason", reason_isw.GetAsData(process_sp->GetByteOrder()), + valobj.GetExecutionContextRef(), voidstar); + if (userinfo_sp) + *userinfo_sp = ValueObject::CreateValueObjectFromData( + "userInfo", userinfo_isw.GetAsData(process_sp->GetByteOrder()), + valobj.GetExecutionContextRef(), voidstar); + if (reserved_sp) + *reserved_sp = ValueObject::CreateValueObjectFromData( + "reserved", reserved_isw.GetAsData(process_sp->GetByteOrder()), + valobj.GetExecutionContextRef(), voidstar); + + return true; +} + +bool lldb_private::formatters::NSException_SummaryProvider( + ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + lldb::ValueObjectSP name_sp; + lldb::ValueObjectSP reason_sp; + if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr, nullptr)) + return false; if (!name_sp || !reason_sp) return false; @@ -101,83 +122,55 @@ class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd { : SyntheticChildrenFrontEnd(*valobj_sp) {} ~NSExceptionSyntheticFrontEnd() override = default; - // no need to delete m_child_ptr - it's kept alive by the cluster manager on - // our behalf size_t CalculateNumChildren() override { - if (m_child_ptr) - return 1; - if (m_child_sp) - return 1; - return 0; + return 4; } lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { - if (idx != 0) - return lldb::ValueObjectSP(); - - if (m_child_ptr) - return m_child_ptr->GetSP(); - return m_child_sp; + switch (idx) { + case 0: return m_name_sp; + case 1: return m_reason_sp; + case 2: return m_userinfo_sp; + case 3: return m_reserved_sp; + } + return lldb::ValueObjectSP(); } bool Update() override { - m_child_ptr = nullptr; - m_child_sp.reset(); - - ProcessSP process_sp(m_backend.GetProcessSP()); - if (!process_sp) - return false; - - lldb::addr_t userinfo_location = LLDB_INVALID_ADDRESS; - - CompilerType valobj_type(m_backend.GetCompilerType()); - Flags type_flags(valobj_type.GetTypeInfo()); - if (type_flags.AllClear(eTypeHasValue)) { - if (m_backend.IsBaseClass() && m_backend.GetParent()) - userinfo_location = - m_backend.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); - } else - userinfo_location = m_backend.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); - - if (userinfo_location == LLDB_INVALID_ADDRESS) - return false; - - size_t ptr_size = process_sp->GetAddressByteSize(); - - userinfo_location += 3 * ptr_size; - Status error; - lldb::addr_t userinfo = - process_sp->ReadPointerFromMemory(userinfo_location, error); - if (userinfo == LLDB_INVALID_ADDRESS || error.Fail()) - return false; - InferiorSizedWord isw(userinfo, *process_sp); - m_child_sp = CreateValueObjectFromData( - "userInfo", isw.GetAsData(process_sp->GetByteOrder()), - m_backend.GetExecutionContextRef(), - process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType( - lldb::eBasicTypeObjCID)); - return false; + m_name_sp.reset(); + m_reason_sp.reset(); + m_userinfo_sp.reset(); + m_reserved_sp.reset(); + + return ExtractFields(m_backend, &m_name_sp, &m_reason_sp, &m_userinfo_sp, + &m_reserved_sp); } bool MightHaveChildren() override { return true; } size_t GetIndexOfChildWithName(const ConstString &name) override { + // NSException has 4 members: + // NSString *name; + // NSString *reason; + // NSDictionary *userInfo; + // id reserved; + static ConstString g___name("name"); + static ConstString g___reason("reason"); static ConstString g___userInfo("userInfo"); - if (name == g___userInfo) - return 0; + static ConstString g___reserved("reserved"); + if (name == g___name) return 0; + if (name == g___reason) return 1; + if (name == g___userInfo) return 2; + if (name == g___reserved) return 3; return UINT32_MAX; } private: - // the child here can be "real" (i.e. an actual child of the root) or - // synthetized from raw memory if the former, I need to store a plain pointer - // to it - or else a loop of references will cause this entire hierarchy of - // values to leak if the latter, then I need to store a SharedPointer to it - - // so that it only goes away when everyone else in the cluster goes away oh - // joy! - ValueObject *m_child_ptr; - ValueObjectSP m_child_sp; + ValueObjectSP m_name_sp; + ValueObjectSP m_reason_sp; + ValueObjectSP m_userinfo_sp; + ValueObjectSP m_reserved_sp; }; SyntheticChildrenFrontEnd * diff --git a/source/Plugins/Language/ObjC/NSIndexPath.cpp b/source/Plugins/Language/ObjC/NSIndexPath.cpp index 9533e96004a5..660344c4f877 100644 --- a/source/Plugins/Language/ObjC/NSIndexPath.cpp +++ b/source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -1,16 +1,11 @@ //===-- NSIndexPath.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Cocoa.h" #include "lldb/Core/ValueObject.h" @@ -130,11 +125,7 @@ class NSIndexPathSyntheticFrontEnd : public SyntheticChildrenFrontEnd { return false; } - bool MightHaveChildren() override { - if (m_impl.m_mode == Mode::Invalid) - return false; - return true; - } + bool MightHaveChildren() override { return m_impl.m_mode != Mode::Invalid; } size_t GetIndexOfChildWithName(const ConstString &name) override { const char *item_name = name.GetCString(); diff --git a/source/Plugins/Language/ObjC/NSSet.cpp b/source/Plugins/Language/ObjC/NSSet.cpp index 341459d0cc94..b4e6963bb032 100644 --- a/source/Plugins/Language/ObjC/NSSet.cpp +++ b/source/Plugins/Language/ObjC/NSSet.cpp @@ -1,16 +1,11 @@ //===-- NSSet.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "NSSet.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h" @@ -159,28 +154,18 @@ namespace Foundation1437 { uint32_t _cow; // __table storage uint32_t _objs_addr; - union { - uint32_t _mutations; - struct { - uint32_t _muts; - uint32_t _used : 26; - uint32_t _szidx : 6; - }; - }; + uint32_t _muts; + uint32_t _used : 26; + uint32_t _szidx : 6; }; struct DataDescriptor_64 { uint64_t _cow; // __Table storage uint64_t _objs_addr; - union { - uint64_t _mutations; - struct { - uint32_t _muts; - uint32_t _used : 26; - uint32_t _szidx : 6; - }; - }; + uint32_t _muts; + uint32_t _used : 26; + uint32_t _szidx : 6; }; using NSSetMSyntheticFrontEnd = diff --git a/source/Plugins/Language/ObjC/NSSet.h b/source/Plugins/Language/ObjC/NSSet.h index 00451be6c7f3..f11b6d406dec 100644 --- a/source/Plugins/Language/ObjC/NSSet.h +++ b/source/Plugins/Language/ObjC/NSSet.h @@ -1,10 +1,9 @@ //===-- NSSet.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/NSString.cpp b/source/Plugins/Language/ObjC/NSString.cpp index 0b12edb53d7a..8d0906ed7fa7 100644 --- a/source/Plugins/Language/ObjC/NSString.cpp +++ b/source/Plugins/Language/ObjC/NSString.cpp @@ -1,10 +1,9 @@ //===-- NSString.cpp ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -225,10 +224,10 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetStream(&stream); options.SetQuote('"'); options.SetSourceSize(explicit_length); - options.SetNeedsZeroTermination(has_explicit_length == false); + options.SetNeedsZeroTermination(!has_explicit_length); options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped); - options.SetBinaryZeroIsTerminator(has_explicit_length == false); + options.SetBinaryZeroIsTerminator(!has_explicit_length); options.SetLanguage(summary_options.GetLanguage()); return StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF16>(options); @@ -245,10 +244,10 @@ bool lldb_private::formatters::NSStringSummaryProvider( options.SetStream(&stream); options.SetQuote('"'); options.SetSourceSize(explicit_length); - options.SetNeedsZeroTermination(has_explicit_length == false); + options.SetNeedsZeroTermination(!has_explicit_length); options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped); - options.SetBinaryZeroIsTerminator(has_explicit_length == false); + options.SetBinaryZeroIsTerminator(!has_explicit_length); options.SetLanguage(summary_options.GetLanguage()); return StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF16>(options); @@ -260,10 +259,7 @@ bool lldb_private::formatters::NSStringSummaryProvider( Status error; explicit_length = process_sp->ReadUnsignedIntegerFromMemory(location, 1, 0, error); - if (error.Fail() || explicit_length == 0) - has_explicit_length = false; - else - has_explicit_length = true; + has_explicit_length = !(error.Fail() || explicit_length == 0); location++; } options.SetLocation(location); diff --git a/source/Plugins/Language/ObjC/NSString.h b/source/Plugins/Language/ObjC/NSString.h index 3a923c2be6ac..33052d47d56e 100644 --- a/source/Plugins/Language/ObjC/NSString.h +++ b/source/Plugins/Language/ObjC/NSString.h @@ -1,10 +1,9 @@ //===-- NSString.h ---------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 3a42d43ca596..6898fefa80b0 100644 --- a/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -1,18 +1,13 @@ //===-- ObjCLanguage.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "ObjCLanguage.h" #include "lldb/Core/PluginManager.h" @@ -411,6 +406,9 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { AddCXXSummary( objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags); + AddCXXSummary( + objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, + "NSArray summary provider", ConstString("_NSCallStackArray"), appkit_flags); AddCXXSummary( objc_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags); @@ -530,6 +528,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) { lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), ScriptedSyntheticChildren::Flags()); + AddCXXSynthetic(objc_category_sp, + lldb_private::formatters::NSArraySyntheticFrontEndCreator, + "NSArray synthetic children", ConstString("_NSCallStackArray"), + ScriptedSyntheticChildren::Flags()); AddCXXSynthetic(objc_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.h b/source/Plugins/Language/ObjC/ObjCLanguage.h index 10c30b338cba..efb53dcbbd09 100644 --- a/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -1,22 +1,17 @@ //===-- ObjCLanguage.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjCLanguage_h_ #define liblldb_ObjCLanguage_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "Plugins/Language/ClangCommon/ClangHighlighter.h" #include "lldb/Target/Language.h" #include "lldb/Utility/ConstString.h" diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp index 5e6d86e05318..69e82510d199 100644 --- a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp +++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp @@ -1,10 +1,9 @@ //===-- ObjCPlusPlusLanguage.cpp --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h index b1825c9d53da..6f801d02d333 100644 --- a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h +++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h @@ -1,19 +1,14 @@ //===-- ObjCPlusPlusLanguage.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjCPlusPlusLanguage_h_ #define liblldb_ObjCPlusPlusLanguage_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Language/ClangCommon/ClangHighlighter.h" #include "lldb/Target/Language.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Language/Swift/CMakeLists.txt b/source/Plugins/Language/Swift/CMakeLists.txt index 90b87b710b5e..bdd23223f6ea 100644 --- a/source/Plugins/Language/Swift/CMakeLists.txt +++ b/source/Plugins/Language/Swift/CMakeLists.txt @@ -28,4 +28,8 @@ add_lldb_library(lldbPluginSwiftLanguage PLUGIN LINK_COMPONENTS Support ) +if(CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT SWIFT_COMPILER_MSVC_LIKE) + target_compile_options(lldbPluginSwiftLanguage PRIVATE + -Wno-dollar-in-identifier-extension) +endif() diff --git a/source/Plugins/Language/Swift/SwiftHashedContainer.cpp b/source/Plugins/Language/Swift/SwiftHashedContainer.cpp index 3dff47f3499c..7a180e09fb08 100644 --- a/source/Plugins/Language/Swift/SwiftHashedContainer.cpp +++ b/source/Plugins/Language/Swift/SwiftHashedContainer.cpp @@ -541,7 +541,7 @@ bool NativeHashedStorageHandler::IsValid() { uint64_t NativeHashedStorageHandler::GetMetadataWord(int index, Status &error) { - if (index >= GetWordCount()) { + if (static_cast(index) >= GetWordCount()) { error.SetErrorToGenericError(); return 0; } diff --git a/source/Plugins/Language/Swift/SwiftOptionSet.cpp b/source/Plugins/Language/Swift/SwiftOptionSet.cpp index a209f7f34260..e365e675989a 100644 --- a/source/Plugins/Language/Swift/SwiftOptionSet.cpp +++ b/source/Plugins/Language/Swift/SwiftOptionSet.cpp @@ -68,6 +68,7 @@ static clang::EnumDecl *GetAsEnumDecl(const CompilerType &compiler_type) { if (const clang::EnumType *enum_type = qual_type->getAs()) return enum_type->getDecl(); + break; } default: break; diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 71864ea10078..f51a40bb6d89 100644 --- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -1,10 +1,9 @@ //===-- ItaniumABILanguageRuntime.cpp --------------------------------------*- //C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,11 @@ #include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/DataFormatters/FormattersHelpers.h" +#include "lldb/Expression/DiagnosticManager.h" +#include "lldb/Expression/FunctionCaller.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -32,6 +33,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include @@ -99,7 +101,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( llvm::DenseSet searched_symbol_files; if (sc.module_sp) { num_matches = sc.module_sp->FindTypes( - sc, ConstString(lookup_name), exact_match, 1, + ConstString(lookup_name), exact_match, 1, searched_symbol_files, class_types); } @@ -107,7 +109,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( // list in the target and get as many unique matches as possible if (num_matches == 0) { num_matches = target.GetImages().FindTypes( - sc, ConstString(lookup_name), exact_match, UINT32_MAX, + nullptr, ConstString(lookup_name), exact_match, UINT32_MAX, searched_symbol_files, class_types); } @@ -205,71 +207,71 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress( // Only a pointer or reference type can have a different dynamic and static // type: - if (CouldHaveDynamicValue(in_value)) { - // First job, pull out the address at 0 offset from the object. - AddressType address_type; - lldb::addr_t original_ptr = in_value.GetPointerValue(&address_type); - if (original_ptr == LLDB_INVALID_ADDRESS) - return false; + if (!CouldHaveDynamicValue(in_value)) + return false; - ExecutionContext exe_ctx(in_value.GetExecutionContextRef()); + // First job, pull out the address at 0 offset from the object. + AddressType address_type; + lldb::addr_t original_ptr = in_value.GetPointerValue(&address_type); + if (original_ptr == LLDB_INVALID_ADDRESS) + return false; - Process *process = exe_ctx.GetProcessPtr(); + ExecutionContext exe_ctx(in_value.GetExecutionContextRef()); - if (process == nullptr) - return false; + Process *process = exe_ctx.GetProcessPtr(); - Status error; - const lldb::addr_t vtable_address_point = - process->ReadPointerFromMemory(original_ptr, error); + if (process == nullptr) + return false; - if (!error.Success() || vtable_address_point == LLDB_INVALID_ADDRESS) { - return false; - } + Status error; + const lldb::addr_t vtable_address_point = + process->ReadPointerFromMemory(original_ptr, error); - class_type_or_name = GetTypeInfoFromVTableAddress(in_value, original_ptr, - vtable_address_point); - - if (class_type_or_name) { - TypeSP type_sp = class_type_or_name.GetTypeSP(); - // There can only be one type with a given name, so we've just found - // duplicate definitions, and this one will do as well as any other. We - // don't consider something to have a dynamic type if it is the same as - // the static type. So compare against the value we were handed. - if (type_sp) { - if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(), - type_sp->GetForwardCompilerType())) { - // The dynamic type we found was the same type, so we don't have a - // dynamic type here... - return false; - } + if (!error.Success() || vtable_address_point == LLDB_INVALID_ADDRESS) + return false; - // The offset_to_top is two pointers above the vtable pointer. - const uint32_t addr_byte_size = process->GetAddressByteSize(); - const lldb::addr_t offset_to_top_location = - vtable_address_point - 2 * addr_byte_size; - // Watch for underflow, offset_to_top_location should be less than - // vtable_address_point - if (offset_to_top_location >= vtable_address_point) - return false; - const int64_t offset_to_top = process->ReadSignedIntegerFromMemory( - offset_to_top_location, addr_byte_size, INT64_MIN, error); - - if (offset_to_top == INT64_MIN) - return false; - // So the dynamic type is a value that starts at offset_to_top above - // the original address. - lldb::addr_t dynamic_addr = original_ptr + offset_to_top; - if (!process->GetTarget().GetSectionLoadList().ResolveLoadAddress( - dynamic_addr, dynamic_address)) { - dynamic_address.SetRawAddress(dynamic_addr); - } - return true; - } - } + class_type_or_name = GetTypeInfoFromVTableAddress(in_value, original_ptr, + vtable_address_point); + + if (!class_type_or_name) + return false; + + TypeSP type_sp = class_type_or_name.GetTypeSP(); + // There can only be one type with a given name, so we've just found + // duplicate definitions, and this one will do as well as any other. We + // don't consider something to have a dynamic type if it is the same as + // the static type. So compare against the value we were handed. + if (!type_sp) + return true; + + if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(), + type_sp->GetForwardCompilerType())) { + // The dynamic type we found was the same type, so we don't have a + // dynamic type here... + return false; } - return class_type_or_name.IsEmpty() == false; + // The offset_to_top is two pointers above the vtable pointer. + const uint32_t addr_byte_size = process->GetAddressByteSize(); + const lldb::addr_t offset_to_top_location = + vtable_address_point - 2 * addr_byte_size; + // Watch for underflow, offset_to_top_location should be less than + // vtable_address_point + if (offset_to_top_location >= vtable_address_point) + return false; + const int64_t offset_to_top = process->ReadSignedIntegerFromMemory( + offset_to_top_location, addr_byte_size, INT64_MIN, error); + + if (offset_to_top == INT64_MIN) + return false; + // So the dynamic type is a value that starts at offset_to_top above + // the original address. + lldb::addr_t dynamic_addr = original_ptr + offset_to_top; + if (!process->GetTarget().GetSectionLoadList().ResolveLoadAddress( + dynamic_addr, dynamic_address)) { + dynamic_address.SetRawAddress(dynamic_addr); + } + return true; } TypeAndOrName ItaniumABILanguageRuntime::FixUpDynamicType( @@ -310,10 +312,7 @@ bool ItaniumABILanguageRuntime::IsVTableName(const char *name) { return false; // Can we maybe ask Clang about this? - if (strstr(name, "_vptr$") == name) - return true; - else - return false; + return strstr(name, "_vptr$") == name; } //------------------------------------------------------------------ @@ -484,8 +483,8 @@ lldb::SearchFilterSP ItaniumABILanguageRuntime::CreateExceptionSearchFilter() { // Limit the number of modules that are searched for these breakpoints for // Apple binaries. FileSpecList filter_modules; - filter_modules.Append(FileSpec("libc++abi.dylib", false)); - filter_modules.Append(FileSpec("libSystem.B.dylib", false)); + filter_modules.Append(FileSpec("libc++abi.dylib")); + filter_modules.Append(FileSpec("libSystem.B.dylib")); return target.GetSearchFilterForModuleList(&filter_modules); } else { return LanguageRuntime::CreateExceptionSearchFilter(); @@ -553,6 +552,64 @@ bool ItaniumABILanguageRuntime::ExceptionBreakpointsExplainStop( break_site_id, m_cxx_exception_bp_sp->GetID()); } +ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread( + ThreadSP thread_sp) { + if (!thread_sp->SafeToCallFunctions()) + return {}; + + ClangASTContext *clang_ast_context = + m_process->GetTarget().GetScratchClangASTContext(); + CompilerType voidstar = + clang_ast_context->GetBasicType(eBasicTypeVoid).GetPointerType(); + + DiagnosticManager diagnostics; + ExecutionContext exe_ctx; + EvaluateExpressionOptions options; + + options.SetUnwindOnError(true); + options.SetIgnoreBreakpoints(true); + options.SetStopOthers(true); + options.SetTimeout(std::chrono::milliseconds(500)); + options.SetTryAllThreads(false); + thread_sp->CalculateExecutionContext(exe_ctx); + + const ModuleList &modules = m_process->GetTarget().GetImages(); + SymbolContextList contexts; + SymbolContext context; + + modules.FindSymbolsWithNameAndType( + ConstString("__cxa_current_exception_type"), eSymbolTypeCode, contexts); + contexts.GetContextAtIndex(0, context); + Address addr = context.symbol->GetAddress(); + + Status error; + FunctionCaller *function_caller = + m_process->GetTarget().GetFunctionCallerForLanguage( + eLanguageTypeC, voidstar, addr, ValueList(), "caller", error); + + ExpressionResults func_call_ret; + Value results; + func_call_ret = function_caller->ExecuteFunction(exe_ctx, nullptr, options, + diagnostics, results); + if (func_call_ret != eExpressionCompleted || !error.Success()) { + return ValueObjectSP(); + } + + size_t ptr_size = m_process->GetAddressByteSize(); + addr_t result_ptr = results.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + addr_t exception_addr = + m_process->ReadPointerFromMemory(result_ptr - ptr_size, error); + + lldb_private::formatters::InferiorSizedWord exception_isw(exception_addr, + *m_process); + ValueObjectSP exception = ValueObject::CreateValueObjectFromData( + "exception", exception_isw.GetAsData(m_process->GetByteOrder()), exe_ctx, + voidstar); + exception = exception->GetDynamicValue(eDynamicDontRunTarget); + + return exception; +} + TypeAndOrName ItaniumABILanguageRuntime::GetDynamicTypeInfo( const lldb_private::Address &vtable_addr) { std::lock_guard locker(m_dynamic_type_map_mutex); diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h index 480c32691c8b..1507da952d71 100644 --- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h +++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h @@ -1,23 +1,18 @@ //===-- ItaniumABILanguageRuntime.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ItaniumABILanguageRuntime_h_ #define liblldb_ItaniumABILanguageRuntime_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/Type.h" @@ -69,6 +64,9 @@ class ItaniumABILanguageRuntime : public lldb_private::CPPLanguageRuntime { bool throw_bp) override; lldb::SearchFilterSP CreateExceptionSearchFilter() override; + + lldb::ValueObjectSP GetExceptionObjectForThread( + lldb::ThreadSP thread_sp) override; //------------------------------------------------------------------ // PluginInterface protocol diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp index 6450c9b2965e..0e26de569e88 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -1,10 +1,9 @@ //===-- AppleObjCClassDescriptorV2.cpp -----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -264,11 +263,7 @@ bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr) { } process->ReadCStringFromMemory(m_types_ptr, m_types, error); - if (error.Fail()) { - return false; - } - - return true; + return !error.Fail(); } bool ClassDescriptorV2::ivar_list_t::Read(Process *process, lldb::addr_t addr) { @@ -323,11 +318,7 @@ bool ClassDescriptorV2::ivar_t::Read(Process *process, lldb::addr_t addr) { } process->ReadCStringFromMemory(m_type_ptr, m_type, error); - if (error.Fail()) { - return false; - } - - return true; + return !error.Fail(); } bool ClassDescriptorV2::Describe( @@ -521,11 +512,11 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime, CompilerType ivar_type = encoding_to_type_sp->RealizeType(type, for_expression); if (ivar_type) { - auto ivar_size = ivar_type.GetByteSize(nullptr); LLDB_LOGV(log, "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = " "{3}, type_size = {4}", - name, type, offset_ptr, size, ivar_size ? *ivar_size : 0); + name, type, offset_ptr, size, + ivar_type.GetByteSize(nullptr).getValueOr(0)); Scalar offset_scalar; Status error; const int offset_ptr_size = 4; diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h index 787423b54766..7738531c71a1 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h @@ -1,21 +1,16 @@ //===-- AppleObjCClassDescriptorV2.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AppleObjCClassDescriptorV2_h_ #define liblldb_AppleObjCClassDescriptorV2_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "AppleObjCRuntimeV2.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index 105c088b9e91..fba03e84ed2d 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -1,9 +1,8 @@ //===-- AppleObjCDeclVendor.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -558,7 +557,7 @@ AppleObjCDeclVendor::FindDecls(const ConstString &name, bool append, LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? if (log) - log->Printf("AppleObjCDeclVendor::FindTypes [%u] ('%s', %s, %u, )", + log->Printf("AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )", current_id, (const char *)name.AsCString(), append ? "true" : "false", max_matches); diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h index 2f087da16bc1..d243ab298b6e 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h @@ -1,19 +1,14 @@ //===-- AppleObjCDeclVendor.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AppleObjCDeclVendor_h_ #define liblldb_AppleObjCDeclVendor_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/DeclVendor.h" #include "lldb/Target/ObjCLanguageRuntime.h" diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 5478c0bc7e81..037a6c5b4549 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -1,10 +1,9 @@ //===-- AppleObjCRuntime.cpp -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,13 +16,15 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectConstResult.h" +#include "lldb/DataFormatters/FormattersHelpers.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/FunctionCaller.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/CPPLanguageRuntime.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -32,9 +33,13 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" +#include "Plugins/Process/Utility/HistoryThread.h" +#include "Plugins/Language/ObjC/NSString.h" + #include using namespace lldb; @@ -459,13 +464,10 @@ bool AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing() { SymbolContextList sc_list; - if (target.GetImages().FindSymbolsWithNameAndType(s_method_signature, - eSymbolTypeCode, sc_list) || - target.GetImages().FindSymbolsWithNameAndType(s_arclite_method_signature, - eSymbolTypeCode, sc_list)) - return true; - else - return false; + return target.GetImages().FindSymbolsWithNameAndType( + s_method_signature, eSymbolTypeCode, sc_list) || + target.GetImages().FindSymbolsWithNameAndType( + s_arclite_method_signature, eSymbolTypeCode, sc_list); } lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() { @@ -473,13 +475,115 @@ lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() { if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) { FileSpecList filter_modules; - filter_modules.Append(FileSpec("libobjc.A.dylib", false)); + filter_modules.Append(std::get<0>(GetExceptionThrowLocation())); return target.GetSearchFilterForModuleList(&filter_modules); } else { return LanguageRuntime::CreateExceptionSearchFilter(); } } +ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread( + ThreadSP thread_sp) { + auto cpp_runtime = m_process->GetCPPLanguageRuntime(); + if (!cpp_runtime) return ValueObjectSP(); + auto cpp_exception = cpp_runtime->GetExceptionObjectForThread(thread_sp); + if (!cpp_exception) return ValueObjectSP(); + + auto descriptor = GetClassDescriptor(*cpp_exception.get()); + if (!descriptor || !descriptor->IsValid()) return ValueObjectSP(); + + while (descriptor) { + ConstString class_name(descriptor->GetClassName()); + if (class_name == ConstString("NSException")) return cpp_exception; + descriptor = descriptor->GetSuperclass(); + } + + return ValueObjectSP(); +} + +ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException( + lldb::ValueObjectSP exception_sp) { + ValueObjectSP reserved_dict = + exception_sp->GetChildMemberWithName(ConstString("reserved"), true); + if (!reserved_dict) return ThreadSP(); + + reserved_dict = reserved_dict->GetSyntheticValue(); + if (!reserved_dict) return ThreadSP(); + + CompilerType objc_id = + exception_sp->GetTargetSP()->GetScratchClangASTContext()->GetBasicType( + lldb::eBasicTypeObjCID); + ValueObjectSP return_addresses; + + auto objc_object_from_address = [&exception_sp, &objc_id](uint64_t addr, + const char *name) { + Value value(addr); + value.SetCompilerType(objc_id); + auto object = ValueObjectConstResult::Create( + exception_sp->GetTargetSP().get(), value, ConstString(name)); + object = object->GetDynamicValue(eDynamicDontRunTarget); + return object; + }; + + for (size_t idx = 0; idx < reserved_dict->GetNumChildren(); idx++) { + ValueObjectSP dict_entry = reserved_dict->GetChildAtIndex(idx, true); + + DataExtractor data; + data.SetAddressByteSize(dict_entry->GetProcessSP()->GetAddressByteSize()); + Status error; + dict_entry->GetData(data, error); + if (error.Fail()) return ThreadSP(); + + lldb::offset_t data_offset = 0; + auto dict_entry_key = data.GetPointer(&data_offset); + auto dict_entry_value = data.GetPointer(&data_offset); + + auto key_nsstring = objc_object_from_address(dict_entry_key, "key"); + StreamString key_summary; + if (lldb_private::formatters::NSStringSummaryProvider( + *key_nsstring, key_summary, TypeSummaryOptions()) && + !key_summary.Empty()) { + if (key_summary.GetString() == "\"callStackReturnAddresses\"") { + return_addresses = objc_object_from_address(dict_entry_value, + "callStackReturnAddresses"); + break; + } + } + } + + if (!return_addresses) return ThreadSP(); + auto frames_value = + return_addresses->GetChildMemberWithName(ConstString("_frames"), true); + addr_t frames_addr = frames_value->GetValueAsUnsigned(0); + auto count_value = + return_addresses->GetChildMemberWithName(ConstString("_cnt"), true); + size_t count = count_value->GetValueAsUnsigned(0); + auto ignore_value = + return_addresses->GetChildMemberWithName(ConstString("_ignore"), true); + size_t ignore = ignore_value->GetValueAsUnsigned(0); + + size_t ptr_size = m_process->GetAddressByteSize(); + std::vector pcs; + for (size_t idx = 0; idx < count; idx++) { + Status error; + addr_t pc = m_process->ReadPointerFromMemory( + frames_addr + (ignore + idx) * ptr_size, error); + pcs.push_back(pc); + } + + if (pcs.empty()) return ThreadSP(); + + ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs, 0, false)); + m_process->GetExtendedThreadList().AddThread(new_thread_sp); + return new_thread_sp; +} + +std::tuple +AppleObjCRuntime::GetExceptionThrowLocation() { + return std::make_tuple( + FileSpec("libobjc.A.dylib"), ConstString("objc_exception_throw")); +} + void AppleObjCRuntime::ReadObjCLibraryIfNeeded(const ModuleList &module_list) { if (!HasReadObjCLibrary()) { std::lock_guard guard(module_list.GetMutex()); diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h index 8df69395615e..c4dff5415f17 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h @@ -1,21 +1,16 @@ //===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AppleObjCRuntime_h_ #define liblldb_AppleObjCRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/Optional.h" -// Project includes #include "AppleObjCTrampolineHandler.h" #include "AppleThreadPlanStepThroughObjCTrampoline.h" #include "lldb/Target/LanguageRuntime.h" @@ -99,6 +94,14 @@ class AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime { bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override; lldb::SearchFilterSP CreateExceptionSearchFilter() override; + + static std::tuple GetExceptionThrowLocation(); + + lldb::ValueObjectSP GetExceptionObjectForThread( + lldb::ThreadSP thread_sp) override; + + lldb::ThreadSP GetBacktraceThreadFromException( + lldb::ValueObjectSP thread_sp) override; uint32_t GetFoundationVersion(); diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 5001c0461b3b..fde99473701a 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -1,10 +1,9 @@ //===-- AppleObjCRuntimeV1.cpp --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,7 +16,6 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Expression/FunctionCaller.h" #include "lldb/Expression/UtilityFunction.h" #include "lldb/Symbol/ClangASTContext.h" @@ -29,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -58,7 +57,7 @@ bool AppleObjCRuntimeV1::GetDynamicTypeAndAddress( class_type_or_name.SetName(class_descriptor->GetClassName()); } } - return class_type_or_name.IsEmpty() == false; + return !class_type_or_name.IsEmpty(); } //------------------------------------------------------------------ @@ -113,8 +112,9 @@ AppleObjCRuntimeV1::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, if (throw_bp) resolver_sp.reset(new BreakpointResolverName( - bkpt, "objc_exception_throw", eFunctionNameTypeBase, - eLanguageTypeUnknown, Breakpoint::Exact, 0, eLazyBoolNo)); + bkpt, std::get<1>(GetExceptionThrowLocation()).AsCString(), + eFunctionNameTypeBase, eLanguageTypeUnknown, Breakpoint::Exact, 0, + eLazyBoolNo)); // FIXME: don't do catch yet. return resolver_sp; } diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h index 52eec0f692fb..79cca67cfc96 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h @@ -1,19 +1,14 @@ //===-- AppleObjCRuntimeV1.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AppleObjCRuntimeV1_h_ #define liblldb_AppleObjCRuntimeV1_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "AppleObjCRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index f9be8c6d47a3..8a9edc6c21d6 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1,24 +1,19 @@ //===-- AppleObjCRuntimeV2.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes #include #include -// Other libraries and framework includes #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Host/OptionParser.h" #include "lldb/Symbol/CompilerType.h" @@ -28,8 +23,8 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/FunctionCaller.h" @@ -44,14 +39,17 @@ #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Target/ABI.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/StackFrameRecognizer.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -377,6 +375,8 @@ ExtractRuntimeGlobalSymbol(Process *process, ConstString name, } } +static void RegisterObjCExceptionRecognizer(); + AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, const ModuleSP &objc_module_sp) : AppleObjCRuntime(process), m_get_class_info_code(), @@ -397,6 +397,7 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, static const ConstString g_gdb_object_getClass("gdb_object_getClass"); m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType( g_gdb_object_getClass, eSymbolTypeCode) != NULL); + RegisterObjCExceptionRecognizer(); } bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress( @@ -452,7 +453,7 @@ bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress( } } } - return class_type_or_name.IsEmpty() == false; + return !class_type_or_name.IsEmpty(); } bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress( @@ -812,8 +813,9 @@ AppleObjCRuntimeV2::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, if (throw_bp) resolver_sp.reset(new BreakpointResolverName( - bkpt, "objc_exception_throw", eFunctionNameTypeBase, - eLanguageTypeUnknown, Breakpoint::Exact, 0, eLazyBoolNo)); + bkpt, std::get<1>(GetExceptionThrowLocation()).AsCString(), + eFunctionNameTypeBase, eLanguageTypeUnknown, Breakpoint::Exact, 0, + eLazyBoolNo)); // FIXME: We don't do catch breakpoints for ObjC yet. // Should there be some way for the runtime to specify what it can do in this // regard? @@ -1858,8 +1860,8 @@ void AppleObjCRuntimeV2::UpdateISAToDescriptorMapIfNeeded() { // warn if: // - we could not run either expression // - we found fewer than num_classes_to_warn_at classes total - if ((false == shared_cache_update_result.m_update_ran) || - (false == dynamic_update_result.m_update_ran)) + if ((!shared_cache_update_result.m_update_ran) || + (!dynamic_update_result.m_update_ran)) WarnIfNoClassesCached( SharedCacheWarningReason::eExpressionExecutionFailure); else if (dynamic_update_result.m_num_found + @@ -2434,7 +2436,7 @@ AppleObjCRuntimeV2::NonPointerISACache::NonPointerISACache( ObjCLanguageRuntime::ClassDescriptorSP AppleObjCRuntimeV2::NonPointerISACache::GetClassDescriptor(ObjCISA isa) { ObjCISA real_isa = 0; - if (EvaluateNonPointerISA(isa, real_isa) == false) + if (!EvaluateNonPointerISA(isa, real_isa)) return ObjCLanguageRuntime::ClassDescriptorSP(); auto cache_iter = m_cache.find(real_isa); if (cache_iter != m_cache.end()) @@ -2458,7 +2460,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( // If all of the indexed ISA variables are set, then its possible that this // ISA is indexed, and we should first try to get its value using the index. - // Note, we check these varaibles first as the ObjC runtime will set at least + // Note, we check these variables first as the ObjC runtime will set at least // one of their values to 0 if they aren't needed. if (m_objc_debug_indexed_isa_magic_mask && m_objc_debug_indexed_isa_magic_value && @@ -2545,7 +2547,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( return false; } - // Definately not an indexed ISA, so try to use a mask to extract the pointer + // Definitely not an indexed ISA, so try to use a mask to extract the pointer // from the ISA. if ((isa & m_objc_debug_isa_magic_mask) == m_objc_debug_isa_magic_value) { ret_isa = isa & m_objc_debug_isa_class_mask; @@ -2605,3 +2607,62 @@ void AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, } else this->AppleObjCRuntime::GetValuesForGlobalCFBooleans(cf_true, cf_false); } + +#pragma mark Frame recognizers + +class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame { + public: + ObjCExceptionRecognizedStackFrame(StackFrameSP frame_sp) { + ThreadSP thread_sp = frame_sp->GetThread(); + ProcessSP process_sp = thread_sp->GetProcess(); + + const lldb::ABISP &abi = process_sp->GetABI(); + if (!abi) return; + + CompilerType voidstar = process_sp->GetTarget() + .GetScratchClangASTContext() + ->GetBasicType(lldb::eBasicTypeVoid) + .GetPointerType(); + + ValueList args; + Value input_value; + input_value.SetCompilerType(voidstar); + args.PushValue(input_value); + + if (!abi->GetArgumentValues(*thread_sp, args)) return; + + addr_t exception_addr = args.GetValueAtIndex(0)->GetScalar().ULongLong(); + + Value value(exception_addr); + value.SetCompilerType(voidstar); + exception = ValueObjectConstResult::Create(frame_sp.get(), value, + ConstString("exception")); + exception = exception->GetDynamicValue(eDynamicDontRunTarget); + + m_arguments = ValueObjectListSP(new ValueObjectList()); + m_arguments->Append(exception); + } + + ValueObjectSP exception; + + lldb::ValueObjectSP GetExceptionObject() override { return exception; } +}; + +class ObjCExceptionThrowFrameRecognizer : public StackFrameRecognizer { + lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame) { + return lldb::RecognizedStackFrameSP( + new ObjCExceptionRecognizedStackFrame(frame)); + }; +}; + +static void RegisterObjCExceptionRecognizer() { + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { + FileSpec module; + ConstString function; + std::tie(module, function) = AppleObjCRuntime::GetExceptionThrowLocation(); + StackFrameRecognizerManager::AddRecognizer( + StackFrameRecognizerSP(new ObjCExceptionThrowFrameRecognizer()), + module.GetFilename(), function, /*first_instruction_only*/ true); + }); +} diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 724d0e7328ea..0a0eaa5416e5 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -1,23 +1,18 @@ //===-- AppleObjCRuntimeV2.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AppleObjCRuntimeV2_h_ #define liblldb_AppleObjCRuntimeV2_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "AppleObjCRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index c75fa71ba131..aeb8294b7a80 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -1,19 +1,14 @@ //===-- AppleObjCTrampolineHandler.cpp ----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "AppleObjCTrampolineHandler.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "AppleThreadPlanStepThroughObjCTrampoline.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -80,7 +75,7 @@ extern \"C\" void * __lldb_objc_find_implementation_for_selector ( \n\ void *super_ptr; \n\ }; \n\ struct __lldb_objc_super { \n\ - void *reciever; \n\ + void *receiver; \n\ struct __lldb_objc_class *class_ptr; \n\ }; \n\ struct __lldb_msg_ref { \n\ @@ -202,7 +197,7 @@ extern \"C\" void * __lldb_objc_find_implementation_for_selector (void *object, void *super_ptr; \n\ }; \n\ struct __lldb_objc_super { \n\ - void *reciever; \n\ + void *receiver; \n\ struct __lldb_objc_class *class_ptr; \n\ }; \n\ struct __lldb_msg_ref { \n\ diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h index dc58a8bc1eb6..ed93fc194df1 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h @@ -1,23 +1,18 @@ //===-- AppleObjCTrampolineHandler.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_AppleObjCTrampolineHandler_h_ #define lldb_AppleObjCTrampolineHandler_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Expression/UtilityFunction.h" #include "lldb/lldb-public.h" diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index 9bb1a4e0ee42..fd02e71d8672 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -1,9 +1,8 @@ //===-- AppleObjCTypeEncodingParser.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h index 4da84dd92c3f..ade96dc4170d 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h @@ -1,21 +1,16 @@ //===-- AppleObjCTypeEncodingParser.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_AppleObjCTypeEncodingParser_h_ #define liblldb_AppleObjCTypeEncodingParser_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/AST/ASTContext.h" -// Project includes #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp index fcaf48633503..85fd6620c90d 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -1,17 +1,12 @@ //===-- AppleThreadPlanStepThroughObjCTrampoline.cpp //--------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "AppleThreadPlanStepThroughObjCTrampoline.h" #include "AppleObjCTrampolineHandler.h" #include "lldb/Expression/DiagnosticManager.h" @@ -204,10 +199,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) { // The base class MischiefManaged does some cleanup - so you have to call it in // your MischiefManaged derived class. bool AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged() { - if (IsPlanComplete()) - return true; - else - return false; + return IsPlanComplete(); } bool AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; } diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h index 60c8b92d9cc7..96f37851a35f 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h @@ -1,19 +1,14 @@ //===-- AppleThreadPlanStepThroughObjCTrampoline.h --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_AppleThreadPlanStepThroughObjCTrampoline_h_ #define lldb_AppleThreadPlanStepThroughObjCTrampoline_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "AppleObjCTrampolineHandler.h" #include "lldb/Core/Value.h" #include "lldb/Target/ThreadPlan.h" diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp index cbbc35f1c08a..60549663db66 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp @@ -1,17 +1,13 @@ //===-- RenderScriptExpressionOpts.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/None.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Instruction.h" @@ -24,7 +20,6 @@ #include "clang/Basic/TargetOptions.h" -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Log.h" diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h index f45ff83c5a2b..00425b781ee0 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h @@ -1,24 +1,19 @@ //===-- RenderScriptExpressionOpts.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_RENDERSCRIPT_EXPROPTS_H #define LLDB_RENDERSCRIPT_EXPROPTS_H -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/IR/Module.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -// Project includes #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index d2129803886f..bae1da0edd62 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -1,18 +1,13 @@ //===-- RenderScriptRuntime.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/StringSwitch.h" -// Project includes #include "RenderScriptRuntime.h" #include "RenderScriptScriptGroup.h" @@ -20,7 +15,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/DumpValueObjectOptions.h" #include "lldb/Expression/UserExpression.h" @@ -41,8 +35,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Status.h" @@ -2079,10 +2073,8 @@ bool RenderScriptRuntime::JITElementPacked(Element &elem, // If this Element has subelements then JIT rsaElementGetSubElements() for // details about its fields - if (*elem.field_count.get() > 0 && !JITSubelements(elem, context, frame_ptr)) - return false; - - return true; + return !(*elem.field_count.get() > 0 && + !JITSubelements(elem, context, frame_ptr)); } // JITs the RS runtime for information about the subelements/fields of a struct @@ -2305,10 +2297,7 @@ bool RenderScriptRuntime::RefreshAllocation(AllocationDetails *alloc, SetElementSize(alloc->element); // Use GetOffsetPointer() to infer size of the allocation - if (!JITAllocationSize(alloc, frame_ptr)) - return false; - - return true; + return JITAllocationSize(alloc, frame_ptr); } // Function attempts to set the type_name member of the paramaterised Element @@ -2529,21 +2518,22 @@ bool RenderScriptRuntime::LoadAllocation(Stream &strm, const uint32_t alloc_id, "Allocation information not available"); // Check we can read from file - FileSpec file(path, true); - if (!file.Exists()) { + FileSpec file(path); + FileSystem::Instance().Resolve(file); + if (!FileSystem::Instance().Exists(file)) { strm.Printf("Error: File %s does not exist", path); strm.EOL(); return false; } - if (!file.Readable()) { + if (!FileSystem::Instance().Readable(file)) { strm.Printf("Error: File %s does not have readable permissions", path); strm.EOL(); return false; } // Read file into data buffer - auto data_sp = DataBufferLLVM::CreateFromPath(file.GetPath()); + auto data_sp = FileSystem::Instance().CreateDataBuffer(file.GetPath()); // Cast start of buffer to FileHeader and use pointer to read metadata void *file_buf = data_sp->GetBytes(); @@ -2753,9 +2743,14 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id, "Allocation information not available"); // Check we can create writable file - FileSpec file_spec(path, true); - File file(file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate | - File::eOpenOptionTruncate); + FileSpec file_spec(path); + FileSystem::Instance().Resolve(file_spec); + File file; + FileSystem::Instance().Open(file, file_spec, + File::eOpenOptionWrite | + File::eOpenOptionCanCreate | + File::eOpenOptionTruncate); + if (!file) { strm.Printf("Error: Failed to open '%s' for writing", path); strm.EOL(); @@ -3079,7 +3074,8 @@ bool RSModuleDescriptor::ParseRSInfo() { const addr_t size = info_sym->GetByteSize(); const FileSpec fs = m_module->GetFileSpec(); - auto buffer = DataBufferLLVM::CreateSliceFromPath(fs.GetPath(), size, addr); + auto buffer = + FileSystem::Instance().CreateDataBuffer(fs.GetPath(), size, addr); if (!buffer) return false; @@ -3718,7 +3714,8 @@ bool RenderScriptRuntime::GetKernelCoordinate(RSCoordinate &coord, continue; // Find the function name - const SymbolContext sym_ctx = frame_sp->GetSymbolContext(false); + const SymbolContext sym_ctx = + frame_sp->GetSymbolContext(eSymbolContextFunction); const ConstString func_name = sym_ctx.GetFunctionName(); if (!func_name) continue; @@ -4650,8 +4647,9 @@ class CommandObjectRenderScriptRuntimeAllocationDump switch (short_option) { case 'f': - m_outfile.SetFile(option_arg, true, FileSpec::Style::native); - if (m_outfile.Exists()) { + m_outfile.SetFile(option_arg, FileSpec::Style::native); + FileSystem::Instance().Resolve(m_outfile); + if (FileSystem::Instance().Exists(m_outfile)) { m_outfile.Clear(); err.SetErrorStringWithFormat("file already exists: '%s'", option_arg.str().c_str()); @@ -4706,16 +4704,17 @@ class CommandObjectRenderScriptRuntimeAllocationDump m_options.m_outfile; // Dump allocation to file instead if (outfile_spec) { // Open output file - char path[256]; - outfile_spec.GetPath(path, sizeof(path)); - if (outfile_stream.GetFile() - .Open(path, File::eOpenOptionWrite | File::eOpenOptionCanCreate) - .Success()) { + std::string path = outfile_spec.GetPath(); + auto error = FileSystem::Instance().Open( + outfile_stream.GetFile(), outfile_spec, + File::eOpenOptionWrite | File::eOpenOptionCanCreate); + if (error.Success()) { output_strm = &outfile_stream; - result.GetOutputStream().Printf("Results written to '%s'", path); + result.GetOutputStream().Printf("Results written to '%s'", + path.c_str()); result.GetOutputStream().EOL(); } else { - result.AppendErrorWithFormat("Couldn't open file '%s'", path); + result.AppendErrorWithFormat("Couldn't open file '%s'", path.c_str()); result.SetStatus(eReturnStatusFailed); return false; } diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h index e99025439a16..71d726097f89 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h @@ -1,27 +1,22 @@ //===-- RenderScriptRuntime.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RenderScriptRuntime_h_ #define liblldb_RenderScriptRuntime_h_ -// C Includes -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -// Project includes #include "lldb/Core/Module.h" #include "lldb/Expression/LLVMUserExpression.h" #include "lldb/Target/CPPLanguageRuntime.h" diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp index 7786d686ad6a..45d0d028d047 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp @@ -1,9 +1,8 @@ //===-- RenderScriptScriptGroup.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h index 5c5608c99862..c25e240f6d52 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h @@ -1,9 +1,8 @@ //===-- RenderScriptScriptGroup.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp index e1f8ea648414..8fb09601bc0b 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp @@ -1,17 +1,13 @@ //===-- RenderScriptx86ABIFixups.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CallSite.h" @@ -23,7 +19,6 @@ #include "llvm/IRReader/IRReader.h" #include "llvm/Pass.h" -// Project includes #include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h index b2caea49bd1e..a5efc999aea4 100644 --- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h +++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h @@ -1,9 +1,8 @@ //===-- RenderScriptx86ABIFixups.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp index b9e49d1faa1b..1d118c3e829a 100644 --- a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -1,9 +1,8 @@ //===-- MemoryHistoryASan.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h index 31e9873fb1ee..266576b0cd96 100644 --- a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h +++ b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h @@ -1,19 +1,14 @@ //===-- MemoryHistoryASan.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_MemoryHistoryASan_h_ #define liblldb_MemoryHistoryASan_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/Process.h" diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index 275f1fa2f70b..3e32d15984bd 100644 --- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -1,9 +1,8 @@ //===-- ObjectContainerBSDArchive.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -33,7 +32,6 @@ typedef struct ar_hdr { #include "lldb/Host/FileSystem.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" @@ -208,7 +206,7 @@ ObjectContainerBSDArchive::Archive::FindCachedArchive( while (pos != archive_map.end() && pos->first == file) { bool match = true; if (arch.IsValid() && - pos->second->GetArchitecture().IsCompatibleMatch(arch) == false) + !pos->second->GetArchitecture().IsCompatibleMatch(arch)) match = false; else if (file_offset != LLDB_INVALID_OFFSET && pos->second->GetFileOffset() != file_offset) @@ -313,7 +311,7 @@ ObjectContainer *ObjectContainerBSDArchive::CreateInstance( // file gets updated by a new build while this .a file is being used for // debugging DataBufferSP archive_data_sp = - DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset); + FileSystem::Instance().CreateDataBuffer(*file, length, file_offset); if (!archive_data_sp) return nullptr; @@ -461,14 +459,14 @@ size_t ObjectContainerBSDArchive::GetModuleSpecifications( return 0; const size_t initial_count = specs.GetSize(); - llvm::sys::TimePoint<> file_mod_time = FileSystem::GetModificationTime(file); + llvm::sys::TimePoint<> file_mod_time = FileSystem::Instance().GetModificationTime(file); Archive::shared_ptr archive_sp( Archive::FindCachedArchive(file, ArchSpec(), file_mod_time, file_offset)); bool set_archive_arch = false; if (!archive_sp) { set_archive_arch = true; data_sp = - DataBufferLLVM::CreateSliceFromPath(file.GetPath(), file_size, file_offset); + FileSystem::Instance().CreateDataBuffer(file, file_size, file_offset); if (data_sp) { data.SetData(data_sp, 0, data_sp->GetByteSize()); archive_sp = Archive::ParseAndCacheArchiveForFile( diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h index cb63eccff65e..868f505699f5 100644 --- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h +++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h @@ -1,9 +1,8 @@ //===-- ObjectContainerBSDArchive.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,11 +15,8 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" -// Other libraries and framework includes #include "llvm/Support/Chrono.h" -// C Includes -// C++ Includes #include #include #include diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp index 4c48d641829a..808e4691c20b 100644 --- a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp +++ b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp @@ -1,9 +1,8 @@ //===-- ObjectContainerUniversalMachO.cpp -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h index d3c0a080a6f9..e2377fde35db 100644 --- a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h +++ b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h @@ -1,22 +1,17 @@ //===-- ObjectContainerUniversalMachO.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjectContainerUniversalMachO_h_ #define liblldb_ObjectContainerUniversalMachO_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes +#include "lldb/Host/SafeMachO.h" #include "lldb/Symbol/ObjectContainer.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/SafeMachO.h" class ObjectContainerUniversalMachO : public lldb_private::ObjectContainer { public: diff --git a/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp new file mode 100644 index 000000000000..511b984261bd --- /dev/null +++ b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp @@ -0,0 +1,361 @@ +//===-- BreakpadRecords.cpp ----------------------------------- -*- 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 +// +//===----------------------------------------------------------------------===// + +#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/FormatVariadic.h" + +using namespace lldb_private; +using namespace lldb_private::breakpad; + +namespace { +enum class Token { Unknown, Module, Info, CodeID, File, Func, Public, Stack }; +} + +static Token toToken(llvm::StringRef str) { + return llvm::StringSwitch(str) + .Case("MODULE", Token::Module) + .Case("INFO", Token::Info) + .Case("CODE_ID", Token::CodeID) + .Case("FILE", Token::File) + .Case("FUNC", Token::Func) + .Case("PUBLIC", Token::Public) + .Case("STACK", Token::Stack) + .Default(Token::Unknown); +} + +static llvm::Triple::OSType toOS(llvm::StringRef str) { + using llvm::Triple; + return llvm::StringSwitch(str) + .Case("Linux", Triple::Linux) + .Case("mac", Triple::MacOSX) + .Case("windows", Triple::Win32) + .Default(Triple::UnknownOS); +} + +static llvm::Triple::ArchType toArch(llvm::StringRef str) { + using llvm::Triple; + return llvm::StringSwitch(str) + .Case("arm", Triple::arm) + .Case("arm64", Triple::aarch64) + .Case("mips", Triple::mips) + .Case("ppc", Triple::ppc) + .Case("ppc64", Triple::ppc64) + .Case("s390", Triple::systemz) + .Case("sparc", Triple::sparc) + .Case("sparcv9", Triple::sparcv9) + .Case("x86", Triple::x86) + .Case("x86_64", Triple::x86_64) + .Default(Triple::UnknownArch); +} + +/// Return the number of hex digits needed to encode an (POD) object of a given +/// type. +template static constexpr size_t hex_digits() { + return 2 * sizeof(T); +} + +/// Consume the right number of digits from the input StringRef and convert it +/// to the endian-specific integer N. Return true on success. +template static bool consume_hex_integer(llvm::StringRef &str, T &N) { + llvm::StringRef chunk = str.take_front(hex_digits()); + uintmax_t t; + if (!to_integer(chunk, t, 16)) + return false; + N = t; + str = str.drop_front(hex_digits()); + return true; +} + +static UUID parseModuleId(llvm::Triple::OSType os, llvm::StringRef str) { + struct data_t { + struct uuid_t { + llvm::support::ulittle32_t part1; + llvm::support::ulittle16_t part2[2]; + uint8_t part3[8]; + } uuid; + llvm::support::ulittle32_t age; + } data; + static_assert(sizeof(data) == 20, ""); + // The textual module id encoding should be between 33 and 40 bytes long, + // depending on the size of the age field, which is of variable length. + // The first three chunks of the id are encoded in big endian, so we need to + // byte-swap those. + if (str.size() <= hex_digits() || + str.size() > hex_digits()) + return UUID(); + if (!consume_hex_integer(str, data.uuid.part1)) + return UUID(); + for (auto &t : data.uuid.part2) { + if (!consume_hex_integer(str, t)) + return UUID(); + } + for (auto &t : data.uuid.part3) { + if (!consume_hex_integer(str, t)) + return UUID(); + } + uint32_t age; + if (!to_integer(str, age, 16)) + return UUID(); + data.age = age; + + // On non-windows, the age field should always be zero, so we don't include to + // match the native uuid format of these platforms. + return UUID::fromData(&data, os == llvm::Triple::Win32 ? sizeof(data) + : sizeof(data.uuid)); +} + +Record::Kind Record::classify(llvm::StringRef Line) { + Token Tok = toToken(getToken(Line).first); + switch (Tok) { + case Token::Module: + return Record::Module; + case Token::Info: + return Record::Info; + case Token::File: + return Record::File; + case Token::Func: + return Record::Func; + case Token::Public: + return Record::Public; + case Token::Stack: + return Record::Stack; + + case Token::CodeID: + case Token::Unknown: + // Optimistically assume that any unrecognised token means this is a line + // record, those don't have a special keyword and start directly with a + // hex number. CODE_ID should never be at the start of a line, but if it + // is, it can be treated the same way as a garbled line record. + return Record::Line; + } + llvm_unreachable("Fully covered switch above!"); +} + +llvm::Optional ModuleRecord::parse(llvm::StringRef Line) { + // MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 a.out + llvm::StringRef Str; + std::tie(Str, Line) = getToken(Line); + if (toToken(Str) != Token::Module) + return llvm::None; + + std::tie(Str, Line) = getToken(Line); + llvm::Triple::OSType OS = toOS(Str); + if (OS == llvm::Triple::UnknownOS) + return llvm::None; + + std::tie(Str, Line) = getToken(Line); + llvm::Triple::ArchType Arch = toArch(Str); + if (Arch == llvm::Triple::UnknownArch) + return llvm::None; + + std::tie(Str, Line) = getToken(Line); + UUID ID = parseModuleId(OS, Str); + if (!ID) + return llvm::None; + + return ModuleRecord(OS, Arch, std::move(ID)); +} + +llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, + const ModuleRecord &R) { + return OS << "MODULE " << llvm::Triple::getOSTypeName(R.OS) << " " + << llvm::Triple::getArchTypeName(R.Arch) << " " + << R.ID.GetAsString(); +} + +llvm::Optional InfoRecord::parse(llvm::StringRef Line) { + // INFO CODE_ID 554889E55DC3CCCCCCCCCCCCCCCCCCCC [a.exe] + llvm::StringRef Str; + std::tie(Str, Line) = getToken(Line); + if (toToken(Str) != Token::Info) + return llvm::None; + + std::tie(Str, Line) = getToken(Line); + if (toToken(Str) != Token::CodeID) + return llvm::None; + + std::tie(Str, Line) = getToken(Line); + // If we don't have any text following the code ID (e.g. on linux), we should + // use this as the UUID. Otherwise, we should revert back to the module ID. + UUID ID; + if (Line.trim().empty()) { + if (Str.empty() || ID.SetFromStringRef(Str, Str.size() / 2) != Str.size()) + return llvm::None; + } + return InfoRecord(std::move(ID)); +} + +llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, + const InfoRecord &R) { + return OS << "INFO CODE_ID " << R.ID.GetAsString(); +} + +llvm::Optional FileRecord::parse(llvm::StringRef Line) { + // FILE number name + llvm::StringRef Str; + std::tie(Str, Line) = getToken(Line); + if (toToken(Str) != Token::File) + return llvm::None; + + size_t Number; + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, Number)) + return llvm::None; + + llvm::StringRef Name = Line.trim(); + if (Name.empty()) + return llvm::None; + + return FileRecord(Number, Name); +} + +llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, + const FileRecord &R) { + return OS << "FILE " << R.Number << " " << R.Name; +} + +static bool parsePublicOrFunc(llvm::StringRef Line, bool &Multiple, + lldb::addr_t &Address, lldb::addr_t *Size, + lldb::addr_t &ParamSize, llvm::StringRef &Name) { + // PUBLIC [m] address param_size name + // or + // FUNC [m] address size param_size name + + Token Tok = Size ? Token::Func : Token::Public; + + llvm::StringRef Str; + std::tie(Str, Line) = getToken(Line); + if (toToken(Str) != Tok) + return false; + + std::tie(Str, Line) = getToken(Line); + Multiple = Str == "m"; + + if (Multiple) + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, Address, 16)) + return false; + + if (Tok == Token::Func) { + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, *Size, 16)) + return false; + } + + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, ParamSize, 16)) + return false; + + Name = Line.trim(); + if (Name.empty()) + return false; + + return true; +} + +llvm::Optional FuncRecord::parse(llvm::StringRef Line) { + bool Multiple; + lldb::addr_t Address, Size, ParamSize; + llvm::StringRef Name; + + if (parsePublicOrFunc(Line, Multiple, Address, &Size, ParamSize, Name)) + return FuncRecord(Multiple, Address, Size, ParamSize, Name); + + return llvm::None; +} + +bool breakpad::operator==(const FuncRecord &L, const FuncRecord &R) { + return L.Multiple == R.Multiple && L.Address == R.Address && + L.Size == R.Size && L.ParamSize == R.ParamSize && L.Name == R.Name; +} +llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, + const FuncRecord &R) { + return OS << llvm::formatv("FUNC {0}{1:x-} {2:x-} {3:x-} {4}", + R.Multiple ? "m " : "", R.Address, R.Size, + R.ParamSize, R.Name); +} + +llvm::Optional LineRecord::parse(llvm::StringRef Line) { + lldb::addr_t Address; + llvm::StringRef Str; + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, Address, 16)) + return llvm::None; + + lldb::addr_t Size; + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, Size, 16)) + return llvm::None; + + uint32_t LineNum; + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, LineNum)) + return llvm::None; + + size_t FileNum; + std::tie(Str, Line) = getToken(Line); + if (!to_integer(Str, FileNum)) + return llvm::None; + + return LineRecord(Address, Size, LineNum, FileNum); +} + +bool breakpad::operator==(const LineRecord &L, const LineRecord &R) { + return L.Address == R.Address && L.Size == R.Size && L.LineNum == R.LineNum && + L.FileNum == R.FileNum; +} +llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, + const LineRecord &R) { + return OS << llvm::formatv("{0:x-} {1:x-} {2} {3}", R.Address, R.Size, + R.LineNum, R.FileNum); +} + +llvm::Optional PublicRecord::parse(llvm::StringRef Line) { + bool Multiple; + lldb::addr_t Address, ParamSize; + llvm::StringRef Name; + + if (parsePublicOrFunc(Line, Multiple, Address, nullptr, ParamSize, Name)) + return PublicRecord(Multiple, Address, ParamSize, Name); + + return llvm::None; +} + +bool breakpad::operator==(const PublicRecord &L, const PublicRecord &R) { + return L.Multiple == R.Multiple && L.Address == R.Address && + L.ParamSize == R.ParamSize && L.Name == R.Name; +} +llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS, + const PublicRecord &R) { + return OS << llvm::formatv("PUBLIC {0}{1:x-} {2:x-} {3}", + R.Multiple ? "m " : "", R.Address, R.ParamSize, + R.Name); +} + +llvm::StringRef breakpad::toString(Record::Kind K) { + switch (K) { + case Record::Module: + return "MODULE"; + case Record::Info: + return "INFO"; + case Record::File: + return "FILE"; + case Record::Func: + return "FUNC"; + case Record::Line: + return "LINE"; + case Record::Public: + return "PUBLIC"; + case Record::Stack: + return "STACK"; + } + llvm_unreachable("Unknown record kind!"); +} diff --git a/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h new file mode 100644 index 000000000000..4353479c1063 --- /dev/null +++ b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h @@ -0,0 +1,147 @@ +//===-- BreakpadRecords.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 LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H +#define LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H + +#include "lldb/Utility/UUID.h" +#include "lldb/lldb-types.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Support/FormatProviders.h" + +namespace lldb_private { +namespace breakpad { + +class Record { +public: + enum Kind { Module, Info, File, Func, Line, Public, Stack }; + + /// Attempt to guess the kind of the record present in the argument without + /// doing a full parse. The returned kind will always be correct for valid + /// records, but the full parse can still fail in case of corrupted input. + static Kind classify(llvm::StringRef Line); + +protected: + Record(Kind K) : TheKind(K) {} + + ~Record() = default; + +public: + Kind getKind() { return TheKind; } + +private: + Kind TheKind; +}; + +llvm::StringRef toString(Record::Kind K); +inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, Record::Kind K) { + OS << toString(K); + return OS; +} + +class ModuleRecord : public Record { +public: + static llvm::Optional parse(llvm::StringRef Line); + ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID) + : Record(Module), OS(OS), Arch(Arch), ID(std::move(ID)) {} + + llvm::Triple::OSType OS; + llvm::Triple::ArchType Arch; + UUID ID; +}; + +inline bool operator==(const ModuleRecord &L, const ModuleRecord &R) { + return L.OS == R.OS && L.Arch == R.Arch && L.ID == R.ID; +} +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ModuleRecord &R); + +class InfoRecord : public Record { +public: + static llvm::Optional parse(llvm::StringRef Line); + InfoRecord(UUID ID) : Record(Info), ID(std::move(ID)) {} + + UUID ID; +}; + +inline bool operator==(const InfoRecord &L, const InfoRecord &R) { + return L.ID == R.ID; +} +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const InfoRecord &R); + +class FileRecord : public Record { +public: + static llvm::Optional parse(llvm::StringRef Line); + FileRecord(size_t Number, llvm::StringRef Name) + : Record(File), Number(Number), Name(Name) {} + + size_t Number; + llvm::StringRef Name; +}; + +inline bool operator==(const FileRecord &L, const FileRecord &R) { + return L.Number == R.Number && L.Name == R.Name; +} +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FileRecord &R); + +class FuncRecord : public Record { +public: + static llvm::Optional parse(llvm::StringRef Line); + FuncRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t Size, + lldb::addr_t ParamSize, llvm::StringRef Name) + : Record(Module), Multiple(Multiple), Address(Address), Size(Size), + ParamSize(ParamSize), Name(Name) {} + + bool Multiple; + lldb::addr_t Address; + lldb::addr_t Size; + lldb::addr_t ParamSize; + llvm::StringRef Name; +}; + +bool operator==(const FuncRecord &L, const FuncRecord &R); +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FuncRecord &R); + +class LineRecord : public Record { +public: + static llvm::Optional parse(llvm::StringRef Line); + LineRecord(lldb::addr_t Address, lldb::addr_t Size, uint32_t LineNum, + size_t FileNum) + : Record(Line), Address(Address), Size(Size), LineNum(LineNum), + FileNum(FileNum) {} + + lldb::addr_t Address; + lldb::addr_t Size; + uint32_t LineNum; + size_t FileNum; +}; + +bool operator==(const LineRecord &L, const LineRecord &R); +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const LineRecord &R); + +class PublicRecord : public Record { +public: + static llvm::Optional parse(llvm::StringRef Line); + PublicRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t ParamSize, + llvm::StringRef Name) + : Record(Module), Multiple(Multiple), Address(Address), + ParamSize(ParamSize), Name(Name) {} + + bool Multiple; + lldb::addr_t Address; + lldb::addr_t ParamSize; + llvm::StringRef Name; +}; + +bool operator==(const PublicRecord &L, const PublicRecord &R); +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const PublicRecord &R); + +} // namespace breakpad +} // namespace lldb_private + +#endif // LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H diff --git a/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt b/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt new file mode 100644 index 000000000000..0f3d9233083e --- /dev/null +++ b/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt @@ -0,0 +1,12 @@ +add_lldb_library(lldbPluginObjectFileBreakpad PLUGIN + BreakpadRecords.cpp + ObjectFileBreakpad.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbSymbol + lldbUtility + LINK_COMPONENTS + Support + ) diff --git a/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp new file mode 100644 index 000000000000..8825c83f7476 --- /dev/null +++ b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp @@ -0,0 +1,173 @@ +//===-- ObjectFileBreakpad.cpp -------------------------------- -*- 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 +// +//===----------------------------------------------------------------------===// + +#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h" +#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Section.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::breakpad; + +namespace { +struct Header { + ArchSpec arch; + UUID uuid; + static llvm::Optional
parse(llvm::StringRef text); +}; +} // namespace + +llvm::Optional
Header::parse(llvm::StringRef text) { + llvm::StringRef line; + std::tie(line, text) = text.split('\n'); + auto Module = ModuleRecord::parse(line); + if (!Module) + return llvm::None; + + llvm::Triple triple; + triple.setArch(Module->Arch); + triple.setOS(Module->OS); + + std::tie(line, text) = text.split('\n'); + + auto Info = InfoRecord::parse(line); + UUID uuid = Info && Info->ID ? Info->ID : Module->ID; + return Header{ArchSpec(triple), std::move(uuid)}; +} + +void ObjectFileBreakpad::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + CreateMemoryInstance, GetModuleSpecifications); +} + +void ObjectFileBreakpad::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); +} + +ConstString ObjectFileBreakpad::GetPluginNameStatic() { + static ConstString g_name("breakpad"); + return g_name; +} + +ObjectFile *ObjectFileBreakpad::CreateInstance( + const ModuleSP &module_sp, DataBufferSP &data_sp, offset_t data_offset, + const FileSpec *file, offset_t file_offset, offset_t length) { + if (!data_sp) { + data_sp = MapFileData(*file, length, file_offset); + if (!data_sp) + return nullptr; + data_offset = 0; + } + auto text = toStringRef(data_sp->GetData()); + llvm::Optional
header = Header::parse(text); + if (!header) + return nullptr; + + // Update the data to contain the entire file if it doesn't already + if (data_sp->GetByteSize() < length) { + data_sp = MapFileData(*file, length, file_offset); + if (!data_sp) + return nullptr; + data_offset = 0; + } + + return new ObjectFileBreakpad(module_sp, data_sp, data_offset, file, + file_offset, length, std::move(header->arch), + std::move(header->uuid)); +} + +ObjectFile *ObjectFileBreakpad::CreateMemoryInstance( + const ModuleSP &module_sp, DataBufferSP &data_sp, + const ProcessSP &process_sp, addr_t header_addr) { + return nullptr; +} + +size_t ObjectFileBreakpad::GetModuleSpecifications( + const FileSpec &file, DataBufferSP &data_sp, offset_t data_offset, + offset_t file_offset, offset_t length, ModuleSpecList &specs) { + auto text = toStringRef(data_sp->GetData()); + llvm::Optional
header = Header::parse(text); + if (!header) + return 0; + ModuleSpec spec(file, std::move(header->arch)); + spec.GetUUID() = std::move(header->uuid); + specs.Append(spec); + return 1; +} + +ObjectFileBreakpad::ObjectFileBreakpad(const ModuleSP &module_sp, + DataBufferSP &data_sp, + offset_t data_offset, + const FileSpec *file, offset_t offset, + offset_t length, ArchSpec arch, + UUID uuid) + : ObjectFile(module_sp, file, offset, length, data_sp, data_offset), + m_arch(std::move(arch)), m_uuid(std::move(uuid)) {} + +bool ObjectFileBreakpad::ParseHeader() { + // We already parsed the header during initialization. + return true; +} + +Symtab *ObjectFileBreakpad::GetSymtab() { + // TODO + return nullptr; +} + +bool ObjectFileBreakpad::GetUUID(UUID *uuid) { + *uuid = m_uuid; + return true; +} + +void ObjectFileBreakpad::CreateSections(SectionList &unified_section_list) { + if (m_sections_ap) + return; + m_sections_ap = llvm::make_unique(); + + llvm::Optional current_section; + offset_t section_start; + llvm::StringRef text = toStringRef(m_data.GetData()); + uint32_t next_section_id = 1; + auto maybe_add_section = [&](const uint8_t *end_ptr) { + if (!current_section) + return; // We have been called before parsing the first line. + + offset_t end_offset = end_ptr - m_data.GetDataStart(); + auto section_sp = std::make_shared
( + GetModule(), this, next_section_id++, + ConstString(toString(*current_section)), eSectionTypeOther, + /*file_vm_addr*/ 0, /*vm_size*/ 0, section_start, + end_offset - section_start, /*log2align*/ 0, /*flags*/ 0); + m_sections_ap->AddSection(section_sp); + unified_section_list.AddSection(section_sp); + }; + while (!text.empty()) { + llvm::StringRef line; + std::tie(line, text) = text.split('\n'); + + Record::Kind next_section = Record::classify(line); + if (next_section == Record::Line) { + // Line records logically belong to the preceding Func record, so we put + // them in the same section. + next_section = Record::Func; + } + if (next_section == current_section) + continue; + + // Changing sections, finish off the previous one, if there was any. + maybe_add_section(line.bytes_begin()); + // And start a new one. + current_section = next_section; + section_start = line.bytes_begin() - m_data.GetDataStart(); + } + // Finally, add the last section. + maybe_add_section(m_data.GetDataEnd()); +} diff --git a/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h new file mode 100644 index 000000000000..0304eff6e255 --- /dev/null +++ b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h @@ -0,0 +1,107 @@ +//===-- ObjectFileBreakpad.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 LLDB_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H +#define LLDB_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H + +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/ArchSpec.h" + +namespace lldb_private { +namespace breakpad { + +class ObjectFileBreakpad : public ObjectFile { +public: + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void Initialize(); + static void Terminate(); + + static ConstString GetPluginNameStatic(); + static const char *GetPluginDescriptionStatic() { + return "Breakpad object file reader."; + } + + static ObjectFile * + CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, + lldb::offset_t data_offset, const FileSpec *file, + lldb::offset_t file_offset, lldb::offset_t length); + + static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp, + lldb::DataBufferSP &data_sp, + const lldb::ProcessSP &process_sp, + lldb::addr_t header_addr); + + static size_t GetModuleSpecifications(const FileSpec &file, + lldb::DataBufferSP &data_sp, + lldb::offset_t data_offset, + lldb::offset_t file_offset, + lldb::offset_t length, + ModuleSpecList &specs); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + ConstString GetPluginName() override { return GetPluginNameStatic(); } + + uint32_t GetPluginVersion() override { return 1; } + + //------------------------------------------------------------------ + // ObjectFile Protocol. + //------------------------------------------------------------------ + + bool ParseHeader() override; + + lldb::ByteOrder GetByteOrder() const override { + return m_arch.GetByteOrder(); + } + + bool IsExecutable() const override { return false; } + + uint32_t GetAddressByteSize() const override { + return m_arch.GetAddressByteSize(); + } + + AddressClass GetAddressClass(lldb::addr_t file_addr) override { + return AddressClass::eInvalid; + } + + Symtab *GetSymtab() override; + + bool IsStripped() override { return false; } + + void CreateSections(SectionList &unified_section_list) override; + + void Dump(Stream *s) override {} + + ArchSpec GetArchitecture() override { return m_arch; } + + bool GetUUID(UUID *uuid) override; + + FileSpecList GetDebugSymbolFilePaths() override { return FileSpecList(); } + + uint32_t GetDependentModules(FileSpecList &files) override { return 0; } + + Type CalculateType() override { return eTypeDebugInfo; } + + Strata CalculateStrata() override { return eStrataUser; } + +private: + ArchSpec m_arch; + UUID m_uuid; + + ObjectFileBreakpad(const lldb::ModuleSP &module_sp, + lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, + const FileSpec *file, lldb::offset_t offset, + lldb::offset_t length, ArchSpec arch, UUID uuid); +}; + +} // namespace breakpad +} // namespace lldb_private +#endif // LLDB_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H diff --git a/source/Plugins/ObjectFile/CMakeLists.txt b/source/Plugins/ObjectFile/CMakeLists.txt index 06aa01c4f004..4edd667b9723 100644 --- a/source/Plugins/ObjectFile/CMakeLists.txt +++ b/source/Plugins/ObjectFile/CMakeLists.txt @@ -1,4 +1,5 @@ +add_subdirectory(Breakpad) add_subdirectory(ELF) add_subdirectory(Mach-O) add_subdirectory(PECOFF) -add_subdirectory(JIT) \ No newline at end of file +add_subdirectory(JIT) diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/source/Plugins/ObjectFile/ELF/ELFHeader.cpp index 16cbb6e5753b..13d85d1c95bc 100644 --- a/source/Plugins/ObjectFile/ELF/ELFHeader.cpp +++ b/source/Plugins/ObjectFile/ELF/ELFHeader.cpp @@ -1,9 +1,8 @@ //===-- ELFHeader.cpp ----------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -38,7 +37,7 @@ static bool GetMaxU64(const lldb_private::DataExtractor &data, lldb::offset_t saved_offset = *offset; for (uint32_t i = 0; i < count; ++i, ++value) { - if (GetMaxU64(data, offset, value, byte_size) == false) { + if (!GetMaxU64(data, offset, value, byte_size)) { *offset = saved_offset; return false; } @@ -60,7 +59,7 @@ static bool GetMaxS64(const lldb_private::DataExtractor &data, lldb::offset_t saved_offset = *offset; for (uint32_t i = 0; i < count; ++i, ++value) { - if (GetMaxS64(data, offset, value, byte_size) == false) { + if (!GetMaxS64(data, offset, value, byte_size)) { *offset = saved_offset; return false; } @@ -133,7 +132,7 @@ bool ELFHeader::Parse(lldb_private::DataExtractor &data, return false; // Read e_entry, e_phoff and e_shoff. - if (GetMaxU64(data, offset, &e_entry, byte_size, 3) == false) + if (!GetMaxU64(data, offset, &e_entry, byte_size, 3)) return false; // Read e_flags. @@ -232,11 +231,11 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data, return false; // Read sh_flags. - if (GetMaxU64(data, offset, &sh_flags, byte_size) == false) + if (!GetMaxU64(data, offset, &sh_flags, byte_size)) return false; // Read sh_addr, sh_off and sh_size. - if (GetMaxU64(data, offset, &sh_addr, byte_size, 3) == false) + if (!GetMaxU64(data, offset, &sh_addr, byte_size, 3)) return false; // Read sh_link and sh_info. @@ -244,7 +243,7 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data, return false; // Read sh_addralign and sh_entsize. - if (GetMaxU64(data, offset, &sh_addralign, byte_size, 2) == false) + if (!GetMaxU64(data, offset, &sh_addralign, byte_size, 2)) return false; return true; @@ -332,7 +331,7 @@ bool ELFSymbol::Parse(const lldb_private::DataExtractor &data, if (parsing_32) { // Read st_value and st_size. - if (GetMaxU64(data, offset, &st_value, byte_size, 2) == false) + if (!GetMaxU64(data, offset, &st_value, byte_size, 2)) return false; // Read st_info and st_other. @@ -376,7 +375,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data, if (parsing_32) { // Read p_offset, p_vaddr, p_paddr, p_filesz and p_memsz. - if (GetMaxU64(data, offset, &p_offset, byte_size, 5) == false) + if (!GetMaxU64(data, offset, &p_offset, byte_size, 5)) return false; // Read p_flags. @@ -384,7 +383,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data, return false; // Read p_align. - if (GetMaxU64(data, offset, &p_align, byte_size) == false) + if (!GetMaxU64(data, offset, &p_align, byte_size)) return false; } else { // Read p_flags. @@ -392,7 +391,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data, return false; // Read p_offset, p_vaddr, p_paddr, p_filesz, p_memsz and p_align. - if (GetMaxU64(data, offset, &p_offset, byte_size, 6) == false) + if (!GetMaxU64(data, offset, &p_offset, byte_size, 6)) return false; } @@ -420,10 +419,7 @@ bool ELFRel::Parse(const lldb_private::DataExtractor &data, const unsigned byte_size = data.GetAddressByteSize(); // Read r_offset and r_info. - if (GetMaxU64(data, offset, &r_offset, byte_size, 2) == false) - return false; - - return true; + return GetMaxU64(data, offset, &r_offset, byte_size, 2) != false; } //------------------------------------------------------------------------------ @@ -436,11 +432,11 @@ bool ELFRela::Parse(const lldb_private::DataExtractor &data, const unsigned byte_size = data.GetAddressByteSize(); // Read r_offset and r_info. - if (GetMaxU64(data, offset, &r_offset, byte_size, 2) == false) + if (!GetMaxU64(data, offset, &r_offset, byte_size, 2)) return false; // Read r_addend; - if (GetMaxS64(data, offset, &r_addend, byte_size) == false) + if (!GetMaxS64(data, offset, &r_addend, byte_size)) return false; return true; diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.h b/source/Plugins/ObjectFile/ELF/ELFHeader.h index faaf8be99d68..493785307997 100644 --- a/source/Plugins/ObjectFile/ELF/ELFHeader.h +++ b/source/Plugins/ObjectFile/ELF/ELFHeader.h @@ -1,9 +1,8 @@ //===-- ELFHeader.h ------------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 14819f4ee6fd..3774d81dc13a 100644 --- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1,9 +1,8 @@ //===-- ObjectFileELF.cpp ------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,7 +16,9 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/SectionLoadList.h" @@ -30,6 +31,7 @@ #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" +#include "llvm/ADT/IntervalMap.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/StringRef.h" #include "llvm/Object/Decompressor.h" @@ -236,6 +238,8 @@ unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) { } // end anonymous namespace +static user_id_t SegmentID(size_t PHdrIndex) { return ~PHdrIndex; } + bool ELFNote::Parse(const DataExtractor &data, lldb::offset_t *offset) { // Read all fields. if (data.GetU32(offset, &n_namesz, 3) == NULL) @@ -434,9 +438,8 @@ ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp, if (address_size == 4 || address_size == 8) { std::unique_ptr objfile_ap(new ObjectFileELF( module_sp, data_sp, data_offset, file, file_offset, length)); - ArchSpec spec; - if (objfile_ap->GetArchitecture(spec) && - objfile_ap->SetModulesArchitecture(spec)) + ArchSpec spec = objfile_ap->GetArchitecture(); + if (spec && objfile_ap->SetModulesArchitecture(spec)) return objfile_ap.release(); } @@ -453,9 +456,8 @@ ObjectFile *ObjectFileELF::CreateMemoryInstance( if (address_size == 4 || address_size == 8) { std::unique_ptr objfile_ap( new ObjectFileELF(module_sp, data_sp, process_sp, header_addr)); - ArchSpec spec; - if (objfile_ap->GetArchitecture(spec) && - objfile_ap->SetModulesArchitecture(spec)) + ArchSpec spec = objfile_ap->GetArchitecture(); + if (spec && objfile_ap->SetModulesArchitecture(spec)) return objfile_ap.release(); } } @@ -539,14 +541,13 @@ static uint32_t calc_gnu_debuglink_crc32(const void *buf, size_t size) { uint32_t ObjectFileELF::CalculateELFNotesSegmentsCRC32( const ProgramHeaderColl &program_headers, DataExtractor &object_data) { - typedef ProgramHeaderCollConstIter Iter; uint32_t core_notes_crc = 0; - for (Iter I = program_headers.begin(); I != program_headers.end(); ++I) { - if (I->p_type == llvm::ELF::PT_NOTE) { - const elf_off ph_offset = I->p_offset; - const size_t ph_size = I->p_filesz; + for (const ELFProgramHeader &H : program_headers) { + if (H.p_type == llvm::ELF::PT_NOTE) { + const elf_off ph_offset = H.p_offset; + const size_t ph_size = H.p_filesz; DataExtractor segment_data; if (segment_data.SetData(object_data, ph_offset, ph_size) != ph_size) { @@ -714,7 +715,8 @@ size_t ObjectFileELF::GetModuleSpecifications( func_cat, "Calculating module crc32 %s with size %" PRIu64 " KiB", file.GetLastPathComponent().AsCString(), - (file.GetByteSize() - file_offset) / 1024); + (FileSystem::Instance().GetByteSize(file) - file_offset) / + 1024); // For core files - which usually don't happen to have a // gnu_debuglink, and are pretty bulky - calculating whole @@ -804,21 +806,10 @@ bool ObjectFileELF::SetLoadAddress(Target &target, lldb::addr_t value, SectionList *section_list = GetSectionList(); if (section_list) { if (!value_is_offset) { - bool found_offset = false; - for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) { - const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i); - if (header == nullptr) - continue; - - if (header->p_type != PT_LOAD || header->p_offset != 0) - continue; - - value = value - header->p_vaddr; - found_offset = true; - break; - } - if (!found_offset) + addr_t base = GetBaseAddress().GetFileAddress(); + if (base == LLDB_INVALID_ADDRESS) return false; + value -= base; } const size_t num_sections = section_list->GetSize(); @@ -828,7 +819,8 @@ bool ObjectFileELF::SetLoadAddress(Target &target, lldb::addr_t value, // Iterate through the object file sections to find all of the sections // that have SHF_ALLOC in their flag bits. SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); - if (section_sp && section_sp->Test(SHF_ALLOC)) { + if (section_sp->Test(SHF_ALLOC) || + section_sp->GetType() == eSectionTypeContainer) { lldb::addr_t load_addr = section_sp->GetFileAddress(); // We don't want to update the load address of a section with type // eSectionTypeAbsoluteAddress as they already have the absolute load @@ -893,11 +885,11 @@ AddressClass ObjectFileELF::GetAddressClass(addr_t file_addr) { } size_t ObjectFileELF::SectionIndex(const SectionHeaderCollIter &I) { - return std::distance(m_section_headers.begin(), I) + 1u; + return std::distance(m_section_headers.begin(), I); } size_t ObjectFileELF::SectionIndex(const SectionHeaderCollConstIter &I) const { - return std::distance(m_section_headers.begin(), I) + 1u; + return std::distance(m_section_headers.begin(), I); } bool ObjectFileELF::ParseHeader() { @@ -954,7 +946,7 @@ lldb_private::FileSpecList ObjectFileELF::GetDebugSymbolFilePaths() { FileSpecList file_spec_list; if (!m_gnu_debuglink_file.empty()) { - FileSpec file_spec(m_gnu_debuglink_file, false); + FileSpec file_spec(m_gnu_debuglink_file); file_spec_list.Append(file_spec); } return file_spec_list; @@ -1056,6 +1048,18 @@ lldb_private::Address ObjectFileELF::GetEntryPointAddress() { return m_entry_point_address; } +Address ObjectFileELF::GetBaseAddress() { + for (const auto &EnumPHdr : llvm::enumerate(ProgramHeaders())) { + const ELFProgramHeader &H = EnumPHdr.value(); + if (H.p_type != PT_LOAD) + continue; + + return Address( + GetSectionList()->FindSectionByID(SegmentID(EnumPHdr.index())), 0); + } + return LLDB_INVALID_ADDRESS; +} + //---------------------------------------------------------------------- // ParseDependentModules //---------------------------------------------------------------------- @@ -1085,7 +1089,7 @@ size_t ObjectFileELF::ParseDependentModules() { return 0; // sh_link: section header index of string table used by entries in the // section. - Section *dynstr = section_list->FindSectionByID(header->sh_link + 1).get(); + Section *dynstr = section_list->FindSectionByID(header->sh_link).get(); if (!dynstr) return 0; @@ -1108,7 +1112,9 @@ size_t ObjectFileELF::ParseDependentModules() { uint32_t str_index = static_cast(symbol.d_val); const char *lib_name = dynstr_data.PeekCStr(str_index); - m_filespec_ap->Append(FileSpec(lib_name, true)); + FileSpec file_spec(lib_name); + FileSystem::Instance().Resolve(file_spec); + m_filespec_ap->Append(file_spec); } } @@ -1142,7 +1148,7 @@ size_t ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers, uint32_t idx; lldb::offset_t offset; for (idx = 0, offset = 0; idx < header.e_phnum; ++idx) { - if (program_headers[idx].Parse(data, &offset) == false) + if (!program_headers[idx].Parse(data, &offset)) break; } @@ -1155,8 +1161,8 @@ size_t ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers, //---------------------------------------------------------------------- // ParseProgramHeaders //---------------------------------------------------------------------- -size_t ObjectFileELF::ParseProgramHeaders() { - return GetProgramHeaderInfo(m_program_headers, m_data, m_header); +bool ObjectFileELF::ParseProgramHeaders() { + return GetProgramHeaderInfo(m_program_headers, m_data, m_header) != 0; } lldb_private::Status @@ -1391,7 +1397,7 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data, arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS) // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing for some // cases (e.g. compile with -nostdlib) Hence set OS to Linux - arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); + arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); } } @@ -1495,7 +1501,7 @@ size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, const uint32_t sub_type = subTypeFromElfHeader(header); arch_spec.SetArchitecture(eArchTypeELF, header.e_machine, sub_type, header.e_ident[EI_OSABI]); - + // Validate if it is ok to remove GetOsFromOSABI. Note, that now the OS is // determined based on EI_OSABI flag and the info extracted from ELF notes // (see RefineModuleDetailsFromNote). However in some cases that still @@ -1554,7 +1560,7 @@ size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, uint32_t idx; lldb::offset_t offset; for (idx = 0, offset = 0; idx < header.e_shnum; ++idx) { - if (section_headers[idx].Parse(sh_data, &offset) == false) + if (!section_headers[idx].Parse(sh_data, &offset)) break; } if (idx < section_headers.size()) @@ -1702,27 +1708,6 @@ size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, return 0; } -size_t ObjectFileELF::GetProgramHeaderCount() { return ParseProgramHeaders(); } - -const elf::ELFProgramHeader * -ObjectFileELF::GetProgramHeaderByIndex(lldb::user_id_t id) { - if (!id || !ParseProgramHeaders()) - return NULL; - - if (--id < m_program_headers.size()) - return &m_program_headers[id]; - - return NULL; -} - -DataExtractor ObjectFileELF::GetSegmentDataByIndex(lldb::user_id_t id) { - const elf::ELFProgramHeader *segment_header = GetProgramHeaderByIndex(id); - if (segment_header == NULL) - return DataExtractor(); - return DataExtractor(m_data, segment_header->p_offset, - segment_header->p_filesz); -} - llvm::StringRef ObjectFileELF::StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const { size_t pos = symbol_name.find('@'); @@ -1740,10 +1725,10 @@ size_t ObjectFileELF::ParseSectionHeaders() { const ObjectFileELF::ELFSectionHeaderInfo * ObjectFileELF::GetSectionHeaderByIndex(lldb::user_id_t id) { - if (!id || !ParseSectionHeaders()) + if (!ParseSectionHeaders()) return NULL; - if (--id < m_section_headers.size()) + if (id < m_section_headers.size()) return &m_section_headers[id]; return NULL; @@ -1758,236 +1743,276 @@ lldb::user_id_t ObjectFileELF::GetSectionIndexByName(const char *name) { return 0; } -void ObjectFileELF::CreateSections(SectionList &unified_section_list) { - if (!m_sections_ap.get() && ParseSectionHeaders()) { - m_sections_ap.reset(new SectionList()); - - // Object files frequently have 0 for every section address, meaning we - // need to compute synthetic addresses in order for "file addresses" from - // different sections to not overlap - bool synthaddrs = (CalculateType() == ObjectFile::Type::eTypeObjectFile); - uint64_t nextaddr = 0; - - for (SectionHeaderCollIter I = m_section_headers.begin(); - I != m_section_headers.end(); ++I) { - const ELFSectionHeaderInfo &header = *I; - - ConstString &name = I->section_name; - const uint64_t file_size = - header.sh_type == SHT_NOBITS ? 0 : header.sh_size; - const uint64_t vm_size = header.sh_flags & SHF_ALLOC ? header.sh_size : 0; - - static ConstString g_sect_name_text(".text"); - static ConstString g_sect_name_data(".data"); - static ConstString g_sect_name_bss(".bss"); - static ConstString g_sect_name_tdata(".tdata"); - static ConstString g_sect_name_tbss(".tbss"); - static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev"); - static ConstString g_sect_name_dwarf_debug_addr(".debug_addr"); - static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges"); - static ConstString g_sect_name_dwarf_debug_cu_index(".debug_cu_index"); - static ConstString g_sect_name_dwarf_debug_frame(".debug_frame"); - static ConstString g_sect_name_dwarf_debug_info(".debug_info"); - static ConstString g_sect_name_dwarf_debug_line(".debug_line"); - static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); - static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); - static ConstString g_sect_name_dwarf_debug_macro(".debug_macro"); - static ConstString g_sect_name_dwarf_debug_names(".debug_names"); - static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames"); - static ConstString g_sect_name_dwarf_debug_pubtypes(".debug_pubtypes"); - static ConstString g_sect_name_dwarf_debug_ranges(".debug_ranges"); - static ConstString g_sect_name_dwarf_debug_str(".debug_str"); - static ConstString g_sect_name_dwarf_debug_str_offsets( - ".debug_str_offsets"); - static ConstString g_sect_name_dwarf_debug_abbrev_dwo( - ".debug_abbrev.dwo"); - static ConstString g_sect_name_dwarf_debug_info_dwo(".debug_info.dwo"); - static ConstString g_sect_name_dwarf_debug_line_dwo(".debug_line.dwo"); - static ConstString g_sect_name_dwarf_debug_macro_dwo(".debug_macro.dwo"); - static ConstString g_sect_name_dwarf_debug_loc_dwo(".debug_loc.dwo"); - static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo"); - static ConstString g_sect_name_dwarf_debug_str_offsets_dwo( - ".debug_str_offsets.dwo"); - static ConstString g_sect_name_dwarf_debug_types(".debug_types"); - static ConstString g_sect_name_eh_frame(".eh_frame"); - static ConstString g_sect_name_swift_ast(".swift_ast"); - static ConstString g_sect_name_arm_exidx(".ARM.exidx"); - static ConstString g_sect_name_arm_extab(".ARM.extab"); - static ConstString g_sect_name_go_symtab(".gosymtab"); - static ConstString g_sect_name_dwarf_gnu_debugaltlink(".gnu_debugaltlink"); - - SectionType sect_type = eSectionTypeOther; - - bool is_thread_specific = false; - - if (name == g_sect_name_text) - sect_type = eSectionTypeCode; - else if (name == g_sect_name_data) - sect_type = eSectionTypeData; - else if (name == g_sect_name_bss) - sect_type = eSectionTypeZeroFill; - else if (name == g_sect_name_tdata) { - sect_type = eSectionTypeData; - is_thread_specific = true; - } else if (name == g_sect_name_tbss) { - sect_type = eSectionTypeZeroFill; - is_thread_specific = true; - } - // .debug_abbrev – Abbreviations used in the .debug_info section - // .debug_aranges – Lookup table for mapping addresses to compilation - // units .debug_frame – Call frame information .debug_info – The core - // DWARF information section .debug_line – Line number information - // .debug_loc – Location lists used in DW_AT_location attributes - // .debug_macinfo – Macro information .debug_pubnames – Lookup table - // for mapping object and function names to compilation units - // .debug_pubtypes – Lookup table for mapping type names to compilation - // units .debug_ranges – Address ranges used in DW_AT_ranges attributes - // .debug_str – String table used in .debug_info MISSING? - // .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section, - // http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html MISSING? - // .debug-index - http://src.chromium.org/viewvc/chrome/trunk/src/build - // /gdb-add-index?pathrev=144644 MISSING? .debug_types - Type - // descriptions from DWARF 4? See - // http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo - else if (name == g_sect_name_dwarf_debug_abbrev) - sect_type = eSectionTypeDWARFDebugAbbrev; - else if (name == g_sect_name_dwarf_debug_addr) - sect_type = eSectionTypeDWARFDebugAddr; - else if (name == g_sect_name_dwarf_debug_aranges) - sect_type = eSectionTypeDWARFDebugAranges; - else if (name == g_sect_name_dwarf_debug_cu_index) - sect_type = eSectionTypeDWARFDebugCuIndex; - else if (name == g_sect_name_dwarf_debug_frame) - sect_type = eSectionTypeDWARFDebugFrame; - else if (name == g_sect_name_dwarf_debug_info) - sect_type = eSectionTypeDWARFDebugInfo; - else if (name == g_sect_name_dwarf_debug_line) - sect_type = eSectionTypeDWARFDebugLine; - else if (name == g_sect_name_dwarf_debug_loc) - sect_type = eSectionTypeDWARFDebugLoc; - else if (name == g_sect_name_dwarf_debug_macinfo) - sect_type = eSectionTypeDWARFDebugMacInfo; - else if (name == g_sect_name_dwarf_debug_macro) - sect_type = eSectionTypeDWARFDebugMacro; - else if (name == g_sect_name_dwarf_debug_names) - sect_type = eSectionTypeDWARFDebugNames; - else if (name == g_sect_name_dwarf_debug_pubnames) - sect_type = eSectionTypeDWARFDebugPubNames; - else if (name == g_sect_name_dwarf_debug_pubtypes) - sect_type = eSectionTypeDWARFDebugPubTypes; - else if (name == g_sect_name_dwarf_debug_ranges) - sect_type = eSectionTypeDWARFDebugRanges; - else if (name == g_sect_name_dwarf_debug_str) - sect_type = eSectionTypeDWARFDebugStr; - else if (name == g_sect_name_dwarf_debug_types) - sect_type = eSectionTypeDWARFDebugTypes; - else if (name == g_sect_name_dwarf_debug_str_offsets) - sect_type = eSectionTypeDWARFDebugStrOffsets; - else if (name == g_sect_name_dwarf_debug_abbrev_dwo) - sect_type = eSectionTypeDWARFDebugAbbrev; - else if (name == g_sect_name_dwarf_debug_info_dwo) - sect_type = eSectionTypeDWARFDebugInfo; - else if (name == g_sect_name_dwarf_debug_line_dwo) - sect_type = eSectionTypeDWARFDebugLine; - else if (name == g_sect_name_dwarf_debug_macro_dwo) - sect_type = eSectionTypeDWARFDebugMacro; - else if (name == g_sect_name_dwarf_debug_loc_dwo) - sect_type = eSectionTypeDWARFDebugLoc; - else if (name == g_sect_name_dwarf_debug_str_dwo) - sect_type = eSectionTypeDWARFDebugStr; - else if (name == g_sect_name_dwarf_debug_str_offsets_dwo) - sect_type = eSectionTypeDWARFDebugStrOffsets; - else if (name == g_sect_name_eh_frame) - sect_type = eSectionTypeEHFrame; - else if (name == g_sect_name_swift_ast) - sect_type = eSectionTypeSwiftModules; - else if (name == g_sect_name_arm_exidx) - sect_type = eSectionTypeARMexidx; - else if (name == g_sect_name_arm_extab) - sect_type = eSectionTypeARMextab; - else if (name == g_sect_name_go_symtab) - sect_type = eSectionTypeGoSymtab; - else if (name == g_sect_name_dwarf_gnu_debugaltlink) - sect_type = eSectionTypeDWARFGNUDebugAltLink; - - const uint32_t permissions = - ((header.sh_flags & SHF_ALLOC) ? ePermissionsReadable : 0u) | - ((header.sh_flags & SHF_WRITE) ? ePermissionsWritable : 0u) | - ((header.sh_flags & SHF_EXECINSTR) ? ePermissionsExecutable : 0u); - switch (header.sh_type) { - case SHT_SYMTAB: - assert(sect_type == eSectionTypeOther); - sect_type = eSectionTypeELFSymbolTable; - break; - case SHT_DYNSYM: - assert(sect_type == eSectionTypeOther); - sect_type = eSectionTypeELFDynamicSymbols; - break; - case SHT_RELA: - case SHT_REL: - assert(sect_type == eSectionTypeOther); - sect_type = eSectionTypeELFRelocationEntries; - break; - case SHT_DYNAMIC: - assert(sect_type == eSectionTypeOther); - sect_type = eSectionTypeELFDynamicLinkInfo; - break; - } +static SectionType GetSectionTypeFromName(llvm::StringRef Name) { + return llvm::StringSwitch(Name) + .Case(".ARM.exidx", eSectionTypeARMexidx) + .Case(".ARM.extab", eSectionTypeARMextab) + .Cases(".bss", ".tbss", eSectionTypeZeroFill) + .Cases(".data", ".tdata", eSectionTypeData) + .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev) + .Case(".debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo) + .Case(".debug_addr", eSectionTypeDWARFDebugAddr) + .Case(".debug_aranges", eSectionTypeDWARFDebugAranges) + .Case(".debug_cu_index", eSectionTypeDWARFDebugCuIndex) + .Case(".debug_frame", eSectionTypeDWARFDebugFrame) + .Case(".debug_info", eSectionTypeDWARFDebugInfo) + .Case(".debug_info.dwo", eSectionTypeDWARFDebugInfoDwo) + .Cases(".debug_line", ".debug_line.dwo", eSectionTypeDWARFDebugLine) + .Cases(".debug_line_str", ".debug_line_str.dwo", + eSectionTypeDWARFDebugLineStr) + .Cases(".debug_loc", ".debug_loc.dwo", eSectionTypeDWARFDebugLoc) + .Cases(".debug_loclists", ".debug_loclists.dwo", + eSectionTypeDWARFDebugLocLists) + .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo) + .Cases(".debug_macro", ".debug_macro.dwo", eSectionTypeDWARFDebugMacro) + .Case(".debug_names", eSectionTypeDWARFDebugNames) + .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames) + .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes) + .Case(".debug_ranges", eSectionTypeDWARFDebugRanges) + .Case(".debug_rnglists", eSectionTypeDWARFDebugRngLists) + .Case(".debug_str", eSectionTypeDWARFDebugStr) + .Case(".debug_str.dwo", eSectionTypeDWARFDebugStrDwo) + .Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets) + .Case(".debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo) + .Case(".debug_types", eSectionTypeDWARFDebugTypes) + .Case(".eh_frame", eSectionTypeEHFrame) + .Case(".gnu_debugaltlink", eSectionTypeDWARFGNUDebugAltLink) + .Case(".gosymtab", eSectionTypeGoSymtab) + .Case(".text", eSectionTypeCode) + // Swift support: + .Case(".swift_ast", eSectionTypeSwiftModules) + // + .Default(eSectionTypeOther); +} + +SectionType ObjectFileELF::GetSectionType(const ELFSectionHeaderInfo &H) const { + switch (H.sh_type) { + case SHT_PROGBITS: + if (H.sh_flags & SHF_EXECINSTR) + return eSectionTypeCode; + break; + case SHT_SYMTAB: + return eSectionTypeELFSymbolTable; + case SHT_DYNSYM: + return eSectionTypeELFDynamicSymbols; + case SHT_RELA: + case SHT_REL: + return eSectionTypeELFRelocationEntries; + case SHT_DYNAMIC: + return eSectionTypeELFDynamicLinkInfo; + } + SectionType Type = GetSectionTypeFromName(H.section_name.GetStringRef()); + if (Type == eSectionTypeOther) { + // the kalimba toolchain assumes that ELF section names are free-form. + // It does support linkscripts which (can) give rise to various + // arbitrarily named sections being "Code" or "Data". + Type = kalimbaSectionType(m_header, H); + } + return Type; +} + +static uint32_t GetTargetByteSize(SectionType Type, const ArchSpec &arch) { + switch (Type) { + case eSectionTypeData: + case eSectionTypeZeroFill: + return arch.GetDataByteSize(); + case eSectionTypeCode: + return arch.GetCodeByteSize(); + default: + return 1; + } +} - if (eSectionTypeOther == sect_type) { - // the kalimba toolchain assumes that ELF section names are free-form. - // It does support linkscripts which (can) give rise to various - // arbitrarily named sections being "Code" or "Data". - sect_type = kalimbaSectionType(m_header, header); - } +static Permissions GetPermissions(const ELFSectionHeader &H) { + Permissions Perm = Permissions(0); + if (H.sh_flags & SHF_ALLOC) + Perm |= ePermissionsReadable; + if (H.sh_flags & SHF_WRITE) + Perm |= ePermissionsWritable; + if (H.sh_flags & SHF_EXECINSTR) + Perm |= ePermissionsExecutable; + return Perm; +} - // In common case ELF code section can have arbitrary name (for example, - // we can specify it using section attribute for particular function) so - // assume that section is a code section if it has SHF_EXECINSTR flag set - // and has SHT_PROGBITS type. - if (eSectionTypeOther == sect_type && - llvm::ELF::SHT_PROGBITS == header.sh_type && - (header.sh_flags & SHF_EXECINSTR)) { - sect_type = eSectionTypeCode; - } +static Permissions GetPermissions(const ELFProgramHeader &H) { + Permissions Perm = Permissions(0); + if (H.p_flags & PF_R) + Perm |= ePermissionsReadable; + if (H.p_flags & PF_W) + Perm |= ePermissionsWritable; + if (H.p_flags & PF_X) + Perm |= ePermissionsExecutable; + return Perm; +} - const uint32_t target_bytes_size = - (eSectionTypeData == sect_type || eSectionTypeZeroFill == sect_type) - ? m_arch_spec.GetDataByteSize() - : eSectionTypeCode == sect_type ? m_arch_spec.GetCodeByteSize() - : 1; - elf::elf_xword log2align = - (header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign); - - uint64_t addr = header.sh_addr; - - if ((header.sh_flags & SHF_ALLOC) && synthaddrs) { - nextaddr = - (nextaddr + header.sh_addralign - 1) & ~(header.sh_addralign - 1); - addr = nextaddr; - nextaddr += vm_size; - } +namespace { - SectionSP section_sp(new Section( - GetModule(), // Module to which this section belongs. - this, // ObjectFile to which this section belongs and should read - // section data from. - SectionIndex(I), // Section ID. - name, // Section name. - sect_type, // Section type. - addr, // VM address. - vm_size, // VM size in bytes of this section. - header.sh_offset, // Offset of this section in the file. - file_size, // Size of the section as found in the file. - log2align, // Alignment of the section - header.sh_flags, // Flags for this section. - target_bytes_size)); // Number of host bytes per target byte - - section_sp->SetPermissions(permissions); - if (is_thread_specific) - section_sp->SetIsThreadSpecific(is_thread_specific); - m_sections_ap->AddSection(section_sp); +using VMRange = lldb_private::Range; + +struct SectionAddressInfo { + SectionSP Segment; + VMRange Range; +}; + +// (Unlinked) ELF object files usually have 0 for every section address, meaning +// we need to compute synthetic addresses in order for "file addresses" from +// different sections to not overlap. This class handles that logic. +class VMAddressProvider { + using VMMap = llvm::IntervalMap>; + + ObjectFile::Type ObjectType; + addr_t NextVMAddress = 0; + VMMap::Allocator Alloc; + VMMap Segments = VMMap(Alloc); + VMMap Sections = VMMap(Alloc); + lldb_private::Log *Log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES); + + VMRange GetVMRange(const ELFSectionHeader &H) { + addr_t Address = H.sh_addr; + addr_t Size = H.sh_flags & SHF_ALLOC ? H.sh_size : 0; + if (ObjectType == ObjectFile::Type::eTypeObjectFile && Segments.empty() && (H.sh_flags & SHF_ALLOC)) { + NextVMAddress = + llvm::alignTo(NextVMAddress, std::max(H.sh_addralign, 1)); + Address = NextVMAddress; + NextVMAddress += Size; + } + return VMRange(Address, Size); + } + +public: + VMAddressProvider(ObjectFile::Type Type) : ObjectType(Type) {} + + llvm::Optional GetAddressInfo(const ELFProgramHeader &H) { + if (H.p_memsz == 0) { + LLDB_LOG(Log, + "Ignoring zero-sized PT_LOAD segment. Corrupt object file?"); + return llvm::None; + } + + if (Segments.overlaps(H.p_vaddr, H.p_vaddr + H.p_memsz)) { + LLDB_LOG(Log, + "Ignoring overlapping PT_LOAD segment. Corrupt object file?"); + return llvm::None; + } + return VMRange(H.p_vaddr, H.p_memsz); + } + + llvm::Optional GetAddressInfo(const ELFSectionHeader &H) { + VMRange Range = GetVMRange(H); + SectionSP Segment; + auto It = Segments.find(Range.GetRangeBase()); + if ((H.sh_flags & SHF_ALLOC) && It.valid()) { + addr_t MaxSize; + if (It.start() <= Range.GetRangeBase()) { + MaxSize = It.stop() - Range.GetRangeBase(); + Segment = *It; + } else + MaxSize = It.start() - Range.GetRangeBase(); + if (Range.GetByteSize() > MaxSize) { + LLDB_LOG(Log, "Shortening section crossing segment boundaries. " + "Corrupt object file?"); + Range.SetByteSize(MaxSize); + } + } + if (Range.GetByteSize() > 0 && + Sections.overlaps(Range.GetRangeBase(), Range.GetRangeEnd())) { + LLDB_LOG(Log, "Ignoring overlapping section. Corrupt object file?"); + return llvm::None; } + if (Segment) + Range.Slide(-Segment->GetFileAddress()); + return SectionAddressInfo{Segment, Range}; + } + + void AddSegment(const VMRange &Range, SectionSP Seg) { + Segments.insert(Range.GetRangeBase(), Range.GetRangeEnd(), std::move(Seg)); + } + + void AddSection(SectionAddressInfo Info, SectionSP Sect) { + if (Info.Range.GetByteSize() == 0) + return; + if (Info.Segment) + Info.Range.Slide(Info.Segment->GetFileAddress()); + Sections.insert(Info.Range.GetRangeBase(), Info.Range.GetRangeEnd(), + std::move(Sect)); + } +}; +} + +void ObjectFileELF::CreateSections(SectionList &unified_section_list) { + if (m_sections_ap) + return; + + m_sections_ap = llvm::make_unique(); + VMAddressProvider address_provider(CalculateType()); + + size_t LoadID = 0; + for (const auto &EnumPHdr : llvm::enumerate(ProgramHeaders())) { + const ELFProgramHeader &PHdr = EnumPHdr.value(); + if (PHdr.p_type != PT_LOAD) + continue; + + auto InfoOr = address_provider.GetAddressInfo(PHdr); + if (!InfoOr) + continue; + + ConstString Name(("PT_LOAD[" + llvm::Twine(LoadID++) + "]").str()); + uint32_t Log2Align = llvm::Log2_64(std::max(PHdr.p_align, 1)); + SectionSP Segment = std::make_shared
( + GetModule(), this, SegmentID(EnumPHdr.index()), Name, + eSectionTypeContainer, InfoOr->GetRangeBase(), InfoOr->GetByteSize(), + PHdr.p_offset, PHdr.p_filesz, Log2Align, /*flags*/ 0); + Segment->SetPermissions(GetPermissions(PHdr)); + m_sections_ap->AddSection(Segment); + + address_provider.AddSegment(*InfoOr, std::move(Segment)); + } + + ParseSectionHeaders(); + if (m_section_headers.empty()) + return; + + for (SectionHeaderCollIter I = std::next(m_section_headers.begin()); + I != m_section_headers.end(); ++I) { + const ELFSectionHeaderInfo &header = *I; + + ConstString &name = I->section_name; + const uint64_t file_size = + header.sh_type == SHT_NOBITS ? 0 : header.sh_size; + + auto InfoOr = address_provider.GetAddressInfo(header); + if (!InfoOr) + continue; + + SectionType sect_type = GetSectionType(header); + + const uint32_t target_bytes_size = + GetTargetByteSize(sect_type, m_arch_spec); + + elf::elf_xword log2align = + (header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign); + + SectionSP section_sp(new Section( + InfoOr->Segment, GetModule(), // Module to which this section belongs. + this, // ObjectFile to which this section belongs and should + // read section data from. + SectionIndex(I), // Section ID. + name, // Section name. + sect_type, // Section type. + InfoOr->Range.GetRangeBase(), // VM address. + InfoOr->Range.GetByteSize(), // VM size in bytes of this section. + header.sh_offset, // Offset of this section in the file. + file_size, // Size of the section as found in the file. + log2align, // Alignment of the section + header.sh_flags, // Flags for this section. + target_bytes_size)); // Number of host bytes per target byte + + section_sp->SetPermissions(GetPermissions(header)); + section_sp->SetIsThreadSpecific(header.sh_flags & SHF_TLS); + (InfoOr->Segment ? InfoOr->Segment->GetChildren() : *m_sections_ap) + .AddSection(section_sp); + address_provider.AddSection(std::move(*InfoOr), std::move(section_sp)); } // For eTypeDebugInfo files, the Symbol Vendor will take care of updating the @@ -2054,8 +2079,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, bool skip_oatdata_oatexec = file_extension == ConstString(".oat") || file_extension == ConstString(".odex"); - ArchSpec arch; - GetArchitecture(arch); + ArchSpec arch = GetArchitecture(); ModuleSP module_sp(GetModule()); SectionList *module_section_list = module_sp ? module_sp->GetSectionList() : nullptr; @@ -2067,7 +2091,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, unsigned i; for (i = 0; i < num_symbols; ++i) { - if (symbol.Parse(symtab_data, &offset) == false) + if (!symbol.Parse(symtab_data, &offset)) break; const char *symbol_name = strtab_data.PeekCStr(symbol.st_name); @@ -2087,9 +2111,9 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, SectionSP symbol_section_sp; SymbolType symbol_type = eSymbolTypeInvalid; - Elf64_Half section_idx = symbol.st_shndx; + Elf64_Half shndx = symbol.st_shndx; - switch (section_idx) { + switch (shndx) { case SHN_ABS: symbol_type = eSymbolTypeAbsolute; break; @@ -2097,7 +2121,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, symbol_type = eSymbolTypeUndefined; break; default: - symbol_section_sp = section_list->GetSectionAtIndex(section_idx); + symbol_section_sp = section_list->FindSectionByID(shndx); break; } @@ -2266,7 +2290,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // symbols. See above for more details. uint64_t symbol_value = symbol.st_value + symbol_value_offset; - if (symbol_section_sp == nullptr && section_idx == SHN_ABS && + if (symbol_section_sp == nullptr && shndx == SHN_ABS && symbol.st_size != 0) { // We don't have a section for a symbol with non-zero size. Create a new // section for it so the address range covered by the symbol is also @@ -2386,9 +2410,8 @@ unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table, assert(symtab_hdr->sh_type == SHT_SYMTAB || symtab_hdr->sh_type == SHT_DYNSYM); - // sh_link: section header index of associated string table. Section ID's are - // ones based. - user_id_t strtab_id = symtab_hdr->sh_link + 1; + // sh_link: section header index of associated string table. + user_id_t strtab_id = symtab_hdr->sh_link; Section *strtab = section_list->FindSectionByID(strtab_id).get(); if (symtab && strtab) { @@ -2540,7 +2563,7 @@ static unsigned ParsePLTRelocations( unsigned slot_type = hdr->GetRelocationJumpSlotType(); unsigned i; for (i = 0; i < num_relocations; ++i) { - if (rel.Parse(rel_data, &offset) == false) + if (!rel.Parse(rel_data, &offset)) break; if (reloc_type(rel) != slot_type) @@ -2598,10 +2621,6 @@ ObjectFileELF::ParseTrampolineSymbols(Symtab *symbol_table, user_id_t start_id, if (!symtab_id || !plt_id) return 0; - // Section ID's are ones based; - symtab_id++; - plt_id++; - const ELFSectionHeaderInfo *plt_hdr = GetSectionHeaderByIndex(plt_id); if (!plt_hdr) return 0; @@ -2627,7 +2646,7 @@ ObjectFileELF::ParseTrampolineSymbols(Symtab *symbol_table, user_id_t start_id, return 0; // sh_link points to associated string table. - Section *strtab = section_list->FindSectionByID(sym_hdr->sh_link + 1).get(); + Section *strtab = section_list->FindSectionByID(sym_hdr->sh_link).get(); if (!strtab) return 0; @@ -2673,7 +2692,7 @@ unsigned ObjectFileELF::ApplyRelocations( } for (unsigned i = 0; i < num_relocations; ++i) { - if (rel.Parse(rel_data, &offset) == false) + if (!rel.Parse(rel_data, &offset)) break; Symbol *symbol = NULL; @@ -2695,6 +2714,7 @@ unsigned ObjectFileELF::ApplyRelocations( } } else { switch (reloc_type(rel)) { + case R_AARCH64_ABS64: case R_X86_64_64: { symbol = symtab->FindSymbolByID(reloc_symbol(rel)); if (symbol) { @@ -2703,26 +2723,34 @@ unsigned ObjectFileELF::ApplyRelocations( uint64_t *dst = reinterpret_cast( data_buffer_sp->GetBytes() + rel_section->GetFileOffset() + ELFRelocation::RelocOffset64(rel)); - *dst = value + ELFRelocation::RelocAddend64(rel); + uint64_t val_offset = value + ELFRelocation::RelocAddend64(rel); + memcpy(dst, &val_offset, sizeof(uint64_t)); } break; } case R_X86_64_32: - case R_X86_64_32S: { + case R_X86_64_32S: + case R_AARCH64_ABS32: { symbol = symtab->FindSymbolByID(reloc_symbol(rel)); if (symbol) { addr_t value = symbol->GetAddressRef().GetFileAddress(); value += ELFRelocation::RelocAddend32(rel); - assert( - (reloc_type(rel) == R_X86_64_32 && (value <= UINT32_MAX)) || + if ((reloc_type(rel) == R_X86_64_32 && (value > UINT32_MAX)) || (reloc_type(rel) == R_X86_64_32S && - ((int64_t)value <= INT32_MAX && (int64_t)value >= INT32_MIN))); + ((int64_t)value > INT32_MAX && (int64_t)value < INT32_MIN)) || + (reloc_type(rel) == R_AARCH64_ABS32 && + ((int64_t)value > INT32_MAX && (int64_t)value < INT32_MIN))) { + Log *log = + lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES); + log->Printf("Failed to apply debug info relocations"); + break; + } uint32_t truncated_addr = (value & 0xFFFFFFFF); DataBufferSP &data_buffer_sp = debug_data.GetSharedDataBuffer(); uint32_t *dst = reinterpret_cast( data_buffer_sp->GetBytes() + rel_section->GetFileOffset() + ELFRelocation::RelocOffset32(rel)); - *dst = truncated_addr; + memcpy(dst, &truncated_addr, sizeof(uint32_t)); } break; } @@ -2746,9 +2774,8 @@ unsigned ObjectFileELF::RelocateDebugSections(const ELFSectionHeader *rel_hdr, if (!section_list) return 0; - // Section ID's are ones based. - user_id_t symtab_id = rel_hdr->sh_link + 1; - user_id_t debug_id = rel_hdr->sh_info + 1; + user_id_t symtab_id = rel_hdr->sh_link; + user_id_t debug_id = rel_hdr->sh_info; const ELFSectionHeader *symtab_hdr = GetSectionHeaderByIndex(symtab_id); if (!symtab_hdr) @@ -2986,8 +3013,7 @@ void ObjectFileELF::Dump(Stream *s) { s->Indent(); s->PutCString("ObjectFileELF"); - ArchSpec header_arch; - GetArchitecture(header_arch); + ArchSpec header_arch = GetArchitecture(); *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n"; @@ -3164,11 +3190,9 @@ void ObjectFileELF::DumpELFProgramHeaders(Stream *s) { s->PutCString("==== --------------- -------- -------- -------- " "-------- -------- ------------------------- --------\n"); - uint32_t idx = 0; - for (ProgramHeaderCollConstIter I = m_program_headers.begin(); - I != m_program_headers.end(); ++I, ++idx) { - s->Printf("[%2u] ", idx); - ObjectFileELF::DumpELFProgramHeader(s, *I); + for (const auto &H : llvm::enumerate(m_program_headers)) { + s->Format("[{0,2}] ", H.index()); + ObjectFileELF::DumpELFProgramHeader(s, H.value()); s->EOL(); } } @@ -3275,9 +3299,9 @@ void ObjectFileELF::DumpDependentModules(lldb_private::Stream *s) { } } -bool ObjectFileELF::GetArchitecture(ArchSpec &arch) { +ArchSpec ObjectFileELF::GetArchitecture() { if (!ParseHeader()) - return false; + return ArchSpec(); if (m_section_headers.empty()) { // Allow elf notes to be parsed which may affect the detected architecture. @@ -3288,23 +3312,17 @@ bool ObjectFileELF::GetArchitecture(ArchSpec &arch) { m_arch_spec.TripleOSIsUnspecifiedUnknown()) { // Core files don't have section headers yet they have PT_NOTE program // headers that might shed more light on the architecture - if (ParseProgramHeaders()) { - for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) { - const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i); - if (header && header->p_type == PT_NOTE && header->p_offset != 0 && - header->p_filesz > 0) { - DataExtractor data; - if (data.SetData(m_data, header->p_offset, header->p_filesz) == - header->p_filesz) { - lldb_private::UUID uuid; - RefineModuleDetailsFromNote(data, m_arch_spec, uuid); - } - } + for (const elf::ELFProgramHeader &H : ProgramHeaders()) { + if (H.p_type != PT_NOTE || H.p_offset == 0 || H.p_filesz == 0) + continue; + DataExtractor data; + if (data.SetData(m_data, H.p_offset, H.p_filesz) == H.p_filesz) { + UUID uuid; + RefineModuleDetailsFromNote(data, m_arch_spec, uuid); } } } - arch = m_arch_spec; - return true; + return m_arch_spec; } ObjectFile::Type ObjectFileELF::CalculateType() { @@ -3396,8 +3414,6 @@ size_t ObjectFileELF::ReadSectionData(Section *section, if (section->GetObjectFile() != this) return section->GetObjectFile()->ReadSectionData(section, section_data); - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES); - size_t result = ObjectFile::ReadSectionData(section, section_data); if (result == 0 || !section->Test(SHF_COMPRESSED)) return result; @@ -3408,29 +3424,43 @@ size_t ObjectFileELF::ReadSectionData(Section *section, size_t(section_data.GetByteSize())}, GetByteOrder() == eByteOrderLittle, GetAddressByteSize() == 8); if (!Decompressor) { - LLDB_LOG_ERROR(log, Decompressor.takeError(), - "Unable to initialize decompressor for section {0}", - section->GetName()); - return result; + GetModule()->ReportWarning( + "Unable to initialize decompressor for section '%s': %s", + section->GetName().GetCString(), + llvm::toString(Decompressor.takeError()).c_str()); + section_data.Clear(); + return 0; } + auto buffer_sp = std::make_shared(Decompressor->getDecompressedSize(), 0); - if (auto Error = Decompressor->decompress( + if (auto error = Decompressor->decompress( {reinterpret_cast(buffer_sp->GetBytes()), size_t(buffer_sp->GetByteSize())})) { - LLDB_LOG_ERROR(log, std::move(Error), "Decompression of section {0} failed", - section->GetName()); - return result; + GetModule()->ReportWarning( + "Decompression of section '%s' failed: %s", + section->GetName().GetCString(), + llvm::toString(std::move(error)).c_str()); + section_data.Clear(); + return 0; } + section_data.SetData(buffer_sp); return buffer_sp->GetByteSize(); } +llvm::ArrayRef ObjectFileELF::ProgramHeaders() { + ParseProgramHeaders(); + return m_program_headers; +} + +DataExtractor ObjectFileELF::GetSegmentData(const ELFProgramHeader &H) { + return DataExtractor(m_data, H.p_offset, H.p_filesz); +} + bool ObjectFileELF::AnySegmentHasPhysicalAddress() { - size_t header_count = ParseProgramHeaders(); - for (size_t i = 1; i <= header_count; ++i) { - auto header = GetProgramHeaderByIndex(i); - if (header->p_paddr != 0) + for (const ELFProgramHeader &H : ProgramHeaders()) { + if (H.p_paddr != 0) return true; } return false; @@ -3441,19 +3471,17 @@ ObjectFileELF::GetLoadableData(Target &target) { // Create a list of loadable data from loadable segments, using physical // addresses if they aren't all null std::vector loadables; - size_t header_count = ParseProgramHeaders(); bool should_use_paddr = AnySegmentHasPhysicalAddress(); - for (size_t i = 1; i <= header_count; ++i) { + for (const ELFProgramHeader &H : ProgramHeaders()) { LoadableData loadable; - auto header = GetProgramHeaderByIndex(i); - if (header->p_type != llvm::ELF::PT_LOAD) + if (H.p_type != llvm::ELF::PT_LOAD) continue; - loadable.Dest = should_use_paddr ? header->p_paddr : header->p_vaddr; + loadable.Dest = should_use_paddr ? H.p_paddr : H.p_vaddr; if (loadable.Dest == LLDB_INVALID_ADDRESS) continue; - if (header->p_filesz == 0) + if (H.p_filesz == 0) continue; - auto segment_data = GetSegmentDataByIndex(i); + auto segment_data = GetSegmentData(H); loadable.Contents = llvm::ArrayRef(segment_data.GetDataStart(), segment_data.GetByteSize()); loadables.push_back(loadable); diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h index 2664595fd81d..570a8baa0876 100644 --- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -1,19 +1,16 @@ //===-- ObjectFileELF.h --------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjectFileELF_h_ #define liblldb_ObjectFileELF_h_ -// C Includes #include -// C++ Includes #include #include "lldb/Symbol/ObjectFile.h" @@ -123,7 +120,7 @@ class ObjectFileELF : public lldb_private::ObjectFile { void Dump(lldb_private::Stream *s) override; - bool GetArchitecture(lldb_private::ArchSpec &arch) override; + lldb_private::ArchSpec GetArchitecture() override; bool GetUUID(lldb_private::UUID *uuid) override; @@ -136,6 +133,8 @@ class ObjectFileELF : public lldb_private::ObjectFile { lldb_private::Address GetEntryPointAddress() override; + lldb_private::Address GetBaseAddress() override; + ObjectFile::Type CalculateType() override; ObjectFile::Strata CalculateStrata() override; @@ -147,14 +146,8 @@ class ObjectFileELF : public lldb_private::ObjectFile { size_t ReadSectionData(lldb_private::Section *section, lldb_private::DataExtractor §ion_data) override; - // Returns number of program headers found in the ELF file. - size_t GetProgramHeaderCount(); - - // Returns the program header with the given index. - const elf::ELFProgramHeader *GetProgramHeaderByIndex(lldb::user_id_t id); - - // Returns segment data for the given index. - lldb_private::DataExtractor GetSegmentDataByIndex(lldb::user_id_t id); + llvm::ArrayRef ProgramHeaders(); + lldb_private::DataExtractor GetSegmentData(const elf::ELFProgramHeader &H); llvm::StringRef StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const override; @@ -176,8 +169,6 @@ class ObjectFileELF : public lldb_private::ObjectFile { const lldb::ProcessSP &process_sp, lldb::addr_t header_addr); typedef std::vector ProgramHeaderColl; - typedef ProgramHeaderColl::iterator ProgramHeaderCollIter; - typedef ProgramHeaderColl::const_iterator ProgramHeaderCollConstIter; struct ELFSectionHeaderInfo : public elf::ELFSectionHeader { lldb_private::ConstString section_name; @@ -230,10 +221,10 @@ class ObjectFileELF : public lldb_private::ObjectFile { /// The address class for each symbol in the elf file FileAddressToAddressClassMap m_address_class_map; - /// Returns a 1 based index of the given section header. + /// Returns the index of the given section header. size_t SectionIndex(const SectionHeaderCollIter &I); - /// Returns a 1 based index of the given section header. + /// Returns the index of the given section header. size_t SectionIndex(const SectionHeaderCollConstIter &I) const; // Parses the ELF program headers. @@ -248,14 +239,16 @@ class ObjectFileELF : public lldb_private::ObjectFile { /// Parses all section headers present in this object file and populates /// m_program_headers. This method will compute the header list only once. - /// Returns the number of headers parsed. - size_t ParseProgramHeaders(); + /// Returns true iff the headers have been successfully parsed. + bool ParseProgramHeaders(); /// Parses all section headers present in this object file and populates /// m_section_headers. This method will compute the header list only once. /// Returns the number of headers parsed. size_t ParseSectionHeaders(); + lldb::SectionType GetSectionType(const ELFSectionHeaderInfo &H) const; + static void ParseARMAttributes(lldb_private::DataExtractor &data, uint64_t length, lldb_private::ArchSpec &arch_spec); diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp index af040322ec52..d1e9a5d3d63d 100644 --- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -1,9 +1,8 @@ //===-- ObjectFileJIT.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -153,8 +152,7 @@ void ObjectFileJIT::Dump(Stream *s) { s->Indent(); s->PutCString("ObjectFileJIT"); - ArchSpec arch; - if (GetArchitecture(arch)) + if (ArchSpec arch = GetArchitecture()) *s << ", arch = " << arch.GetArchitectureName(); s->EOL(); @@ -184,17 +182,16 @@ lldb_private::Address ObjectFileJIT::GetEntryPointAddress() { return Address(); } -lldb_private::Address ObjectFileJIT::GetHeaderAddress() { return Address(); } +lldb_private::Address ObjectFileJIT::GetBaseAddress() { return Address(); } ObjectFile::Type ObjectFileJIT::CalculateType() { return eTypeJIT; } ObjectFile::Strata ObjectFileJIT::CalculateStrata() { return eStrataJIT; } -bool ObjectFileJIT::GetArchitecture(ArchSpec &arch) { - ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock()); - if (delegate_sp) - return delegate_sp->GetArchitecture(arch); - return false; +ArchSpec ObjectFileJIT::GetArchitecture() { + if (ObjectFileJITDelegateSP delegate_sp = m_delegate_wp.lock()) + return delegate_sp->GetArchitecture(); + return ArchSpec(); } //------------------------------------------------------------------ @@ -218,7 +215,7 @@ bool ObjectFileJIT::SetLoadAddress(Target &target, lldb::addr_t value, // that size on disk (to avoid __PAGEZERO) and load them SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); if (section_sp && section_sp->GetFileSize() > 0 && - section_sp->IsThreadSpecific() == false) { + !section_sp->IsThreadSpecific()) { if (target.GetSectionLoadList().SetSectionLoadAddress( section_sp, section_sp->GetFileAddress() + value)) ++num_loaded_sections; diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h index c964906a5e8e..2d0b17d6b72c 100644 --- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h +++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h @@ -1,19 +1,14 @@ //===-- ObjectFileJIT.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjectFileJIT_h_ #define liblldb_ObjectFileJIT_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Symbol/ObjectFile.h" @@ -77,7 +72,7 @@ class ObjectFileJIT : public lldb_private::ObjectFile { void Dump(lldb_private::Stream *s) override; - bool GetArchitecture(lldb_private::ArchSpec &arch) override; + lldb_private::ArchSpec GetArchitecture() override; bool GetUUID(lldb_private::UUID *uuid) override; @@ -93,7 +88,7 @@ class ObjectFileJIT : public lldb_private::ObjectFile { lldb_private::Address GetEntryPointAddress() override; - lldb_private::Address GetHeaderAddress() override; + lldb_private::Address GetBaseAddress() override; ObjectFile::Type CalculateType() override; diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 6fcb309ca8d3..f5726b602d1d 100644 --- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1,18 +1,13 @@ //===-- ObjectFileMachO.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "Plugins/Process/Utility/RegisterContextDarwin_arm.h" #include "Plugins/Process/Utility/RegisterContextDarwin_arm64.h" #include "Plugins/Process/Utility/RegisterContextDarwin_i386.h" @@ -23,7 +18,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/Host.h" @@ -42,12 +36,13 @@ #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" -#include "lldb/Utility/SafeMachO.h" +#include "lldb/Host/SafeMachO.h" #include "llvm/Support/MemoryBuffer.h" @@ -920,12 +915,10 @@ size_t ObjectFileMachO::GetModuleSpecifications( spec.SetObjectOffset(file_offset); spec.SetObjectSize(length); - if (GetArchitecture(header, data, data_offset, - spec.GetArchitecture())) { - if (spec.GetArchitecture().IsValid()) { - GetUUID(header, data, data_offset, spec.GetUUID()); - specs.Append(spec); - } + spec.GetArchitecture() = GetArchitecture(header, data, data_offset); + if (spec.GetArchitecture().IsValid()) { + GetUUID(header, data, data_offset, spec.GetUUID()); + specs.Append(spec); } } } @@ -963,6 +956,11 @@ const ConstString &ObjectFileMachO::GetSegmentNameLINKEDIT() { return g_section_name_LINKEDIT; } +const ConstString &ObjectFileMachO::GetSegmentNameDWARF() { + static ConstString g_section_name("__DWARF"); + return g_section_name; +} + const ConstString &ObjectFileMachO::GetSectionNameEHFrame() { static ConstString g_section_name_eh_frame("__eh_frame"); return g_section_name_eh_frame; @@ -1103,9 +1101,7 @@ bool ObjectFileMachO::ParseHeader() { if (can_parse) { m_data.GetU32(&offset, &m_header.cputype, 6); - ArchSpec mach_arch; - - if (GetArchitecture(mach_arch)) { + if (ArchSpec mach_arch = GetArchitecture()) { // Check if the module has a required architecture const ArchSpec &module_arch = module_sp->GetArchitecture(); if (module_arch.IsValid() && !module_arch.IsCompatibleMatch(mach_arch)) @@ -1192,21 +1188,28 @@ AddressClass ObjectFileMachO::GetAddressClass(lldb::addr_t file_addr) { case eSectionTypeDebug: case eSectionTypeDWARFDebugAbbrev: + case eSectionTypeDWARFDebugAbbrevDwo: case eSectionTypeDWARFDebugAddr: case eSectionTypeDWARFDebugAranges: case eSectionTypeDWARFDebugCuIndex: case eSectionTypeDWARFDebugFrame: case eSectionTypeDWARFDebugInfo: + case eSectionTypeDWARFDebugInfoDwo: case eSectionTypeDWARFDebugLine: + case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: case eSectionTypeDWARFDebugPubNames: case eSectionTypeDWARFDebugPubTypes: case eSectionTypeDWARFDebugRanges: + case eSectionTypeDWARFDebugRngLists: case eSectionTypeDWARFDebugStr: + case eSectionTypeDWARFDebugStrDwo: case eSectionTypeDWARFDebugStrOffsets: + case eSectionTypeDWARFDebugStrOffsetsDwo: case eSectionTypeDWARFDebugTypes: case eSectionTypeDWARFAppleNames: case eSectionTypeDWARFAppleTypes: @@ -1302,6 +1305,9 @@ AddressClass ObjectFileMachO::GetAddressClass(lldb::addr_t file_addr) { return AddressClass::eRuntime; case eSymbolTypeASTFile: return AddressClass::eDebug; + + case eSymbolTypeIVarOffset: + break; } } } @@ -1460,6 +1466,7 @@ static lldb::SectionType GetSectionType(uint32_t flags, static ConstString g_sect_name_dwarf_debug_info("__debug_info"); static ConstString g_sect_name_dwarf_debug_line("__debug_line"); static ConstString g_sect_name_dwarf_debug_loc("__debug_loc"); + static ConstString g_sect_name_dwarf_debug_loclists("__debug_loclists"); static ConstString g_sect_name_dwarf_debug_macinfo("__debug_macinfo"); static ConstString g_sect_name_dwarf_debug_names("__debug_names"); static ConstString g_sect_name_dwarf_debug_pubnames("__debug_pubnames"); @@ -1490,6 +1497,8 @@ static lldb::SectionType GetSectionType(uint32_t flags, return eSectionTypeDWARFDebugLine; if (section_name == g_sect_name_dwarf_debug_loc) return eSectionTypeDWARFDebugLoc; + if (section_name == g_sect_name_dwarf_debug_loclists) + return eSectionTypeDWARFDebugLocLists; if (section_name == g_sect_name_dwarf_debug_macinfo) return eSectionTypeDWARFDebugMacInfo; if (section_name == g_sect_name_dwarf_debug_names) @@ -1499,7 +1508,7 @@ static lldb::SectionType GetSectionType(uint32_t flags, if (section_name == g_sect_name_dwarf_debug_pubtypes) return eSectionTypeDWARFDebugPubTypes; if (section_name == g_sect_name_dwarf_debug_ranges) - return eSectionTypeDWARFDebugRanges; + return eSectionTypeDWARFDebugRanges; if (section_name == g_sect_name_dwarf_debug_str) return eSectionTypeDWARFDebugStr; if (section_name == g_sect_name_dwarf_debug_types) @@ -1676,7 +1685,7 @@ void ObjectFileMachO::ProcessSegmentCommand(const load_command &load_cmd_, } else if (unified_section_sp) { if (is_dsym && unified_section_sp->GetFileAddress() != load_cmd.vmaddr) { // Check to see if the module was read from memory? - if (module_sp->GetObjectFile()->GetHeaderAddress().IsValid()) { + if (module_sp->GetObjectFile()->GetBaseAddress().IsValid()) { // We have a module that is in memory and needs to have its file // address adjusted. We need to do this because when we load a file // from memory, its addresses will be slid already, yet the addresses @@ -2303,7 +2312,7 @@ size_t ObjectFileMachO::ParseSymtab() { uint32_t name_offset = cmd_offset + m_data.GetU32(&offset); const char *path = m_data.PeekCStr(name_offset); if (path) { - FileSpec file_spec(path, false); + FileSpec file_spec(path); // Strip the path if there is @rpath, @executable, etc so we just use // the basename if (path[0] == '@') @@ -2758,7 +2767,7 @@ size_t ObjectFileMachO::ParseSymtab() { // shared cache UUID in the development or non-development shared caches // on disk. if (process_shared_cache_uuid.IsValid()) { - if (dsc_development_filespec.Exists()) { + if (FileSystem::Instance().Exists(dsc_development_filespec)) { UUID dsc_development_uuid = GetSharedCacheUUID( dsc_development_filespec, byte_order, addr_byte_size); if (dsc_development_uuid.IsValid() && @@ -2767,7 +2776,8 @@ size_t ObjectFileMachO::ParseSymtab() { dsc_uuid = dsc_development_uuid; } } - if (!dsc_uuid.IsValid() && dsc_nondevelopment_filespec.Exists()) { + if (!dsc_uuid.IsValid() && + FileSystem::Instance().Exists(dsc_nondevelopment_filespec)) { UUID dsc_nondevelopment_uuid = GetSharedCacheUUID( dsc_nondevelopment_filespec, byte_order, addr_byte_size); if (dsc_nondevelopment_uuid.IsValid() && @@ -2780,8 +2790,8 @@ size_t ObjectFileMachO::ParseSymtab() { // Failing a UUID match, prefer the development dyld_shared cache if both // are present. - if (!dsc_filespec.Exists()) { - if (dsc_development_filespec.Exists()) { + if (!FileSystem::Instance().Exists(dsc_filespec)) { + if (FileSystem::Instance().Exists(dsc_development_filespec)) { dsc_filespec = dsc_development_filespec; } else { dsc_filespec = dsc_nondevelopment_filespec; @@ -3189,11 +3199,11 @@ size_t ObjectFileMachO::ParseSymtab() { // file so you end up with a path that looks // like "/tmp/src//tmp/src/" FileSpec so_dir(so_path, false); - if (!so_dir.Exists()) { + if (!FileSystem::Instance().Exists(so_dir)) { so_dir.SetFile( &full_so_path[double_slash_pos + 1], false); - if (so_dir.Exists()) { + if (FileSystem::Instance().Exists(so_dir)) { // Trim off the incorrect path full_so_path.erase(0, double_slash_pos + 1); @@ -4145,11 +4155,11 @@ size_t ObjectFileMachO::ParseSymtab() { // string in the DW_AT_comp_dir, and the second is the // directory for the source file so you end up with a path // that looks like "/tmp/src//tmp/src/" - FileSpec so_dir(so_path, false); - if (!so_dir.Exists()) { - so_dir.SetFile(&full_so_path[double_slash_pos + 1], false, + FileSpec so_dir(so_path); + if (!FileSystem::Instance().Exists(so_dir)) { + so_dir.SetFile(&full_so_path[double_slash_pos + 1], FileSpec::Style::native); - if (so_dir.Exists()) { + if (FileSystem::Instance().Exists(so_dir)) { // Trim off the incorrect path full_so_path.erase(0, double_slash_pos + 1); } @@ -4610,7 +4620,7 @@ size_t ObjectFileMachO::ParseSymtab() { symbol_value -= section_file_addr; } - if (is_debug == false) { + if (!is_debug) { if (type == eSymbolTypeCode) { // See if we can find a N_FUN entry for any code symbols. If we // do find a match, and the name matches, then we can merge the @@ -4809,7 +4819,7 @@ size_t ObjectFileMachO::ParseSymtab() { if (function_starts_count > 0) { uint32_t num_synthetic_function_symbols = 0; for (i = 0; i < function_starts_count; ++i) { - if (function_starts.GetEntryRef(i).data == false) + if (!function_starts.GetEntryRef(i).data) ++num_synthetic_function_symbols; } @@ -4821,7 +4831,7 @@ size_t ObjectFileMachO::ParseSymtab() { for (i = 0; i < function_starts_count; ++i) { const FunctionStarts::Entry *func_start_entry = function_starts.GetEntryAtIndex(i); - if (func_start_entry->data == false) { + if (!func_start_entry->data) { addr_t symbol_file_addr = func_start_entry->addr; uint32_t symbol_flags = 0; if (is_arm) { @@ -5026,8 +5036,7 @@ void ObjectFileMachO::Dump(Stream *s) { else s->PutCString("ObjectFileMachO32"); - ArchSpec header_arch; - GetArchitecture(header_arch); + ArchSpec header_arch = GetArchitecture(); *s << ", file = '" << m_file << "', triple = " << header_arch.GetTriple().getTriple() << "\n"; @@ -5150,10 +5159,11 @@ namespace { }; } // namespace -bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header, - const lldb_private::DataExtractor &data, - lldb::offset_t lc_offset, - ArchSpec &arch) { +ArchSpec +ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header, + const lldb_private::DataExtractor &data, + lldb::offset_t lc_offset) { + ArchSpec arch; arch.SetArchitecture(eArchTypeMachO, header.cputype, header.cpusubtype); if (arch.IsValid()) { @@ -5178,7 +5188,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header, triple.setVendor(llvm::Triple::UnknownVendor); triple.setVendorName(llvm::StringRef()); } - return true; + return arch; } else { struct load_command load_cmd; llvm::SmallString<16> os_name; @@ -5207,7 +5217,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header, os << GetOSName(load_cmd.cmd) << min_os.major_version << '.' << min_os.minor_version << '.' << min_os.patch_version; triple.setOSName(os.str()); - return true; + return arch; } default: break; @@ -5243,7 +5253,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header, triple.setOSName(os.str()); if (!os_env.environment.empty()) triple.setEnvironmentName(os_env.environment); - return true; + return arch; } } while (0); offset = cmd_offset + load_cmd.cmdsize; @@ -5258,7 +5268,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header, } } } - return arch.IsValid(); + return arch; } bool ObjectFileMachO::GetUUID(lldb_private::UUID *uuid) { @@ -5281,9 +5291,6 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) { std::vector rpath_paths; std::vector rpath_relative_paths; std::vector at_exec_relative_paths; - const bool resolve_path = false; // Don't resolve the dependent file paths - // since they may not reside on this - // system uint32_t i; for (i = 0; i < m_header.ncmds; ++i) { const uint32_t cmd_offset = offset; @@ -5312,7 +5319,7 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) { at_exec_relative_paths.push_back(path + strlen("@executable_path")); } else { - FileSpec file_spec(path, resolve_path); + FileSpec file_spec(path); if (files.AppendIfUnique(file_spec)) count++; } @@ -5327,8 +5334,8 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) { } FileSpec this_file_spec(m_file); - this_file_spec.ResolvePath(); - + FileSystem::Instance().Resolve(this_file_spec); + if (!rpath_paths.empty()) { // Fixup all LC_RPATH values to be absolute paths std::string loader_path("@loader_path"); @@ -5349,8 +5356,10 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) { path += rpath_relative_path; // It is OK to resolve this path because we must find a file on disk // for us to accept it anyway if it is rpath relative. - FileSpec file_spec(path, true); - if (file_spec.Exists() && files.AppendIfUnique(file_spec)) { + FileSpec file_spec(path); + FileSystem::Instance().Resolve(file_spec); + if (FileSystem::Instance().Exists(file_spec) && + files.AppendIfUnique(file_spec)) { count++; break; } @@ -5367,7 +5376,8 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) { for (const auto &at_exec_relative_path : at_exec_relative_paths) { FileSpec file_spec = exec_dir.CopyByAppendingPathComponent(at_exec_relative_path); - if (file_spec.Exists() && files.AppendIfUnique(file_spec)) + if (FileSystem::Instance().Exists(file_spec) && + files.AppendIfUnique(file_spec)) count++; } } @@ -5532,7 +5542,7 @@ lldb_private::Address ObjectFileMachO::GetEntryPointAddress() { return m_entry_point_address; } -lldb_private::Address ObjectFileMachO::GetHeaderAddress() { +lldb_private::Address ObjectFileMachO::GetBaseAddress() { lldb_private::Address header_addr; SectionList *section_list = GetSectionList(); if (section_list) { @@ -5880,14 +5890,16 @@ llvm::VersionTuple ObjectFileMachO::GetVersion() { return llvm::VersionTuple(); } -bool ObjectFileMachO::GetArchitecture(ArchSpec &arch) { +ArchSpec ObjectFileMachO::GetArchitecture() { ModuleSP module_sp(GetModule()); + ArchSpec arch; if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); + return GetArchitecture(m_header, m_data, - MachHeaderSizeFromMagic(m_header.magic), arch); + MachHeaderSizeFromMagic(m_header.magic)); } - return false; + return arch; } void ObjectFileMachO::GetProcessSharedCacheUUID(Process *process, addr_t &base_addr, UUID &uuid) { @@ -6054,7 +6066,7 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions, if (m_sdk_versions.empty()) { lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); bool success = false; - for (uint32_t i = 0; success == false && i < m_header.ncmds; ++i) { + for (uint32_t i = 0; !success && i < m_header.ncmds; ++i) { const lldb::offset_t load_cmd_offset = offset; version_min_command lc; @@ -6083,47 +6095,46 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions, offset = load_cmd_offset + lc.cmdsize; } - if (success == false) - { - offset = MachHeaderSizeFromMagic(m_header.magic); - for (uint32_t i = 0; success == false && i < m_header.ncmds; ++i) - { - const lldb::offset_t load_cmd_offset = offset; + if (!success) { + offset = MachHeaderSizeFromMagic(m_header.magic); + for (uint32_t i = 0; !success && i < m_header.ncmds; ++i) { + const lldb::offset_t load_cmd_offset = offset; - version_min_command lc; - if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL) - break; - if (lc.cmd == llvm::MachO::LC_BUILD_VERSION) - { - // struct build_version_command { - // uint32_t cmd; /* LC_BUILD_VERSION */ - // uint32_t cmdsize; /* sizeof(struct build_version_command) plus */ - // /* ntools * sizeof(struct build_tool_version) */ - // uint32_t platform; /* platform */ - // uint32_t minos; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */ - // uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */ - // uint32_t ntools; /* number of tool entries following this */ - // }; - - offset += 4; // skip platform - uint32_t minos = m_data.GetU32(&offset); - - const uint32_t xxxx = minos >> 16; - const uint32_t yy = (minos >> 8) & 0xffu; - const uint32_t zz = minos & 0xffu; - if (xxxx) - { - m_sdk_versions.push_back (xxxx); - m_sdk_versions.push_back (yy); - m_sdk_versions.push_back (zz); - success = true; - } - } - offset = load_cmd_offset + lc.cmdsize; + version_min_command lc; + if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL) + break; + if (lc.cmd == llvm::MachO::LC_BUILD_VERSION) { + // struct build_version_command { + // uint32_t cmd; /* LC_BUILD_VERSION */ + // uint32_t cmdsize; /* sizeof(struct + // build_version_command) plus */ + // /* ntools * sizeof(struct + // build_tool_version) */ + // uint32_t platform; /* platform */ + // uint32_t minos; /* X.Y.Z is encoded in nibbles + // xxxx.yy.zz */ uint32_t sdk; /* X.Y.Z is encoded + // in nibbles xxxx.yy.zz */ uint32_t ntools; /* number + // of tool entries following this */ + // }; + + offset += 4; // skip platform + uint32_t minos = m_data.GetU32(&offset); + + const uint32_t xxxx = minos >> 16; + const uint32_t yy = (minos >> 8) & 0xffu; + const uint32_t zz = minos & 0xffu; + if (xxxx) { + m_sdk_versions.push_back(xxxx); + m_sdk_versions.push_back(yy); + m_sdk_versions.push_back(zz); + success = true; + } } + offset = load_cmd_offset + lc.cmdsize; + } } - if (success == false) { + if (!success) { // Push an invalid value so we don't try to find // the version # again on the next call to this // method. @@ -6173,52 +6184,52 @@ Section *ObjectFileMachO::GetMachHeaderSection() { // the mach-o file which can be subtracted from the vmaddr of the other // segments found in memory and added to the load address ModuleSP module_sp = GetModule(); - if (module_sp) { - SectionList *section_list = GetSectionList(); - if (section_list) { - lldb::addr_t mach_base_file_addr = LLDB_INVALID_ADDRESS; - const size_t num_sections = section_list->GetSize(); - - for (size_t sect_idx = 0; sect_idx < num_sections && - mach_base_file_addr == LLDB_INVALID_ADDRESS; - ++sect_idx) { - Section *section = section_list->GetSectionAtIndex(sect_idx).get(); - if (section && section->GetFileSize() > 0 && - section->GetFileOffset() == 0 && - section->IsThreadSpecific() == false && - module_sp.get() == section->GetModule().get()) { - return section; - } - } - } + if (!module_sp) + return nullptr; + SectionList *section_list = GetSectionList(); + if (!section_list) + return nullptr; + const size_t num_sections = section_list->GetSize(); + for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) { + Section *section = section_list->GetSectionAtIndex(sect_idx).get(); + if (section->GetFileOffset() == 0 && SectionIsLoadable(section)) + return section; } return nullptr; } +bool ObjectFileMachO::SectionIsLoadable(const Section *section) { + if (!section) + return false; + const bool is_dsym = (m_header.filetype == MH_DSYM); + if (section->GetFileSize() == 0 && !is_dsym) + return false; + if (section->IsThreadSpecific()) + return false; + if (GetModule().get() != section->GetModule().get()) + return false; + // Be careful with __LINKEDIT and __DWARF segments + if (section->GetName() == GetSegmentNameLINKEDIT() || + section->GetName() == GetSegmentNameDWARF()) { + // Only map __LINKEDIT and __DWARF if we have an in memory image and + // this isn't a kernel binary like a kext or mach_kernel. + const bool is_memory_image = (bool)m_process_wp.lock(); + const Strata strata = GetStrata(); + if (is_memory_image == false || strata == eStrataKernel) + return false; + } + return true; +} + lldb::addr_t ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage( - lldb::addr_t mach_header_load_address, const Section *mach_header_section, + lldb::addr_t header_load_address, const Section *header_section, const Section *section) { ModuleSP module_sp = GetModule(); - if (module_sp && mach_header_section && section && - mach_header_load_address != LLDB_INVALID_ADDRESS) { - lldb::addr_t mach_header_file_addr = mach_header_section->GetFileAddress(); - if (mach_header_file_addr != LLDB_INVALID_ADDRESS) { - if (section && section->GetFileSize() > 0 && - section->IsThreadSpecific() == false && - module_sp.get() == section->GetModule().get()) { - // Ignore __LINKEDIT and __DWARF segments - if (section->GetName() == GetSegmentNameLINKEDIT()) { - // Only map __LINKEDIT if we have an in memory image and this isn't a - // kernel binary like a kext or mach_kernel. - const bool is_memory_image = (bool)m_process_wp.lock(); - const Strata strata = GetStrata(); - if (is_memory_image == false || strata == eStrataKernel) - return LLDB_INVALID_ADDRESS; - } - return section->GetFileAddress() - mach_header_file_addr + - mach_header_load_address; - } - } + if (module_sp && header_section && section && + header_load_address != LLDB_INVALID_ADDRESS) { + lldb::addr_t file_addr = header_section->GetFileAddress(); + if (file_addr != LLDB_INVALID_ADDRESS && SectionIsLoadable(section)) + return section->GetFileAddress() - file_addr + header_load_address; } return LLDB_INVALID_ADDRESS; } @@ -6238,22 +6249,10 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value, // Iterate through the object file sections to find all of the // sections that size on disk (to avoid __PAGEZERO) and load them SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); - if (section_sp && section_sp->GetFileSize() > 0 && - section_sp->IsThreadSpecific() == false && - module_sp.get() == section_sp->GetModule().get()) { - // Ignore __LINKEDIT and __DWARF segments - if (section_sp->GetName() == GetSegmentNameLINKEDIT()) { - // Only map __LINKEDIT if we have an in memory image and this - // isn't a kernel binary like a kext or mach_kernel. - const bool is_memory_image = (bool)m_process_wp.lock(); - const Strata strata = GetStrata(); - if (is_memory_image == false || strata == eStrataKernel) - continue; - } + if (SectionIsLoadable(section_sp.get())) if (target.GetSectionLoadList().SetSectionLoadAddress( section_sp, section_sp->GetFileAddress() + value)) ++num_loaded_sections; - } } } else { // "value" is the new base address of the mach_header, adjust each @@ -6521,10 +6520,10 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, File core_file; std::string core_file_path(outfile.GetPath()); - error = core_file.Open(core_file_path.c_str(), - File::eOpenOptionWrite | - File::eOpenOptionTruncate | - File::eOpenOptionCanCreate); + error = FileSystem::Instance().Open(core_file, outfile, + File::eOpenOptionWrite | + File::eOpenOptionTruncate | + File::eOpenOptionCanCreate); if (error.Success()) { // Read 1 page at a time uint8_t bytes[0x1000]; diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h index be64518064b5..29ee204d6eef 100644 --- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -1,25 +1,20 @@ //===-- ObjectFileMachO.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjectFileMachO_h_ #define liblldb_ObjectFileMachO_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Core/RangeMap.h" +#include "lldb/Host/SafeMachO.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/UUID.h" //---------------------------------------------------------------------- @@ -96,7 +91,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile { void Dump(lldb_private::Stream *s) override; - bool GetArchitecture(lldb_private::ArchSpec &arch) override; + lldb_private::ArchSpec GetArchitecture() override; bool GetUUID(lldb_private::UUID *uuid) override; @@ -108,7 +103,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile { lldb_private::Address GetEntryPointAddress() override; - lldb_private::Address GetHeaderAddress() override; + lldb_private::Address GetBaseAddress() override; uint32_t GetNumThreadContexts() override; @@ -151,10 +146,10 @@ class ObjectFileMachO : public lldb_private::ObjectFile { lldb::offset_t lc_offset, // Offset to the first load command lldb_private::UUID &uuid); - static bool GetArchitecture(const llvm::MachO::mach_header &header, - const lldb_private::DataExtractor &data, - lldb::offset_t lc_offset, - lldb_private::ArchSpec &arch); + static lldb_private::ArchSpec + GetArchitecture(const llvm::MachO::mach_header &header, + const lldb_private::DataExtractor &data, + lldb::offset_t lc_offset); // Intended for same-host arm device debugging where lldb needs to // detect libraries in the shared cache and augment the nlist entries @@ -196,6 +191,8 @@ class ObjectFileMachO : public lldb_private::ObjectFile { void SanitizeSegmentCommand(llvm::MachO::segment_command_64 &seg_cmd, uint32_t cmd_idx); + bool SectionIsLoadable(const lldb_private::Section *section); + llvm::MachO::mach_header m_header; static const lldb_private::ConstString &GetSegmentNameTEXT(); static const lldb_private::ConstString &GetSegmentNameDATA(); @@ -203,6 +200,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile { static const lldb_private::ConstString &GetSegmentNameDATA_CONST(); static const lldb_private::ConstString &GetSegmentNameOBJC(); static const lldb_private::ConstString &GetSegmentNameLINKEDIT(); + static const lldb_private::ConstString &GetSegmentNameDWARF(); static const lldb_private::ConstString &GetSectionNameEHFrame(); llvm::MachO::dysymtab_command m_dysymtab; diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 07df15b7c515..f3e280689023 100644 --- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -1,9 +1,8 @@ //===-- ObjectFilePECOFF.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -23,11 +22,14 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" #include "llvm/BinaryFormat/COFF.h" +#include "llvm/Object/COFFImportFile.h" +#include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #define IMAGE_DOS_SIGNATURE 0x5A4D // MZ @@ -86,6 +88,10 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp, if (!objfile_ap || !objfile_ap->ParseHeader()) return nullptr; + // Cache coff binary. + if (!objfile_ap->CreateBinary()) + return nullptr; + return objfile_ap.release(); } @@ -131,9 +137,7 @@ size_t ObjectFilePECOFF::GetModuleSpecifications( specs.Append(ModuleSpec(file, spec)); spec.SetTriple("i686-pc-windows"); specs.Append(ModuleSpec(file, spec)); - } - else if (coff_header.machine == MachineArmNt) - { + } else if (coff_header.machine == MachineArmNt) { spec.SetTriple("arm-pc-windows"); specs.Append(ModuleSpec(file, spec)); } @@ -168,6 +172,40 @@ lldb::SymbolType ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type) { return lldb::eSymbolTypeInvalid; } +bool ObjectFilePECOFF::CreateBinary() { + if (m_owningbin) + return true; + + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); + + auto binary = llvm::object::createBinary(m_file.GetPath()); + if (!binary) { + if (log) + log->Printf("ObjectFilePECOFF::CreateBinary() - failed to create binary " + "for file (%s): %s", + m_file ? m_file.GetPath().c_str() : "", + errorToErrorCode(binary.takeError()).message().c_str()); + return false; + } + + // Make sure we only handle COFF format. + if (!binary->getBinary()->isCOFF() && + !binary->getBinary()->isCOFFImportFile()) + return false; + + m_owningbin = OWNBINType(std::move(*binary)); + if (log) + log->Printf("%p ObjectFilePECOFF::CreateBinary() module = %p (%s), file = " + "%s, binary = %p (Bin = %p)", + static_cast(this), + static_cast(GetModule().get()), + GetModule()->GetSpecificationDescription().c_str(), + m_file ? m_file.GetPath().c_str() : "", + static_cast(m_owningbin.getPointer()), + static_cast(m_owningbin->getBinary())); + return true; +} + ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp, DataBufferSP &data_sp, lldb::offset_t data_offset, @@ -176,7 +214,7 @@ ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp, lldb::offset_t length) : ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset), m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(), - m_entry_point_address() { + m_entry_point_address(), m_deps_filespec(), m_owningbin() { ::memset(&m_dos_header, 0, sizeof(m_dos_header)); ::memset(&m_coff_header, 0, sizeof(m_coff_header)); ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt)); @@ -188,7 +226,7 @@ ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp, addr_t header_addr) : ObjectFile(module_sp, process_sp, header_addr, header_data_sp), m_dos_header(), m_coff_header(), m_coff_header_opt(), m_sect_headers(), - m_entry_point_address() { + m_entry_point_address(), m_deps_filespec(), m_owningbin() { ::memset(&m_dos_header, 0, sizeof(m_dos_header)); ::memset(&m_coff_header, 0, sizeof(m_coff_header)); ::memset(&m_coff_header_opt, 0, sizeof(m_coff_header_opt)); @@ -431,7 +469,7 @@ bool ObjectFilePECOFF::ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr) { DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) { if (m_file) { - // A bit of a hack, but we intend to write to this buffer, so we can't + // A bit of a hack, but we intend to write to this buffer, so we can't // mmap it. auto buffer_sp = MapFileData(m_file, size, offset); return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()); @@ -488,25 +526,23 @@ bool ObjectFilePECOFF::ParseSectionHeaders( } } - return m_sect_headers.empty() == false; + return !m_sect_headers.empty(); } -bool ObjectFilePECOFF::GetSectionName(std::string §_name, - const section_header_t §) { - if (sect.name[0] == '/') { - lldb::offset_t stroff = strtoul(§.name[1], NULL, 10); +llvm::StringRef ObjectFilePECOFF::GetSectionName(const section_header_t §) { + llvm::StringRef hdr_name(sect.name, llvm::array_lengthof(sect.name)); + hdr_name = hdr_name.split('\0').first; + if (hdr_name.consume_front("/")) { + lldb::offset_t stroff; + if (!to_integer(hdr_name, stroff, 10)) + return ""; lldb::offset_t string_file_offset = m_coff_header.symoff + (m_coff_header.nsyms * 18) + stroff; - const char *name = m_data.GetCStr(&string_file_offset); - if (name) { - sect_name = name; - return true; - } - - return false; + if (const char *name = m_data.GetCStr(&string_file_offset)) + return name; + return ""; } - sect_name = sect.name; - return true; + return hdr_name; } //---------------------------------------------------------------------- @@ -663,147 +699,216 @@ bool ObjectFilePECOFF::IsStripped() { } void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { - if (!m_sections_ap.get()) { - m_sections_ap.reset(new SectionList()); + if (m_sections_ap) + return; + m_sections_ap.reset(new SectionList()); + ModuleSP module_sp(GetModule()); + if (module_sp) { + std::lock_guard guard(module_sp->GetMutex()); + const uint32_t nsects = m_sect_headers.size(); ModuleSP module_sp(GetModule()); - if (module_sp) { - std::lock_guard guard(module_sp->GetMutex()); - const uint32_t nsects = m_sect_headers.size(); - ModuleSP module_sp(GetModule()); - for (uint32_t idx = 0; idx < nsects; ++idx) { - std::string sect_name; - GetSectionName(sect_name, m_sect_headers[idx]); - ConstString const_sect_name(sect_name.c_str()); - static ConstString g_code_sect_name(".code"); - static ConstString g_CODE_sect_name("CODE"); - static ConstString g_data_sect_name(".data"); - static ConstString g_DATA_sect_name("DATA"); - static ConstString g_bss_sect_name(".bss"); - static ConstString g_BSS_sect_name("BSS"); - static ConstString g_debug_sect_name(".debug"); - static ConstString g_reloc_sect_name(".reloc"); - static ConstString g_stab_sect_name(".stab"); - static ConstString g_stabstr_sect_name(".stabstr"); - static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev"); - static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges"); - static ConstString g_sect_name_dwarf_debug_frame(".debug_frame"); - static ConstString g_sect_name_dwarf_debug_info(".debug_info"); - static ConstString g_sect_name_dwarf_debug_line(".debug_line"); - static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); - static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); - static ConstString g_sect_name_dwarf_debug_names(".debug_names"); - static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames"); - static ConstString g_sect_name_dwarf_debug_pubtypes(".debug_pubtypes"); - static ConstString g_sect_name_dwarf_debug_ranges(".debug_ranges"); - static ConstString g_sect_name_dwarf_debug_str(".debug_str"); - static ConstString g_sect_name_dwarf_debug_types(".debug_types"); - static ConstString g_sect_name_eh_frame(".eh_frame"); - static ConstString g_sect_name_swift_ast(".swift_ast"); - static ConstString g_sect_name_go_symtab(".gosymtab"); - SectionType section_type = eSectionTypeOther; - if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE && - ((const_sect_name == g_code_sect_name) || - (const_sect_name == g_CODE_sect_name))) { - section_type = eSectionTypeCode; - } else if (m_sect_headers[idx].flags & - llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA && - ((const_sect_name == g_data_sect_name) || - (const_sect_name == g_DATA_sect_name))) { + for (uint32_t idx = 0; idx < nsects; ++idx) { + ConstString const_sect_name(GetSectionName(m_sect_headers[idx])); + static ConstString g_code_sect_name(".code"); + static ConstString g_CODE_sect_name("CODE"); + static ConstString g_data_sect_name(".data"); + static ConstString g_DATA_sect_name("DATA"); + static ConstString g_bss_sect_name(".bss"); + static ConstString g_BSS_sect_name("BSS"); + static ConstString g_debug_sect_name(".debug"); + static ConstString g_reloc_sect_name(".reloc"); + static ConstString g_stab_sect_name(".stab"); + static ConstString g_stabstr_sect_name(".stabstr"); + static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev"); + static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges"); + static ConstString g_sect_name_dwarf_debug_frame(".debug_frame"); + static ConstString g_sect_name_dwarf_debug_info(".debug_info"); + static ConstString g_sect_name_dwarf_debug_line(".debug_line"); + static ConstString g_sect_name_dwarf_debug_loc(".debug_loc"); + static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists"); + static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo"); + static ConstString g_sect_name_dwarf_debug_names(".debug_names"); + static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames"); + static ConstString g_sect_name_dwarf_debug_pubtypes(".debug_pubtypes"); + static ConstString g_sect_name_dwarf_debug_ranges(".debug_ranges"); + static ConstString g_sect_name_dwarf_debug_str(".debug_str"); + static ConstString g_sect_name_dwarf_debug_types(".debug_types"); + static ConstString g_sect_name_eh_frame(".eh_frame"); + static ConstString g_sect_name_swift_ast(".swift_ast"); // downstream change + static ConstString g_sect_name_go_symtab(".gosymtab"); + SectionType section_type = eSectionTypeOther; + if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE && + ((const_sect_name == g_code_sect_name) || + (const_sect_name == g_CODE_sect_name))) { + section_type = eSectionTypeCode; + } else if (m_sect_headers[idx].flags & + llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA && + ((const_sect_name == g_data_sect_name) || + (const_sect_name == g_DATA_sect_name))) { + if (m_sect_headers[idx].size == 0 && m_sect_headers[idx].offset == 0) + section_type = eSectionTypeZeroFill; + else section_type = eSectionTypeData; - } else if (m_sect_headers[idx].flags & - llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA && - ((const_sect_name == g_bss_sect_name) || - (const_sect_name == g_BSS_sect_name))) { - if (m_sect_headers[idx].size == 0) - section_type = eSectionTypeZeroFill; - else - section_type = eSectionTypeData; - } else if (const_sect_name == g_debug_sect_name) { - section_type = eSectionTypeDebug; - } else if (const_sect_name == g_stabstr_sect_name) { - section_type = eSectionTypeDataCString; - } else if (const_sect_name == g_reloc_sect_name) { - section_type = eSectionTypeOther; - } else if (const_sect_name == g_sect_name_dwarf_debug_abbrev) - section_type = eSectionTypeDWARFDebugAbbrev; - else if (const_sect_name == g_sect_name_dwarf_debug_aranges) - section_type = eSectionTypeDWARFDebugAranges; - else if (const_sect_name == g_sect_name_dwarf_debug_frame) - section_type = eSectionTypeDWARFDebugFrame; - else if (const_sect_name == g_sect_name_dwarf_debug_info) - section_type = eSectionTypeDWARFDebugInfo; - else if (const_sect_name == g_sect_name_dwarf_debug_line) - section_type = eSectionTypeDWARFDebugLine; - else if (const_sect_name == g_sect_name_dwarf_debug_loc) - section_type = eSectionTypeDWARFDebugLoc; - else if (const_sect_name == g_sect_name_dwarf_debug_macinfo) - section_type = eSectionTypeDWARFDebugMacInfo; - else if (const_sect_name == g_sect_name_dwarf_debug_names) - section_type = eSectionTypeDWARFDebugNames; - else if (const_sect_name == g_sect_name_dwarf_debug_pubnames) - section_type = eSectionTypeDWARFDebugPubNames; - else if (const_sect_name == g_sect_name_dwarf_debug_pubtypes) - section_type = eSectionTypeDWARFDebugPubTypes; - else if (const_sect_name == g_sect_name_dwarf_debug_ranges) - section_type = eSectionTypeDWARFDebugRanges; - else if (const_sect_name == g_sect_name_dwarf_debug_str) - section_type = eSectionTypeDWARFDebugStr; - else if (const_sect_name == g_sect_name_dwarf_debug_types) - section_type = eSectionTypeDWARFDebugTypes; - else if (const_sect_name == g_sect_name_eh_frame) - section_type = eSectionTypeEHFrame; - else if (const_sect_name == g_sect_name_swift_ast) - section_type = eSectionTypeSwiftModules; - else if (const_sect_name == g_sect_name_go_symtab) - section_type = eSectionTypeGoSymtab; - else if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE) { - section_type = eSectionTypeCode; - } else if (m_sect_headers[idx].flags & - llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA) { + } else if (m_sect_headers[idx].flags & + llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA && + ((const_sect_name == g_bss_sect_name) || + (const_sect_name == g_BSS_sect_name))) { + if (m_sect_headers[idx].size == 0) + section_type = eSectionTypeZeroFill; + else + section_type = eSectionTypeData; + } else if (const_sect_name == g_debug_sect_name) { + section_type = eSectionTypeDebug; + } else if (const_sect_name == g_stabstr_sect_name) { + section_type = eSectionTypeDataCString; + } else if (const_sect_name == g_reloc_sect_name) { + section_type = eSectionTypeOther; + } else if (const_sect_name == g_sect_name_dwarf_debug_abbrev) + section_type = eSectionTypeDWARFDebugAbbrev; + else if (const_sect_name == g_sect_name_dwarf_debug_aranges) + section_type = eSectionTypeDWARFDebugAranges; + else if (const_sect_name == g_sect_name_dwarf_debug_frame) + section_type = eSectionTypeDWARFDebugFrame; + else if (const_sect_name == g_sect_name_dwarf_debug_info) + section_type = eSectionTypeDWARFDebugInfo; + else if (const_sect_name == g_sect_name_dwarf_debug_line) + section_type = eSectionTypeDWARFDebugLine; + else if (const_sect_name == g_sect_name_dwarf_debug_loc) + section_type = eSectionTypeDWARFDebugLoc; + else if (const_sect_name == g_sect_name_dwarf_debug_loclists) + section_type = eSectionTypeDWARFDebugLocLists; + else if (const_sect_name == g_sect_name_dwarf_debug_macinfo) + section_type = eSectionTypeDWARFDebugMacInfo; + else if (const_sect_name == g_sect_name_dwarf_debug_names) + section_type = eSectionTypeDWARFDebugNames; + else if (const_sect_name == g_sect_name_dwarf_debug_pubnames) + section_type = eSectionTypeDWARFDebugPubNames; + else if (const_sect_name == g_sect_name_dwarf_debug_pubtypes) + section_type = eSectionTypeDWARFDebugPubTypes; + else if (const_sect_name == g_sect_name_dwarf_debug_ranges) + section_type = eSectionTypeDWARFDebugRanges; + else if (const_sect_name == g_sect_name_dwarf_debug_str) + section_type = eSectionTypeDWARFDebugStr; + else if (const_sect_name == g_sect_name_dwarf_debug_types) + section_type = eSectionTypeDWARFDebugTypes; + else if (const_sect_name == g_sect_name_eh_frame) + section_type = eSectionTypeEHFrame; + else if (const_sect_name == g_sect_name_swift_ast) + section_type = eSectionTypeSwiftModules; // downstream change + else if (const_sect_name == g_sect_name_go_symtab) + section_type = eSectionTypeGoSymtab; + else if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE) { + section_type = eSectionTypeCode; + } else if (m_sect_headers[idx].flags & + llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA) { + section_type = eSectionTypeData; + } else if (m_sect_headers[idx].flags & + llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) { + if (m_sect_headers[idx].size == 0) + section_type = eSectionTypeZeroFill; + else section_type = eSectionTypeData; - } else if (m_sect_headers[idx].flags & - llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) { - if (m_sect_headers[idx].size == 0) - section_type = eSectionTypeZeroFill; - else - section_type = eSectionTypeData; - } - - // Use a segment ID of the segment index shifted left by 8 so they - // never conflict with any of the sections. - SectionSP section_sp(new Section( - module_sp, // Module to which this section belongs - this, // Object file to which this section belongs - idx + 1, // Section ID is the 1 based segment index shifted right by - // 8 bits as not to collide with any of the 256 section IDs - // that are possible - const_sect_name, // Name of this section - section_type, // This section is a container of other sections. - m_coff_header_opt.image_base + - m_sect_headers[idx].vmaddr, // File VM address == addresses as - // they are found in the object file - m_sect_headers[idx].vmsize, // VM size in bytes of this section - m_sect_headers[idx] - .offset, // Offset to the data for this section in the file - m_sect_headers[idx] - .size, // Size in bytes of this section as found in the file - m_coff_header_opt.sect_alignment, // Section alignment - m_sect_headers[idx].flags)); // Flags for this section - - // section_sp->SetIsEncrypted (segment_is_encrypted); - - unified_section_list.AddSection(section_sp); - m_sections_ap->AddSection(section_sp); } + + // Use a segment ID of the segment index shifted left by 8 so they + // never conflict with any of the sections. + SectionSP section_sp(new Section( + module_sp, // Module to which this section belongs + this, // Object file to which this section belongs + idx + 1, // Section ID is the 1 based segment index shifted right by + // 8 bits as not to collide with any of the 256 section IDs + // that are possible + const_sect_name, // Name of this section + section_type, // This section is a container of other sections. + m_coff_header_opt.image_base + + m_sect_headers[idx].vmaddr, // File VM address == addresses as + // they are found in the object file + m_sect_headers[idx].vmsize, // VM size in bytes of this section + m_sect_headers[idx] + .offset, // Offset to the data for this section in the file + m_sect_headers[idx] + .size, // Size in bytes of this section as found in the file + m_coff_header_opt.sect_alignment, // Section alignment + m_sect_headers[idx].flags)); // Flags for this section + + // section_sp->SetIsEncrypted (segment_is_encrypted); + + unified_section_list.AddSection(section_sp); + m_sections_ap->AddSection(section_sp); } } } bool ObjectFilePECOFF::GetUUID(UUID *uuid) { return false; } +uint32_t ObjectFilePECOFF::ParseDependentModules() { + ModuleSP module_sp(GetModule()); + if (!module_sp) + return 0; + + std::lock_guard guard(module_sp->GetMutex()); + if (m_deps_filespec) + return m_deps_filespec->GetSize(); + + // Cache coff binary if it is not done yet. + if (!CreateBinary()) + return 0; + + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); + if (log) + log->Printf("%p ObjectFilePECOFF::ParseDependentModules() module = %p " + "(%s), binary = %p (Bin = %p)", + static_cast(this), static_cast(module_sp.get()), + module_sp->GetSpecificationDescription().c_str(), + static_cast(m_owningbin.getPointer()), + m_owningbin ? static_cast(m_owningbin->getBinary()) + : nullptr); + + auto COFFObj = + llvm::dyn_cast(m_owningbin->getBinary()); + if (!COFFObj) + return 0; + + m_deps_filespec = FileSpecList(); + + for (const auto &entry : COFFObj->import_directories()) { + llvm::StringRef dll_name; + auto ec = entry.getName(dll_name); + // Report a bogus entry. + if (ec != std::error_code()) { + if (log) + log->Printf("ObjectFilePECOFF::ParseDependentModules() - failed to get " + "import directory entry name: %s", + ec.message().c_str()); + continue; + } + + // At this moment we only have the base name of the DLL. The full path can + // only be seen after the dynamic loading. Our best guess is Try to get it + // with the help of the object file's directory. + llvm::SmallString<128> dll_fullpath; + FileSpec dll_specs(dll_name); + dll_specs.GetDirectory().SetString(m_file.GetDirectory().GetCString()); + + if (!llvm::sys::fs::real_path(dll_specs.GetPath(), dll_fullpath)) + m_deps_filespec->Append(FileSpec(dll_fullpath)); + else { + // Known DLLs or DLL not found in the object file directory. + m_deps_filespec->Append(FileSpec(dll_name)); + } + } + return m_deps_filespec->GetSize(); +} + uint32_t ObjectFilePECOFF::GetDependentModules(FileSpecList &files) { - return 0; + auto num_modules = ParseDependentModules(); + auto original_size = files.GetSize(); + + for (unsigned i = 0; i < num_modules; ++i) + files.AppendIfUnique(m_deps_filespec->GetFileSpecAtIndex(i)); + + return files.GetSize() - original_size; } lldb_private::Address ObjectFilePECOFF::GetEntryPointAddress() { @@ -814,12 +919,12 @@ lldb_private::Address ObjectFilePECOFF::GetEntryPointAddress() { return m_entry_point_address; SectionList *section_list = GetSectionList(); - addr_t offset = m_coff_header_opt.entry; + addr_t file_addr = m_coff_header_opt.entry + m_coff_header_opt.image_base; if (!section_list) - m_entry_point_address.SetOffset(offset); + m_entry_point_address.SetOffset(file_addr); else - m_entry_point_address.ResolveAddressUsingFileSections(offset, section_list); + m_entry_point_address.ResolveAddressUsingFileSections(file_addr, section_list); return m_entry_point_address; } @@ -837,8 +942,7 @@ void ObjectFilePECOFF::Dump(Stream *s) { s->Indent(); s->PutCString("ObjectFilePECOFF"); - ArchSpec header_arch; - GetArchitecture(header_arch); + ArchSpec header_arch = GetArchitecture(); *s << ", file = '" << m_file << "', arch = " << header_arch.GetArchitectureName() << "\n"; @@ -860,6 +964,9 @@ void ObjectFilePECOFF::Dump(Stream *s) { s->EOL(); DumpSectionHeaders(s); s->EOL(); + + DumpDependentModules(s); + s->EOL(); } } @@ -977,8 +1084,7 @@ void ObjectFilePECOFF::DumpOptCOFFHeader(Stream *s, //---------------------------------------------------------------------- void ObjectFilePECOFF::DumpSectionHeader(Stream *s, const section_header_t &sh) { - std::string name; - GetSectionName(name, sh); + std::string name = GetSectionName(sh); s->Printf("%-16s 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x 0x%4.4x " "0x%4.4x 0x%8.8x\n", name.c_str(), sh.vmaddr, sh.vmsize, sh.offset, sh.size, sh.reloff, @@ -1007,6 +1113,22 @@ void ObjectFilePECOFF::DumpSectionHeaders(Stream *s) { } } +//---------------------------------------------------------------------- +// DumpDependentModules +// +// Dump all of the dependent modules to the specified output stream +//---------------------------------------------------------------------- +void ObjectFilePECOFF::DumpDependentModules(lldb_private::Stream *s) { + auto num_modules = ParseDependentModules(); + if (num_modules > 0) { + s->PutCString("Dependent Modules\n"); + for (unsigned i = 0; i < num_modules; ++i) { + auto spec = m_deps_filespec->GetFileSpecAtIndex(i); + s->Printf(" %s\n", spec.GetFilename().GetCString()); + } + } +} + bool ObjectFilePECOFF::IsWindowsSubsystem() { switch (m_coff_header_opt.subsystem) { case llvm::COFF::IMAGE_SUBSYSTEM_NATIVE: @@ -1022,9 +1144,11 @@ bool ObjectFilePECOFF::IsWindowsSubsystem() { } } -bool ObjectFilePECOFF::GetArchitecture(ArchSpec &arch) { +ArchSpec ObjectFilePECOFF::GetArchitecture() { uint16_t machine = m_coff_header.machine; switch (machine) { + default: + break; case llvm::COFF::IMAGE_FILE_MACHINE_AMD64: case llvm::COFF::IMAGE_FILE_MACHINE_I386: case llvm::COFF::IMAGE_FILE_MACHINE_POWERPC: @@ -1032,14 +1156,13 @@ bool ObjectFilePECOFF::GetArchitecture(ArchSpec &arch) { case llvm::COFF::IMAGE_FILE_MACHINE_ARM: case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT: case llvm::COFF::IMAGE_FILE_MACHINE_THUMB: + ArchSpec arch; arch.SetArchitecture(eArchTypeCOFF, machine, LLDB_INVALID_CPUTYPE, IsWindowsSubsystem() ? llvm::Triple::Win32 : llvm::Triple::UnknownOS); - return true; - default: - break; + return arch; } - return false; + return ArchSpec(); } ObjectFile::Type ObjectFilePECOFF::CalculateType() { @@ -1053,6 +1176,7 @@ ObjectFile::Type ObjectFilePECOFF::CalculateType() { } ObjectFile::Strata ObjectFilePECOFF::CalculateStrata() { return eStrataUser; } + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h index d8a94e19d34f..cd1cb0200310 100644 --- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h +++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h @@ -1,22 +1,18 @@ //===-- ObjectFilePECOFF.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ObjectFilePECOFF_h_ #define liblldb_ObjectFilePECOFF_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/ObjectFile.h" +#include "llvm/Object/Binary.h" class ObjectFilePECOFF : public lldb_private::ObjectFile { public: @@ -113,7 +109,7 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile { void Dump(lldb_private::Stream *s) override; - bool GetArchitecture(lldb_private::ArchSpec &arch) override; + lldb_private::ArchSpec GetArchitecture() override; bool GetUUID(lldb_private::UUID *uuid) override; @@ -261,6 +257,8 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile { bool ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr); bool ParseSectionHeaders(uint32_t offset); + uint32_t ParseDependentModules(); + static void DumpDOSHeader(lldb_private::Stream *s, const dos_header_t &header); static void DumpCOFFHeader(lldb_private::Stream *s, @@ -269,12 +267,17 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile { const coff_opt_header_t &header); void DumpSectionHeaders(lldb_private::Stream *s); void DumpSectionHeader(lldb_private::Stream *s, const section_header_t &sh); - bool GetSectionName(std::string §_name, const section_header_t §); + void DumpDependentModules(lldb_private::Stream *s); + + llvm::StringRef GetSectionName(const section_header_t §); typedef std::vector SectionHeaderColl; typedef SectionHeaderColl::iterator SectionHeaderCollIter; typedef SectionHeaderColl::const_iterator SectionHeaderCollConstIter; +private: + bool CreateBinary(); + private: dos_header_t m_dos_header; coff_header_t m_coff_header; @@ -282,6 +285,9 @@ class ObjectFilePECOFF : public lldb_private::ObjectFile { SectionHeaderColl m_sect_headers; lldb::addr_t m_image_base; lldb_private::Address m_entry_point_address; + llvm::Optional m_deps_filespec; + typedef llvm::object::OwningBinary OWNBINType; + llvm::Optional m_owningbin; }; #endif // liblldb_ObjectFilePECOFF_h_ diff --git a/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp b/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp index d6553f6e5142..d5da60b19bfc 100644 --- a/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp +++ b/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp @@ -1,9 +1,8 @@ //===-- WindowsMiniDump.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,7 +15,7 @@ #ifdef _WIN32 #include "lldb/Host/windows/windows.h" -#include // for MiniDumpWriteDump +#include #endif namespace lldb_private { diff --git a/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h b/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h index 135d53387387..9aaed6908a15 100644 --- a/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h +++ b/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.h @@ -1,9 +1,8 @@ //===-- WindowsMiniDump.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index d6252c473270..7ef0611a48c0 100644 --- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -1,18 +1,14 @@ //===-- OperatingSystemPython.cpp --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 LLDB_DISABLE_PYTHON #include "OperatingSystemPython.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "Plugins/Process/Utility/DynamicRegisterInfo.h" #include "Plugins/Process/Utility/RegisterContextDummy.h" #include "Plugins/Process/Utility/RegisterContextMemory.h" @@ -20,7 +16,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" @@ -32,6 +27,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" @@ -53,7 +49,8 @@ OperatingSystem *OperatingSystemPython::CreateInstance(Process *process, // Python OperatingSystem plug-ins must be requested by name, so force must // be true FileSpec python_os_plugin_spec(process->GetPythonOSPluginPath()); - if (python_os_plugin_spec && python_os_plugin_spec.Exists()) { + if (python_os_plugin_spec && + FileSystem::Instance().Exists(python_os_plugin_spec)) { std::unique_ptr os_ap( new OperatingSystemPython(process, python_os_plugin_spec)); if (os_ap.get() && os_ap->IsValid()) @@ -215,7 +212,7 @@ bool OperatingSystemPython::UpdateThreadList(ThreadList &old_thread_list, // beginning of the list uint32_t insert_idx = 0; for (uint32_t core_idx = 0; core_idx < num_cores; ++core_idx) { - if (core_used_map[core_idx] == false) { + if (!core_used_map[core_idx]) { new_thread_list.InsertThread( core_thread_list.GetThreadAtIndex(core_idx, false), insert_idx); ++insert_idx; diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h index 2e1680410962..3d6414521d2f 100644 --- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h +++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h @@ -1,9 +1,8 @@ //===-- OperatingSystemPython.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,10 +11,6 @@ #ifndef LLDB_DISABLE_PYTHON -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/OperatingSystem.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/Plugins/Platform/Android/AdbClient.cpp b/source/Plugins/Platform/Android/AdbClient.cpp index 4cd8c645dd76..e99018d88cb2 100644 --- a/source/Plugins/Platform/Android/AdbClient.cpp +++ b/source/Plugins/Platform/Android/AdbClient.cpp @@ -1,13 +1,11 @@ //===-- AdbClient.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Other libraries and framework includes #include "AdbClient.h" #include "llvm/ADT/STLExtras.h" @@ -484,7 +482,7 @@ Status AdbClient::SyncService::internalPushFile(const FileSpec &local_file, return Status("Failed to send file chunk: %s", error.AsCString()); } error = SendSyncRequest( - kDONE, llvm::sys::toTimeT(FileSystem::GetModificationTime(local_file)), + kDONE, llvm::sys::toTimeT(FileSystem::Instance().GetModificationTime(local_file)), nullptr); if (error.Fail()) return error; diff --git a/source/Plugins/Platform/Android/AdbClient.h b/source/Plugins/Platform/Android/AdbClient.h index 0d2100fc5663..035796b1cf9b 100644 --- a/source/Plugins/Platform/Android/AdbClient.h +++ b/source/Plugins/Platform/Android/AdbClient.h @@ -1,9 +1,8 @@ //===-- AdbClient.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Platform/Android/PlatformAndroid.cpp b/source/Plugins/Platform/Android/PlatformAndroid.cpp index 1cedcde97a92..1e9c840a2418 100644 --- a/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -1,23 +1,21 @@ //===-- PlatformAndroid.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/UriParser.h" -// Project includes #include "AdbClient.h" #include "PlatformAndroid.h" #include "PlatformAndroidRemoteGDBServer.h" @@ -75,7 +73,7 @@ PlatformSP PlatformAndroid::CreateInstance(bool force, const ArchSpec *arch) { } bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getVendor()) { case llvm::Triple::PC: @@ -83,9 +81,9 @@ PlatformSP PlatformAndroid::CreateInstance(bool force, const ArchSpec *arch) { break; #if defined(__ANDROID__) - // Only accept "unknown" for the vendor if the host is android and it + // Only accept "unknown" for the vendor if the host is android and if // "unknown" wasn't specified (it was just returned because it was NOT - // specified_ + // specified). case llvm::Triple::VendorType::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; @@ -95,7 +93,7 @@ PlatformSP PlatformAndroid::CreateInstance(bool force, const ArchSpec *arch) { } if (create) { - switch (triple.getOS()) { + switch (triple.getEnvironment()) { case llvm::Triple::Android: break; @@ -103,8 +101,8 @@ PlatformSP PlatformAndroid::CreateInstance(bool force, const ArchSpec *arch) { // Only accept "unknown" for the OS if the host is android and it // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::OSType::UnknownOS: - create = !arch->TripleOSWasSpecified(); + case llvm::Triple::EnvironmentType::UnknownEnvironment: + create = !arch->TripleEnvironmentWasSpecified(); break; #endif default: @@ -193,7 +191,7 @@ Status PlatformAndroid::GetFile(const FileSpec &source, if (IsHost() || !m_remote_platform_sp) return PlatformLinux::GetFile(source, destination); - FileSpec source_spec(source.GetPath(false), false, FileSpec::Style::posix); + FileSpec source_spec(source.GetPath(false), FileSpec::Style::posix); if (source_spec.IsRelative()) source_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent( source_spec.GetCString(false)); @@ -237,8 +235,7 @@ Status PlatformAndroid::PutFile(const FileSpec &source, if (IsHost() || !m_remote_platform_sp) return PlatformLinux::PutFile(source, destination, uid, gid); - FileSpec destination_spec(destination.GetPath(false), false, - FileSpec::Style::posix); + FileSpec destination_spec(destination.GetPath(false), FileSpec::Style::posix); if (destination_spec.IsRelative()) destination_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent( destination_spec.GetCString(false)); @@ -343,7 +340,7 @@ Status PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp, log->Printf("Failed to remove temp directory: %s", error.AsCString()); }); - FileSpec symfile_platform_filespec(tmpdir, false); + FileSpec symfile_platform_filespec(tmpdir); symfile_platform_filespec.AppendPathComponent("symbolized.oat"); // Execute oatdump on the remote device to generate a file with symtab diff --git a/source/Plugins/Platform/Android/PlatformAndroid.h b/source/Plugins/Platform/Android/PlatformAndroid.h index 4c12eb8c016d..2d004419984c 100644 --- a/source/Plugins/Platform/Android/PlatformAndroid.h +++ b/source/Plugins/Platform/Android/PlatformAndroid.h @@ -1,22 +1,17 @@ //===-- PlatformAndroid.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformAndroid_h_ #define liblldb_PlatformAndroid_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "Plugins/Platform/Linux/PlatformLinux.h" #include "AdbClient.h" diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp index 2415da31daf0..e36527dc1291 100644 --- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp +++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp @@ -1,13 +1,11 @@ //===-- PlatformAndroidRemoteGDBServer.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Other libraries and framework includes #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/common/TCPSocket.h" #include "lldb/Utility/Log.h" diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h index 1bd13ffe89fe..c4421a3f4a32 100644 --- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h +++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h @@ -1,22 +1,17 @@ //===-- PlatformAndroidRemoteGDBServer.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformAndroidRemoteGDBServer_h_ #define liblldb_PlatformAndroidRemoteGDBServer_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" #include "llvm/ADT/Optional.h" diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index 645228765faa..4df466a007e0 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -1,34 +1,29 @@ //===-- PlatformFreeBSD.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformFreeBSD.h" #include "lldb/Host/Config.h" -// C Includes #include #ifndef LLDB_DISABLE_POSIX #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -52,7 +47,7 @@ PlatformSP PlatformFreeBSD::CreateInstance(bool force, const ArchSpec *arch) { arch ? arch->GetTriple().getTriple() : ""); bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getOS()) { case llvm::Triple::FreeBSD: diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h index 274304834290..30c95dc380e4 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -1,9 +1,8 @@ //===-- PlatformFreeBSD.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp index 00327e485bf3..ddcc6290235f 100644 --- a/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ b/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp @@ -1,19 +1,15 @@ //===-- PlatformKalimba.cpp ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformKalimba.h" #include "lldb/Host/Config.h" -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -33,7 +29,7 @@ static uint32_t g_initialize_count = 0; PlatformSP PlatformKalimba::CreateInstance(bool force, const ArchSpec *arch) { bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getVendor()) { case llvm::Triple::CSR: diff --git a/source/Plugins/Platform/Kalimba/PlatformKalimba.h b/source/Plugins/Platform/Kalimba/PlatformKalimba.h index 53a8e5594aaa..2d395925bb18 100644 --- a/source/Plugins/Platform/Kalimba/PlatformKalimba.h +++ b/source/Plugins/Platform/Kalimba/PlatformKalimba.h @@ -1,19 +1,14 @@ //===-- PlatformKalimba.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformKalimba_h_ #define liblldb_PlatformKalimba_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Platform.h" namespace lldb_private { diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp index 14c35fe6a01a..5100b1749761 100644 --- a/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -1,32 +1,27 @@ //===-- PlatformLinux.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformLinux.h" #include "lldb/Host/Config.h" -// C Includes #include #ifndef LLDB_DISABLE_POSIX #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -50,7 +45,7 @@ PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) { arch ? arch->GetTriple().getTriple() : ""); bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getOS()) { case llvm::Triple::Linux: @@ -322,8 +317,8 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, // Now create the gdb-remote process. LLDB_LOG(log, "having target create process with gdb-remote plugin"); - process_sp = target->CreateProcess( - launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr); + process_sp = + target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr); if (!process_sp) { error.SetErrorString("CreateProcess() failed for gdb-remote process"); diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h index 50d721f7c072..2b05c2705fdc 100644 --- a/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/source/Plugins/Platform/Linux/PlatformLinux.h @@ -1,9 +1,8 @@ //===-- PlatformLinux.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp index 0c39799a21a5..f2a2c0a8753b 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -1,24 +1,19 @@ //===-- PlatformAppleSimulator.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformAppleSimulator.h" -// C Includes #if defined(__APPLE__) #include #endif -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Host/PseudoTerminal.h" #include "lldb/Target/Process.h" #include "lldb/Utility/LLDBAssert.h" @@ -229,9 +224,8 @@ FileSpec PlatformAppleSimulator::GetCoreSimulatorPath() { cs_path.Printf( "%s/Library/PrivateFrameworks/CoreSimulator.framework/CoreSimulator", developer_dir); - const bool resolve_path = true; - m_core_simulator_framework_path = - FileSpec(cs_path.GetData(), resolve_path); + m_core_simulator_framework_path = FileSpec(cs_path.GetData()); + FileSystem::Instance().Resolve(*m_core_simulator_framework_path); } } diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h index 2536854e9630..705d563bef32 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h @@ -1,21 +1,16 @@ //===-- PlatformAppleSimulator.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformAppleSimulator_h_ #define liblldb_PlatformAppleSimulator_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "Plugins/Platform/MacOSX/PlatformDarwin.h" #include "Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h" #include "lldb/Utility/FileSpec.h" diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp index e55cc0f4f6a4..6935ac6053c1 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -1,18 +1,13 @@ //===-- PlatformAppleTVSimulator.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformAppleTVSimulator.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -80,7 +75,7 @@ PlatformSP PlatformAppleTVSimulator::CreateInstance(bool force, } bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { switch (arch->GetMachine()) { case llvm::Triple::x86_64: { const llvm::Triple &triple = arch->GetTriple(); @@ -93,7 +88,7 @@ PlatformSP PlatformAppleTVSimulator::CreateInstance(bool force, // Only accept "unknown" for the vendor if the host is Apple and it // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; #endif @@ -190,7 +185,7 @@ Status PlatformAppleTVSimulator::ResolveExecutable( // ourselves Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) { if (resolved_module_spec.GetArchitecture().IsValid()) { error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, NULL, NULL, NULL); @@ -228,7 +223,7 @@ Status PlatformAppleTVSimulator::ResolveExecutable( } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -247,19 +242,20 @@ Status PlatformAppleTVSimulator::ResolveExecutable( return error; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { if (ft == llvm::sys::fs::file_type::directory_file) { + FileSpec file_spec(path); const char *filename = file_spec.GetFilename().GetCString(); if (filename && strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) == 0) { ::snprintf((char *)baton, PATH_MAX, "%s", filename); - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; } } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } const char *PlatformAppleTVSimulator::GetSDKDirectoryAsCString() { @@ -277,9 +273,9 @@ const char *PlatformAppleTVSimulator::GetSDKDirectoryAsCString() { bool find_directories = true; bool find_files = false; bool find_other = false; - FileSpec::EnumerateDirectory(sdks_directory, find_directories, find_files, - find_other, EnumerateDirectoryCallback, - sdk_dirname); + FileSystem::Instance().EnumerateDirectory( + sdks_directory, find_directories, find_files, find_other, + EnumerateDirectoryCallback, sdk_dirname); if (sdk_dirname[0]) { m_sdk_directory = sdks_directory; @@ -315,13 +311,15 @@ Status PlatformAppleTVSimulator::GetSymbolFile(const FileSpec &platform_file, platform_file_path); // First try in the SDK and see if the file is in there - local_file.SetFile(resolved_path, true, FileSpec::Style::native); - if (local_file.Exists()) + local_file.SetFile(resolved_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) return error; // Else fall back to the actual path itself - local_file.SetFile(platform_file_path, true, FileSpec::Style::native); - if (local_file.Exists()) + local_file.SetFile(platform_file_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) return error; } error.SetErrorStringWithFormat( diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h index 8cecb4d496ab..534bfef7e74b 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h @@ -1,19 +1,14 @@ //===-- PlatformAppleTVSimulator.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformAppleTVSimulator_h_ #define liblldb_PlatformAppleTVSimulator_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "PlatformDarwin.h" class PlatformAppleTVSimulator : public PlatformDarwin { diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp index 8bbe0af0aec2..fb2f1316383e 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -1,18 +1,13 @@ //===-- PlatformAppleWatchSimulator.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformAppleWatchSimulator.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -79,7 +74,7 @@ PlatformSP PlatformAppleWatchSimulator::CreateInstance(bool force, } bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { switch (arch->GetMachine()) { case llvm::Triple::x86_64: { const llvm::Triple &triple = arch->GetTriple(); @@ -92,7 +87,7 @@ PlatformSP PlatformAppleWatchSimulator::CreateInstance(bool force, // Only accept "unknown" for the vendor if the host is Apple and it // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; #endif @@ -190,7 +185,7 @@ Status PlatformAppleWatchSimulator::ResolveExecutable( // ourselves Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) { if (resolved_module_spec.GetArchitecture().IsValid()) { error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, NULL, NULL, NULL); @@ -228,7 +223,7 @@ Status PlatformAppleWatchSimulator::ResolveExecutable( } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -247,19 +242,20 @@ Status PlatformAppleWatchSimulator::ResolveExecutable( return error; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { if (ft == llvm::sys::fs::file_type::directory_file) { + FileSpec file_spec(path); const char *filename = file_spec.GetFilename().GetCString(); if (filename && strncmp(filename, "AppleWatchSimulator", strlen("AppleWatchSimulator")) == 0) { ::snprintf((char *)baton, PATH_MAX, "%s", filename); - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; } } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { @@ -277,9 +273,9 @@ const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { bool find_directories = true; bool find_files = false; bool find_other = false; - FileSpec::EnumerateDirectory(sdks_directory, find_directories, find_files, - find_other, EnumerateDirectoryCallback, - sdk_dirname); + FileSystem::Instance().EnumerateDirectory( + sdks_directory, find_directories, find_files, find_other, + EnumerateDirectoryCallback, sdk_dirname); if (sdk_dirname[0]) { m_sdk_directory = sdks_directory; @@ -315,13 +311,15 @@ Status PlatformAppleWatchSimulator::GetSymbolFile(const FileSpec &platform_file, platform_file_path); // First try in the SDK and see if the file is in there - local_file.SetFile(resolved_path, true, FileSpec::Style::native); - if (local_file.Exists()) + local_file.SetFile(resolved_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) return error; // Else fall back to the actual path itself - local_file.SetFile(platform_file_path, true, FileSpec::Style::native); - if (local_file.Exists()) + local_file.SetFile(platform_file_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) return error; } error.SetErrorStringWithFormat( diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h index 30aa42c964a5..463dc2cee641 100644 --- a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h @@ -1,19 +1,14 @@ //===-- PlatformAppleWatchSimulator.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformAppleWatchSimulator_h_ #define liblldb_PlatformAppleWatchSimulator_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "PlatformDarwin.h" class PlatformAppleWatchSimulator : public PlatformDarwin { diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 9c7ae39ecd77..83933126c818 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1,22 +1,18 @@ //===-- PlatformDarwin.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformDarwin.h" -// C Includes #include -// C++ Includes #include #include -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Debugger.h" @@ -33,7 +29,6 @@ #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Timer.h" @@ -43,7 +38,7 @@ #include "llvm/Support/VersionTuple.h" #if defined(__APPLE__) -#include // for TARGET_OS_TV, TARGET_OS_WATCH +#include #endif using namespace lldb; @@ -88,7 +83,7 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( ObjectFile *objfile = symfile->GetObjectFile(); if (objfile) { FileSpec symfile_spec(objfile->GetFileSpec()); - if (symfile_spec && symfile_spec.Exists()) { + if (symfile_spec && FileSystem::Instance().Exists(symfile_spec)) { while (module_spec.GetFilename()) { std::string module_basename( module_spec.GetFilename().GetCString()); @@ -130,20 +125,21 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( "%s/../Python/%s.py", symfile_spec.GetDirectory().GetCString(), original_module_basename.c_str()); - FileSpec script_fspec(path_string.GetString(), true); - FileSpec orig_script_fspec(original_path_string.GetString(), - true); + FileSpec script_fspec(path_string.GetString()); + FileSystem::Instance().Resolve(script_fspec); + FileSpec orig_script_fspec(original_path_string.GetString()); + FileSystem::Instance().Resolve(orig_script_fspec); // if we did some replacements of reserved characters, and a // file with the untampered name exists, then warn the user // that the file as-is shall not be loaded if (feedback_stream) { if (module_basename != original_module_basename && - orig_script_fspec.Exists()) { + FileSystem::Instance().Exists(orig_script_fspec)) { const char *reason_for_complaint = was_keyword ? "conflicts with a keyword" : "contains reserved characters"; - if (script_fspec.Exists()) + if (FileSystem::Instance().Exists(script_fspec)) feedback_stream->Printf( "warning: the symbol file '%s' contains a debug " "script. However, its name" @@ -167,7 +163,7 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( } } - if (script_fspec.Exists()) { + if (FileSystem::Instance().Exists(script_fspec)) { file_list.Append(script_fspec); break; } @@ -193,25 +189,12 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( Status PlatformDarwin::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, FileSpec &sym_file) { - Status error; sym_file = sym_spec.GetSymbolFileSpec(); - - llvm::sys::fs::file_status st; - if (status(sym_file.GetPath(), st, false)) { - error.SetErrorString("Could not stat file!"); - return error; + if (FileSystem::Instance().IsDirectory(sym_file)) { + sym_file = Symbols::FindSymbolFileInBundle(sym_file, sym_spec.GetUUIDPtr(), + sym_spec.GetArchitecturePtr()); } - - if (exists(st)) { - if (is_directory(st)) { - sym_file = Symbols::FindSymbolFileInBundle( - sym_file, sym_spec.GetUUIDPtr(), sym_spec.GetArchitecturePtr()); - } - } else { - if (sym_spec.GetUUID().IsValid()) { - } - } - return error; + return {}; } static lldb_private::Status @@ -261,7 +244,7 @@ lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache( if (!cache_path.empty()) { std::string module_path(module_spec.GetFileSpec().GetPath()); cache_path.append(module_path); - FileSpec module_cache_spec(cache_path, false); + FileSpec module_cache_spec(cache_path); // if rsync is supported, always bring in the file - rsync will be very // efficient when files are the same on the local and remote end of the @@ -270,7 +253,7 @@ lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache( err = BringInRemoteFile(this, module_spec, module_cache_spec); if (err.Fail()) return err; - if (module_cache_spec.Exists()) { + if (FileSystem::Instance().Exists(module_cache_spec)) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) log->Printf("[%s] module %s/%s was rsynced and is now there", @@ -286,7 +269,7 @@ lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache( } // try to find the module in the cache - if (module_cache_spec.Exists()) { + if (FileSystem::Instance().Exists(module_cache_spec)) { // get the local and remote MD5 and compare if (m_remote_platform_sp) { // when going over the *slow* GDB remote transfer mechanism we first @@ -337,7 +320,7 @@ lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache( Status err = BringInRemoteFile(this, module_spec, module_cache_spec); if (err.Fail()) return err; - if (module_cache_spec.Exists()) { + if (FileSystem::Instance().Exists(module_cache_spec)) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) log->Printf("[%s] module %s/%s is now cached and fine", @@ -412,8 +395,8 @@ Status PlatformDarwin::GetSharedModule( snprintf(new_path + search_path_len, sizeof(new_path) - search_path_len, "/%s", platform_path + bundle_directory_len); - FileSpec new_file_spec(new_path, false); - if (new_file_spec.Exists()) { + FileSpec new_file_spec(new_path); + if (FileSystem::Instance().Exists(new_file_spec)) { ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = new_file_spec; Status new_error(Platform::GetSharedModule( @@ -505,10 +488,7 @@ bool PlatformDarwin::ModuleIsExcludedForUnconstrainedSearches( return false; ObjectFile::Type obj_type = obj_file->GetType(); - if (obj_type == ObjectFile::eTypeDynamicLinker) - return true; - else - return false; + return obj_type == ObjectFile::eTypeDynamicLinker; } bool PlatformDarwin::x86GetSupportedArchitectureAtIndex(uint32_t idx, @@ -1167,9 +1147,9 @@ const char *PlatformDarwin::GetDeveloperDirectory() { if (xcode_select_prefix_dir) xcode_dir_path.append(xcode_select_prefix_dir); xcode_dir_path.append("/usr/share/xcode-select/xcode_dir_path"); - temp_file_spec.SetFile(xcode_dir_path, false, FileSpec::Style::native); + temp_file_spec.SetFile(xcode_dir_path, FileSpec::Style::native); auto dir_buffer = - DataBufferLLVM::CreateFromPath(temp_file_spec.GetPath()); + FileSystem::Instance().CreateDataBuffer(temp_file_spec.GetPath()); if (dir_buffer && dir_buffer->GetByteSize() > 0) { llvm::StringRef path_ref(dir_buffer->GetChars()); // Trim tailing newlines and make sure there is enough room for a null @@ -1183,8 +1163,8 @@ const char *PlatformDarwin::GetDeveloperDirectory() { } if (!developer_dir_path_valid) { - FileSpec xcode_select_cmd("/usr/bin/xcode-select", false); - if (xcode_select_cmd.Exists()) { + FileSpec xcode_select_cmd("/usr/bin/xcode-select"); + if (FileSystem::Instance().Exists(xcode_select_cmd)) { int exit_status = -1; int signo = -1; std::string command_output; @@ -1206,8 +1186,8 @@ const char *PlatformDarwin::GetDeveloperDirectory() { } developer_dir_path[i] = '\0'; - FileSpec devel_dir(developer_dir_path, false); - if (llvm::sys::fs::is_directory(devel_dir.GetPath())) { + FileSpec devel_dir(developer_dir_path); + if (FileSystem::Instance().IsDirectory(devel_dir)) { developer_dir_path_valid = true; } } @@ -1215,9 +1195,8 @@ const char *PlatformDarwin::GetDeveloperDirectory() { } if (developer_dir_path_valid) { - temp_file_spec.SetFile(developer_dir_path, false, - FileSpec::Style::native); - if (temp_file_spec.Exists()) { + temp_file_spec.SetFile(developer_dir_path, FileSpec::Style::native); + if (FileSystem::Instance().Exists(temp_file_spec)) { m_developer_directory.assign(developer_dir_path); return m_developer_directory.c_str(); } @@ -1247,7 +1226,7 @@ BreakpointSP PlatformDarwin::SetThreadCreationBreakpoint(Target &target) { FileSpecList bp_modules; for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++) { const char *bp_module = g_bp_modules[i]; - bp_modules.Append(FileSpec(bp_module, false)); + bp_modules.Append(FileSpec(bp_module)); } bool internal = true; @@ -1300,20 +1279,20 @@ static const char *const sdk_strings[] = { }; static FileSpec CheckPathForXcode(const FileSpec &fspec) { - if (fspec.Exists()) { + if (FileSystem::Instance().Exists(fspec)) { const char substr[] = ".app/Contents"; std::string path_to_shlib = fspec.GetPath(); size_t pos = path_to_shlib.rfind(substr); if (pos != std::string::npos) { path_to_shlib.erase(pos + strlen(substr)); - FileSpec ret(path_to_shlib, false); + FileSpec ret(path_to_shlib); FileSpec xcode_binary_path = ret; xcode_binary_path.AppendPathComponent("MacOS"); xcode_binary_path.AppendPathComponent("Xcode"); - if (xcode_binary_path.Exists()) { + if (FileSystem::Instance().Exists(xcode_binary_path)) { return ret; } } @@ -1348,8 +1327,9 @@ static FileSpec GetXcodeContentsPath() { if (!g_xcode_filespec) { const char *developer_dir_env_var = getenv("DEVELOPER_DIR"); if (developer_dir_env_var && developer_dir_env_var[0]) { - g_xcode_filespec = - CheckPathForXcode(FileSpec(developer_dir_env_var, true)); + FileSpec developer_dir_spec = FileSpec(developer_dir_env_var); + FileSystem::Instance().Resolve(developer_dir_spec); + g_xcode_filespec = CheckPathForXcode(developer_dir_spec); } // Fall back to using "xcrun" to find the selected Xcode @@ -1373,7 +1353,7 @@ static FileSpec GetXcodeContentsPath() { } output.append("/.."); - g_xcode_filespec = CheckPathForXcode(FileSpec(output, false)); + g_xcode_filespec = CheckPathForXcode(FileSpec(output)); } } } @@ -1417,23 +1397,24 @@ bool PlatformDarwin::SDKSupportsModules(SDKType desired_type, return false; } -FileSpec::EnumerateDirectoryResult PlatformDarwin::DirectoryEnumerator( - void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec) { +FileSystem::EnumerateDirectoryResult PlatformDarwin::DirectoryEnumerator( + void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) { SDKEnumeratorInfo *enumerator_info = static_cast(baton); + FileSpec spec(path); if (SDKSupportsModules(enumerator_info->sdk_type, spec)) { enumerator_info->found_path = spec; - return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; + return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; } - return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; + return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; } FileSpec PlatformDarwin::FindSDKInXcodeForModules(SDKType sdk_type, const FileSpec &sdks_spec) { // Look inside Xcode for the required installed iOS SDK version - if (!llvm::sys::fs::is_directory(sdks_spec.GetPath())) { + if (!FileSystem::Instance().IsDirectory(sdks_spec)) { return FileSpec(); } @@ -1445,11 +1426,11 @@ FileSpec PlatformDarwin::FindSDKInXcodeForModules(SDKType sdk_type, enumerator_info.sdk_type = sdk_type; - FileSpec::EnumerateDirectory(sdks_spec.GetPath(), find_directories, - find_files, find_other, DirectoryEnumerator, - &enumerator_info); + FileSystem::Instance().EnumerateDirectory( + sdks_spec.GetPath(), find_directories, find_files, find_other, + DirectoryEnumerator, &enumerator_info); - if (llvm::sys::fs::is_directory(enumerator_info.found_path.GetPath())) + if (FileSystem::Instance().IsDirectory(enumerator_info.found_path)) return enumerator_info.found_path; else return FileSpec(); @@ -1496,7 +1477,7 @@ FileSpec PlatformDarwin::GetSDKDirectoryForModules(SDKType sdk_type) { version.getMinor().getValueOr(0)); native_sdk_spec.AppendPathComponent(native_sdk_name.GetString()); - if (native_sdk_spec.Exists()) { + if (FileSystem::Instance().Exists(native_sdk_spec)) { return native_sdk_spec; } } @@ -1594,7 +1575,7 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType( sysroot_spec = GetSDKDirectoryForModules(sdk_type); } - if (llvm::sys::fs::is_directory(sysroot_spec.GetPath())) { + if (FileSystem::Instance().IsDirectory(sysroot_spec.GetPath())) { options.push_back("-isysroot"); options.push_back(sysroot_spec.GetPath()); } @@ -1658,7 +1639,7 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) { xcode_lldb_resources.AppendPathComponent("SharedFrameworks"); xcode_lldb_resources.AppendPathComponent("LLDB.framework"); xcode_lldb_resources.AppendPathComponent("Resources"); - if (xcode_lldb_resources.Exists()) { + if (FileSystem::Instance().Exists(xcode_lldb_resources)) { FileSpec dir; dir.GetDirectory().SetCString(xcode_lldb_resources.GetPath().c_str()); g_executable_dirs.push_back(dir); @@ -1672,7 +1653,7 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) { FileSpec executable_file; executable_file.GetDirectory() = executable_dir.GetDirectory(); executable_file.GetFilename().SetCString(basename); - if (executable_file.Exists()) + if (FileSystem::Instance().Exists(executable_file)) return executable_file; } @@ -1810,7 +1791,7 @@ PlatformDarwin::FindBundleBinaryInExecSearchPaths (const ModuleSpec &module_spec path_to_try.AppendPathComponent(path_parts[k]); } - if (path_to_try.Exists()) { + if (FileSystem::Instance().Exists(path_to_try)) { ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = path_to_try; Status new_error(Platform::GetSharedModule( diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/source/Plugins/Platform/MacOSX/PlatformDarwin.h index 371ca8be0eb2..beb1fe54844c 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -1,21 +1,17 @@ //===-- PlatformDarwin.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformDarwin_h_ #define liblldb_PlatformDarwin_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Platform/POSIX/PlatformPOSIX.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Utility/FileSpec.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" @@ -114,9 +110,9 @@ class PlatformDarwin : public PlatformPOSIX { SDKType sdk_type; }; - static lldb_private::FileSpec::EnumerateDirectoryResult + static lldb_private::FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, - const lldb_private::FileSpec &spec); + llvm::StringRef path); static lldb_private::FileSpec FindSDKInXcodeForModules(SDKType sdk_type, diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp index d41382a253c1..289827eb77e2 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -1,10 +1,9 @@ //===-- PlatformDarwinKernel.cpp -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,10 +12,6 @@ #if defined(__APPLE__) // This Plugin uses the Mac-specific // source/Host/macosx/cfcpp utilities -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -95,7 +90,7 @@ PlatformSP PlatformDarwinKernel::CreateInstance(bool force, // ArchSpec for normal userland debugging. It is only useful in kernel debug // sessions and the DynamicLoaderDarwinPlugin (or a user doing 'platform // select') will force the creation of this Platform plugin. - if (force == false) { + if (!force) { if (log) log->Printf("PlatformDarwinKernel::%s() aborting creation of platform " "because force == false", @@ -106,7 +101,7 @@ PlatformSP PlatformDarwinKernel::CreateInstance(bool force, bool create = force; LazyBool is_ios_debug_session = eLazyBoolCalculate; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getVendor()) { case llvm::Triple::Apple: @@ -115,7 +110,7 @@ PlatformSP PlatformDarwinKernel::CreateInstance(bool force, // Only accept "unknown" for vendor if the host is Apple and it "unknown" // wasn't specified (it was just returned because it was NOT specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; default: @@ -377,12 +372,15 @@ void PlatformDarwinKernel::CollectKextAndKernelDirectories() { GetUserSpecifiedDirectoriesToSearch(); // Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols - FileSpec possible_dir(developer_dir + "/../Symbols", true); - if (llvm::sys::fs::is_directory(possible_dir.GetPath())) + FileSpec possible_dir(developer_dir + "/../Symbols"); + FileSystem::Instance().Resolve(possible_dir); + if (FileSystem::Instance().IsDirectory(possible_dir)) m_search_directories.push_back(possible_dir); // Add simple directory of the current working directory - m_search_directories_no_recursing.push_back(FileSpec(".", true)); + FileSpec cwd("."); + FileSystem::Instance().Resolve(cwd); + m_search_directories_no_recursing.push_back(cwd); } void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() { @@ -392,8 +390,8 @@ void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() { const uint32_t user_dirs_count = user_dirs.GetSize(); for (uint32_t i = 0; i < user_dirs_count; i++) { FileSpec dir = user_dirs.GetFileSpecAtIndex(i); - dir.ResolvePath(); - if (llvm::sys::fs::is_directory(dir.GetPath())) { + FileSystem::Instance().Resolve(dir); + if (FileSystem::Instance().IsDirectory(dir)) { m_search_directories.push_back(dir); } } @@ -408,14 +406,14 @@ void PlatformDarwinKernel::AddRootSubdirsToSearchPaths( // /AppleInternal/Developer/KDKs/*.kdk/... nullptr}; for (int i = 0; subdirs[i] != nullptr; i++) { - FileSpec testdir(dir + subdirs[i], true); - if (llvm::sys::fs::is_directory(testdir.GetPath())) + FileSpec testdir(dir + subdirs[i]); + FileSystem::Instance().Resolve(testdir); + if (FileSystem::Instance().IsDirectory(testdir)) thisp->m_search_directories.push_back(testdir); } // Look for kernel binaries in the top level directory, without any recursion - thisp->m_search_directories_no_recursing.push_back( - FileSpec(dir + "/", false)); + thisp->m_search_directories_no_recursing.push_back(FileSpec(dir + "/")); } // Given a directory path dir, look for any subdirs named *.kdk and *.sdk @@ -424,25 +422,26 @@ void PlatformDarwinKernel::AddSDKSubdirsToSearchPaths(const std::string &dir) { const bool find_directories = true; const bool find_files = false; const bool find_other = false; - FileSpec::EnumerateDirectory(dir.c_str(), find_directories, find_files, - find_other, FindKDKandSDKDirectoriesInDirectory, - this); + FileSystem::Instance().EnumerateDirectory( + dir.c_str(), find_directories, find_files, find_other, + FindKDKandSDKDirectoriesInDirectory, this); } // Helper function to find *.sdk and *.kdk directories in a given directory. -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { static ConstString g_sdk_suffix = ConstString(".sdk"); static ConstString g_kdk_suffix = ConstString(".kdk"); PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton; + FileSpec file_spec(path); if (ft == llvm::sys::fs::file_type::directory_file && (file_spec.GetFileNameExtension() == g_sdk_suffix || file_spec.GetFileNameExtension() == g_kdk_suffix)) { AddRootSubdirsToSearchPaths(thisp, file_spec.GetPath()); } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } // Recursively search trough m_search_directories looking for kext and kernel @@ -454,7 +453,7 @@ void PlatformDarwinKernel::SearchForKextsAndKernelsRecursively() { const bool find_directories = true; const bool find_files = true; const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s. - FileSpec::EnumerateDirectory( + FileSystem::Instance().EnumerateDirectory( dir.GetPath().c_str(), find_directories, find_files, find_other, GetKernelsAndKextsInDirectoryWithRecursion, this); } @@ -464,7 +463,7 @@ void PlatformDarwinKernel::SearchForKextsAndKernelsRecursively() { const bool find_directories = true; const bool find_files = true; const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s. - FileSpec::EnumerateDirectory( + FileSystem::Instance().EnumerateDirectory( dir.GetPath().c_str(), find_directories, find_files, find_other, GetKernelsAndKextsInDirectoryNoRecursion, this); } @@ -478,25 +477,27 @@ void PlatformDarwinKernel::SearchForKextsAndKernelsRecursively() { // // Recurse into any subdirectories found. -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { - return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, true); + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { + return GetKernelsAndKextsInDirectoryHelper(baton, ft, path, true); } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { - return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, false); + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { + return GetKernelsAndKextsInDirectoryHelper(baton, ft, path, false); } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec, + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path, bool recurse) { static ConstString g_kext_suffix = ConstString(".kext"); static ConstString g_dsym_suffix = ConstString(".dSYM"); static ConstString g_bundle_suffix = ConstString("Bundle"); + + FileSpec file_spec(path); ConstString file_spec_extension = file_spec.GetFileNameExtension(); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); @@ -528,19 +529,19 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( } thisp->m_kernel_binaries_without_dsyms.push_back(file_spec); } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } } else if (ft == llvm::sys::fs::file_type::directory_file && file_spec_extension == g_kext_suffix) { AddKextToMap(thisp, file_spec); // Look to see if there is a PlugIns subdir with more kexts - FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns", false); + FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns"); std::string search_here_too; - if (llvm::sys::fs::is_directory(contents_plugins.GetPath())) { + if (FileSystem::Instance().IsDirectory(contents_plugins)) { search_here_too = contents_plugins.GetPath(); } else { - FileSpec plugins(file_spec.GetPath() + "/PlugIns", false); - if (llvm::sys::fs::is_directory(plugins.GetPath())) { + FileSpec plugins(file_spec.GetPath() + "/PlugIns"); + if (FileSystem::Instance().IsDirectory(plugins)) { search_here_too = plugins.GetPath(); } } @@ -549,13 +550,13 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( const bool find_directories = true; const bool find_files = false; const bool find_other = false; - FileSpec::EnumerateDirectory( + FileSystem::Instance().EnumerateDirectory( search_here_too.c_str(), find_directories, find_files, find_other, recurse ? GetKernelsAndKextsInDirectoryWithRecursion : GetKernelsAndKextsInDirectoryNoRecursion, baton); } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } // Don't recurse into dSYM/kext/bundle directories if (recurse && file_spec_extension != g_dsym_suffix && @@ -563,9 +564,9 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( file_spec_extension != g_bundle_suffix) { if (log_verbose) log_verbose->Printf ("PlatformDarwinKernel descending into directory '%s'", file_spec.GetPath().c_str()); - return FileSpec::eEnumerateDirectoryResultEnter; + return FileSystem::eEnumerateDirectoryResultEnter; } else { - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } } @@ -612,7 +613,7 @@ bool PlatformDarwinKernel::KextHasdSYMSibling( std::string filename = dsym_fspec.GetFilename().AsCString(); filename += ".dSYM"; dsym_fspec.GetFilename() = ConstString(filename); - if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) { + if (FileSystem::Instance().IsDirectory(dsym_fspec)) { return true; } // Should probably get the CFBundleExecutable here or call @@ -625,8 +626,9 @@ bool PlatformDarwinKernel::KextHasdSYMSibling( kext_bundle_filepath.GetPath() + "/Contents/MacOS/"; deep_bundle_str += executable_name.AsCString(); deep_bundle_str += ".dSYM"; - dsym_fspec.SetFile(deep_bundle_str, true, FileSpec::Style::native); - if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) { + dsym_fspec.SetFile(deep_bundle_str, FileSpec::Style::native); + FileSystem::Instance().Resolve(dsym_fspec); + if (FileSystem::Instance().IsDirectory(dsym_fspec)) { return true; } @@ -635,11 +637,9 @@ bool PlatformDarwinKernel::KextHasdSYMSibling( std::string shallow_bundle_str = kext_bundle_filepath.GetPath() + "/"; shallow_bundle_str += executable_name.AsCString(); shallow_bundle_str += ".dSYM"; - dsym_fspec.SetFile(shallow_bundle_str, true, FileSpec::Style::native); - if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) { - return true; - } - return false; + dsym_fspec.SetFile(shallow_bundle_str, FileSpec::Style::native); + FileSystem::Instance().Resolve(dsym_fspec); + return FileSystem::Instance().IsDirectory(dsym_fspec); } // Given a FileSpec of /dir/dir/mach.development.t7004 Return true if a dSYM @@ -650,10 +650,7 @@ bool PlatformDarwinKernel::KernelHasdSYMSibling(const FileSpec &kernel_binary) { std::string filename = kernel_binary.GetFilename().AsCString(); filename += ".dSYM"; kernel_dsym.GetFilename() = ConstString(filename); - if (llvm::sys::fs::is_directory(kernel_dsym.GetPath())) { - return true; - } - return false; + return FileSystem::Instance().IsDirectory(kernel_dsym); } Status PlatformDarwinKernel::GetSharedModule( @@ -712,11 +709,10 @@ Status PlatformDarwinKernel::GetSharedModule( } } - if (kext_bundle_id.compare("mach_kernel") == 0 && - module_spec.GetUUID().IsValid()) { + if (kext_bundle_id == "mach_kernel" && module_spec.GetUUID().IsValid()) { // First try all kernel binaries that have a dSYM next to them for (auto possible_kernel : m_kernel_binaries_with_dsyms) { - if (possible_kernel.Exists()) { + if (FileSystem::Instance().Exists(possible_kernel)) { ModuleSpec kern_spec(possible_kernel); kern_spec.GetUUID() = module_spec.GetUUID(); ModuleSP module_sp(new Module(kern_spec)); @@ -752,7 +748,7 @@ Status PlatformDarwinKernel::GetSharedModule( // Next try all kernel binaries that don't have a dSYM for (auto possible_kernel : m_kernel_binaries_without_dsyms) { - if (possible_kernel.Exists()) { + if (FileSystem::Instance().Exists(possible_kernel)) { ModuleSpec kern_spec(possible_kernel); kern_spec.GetUUID() = module_spec.GetUUID(); ModuleSP module_sp(new Module(kern_spec)); @@ -793,7 +789,7 @@ PlatformDarwinKernel::SearchForExecutablesRecursively(const std::string &dir) { break; if (llvm::sys::fs::is_regular_file(*status) && llvm::sys::fs::can_execute(it->path())) - executables.emplace_back(it->path(), false); + executables.emplace_back(it->path()); } return executables; } @@ -803,7 +799,7 @@ Status PlatformDarwinKernel::ExamineKextForMatchingUUID( const ArchSpec &arch, ModuleSP &exe_module_sp) { for (const auto &exe_file : SearchForExecutablesRecursively(kext_bundle_path.GetPath())) { - if (exe_file.Exists()) { + if (FileSystem::Instance().Exists(exe_file)) { ModuleSpec exe_spec(exe_file); exe_spec.GetUUID() = uuid; if (!uuid.IsValid()) { diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h index 7f603cac2bec..bf965c08e1c8 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h +++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h @@ -1,9 +1,8 @@ //===-- PlatformDarwinKernel.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,14 +14,10 @@ #if defined(__APPLE__) // This Plugin uses the Mac-specific // source/Host/macosx/cfcpp utilities -// C Includes -// C++ Includes -// Other libraries and framework includes #include "lldb/Utility/FileSpec.h" #include "llvm/Support/FileSystem.h" -// Project includes #include "PlatformDarwin.h" class PlatformDarwinKernel : public PlatformDarwin { @@ -106,26 +101,25 @@ class PlatformDarwinKernel : public PlatformDarwin { void AddSDKSubdirsToSearchPaths(const std::string &dir); - static lldb_private::FileSpec::EnumerateDirectoryResult + static lldb_private::FileSystem::EnumerateDirectoryResult FindKDKandSDKDirectoriesInDirectory(void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + llvm::StringRef path); void SearchForKextsAndKernelsRecursively(); - static lldb_private::FileSpec::EnumerateDirectoryResult - GetKernelsAndKextsInDirectoryWithRecursion( - void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + static lldb_private::FileSystem::EnumerateDirectoryResult + GetKernelsAndKextsInDirectoryWithRecursion(void *baton, + llvm::sys::fs::file_type ft, + llvm::StringRef path); - static lldb_private::FileSpec::EnumerateDirectoryResult - GetKernelsAndKextsInDirectoryNoRecursion( - void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + static lldb_private::FileSystem::EnumerateDirectoryResult + GetKernelsAndKextsInDirectoryNoRecursion(void *baton, + llvm::sys::fs::file_type ft, + llvm::StringRef path); - static lldb_private::FileSpec::EnumerateDirectoryResult + static lldb_private::FileSystem::EnumerateDirectoryResult GetKernelsAndKextsInDirectoryHelper(void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec, - bool recurse); + llvm::StringRef path, bool recurse); static std::vector SearchForExecutablesRecursively(const std::string &dir); @@ -148,7 +142,7 @@ class PlatformDarwinKernel : public PlatformDarwin { const lldb_private::ArchSpec &arch, lldb::ModuleSP &exe_module_sp); - // Most of the ivars are assembled under FileSpec::EnumerateDirectory calls + // Most of the ivars are assembled under FileSystem::EnumerateDirectory calls // where the // function being called for each file/directory must be static. We'll pass a // this pointer diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 99f603b01f43..6eba38f98126 100644 --- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -1,21 +1,17 @@ //===-- PlatformMacOSX.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformMacOSX.h" #include "lldb/Host/Config.h" -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -83,7 +79,7 @@ PlatformSP PlatformMacOSX::CreateInstance(bool force, const ArchSpec *arch) { const bool is_host = false; bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getVendor()) { case llvm::Triple::Apple: @@ -93,7 +89,7 @@ PlatformSP PlatformMacOSX::CreateInstance(bool force, const ArchSpec *arch) { #if defined(__APPLE__) // Only accept "unknown" for vendor if the host is Apple and it "unknown" // wasn't specified (it was just returned because it was NOT specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; #endif @@ -218,14 +214,14 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { "SDKs/MacOSX%u.%u.sdk", xcode_contents_path.c_str(), versions[0], versions[1]); - fspec.SetFile(sdk_path.GetString(), false, FileSpec::Style::native); - if (fspec.Exists()) + fspec.SetFile(sdk_path.GetString(), FileSpec::Style::native); + if (FileSystem::Instance().Exists(fspec)) return ConstString(sdk_path.GetString()); } if (!default_xcode_sdk.empty()) { - fspec.SetFile(default_xcode_sdk, false, FileSpec::Style::native); - if (fspec.Exists()) + fspec.SetFile(default_xcode_sdk, FileSpec::Style::native); + if (FileSystem::Instance().Exists(fspec)) return ConstString(default_xcode_sdk); } } @@ -259,7 +255,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, #endif std::string remote_os_build; m_remote_platform_sp->GetOSBuildString(remote_os_build); - if (local_os_build.compare(remote_os_build) == 0) { + if (local_os_build == remote_os_build) { // same OS version: the local file is good enough local_file = platform_file; return Status(); @@ -268,8 +264,8 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, std::string cache_path(GetLocalCacheDirectory()); std::string module_path(platform_file.GetPath()); cache_path.append(module_path); - FileSpec module_cache_spec(cache_path, false); - if (module_cache_spec.Exists()) { + FileSpec module_cache_spec(cache_path); + if (FileSystem::Instance().Exists(module_cache_spec)) { local_file = module_cache_spec; return Status(); } @@ -284,7 +280,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file, err = GetFile(platform_file, module_cache_spec); if (err.Fail()) return err; - if (module_cache_spec.Exists()) { + if (FileSystem::Instance().Exists(module_cache_spec)) { local_file = module_cache_spec; return Status(); } else diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/source/Plugins/Platform/MacOSX/PlatformMacOSX.h index d1e609258d4d..2475fcd2d46e 100644 --- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.h +++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.h @@ -1,19 +1,14 @@ //===-- PlatformMacOSX.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformMacOSX_h_ #define liblldb_PlatformMacOSX_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "PlatformDarwin.h" class PlatformMacOSX : public PlatformDarwin { diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp index 1ef0f2012b80..ff61ced2bbff 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp @@ -1,19 +1,14 @@ //===-- PlatformRemoteAppleBridge.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "PlatformRemoteAppleBridge.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -98,7 +93,7 @@ PlatformSP PlatformRemoteAppleBridge::CreateInstance(bool force, // Only accept "unknown" for the vendor if the host is Apple and // it "unknown" wasn't specified (it was just returned because it // was NOT specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h index 39fa0a9a47b5..339c3c8689b4 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h @@ -1,21 +1,16 @@ //===-- PlatformRemoteAppleBridge.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformRemoteAppleBridge_h_ #define liblldb_PlatformRemoteAppleBridge_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/FileSpec.h" #include "llvm/Support/FileSystem.h" diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp index be4c829a981c..586db67ee52e 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -1,19 +1,14 @@ //===-- PlatformRemoteAppleTV.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "PlatformRemoteAppleTV.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -101,7 +96,7 @@ PlatformSP PlatformRemoteAppleTV::CreateInstance(bool force, // Only accept "unknown" for the vendor if the host is Apple and // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h index 08dd231e85ee..c302f7865c4f 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h @@ -1,21 +1,16 @@ //===-- PlatformRemoteAppleTV.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformRemoteAppleTV_h_ #define liblldb_PlatformRemoteAppleTV_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/FileSpec.h" #include "llvm/Support/FileSystem.h" diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp index 6159511d4a18..7ab9a469b447 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -1,19 +1,14 @@ //===-- PlatformRemoteAppleWatch.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "PlatformRemoteAppleWatch.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -96,7 +91,7 @@ PlatformSP PlatformRemoteAppleWatch::CreateInstance(bool force, // Only accept "unknown" for the vendor if the host is Apple and // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h index 93be55b595f8..2c3462a999b6 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h @@ -1,22 +1,17 @@ //===-- PlatformRemoteAppleWatch.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformRemoteAppleWatch_h_ #define liblldb_PlatformRemoteAppleWatch_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/FileSpec.h" #include "PlatformRemoteDarwinDevice.h" diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp index d963e68ce756..59bf4831fbfa 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp @@ -1,23 +1,19 @@ //===-- PlatformRemoteDarwinDevice.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformRemoteDarwinDevice.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -85,7 +81,7 @@ Status PlatformRemoteDarwinDevice::ResolveExecutable( // ourselves Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) { if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid()) { error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, @@ -119,7 +115,7 @@ Status PlatformRemoteDarwinDevice::ResolveExecutable( } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -139,12 +135,12 @@ Status PlatformRemoteDarwinDevice::ResolveExecutable( return error; } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformRemoteDarwinDevice::GetContainedFilesIntoVectorOfStringsCallback( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { ((PlatformRemoteDarwinDevice::SDKDirectoryInfoCollection *)baton) - ->push_back(PlatformRemoteDarwinDevice::SDKDirectoryInfo(file_spec)); - return FileSpec::eEnumerateDirectoryResultNext; + ->push_back(PlatformRemoteDarwinDevice::SDKDirectoryInfo(FileSpec(path))); + return FileSystem::eEnumerateDirectoryResultNext; } bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { @@ -153,7 +149,8 @@ bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { if (m_sdk_directory_infos.empty()) { // A --sysroot option was supplied - add it to our list of SDKs to check if (m_sdk_sysroot) { - FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString(), true); + FileSpec sdk_sysroot_fspec(m_sdk_sysroot.GetCString()); + FileSystem::Instance().Resolve(sdk_sysroot_fspec); const SDKDirectoryInfo sdk_sysroot_directory_info(sdk_sysroot_fspec); m_sdk_directory_infos.push_back(sdk_sysroot_directory_info); if (log) { @@ -175,10 +172,10 @@ bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { const bool find_other = false; SDKDirectoryInfoCollection builtin_sdk_directory_infos; - FileSpec::EnumerateDirectory(m_device_support_directory, find_directories, - find_files, find_other, - GetContainedFilesIntoVectorOfStringsCallback, - &builtin_sdk_directory_infos); + FileSystem::Instance().EnumerateDirectory( + m_device_support_directory, find_directories, find_files, find_other, + GetContainedFilesIntoVectorOfStringsCallback, + &builtin_sdk_directory_infos); // Only add SDK directories that have symbols in them, some SDKs only // contain developer disk images and no symbols, so they aren't useful to @@ -187,7 +184,7 @@ bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { for (const auto &sdk_directory_info : builtin_sdk_directory_infos) { sdk_symbols_symlink_fspec = sdk_directory_info.directory; sdk_symbols_symlink_fspec.AppendPathComponent("Symbols"); - if (sdk_symbols_symlink_fspec.Exists()) { + if (FileSystem::Instance().Exists(sdk_symbols_symlink_fspec)) { m_sdk_directory_infos.push_back(sdk_directory_info); if (log) { log->Printf("PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " @@ -205,22 +202,23 @@ bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { const uint32_t num_installed = m_sdk_directory_infos.size(); std::string local_sdk_cache_str = "~/Library/Developer/Xcode/"; local_sdk_cache_str += dirname; - FileSpec local_sdk_cache(local_sdk_cache_str.c_str(), true); - if (local_sdk_cache.Exists()) { - if (log) { + FileSpec local_sdk_cache(local_sdk_cache_str.c_str()); + FileSystem::Instance().Resolve(local_sdk_cache); + if (FileSystem::Instance().Exists(local_sdk_cache)) { + if (log) { log->Printf("PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " "searching %s for additional SDKs", local_sdk_cache.GetPath().c_str()); - } + } char path[PATH_MAX]; if (local_sdk_cache.GetPath(path, sizeof(path))) { - FileSpec::EnumerateDirectory( - path, find_directories, find_files, find_other, - GetContainedFilesIntoVectorOfStringsCallback, - &m_sdk_directory_infos); - const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); - // First try for an exact match of major, minor and update - for (uint32_t i = num_installed; i < num_sdk_infos; ++i) { + FileSystem::Instance().EnumerateDirectory( + path, find_directories, find_files, find_other, + GetContainedFilesIntoVectorOfStringsCallback, + &m_sdk_directory_infos); + const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); + // First try for an exact match of major, minor and update + for (uint32_t i = num_installed; i < num_sdk_infos; ++i) { m_sdk_directory_infos[i].user_cached = true; if (log) { log->Printf("PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " @@ -235,15 +233,15 @@ bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { const char *addtional_platform_dirs = getenv("PLATFORM_SDK_DIRECTORY"); if (addtional_platform_dirs) { SDKDirectoryInfoCollection env_var_sdk_directory_infos; - FileSpec::EnumerateDirectory(addtional_platform_dirs, find_directories, - find_files, find_other, - GetContainedFilesIntoVectorOfStringsCallback, - &env_var_sdk_directory_infos); + FileSystem::Instance().EnumerateDirectory( + addtional_platform_dirs, find_directories, find_files, find_other, + GetContainedFilesIntoVectorOfStringsCallback, + &env_var_sdk_directory_infos); FileSpec sdk_symbols_symlink_fspec; for (const auto &sdk_directory_info : env_var_sdk_directory_infos) { sdk_symbols_symlink_fspec = sdk_directory_info.directory; sdk_symbols_symlink_fspec.AppendPathComponent("Symbols"); - if (sdk_symbols_symlink_fspec.Exists()) { + if (FileSystem::Instance().Exists(sdk_symbols_symlink_fspec)) { m_sdk_directory_infos.push_back(sdk_directory_info); if (log) { log->Printf("PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " @@ -418,12 +416,12 @@ bool PlatformRemoteDarwinDevice::GetFileInSDK(const char *platform_file_path, const char *paths_to_try[] = {"Symbols", "", "Symbols.Internal", nullptr}; for (size_t i = 0; paths_to_try[i] != nullptr; i++) { - local_file.SetFile(sdkroot_path, false, FileSpec::Style::native); + local_file.SetFile(sdkroot_path, FileSpec::Style::native); if (paths_to_try[i][0] != '\0') local_file.AppendPathComponent(paths_to_try[i]); local_file.AppendPathComponent(platform_file_path); - local_file.ResolvePath(); - if (local_file.Exists()) { + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) { if (log) log->Printf("Found a copy of %s in the SDK dir %s/%s", platform_file_path, sdkroot_path.c_str(), @@ -451,8 +449,9 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s", os_version_dir, platform_file_path); - local_file.SetFile(resolved_path, true, FileSpec::Style::native); - if (local_file.Exists()) { + local_file.SetFile(resolved_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) { if (log) { log->Printf("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir); @@ -463,8 +462,9 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols.Internal/%s", os_version_dir, platform_file_path); - local_file.SetFile(resolved_path, true, FileSpec::Style::native); - if (local_file.Exists()) { + local_file.SetFile(resolved_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) { if (log) { log->Printf( "Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", @@ -475,8 +475,9 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, ::snprintf(resolved_path, sizeof(resolved_path), "%s/Symbols/%s", os_version_dir, platform_file_path); - local_file.SetFile(resolved_path, true, FileSpec::Style::native); - if (local_file.Exists()) { + local_file.SetFile(resolved_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) { if (log) { log->Printf("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir); @@ -485,7 +486,7 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file, } } local_file = platform_file; - if (local_file.Exists()) + if (FileSystem::Instance().Exists(local_file)) return error; error.SetErrorStringWithFormat( diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h index 8ddfd51600fd..b0a04592bf23 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h @@ -1,21 +1,16 @@ //===-- PlatformRemoteDarwinDevice.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformRemoteDarwinDevice_h_ #define liblldb_PlatformRemoteDarwinDevice_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "PlatformDarwin.h" #include "lldb/Utility/FileSpec.h" @@ -84,10 +79,10 @@ class PlatformRemoteDarwinDevice : public PlatformDarwin { const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion(); - static lldb_private::FileSpec::EnumerateDirectoryResult - GetContainedFilesIntoVectorOfStringsCallback( - void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + static lldb_private::FileSystem::EnumerateDirectoryResult + GetContainedFilesIntoVectorOfStringsCallback(void *baton, + llvm::sys::fs::file_type ft, + llvm::StringRef path); uint32_t FindFileInAllSDKs(const char *platform_file_path, lldb_private::FileSpecList &file_list); diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index 150bfdbfc118..9e4c2b61065d 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -1,18 +1,13 @@ //===-- PlatformRemoteiOS.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformRemoteiOS.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -75,7 +70,7 @@ PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) { } bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { switch (arch->GetMachine()) { case llvm::Triple::arm: case llvm::Triple::aarch64: @@ -91,7 +86,7 @@ PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) { // Only accept "unknown" for the vendor if the host is Apple and // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h index 975f50b421f1..4a739f8802f2 100644 --- a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h +++ b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -1,21 +1,16 @@ //===-- PlatformRemoteiOS.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformRemoteiOS_h_ #define liblldb_PlatformRemoteiOS_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "PlatformRemoteDarwinDevice.h" #include "lldb/Utility/FileSpec.h" diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp index 26feec282322..1ba9419b07ac 100644 --- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -1,19 +1,14 @@ //===-- PlatformiOSSimulator.cpp -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformiOSSimulator.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -80,7 +75,7 @@ PlatformSP PlatformiOSSimulator::CreateInstance(bool force, } bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { switch (arch->GetMachine()) { case llvm::Triple::x86_64: case llvm::Triple::x86: { @@ -94,7 +89,7 @@ PlatformSP PlatformiOSSimulator::CreateInstance(bool force, // Only accept "unknown" for the vendor if the host is Apple and it // "unknown" wasn't specified (it was just returned because it was NOT // specified) - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; #endif @@ -196,7 +191,7 @@ Status PlatformiOSSimulator::ResolveExecutable( // ourselves Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) { if (resolved_module_spec.GetArchitecture().IsValid()) { error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, NULL, NULL, NULL); @@ -234,7 +229,7 @@ Status PlatformiOSSimulator::ResolveExecutable( } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -253,18 +248,19 @@ Status PlatformiOSSimulator::ResolveExecutable( return error; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { if (ft == llvm::sys::fs::file_type::directory_file) { + FileSpec file_spec(path); const char *filename = file_spec.GetFilename().GetCString(); if (filename && strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) { ::snprintf((char *)baton, PATH_MAX, "%s", filename); - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; } } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } const char *PlatformiOSSimulator::GetSDKDirectoryAsCString() { @@ -282,9 +278,9 @@ const char *PlatformiOSSimulator::GetSDKDirectoryAsCString() { bool find_directories = true; bool find_files = false; bool find_other = false; - FileSpec::EnumerateDirectory(sdks_directory, find_directories, find_files, - find_other, EnumerateDirectoryCallback, - sdk_dirname); + FileSystem::Instance().EnumerateDirectory( + sdks_directory, find_directories, find_files, find_other, + EnumerateDirectoryCallback, sdk_dirname); if (sdk_dirname[0]) { m_sdk_directory = sdks_directory; @@ -320,13 +316,15 @@ Status PlatformiOSSimulator::GetSymbolFile(const FileSpec &platform_file, platform_file_path); // First try in the SDK and see if the file is in there - local_file.SetFile(resolved_path, true, FileSpec::Style::native); - if (local_file.Exists()) + local_file.SetFile(resolved_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) return error; // Else fall back to the actual path itself - local_file.SetFile(platform_file_path, true, FileSpec::Style::native); - if (local_file.Exists()) + local_file.SetFile(platform_file_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(local_file); + if (FileSystem::Instance().Exists(local_file)) return error; } error.SetErrorStringWithFormat( diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h index 2d81d6229f73..5e415fc50c7f 100644 --- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h +++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h @@ -1,22 +1,17 @@ //===-- PlatformiOSSimulator.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformiOSSimulator_h_ #define liblldb_PlatformiOSSimulator_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "PlatformAppleSimulator.h" class PlatformiOSSimulator : public PlatformAppleSimulator { diff --git a/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h b/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h index 083e2d6c5687..bb42a388d045 100644 --- a/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h +++ b/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h @@ -1,29 +1,24 @@ //===-- PlatformiOSSimulatorCoreSimulatorSupport.h ----------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformiOSSimulatorCoreSimulatorSupport_h_ #define liblldb_PlatformiOSSimulatorCoreSimulatorSupport_h_ -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes #ifdef __APPLE__ #include #else typedef void *id; #endif -// Project includes #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/ConstString.h" diff --git a/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm b/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm index 4516a66ee8ca..a172c9d70674 100644 --- a/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm +++ b/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm @@ -1,10 +1,9 @@ //===-- PlatformiOSSimulatorCoreSimulatorSupport.cpp ---------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -409,7 +408,7 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info, // Check in case our file action open wants to open the slave const char *slave_path = launch_info.GetPTY().GetSlaveName(NULL, 0); if (slave_path) { - FileSpec slave_spec(slave_path, false); + FileSpec slave_spec(slave_path); if (file_spec == slave_spec) { int slave_fd = launch_info.GetPTY().GetSlaveFileDescriptor(); if (slave_fd == PseudoTerminal::invalid_fd) @@ -591,7 +590,7 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info, std::function f) { const size_t n = GetNumDevices(); for (NSUInteger i = 0; i < n; ++i) { - if (f(GetDeviceAtIndex(i)) == false) + if (!f(GetDeviceAtIndex(i))) break; } } diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index f86def6e25f4..294eddb86683 100644 --- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -1,32 +1,27 @@ //===-- PlatformNetBSD.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformNetBSD.h" #include "lldb/Host/Config.h" -// C Includes #include #ifndef LLDB_DISABLE_POSIX #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -50,7 +45,7 @@ PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) { arch ? arch->GetTriple().getTriple() : ""); bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getOS()) { case llvm::Triple::NetBSD: @@ -291,8 +286,8 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, // Now create the gdb-remote process. LLDB_LOG(log, "having target create process with gdb-remote plugin"); - process_sp = target->CreateProcess( - launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr); + process_sp = + target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr); if (!process_sp) { error.SetErrorString("CreateProcess() failed for gdb-remote process"); diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h index 28a5d6713dd9..8558f3c2310e 100644 --- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -1,9 +1,8 @@ //===-- PlatformNetBSD.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp index 10ca8fbfbdd7..54971294ffb6 100644 --- a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -1,32 +1,27 @@ //===-- PlatformOpenBSD.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformOpenBSD.h" #include "lldb/Host/Config.h" -// C Includes #include #ifndef LLDB_DISABLE_POSIX #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -50,7 +45,7 @@ PlatformSP PlatformOpenBSD::CreateInstance(bool force, const ArchSpec *arch) { arch ? arch->GetTriple().getTriple() : ""); bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getOS()) { case llvm::Triple::OpenBSD: diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h index cb5e9bfe6392..5c4c7a2b8feb 100644 --- a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h +++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h @@ -1,9 +1,8 @@ //===-- PlatformOpenBSD.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index 29a4694447f9..a28a73230e2a 100644 --- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -1,18 +1,13 @@ //===-- PlatformPOSIX.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformPOSIX.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -128,23 +123,25 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec, if (IsHost()) { // If we have "ls" as the exe_file, resolve the executable location based // on the current path variables - if (!resolved_module_spec.GetFileSpec().Exists()) { + if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) { resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path)); - resolved_module_spec.GetFileSpec().SetFile(exe_path, true, + resolved_module_spec.GetFileSpec().SetFile(exe_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec()); } - if (!resolved_module_spec.GetFileSpec().Exists()) - resolved_module_spec.GetFileSpec().ResolveExecutableLocation(); + if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) + FileSystem::Instance().ResolveExecutableLocation( + resolved_module_spec.GetFileSpec()); // Resolve any executable within a bundle on MacOSX Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) error.Clear(); else { - const uint32_t permissions = - resolved_module_spec.GetFileSpec().GetPermissions(); + const uint32_t permissions = FileSystem::Instance().GetPermissions( + resolved_module_spec.GetFileSpec()); if (permissions && (permissions & eFilePermissionsEveryoneR) == 0) error.SetErrorStringWithFormat( "executable '%s' is not readable", @@ -166,7 +163,7 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec, // Resolve any executable within a bundle on MacOSX Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) error.Clear(); else error.SetErrorStringWithFormat("the platform is not currently " @@ -237,7 +234,8 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec, } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable( + resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -455,7 +453,7 @@ lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) { Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) { if (IsHost()) - return FileSystem::Symlink(src, dst); + return FileSystem::Instance().Symlink(src, dst); else if (m_remote_platform_sp) return m_remote_platform_sp->CreateSymlink(src, dst); else @@ -464,7 +462,7 @@ Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) { bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) { if (IsHost()) - return file_spec.Exists(); + return FileSystem::Instance().Exists(file_spec); else if (m_remote_platform_sp) return m_remote_platform_sp->GetFileExists(file_spec); else @@ -1282,8 +1280,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process, std::string name_string; process->ReadCStringFromMemory(buffer_addr, name_string, utility_error); if (utility_error.Success()) - loaded_image->SetFile(name_string, false, - llvm::sys::path::Style::posix); + loaded_image->SetFile(name_string, llvm::sys::path::Style::posix); } return process->AddImageToken(token); } diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h index cc6f7299c194..f6958cae25f8 100644 --- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -1,22 +1,17 @@ //===-- PlatformPOSIX.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformPOSIX_h_ #define liblldb_PlatformPOSIX_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/Options.h" #include "lldb/Target/Platform.h" diff --git a/source/Plugins/Platform/Windows/PlatformWindows.cpp b/source/Plugins/Platform/Windows/PlatformWindows.cpp index ccbb7a48fc29..3826aaab55f2 100644 --- a/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -1,24 +1,19 @@ //===-- PlatformWindows.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformWindows.h" -// C Includes #include #if defined(_WIN32) #include "lldb/Host/windows/windows.h" #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Debugger.h" @@ -71,14 +66,14 @@ PlatformSP PlatformWindows::CreateInstance(bool force, const bool is_host = false; bool create = force; - if (create == false && arch && arch->IsValid()) { + if (!create && arch && arch->IsValid()) { const llvm::Triple &triple = arch->GetTriple(); switch (triple.getVendor()) { case llvm::Triple::PC: create = true; break; - case llvm::Triple::UnknownArch: + case llvm::Triple::UnknownVendor: create = !arch->TripleVendorWasSpecified(); break; @@ -192,16 +187,18 @@ Status PlatformWindows::ResolveExecutable( if (IsHost()) { // if we cant resolve the executable loation based on the current path // variables - if (!resolved_module_spec.GetFileSpec().Exists()) { + if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) { resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path)); - resolved_module_spec.GetFileSpec().SetFile(exe_path, true, + resolved_module_spec.GetFileSpec().SetFile(exe_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec()); } - if (!resolved_module_spec.GetFileSpec().Exists()) - resolved_module_spec.GetFileSpec().ResolveExecutableLocation(); + if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) + FileSystem::Instance().ResolveExecutableLocation( + resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists()) + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) error.Clear(); else { ms.GetFileSpec().GetPath(exe_path, sizeof(exe_path)); @@ -215,7 +212,7 @@ Status PlatformWindows::ResolveExecutable( } else { // We may connect to a process and use the provided executable (Don't use // local $PATH). - if (resolved_module_spec.GetFileSpec().Exists()) + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) error.Clear(); else error.SetErrorStringWithFormat("the platform is not currently " @@ -262,7 +259,8 @@ Status PlatformWindows::ResolveExecutable( } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable( + resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -438,9 +436,8 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo &launch_info, ProcessAttachInfo attach_info(launch_info); return Attach(attach_info, debugger, target, error); } else { - ProcessSP process_sp = - target->CreateProcess(launch_info.GetListenerForProcess(debugger), - launch_info.GetProcessPluginName(), nullptr); + ProcessSP process_sp = target->CreateProcess( + launch_info.GetListener(), launch_info.GetProcessPluginName(), nullptr); // We need to launch and attach to the process. launch_info.GetFlags().Set(eLaunchFlagDebug); diff --git a/source/Plugins/Platform/Windows/PlatformWindows.h b/source/Plugins/Platform/Windows/PlatformWindows.h index 3a15271c5762..3b831487e2b2 100644 --- a/source/Plugins/Platform/Windows/PlatformWindows.h +++ b/source/Plugins/Platform/Windows/PlatformWindows.h @@ -1,19 +1,14 @@ //===-- PlatformWindows.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformWindows_h_ #define liblldb_PlatformWindows_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Platform.h" namespace lldb_private { diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 7f86d6d0347b..cb971b02dcb5 100644 --- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -1,18 +1,14 @@ //===-- PlatformRemoteGDBServer.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PlatformRemoteGDBServer.h" #include "lldb/Host/Config.h" -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -43,7 +39,7 @@ static bool g_initialized = false; void PlatformRemoteGDBServer::Initialize() { Platform::Initialize(); - if (g_initialized == false) { + if (!g_initialized) { g_initialized = true; PluginManager::RegisterPlugin( PlatformRemoteGDBServer::GetPluginNameStatic(), @@ -107,7 +103,7 @@ Status PlatformRemoteGDBServer::ResolveExecutable( // Resolve any executable within an apk on Android? // Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec()); - if (resolved_module_spec.GetFileSpec().Exists() || + if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()) || module_spec.GetUUID().IsValid()) { if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid()) { @@ -142,7 +138,7 @@ Status PlatformRemoteGDBServer::ResolveExecutable( } if (error.Fail() || !exe_module_sp) { - if (resolved_module_spec.GetFileSpec().Readable()) { + if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) { error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), @@ -499,8 +495,8 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess( // The darwin always currently uses the GDB remote debugger plug-in // so even when debugging locally we are debugging remotely! - process_sp = target->CreateProcess( - launch_info.GetListenerForProcess(debugger), "gdb-remote", NULL); + process_sp = target->CreateProcess(launch_info.GetListener(), + "gdb-remote", NULL); if (process_sp) { error = process_sp->ConnectRemote(nullptr, connect_url.c_str()); diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h index a31933b5d9b0..d7a5aa5537cb 100644 --- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -1,22 +1,17 @@ //===-- PlatformRemoteGDBServer.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_PlatformRemoteGDBServer_h_ #define liblldb_PlatformRemoteGDBServer_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "lldb/Target/Platform.h" diff --git a/source/Plugins/Process/Darwin/CFBundle.cpp b/source/Plugins/Process/Darwin/CFBundle.cpp index 7b080e60cdb3..9bdc6f561997 100644 --- a/source/Plugins/Process/Darwin/CFBundle.cpp +++ b/source/Plugins/Process/Darwin/CFBundle.cpp @@ -1,9 +1,8 @@ //===-- CFBundle.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/CFBundle.h b/source/Plugins/Process/Darwin/CFBundle.h index 09957af534b3..c56edee7a03a 100644 --- a/source/Plugins/Process/Darwin/CFBundle.h +++ b/source/Plugins/Process/Darwin/CFBundle.h @@ -1,9 +1,8 @@ //===-- CFBundle.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/CFString.cpp b/source/Plugins/Process/Darwin/CFString.cpp index b87afe999181..21b3a0427c60 100644 --- a/source/Plugins/Process/Darwin/CFString.cpp +++ b/source/Plugins/Process/Darwin/CFString.cpp @@ -1,9 +1,8 @@ //===-- CFString.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/CFString.h b/source/Plugins/Process/Darwin/CFString.h index 18d60a5a74bd..47db507ce38b 100644 --- a/source/Plugins/Process/Darwin/CFString.h +++ b/source/Plugins/Process/Darwin/CFString.h @@ -1,9 +1,8 @@ //===-- CFString.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/CFUtils.h b/source/Plugins/Process/Darwin/CFUtils.h index a904cd0ea6f0..9dae40670f34 100644 --- a/source/Plugins/Process/Darwin/CFUtils.h +++ b/source/Plugins/Process/Darwin/CFUtils.h @@ -1,9 +1,8 @@ //===-- CFUtils.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp index 95659725ce2e..c72def374078 100644 --- a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp +++ b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp @@ -1,9 +1,8 @@ //===-- DarwinProcessLauncher.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Darwin/DarwinProcessLauncher.h b/source/Plugins/Process/Darwin/DarwinProcessLauncher.h index a0e8ce5cb9dc..004ff19dd9fa 100644 --- a/source/Plugins/Process/Darwin/DarwinProcessLauncher.h +++ b/source/Plugins/Process/Darwin/DarwinProcessLauncher.h @@ -1,9 +1,8 @@ //===-- DarwinProcessLauncher.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Darwin/LaunchFlavor.h b/source/Plugins/Process/Darwin/LaunchFlavor.h index 7b161712cffd..cfd76d1b9c3c 100644 --- a/source/Plugins/Process/Darwin/LaunchFlavor.h +++ b/source/Plugins/Process/Darwin/LaunchFlavor.h @@ -1,9 +1,8 @@ //===-- LaunchFlavor.h ---------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Darwin/MachException.cpp b/source/Plugins/Process/Darwin/MachException.cpp index bc2a9a7b7d54..50543d5b8de1 100644 --- a/source/Plugins/Process/Darwin/MachException.cpp +++ b/source/Plugins/Process/Darwin/MachException.cpp @@ -1,9 +1,8 @@ //===-- MachException.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/MachException.h b/source/Plugins/Process/Darwin/MachException.h index 2da6a36a921e..18e49173b020 100644 --- a/source/Plugins/Process/Darwin/MachException.h +++ b/source/Plugins/Process/Darwin/MachException.h @@ -1,9 +1,8 @@ //===-- MachException.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp b/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp index 8041597bd7b8..7fb39eefd205 100644 --- a/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp +++ b/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp @@ -1,9 +1,8 @@ //===-- NativeProcessDarwin.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -19,10 +18,10 @@ // C++ includes // LLDB includes -#include "lldb/Core/State.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "CFBundle.h" @@ -63,12 +62,13 @@ Status NativeProcessProtocol::Launch( // Verify the working directory is valid if one was specified. FileSpec working_dir(launch_info.GetWorkingDirectory()); - if (working_dir && - (!working_dir.ResolvePath() || - !llvm::sys::fs::is_directory(working_dir.GetPath())) { - error.SetErrorStringWithFormat("No such file or directory: %s", + if (working_dir) { + FileInstance::Instance().Resolve(working_dir); + if (!FileSystem::Instance().IsDirectory(working_dir)) { + error.SetErrorStringWithFormat("No such file or directory: %s", working_dir.GetCString()); - return error; + return error; + } } // Launch the inferior. diff --git a/source/Plugins/Process/Darwin/NativeProcessDarwin.h b/source/Plugins/Process/Darwin/NativeProcessDarwin.h index 0b186fd7d80c..b55c1728c6a6 100644 --- a/source/Plugins/Process/Darwin/NativeProcessDarwin.h +++ b/source/Plugins/Process/Darwin/NativeProcessDarwin.h @@ -1,9 +1,8 @@ //===-- NativeProcessDarwin.h --------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -21,7 +20,6 @@ #include #include -// Other libraries and framework includes #include "lldb/Host/Debug.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/Pipe.h" diff --git a/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp b/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp index 521c6d5c8fd0..a1979c5a66a2 100644 --- a/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp +++ b/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp @@ -1,9 +1,8 @@ //===-- NativeThreadDarwin.cpp -------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Darwin/NativeThreadDarwin.h b/source/Plugins/Process/Darwin/NativeThreadDarwin.h index f66f8fe8738c..160e18d35892 100644 --- a/source/Plugins/Process/Darwin/NativeThreadDarwin.h +++ b/source/Plugins/Process/Darwin/NativeThreadDarwin.h @@ -1,9 +1,8 @@ //===-- NativeThreadDarwin.h ---------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp b/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp index 4ff662e42097..499db58e2d81 100644 --- a/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp +++ b/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp @@ -1,10 +1,9 @@ //===-- NativeThreadListDarwin.cpp ------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/Darwin/NativeThreadListDarwin.h b/source/Plugins/Process/Darwin/NativeThreadListDarwin.h index 7b59afb96e95..9ab0a7c8c802 100644 --- a/source/Plugins/Process/Darwin/NativeThreadListDarwin.h +++ b/source/Plugins/Process/Darwin/NativeThreadListDarwin.h @@ -1,10 +1,9 @@ //===-- NativeThreadListDarwin.h --------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp index 3576a7f26f86..397b9315d376 100644 --- a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp +++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp @@ -1,13 +1,11 @@ //===-- FreeBSDThread.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include #include @@ -16,12 +14,9 @@ #include #include -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/State.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/State.h" -// Project includes #include "FreeBSDThread.h" #include "POSIXStopInfo.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" @@ -42,7 +37,6 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThread.h" @@ -50,6 +44,7 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/SmallString.h" using namespace lldb; diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.h b/source/Plugins/Process/FreeBSD/FreeBSDThread.h index c93cc4fbfd73..83a987cf75ce 100644 --- a/source/Plugins/Process/FreeBSD/FreeBSDThread.h +++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.h @@ -1,20 +1,17 @@ //===-- FreeBSDThread.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_FreeBSDThread_H_ #define liblldb_FreeBSDThread_H_ -// C++ Includes #include #include -// Other libraries and framework includes #include "RegisterContextPOSIX.h" #include "lldb/Target/Thread.h" diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp index 9c75c26e379b..71f012944a9a 100644 --- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp +++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp @@ -1,9 +1,8 @@ //===-- POSIXStopInfo.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h index ff3693107170..a2fe76714ba1 100644 --- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h +++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h @@ -1,9 +1,8 @@ //===-- POSIXStopInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index 04abf97f95da..f09087a6df4c 100644 --- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -1,14 +1,12 @@ //===-- ProcessFreeBSD.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include #include @@ -18,18 +16,17 @@ #include #include -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include "FreeBSDThread.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" @@ -38,13 +35,11 @@ #include "ProcessFreeBSD.h" #include "ProcessMonitor.h" -// Other libraries and framework includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" @@ -52,6 +47,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/State.h" #include "lldb/Host/posix/Fcntl.h" @@ -287,7 +283,7 @@ bool ProcessFreeBSD::CanDebug(lldb::TargetSP target_sp, // For now we are just making sure the file exists for a given module ModuleSP exe_module_sp(target_sp->GetExecutableModule()); if (exe_module_sp.get()) - return exe_module_sp->GetFileSpec().Exists(); + return FileSystem::Instance().Exists(exe_module_sp->GetFileSpec()); // If there is no executable module, we return true since we might be // preparing to attach. return true; @@ -335,7 +331,7 @@ ProcessFreeBSD::DoAttachToProcessWithID(lldb::pid_t pid, GetTarget().SetArchitecture(module_arch); // Initialize the target module list - GetTarget().SetExecutableModule(exe_module_sp, true); + GetTarget().SetExecutableModule(exe_module_sp, eLoadDependentsYes); SetSTDIOFileDescriptor(m_monitor->GetTerminalFD()); @@ -373,12 +369,13 @@ Status ProcessFreeBSD::DoLaunch(Module *module, assert(m_monitor == NULL); FileSpec working_dir = launch_info.GetWorkingDirectory(); - namespace fs = llvm::sys::fs; - if (working_dir && (!working_dir.ResolvePath() || - !fs::is_directory(working_dir.GetPath()))) { - error.SetErrorStringWithFormat("No such file or directory: %s", + if (working_dir) { + FileSystem::Instance().Resolve(working_dir); + if (!FileSystem::Instance().IsDirectory(working_dir.GetPath())) { + error.SetErrorStringWithFormat("No such file or directory: %s", working_dir.GetCString()); - return error; + return error; + } } SetPrivateState(eStateLaunching); @@ -390,8 +387,7 @@ Status ProcessFreeBSD::DoLaunch(Module *module, FileSpec stdout_file_spec{}; FileSpec stderr_file_spec{}; - const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL, 0), - false}; + const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL, 0)}; file_action = launch_info.GetFileActionForFD(STDIN_FILENO); stdin_file_spec = @@ -519,7 +515,7 @@ void ProcessFreeBSD::DoDidExec() { executable_search_paths.GetSize() ? &executable_search_paths : NULL); if (!error.Success()) return; - target->SetExecutableModule(exe_module_sp, true); + target->SetExecutableModule(exe_module_sp, eLoadDependentsYes); } } } diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h index 7ed2a56cd549..e8a0cd9a9dff 100644 --- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -1,10 +1,9 @@ //===-- ProcessFreeBSD.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index 51fdf2e5ef33..dfebbcca2835 100644 --- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -1,13 +1,11 @@ //===-- ProcessMonitor.cpp ------------------------------------ -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include #include @@ -19,16 +17,14 @@ #include #include -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Host/Host.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "llvm/Support/Errno.h" @@ -171,7 +167,7 @@ static size_t DoWriteMemory(lldb::pid_t pid, lldb::addr_t vm_addr, pi_desc.piod_op = PIOD_WRITE_D; pi_desc.piod_offs = (void *)vm_addr; - pi_desc.piod_addr = (void *)buf; + pi_desc.piod_addr = const_cast(buf); pi_desc.piod_len = size; if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0) { diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/source/Plugins/Process/FreeBSD/ProcessMonitor.h index 1d3e2d746fa9..597f741c8a3b 100644 --- a/source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -1,23 +1,19 @@ //===-- ProcessMonitor.h -------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessMonitor_H_ #define liblldb_ProcessMonitor_H_ -// C Includes #include #include -// C++ Includes #include -// Other libraries and framework includes #include "lldb/Host/HostThread.h" #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-types.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h index b1b44e71de46..085c169b45aa 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h @@ -1,18 +1,14 @@ //===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_H_ #define liblldb_RegisterContextPOSIX_H_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/ArchSpec.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp index 8ddc253aea5d..89677d4056fa 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextPOSIXProcessMonitor_arm.cpp -----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "ProcessFreeBSD.h" #include "ProcessMonitor.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h index 6aa71c24f1cd..b376967df99c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_arm.h --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp index 93ffeb5ea79b..801d1c4affc5 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextPOSIXProcessMonitor_arm64.cpp -----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h" #include "ProcessFreeBSD.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h index 8591c83be541..d54d34e89cad 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_arm64.h --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp index 734167e1fc98..706e5ce79518 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextPOSIXProcessMonitor_mips64.cpp -----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h" #include "ProcessFreeBSD.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h index 6f57b0d9cd65..a482cd3f1e1c 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_mips64.h -------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp index 5cc6cd290629..d94638dc44f0 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextPOSIXProcessMonitor_powerpc.cpp ----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "ProcessFreeBSD.h" #include "ProcessMonitor.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h index 188ddea7d473..17b649feebf1 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h @@ -1,10 +1,9 @@ //===-- RegisterContextPOSIXProcessMonitor_powerpc.h -------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp index 7db7f803b371..01e1224ba280 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextPOSIXProcessMonitor_x86.cpp --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" #include "Plugins/Process/FreeBSD/ProcessMonitor.h" diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h index 8c654f97dcd9..c9dc02a88e01 100644 --- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h +++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXProcessMonitor_x86.h ----------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/source/Plugins/Process/Linux/NativeProcessLinux.cpp index a22879825898..13fd4dbfee59 100644 --- a/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1,37 +1,30 @@ //===-- NativeProcessLinux.cpp -------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "NativeProcessLinux.h" -// C Includes #include #include #include #include -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Host/ThreadLauncher.h" -#include "lldb/Host/common/NativeBreakpoint.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/linux/Ptrace.h" #include "lldb/Host/linux/Uio.h" @@ -41,6 +34,8 @@ #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StringExtractor.h" #include "llvm/Support/Errno.h" @@ -49,6 +44,7 @@ #include "NativeThreadLinux.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" +#include "Plugins/Process/Utility/LinuxProcMaps.h" #include "Procfs.h" #include @@ -759,9 +755,7 @@ void NativeProcessLinux::MonitorBreakpoint(NativeThreadLinux &thread) { // Mark the thread as stopped at breakpoint. thread.SetStoppedByBreakpoint(); - Status error = FixupBreakpointPCAsNeeded(thread); - if (error.Fail()) - LLDB_LOG(log, "pid = {0} fixup: {1}", thread.GetID(), error); + FixupBreakpointPCAsNeeded(thread); if (m_threads_stepping_with_breakpoint.find(thread.GetID()) != m_threads_stepping_with_breakpoint.end()) @@ -1238,90 +1232,6 @@ Status NativeProcessLinux::Kill() { return error; } -static Status -ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line, - MemoryRegionInfo &memory_region_info) { - memory_region_info.Clear(); - - StringExtractor line_extractor(maps_line); - - // Format: {address_start_hex}-{address_end_hex} perms offset dev inode - // pathname perms: rwxp (letter is present if set, '-' if not, final - // character is p=private, s=shared). - - // Parse out the starting address - lldb::addr_t start_address = line_extractor.GetHexMaxU64(false, 0); - - // Parse out hyphen separating start and end address from range. - if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != '-')) - return Status( - "malformed /proc/{pid}/maps entry, missing dash between address range"); - - // Parse out the ending address - lldb::addr_t end_address = line_extractor.GetHexMaxU64(false, start_address); - - // Parse out the space after the address. - if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != ' ')) - return Status( - "malformed /proc/{pid}/maps entry, missing space after range"); - - // Save the range. - memory_region_info.GetRange().SetRangeBase(start_address); - memory_region_info.GetRange().SetRangeEnd(end_address); - - // Any memory region in /proc/{pid}/maps is by definition mapped into the - // process. - memory_region_info.SetMapped(MemoryRegionInfo::OptionalBool::eYes); - - // Parse out each permission entry. - if (line_extractor.GetBytesLeft() < 4) - return Status("malformed /proc/{pid}/maps entry, missing some portion of " - "permissions"); - - // Handle read permission. - const char read_perm_char = line_extractor.GetChar(); - if (read_perm_char == 'r') - memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eYes); - else if (read_perm_char == '-') - memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo); - else - return Status("unexpected /proc/{pid}/maps read permission char"); - - // Handle write permission. - const char write_perm_char = line_extractor.GetChar(); - if (write_perm_char == 'w') - memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eYes); - else if (write_perm_char == '-') - memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo); - else - return Status("unexpected /proc/{pid}/maps write permission char"); - - // Handle execute permission. - const char exec_perm_char = line_extractor.GetChar(); - if (exec_perm_char == 'x') - memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eYes); - else if (exec_perm_char == '-') - memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo); - else - return Status("unexpected /proc/{pid}/maps exec permission char"); - - line_extractor.GetChar(); // Read the private bit - line_extractor.SkipSpaces(); // Skip the separator - line_extractor.GetHexMaxU64(false, 0); // Read the offset - line_extractor.GetHexMaxU64(false, 0); // Read the major device number - line_extractor.GetChar(); // Read the device id separator - line_extractor.GetHexMaxU64(false, 0); // Read the major device number - line_extractor.SkipSpaces(); // Skip the separator - line_extractor.GetU64(0, 10); // Read the inode number - - line_extractor.SkipSpaces(); - const char *name = line_extractor.Peek(); - if (name) - memory_region_info.SetName(name); - - return Status(); -} - Status NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { // FIXME review that the final memory region returned extends to the end of @@ -1407,22 +1317,23 @@ Status NativeProcessLinux::PopulateMemoryRegionCache() { m_supports_mem_region = LazyBool::eLazyBoolNo; return BufferOrError.getError(); } - StringRef Rest = BufferOrError.get()->getBuffer(); - while (! Rest.empty()) { - StringRef Line; - std::tie(Line, Rest) = Rest.split('\n'); - MemoryRegionInfo info; - const Status parse_error = - ParseMemoryRegionInfoFromProcMapsLine(Line, info); - if (parse_error.Fail()) { - LLDB_LOG(log, "failed to parse proc maps line '{0}': {1}", Line, - parse_error); - m_supports_mem_region = LazyBool::eLazyBoolNo; - return parse_error; - } - m_mem_region_cache.emplace_back( - info, FileSpec(info.GetName().GetCString(), true)); - } + Status Result; + ParseLinuxMapRegions(BufferOrError.get()->getBuffer(), + [&](const MemoryRegionInfo &Info, const Status &ST) { + if (ST.Success()) { + FileSpec file_spec(Info.GetName().GetCString()); + FileSystem::Instance().Resolve(file_spec); + m_mem_region_cache.emplace_back(Info, file_spec); + return true; + } else { + m_supports_mem_region = LazyBool::eLazyBoolNo; + LLDB_LOG(log, "failed to parse proc maps: {0}", ST); + Result = ST; + return false; + } + }); + if (Result.Fail()) + return Result; if (m_mem_region_cache.empty()) { // No entries after attempting to read them. This shouldn't happen if @@ -1502,40 +1413,6 @@ size_t NativeProcessLinux::UpdateThreads() { return m_threads.size(); } -Status NativeProcessLinux::GetSoftwareBreakpointPCOffset( - uint32_t &actual_opcode_size) { - // FIXME put this behind a breakpoint protocol class that can be - // set per architecture. Need ARM, MIPS support here. - static const uint8_t g_i386_opcode[] = {0xCC}; - static const uint8_t g_s390x_opcode[] = {0x00, 0x01}; - - switch (m_arch.GetMachine()) { - case llvm::Triple::x86: - case llvm::Triple::x86_64: - actual_opcode_size = static_cast(sizeof(g_i386_opcode)); - return Status(); - - case llvm::Triple::systemz: - actual_opcode_size = static_cast(sizeof(g_s390x_opcode)); - return Status(); - - case llvm::Triple::arm: - case llvm::Triple::aarch64: - case llvm::Triple::mips64: - case llvm::Triple::mips64el: - case llvm::Triple::mips: - case llvm::Triple::mipsel: - case llvm::Triple::ppc64le: - // On these architectures the PC don't get updated for breakpoint hits - actual_opcode_size = 0; - return Status(); - - default: - assert(false && "CPU type not supported!"); - return Status("CPU type not supported"); - } -} - Status NativeProcessLinux::SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) { if (hardware) @@ -1551,74 +1428,26 @@ Status NativeProcessLinux::RemoveBreakpoint(lldb::addr_t addr, bool hardware) { return NativeProcessProtocol::RemoveBreakpoint(addr); } -Status NativeProcessLinux::GetSoftwareBreakpointTrapOpcode( - size_t trap_opcode_size_hint, size_t &actual_opcode_size, - const uint8_t *&trap_opcode_bytes) { - // FIXME put this behind a breakpoint protocol class that can be set per - // architecture. Need MIPS support here. - static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x20, 0xd4}; +llvm::Expected> +NativeProcessLinux::GetSoftwareBreakpointTrapOpcode(size_t size_hint) { // The ARM reference recommends the use of 0xe7fddefe and 0xdefe but the // linux kernel does otherwise. - static const uint8_t g_arm_breakpoint_opcode[] = {0xf0, 0x01, 0xf0, 0xe7}; - static const uint8_t g_i386_opcode[] = {0xCC}; - static const uint8_t g_mips64_opcode[] = {0x00, 0x00, 0x00, 0x0d}; - static const uint8_t g_mips64el_opcode[] = {0x0d, 0x00, 0x00, 0x00}; - static const uint8_t g_s390x_opcode[] = {0x00, 0x01}; - static const uint8_t g_thumb_breakpoint_opcode[] = {0x01, 0xde}; - static const uint8_t g_ppc64le_opcode[] = {0x08, 0x00, 0xe0, 0x7f}; // trap - - switch (m_arch.GetMachine()) { - case llvm::Triple::aarch64: - trap_opcode_bytes = g_aarch64_opcode; - actual_opcode_size = sizeof(g_aarch64_opcode); - return Status(); + static const uint8_t g_arm_opcode[] = {0xf0, 0x01, 0xf0, 0xe7}; + static const uint8_t g_thumb_opcode[] = {0x01, 0xde}; + switch (GetArchitecture().GetMachine()) { case llvm::Triple::arm: - switch (trap_opcode_size_hint) { + switch (size_hint) { case 2: - trap_opcode_bytes = g_thumb_breakpoint_opcode; - actual_opcode_size = sizeof(g_thumb_breakpoint_opcode); - return Status(); + return llvm::makeArrayRef(g_thumb_opcode); case 4: - trap_opcode_bytes = g_arm_breakpoint_opcode; - actual_opcode_size = sizeof(g_arm_breakpoint_opcode); - return Status(); + return llvm::makeArrayRef(g_arm_opcode); default: - assert(false && "Unrecognised trap opcode size hint!"); - return Status("Unrecognised trap opcode size hint!"); + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Unrecognised trap opcode size hint!"); } - - case llvm::Triple::x86: - case llvm::Triple::x86_64: - trap_opcode_bytes = g_i386_opcode; - actual_opcode_size = sizeof(g_i386_opcode); - return Status(); - - case llvm::Triple::mips: - case llvm::Triple::mips64: - trap_opcode_bytes = g_mips64_opcode; - actual_opcode_size = sizeof(g_mips64_opcode); - return Status(); - - case llvm::Triple::mipsel: - case llvm::Triple::mips64el: - trap_opcode_bytes = g_mips64el_opcode; - actual_opcode_size = sizeof(g_mips64el_opcode); - return Status(); - - case llvm::Triple::systemz: - trap_opcode_bytes = g_s390x_opcode; - actual_opcode_size = sizeof(g_s390x_opcode); - return Status(); - - case llvm::Triple::ppc64le: - trap_opcode_bytes = g_ppc64le_opcode; - actual_opcode_size = sizeof(g_ppc64le_opcode); - return Status(); - default: - assert(false && "CPU type not supported!"); - return Status("CPU type not supported"); + return NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode(size_hint); } } @@ -1677,15 +1506,6 @@ Status NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size, return Status(); } -Status NativeProcessLinux::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, - size_t size, - size_t &bytes_read) { - Status error = ReadMemory(addr, buf, size, bytes_read); - if (error.Fail()) - return error; - return m_breakpoint_list.RemoveTrapsFromBuffer(addr, buf, size); -} - Status NativeProcessLinux::WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) { const unsigned char *src = static_cast(buf); @@ -1810,90 +1630,14 @@ NativeThreadLinux &NativeProcessLinux::AddThread(lldb::tid_t thread_id) { return static_cast(*m_threads.back()); } -Status -NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); - - Status error; - - // Find out the size of a breakpoint (might depend on where we are in the - // code). - NativeRegisterContext &context = thread.GetRegisterContext(); - - uint32_t breakpoint_size = 0; - error = GetSoftwareBreakpointPCOffset(breakpoint_size); - if (error.Fail()) { - LLDB_LOG(log, "GetBreakpointSize() failed: {0}", error); - return error; - } else - LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size); - - // First try probing for a breakpoint at a software breakpoint location: PC - - // breakpoint size. - const lldb::addr_t initial_pc_addr = context.GetPCfromBreakpointLocation(); - lldb::addr_t breakpoint_addr = initial_pc_addr; - if (breakpoint_size > 0) { - // Do not allow breakpoint probe to wrap around. - if (breakpoint_addr >= breakpoint_size) - breakpoint_addr -= breakpoint_size; - } - - // Check if we stopped because of a breakpoint. - NativeBreakpointSP breakpoint_sp; - error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp); - if (!error.Success() || !breakpoint_sp) { - // We didn't find one at a software probe location. Nothing to do. - LLDB_LOG(log, - "pid {0} no lldb breakpoint found at current pc with " - "adjustment: {1}", - GetID(), breakpoint_addr); - return Status(); - } - - // If the breakpoint is not a software breakpoint, nothing to do. - if (!breakpoint_sp->IsSoftwareBreakpoint()) { - LLDB_LOG( - log, - "pid {0} breakpoint found at {1:x}, not software, nothing to adjust", - GetID(), breakpoint_addr); - return Status(); - } - - // - // We have a software breakpoint and need to adjust the PC. - // - - // Sanity check. - if (breakpoint_size == 0) { - // Nothing to do! How did we get here? - LLDB_LOG(log, - "pid {0} breakpoint found at {1:x}, it is software, but the " - "size is zero, nothing to do (unexpected)", - GetID(), breakpoint_addr); - return Status(); - } - - // Change the program counter. - LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(), - thread.GetID(), initial_pc_addr, breakpoint_addr); - - error = context.SetPC(breakpoint_addr); - if (error.Fail()) { - LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(), - thread.GetID(), error); - return error; - } - - return error; -} - Status NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) { Status error = PopulateMemoryRegionCache(); if (error.Fail()) return error; - FileSpec module_file_spec(module_path, true); + FileSpec module_file_spec(module_path); + FileSystem::Instance().Resolve(module_file_spec); file_spec.Clear(); for (const auto &it : m_mem_region_cache) { @@ -1913,7 +1657,7 @@ Status NativeProcessLinux::GetFileLoadAddress(const llvm::StringRef &file_name, if (error.Fail()) return error; - FileSpec file(file_name, false); + FileSpec file(file_name); for (const auto &it : m_mem_region_cache) { if (it.second == file) { load_addr = it.first.GetRange().GetRangeBase(); diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.h b/source/Plugins/Process/Linux/NativeProcessLinux.h index 1c2f786e8d69..184d051fd984 100644 --- a/source/Plugins/Process/Linux/NativeProcessLinux.h +++ b/source/Plugins/Process/Linux/NativeProcessLinux.h @@ -1,9 +1,8 @@ //===-- NativeProcessLinux.h ---------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -71,9 +70,6 @@ class NativeProcessLinux : public NativeProcessProtocol { Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; - Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read) override; - Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override; @@ -134,13 +130,8 @@ class NativeProcessLinux : public NativeProcessProtocol { bool SupportHardwareSingleStepping() const; protected: - // --------------------------------------------------------------------- - // NativeProcessProtocol protected interface - // --------------------------------------------------------------------- - Status - GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, - size_t &actual_opcode_size, - const uint8_t *&trap_opcode_bytes) override; + llvm::Expected> + GetSoftwareBreakpointTrapOpcode(size_t size_hint) override; private: MainLoop::SignalHandleUP m_sigchld_handle; @@ -190,10 +181,6 @@ class NativeProcessLinux : public NativeProcessProtocol { NativeThreadLinux &AddThread(lldb::tid_t thread_id); - Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); - - Status FixupBreakpointPCAsNeeded(NativeThreadLinux &thread); - /// Writes a siginfo_t structure corresponding to the given thread ID to the /// memory region pointed to by @p siginfo. Status GetSignalInfo(lldb::tid_t tid, void *siginfo); diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp index c8a8355f9cb9..2f2ade093c10 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp @@ -1,18 +1,17 @@ //===-- NativeRegisterContextLinux.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "NativeRegisterContextLinux.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeThreadProtocol.h" #include "lldb/Host/linux/Ptrace.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux.h index 2cea497b53bc..10f47ee0a186 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp index 749291684620..3c6e0142de74 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_arm.cpp --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,9 @@ #include "Plugins/Process/Linux/Procfs.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h index d0b068550a9e..b7d77403ba59 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_arm.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index d0e84d0926a7..d4751156497c 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_arm64.cpp --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,14 +11,11 @@ #include "NativeRegisterContextLinux_arm64.h" #include "NativeRegisterContextLinux_arm.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h index c859d4249d05..57af505db94d 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_arm64.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp index 69194b3c0663..3f5210adc49d 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_mips64.cpp ---------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,22 +10,19 @@ #include "NativeRegisterContextLinux_mips64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "Plugins/Process/Linux/NativeProcessLinux.h" #include "Plugins/Process/Linux/Procfs.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "Plugins/Process/Utility/RegisterContextLinux_mips.h" #include "Plugins/Process/Utility/RegisterContextLinux_mips64.h" #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-enumerations.h" diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h index c4e984a545bc..5465b84827f4 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_mips64.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp index 6aa4af64ab51..697f6f4891b0 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_ppc64le.cpp ------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,10 +13,10 @@ #include "NativeRegisterContextLinux_ppc64le.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.h index 2c4471962ad0..ff3a740b99aa 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_ppc64le.h --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp index 36da2b001054..f5565893c10d 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_s390x.cpp --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #include "NativeRegisterContextLinux_s390x.h" #include "Plugins/Process/Linux/NativeProcessLinux.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h" diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h index 57b1a0481512..33fe9a68e5d4 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_s390x.h ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp index 87f4b8da053e..4963c52ecee9 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_x86_64.cpp ---------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #include "NativeRegisterContextLinux_x86_64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h index 9dcf82f50a45..25a73db48f40 100644 --- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h +++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextLinux_x86_64.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/source/Plugins/Process/Linux/NativeThreadLinux.cpp index 4ab2a9ae6245..287a271689a4 100644 --- a/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -1,9 +1,8 @@ //===-- NativeThreadLinux.cpp --------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,12 +15,12 @@ #include "NativeRegisterContextLinux.h" #include "SingleStepCheck.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostNativeThread.h" #include "lldb/Host/linux/Ptrace.h" #include "lldb/Host/linux/Support.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/SmallString.h" diff --git a/source/Plugins/Process/Linux/NativeThreadLinux.h b/source/Plugins/Process/Linux/NativeThreadLinux.h index a7c4e982012d..84480d362752 100644 --- a/source/Plugins/Process/Linux/NativeThreadLinux.h +++ b/source/Plugins/Process/Linux/NativeThreadLinux.h @@ -1,9 +1,8 @@ //===-- NativeThreadLinux.h ----------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/ProcessorTrace.cpp b/source/Plugins/Process/Linux/ProcessorTrace.cpp index 505c526ab70d..749a765731b6 100644 --- a/source/Plugins/Process/Linux/ProcessorTrace.cpp +++ b/source/Plugins/Process/Linux/ProcessorTrace.cpp @@ -1,9 +1,8 @@ //===-- ProcessorTrace.cpp ------------------------------------ -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/ProcessorTrace.h b/source/Plugins/Process/Linux/ProcessorTrace.h index 6fd918c2bb58..6078141ce775 100644 --- a/source/Plugins/Process/Linux/ProcessorTrace.h +++ b/source/Plugins/Process/Linux/ProcessorTrace.h @@ -1,9 +1,8 @@ //===-- ProcessorTrace.h -------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/Procfs.h b/source/Plugins/Process/Linux/Procfs.h index 1d9c9dbe273f..59dd76a2584c 100644 --- a/source/Plugins/Process/Linux/Procfs.h +++ b/source/Plugins/Process/Linux/Procfs.h @@ -1,9 +1,8 @@ //===-- Procfs.h ---------------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/SingleStepCheck.cpp b/source/Plugins/Process/Linux/SingleStepCheck.cpp index c57a2daf2275..01d8ef9d33a9 100644 --- a/source/Plugins/Process/Linux/SingleStepCheck.cpp +++ b/source/Plugins/Process/Linux/SingleStepCheck.cpp @@ -1,9 +1,8 @@ //===-- SingleStepCheck.cpp ----------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Linux/SingleStepCheck.h b/source/Plugins/Process/Linux/SingleStepCheck.h index afeda7310349..c55771e06aca 100644 --- a/source/Plugins/Process/Linux/SingleStepCheck.h +++ b/source/Plugins/Process/Linux/SingleStepCheck.h @@ -1,9 +1,8 @@ //===-- SingleStepCheck.h ------------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 116155d9a232..5da835d35254 100644 --- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -1,33 +1,28 @@ //===-- CommunicationKDP.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "CommunicationKDP.h" -// C Includes #include #include #include -// C++ Includes -// Other libraries and framework includes #include "lldb/Core/DumpDataExtractor.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/UUID.h" -// Project includes #include "ProcessKDPLog.h" using namespace lldb; @@ -467,19 +462,13 @@ lldb_private::UUID CommunicationKDP::GetUUID() { bool CommunicationKDP::RemoteIsEFI() { if (GetKernelVersion() == NULL) return false; - if (strncmp(m_kernel_version.c_str(), "EFI", 3) == 0) - return true; - else - return false; + return strncmp(m_kernel_version.c_str(), "EFI", 3) == 0; } bool CommunicationKDP::RemoteIsDarwinKernel() { if (GetKernelVersion() == NULL) return false; - if (m_kernel_version.find("Darwin Kernel") != std::string::npos) - return true; - else - return false; + return m_kernel_version.find("Darwin Kernel") != std::string::npos; } lldb::addr_t CommunicationKDP::GetLoadAddress() { @@ -1262,9 +1251,7 @@ bool CommunicationKDP::SendRequestResume() { request_packet.PutHex32(GetCPUMask()); DataExtractor reply_packet; - if (SendRequestAndGetReply(command, request_packet, reply_packet)) - return true; - return false; + return SendRequestAndGetReply(command, request_packet, reply_packet); } bool CommunicationKDP::SendRequestBreakpoint(bool set, addr_t addr) { @@ -1297,7 +1284,5 @@ bool CommunicationKDP::SendRequestSuspend() { const uint32_t command_length = 8; MakeRequestPacketHeader(command, request_packet, command_length); DataExtractor reply_packet; - if (SendRequestAndGetReply(command, request_packet, reply_packet)) - return true; - return false; + return SendRequestAndGetReply(command, request_packet, reply_packet); } diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h index afac6601a56b..b5aa146ac39a 100644 --- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h +++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h @@ -1,27 +1,22 @@ //===-- CommunicationKDP.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_CommunicationKDP_h_ #define liblldb_CommunicationKDP_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Communication.h" -#include "lldb/Core/Listener.h" #include "lldb/Core/StreamBuffer.h" -#include "lldb/Host/Predicate.h" +#include "lldb/Utility/Listener.h" +#include "lldb/Utility/Predicate.h" #include "lldb/lldb-private.h" class CommunicationKDP : public lldb_private::Communication { diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index c0ac349b1597..c9ac78997cb8 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -1,26 +1,20 @@ //===-- ProcessKDP.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include -// C++ Includes #include -// Other libraries and framework includes #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" -#include "lldb/Utility/UUID.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Host.h" #include "lldb/Host/Symbols.h" @@ -37,13 +31,14 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StringExtractor.h" +#include "lldb/Utility/UUID.h" #include "llvm/Support/Threading.h" #define USEC_PER_SEC 1000000 -// Project includes #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" #include "ProcessKDP.h" @@ -300,7 +295,8 @@ Status ProcessKDP::DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { if (module_spec.GetSymbolFileSpec()) { ModuleSpec executable_module_spec = Symbols::LocateExecutableObjectFile(module_spec); - if (executable_module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists( + executable_module_spec.GetFileSpec())) { module_spec.GetFileSpec() = executable_module_spec.GetFileSpec(); } @@ -309,7 +305,7 @@ Status ProcessKDP::DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { !module_spec.GetSymbolFileSpec()) Symbols::DownloadObjectAndSymbolFile(module_spec, true); - if (module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) { ModuleSP module_sp(new Module(module_spec)); if (module_sp.get() && module_sp->GetObjectFile()) { // Get the current target executable diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h index b4eae58af83c..31de54c46651 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h @@ -1,28 +1,24 @@ //===-- ProcessKDP.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessKDP_h_ #define liblldb_ProcessKDP_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Host/HostThread.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp index ffab3e5e23c7..96d2921747af 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp @@ -1,9 +1,8 @@ //===-- ProcessKDPLog.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h index 908754ec992b..c22dd980b6ec 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h @@ -1,9 +1,8 @@ //===-- ProcessKDPLog.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp index 159a046b617d..da6e0f5c5044 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp @@ -1,18 +1,13 @@ //===-- RegisterContextKDP_arm.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextKDP_arm.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "ProcessKDP.h" #include "ThreadKDP.h" diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h index fe02b0648221..e31da42121b6 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h @@ -1,20 +1,15 @@ //===-- RegisterContextKDP_arm.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextKDP_arm_h_ #define liblldb_RegisterContextKDP_arm_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/RegisterContextDarwin_arm.h" class ThreadKDP; diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp index 44534a252568..f83498606121 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp @@ -1,19 +1,14 @@ //===-- RegisterContextKDP_arm64.cpp ------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextKDP_arm64.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "ProcessKDP.h" #include "ThreadKDP.h" diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h index 0922654de2cc..29dfc6789e82 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h @@ -1,21 +1,16 @@ //===-- RegisterContextKDP_arm64.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextKDP_arm64_h_ #define liblldb_RegisterContextKDP_arm64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/RegisterContextDarwin_arm64.h" class ThreadKDP; diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp index e48232ad8dda..7cb057d33f89 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp @@ -1,16 +1,11 @@ //===-- RegisterContextKDP_i386.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextKDP_i386.h" #include "ProcessKDP.h" #include "ThreadKDP.h" diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h index 5803670a08b4..fd48fbd19481 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h @@ -1,19 +1,14 @@ //===-- RegisterContextKDP_i386.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextKDP_i386_h_ #define liblldb_RegisterContextKDP_i386_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/RegisterContextDarwin_i386.h" class ThreadKDP; diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp index 50e11f381925..701c160dd95a 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp @@ -1,16 +1,11 @@ //===-- RegisterContextKDP_x86_64.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextKDP_x86_64.h" #include "ProcessKDP.h" #include "ThreadKDP.h" diff --git a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h index 7a40bb626385..79623095b631 100644 --- a/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h +++ b/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h @@ -1,19 +1,14 @@ //===-- RegisterContextKDP_x86_64.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextKDP_x86_64_h_ #define liblldb_RegisterContextKDP_x86_64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/RegisterContextDarwin_x86_64.h" class ThreadKDP; diff --git a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index 7fca0fc24fdb..d0e78a8e74da 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -1,18 +1,16 @@ //===-- ThreadKDP.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ThreadKDP.h" -#include "lldb/Utility/SafeMachO.h" +#include "lldb/Host/SafeMachO.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" @@ -20,6 +18,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "Plugins/Process/Utility/StopInfoMachException.h" diff --git a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h index ea517b4254fc..e7330f223ff4 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h +++ b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h @@ -1,9 +1,8 @@ //===-- ThreadKDP.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/NetBSD/CMakeLists.txt b/source/Plugins/Process/NetBSD/CMakeLists.txt index 92a6014ced07..586725bb7a56 100644 --- a/source/Plugins/Process/NetBSD/CMakeLists.txt +++ b/source/Plugins/Process/NetBSD/CMakeLists.txt @@ -5,13 +5,13 @@ add_lldb_library(lldbPluginProcessNetBSD PLUGIN NativeThreadNetBSD.cpp LINK_LIBS - lldbCore lldbHost lldbSymbol lldbTarget lldbUtility lldbPluginProcessPOSIX lldbPluginProcessUtility + util LINK_COMPONENTS Support ) diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp index 1a4cb21d000e..b0ae54841b19 100644 --- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -1,26 +1,21 @@ //===-- NativeProcessNetBSD.cpp ------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "NativeProcessNetBSD.h" -// C Includes -// C++ Includes -// Other libraries and framework includes #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostProcess.h" -#include "lldb/Host/common/NativeBreakpoint.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/posix/ProcessLauncherPosixFork.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/State.h" #include "llvm/Support/Errno.h" // System includes - They have to be included after framework includes because @@ -322,100 +317,6 @@ Status NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr, return error; } -Status NativeProcessNetBSD::GetSoftwareBreakpointPCOffset( - uint32_t &actual_opcode_size) { - // FIXME put this behind a breakpoint protocol class that can be - // set per architecture. Need ARM, MIPS support here. - static const uint8_t g_i386_opcode[] = {0xCC}; - switch (m_arch.GetMachine()) { - case llvm::Triple::x86_64: - actual_opcode_size = static_cast(sizeof(g_i386_opcode)); - return Status(); - default: - assert(false && "CPU type not supported!"); - return Status("CPU type not supported"); - } -} - -Status -NativeProcessNetBSD::FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread) { - Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS)); - Status error; - // Find out the size of a breakpoint (might depend on where we are in the - // code). - NativeRegisterContext& context = thread.GetRegisterContext(); - uint32_t breakpoint_size = 0; - error = GetSoftwareBreakpointPCOffset(breakpoint_size); - if (error.Fail()) { - LLDB_LOG(log, "GetBreakpointSize() failed: {0}", error); - return error; - } else - LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size); - // First try probing for a breakpoint at a software breakpoint location: PC - - // breakpoint size. - const lldb::addr_t initial_pc_addr = - context.GetPCfromBreakpointLocation(); - lldb::addr_t breakpoint_addr = initial_pc_addr; - if (breakpoint_size > 0) { - // Do not allow breakpoint probe to wrap around. - if (breakpoint_addr >= breakpoint_size) - breakpoint_addr -= breakpoint_size; - } - // Check if we stopped because of a breakpoint. - NativeBreakpointSP breakpoint_sp; - error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp); - if (!error.Success() || !breakpoint_sp) { - // We didn't find one at a software probe location. Nothing to do. - LLDB_LOG(log, - "pid {0} no lldb breakpoint found at current pc with " - "adjustment: {1}", - GetID(), breakpoint_addr); - return Status(); - } - // If the breakpoint is not a software breakpoint, nothing to do. - if (!breakpoint_sp->IsSoftwareBreakpoint()) { - LLDB_LOG( - log, - "pid {0} breakpoint found at {1:x}, not software, nothing to adjust", - GetID(), breakpoint_addr); - return Status(); - } - // - // We have a software breakpoint and need to adjust the PC. - // - // Sanity check. - if (breakpoint_size == 0) { - // Nothing to do! How did we get here? - LLDB_LOG(log, - "pid {0} breakpoint found at {1:x}, it is software, but the " - "size is zero, nothing to do (unexpected)", - GetID(), breakpoint_addr); - return Status(); - } - // - // We have a software breakpoint and need to adjust the PC. - // - // Sanity check. - if (breakpoint_size == 0) { - // Nothing to do! How did we get here? - LLDB_LOG(log, - "pid {0} breakpoint found at {1:x}, it is software, but the " - "size is zero, nothing to do (unexpected)", - GetID(), breakpoint_addr); - return Status(); - } - // Change the program counter. - LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(), - thread.GetID(), initial_pc_addr, breakpoint_addr); - error = context.SetPC(breakpoint_addr); - if (error.Fail()) { - LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(), - thread.GetID(), error); - return error; - } - return error; -} - Status NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) { Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS)); LLDB_LOG(log, "pid {0}", GetID()); @@ -637,7 +538,7 @@ Status NativeProcessNetBSD::PopulateMemoryRegionCache() { info.SetName(vm[i].kve_path); m_mem_region_cache.emplace_back( - info, FileSpec(info.GetName().GetCString(), true)); + info, FileSpec(info.GetName().GetCString())); } free(vm); @@ -682,23 +583,6 @@ Status NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size, return SetSoftwareBreakpoint(addr, size); } -Status NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode( - size_t trap_opcode_size_hint, size_t &actual_opcode_size, - const uint8_t *&trap_opcode_bytes) { - static const uint8_t g_i386_opcode[] = {0xCC}; - - switch (m_arch.GetMachine()) { - case llvm::Triple::x86: - case llvm::Triple::x86_64: - trap_opcode_bytes = g_i386_opcode; - actual_opcode_size = sizeof(g_i386_opcode); - return Status(); - default: - assert(false && "CPU type not supported!"); - return Status("CPU type not supported"); - } -} - Status NativeProcessNetBSD::GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) { return Status("Unimplemented"); @@ -824,15 +708,6 @@ Status NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, return Status(); } -Status NativeProcessNetBSD::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, - size_t size, - size_t &bytes_read) { - Status error = ReadMemory(addr, buf, size, bytes_read); - if (error.Fail()) - return error; - return m_breakpoint_list.RemoveTrapsFromBuffer(addr, buf, size); -} - Status NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) { const unsigned char *src = static_cast(buf); diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h index 142f74ecf194..50c299a74ac6 100644 --- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h +++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h @@ -1,9 +1,8 @@ //===-- NativeProcessNetBSD.h --------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -58,9 +57,6 @@ class NativeProcessNetBSD : public NativeProcessProtocol { Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; - Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, - size_t &bytes_read) override; - Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override; @@ -93,16 +89,6 @@ class NativeProcessNetBSD : public NativeProcessProtocol { static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr, int data = 0, int *result = nullptr); -protected: - // --------------------------------------------------------------------- - // NativeProcessProtocol protected interface - // --------------------------------------------------------------------- - - Status - GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, - size_t &actual_opcode_size, - const uint8_t *&trap_opcode_bytes) override; - private: MainLoop::SignalHandleUP m_sigchld_handle; ArchSpec m_arch; @@ -125,8 +111,6 @@ class NativeProcessNetBSD : public NativeProcessProtocol { void MonitorSIGTRAP(lldb::pid_t pid); void MonitorSignal(lldb::pid_t pid, int signal); - Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size); - Status FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread); Status PopulateMemoryRegionCache(); void SigchldHandler(); diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp index d4fef6342439..2e3f18e1b684 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextNetBSD.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h index b81430e7f5ac..8b91e06e8f26 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextNetBSD.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp index 16b6f2c52dd5..8c8e265aa4d8 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextNetBSD_x86_64.cpp ---------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,10 +10,10 @@ #include "NativeRegisterContextNetBSD_x86_64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h" diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h index c55ddfec6615..2eb754b4e591 100644 --- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h +++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextNetBSD_x86_64.h --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp index 83f1da78d01d..e25975c93446 100644 --- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp +++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp @@ -1,9 +1,8 @@ //===-- NativeThreadNetBSD.cpp -------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,9 @@ #include "Plugins/Process/POSIX/CrashReason.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h index 72426244c112..01d169d661a5 100644 --- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h +++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h @@ -1,9 +1,8 @@ //===-- NativeThreadNetBSD.h ---------------------------------- -*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/POSIX/CrashReason.cpp b/source/Plugins/Process/POSIX/CrashReason.cpp index 4b24d31226a9..70c2687e3b8c 100644 --- a/source/Plugins/Process/POSIX/CrashReason.cpp +++ b/source/Plugins/Process/POSIX/CrashReason.cpp @@ -1,9 +1,8 @@ //===-- CrashReason.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/POSIX/CrashReason.h b/source/Plugins/Process/POSIX/CrashReason.h index 57abe47b46b2..9b4784a1e68e 100644 --- a/source/Plugins/Process/POSIX/CrashReason.h +++ b/source/Plugins/Process/POSIX/CrashReason.h @@ -1,9 +1,8 @@ //===-- CrashReason.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/POSIX/ProcessMessage.cpp b/source/Plugins/Process/POSIX/ProcessMessage.cpp index 48f2a7844cf7..3dde2f439431 100644 --- a/source/Plugins/Process/POSIX/ProcessMessage.cpp +++ b/source/Plugins/Process/POSIX/ProcessMessage.cpp @@ -1,9 +1,8 @@ //===-- ProcessMessage.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/POSIX/ProcessMessage.h b/source/Plugins/Process/POSIX/ProcessMessage.h index 3c596ca68549..c3d8e95a6c43 100644 --- a/source/Plugins/Process/POSIX/ProcessMessage.h +++ b/source/Plugins/Process/POSIX/ProcessMessage.h @@ -1,9 +1,8 @@ //===-- ProcessMessage.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp index f1beb0f7f738..a17558bfe7c6 100644 --- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp +++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp @@ -1,10 +1,9 @@ //===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h index 134013517a11..c0147c43410f 100644 --- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h +++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h @@ -1,21 +1,16 @@ //===-- ProcessPOSIXLog.h -----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessPOSIXLog_h_ #define liblldb_ProcessPOSIXLog_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Log.h" #define POSIX_LOG_PROCESS (1u << 1) diff --git a/source/Plugins/Process/Utility/ARMDefines.h b/source/Plugins/Process/Utility/ARMDefines.h index 84c2cf19be7b..a47329a2214a 100644 --- a/source/Plugins/Process/Utility/ARMDefines.h +++ b/source/Plugins/Process/Utility/ARMDefines.h @@ -1,9 +1,8 @@ //===-- lldb_ARMDefines.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/ARMUtils.h b/source/Plugins/Process/Utility/ARMUtils.h index 2bbd519b246a..d860348818d3 100644 --- a/source/Plugins/Process/Utility/ARMUtils.h +++ b/source/Plugins/Process/Utility/ARMUtils.h @@ -1,9 +1,8 @@ //===-- ARMUtils.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,7 +11,7 @@ #include "ARMDefines.h" #include "InstructionUtils.h" -#include "llvm/Support/MathExtras.h" // for SignExtend64 template function +#include "llvm/Support/MathExtras.h" // Common utilities for the ARM/Thumb Instruction Set Architecture. diff --git a/source/Plugins/Process/Utility/CMakeLists.txt b/source/Plugins/Process/Utility/CMakeLists.txt index b43756acea63..e36ce4dec98a 100644 --- a/source/Plugins/Process/Utility/CMakeLists.txt +++ b/source/Plugins/Process/Utility/CMakeLists.txt @@ -5,6 +5,7 @@ add_lldb_library(lldbPluginProcessUtility PLUGIN HistoryThread.cpp HistoryUnwind.cpp InferiorCallPOSIX.cpp + LinuxProcMaps.cpp LinuxSignals.cpp MipsLinuxSignals.cpp NativeRegisterContextRegisterInfo.cpp diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp index 5f34e9915ede..63348c3b7d6d 100644 --- a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp +++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp @@ -1,9 +1,8 @@ //===-- DynamicRegisterInfo.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -464,7 +463,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { end = m_value_regs_map.end(); pos != end; ++pos) { if (pos->second.size() > 1) { - std::sort(pos->second.begin(), pos->second.end()); + llvm::sort(pos->second.begin(), pos->second.end()); reg_num_collection::iterator unique_end = std::unique(pos->second.begin(), pos->second.end()); if (unique_end != pos->second.end()) @@ -514,7 +513,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { end = m_invalidate_regs_map.end(); pos != end; ++pos) { if (pos->second.size() > 1) { - std::sort(pos->second.begin(), pos->second.end()); + llvm::sort(pos->second.begin(), pos->second.end()); reg_num_collection::iterator unique_end = std::unique(pos->second.begin(), pos->second.end()); if (unique_end != pos->second.end()) diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.h b/source/Plugins/Process/Utility/DynamicRegisterInfo.h index acb3e3eb8a84..e78da95e1b91 100644 --- a/source/Plugins/Process/Utility/DynamicRegisterInfo.h +++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.h @@ -1,22 +1,17 @@ //===-- DynamicRegisterInfo.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_DynamicRegisterInfo_h_ #define lldb_DynamicRegisterInfo_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/FreeBSDSignals.cpp b/source/Plugins/Process/Utility/FreeBSDSignals.cpp index f695a11c9759..9f63a594e054 100644 --- a/source/Plugins/Process/Utility/FreeBSDSignals.cpp +++ b/source/Plugins/Process/Utility/FreeBSDSignals.cpp @@ -1,16 +1,11 @@ //===-- FreeBSDSignals.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "FreeBSDSignals.h" using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/FreeBSDSignals.h b/source/Plugins/Process/Utility/FreeBSDSignals.h index 8ec96e824f7a..75462f3c76ff 100644 --- a/source/Plugins/Process/Utility/FreeBSDSignals.h +++ b/source/Plugins/Process/Utility/FreeBSDSignals.h @@ -1,16 +1,14 @@ //===-- FreeBSDSignals.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_FreeBSDSignals_H_ #define liblldb_FreeBSDSignals_H_ -// Project includes #include "lldb/Target/UnixSignals.h" namespace lldb_private { diff --git a/source/Plugins/Process/Utility/GDBRemoteSignals.cpp b/source/Plugins/Process/Utility/GDBRemoteSignals.cpp index abcc8a38669a..ed35273ce3fe 100644 --- a/source/Plugins/Process/Utility/GDBRemoteSignals.cpp +++ b/source/Plugins/Process/Utility/GDBRemoteSignals.cpp @@ -1,15 +1,11 @@ //===-- GDBRemoteSignals.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C++ Includes -// Other libraries and framework includes -// Project includes #include "GDBRemoteSignals.h" using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/GDBRemoteSignals.h b/source/Plugins/Process/Utility/GDBRemoteSignals.h index 5900fa75d6f2..a02dd0604e67 100644 --- a/source/Plugins/Process/Utility/GDBRemoteSignals.h +++ b/source/Plugins/Process/Utility/GDBRemoteSignals.h @@ -1,19 +1,14 @@ //===-- GDBRemoteSignals.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_GDBRemoteSignals_H_ #define liblldb_GDBRemoteSignals_H_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/UnixSignals.h" namespace lldb_private { diff --git a/source/Plugins/Process/Utility/HistoryThread.cpp b/source/Plugins/Process/Utility/HistoryThread.cpp index 4983dcdb5142..fc3b1f158d70 100644 --- a/source/Plugins/Process/Utility/HistoryThread.cpp +++ b/source/Plugins/Process/Utility/HistoryThread.cpp @@ -1,9 +1,8 @@ //===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/HistoryThread.h b/source/Plugins/Process/Utility/HistoryThread.h index 7675a95246a7..b3c9a4b3d98e 100644 --- a/source/Plugins/Process/Utility/HistoryThread.h +++ b/source/Plugins/Process/Utility/HistoryThread.h @@ -1,27 +1,22 @@ //===-- HistoryThread.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_HistoryThread_h_ #define liblldb_HistoryThread_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" -#include "lldb/Core/Event.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackFrameList.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/HistoryUnwind.cpp b/source/Plugins/Process/Utility/HistoryUnwind.cpp index 4f0ecba613bf..71119a5c4989 100644 --- a/source/Plugins/Process/Utility/HistoryUnwind.cpp +++ b/source/Plugins/Process/Utility/HistoryUnwind.cpp @@ -1,9 +1,8 @@ //===-- HistoryUnwind.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/HistoryUnwind.h b/source/Plugins/Process/Utility/HistoryUnwind.h index 3b64e38bfaa7..543f913e8fdf 100644 --- a/source/Plugins/Process/Utility/HistoryUnwind.h +++ b/source/Plugins/Process/Utility/HistoryUnwind.h @@ -1,21 +1,16 @@ //===-- HistoryUnwind.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_HistoryUnwind_h_ #define liblldb_HistoryUnwind_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Unwind.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp index 5c51a035ec66..3b40cb322c75 100644 --- a/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp +++ b/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp @@ -1,9 +1,8 @@ //===-- InferiorCallPOSIX.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/InferiorCallPOSIX.h b/source/Plugins/Process/Utility/InferiorCallPOSIX.h index 07bde5bf09b3..04316801b351 100644 --- a/source/Plugins/Process/Utility/InferiorCallPOSIX.h +++ b/source/Plugins/Process/Utility/InferiorCallPOSIX.h @@ -1,9 +1,8 @@ //===-- InferiorCallPOSIX.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/InstructionUtils.h b/source/Plugins/Process/Utility/InstructionUtils.h index 186d525ce499..f74933e691ee 100644 --- a/source/Plugins/Process/Utility/InstructionUtils.h +++ b/source/Plugins/Process/Utility/InstructionUtils.h @@ -1,9 +1,8 @@ //===-- InstructionUtils.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/LinuxProcMaps.cpp b/source/Plugins/Process/Utility/LinuxProcMaps.cpp new file mode 100644 index 000000000000..1ba432aa542b --- /dev/null +++ b/source/Plugins/Process/Utility/LinuxProcMaps.cpp @@ -0,0 +1,112 @@ +//===-- LinuxProcMaps.cpp ---------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "LinuxProcMaps.h" +#include "llvm/ADT/StringRef.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StringExtractor.h" + +using namespace lldb_private; + +static Status +ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef maps_line, + MemoryRegionInfo &memory_region_info) { + memory_region_info.Clear(); + + StringExtractor line_extractor(maps_line); + + // Format: {address_start_hex}-{address_end_hex} perms offset dev inode + // pathname perms: rwxp (letter is present if set, '-' if not, final + // character is p=private, s=shared). + + // Parse out the starting address + lldb::addr_t start_address = line_extractor.GetHexMaxU64(false, 0); + + // Parse out hyphen separating start and end address from range. + if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != '-')) + return Status( + "malformed /proc/{pid}/maps entry, missing dash between address range"); + + // Parse out the ending address + lldb::addr_t end_address = line_extractor.GetHexMaxU64(false, start_address); + + // Parse out the space after the address. + if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != ' ')) + return Status( + "malformed /proc/{pid}/maps entry, missing space after range"); + + // Save the range. + memory_region_info.GetRange().SetRangeBase(start_address); + memory_region_info.GetRange().SetRangeEnd(end_address); + + // Any memory region in /proc/{pid}/maps is by definition mapped into the + // process. + memory_region_info.SetMapped(MemoryRegionInfo::OptionalBool::eYes); + + // Parse out each permission entry. + if (line_extractor.GetBytesLeft() < 4) + return Status("malformed /proc/{pid}/maps entry, missing some portion of " + "permissions"); + + // Handle read permission. + const char read_perm_char = line_extractor.GetChar(); + if (read_perm_char == 'r') + memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eYes); + else if (read_perm_char == '-') + memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo); + else + return Status("unexpected /proc/{pid}/maps read permission char"); + + // Handle write permission. + const char write_perm_char = line_extractor.GetChar(); + if (write_perm_char == 'w') + memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eYes); + else if (write_perm_char == '-') + memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo); + else + return Status("unexpected /proc/{pid}/maps write permission char"); + + // Handle execute permission. + const char exec_perm_char = line_extractor.GetChar(); + if (exec_perm_char == 'x') + memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eYes); + else if (exec_perm_char == '-') + memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo); + else + return Status("unexpected /proc/{pid}/maps exec permission char"); + + line_extractor.GetChar(); // Read the private bit + line_extractor.SkipSpaces(); // Skip the separator + line_extractor.GetHexMaxU64(false, 0); // Read the offset + line_extractor.GetHexMaxU64(false, 0); // Read the major device number + line_extractor.GetChar(); // Read the device id separator + line_extractor.GetHexMaxU64(false, 0); // Read the major device number + line_extractor.SkipSpaces(); // Skip the separator + line_extractor.GetU64(0, 10); // Read the inode number + + line_extractor.SkipSpaces(); + const char *name = line_extractor.Peek(); + if (name) + memory_region_info.SetName(name); + + return Status(); +} + +void lldb_private::ParseLinuxMapRegions(llvm::StringRef linux_map, + LinuxMapCallback const &callback) { + llvm::StringRef lines(linux_map); + llvm::StringRef line; + while (!lines.empty()) { + std::tie(line, lines) = lines.split('\n'); + MemoryRegionInfo region; + Status error = ParseMemoryRegionInfoFromProcMapsLine(line, region); + if (!callback(region, error)) + break; + } +} diff --git a/source/Plugins/Process/Utility/LinuxProcMaps.h b/source/Plugins/Process/Utility/LinuxProcMaps.h new file mode 100644 index 000000000000..e1f0e48ac5c9 --- /dev/null +++ b/source/Plugins/Process/Utility/LinuxProcMaps.h @@ -0,0 +1,27 @@ +//===-- LinuxProcMaps.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_LinuxProcMaps_H_ +#define liblldb_LinuxProcMaps_H_ + +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" +#include + + +namespace lldb_private { + +typedef std::function LinuxMapCallback; + +void ParseLinuxMapRegions(llvm::StringRef linux_map, + LinuxMapCallback const &callback); + +} // namespace lldb_private + +#endif // liblldb_LinuxProcMaps_H_ diff --git a/source/Plugins/Process/Utility/LinuxSignals.cpp b/source/Plugins/Process/Utility/LinuxSignals.cpp index eb01075ed133..bef47cd26307 100644 --- a/source/Plugins/Process/Utility/LinuxSignals.cpp +++ b/source/Plugins/Process/Utility/LinuxSignals.cpp @@ -1,15 +1,11 @@ //===-- LinuxSignals.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C++ Includes -// Other libraries and framework includes -// Project includes #include "LinuxSignals.h" using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/LinuxSignals.h b/source/Plugins/Process/Utility/LinuxSignals.h index e41126225cee..7ad8cfcbef68 100644 --- a/source/Plugins/Process/Utility/LinuxSignals.h +++ b/source/Plugins/Process/Utility/LinuxSignals.h @@ -1,19 +1,14 @@ //===-- LinuxSignals.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_LinuxSignals_H_ #define liblldb_LinuxSignals_H_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/UnixSignals.h" namespace lldb_private { diff --git a/source/Plugins/Process/Utility/MipsLinuxSignals.cpp b/source/Plugins/Process/Utility/MipsLinuxSignals.cpp index 36231023aa3a..d8e5426ab5a5 100644 --- a/source/Plugins/Process/Utility/MipsLinuxSignals.cpp +++ b/source/Plugins/Process/Utility/MipsLinuxSignals.cpp @@ -1,16 +1,12 @@ //===-- MipsLinuxSignals.cpp ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C++ Includes -// Other libraries and framework includes -// Project includes #include "MipsLinuxSignals.h" using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/MipsLinuxSignals.h b/source/Plugins/Process/Utility/MipsLinuxSignals.h index e48ea5943f2b..b5e3ed86f568 100644 --- a/source/Plugins/Process/Utility/MipsLinuxSignals.h +++ b/source/Plugins/Process/Utility/MipsLinuxSignals.h @@ -1,20 +1,15 @@ //===-- MipsLinuxSignals.h ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_MipsLinuxSignals_H_ #define liblldb_MipsLinuxSignals_H_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/UnixSignals.h" namespace lldb_private { diff --git a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp index 3a9d497711c0..be61cfdd7374 100644 --- a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp +++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp @@ -1,9 +1,8 @@ //===-- NativeRegisterContextRegisterInfo.cpp -------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h index 8f2e4409105f..b285c477cd96 100644 --- a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h +++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h @@ -1,9 +1,8 @@ //===-- NativeRegisterContextRegisterInfo.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/NetBSDSignals.cpp b/source/Plugins/Process/Utility/NetBSDSignals.cpp index 7ed7189d8048..29967deb7e9b 100644 --- a/source/Plugins/Process/Utility/NetBSDSignals.cpp +++ b/source/Plugins/Process/Utility/NetBSDSignals.cpp @@ -1,16 +1,11 @@ //===-- NetBSDSignals.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "NetBSDSignals.h" using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/NetBSDSignals.h b/source/Plugins/Process/Utility/NetBSDSignals.h index 4338f881645e..bf7399a89060 100644 --- a/source/Plugins/Process/Utility/NetBSDSignals.h +++ b/source/Plugins/Process/Utility/NetBSDSignals.h @@ -1,16 +1,14 @@ //===-- NetBSDSignals.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_NetBSDSignals_H_ #define liblldb_NetBSDSignals_H_ -// Project includes #include "lldb/Target/UnixSignals.h" namespace lldb_private { diff --git a/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h b/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h index ff57464be2de..ef40162984f1 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h +++ b/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h @@ -1,9 +1,8 @@ //===-- RegisterContextDarwinConstants.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp index 5d9ff02fafdd..bcb58d2a5384 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp @@ -1,23 +1,20 @@ //===-- RegisterContextDarwin_arm.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextDarwin_arm.h" #include "RegisterContextDarwinConstants.h" -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "Plugins/Process/Utility/InstructionUtils.h" @@ -28,7 +25,6 @@ #define LLVM_EXTENSION #endif -// Project includes #include "Utility/ARM_DWARF_Registers.h" #include "Utility/ARM_ehframe_Registers.h" @@ -1673,7 +1669,7 @@ uint32_t RegisterContextDarwin_arm::SetHardwareWatchpoint(lldb::addr_t addr, return LLDB_INVALID_INDEX32; // We must watch for either read or write - if (read == false && write == false) + if (!read && !write) return LLDB_INVALID_INDEX32; // Can't watch more than 4 bytes per WVR/WCR pair diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h index cdf3479dff69..d7c1809a3222 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h @@ -1,19 +1,14 @@ //===-- RegisterContextDarwin_arm.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextDarwin_arm_h_ #define liblldb_RegisterContextDarwin_arm_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp index 1ab5b7c327ad..0fd71205a791 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp @@ -1,26 +1,23 @@ //===-- RegisterContextDarwin_arm64.cpp ---------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextDarwin_arm64.h" #include "RegisterContextDarwinConstants.h" -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" @@ -32,7 +29,6 @@ #define LLVM_EXTENSION #endif -// Project includes #include "Utility/ARM64_DWARF_Registers.h" using namespace lldb; @@ -959,7 +955,7 @@ uint32_t RegisterContextDarwin_arm64::SetHardwareWatchpoint(lldb::addr_t addr, return LLDB_INVALID_INDEX32; // We must watch for either read or write - if (read == false && write == false) + if (!read && !write) return LLDB_INVALID_INDEX32; // Can't watch more than 4 bytes per WVR/WCR pair diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h index 4a0e50947ee7..2f691c807d50 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h @@ -1,20 +1,15 @@ //===-- RegisterContextDarwin_arm64.h -----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextDarwin_arm64_h_ #define liblldb_RegisterContextDarwin_arm64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp index 24414211d9aa..742644d4d8e7 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp @@ -1,23 +1,19 @@ //===-- RegisterContextDarwin_i386.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -#include // offsetof +#include -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" @@ -27,7 +23,6 @@ #define LLVM_EXTENSION #endif -// Project includes #include "RegisterContextDarwin_i386.h" using namespace lldb; diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h index aea8a2900911..e52f0fe63250 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h @@ -1,19 +1,14 @@ //===-- RegisterContextDarwin_i386.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextDarwin_i386_h_ #define liblldb_RegisterContextDarwin_i386_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp index ecad8240b294..35fc2a15732e 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp @@ -1,25 +1,21 @@ //===-- RegisterContextDarwin_x86_64.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -#include // PRIx64 +#include #include -#include // offsetof +#include -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" @@ -29,7 +25,6 @@ #define LLVM_EXTENSION #endif -// Project includes #include "RegisterContextDarwin_x86_64.h" using namespace lldb; diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h index fdd5e8036dee..1a65a4f28b33 100644 --- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h @@ -1,19 +1,14 @@ //===-- RegisterContextDarwin_x86_64.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextDarwin_x86_64_h_ #define liblldb_RegisterContextDarwin_x86_64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.cpp b/source/Plugins/Process/Utility/RegisterContextDummy.cpp index dd6ca92a74ee..5ea13a54fd2b 100644 --- a/source/Plugins/Process/Utility/RegisterContextDummy.cpp +++ b/source/Plugins/Process/Utility/RegisterContextDummy.cpp @@ -1,17 +1,15 @@ //===-- RegisterContextDummy.cpp ---------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/FuncUnwinders.h" @@ -28,6 +26,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" #include "RegisterContextDummy.h" diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.h b/source/Plugins/Process/Utility/RegisterContextDummy.h index ea70288f3d69..70d842389df6 100644 --- a/source/Plugins/Process/Utility/RegisterContextDummy.h +++ b/source/Plugins/Process/Utility/RegisterContextDummy.h @@ -1,22 +1,17 @@ //===-- RegisterContextDummy.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterContextDummy_h_ #define lldb_RegisterContextDummy_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp index 4ccfa2a16fef..41896615bb0a 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_i386.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h index 35a79c14abfc..7aadf3a0a4c9 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_i386.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp index 55a72b2a31b4..7c186ad3ca32 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_mips64.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h index 5e5de71ad72e..96f02b4440c5 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_mips64.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp index efa4cc6d8182..d1b9e59b0c12 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_powerpc.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h index c9a65b1cacce..ba2751194d16 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h @@ -1,20 +1,15 @@ //===-- RegisterContextFreeBSD_powerpc.h -------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextFreeBSD_powerpc_h_ #define liblldb_RegisterContextFreeBSD_powerpc_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterInfoInterface.h" class RegisterContextFreeBSD_powerpc diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp index 4bbbd5c3d0a6..eedfdbbedfb8 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_x86_64.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h index dc30f1783b41..c379e1a5cd75 100644 --- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h @@ -1,9 +1,8 @@ //===-- RegisterContextFreeBSD_x86_64.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.cpp b/source/Plugins/Process/Utility/RegisterContextHistory.cpp index cc0d696b338a..8c2268aeaacb 100644 --- a/source/Plugins/Process/Utility/RegisterContextHistory.cpp +++ b/source/Plugins/Process/Utility/RegisterContextHistory.cpp @@ -1,17 +1,15 @@ //===-- RegisterContextHistory.cpp ---------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/FuncUnwinders.h" @@ -28,6 +26,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" #include "RegisterContextHistory.h" diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.h b/source/Plugins/Process/Utility/RegisterContextHistory.h index acaf8fe5c04a..8c29f1fe634d 100644 --- a/source/Plugins/Process/Utility/RegisterContextHistory.h +++ b/source/Plugins/Process/Utility/RegisterContextHistory.h @@ -1,22 +1,17 @@ //===-- RegisterContextHistory.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterContextHistory_h_ #define lldb_RegisterContextHistory_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index ba9a8071bcfb..423b2e53c661 100644 --- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -1,16 +1,14 @@ //===-- RegisterContextLLDB.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/ArmUnwindInfo.h" @@ -31,6 +29,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" #include "RegisterContextLLDB.h" @@ -54,7 +53,8 @@ RegisterContextLLDB::RegisterContextLLDB(Thread &thread, : RegisterContext(thread, frame_number), m_thread(thread), m_fast_unwind_plan_sp(), m_full_unwind_plan_sp(), m_fallback_unwind_plan_sp(), m_all_registers_available(false), - m_frame_type(-1), m_cfa(LLDB_INVALID_ADDRESS), m_start_pc(), + m_frame_type(-1), m_cfa(LLDB_INVALID_ADDRESS), + m_afa(LLDB_INVALID_ADDRESS), m_start_pc(), m_current_pc(), m_current_offset(0), m_current_offset_backed_up_one(0), m_sym_ctx(sym_ctx), m_sym_ctx_valid(false), m_frame_number(frame_number), m_registers(), m_parent_unwind(unwind_lldb) { @@ -150,7 +150,8 @@ void RegisterContextLLDB::InitializeZerothFrame() { // We require either a symbol or function in the symbols context to be // successfully filled in or this context is of no use to us. - const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; + const SymbolContextItem resolve_scope = + eSymbolContextFunction | eSymbolContextSymbol; if (pc_module_sp.get() && (pc_module_sp->ResolveSymbolContextForAddress( m_current_pc, resolve_scope, m_sym_ctx) & resolve_scope)) { @@ -227,7 +228,7 @@ void RegisterContextLLDB::InitializeZerothFrame() { return; } - if (!ReadCFAValueForRow(row_register_kind, active_row, m_cfa)) { + if (!ReadFrameAddress(row_register_kind, active_row->GetCFAValue(), m_cfa)) { // Try the fall back unwind plan since the // full unwind plan failed. FuncUnwindersSP func_unwinders_sp; @@ -255,12 +256,14 @@ void RegisterContextLLDB::InitializeZerothFrame() { m_frame_type = eNotAValidFrame; return; } - } + } else + ReadFrameAddress(row_register_kind, active_row->GetAFAValue(), m_afa); UnwindLogMsg("initialized frame current pc is 0x%" PRIx64 " cfa is 0x%" PRIx64 - " using %s UnwindPlan", + " afa is 0x%" PRIx64 " using %s UnwindPlan", (uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()), (uint64_t)m_cfa, + (uint64_t)m_afa, m_full_unwind_plan_sp->GetSourceName().GetCString()); } @@ -320,7 +323,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { above_trap_handler = true; if (pc == 0 || pc == 0x1) { - if (above_trap_handler == false) { + if (!above_trap_handler) { m_frame_type = eNotAValidFrame; UnwindLogMsg("this frame has a pc of 0x0"); return; @@ -378,7 +381,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { RegisterKind row_register_kind = m_full_unwind_plan_sp->GetRegisterKind(); UnwindPlan::RowSP row = m_full_unwind_plan_sp->GetRowForFunctionOffset(0); if (row.get()) { - if (!ReadCFAValueForRow(row_register_kind, row, m_cfa)) { + if (!ReadFrameAddress(row_register_kind, row->GetCFAValue(), m_cfa)) { UnwindLogMsg("failed to get cfa value"); if (m_frame_type != eSkipFrame) // don't override eSkipFrame { @@ -387,6 +390,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { return; } + ReadFrameAddress(row_register_kind, row->GetAFAValue(), m_afa); + // A couple of sanity checks.. if (m_cfa == LLDB_INVALID_ADDRESS || m_cfa == 0 || m_cfa == 1) { UnwindLogMsg("could not find a valid cfa address"); @@ -419,7 +424,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { } } - UnwindLogMsg("initialized frame cfa is 0x%" PRIx64, (uint64_t)m_cfa); + UnwindLogMsg("initialized frame cfa is 0x%" PRIx64 " afa is 0x%" PRIx64, + (uint64_t)m_cfa, (uint64_t)m_afa); return; } m_frame_type = eNotAValidFrame; @@ -436,7 +442,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { // then we might not find the correct unwind information later. Instead, let // ResolveSymbolContextForAddress fail, and handle the case via // decr_pc_and_recompute_addr_range below. - const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; + const SymbolContextItem resolve_scope = + eSymbolContextFunction | eSymbolContextSymbol; uint32_t resolved_scope = pc_module_sp->ResolveSymbolContextForAddress( m_current_pc, resolve_scope, m_sym_ctx, resolve_tail_call_address); @@ -466,7 +473,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { bool decr_pc_and_recompute_addr_range = false; // If the symbol lookup failed... - if (m_sym_ctx_valid == false) + if (!m_sym_ctx_valid) decr_pc_and_recompute_addr_range = true; // Or if we're in the middle of the stack (and not "above" an asynchronous @@ -494,7 +501,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { temporary_pc.SetLoadAddress(pc - 1, &process->GetTarget()); m_sym_ctx.Clear(false); m_sym_ctx_valid = false; - uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; + SymbolContextItem resolve_scope = + eSymbolContextFunction | eSymbolContextSymbol; ModuleSP temporary_module_sp = temporary_pc.GetModule(); if (temporary_module_sp && @@ -581,13 +589,15 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { return; } - if (!ReadCFAValueForRow(row_register_kind, active_row, m_cfa)) { + if (!ReadFrameAddress(row_register_kind, active_row->GetCFAValue(), m_cfa)) { UnwindLogMsg("failed to get cfa"); m_frame_type = eNotAValidFrame; return; } - UnwindLogMsg("m_cfa = 0x%" PRIx64, m_cfa); + ReadFrameAddress(row_register_kind, active_row->GetAFAValue(), m_afa); + + UnwindLogMsg("m_cfa = 0x%" PRIx64 " m_afa = 0x%" PRIx64, m_cfa, m_afa); if (CheckIfLoopingStack()) { TryFallbackUnwindPlan(); @@ -600,9 +610,10 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { } UnwindLogMsg("initialized frame current pc is 0x%" PRIx64 - " cfa is 0x%" PRIx64, + " cfa is 0x%" PRIx64 " afa is 0x%" PRIx64, (uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()), - (uint64_t)m_cfa); + (uint64_t)m_cfa, + (uint64_t)m_afa); } bool RegisterContextLLDB::CheckIfLoopingStack() { @@ -1238,7 +1249,7 @@ RegisterContextLLDB::SavedLocationForRegister( // Address register and it hasn't been saved anywhere yet -- that is, // it's still live in the actual register. Handle this specially. - if (have_unwindplan_regloc == false && return_address_reg.IsValid() && + if (!have_unwindplan_regloc && return_address_reg.IsValid() && IsFrameZero()) { if (return_address_reg.GetAsKind(eRegisterKindLLDB) != LLDB_INVALID_REGNUM) { @@ -1311,17 +1322,13 @@ RegisterContextLLDB::SavedLocationForRegister( unwindplan_regloc)) { can_fetch_pc_value = true; } - if (ReadCFAValueForRow(unwindplan_registerkind, active_row, - cfa_value)) { + if (ReadFrameAddress(unwindplan_registerkind, + active_row->GetCFAValue(), cfa_value)) { can_fetch_cfa = true; } } - if (can_fetch_pc_value && can_fetch_cfa) { - have_unwindplan_regloc = true; - } else { - have_unwindplan_regloc = false; - } + have_unwindplan_regloc = can_fetch_pc_value && can_fetch_cfa; } else { // We were unable to fall back to another unwind plan have_unwindplan_regloc = false; @@ -1332,7 +1339,7 @@ RegisterContextLLDB::SavedLocationForRegister( ExecutionContext exe_ctx(m_thread.shared_from_this()); Process *process = exe_ctx.GetProcessPtr(); - if (have_unwindplan_regloc == false) { + if (!have_unwindplan_regloc) { // If the UnwindPlan failed to give us an unwind location for this // register, we may be able to fall back to some ABI-defined default. For // example, some ABIs allow to determine the caller's SP via the CFA. Also, @@ -1351,7 +1358,7 @@ RegisterContextLLDB::SavedLocationForRegister( } } - if (have_unwindplan_regloc == false) { + if (!have_unwindplan_regloc) { if (IsFrameZero()) { // This is frame 0 - we should return the actual live register context // value @@ -1397,7 +1404,7 @@ RegisterContextLLDB::SavedLocationForRegister( } if (unwindplan_regloc.IsSame()) { - if (IsFrameZero() == false && + if (!IsFrameZero() && (regnum.GetAsKind(eRegisterKindGeneric) == LLDB_REGNUM_GENERIC_PC || regnum.GetAsKind(eRegisterKindGeneric) == LLDB_REGNUM_GENERIC_RA)) { UnwindLogMsg("register %s (%d) is marked as 'IsSame' - it is a pc or " @@ -1441,6 +1448,36 @@ RegisterContextLLDB::SavedLocationForRegister( return UnwindLLDB::RegisterSearchResult::eRegisterFound; } + if (unwindplan_regloc.IsAFAPlusOffset()) { + if (m_afa == LLDB_INVALID_ADDRESS) + return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; + + int offset = unwindplan_regloc.GetOffset(); + regloc.type = UnwindLLDB::RegisterLocation::eRegisterValueInferred; + regloc.location.inferred_value = m_afa + offset; + m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc; + UnwindLogMsg("supplying caller's register %s (%d), value is AFA plus " + "offset %d [value is 0x%" PRIx64 "]", + regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), offset, + regloc.location.inferred_value); + return UnwindLLDB::RegisterSearchResult::eRegisterFound; + } + + if (unwindplan_regloc.IsAtAFAPlusOffset()) { + if (m_afa == LLDB_INVALID_ADDRESS) + return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; + + int offset = unwindplan_regloc.GetOffset(); + regloc.type = UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation; + regloc.location.target_memory_location = m_afa + offset; + m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc; + UnwindLogMsg("supplying caller's register %s (%d) from the stack, saved at " + "AFA plus offset %d [saved at 0x%" PRIx64 "]", + regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), offset, + regloc.location.target_memory_location); + return UnwindLLDB::RegisterSearchResult::eRegisterFound; + } + if (unwindplan_regloc.IsInOtherRegister()) { uint32_t unwindplan_regnum = unwindplan_regloc.GetRegisterNumber(); RegisterNumber row_regnum(m_thread, unwindplan_registerkind, @@ -1555,7 +1592,6 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() { addr_t old_caller_pc_value = LLDB_INVALID_ADDRESS; addr_t new_caller_pc_value = LLDB_INVALID_ADDRESS; - addr_t old_this_frame_cfa_value = m_cfa; UnwindLLDB::RegisterLocation regloc; if (SavedLocationForRegister(pc_regnum.GetAsKind(eRegisterKindLLDB), regloc) == @@ -1585,6 +1621,7 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() { // the value of the m_cfa ivar. Save is down below a bit in 'old_cfa'. UnwindPlanSP original_full_unwind_plan_sp = m_full_unwind_plan_sp; addr_t old_cfa = m_cfa; + addr_t old_afa = m_afa; m_registers.clear(); @@ -1595,19 +1632,21 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() { if (active_row && active_row->GetCFAValue().GetValueType() != - UnwindPlan::Row::CFAValue::unspecified) { + UnwindPlan::Row::FAValue::unspecified) { addr_t new_cfa; - if (!ReadCFAValueForRow(m_fallback_unwind_plan_sp->GetRegisterKind(), - active_row, new_cfa) || + if (!ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(), + active_row->GetCFAValue(), new_cfa) || new_cfa == 0 || new_cfa == 1 || new_cfa == LLDB_INVALID_ADDRESS) { UnwindLogMsg("failed to get cfa with fallback unwindplan"); m_fallback_unwind_plan_sp.reset(); m_full_unwind_plan_sp = original_full_unwind_plan_sp; - m_cfa = old_cfa; return false; } m_cfa = new_cfa; + ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(), + active_row->GetAFAValue(), m_afa); + if (SavedLocationForRegister(pc_regnum.GetAsKind(eRegisterKindLLDB), regloc) == UnwindLLDB::RegisterSearchResult::eRegisterFound) { @@ -1628,19 +1667,18 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() { m_fallback_unwind_plan_sp.reset(); m_full_unwind_plan_sp = original_full_unwind_plan_sp; m_cfa = old_cfa; + m_afa = old_afa; return false; } - if (old_caller_pc_value != LLDB_INVALID_ADDRESS) { - if (old_caller_pc_value == new_caller_pc_value && - new_cfa == old_this_frame_cfa_value) { - UnwindLogMsg("fallback unwind plan got the same values for this frame " - "CFA and caller frame pc, not using"); - m_fallback_unwind_plan_sp.reset(); - m_full_unwind_plan_sp = original_full_unwind_plan_sp; - m_cfa = old_cfa; - return false; - } + if (old_caller_pc_value == new_caller_pc_value && + m_cfa == old_cfa && + m_afa == old_afa) { + UnwindLogMsg("fallback unwind plan got the same values for this frame " + "CFA and caller frame pc, not using"); + m_fallback_unwind_plan_sp.reset(); + m_full_unwind_plan_sp = original_full_unwind_plan_sp; + return false; } UnwindLogMsg("trying to unwind from this function with the UnwindPlan '%s' " @@ -1674,16 +1712,19 @@ bool RegisterContextLLDB::ForceSwitchToFallbackUnwindPlan() { if (active_row && active_row->GetCFAValue().GetValueType() != - UnwindPlan::Row::CFAValue::unspecified) { + UnwindPlan::Row::FAValue::unspecified) { addr_t new_cfa; - if (!ReadCFAValueForRow(m_fallback_unwind_plan_sp->GetRegisterKind(), - active_row, new_cfa) || + if (!ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(), + active_row->GetCFAValue(), new_cfa) || new_cfa == 0 || new_cfa == 1 || new_cfa == LLDB_INVALID_ADDRESS) { UnwindLogMsg("failed to get cfa with fallback unwindplan"); m_fallback_unwind_plan_sp.reset(); return false; } + ReadFrameAddress(m_fallback_unwind_plan_sp->GetRegisterKind(), + active_row->GetAFAValue(), m_afa); + m_full_unwind_plan_sp = m_fallback_unwind_plan_sp; m_fallback_unwind_plan_sp.reset(); @@ -1698,18 +1739,18 @@ bool RegisterContextLLDB::ForceSwitchToFallbackUnwindPlan() { return false; } -bool RegisterContextLLDB::ReadCFAValueForRow( - lldb::RegisterKind row_register_kind, const UnwindPlan::RowSP &row, - addr_t &cfa_value) { +bool RegisterContextLLDB::ReadFrameAddress( + lldb::RegisterKind row_register_kind, UnwindPlan::Row::FAValue &fa, + addr_t &address) { RegisterValue reg_value; - cfa_value = LLDB_INVALID_ADDRESS; + address = LLDB_INVALID_ADDRESS; addr_t cfa_reg_contents; - switch (row->GetCFAValue().GetValueType()) { - case UnwindPlan::Row::CFAValue::isRegisterDereferenced: { + switch (fa.GetValueType()) { + case UnwindPlan::Row::FAValue::isRegisterDereferenced: { RegisterNumber cfa_reg(m_thread, row_register_kind, - row->GetCFAValue().GetRegisterNumber()); + fa.GetRegisterNumber()); if (ReadGPRValue(cfa_reg, cfa_reg_contents)) { const RegisterInfo *reg_info = GetRegisterInfoAtIndex(cfa_reg.GetAsKind(eRegisterKindLLDB)); @@ -1718,12 +1759,12 @@ bool RegisterContextLLDB::ReadCFAValueForRow( Status error = ReadRegisterValueFromMemory( reg_info, cfa_reg_contents, reg_info->byte_size, reg_value); if (error.Success()) { - cfa_value = reg_value.GetAsUInt64(); + address = reg_value.GetAsUInt64(); UnwindLogMsg( "CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64 ", CFA value is 0x%" PRIx64, cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB), - cfa_reg_contents, cfa_value); + cfa_reg_contents, address); return true; } else { UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64 @@ -1735,9 +1776,9 @@ bool RegisterContextLLDB::ReadCFAValueForRow( } break; } - case UnwindPlan::Row::CFAValue::isRegisterPlusOffset: { + case UnwindPlan::Row::FAValue::isRegisterPlusOffset: { RegisterNumber cfa_reg(m_thread, row_register_kind, - row->GetCFAValue().GetRegisterNumber()); + fa.GetRegisterNumber()); if (ReadGPRValue(cfa_reg, cfa_reg_contents)) { if (cfa_reg_contents == LLDB_INVALID_ADDRESS || cfa_reg_contents == 0 || cfa_reg_contents == 1) { @@ -1748,35 +1789,35 @@ bool RegisterContextLLDB::ReadCFAValueForRow( cfa_reg_contents = LLDB_INVALID_ADDRESS; return false; } - cfa_value = cfa_reg_contents + row->GetCFAValue().GetOffset(); + address = cfa_reg_contents + fa.GetOffset(); UnwindLogMsg( "CFA is 0x%" PRIx64 ": Register %s (%d) contents are 0x%" PRIx64 ", offset is %d", - cfa_value, cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB), - cfa_reg_contents, row->GetCFAValue().GetOffset()); + address, cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB), + cfa_reg_contents, fa.GetOffset()); return true; } break; } - case UnwindPlan::Row::CFAValue::isDWARFExpression: { + case UnwindPlan::Row::FAValue::isDWARFExpression: { ExecutionContext exe_ctx(m_thread.shared_from_this()); Process *process = exe_ctx.GetProcessPtr(); - DataExtractor dwarfdata(row->GetCFAValue().GetDWARFExpressionBytes(), - row->GetCFAValue().GetDWARFExpressionLength(), + DataExtractor dwarfdata(fa.GetDWARFExpressionBytes(), + fa.GetDWARFExpressionLength(), process->GetByteOrder(), process->GetAddressByteSize()); ModuleSP opcode_ctx; DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0, - row->GetCFAValue().GetDWARFExpressionLength()); + fa.GetDWARFExpressionLength()); dwarfexpr.SetRegisterKind(row_register_kind); Value result; Status error; if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result, &error)) { - cfa_value = result.GetScalar().ULongLong(); + address = result.GetScalar().ULongLong(); UnwindLogMsg("CFA value set by DWARF expression is 0x%" PRIx64, - cfa_value); + address); return true; } UnwindLogMsg("Failed to set CFA value via DWARF expression: %s", @@ -2005,12 +2046,8 @@ bool RegisterContextLLDB::ReadPC(addr_t &pc) { pc = abi->FixCodeAddress(pc); } - if (m_all_registers_available == false && above_trap_handler == false && - (pc == 0 || pc == 1)) { - return false; - } - - return true; + return !(m_all_registers_available == false && + above_trap_handler == false && (pc == 0 || pc == 1)); } else { return false; } diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.h b/source/Plugins/Process/Utility/RegisterContextLLDB.h index 7e9e77dcf06d..0b9bee667cbc 100644 --- a/source/Plugins/Process/Utility/RegisterContextLLDB.h +++ b/source/Plugins/Process/Utility/RegisterContextLLDB.h @@ -1,22 +1,17 @@ //===-- RegisterContextLLDB.h --------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterContextLLDB_h_ #define lldb_RegisterContextLLDB_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "UnwindLLDB.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/UnwindPlan.h" @@ -192,9 +187,9 @@ class RegisterContextLLDB : public lldb_private::RegisterContext { bool ReadGPRValue(const RegisterNumber ®_num, lldb::addr_t &value); - // Get the CFA register for a given frame. - bool ReadCFAValueForRow(lldb::RegisterKind register_kind, - const UnwindPlan::RowSP &row, lldb::addr_t &value); + // Get the Frame Address register for a given frame. + bool ReadFrameAddress(lldb::RegisterKind register_kind, + UnwindPlan::Row::FAValue &fa, lldb::addr_t &address); lldb::UnwindPlanSP GetFastUnwindPlanForFrame(); @@ -225,6 +220,7 @@ class RegisterContextLLDB : public lldb_private::RegisterContext { int m_frame_type; // enum FrameType lldb::addr_t m_cfa; + lldb::addr_t m_afa; lldb_private::Address m_start_pc; lldb_private::Address m_current_pc; diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp index 2cb17cb182e2..5b9f69a06715 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_i386.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_i386.h b/source/Plugins/Process/Utility/RegisterContextLinux_i386.h index fbf803789cc1..5567a1ac42e5 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_i386.h +++ b/source/Plugins/Process/Utility/RegisterContextLinux_i386.h @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_i386.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp index 7b16531dcc89..c2e3d959a889 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_mips.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h index a16c4ecd15f8..e637dfc15e4d 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h +++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_mips.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp index 1bb16c701126..9eab9cf59a26 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_mips64.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h index d3ca9d75300e..ca0f0140a22d 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h +++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_mips64.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp index 5a7f5a125246..672567acf3a3 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_s390x.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h index 556cc2e12484..10810c97af80 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h +++ b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_s390x.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp index 526b3eca81ae..5a6e766d9993 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_x86_64.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h index 99a4cb736790..02f273cb02c9 100644 --- a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h @@ -1,9 +1,8 @@ //===-- RegisterContextLinux_x86_64.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp index 77c1bea34851..e60a03a09ee9 100644 --- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp +++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp @@ -1,24 +1,19 @@ //===-- RegisterContextMacOSXFrameBackchain.cpp -----------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextMacOSXFrameBackchain.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" -// Project includes #include "lldb/Utility/StringExtractorGDBRemote.h" using namespace lldb; diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h index 4f5816aa4909..36e5538daa8a 100644 --- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h +++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h @@ -1,19 +1,14 @@ //===-- RegisterContextMacOSXFrameBackchain.h -------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterContextMacOSXFrameBackchain_h_ #define lldb_RegisterContextMacOSXFrameBackchain_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp b/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp index 71d35bbd3938..c7042ab5137a 100644 --- a/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp +++ b/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextMach_arm.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,13 +10,9 @@ #include "RegisterContextMach_arm.h" -// C Includes #include #include -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/RegisterContextMach_arm.h b/source/Plugins/Process/Utility/RegisterContextMach_arm.h index a2cf6bfcbe4a..8b2425a193be 100644 --- a/source/Plugins/Process/Utility/RegisterContextMach_arm.h +++ b/source/Plugins/Process/Utility/RegisterContextMach_arm.h @@ -1,20 +1,15 @@ //===-- RegisterContextMach_arm.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextMach_arm_h_ #define liblldb_RegisterContextMach_arm_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextDarwin_arm.h" class RegisterContextMach_arm : public RegisterContextDarwin_arm { diff --git a/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp b/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp index 5a260d5de1d5..e631ab9bb26c 100644 --- a/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp +++ b/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp @@ -1,20 +1,15 @@ //===-- RegisterContextMach_i386.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #if defined(__APPLE__) -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextMach_i386.h" using namespace lldb; diff --git a/source/Plugins/Process/Utility/RegisterContextMach_i386.h b/source/Plugins/Process/Utility/RegisterContextMach_i386.h index 8ac693a55584..b8835561e98c 100644 --- a/source/Plugins/Process/Utility/RegisterContextMach_i386.h +++ b/source/Plugins/Process/Utility/RegisterContextMach_i386.h @@ -1,19 +1,14 @@ //===-- RegisterContextMach_i386.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextMach_i386_h_ #define liblldb_RegisterContextMach_i386_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextDarwin_i386.h" class RegisterContextMach_i386 : public RegisterContextDarwin_i386 { diff --git a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp index 0180879d51ee..db17d7d88778 100644 --- a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp @@ -1,20 +1,15 @@ //===-- RegisterContextMach_x86_64.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #if defined(__APPLE__) -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextMach_x86_64.h" using namespace lldb; diff --git a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h index cd425046b08e..688009aef8af 100644 --- a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h @@ -1,20 +1,15 @@ //===-- RegisterContextMach_x86_64.h ------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextMach_x86_64_h_ #define liblldb_RegisterContextMach_x86_64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContextDarwin_x86_64.h" class RegisterContextMach_x86_64 : public RegisterContextDarwin_x86_64 { diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/source/Plugins/Process/Utility/RegisterContextMemory.cpp index 76189ea781de..533bcb420adb 100644 --- a/source/Plugins/Process/Utility/RegisterContextMemory.cpp +++ b/source/Plugins/Process/Utility/RegisterContextMemory.cpp @@ -1,23 +1,18 @@ //===-- RegisterContextMemory.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextMemory.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "DynamicRegisterInfo.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" using namespace lldb; diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.h b/source/Plugins/Process/Utility/RegisterContextMemory.h index cad1592af5ba..072e8b3eac41 100644 --- a/source/Plugins/Process/Utility/RegisterContextMemory.h +++ b/source/Plugins/Process/Utility/RegisterContextMemory.h @@ -1,21 +1,16 @@ //===-- RegisterContextMemory.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterContextMemory_h_ #define lldb_RegisterContextMemory_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp index ca7a0139ccc0..d0dc0becfed3 100644 --- a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextNetBSD_x86_64.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h index 6b1998148d61..4820ef8d17ba 100644 --- a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h @@ -1,9 +1,8 @@ //===-- RegisterContextNetBSD_x86_64.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp index 1f958105b10b..6d2bc1a2f9b5 100644 --- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp +++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextOpenBSD_i386.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h index d3c13008bece..992ce0959fdf 100644 --- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h +++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h @@ -1,9 +1,8 @@ //===-- RegisterContextOpenBSD_i386.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp index e7ff0732ffec..a2e82cca1f59 100644 --- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextOpenBSD_x86_64.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h index aa2b7733f389..9c76e7211132 100644 --- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h @@ -1,9 +1,8 @@ //===-- RegisterContextOpenBSD_x86_64.h -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp index 352e251e3b64..3c9efab83322 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX_arm.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,14 +10,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_arm.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h index 8c5fe9d2c2de..70409efd21f8 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_arm.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_arm_h_ #define liblldb_RegisterContextPOSIX_arm_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterInfoInterface.h" #include "lldb-arm-register-enums.h" #include "lldb/Target/RegisterContext.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp index 3ff93cde2347..586cb7009249 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX_arm64.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,14 +10,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_arm64.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h index 27251da2a9af..b8d967ee7c97 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_arm64.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_arm64_h_ #define liblldb_RegisterContextPOSIX_arm64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterInfoInterface.h" #include "lldb-arm64-register-enums.h" #include "lldb/Target/RegisterContext.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp index 98d1e6fa8817..84d89864de84 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX_mips64.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,14 +10,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_mips64.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h index 1695ec9a0bab..087ba923c2d9 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_mips64.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_mips64_h_ #define liblldb_RegisterContextPOSIX_mips64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContext_mips.h" #include "RegisterInfoInterface.h" #include "lldb/Target/RegisterContext.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp index 9f0552539723..b651850c6150 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp @@ -1,10 +1,9 @@ //===-- RegisterContextPOSIX_powerpc.cpp -------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,14 +11,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_powerpc.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h index 50f234680ca0..dc8c08ff76d1 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_powerpc.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_powerpc_h_ #define liblldb_RegisterContextPOSIX_powerpc_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContext_powerpc.h" #include "RegisterInfoInterface.h" #include "lldb/Target/RegisterContext.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp index 41ae5ec6b51a..d6d46f4f4538 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX_ppc64le.cpp -------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,14 +10,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_ppc64le.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h index 1070b4dea405..06405352a534 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_ppc64le.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_ppc64le_h_ #define liblldb_RegisterContextPOSIX_ppc64le_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h" #include "RegisterInfoInterface.h" #include "Utility/PPC64LE_DWARF_Registers.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp index 662ac38405ef..5dbf6bf6a937 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX_s390x.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,14 +10,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_s390x.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h index d5337630c32d..54191e839a2c 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_s390x.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_s390x_h_ #define liblldb_RegisterContextPOSIX_s390x_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContext_s390x.h" #include "RegisterInfoInterface.h" #include "lldb-s390x-register-enums.h" diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp index d2a06e1b7897..43c6973d6263 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIX_x86.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,14 +10,14 @@ #include #include -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "llvm/Support/Compiler.h" #include "RegisterContextPOSIX_x86.h" @@ -376,7 +375,7 @@ RegisterContextPOSIX_x86::FPRType RegisterContextPOSIX_x86::GetFPRType() { if (m_fpr_type == eNotValid) { // TODO: Use assembly to call cpuid on the inferior and query ebx or ecx m_fpr_type = eXSAVE; // extended floating-point registers, if available - if (false == ReadFPR()) + if (!ReadFPR()) m_fpr_type = eFXSAVE; // assume generic floating-point registers } return m_fpr_type; diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h index ca71a6f272f8..8291d6585479 100644 --- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h +++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h @@ -1,19 +1,14 @@ //===-- RegisterContextPOSIX_x86.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextPOSIX_x86_h_ #define liblldb_RegisterContextPOSIX_x86_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "RegisterContext_x86.h" #include "RegisterInfoInterface.h" #include "lldb-x86-register-enums.h" diff --git a/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp b/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp index 96ad139f7364..9cc90f0bce52 100644 --- a/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp +++ b/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextThreadMemory.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContextThreadMemory.h b/source/Plugins/Process/Utility/RegisterContextThreadMemory.h index 3b3b0856a4ca..09a679ab2c9f 100644 --- a/source/Plugins/Process/Utility/RegisterContextThreadMemory.h +++ b/source/Plugins/Process/Utility/RegisterContextThreadMemory.h @@ -1,21 +1,16 @@ //===-- RegisterContextThreadMemory.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_RegisterContextThreadMemory_h_ #define lldb_RegisterContextThreadMemory_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/RegisterContext.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterContext_mips.h b/source/Plugins/Process/Utility/RegisterContext_mips.h index da470bd82732..7780be51baad 100644 --- a/source/Plugins/Process/Utility/RegisterContext_mips.h +++ b/source/Plugins/Process/Utility/RegisterContext_mips.h @@ -1,9 +1,8 @@ //===-- RegisterContext_mips.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContext_powerpc.h b/source/Plugins/Process/Utility/RegisterContext_powerpc.h index 73242952c6d0..1ffcbeb5ec48 100644 --- a/source/Plugins/Process/Utility/RegisterContext_powerpc.h +++ b/source/Plugins/Process/Utility/RegisterContext_powerpc.h @@ -1,10 +1,9 @@ //===-- RegisterContext_powerpc.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContext_s390x.h b/source/Plugins/Process/Utility/RegisterContext_s390x.h index 90803dc16785..87e7b7d5e386 100644 --- a/source/Plugins/Process/Utility/RegisterContext_s390x.h +++ b/source/Plugins/Process/Utility/RegisterContext_s390x.h @@ -1,9 +1,8 @@ //===-- RegisterContext_s390x.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterContext_x86.h b/source/Plugins/Process/Utility/RegisterContext_x86.h index 6146dcaf7e5a..049865ca38b3 100644 --- a/source/Plugins/Process/Utility/RegisterContext_x86.h +++ b/source/Plugins/Process/Utility/RegisterContext_x86.h @@ -1,9 +1,8 @@ //===-- RegisterContext_x86.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -341,7 +340,7 @@ LLVM_PACKED_END // x86 extensions to FXSAVE (i.e. for AVX and MPX processors) LLVM_PACKED_START -struct LLVM_ALIGNAS(64) XSAVE { +struct LLVM_ALIGNAS(16) XSAVE { FXSAVE i387; // floating point registers typical in i387_fxsave_struct XSAVE_HDR header; // The xsave_hdr_struct can be used to determine if the // following extensions are usable diff --git a/source/Plugins/Process/Utility/RegisterInfoInterface.h b/source/Plugins/Process/Utility/RegisterInfoInterface.h index 5d7ad89ad394..96ea4032996e 100644 --- a/source/Plugins/Process/Utility/RegisterInfoInterface.h +++ b/source/Plugins/Process/Utility/RegisterInfoInterface.h @@ -1,9 +1,8 @@ //===-- RegisterInfoInterface.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp index 0111b842509b..1355c65442e7 100644 --- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp +++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp @@ -1,9 +1,8 @@ //===-- RegisterInfoPOSIX_arm.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h index d90aec1c5116..39c2047600aa 100644 --- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h +++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h @@ -1,9 +1,8 @@ //===-- RegisterInfoPOSIX_arm.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 1b145e0a173b..e422bef4d468 100644 --- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -1,9 +1,8 @@ //===-- RegisterInfoPOSIX_arm64.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h index af770760cbf4..ace179a81814 100644 --- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h +++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h @@ -1,9 +1,8 @@ //===-- RegisterInfoPOSIX_arm64.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp index e5e7350fe68a..a0da646a3d1f 100644 --- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp +++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp @@ -1,9 +1,8 @@ //===-- RegisterInfoPOSIX_ppc64le.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h index 411ab05c2b13..c4d4d3b546e2 100644 --- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h +++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h @@ -1,9 +1,8 @@ //===-- RegisterInfoPOSIX_ppc64le.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfos_arm.h b/source/Plugins/Process/Utility/RegisterInfos_arm.h index 74d3226c8a52..74b9e3b2db32 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_arm.h +++ b/source/Plugins/Process/Utility/RegisterInfos_arm.h @@ -1,20 +1,15 @@ //===-- RegisterInfos_arm.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #ifdef DECLARE_REGISTER_INFOS_ARM_STRUCT -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterInfos_arm64.h b/source/Plugins/Process/Utility/RegisterInfos_arm64.h index b996533791ff..4ee0b528f229 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_arm64.h +++ b/source/Plugins/Process/Utility/RegisterInfos_arm64.h @@ -1,20 +1,15 @@ //===-- RegisterInfos_arm64.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #ifdef DECLARE_REGISTER_INFOS_ARM64_STRUCT -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/RegisterInfos_i386.h b/source/Plugins/Process/Utility/RegisterInfos_i386.h index ffdc4d0d116b..72ff904520ad 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_i386.h +++ b/source/Plugins/Process/Utility/RegisterInfos_i386.h @@ -1,9 +1,8 @@ //===-- RegisterInfos_i386.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,7 +10,6 @@ #include #include -// Project includes #ifdef DECLARE_REGISTER_INFOS_I386_STRUCT diff --git a/source/Plugins/Process/Utility/RegisterInfos_mips.h b/source/Plugins/Process/Utility/RegisterInfos_mips.h index b116b99b3f81..08201fd1191c 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_mips.h +++ b/source/Plugins/Process/Utility/RegisterInfos_mips.h @@ -1,21 +1,16 @@ //===-- RegisterInfos_mips.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes #include "lldb/Core/dwarf.h" #include "llvm/Support/Compiler.h" -// Project includes #ifdef DECLARE_REGISTER_INFOS_MIPS_STRUCT diff --git a/source/Plugins/Process/Utility/RegisterInfos_mips64.h b/source/Plugins/Process/Utility/RegisterInfos_mips64.h index 3c3912fa6978..b6e218ea4414 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_mips64.h +++ b/source/Plugins/Process/Utility/RegisterInfos_mips64.h @@ -1,21 +1,16 @@ //===-- RegisterInfos_mips64.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes #include "lldb/Core/dwarf.h" #include "llvm/Support/Compiler.h" -// Project includes #ifdef DECLARE_REGISTER_INFOS_MIPS64_STRUCT diff --git a/source/Plugins/Process/Utility/RegisterInfos_powerpc.h b/source/Plugins/Process/Utility/RegisterInfos_powerpc.h index c0d47f0d991f..51be31f8e028 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_powerpc.h +++ b/source/Plugins/Process/Utility/RegisterInfos_powerpc.h @@ -1,9 +1,8 @@ //===-- RegisterInfos_powerpc.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/RegisterInfos_ppc64.h b/source/Plugins/Process/Utility/RegisterInfos_ppc64.h index 69f00e4ba885..1086d3db0b06 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_ppc64.h +++ b/source/Plugins/Process/Utility/RegisterInfos_ppc64.h @@ -1,15 +1,13 @@ //===-- RegisterInfos_ppc64.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #ifdef DECLARE_REGISTER_INFOS_PPC64_STRUCT -// C Includes #include // Computes the offset of the given GPR_PPC64 in the user data area. diff --git a/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h b/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h index bffa7a1d8b63..0b099a53d875 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h +++ b/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h @@ -1,15 +1,13 @@ //===-- RegisterInfos_ppc64le.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #ifdef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT -// C Includes #include // Computes the offset of the given GPR in the user data area. diff --git a/source/Plugins/Process/Utility/RegisterInfos_s390x.h b/source/Plugins/Process/Utility/RegisterInfos_s390x.h index 0bbf422405ee..11344ff8ee79 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_s390x.h +++ b/source/Plugins/Process/Utility/RegisterInfos_s390x.h @@ -1,20 +1,15 @@ //===-- RegisterInfos_s390x.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes #include "llvm/Support/Compiler.h" -// Project includes #ifdef DECLARE_REGISTER_INFOS_S390X_STRUCT diff --git a/source/Plugins/Process/Utility/RegisterInfos_x86_64.h b/source/Plugins/Process/Utility/RegisterInfos_x86_64.h index 651536cb6045..4a3b3c73fd6b 100644 --- a/source/Plugins/Process/Utility/RegisterInfos_x86_64.h +++ b/source/Plugins/Process/Utility/RegisterInfos_x86_64.h @@ -1,9 +1,8 @@ //===-- RegisterInfos_x86_64.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/StopInfoMachException.cpp b/source/Plugins/Process/Utility/StopInfoMachException.cpp index 49a468423e0f..64b88e665046 100644 --- a/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -1,24 +1,19 @@ //===-- StopInfoMachException.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "StopInfoMachException.h" -// C Includes #if defined(__APPLE__) // Needed for the EXC_RESOURCE interpretation macros #include #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/DynamicLoader.h" @@ -48,8 +43,10 @@ const char *StopInfoMachException::GetDescription() { const char *subcode_label = "subcode"; const char *subcode_desc = NULL; +#if defined(__APPLE__) char code_desc_buf[32]; char subcode_desc_buf[32]; +#endif switch (m_value) { case 1: // EXC_BAD_ACCESS diff --git a/source/Plugins/Process/Utility/StopInfoMachException.h b/source/Plugins/Process/Utility/StopInfoMachException.h index 94516454105e..7fa2e0feb49c 100644 --- a/source/Plugins/Process/Utility/StopInfoMachException.h +++ b/source/Plugins/Process/Utility/StopInfoMachException.h @@ -1,21 +1,16 @@ //===-- StopInfoMachException.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_StopInfoMachException_h_ #define liblldb_StopInfoMachException_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/StopInfo.h" namespace lldb_private { diff --git a/source/Plugins/Process/Utility/ThreadMemory.cpp b/source/Plugins/Process/Utility/ThreadMemory.cpp index 0c7c195815a4..735bfea2fcbe 100644 --- a/source/Plugins/Process/Utility/ThreadMemory.cpp +++ b/source/Plugins/Process/Utility/ThreadMemory.cpp @@ -1,10 +1,9 @@ //===-- ThreadMemory.cpp ----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/ThreadMemory.h b/source/Plugins/Process/Utility/ThreadMemory.h index 89229710da4d..85bc1451e4a0 100644 --- a/source/Plugins/Process/Utility/ThreadMemory.h +++ b/source/Plugins/Process/Utility/ThreadMemory.h @@ -1,21 +1,16 @@ //===-- ThreadMemory.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadMemory_h_ #define liblldb_ThreadMemory_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" class ThreadMemory : public lldb_private::Thread { diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp index 49c06fea78a8..d11fda293f8c 100644 --- a/source/Plugins/Process/Utility/UnwindLLDB.cpp +++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp @@ -1,9 +1,8 @@ //===-- UnwindLLDB.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -212,15 +211,15 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { // On Mac OS X, the _sigtramp asynchronous signal trampoline frame may not // have its (constructed) CFA aligned correctly -- don't do the abi // alignment check for these. - if (reg_ctx_sp->IsTrapHandlerFrame() == false) { + if (!reg_ctx_sp->IsTrapHandlerFrame()) { // See if we can find a fallback unwind plan for THIS frame. It may be // that the UnwindPlan we're using for THIS frame was bad and gave us a // bad CFA. If that's not it, then see if we can change the UnwindPlan // for the frame below us ("NEXT") -- see if using that other UnwindPlan // gets us a better unwind state. - if (reg_ctx_sp->TryFallbackUnwindPlan() == false || - reg_ctx_sp->GetCFA(cursor_sp->cfa) == false || - abi->CallFrameAddressIsValid(cursor_sp->cfa) == false) { + if (!reg_ctx_sp->TryFallbackUnwindPlan() || + !reg_ctx_sp->GetCFA(cursor_sp->cfa) || + !abi->CallFrameAddressIsValid(cursor_sp->cfa)) { if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated // reg_ctx_lldb_sp field of prev_frame. However, cfa field of @@ -385,10 +384,8 @@ bool UnwindLLDB::AddOneMoreFrame(ABI *abi) { // Cursor::m_frames[m_frames.size() - 2], reg_ctx_lldb_sp field was already // updated during TryFallbackUnwindPlan call above. However, cfa field // still needs to be updated. Hence updating it here and then returning. - if (!(m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->GetCFA( - m_frames[m_frames.size() - 2]->cfa))) - return false; - return true; + return m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->GetCFA( + m_frames[m_frames.size() - 2]->cfa); } // The new frame hasn't helped in unwinding. Fall back to the original one as @@ -470,10 +467,7 @@ bool UnwindLLDB::SearchForSavedLocationForRegister( UnwindLLDB::RegisterSearchResult result; result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister( lldb_regnum, regloc); - if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound) - return true; - else - return false; + return result == UnwindLLDB::RegisterSearchResult::eRegisterFound; } while (frame_num >= 0) { UnwindLLDB::RegisterSearchResult result; diff --git a/source/Plugins/Process/Utility/UnwindLLDB.h b/source/Plugins/Process/Utility/UnwindLLDB.h index 3d1f85a3dec3..4a9cdcaa4a1c 100644 --- a/source/Plugins/Process/Utility/UnwindLLDB.h +++ b/source/Plugins/Process/Utility/UnwindLLDB.h @@ -1,21 +1,16 @@ //===-- UnwindLLDB.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_UnwindLLDB_h_ #define lldb_UnwindLLDB_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/UnwindPlan.h" diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp index 2115b4e179c0..b66be3775989 100644 --- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp +++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp @@ -1,9 +1,8 @@ //===-- UnwindMacOSXFrameBackchain.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -114,7 +113,7 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386( if (!m_cursors.empty()) { lldb::addr_t first_frame_pc = m_cursors.front().pc; if (first_frame_pc != LLDB_INVALID_ADDRESS) { - const uint32_t resolve_scope = + const SymbolContextItem resolve_scope = eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction | eSymbolContextSymbol; @@ -205,7 +204,7 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64( if (!m_cursors.empty()) { lldb::addr_t first_frame_pc = m_cursors.front().pc; if (first_frame_pc != LLDB_INVALID_ADDRESS) { - const uint32_t resolve_scope = + const SymbolContextItem resolve_scope = eSymbolContextModule | eSymbolContextCompUnit | eSymbolContextFunction | eSymbolContextSymbol; diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h index 328117a306ef..573b6beb2248 100644 --- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h +++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h @@ -1,21 +1,16 @@ //===-- UnwindMacOSXFrameBackchain.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_UnwindMacOSXFrameBackchain_h_ #define lldb_UnwindMacOSXFrameBackchain_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Unwind.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/Process/Utility/lldb-arm-register-enums.h b/source/Plugins/Process/Utility/lldb-arm-register-enums.h index 49473bb885f2..969449d838e5 100644 --- a/source/Plugins/Process/Utility/lldb-arm-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-arm-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-arm-register-enums.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-arm64-register-enums.h b/source/Plugins/Process/Utility/lldb-arm64-register-enums.h index 7181ce448195..ea60db790d4b 100644 --- a/source/Plugins/Process/Utility/lldb-arm64-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-arm64-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-arm64-register-enums.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h b/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h index 61929365b736..42bc4b54a521 100644 --- a/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-mips-freebsd-register-enums.h ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h b/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h index 0ecf3e366db0..92a1e6e1ef2f 100644 --- a/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h @@ -1,10 +1,9 @@ //===-- lldb-mips-linux-register-enums.h -------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h b/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h index 9ea81c00b666..fb7eb267feac 100644 --- a/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-ppc64-register-enums.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h b/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h index 675804d13268..11b22f487969 100644 --- a/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-ppc64le-register-enums.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-s390x-register-enums.h b/source/Plugins/Process/Utility/lldb-s390x-register-enums.h index 65ff92f39bca..97baf81a59be 100644 --- a/source/Plugins/Process/Utility/lldb-s390x-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-s390x-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-s390x-register-enums.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Utility/lldb-x86-register-enums.h b/source/Plugins/Process/Utility/lldb-x86-register-enums.h index 770ec5a5f3ef..760aa275895e 100644 --- a/source/Plugins/Process/Utility/lldb-x86-register-enums.h +++ b/source/Plugins/Process/Utility/lldb-x86-register-enums.h @@ -1,9 +1,8 @@ //===-- lldb-x86-register-enums.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/DebuggerThread.cpp b/source/Plugins/Process/Windows/Common/DebuggerThread.cpp index ad43551a4c6d..dc24f2102d81 100644 --- a/source/Plugins/Process/Windows/Common/DebuggerThread.cpp +++ b/source/Plugins/Process/Windows/Common/DebuggerThread.cpp @@ -1,9 +1,8 @@ //===-- DebuggerThread.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,7 +11,6 @@ #include "IDebugDelegate.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Host/Predicate.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/windows/HostProcessWindows.h" #include "lldb/Host/windows/HostThreadWindows.h" @@ -21,6 +19,7 @@ #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h" @@ -50,7 +49,7 @@ struct DebugAttachContext { lldb::pid_t m_pid; ProcessAttachInfo m_attach_info; }; -} +} // namespace DebuggerThread::DebuggerThread(DebugDelegateSP debug_delegate) : m_debug_delegate(debug_delegate), m_pid_to_detach(0), @@ -191,7 +190,8 @@ Status DebuggerThread::StopDebugging(bool terminate) { handle, pid, terminate_suceeded); } else { LLDB_LOG(log, - "NOT calling TerminateProcess because the inferior is not valid ({0}, 0) (inferior={1})", + "NOT calling TerminateProcess because the inferior is not valid " + "({0}, 0) (inferior={1})", handle, pid); } } @@ -267,6 +267,8 @@ void DebuggerThread::DebugLoop() { if (wait_result) { DWORD continue_status = DBG_CONTINUE; switch (dbe.dwDebugEventCode) { + default: + llvm_unreachable("Unhandle debug event code!"); case EXCEPTION_DEBUG_EVENT: { ExceptionResult status = HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId); @@ -330,7 +332,7 @@ void DebuggerThread::DebugLoop() { FreeProcessHandles(); LLDB_LOG(log, "WaitForDebugEvent loop completed, exiting."); - SetEvent(m_debugging_ended_event); + ::SetEvent(m_debugging_ended_event); } ExceptionResult @@ -381,7 +383,7 @@ DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id) { Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD); - LLDB_LOG(log, "Thread {0:x} spawned in process {1}", thread_id, + LLDB_LOG(log, "Thread {0} spawned in process {1}", thread_id, m_process.GetProcessId()); HostThread thread(info.hThread); thread.GetNativeThread().SetOwnsHandle(false); @@ -439,7 +441,6 @@ DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, m_debug_delegate->OnExitProcess(info.dwExitCode); - FreeProcessHandles(); return DBG_CONTINUE; } @@ -468,7 +469,7 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, if (path_str.startswith("\\\\?\\")) path += 4; - FileSpec file_spec(path, false); + FileSpec file_spec(path); ModuleSpec module_spec(file_spec); lldb::addr_t load_addr = reinterpret_cast(info.lpBaseOfDll); diff --git a/source/Plugins/Process/Windows/Common/DebuggerThread.h b/source/Plugins/Process/Windows/Common/DebuggerThread.h index fcf36f7dec9b..04da09317cb3 100644 --- a/source/Plugins/Process/Windows/Common/DebuggerThread.h +++ b/source/Plugins/Process/Windows/Common/DebuggerThread.h @@ -1,9 +1,8 @@ //===-- DebuggerThread.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,8 +15,8 @@ #include "ForwardDecl.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/HostThread.h" -#include "lldb/Host/Predicate.h" #include "lldb/Host/windows/windows.h" +#include "lldb/Utility/Predicate.h" namespace lldb_private { diff --git a/source/Plugins/Process/Windows/Common/ExceptionRecord.h b/source/Plugins/Process/Windows/Common/ExceptionRecord.h index 1eec85d52c26..bc03b9784bf3 100644 --- a/source/Plugins/Process/Windows/Common/ExceptionRecord.h +++ b/source/Plugins/Process/Windows/Common/ExceptionRecord.h @@ -1,9 +1,8 @@ //===-- ExceptionRecord.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/ForwardDecl.h b/source/Plugins/Process/Windows/Common/ForwardDecl.h index cfe1b79cee11..ed5ab44d7eb4 100644 --- a/source/Plugins/Process/Windows/Common/ForwardDecl.h +++ b/source/Plugins/Process/Windows/Common/ForwardDecl.h @@ -1,9 +1,8 @@ //===-- ForwardDecl.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -39,4 +38,4 @@ typedef std::shared_ptr ExceptionRecordSP; typedef std::unique_ptr ExceptionRecordUP; } -#endif \ No newline at end of file +#endif diff --git a/source/Plugins/Process/Windows/Common/IDebugDelegate.h b/source/Plugins/Process/Windows/Common/IDebugDelegate.h index 73c285f1ecc7..59f5cd92f5e2 100644 --- a/source/Plugins/Process/Windows/Common/IDebugDelegate.h +++ b/source/Plugins/Process/Windows/Common/IDebugDelegate.h @@ -1,9 +1,8 @@ //===-- IDebugDelegate.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/LocalDebugDelegate.cpp b/source/Plugins/Process/Windows/Common/LocalDebugDelegate.cpp index 92aa7e2678b9..3bb00726f11b 100644 --- a/source/Plugins/Process/Windows/Common/LocalDebugDelegate.cpp +++ b/source/Plugins/Process/Windows/Common/LocalDebugDelegate.cpp @@ -1,9 +1,8 @@ //===-- LocalDebugDelegate.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/LocalDebugDelegate.h b/source/Plugins/Process/Windows/Common/LocalDebugDelegate.h index 2cb479ccce8a..305ba9e0ad74 100644 --- a/source/Plugins/Process/Windows/Common/LocalDebugDelegate.h +++ b/source/Plugins/Process/Windows/Common/LocalDebugDelegate.h @@ -1,9 +1,8 @@ //===-- LocalDebugDelegate.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/NtStructures.h b/source/Plugins/Process/Windows/Common/NtStructures.h index 6826b98c769e..1eb25b282313 100644 --- a/source/Plugins/Process/Windows/Common/NtStructures.h +++ b/source/Plugins/Process/Windows/Common/NtStructures.h @@ -1,9 +1,8 @@ //===-- NtStructures.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index 236b6017c224..e49c49330960 100644 --- a/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -1,9 +1,8 @@ //===-- ProcessWindows.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,12 +12,11 @@ #include "lldb/Host/windows/windows.h" #include -// Other libraries and framework includes #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostNativeProcessBase.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/windows/HostThreadWindows.h" @@ -28,6 +26,7 @@ #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/State.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Format.h" @@ -72,6 +71,20 @@ std::string GetProcessExecutableName(DWORD pid) { return file_name; } +DWORD ConvertLldbToWinApiProtect(uint32_t protect) { + // We also can process a read / write permissions here, but if the debugger + // will make later a write into the allocated memory, it will fail. To get + // around it is possible inside DoWriteMemory to remember memory permissions, + // allow write, write and restore permissions, but for now we process only + // the executable permission. + // + // TODO: Process permissions other than executable + if (protect & ePermissionsExecutable) + return PAGE_EXECUTE_READWRITE; + + return PAGE_READWRITE; +} + } // anonymous namespace namespace lldb_private { @@ -237,11 +250,13 @@ Status ProcessWindows::DoLaunch(Module *exe_module, FileSpec working_dir = launch_info.GetWorkingDirectory(); namespace fs = llvm::sys::fs; - if (working_dir && (!working_dir.ResolvePath() || - !fs::is_directory(working_dir.GetPath()))) { - result.SetErrorStringWithFormat("No such file or directory: %s", - working_dir.GetCString()); - return result; + if (working_dir) { + FileSystem::Instance().Resolve(working_dir); + if (!FileSystem::Instance().IsDirectory(working_dir)) { + result.SetErrorStringWithFormat("No such file or directory: %s", + working_dir.GetCString()); + return result; + } } if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) { @@ -379,7 +394,7 @@ Status ProcessWindows::DoResume() { SetPrivateState(eStateRunning); } } else { - LLDB_LOG(log, "error: process %I64u is in state %u. Returning...", + LLDB_LOG(log, "error: process {0} is in state {1}. Returning...", m_session_data->m_debugger->GetProcess().GetProcessId(), GetPrivateState()); } @@ -577,7 +592,7 @@ bool ProcessWindows::CanDebug(lldb::TargetSP target_sp, // For now we are just making sure the file exists for a given module ModuleSP exe_module_sp(target_sp->GetExecutableModule()); if (exe_module_sp.get()) - return exe_module_sp->GetFileSpec().Exists(); + return FileSystem::Instance().Exists(exe_module_sp->GetFileSpec()); // However, if there is no executable module, we return true since we might // be preparing to attach. return true; @@ -695,6 +710,58 @@ size_t ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf, return bytes_written; } +lldb::addr_t ProcessWindows::DoAllocateMemory(size_t size, uint32_t permissions, + Status &error) { + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to allocate {0} bytes with permissions {1}", size, + permissions); + + if (!m_session_data) { + LLDB_LOG(log, "cannot allocate, there is no active debugger connection."); + error.SetErrorString( + "cannot allocate, there is no active debugger connection"); + return LLDB_INVALID_ADDRESS; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + auto protect = ConvertLldbToWinApiProtect(permissions); + auto result = VirtualAllocEx(handle, nullptr, size, MEM_COMMIT, protect); + if (!result) { + error.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "allocating failed with error: {0}", error); + return LLDB_INVALID_ADDRESS; + } + + return reinterpret_cast(result); +} + +Status ProcessWindows::DoDeallocateMemory(lldb::addr_t ptr) { + Status result; + + Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); + llvm::sys::ScopedLock lock(m_mutex); + LLDB_LOG(log, "attempting to deallocate bytes at address {0}", ptr); + + if (!m_session_data) { + LLDB_LOG(log, "cannot deallocate, there is no active debugger connection."); + result.SetErrorString( + "cannot deallocate, there is no active debugger connection"); + return result; + } + + HostProcess process = m_session_data->m_debugger->GetProcess(); + lldb::process_t handle = process.GetNativeProcess().GetSystemHandle(); + if (!VirtualFreeEx(handle, reinterpret_cast(ptr), 0, MEM_RELEASE)) { + result.SetError(GetLastError(), eErrorTypeWin32); + LLDB_LOG(log, "deallocating failed with error: {0}", result); + return result; + } + + return result; +} + Status ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) { Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY); @@ -812,6 +879,14 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) { SetProcessExitStatus(GetID(), true, 0, exit_code); SetPrivateState(eStateExited); + + // If the process exits before any initial stop then notify the debugger + // of the error otherwise WaitForDebuggerConnection() will be blocked. + // An example of this issue is when a process fails to load a dependent DLL. + if (m_session_data && !m_session_data->m_initial_stop_received) { + Status error(exit_code, eErrorTypeWin32); + OnDebuggerError(error, 0); + } } void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { @@ -829,7 +904,8 @@ void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { return; } - FileSpec executable_file(file_name, true); + FileSpec executable_file(file_name); + FileSystem::Instance().Resolve(executable_file); ModuleSpec module_spec(executable_file); Status error; module = GetTarget().GetSharedModule(module_spec, &error); @@ -880,8 +956,9 @@ ProcessWindows::OnDebugException(bool first_chance, } if (!first_chance) { - // Any second chance exception is an application crash by definition. - SetPrivateState(eStateCrashed); + // Not any second chance exception is an application crash by definition. + // It may be an expression evaluation crash. + SetPrivateState(eStateStopped); } ExceptionResult result = ExceptionResult::SendToApplication; diff --git a/source/Plugins/Process/Windows/Common/ProcessWindows.h b/source/Plugins/Process/Windows/Common/ProcessWindows.h index ed3938beb347..184dab90ff3c 100644 --- a/source/Plugins/Process/Windows/Common/ProcessWindows.h +++ b/source/Plugins/Process/Windows/Common/ProcessWindows.h @@ -1,16 +1,14 @@ //===-- ProcessWindows.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_Plugins_Process_Windows_Common_ProcessWindows_H_ #define liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_ -// Other libraries and framework includes #include "lldb/Target/Process.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" @@ -84,6 +82,9 @@ class ProcessWindows : public Process, public IDebugDelegate { Status &error) override; size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override; + lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, + Status &error) override; + Status DoDeallocateMemory(lldb::addr_t ptr) override; Status GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override; diff --git a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp index 386e9a5816c5..8af9f39bb804 100644 --- a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp +++ b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp @@ -1,9 +1,8 @@ //===-- ProcessWindowsLog.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h index b7f59c708143..66ba245c9fa8 100644 --- a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h +++ b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h @@ -1,9 +1,8 @@ //===-- ProcessWindowsLog.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp b/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp index b3f507128f82..8ca1b5c2821f 100644 --- a/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp +++ b/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp @@ -1,9 +1,8 @@ //===-- RegisterContextWindows.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -40,12 +39,13 @@ void RegisterContextWindows::InvalidateAllRegisters() { bool RegisterContextWindows::ReadAllRegisterValues( lldb::DataBufferSP &data_sp) { + if (!CacheAllRegisterValues()) return false; - if (data_sp->GetByteSize() < sizeof(m_context)) { - data_sp.reset(new DataBufferHeap(sizeof(CONTEXT), 0)); - } + + data_sp.reset(new DataBufferHeap(sizeof(CONTEXT), 0)); memcpy(data_sp->GetBytes(), &m_context, sizeof(m_context)); + return true; } diff --git a/source/Plugins/Process/Windows/Common/RegisterContextWindows.h b/source/Plugins/Process/Windows/Common/RegisterContextWindows.h index bd09295c2f23..e269af95ed81 100644 --- a/source/Plugins/Process/Windows/Common/RegisterContextWindows.h +++ b/source/Plugins/Process/Windows/Common/RegisterContextWindows.h @@ -1,9 +1,8 @@ //===-- RegisterContextWindows.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp b/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp index 3903280918cc..be5846d0b034 100644 --- a/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ b/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -1,13 +1,11 @@ //===-- TargetThreadWindows.cpp----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThreadBase.h" #include "lldb/Host/windows/HostThreadWindows.h" @@ -15,6 +13,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" +#include "lldb/Utility/State.h" #include "Plugins/Process/Utility/UnwindLLDB.h" #include "ProcessWindows.h" diff --git a/source/Plugins/Process/Windows/Common/TargetThreadWindows.h b/source/Plugins/Process/Windows/Common/TargetThreadWindows.h index 952c0f55b57f..fc68cb73db91 100644 --- a/source/Plugins/Process/Windows/Common/TargetThreadWindows.h +++ b/source/Plugins/Process/Windows/Common/TargetThreadWindows.h @@ -1,9 +1,8 @@ //===-- TargetThreadWindows.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp b/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp index 4aa6c785f83c..6c92d098e73a 100644 --- a/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp +++ b/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextWindows_x64.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/windows/HostThreadWindows.h" #include "lldb/Host/windows/windows.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-types.h" @@ -74,12 +73,12 @@ RegisterInfo g_register_infos[] = { nullptr, nullptr}, {DEFINE_GPR(rcx, nullptr), - {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM, + {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, lldb_rcx_x86_64}, nullptr, nullptr}, {DEFINE_GPR(rdx, nullptr), - {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM, + {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, lldb_rdx_x86_64}, nullptr, nullptr}, @@ -104,22 +103,22 @@ RegisterInfo g_register_infos[] = { nullptr, nullptr}, {DEFINE_GPR(r8, nullptr), - {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM, + {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, lldb_r8_x86_64}, nullptr, nullptr}, {DEFINE_GPR(r9, nullptr), - {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM, + {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, lldb_r9_x86_64}, nullptr, nullptr}, {DEFINE_GPR(r10, nullptr), - {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM, + {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, lldb_r10_x86_64}, nullptr, nullptr}, {DEFINE_GPR(r11, nullptr), - {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM, + {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, lldb_r11_x86_64}, nullptr, nullptr}, diff --git a/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h b/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h index 62cedc8fbab0..68793bffa0fc 100644 --- a/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h +++ b/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h @@ -1,9 +1,8 @@ //===-- RegisterContextWindows_x64.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp b/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp index fd486f3d0829..b2c64a9199e3 100644 --- a/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp +++ b/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp @@ -1,15 +1,14 @@ //===-- RegisterContextWindows_x86.cpp --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" #include "lldb/Host/windows/HostThreadWindows.h" #include "lldb/Host/windows/windows.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-types.h" diff --git a/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h b/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h index aae645fdb5a3..7823ff98b8c0 100644 --- a/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h +++ b/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h @@ -1,9 +1,8 @@ //===-- RegisterContextWindows_x86.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp index f92a263f3d53..4b066a6091e1 100644 --- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -1,31 +1,26 @@ //===-- ProcessElfCore.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes #include -// Other libraries and framework includes #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/Support/Threading.h" @@ -61,8 +56,8 @@ lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp, // the header extension. const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr); - auto data_sp = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), - header_size, 0); + auto data_sp = FileSystem::Instance().CreateDataBuffer( + crash_file->GetPath(), header_size, 0); if (data_sp && data_sp->GetByteSize() == header_size && elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) { elf::ELFHeader elf_header; @@ -81,7 +76,7 @@ lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp, bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) { // For now we are just making sure the file exists for a given module - if (!m_core_module_sp && m_core_file.Exists()) { + if (!m_core_module_sp && FileSystem::Instance().Exists(m_core_file)) { ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture()); Status error(ModuleList::GetSharedModule(core_module_spec, m_core_module_sp, NULL, NULL, NULL)); @@ -122,10 +117,10 @@ ConstString ProcessElfCore::GetPluginName() { return GetPluginNameStatic(); } uint32_t ProcessElfCore::GetPluginVersion() { return 1; } lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment( - const elf::ELFProgramHeader *header) { - const lldb::addr_t addr = header->p_vaddr; - FileRange file_range(header->p_offset, header->p_filesz); - VMRangeToFileOffset::Entry range_entry(addr, header->p_memsz, file_range); + const elf::ELFProgramHeader &header) { + const lldb::addr_t addr = header.p_vaddr; + FileRange file_range(header.p_offset, header.p_filesz); + VMRangeToFileOffset::Entry range_entry(addr, header.p_memsz, file_range); VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back(); if (last_entry && last_entry->GetRangeEnd() == range_entry.GetRangeBase() && @@ -140,12 +135,12 @@ lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment( // Keep a separate map of permissions that that isn't coalesced so all ranges // are maintained. const uint32_t permissions = - ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0u) | - ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0u) | - ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0u); + ((header.p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0u) | + ((header.p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0u) | + ((header.p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0u); m_core_range_infos.Append( - VMRangeToPermissions::Entry(addr, header->p_memsz, permissions)); + VMRangeToPermissions::Entry(addr, header.p_memsz, permissions)); return addr; } @@ -166,8 +161,8 @@ Status ProcessElfCore::DoLoadCore() { return error; } - const uint32_t num_segments = core->GetProgramHeaderCount(); - if (num_segments == 0) { + llvm::ArrayRef segments = core->ProgramHeaders(); + if (segments.size() == 0) { error.SetErrorString("core file has no segments"); return error; } @@ -181,20 +176,17 @@ Status ProcessElfCore::DoLoadCore() { /// Walk through segments and Thread and Address Map information. /// PT_NOTE - Contains Thread and Register information /// PT_LOAD - Contains a contiguous range of Process Address Space - for (uint32_t i = 1; i <= num_segments; i++) { - const elf::ELFProgramHeader *header = core->GetProgramHeaderByIndex(i); - assert(header != NULL); - - DataExtractor data = core->GetSegmentDataByIndex(i); + for (const elf::ELFProgramHeader &H : segments) { + DataExtractor data = core->GetSegmentData(H); // Parse thread contexts and auxv structure - if (header->p_type == llvm::ELF::PT_NOTE) { - if (llvm::Error error = ParseThreadContextsFromNoteSegment(header, data)) + if (H.p_type == llvm::ELF::PT_NOTE) { + if (llvm::Error error = ParseThreadContextsFromNoteSegment(H, data)) return Status(std::move(error)); } // PT_LOAD segments contains address map - if (header->p_type == llvm::ELF::PT_LOAD) { - lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(header); + if (H.p_type == llvm::ELF::PT_LOAD) { + lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(H); if (vm_addr > last_addr) ranges_are_sorted = false; vm_addr = last_addr; @@ -249,8 +241,7 @@ Status ProcessElfCore::DoLoadCore() { ModuleSpec exe_module_spec; exe_module_spec.GetArchitecture() = arch; exe_module_spec.GetFileSpec().SetFile( - m_nt_file_entries[0].path.GetCString(), false, - FileSpec::Style::native); + m_nt_file_entries[0].path.GetCString(), FileSpec::Style::native); if (exe_module_spec.GetFileSpec()) { exe_module_sp = GetTarget().GetSharedModule(exe_module_spec); if (exe_module_sp) @@ -715,8 +706,8 @@ llvm::Error ProcessElfCore::parseLinuxNotes(llvm::ArrayRef notes) { /// A note segment consists of one or more NOTE entries, but their types and /// meaning differ depending on the OS. llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment( - const elf::ELFProgramHeader *segment_header, DataExtractor segment_data) { - assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE); + const elf::ELFProgramHeader &segment_header, DataExtractor segment_data) { + assert(segment_header.p_type == llvm::ELF::PT_NOTE); auto notes_or_error = parseSegment(segment_data); if(!notes_or_error) @@ -744,8 +735,7 @@ uint32_t ProcessElfCore::GetNumThreadContexts() { } ArchSpec ProcessElfCore::GetArchitecture() { - ArchSpec arch; - m_core_module_sp->GetObjectFile()->GetArchitecture(arch); + ArchSpec arch = m_core_module_sp->GetObjectFile()->GetArchitecture(); ArchSpec target_arch = GetTarget().GetArchitecture(); arch.MergeFrom(target_arch); diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.h b/source/Plugins/Process/elf-core/ProcessElfCore.h index 325c0152e028..328474eb475f 100644 --- a/source/Plugins/Process/elf-core/ProcessElfCore.h +++ b/source/Plugins/Process/elf-core/ProcessElfCore.h @@ -1,9 +1,8 @@ //===-- ProcessElfCore.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // // Notes about Linux Process core dumps: // 1) Linux core dump is stored as ELF file. @@ -17,13 +16,9 @@ #ifndef liblldb_ProcessElfCore_h_ #define liblldb_ProcessElfCore_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" @@ -140,7 +135,7 @@ class ProcessElfCore : public lldb_private::Process { // For ProcessElfCore only //------------------------------------------------------------------ typedef lldb_private::Range FileRange; - typedef lldb_private::RangeDataArray + typedef lldb_private::RangeDataVector VMRangeToFileOffset; typedef lldb_private::RangeDataVector VMRangeToPermissions; @@ -170,7 +165,7 @@ class ProcessElfCore : public lldb_private::Process { // Parse thread(s) data structures(prstatus, prpsinfo) from given NOTE segment llvm::Error ParseThreadContextsFromNoteSegment( - const elf::ELFProgramHeader *segment_header, + const elf::ELFProgramHeader &segment_header, lldb_private::DataExtractor segment_data); // Returns number of thread contexts stored in the core file @@ -178,7 +173,7 @@ class ProcessElfCore : public lldb_private::Process { // Parse a contiguous address range of the process from LOAD segment lldb::addr_t - AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *header); + AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader &header); llvm::Expected> parseSegment(const lldb_private::DataExtractor &segment); diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp index 0d683153d9ed..b0eb1c8a7e96 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp @@ -1,16 +1,15 @@ //===-- RegisterContextPOSIXCore_arm.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_arm.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h index a98d64caee17..adda43ebccbc 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_arm.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp index 919f8901d39a..fb817e5e590b 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp @@ -1,16 +1,15 @@ //===-- RegisterContextPOSIXCore_arm64.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_arm64.h" #include "Plugins/Process/elf-core/RegisterUtilities.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h index c519b1557189..de6d819c29ce 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_arm64.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp index 532a1f5c0831..75844d213d98 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp @@ -1,16 +1,15 @@ //===-- RegisterContextPOSIXCore_mips64.cpp ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_mips64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h index cf1d8a5bc2d1..999c9451573b 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_mips64.h -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp index 8670e341a277..ed899d98daea 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp @@ -1,17 +1,16 @@ //===-- RegisterContextPOSIXCore_powerpc.cpp --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_powerpc.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h index c352ab5912ff..7684c0b31837 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_powerpc.h ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp index 2237e72353ac..945d444704b2 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp @@ -1,17 +1,16 @@ //===-- RegisterContextPOSIXCore_ppc64le.cpp --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_ppc64le.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h" #include "Plugins/Process/elf-core/RegisterUtilities.h" diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h index c860781d60be..6e01d23dd656 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_ppc64le.h ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp index f0edbf1ea854..5a99250b769d 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp @@ -1,17 +1,16 @@ //===-- RegisterContextPOSIXCore_s390x.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_s390x.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h index 0df136372bdd..729617649c4f 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_s390x.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp index a1f26d52444b..4454857e1799 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp @@ -1,16 +1,15 @@ //===-- RegisterContextPOSIXCore_x86_64.cpp ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "RegisterContextPOSIXCore_x86_64.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" using namespace lldb_private; diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h index 509624174a89..f41991c240d2 100644 --- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h +++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h @@ -1,9 +1,8 @@ //===-- RegisterContextPOSIXCore_x86_64.h -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterUtilities.cpp b/source/Plugins/Process/elf-core/RegisterUtilities.cpp index 3837abadd0f6..c8829d612b31 100644 --- a/source/Plugins/Process/elf-core/RegisterUtilities.cpp +++ b/source/Plugins/Process/elf-core/RegisterUtilities.cpp @@ -1,9 +1,8 @@ //===-- RegisterUtilities.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/RegisterUtilities.h b/source/Plugins/Process/elf-core/RegisterUtilities.h index 9170d94c04b6..a2c76d1ac204 100644 --- a/source/Plugins/Process/elf-core/RegisterUtilities.h +++ b/source/Plugins/Process/elf-core/RegisterUtilities.h @@ -1,9 +1,8 @@ //===-- RegisterUtilities.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/source/Plugins/Process/elf-core/ThreadElfCore.cpp index d9b90c8e902e..83900d5be36e 100644 --- a/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ b/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -1,9 +1,8 @@ //===-- ThreadElfCore.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.h b/source/Plugins/Process/elf-core/ThreadElfCore.h index 167fd6edc4ce..f0cc4daba20d 100644 --- a/source/Plugins/Process/elf-core/ThreadElfCore.h +++ b/source/Plugins/Process/elf-core/ThreadElfCore.h @@ -1,9 +1,8 @@ //===-- ThreadElfCore.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/gdb-remote/CMakeLists.txt b/source/Plugins/Process/gdb-remote/CMakeLists.txt index c26e99f8ca04..7b8e27ca6482 100644 --- a/source/Plugins/Process/gdb-remote/CMakeLists.txt +++ b/source/Plugins/Process/gdb-remote/CMakeLists.txt @@ -17,6 +17,8 @@ add_lldb_library(lldbPluginProcessGDBRemote PLUGIN GDBRemoteClientBase.cpp GDBRemoteCommunication.cpp GDBRemoteCommunicationClient.cpp + GDBRemoteCommunicationHistory.cpp + GDBRemoteCommunicationReplayServer.cpp GDBRemoteCommunicationServer.cpp GDBRemoteCommunicationServerCommon.cpp GDBRemoteCommunicationServerLLGS.cpp diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp index 4e20b56fb111..a06531dbe546 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp @@ -1,9 +1,8 @@ //===-- GDBRemoteClientBase.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -379,7 +378,7 @@ void GDBRemoteClientBase::Lock::SyncWithContinueThread(bool interrupt) { log->PutCString("GDBRemoteClientBase::Lock::Lock sent packet: \\x03"); m_comm.m_interrupt_time = steady_clock::now(); } - m_comm.m_cv.wait(lock, [this] { return m_comm.m_is_running == false; }); + m_comm.m_cv.wait(lock, [this] { return !m_comm.m_is_running; }); m_did_interrupt = true; } m_acquired = true; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h index 3d84ce0ebe18..a2f42b13713e 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h @@ -1,9 +1,8 @@ //===-- GDBRemoteClientBase.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index fb09bb5aca2d..c4a379d8c07d 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1,29 +1,29 @@ //===-- GDBRemoteCommunication.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "GDBRemoteCommunication.h" -// C Includes +#include #include #include #include -// C++ Includes -// Other libraries and framework includes #include "lldb/Core/StreamFile.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Pipe.h" #include "lldb/Host/Socket.h" #include "lldb/Host/StringConvert.h" #include "lldb/Host/ThreadLauncher.h" +#include "lldb/Host/common/TCPSocket.h" +#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" @@ -33,7 +33,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Support/ScopedPrinter.h" -// Project includes #include "ProcessGDBRemoteLog.h" #if defined(__APPLE__) @@ -42,8 +41,7 @@ #define DEBUGSERVER_BASENAME "lldb-server" #endif -#if defined(__APPLE__) -#define HAVE_LIBCOMPRESSION +#if defined(HAVE_LIBCOMPRESSION) #include #endif @@ -55,78 +53,6 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_gdb_remote; -GDBRemoteCommunication::History::History(uint32_t size) - : m_packets(), m_curr_idx(0), m_total_packet_count(0), - m_dumped_to_log(false) { - m_packets.resize(size); -} - -GDBRemoteCommunication::History::~History() {} - -void GDBRemoteCommunication::History::AddPacket(char packet_char, - PacketType type, - uint32_t bytes_transmitted) { - const size_t size = m_packets.size(); - if (size > 0) { - const uint32_t idx = GetNextIndex(); - m_packets[idx].packet.assign(1, packet_char); - m_packets[idx].type = type; - m_packets[idx].bytes_transmitted = bytes_transmitted; - m_packets[idx].packet_idx = m_total_packet_count; - m_packets[idx].tid = llvm::get_threadid(); - } -} - -void GDBRemoteCommunication::History::AddPacket(const std::string &src, - uint32_t src_len, - PacketType type, - uint32_t bytes_transmitted) { - const size_t size = m_packets.size(); - if (size > 0) { - const uint32_t idx = GetNextIndex(); - m_packets[idx].packet.assign(src, 0, src_len); - m_packets[idx].type = type; - m_packets[idx].bytes_transmitted = bytes_transmitted; - m_packets[idx].packet_idx = m_total_packet_count; - m_packets[idx].tid = llvm::get_threadid(); - } -} - -void GDBRemoteCommunication::History::Dump(Stream &strm) const { - const uint32_t size = GetNumPacketsInHistory(); - const uint32_t first_idx = GetFirstSavedPacketIndex(); - const uint32_t stop_idx = m_curr_idx + size; - for (uint32_t i = first_idx; i < stop_idx; ++i) { - const uint32_t idx = NormalizeIndex(i); - const Entry &entry = m_packets[idx]; - if (entry.type == ePacketTypeInvalid || entry.packet.empty()) - break; - strm.Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n", - entry.packet_idx, entry.tid, entry.bytes_transmitted, - (entry.type == ePacketTypeSend) ? "send" : "read", - entry.packet.c_str()); - } -} - -void GDBRemoteCommunication::History::Dump(Log *log) const { - if (log && !m_dumped_to_log) { - m_dumped_to_log = true; - const uint32_t size = GetNumPacketsInHistory(); - const uint32_t first_idx = GetFirstSavedPacketIndex(); - const uint32_t stop_idx = m_curr_idx + size; - for (uint32_t i = first_idx; i < stop_idx; ++i) { - const uint32_t idx = NormalizeIndex(i); - const Entry &entry = m_packets[idx]; - if (entry.type == ePacketTypeInvalid || entry.packet.empty()) - break; - log->Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s", - entry.packet_idx, entry.tid, entry.bytes_transmitted, - (entry.type == ePacketTypeSend) ? "send" : "read", - entry.packet.c_str()); - } - } -} - //---------------------------------------------------------------------- // GDBRemoteCommunication constructor //---------------------------------------------------------------------- @@ -140,9 +66,7 @@ GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name, #endif m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512), m_send_acks(true), m_compression_type(CompressionType::None), - m_listen_url(), m_decompression_scratch_type(CompressionType::None), - m_decompression_scratch(nullptr) -{ + m_listen_url() { } //---------------------------------------------------------------------- @@ -153,8 +77,10 @@ GDBRemoteCommunication::~GDBRemoteCommunication() { Disconnect(); } +#if defined(HAVE_LIBCOMPRESSION) if (m_decompression_scratch) free (m_decompression_scratch); +#endif // Stop the communications read thread which is used to parse all incoming // packets. This function will block until the read thread returns. @@ -178,7 +104,8 @@ size_t GDBRemoteCommunication::SendAck() { const size_t bytes_written = Write(&ch, 1, status, NULL); if (log) log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch); - m_history.AddPacket(ch, History::ePacketTypeSend, bytes_written); + m_history.AddPacket(ch, GDBRemoteCommunicationHistory::ePacketTypeSend, + bytes_written); return bytes_written; } @@ -189,26 +116,31 @@ size_t GDBRemoteCommunication::SendNack() { const size_t bytes_written = Write(&ch, 1, status, NULL); if (log) log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch); - m_history.AddPacket(ch, History::ePacketTypeSend, bytes_written); + m_history.AddPacket(ch, GDBRemoteCommunicationHistory::ePacketTypeSend, + bytes_written); return bytes_written; } GDBRemoteCommunication::PacketResult GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) { - if (IsConnected()) { StreamString packet(0, 4, eByteOrderBig); - packet.PutChar('$'); packet.Write(payload.data(), payload.size()); packet.PutChar('#'); packet.PutHex8(CalculcateChecksum(payload)); + std::string packet_str = packet.GetString(); + return SendRawPacketNoLock(packet_str); +} + +GDBRemoteCommunication::PacketResult +GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef packet, + bool skip_ack) { + if (IsConnected()) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); ConnectionStatus status = eConnectionStatusSuccess; - // TODO: Don't shimmy through a std::string, just use StringRef. - std::string packet_str = packet.GetString(); - const char *packet_data = packet_str.c_str(); - const size_t packet_length = packet.GetSize(); + const char *packet_data = packet.data(); + const size_t packet_length = packet.size(); size_t bytes_written = Write(packet_data, packet_length, status, NULL); if (log) { size_t binary_start_offset = 0; @@ -247,11 +179,12 @@ GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) { (int)packet_length, packet_data); } - m_history.AddPacket(packet.GetString(), packet_length, - History::ePacketTypeSend, bytes_written); + m_history.AddPacket(packet.str(), packet_length, + GDBRemoteCommunicationHistory::ePacketTypeSend, + bytes_written); if (bytes_written == packet_length) { - if (GetSendAcks()) + if (!skip_ack && GetSendAcks()) return GetAck(); else return PacketResult::Success; @@ -743,7 +676,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, // Size of packet before it is decompressed, for logging purposes size_t original_packet_size = m_bytes.size(); if (CompressionIsEnabled()) { - if (DecompressPacket() == false) { + if (!DecompressPacket()) { packet.Clear(); return GDBRemoteCommunication::PacketType::Standard; } @@ -882,7 +815,8 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, } } - m_history.AddPacket(m_bytes, total_length, History::ePacketTypeRecv, + m_history.AddPacket(m_bytes, total_length, + GDBRemoteCommunicationHistory::ePacketTypeRecv, total_length); // Clear packet_str in case there is some existing data in it. @@ -1019,7 +953,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess( // debugserver to use and use it if we do. const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH"); if (env_debugserver_path) { - debugserver_file_spec.SetFile(env_debugserver_path, false, + debugserver_file_spec.SetFile(env_debugserver_path, FileSpec::Style::native); if (log) log->Printf("GDBRemoteCommunication::%s() gdb-remote stub exe path set " @@ -1027,13 +961,14 @@ Status GDBRemoteCommunication::StartDebugserverProcess( __FUNCTION__, env_debugserver_path); } else debugserver_file_spec = g_debugserver_file_spec; - bool debugserver_exists = debugserver_file_spec.Exists(); + bool debugserver_exists = + FileSystem::Instance().Exists(debugserver_file_spec); if (!debugserver_exists) { // The debugserver binary is in the LLDB.framework/Resources directory. debugserver_file_spec = HostInfo::GetSupportExeDir(); if (debugserver_file_spec) { debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME); - debugserver_exists = debugserver_file_spec.Exists(); + debugserver_exists = FileSystem::Instance().Exists(debugserver_file_spec); if (debugserver_exists) { if (log) log->Printf( @@ -1096,7 +1031,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess( debugserver_args.AppendArgument(llvm::StringRef("--setsid")); } - llvm::SmallString named_pipe_path; + llvm::SmallString<128> named_pipe_path; // socket_pipe is used by debug server to communicate back either // TCP port or domain socket name which it listens on. // The second purpose of the pipe to serve as a synchronization point - @@ -1136,9 +1071,9 @@ Status GDBRemoteCommunication::StartDebugserverProcess( __FUNCTION__, error.AsCString()); return error; } - int write_fd = socket_pipe.GetWriteFileDescriptor(); + pipe_t write = socket_pipe.GetWritePipe(); debugserver_args.AppendArgument(llvm::StringRef("--pipe")); - debugserver_args.AppendArgument(llvm::to_string(write_fd)); + debugserver_args.AppendArgument(llvm::to_string(write)); launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor()); #endif } else { @@ -1326,6 +1261,42 @@ Status GDBRemoteCommunication::StartDebugserverProcess( void GDBRemoteCommunication::DumpHistory(Stream &strm) { m_history.Dump(strm); } +void GDBRemoteCommunication::SetHistoryStream(llvm::raw_ostream *strm) { + m_history.SetStream(strm); +} + +llvm::Error +GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client, + GDBRemoteCommunication &server) { + const bool child_processes_inherit = false; + const int backlog = 5; + TCPSocket listen_socket(true, child_processes_inherit); + if (llvm::Error error = + listen_socket.Listen("127.0.0.1:0", backlog).ToError()) + return error; + + Socket *accept_socket; + std::future accept_status = std::async( + std::launch::async, [&] { return listen_socket.Accept(accept_socket); }); + + llvm::SmallString<32> remote_addr; + llvm::raw_svector_ostream(remote_addr) + << "connect://localhost:" << listen_socket.GetLocalPortNumber(); + + std::unique_ptr conn_up( + new ConnectionFileDescriptor()); + if (conn_up->Connect(remote_addr, nullptr) != lldb::eConnectionStatusSuccess) + return llvm::make_error("Unable to connect", + llvm::inconvertibleErrorCode()); + + client.SetConnection(conn_up.release()); + if (llvm::Error error = accept_status.get().ToError()) + return error; + + server.SetConnection(new ConnectionFileDescriptor(accept_socket)); + return llvm::Error::success(); +} + GDBRemoteCommunication::ScopedTimeout::ScopedTimeout( GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout) : m_gdb_comm(gdb_comm), m_timeout_modified(false) { diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index 799319579aca..4ef222406143 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -1,33 +1,30 @@ //===-- GDBRemoteCommunication.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_GDBRemoteCommunication_h_ #define liblldb_GDBRemoteCommunication_h_ -// C Includes -// C++ Includes +#include "GDBRemoteCommunicationHistory.h" + #include #include #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Communication.h" -#include "lldb/Core/Listener.h" +#include "lldb/Host/Config.h" #include "lldb/Host/HostThread.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/Args.h" -#include "lldb/lldb-public.h" - +#include "lldb/Utility/Listener.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/StringExtractorGDBRemote.h" +#include "lldb/lldb-public.h" namespace lldb_private { namespace process_gdb_remote { @@ -140,86 +137,16 @@ class GDBRemoteCommunication : public Communication { // fork/exec to avoid having to connect/accept void DumpHistory(Stream &strm); + void SetHistoryStream(llvm::raw_ostream *strm); -protected: - class History { - public: - enum PacketType { - ePacketTypeInvalid = 0, - ePacketTypeSend, - ePacketTypeRecv - }; - - struct Entry { - Entry() - : packet(), type(ePacketTypeInvalid), bytes_transmitted(0), - packet_idx(0), tid(LLDB_INVALID_THREAD_ID) {} - - void Clear() { - packet.clear(); - type = ePacketTypeInvalid; - bytes_transmitted = 0; - packet_idx = 0; - tid = LLDB_INVALID_THREAD_ID; - } - std::string packet; - PacketType type; - uint32_t bytes_transmitted; - uint32_t packet_idx; - lldb::tid_t tid; - }; - - History(uint32_t size); - - ~History(); - - // For single char packets for ack, nack and /x03 - void AddPacket(char packet_char, PacketType type, - uint32_t bytes_transmitted); - - void AddPacket(const std::string &src, uint32_t src_len, PacketType type, - uint32_t bytes_transmitted); - - void Dump(Stream &strm) const; - - void Dump(Log *log) const; - - bool DidDumpToLog() const { return m_dumped_to_log; } - - protected: - uint32_t GetFirstSavedPacketIndex() const { - if (m_total_packet_count < m_packets.size()) - return 0; - else - return m_curr_idx + 1; - } - - uint32_t GetNumPacketsInHistory() const { - if (m_total_packet_count < m_packets.size()) - return m_total_packet_count; - else - return (uint32_t)m_packets.size(); - } - - uint32_t GetNextIndex() { - ++m_total_packet_count; - const uint32_t idx = m_curr_idx; - m_curr_idx = NormalizeIndex(idx + 1); - return idx; - } - - uint32_t NormalizeIndex(uint32_t i) const { return i % m_packets.size(); } - - std::vector m_packets; - uint32_t m_curr_idx; - uint32_t m_total_packet_count; - mutable bool m_dumped_to_log; - }; + static llvm::Error ConnectLocally(GDBRemoteCommunication &client, + GDBRemoteCommunication &server); +protected: std::chrono::seconds m_packet_timeout; uint32_t m_echo_number; LazyBool m_supports_qEcho; - History m_history; + GDBRemoteCommunicationHistory m_history; bool m_send_acks; bool m_is_platform; // Set to true if this class represents a platform, // false if this class represents a debug session for @@ -228,6 +155,8 @@ class GDBRemoteCommunication : public Communication { CompressionType m_compression_type; PacketResult SendPacketNoLock(llvm::StringRef payload); + PacketResult SendRawPacketNoLock(llvm::StringRef payload, + bool skip_ack = false); PacketResult ReadPacket(StringExtractorGDBRemote &response, Timeout timeout, bool sync_on_timeout); @@ -289,8 +218,10 @@ class GDBRemoteCommunication : public Communication { HostThread m_listen_thread; std::string m_listen_url; - CompressionType m_decompression_scratch_type; - void *m_decompression_scratch; +#if defined(HAVE_LIBCOMPRESSION) + CompressionType m_decompression_scratch_type = CompressionType::None; + void *m_decompression_scratch = nullptr; +#endif DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunication); }; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index d87eb65b2aed..5cd8ebcb30c8 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1,25 +1,20 @@ //===-- GDBRemoteCommunicationClient.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "GDBRemoteCommunicationClient.h" -// C Includes #include #include -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/State.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/XML.h" #include "lldb/Symbol/Symbol.h" @@ -31,9 +26,9 @@ #include "lldb/Utility/JSON.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" -// Project includes #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" #include "lldb/Host/Config.h" @@ -257,10 +252,7 @@ bool GDBRemoteCommunicationClient::GetVAttachOrWaitSupported() { m_attach_or_wait_reply = eLazyBoolYes; } } - if (m_attach_or_wait_reply == eLazyBoolYes) - return true; - else - return false; + return m_attach_or_wait_reply == eLazyBoolYes; } bool GDBRemoteCommunicationClient::GetSyncThreadStateSupported() { @@ -274,14 +266,11 @@ bool GDBRemoteCommunicationClient::GetSyncThreadStateSupported() { m_prepare_for_reg_writing_reply = eLazyBoolYes; } } - if (m_prepare_for_reg_writing_reply == eLazyBoolYes) - return true; - else - return false; + return m_prepare_for_reg_writing_reply == eLazyBoolYes; } void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { - if (did_exec == false) { + if (!did_exec) { // Hard reset everything, this is when we first connect to a GDB server m_supports_not_sending_acks = eLazyBoolCalculate; m_supports_thread_suffix = eLazyBoolCalculate; @@ -750,7 +739,7 @@ lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(bool allow_lazy) { bool sequence_mutex_unavailable; size_t size; size = GetCurrentThreadIDs(thread_ids, sequence_mutex_unavailable); - if (size && sequence_mutex_unavailable == false) { + if (size && !sequence_mutex_unavailable) { m_curr_pid = thread_ids.front(); m_curr_pid_is_valid = eLazyBoolYes; return m_curr_pid; @@ -844,8 +833,8 @@ int GDBRemoteCommunicationClient::SendEnvironmentPacket( if (name_equal_value && name_equal_value[0]) { StreamString packet; bool send_hex_encoding = false; - for (const char *p = name_equal_value; - *p != '\0' && send_hex_encoding == false; ++p) { + for (const char *p = name_equal_value; *p != '\0' && !send_hex_encoding; + ++p) { if (isprint(*p)) { switch (*p) { case '$': @@ -1135,6 +1124,9 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) { Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS)); if (force || m_qHostInfo_is_valid == eLazyBoolCalculate) { + // host info computation can require DNS traffic and shelling out to external processes. + // Increase the timeout to account for that. + ScopedTimeout timeout(*this, seconds(10)); m_qHostInfo_is_valid = eLazyBoolNo; StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse("qHostInfo", response, false) == @@ -1695,7 +1687,7 @@ Status GDBRemoteCommunicationClient::GetWatchpointSupportInfo(uint32_t &num) { found_num_field = true; } } - if (found_num_field == false) { + if (!found_num_field) { m_supports_watchpoint_support_info = eLazyBoolNo; } } else { @@ -1730,12 +1722,10 @@ GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction( // On targets like MIPS and ppc64le, watchpoint exceptions are always // generated before the instruction is executed. The connected target may // not support qHostInfo or qWatchpointSupportInfo packets. - if (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel || - atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el || - atype == llvm::Triple::ppc64le) - after = false; - else - after = true; + after = + !(atype == llvm::Triple::mips || atype == llvm::Triple::mipsel || + atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el || + atype == llvm::Triple::ppc64le); } else { // For MIPS and ppc64le, set m_watchpoints_trigger_after_instruction to // eLazyBoolNo if it is not calculated before. @@ -1821,7 +1811,7 @@ bool GDBRemoteCommunicationClient::GetWorkingDir(FileSpec &working_dir) { return false; std::string cwd; response.GetHexByteString(cwd); - working_dir.SetFile(cwd, false, GetHostArchitecture().GetTriple()); + working_dir.SetFile(cwd, GetHostArchitecture().GetTriple()); return !cwd.empty(); } return false; @@ -1931,8 +1921,7 @@ bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse( // characters in a process name std::string name; extractor.GetHexByteString(name); - process_info.GetExecutableFile().SetFile(name, false, - FileSpec::Style::native); + process_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); } else if (name.equals("cputype")) { value.getAsInteger(0, cpu); } else if (name.equals("cpusubtype")) { @@ -3565,7 +3554,7 @@ bool GDBRemoteCommunicationClient::GetModuleInfo( StringExtractor extractor(value); std::string path; extractor.GetHexByteString(path); - module_spec.GetFileSpec() = FileSpec(path, false, arch_spec.GetTriple()); + module_spec.GetFileSpec() = FileSpec(path, arch_spec.GetTriple()); } } @@ -3601,8 +3590,7 @@ ParseModuleSpec(StructuredData::Dictionary *dict) { if (!dict->GetValueForKeyAsString("file_path", string)) return llvm::None; - result.GetFileSpec() = - FileSpec(string, false, result.GetArchitecture().GetTriple()); + result.GetFileSpec() = FileSpec(string, result.GetArchitecture().GetTriple()); return result; } @@ -3780,7 +3768,7 @@ void GDBRemoteCommunicationClient::ServeSymbolLookups( // Is this the initial qSymbol:: packet? bool first_qsymbol_query = true; - if (m_supports_qSymbol && m_qSymbol_requests_done == false) { + if (m_supports_qSymbol && !m_qSymbol_requests_done) { Lock lock(*this, false); if (lock) { StreamString packet; @@ -3860,6 +3848,9 @@ void GDBRemoteCommunicationClient::ServeSymbolLookups( symbol_load_addr = sc.symbol->GetLoadAddress(&process->GetTarget()); break; + + case eSymbolTypeIVarOffset: + break; } } } diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index cf1d249768d7..3ab215657cd3 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -1,9 +1,8 @@ //===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,8 +11,6 @@ #include "GDBRemoteClientBase.h" -// C Includes -// C++ Includes #include #include #include diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp new file mode 100644 index 000000000000..664fd3b0210a --- /dev/null +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp @@ -0,0 +1,142 @@ +//===-- GDBRemoteCommunicationHistory.cpp -----------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "GDBRemoteCommunicationHistory.h" + +// Other libraries and framework includes +#include "lldb/Core/StreamFile.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Log.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; + +void GDBRemoteCommunicationHistory::Entry::Serialize(raw_ostream &strm) const { + yaml::Output yout(strm); + yout << const_cast(*this); + strm.flush(); +} + +GDBRemoteCommunicationHistory::GDBRemoteCommunicationHistory(uint32_t size) + : m_packets(), m_curr_idx(0), m_total_packet_count(0), + m_dumped_to_log(false) { + if (size) + m_packets.resize(size); +} + +GDBRemoteCommunicationHistory::~GDBRemoteCommunicationHistory() {} + +void GDBRemoteCommunicationHistory::AddPacket(char packet_char, PacketType type, + uint32_t bytes_transmitted) { + const size_t size = m_packets.size(); + if (size == 0) + return; + + const uint32_t idx = GetNextIndex(); + m_packets[idx].packet.data.assign(1, packet_char); + m_packets[idx].type = type; + m_packets[idx].bytes_transmitted = bytes_transmitted; + m_packets[idx].packet_idx = m_total_packet_count; + m_packets[idx].tid = llvm::get_threadid(); + if (m_stream && type == ePacketTypeRecv) + m_packets[idx].Serialize(*m_stream); +} + +void GDBRemoteCommunicationHistory::AddPacket(const std::string &src, + uint32_t src_len, PacketType type, + uint32_t bytes_transmitted) { + const size_t size = m_packets.size(); + if (size == 0) + return; + + const uint32_t idx = GetNextIndex(); + m_packets[idx].packet.data.assign(src, 0, src_len); + m_packets[idx].type = type; + m_packets[idx].bytes_transmitted = bytes_transmitted; + m_packets[idx].packet_idx = m_total_packet_count; + m_packets[idx].tid = llvm::get_threadid(); + if (m_stream && type == ePacketTypeRecv) + m_packets[idx].Serialize(*m_stream); +} + +void GDBRemoteCommunicationHistory::Dump(Stream &strm) const { + const uint32_t size = GetNumPacketsInHistory(); + const uint32_t first_idx = GetFirstSavedPacketIndex(); + const uint32_t stop_idx = m_curr_idx + size; + for (uint32_t i = first_idx; i < stop_idx; ++i) { + const uint32_t idx = NormalizeIndex(i); + const Entry &entry = m_packets[idx]; + if (entry.type == ePacketTypeInvalid || entry.packet.data.empty()) + break; + strm.Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n", + entry.packet_idx, entry.tid, entry.bytes_transmitted, + (entry.type == ePacketTypeSend) ? "send" : "read", + entry.packet.data.c_str()); + } +} + +void GDBRemoteCommunicationHistory::Dump(Log *log) const { + if (!log || m_dumped_to_log) + return; + + m_dumped_to_log = true; + const uint32_t size = GetNumPacketsInHistory(); + const uint32_t first_idx = GetFirstSavedPacketIndex(); + const uint32_t stop_idx = m_curr_idx + size; + for (uint32_t i = first_idx; i < stop_idx; ++i) { + const uint32_t idx = NormalizeIndex(i); + const Entry &entry = m_packets[idx]; + if (entry.type == ePacketTypeInvalid || entry.packet.data.empty()) + break; + log->Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s", + entry.packet_idx, entry.tid, entry.bytes_transmitted, + (entry.type == ePacketTypeSend) ? "send" : "read", + entry.packet.data.c_str()); + } +} + +void yaml::ScalarEnumerationTraits:: + enumeration(IO &io, GDBRemoteCommunicationHistory::PacketType &value) { + io.enumCase(value, "Invalid", + GDBRemoteCommunicationHistory::ePacketTypeInvalid); + io.enumCase(value, "Send", GDBRemoteCommunicationHistory::ePacketTypeSend); + io.enumCase(value, "Recv", GDBRemoteCommunicationHistory::ePacketTypeRecv); +} + +void yaml::ScalarTraits:: + output(const GDBRemoteCommunicationHistory::Entry::BinaryData &Val, void *, + raw_ostream &Out) { + Out << toHex(Val.data); +} + +StringRef +yaml::ScalarTraits::input( + StringRef Scalar, void *, + GDBRemoteCommunicationHistory::Entry::BinaryData &Val) { + Val.data = fromHex(Scalar); + return {}; +} + +void yaml::MappingTraits::mapping( + IO &io, GDBRemoteCommunicationHistory::Entry &Entry) { + io.mapRequired("packet", Entry.packet); + io.mapRequired("type", Entry.type); + io.mapRequired("bytes", Entry.bytes_transmitted); + io.mapRequired("index", Entry.packet_idx); + io.mapRequired("tid", Entry.tid); +} + +StringRef yaml::MappingTraits::validate( + IO &io, GDBRemoteCommunicationHistory::Entry &Entry) { + if (Entry.bytes_transmitted != Entry.packet.data.size()) + return "BinaryData size doesn't match bytes transmitted"; + + return {}; +} diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h new file mode 100644 index 000000000000..85f112b50623 --- /dev/null +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h @@ -0,0 +1,155 @@ +//===-- GDBRemoteCommunicationHistory.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_GDBRemoteCommunicationHistory_h_ +#define liblldb_GDBRemoteCommunicationHistory_h_ + +#include +#include + +#include "lldb/lldb-public.h" +#include "llvm/Support/YAMLTraits.h" +#include "llvm/Support/raw_ostream.h" + +namespace lldb_private { +namespace process_gdb_remote { + +/// The history keeps a circular buffer of GDB remote packets. The history is +/// used for logging and replaying GDB remote packets. +class GDBRemoteCommunicationHistory { +public: + friend llvm::yaml::MappingTraits; + + enum PacketType { ePacketTypeInvalid = 0, ePacketTypeSend, ePacketTypeRecv }; + + /// Entry in the ring buffer containing the packet data, its type, size and + /// index. Entries can be serialized to file. + struct Entry { + Entry() + : packet(), type(ePacketTypeInvalid), bytes_transmitted(0), + packet_idx(0), tid(LLDB_INVALID_THREAD_ID) {} + + void Clear() { + packet.data.clear(); + type = ePacketTypeInvalid; + bytes_transmitted = 0; + packet_idx = 0; + tid = LLDB_INVALID_THREAD_ID; + } + + struct BinaryData { + std::string data; + }; + + void Serialize(llvm::raw_ostream &strm) const; + + BinaryData packet; + PacketType type; + uint32_t bytes_transmitted; + uint32_t packet_idx; + lldb::tid_t tid; + }; + + GDBRemoteCommunicationHistory(uint32_t size = 0); + + ~GDBRemoteCommunicationHistory(); + + // For single char packets for ack, nack and /x03 + void AddPacket(char packet_char, PacketType type, uint32_t bytes_transmitted); + + void AddPacket(const std::string &src, uint32_t src_len, PacketType type, + uint32_t bytes_transmitted); + + void Dump(Stream &strm) const; + void Dump(Log *log) const; + bool DidDumpToLog() const { return m_dumped_to_log; } + + void SetStream(llvm::raw_ostream *strm) { m_stream = strm; } + +private: + uint32_t GetFirstSavedPacketIndex() const { + if (m_total_packet_count < m_packets.size()) + return 0; + else + return m_curr_idx + 1; + } + + uint32_t GetNumPacketsInHistory() const { + if (m_total_packet_count < m_packets.size()) + return m_total_packet_count; + else + return (uint32_t)m_packets.size(); + } + + uint32_t GetNextIndex() { + ++m_total_packet_count; + const uint32_t idx = m_curr_idx; + m_curr_idx = NormalizeIndex(idx + 1); + return idx; + } + + uint32_t NormalizeIndex(uint32_t i) const { + return m_packets.empty() ? 0 : i % m_packets.size(); + } + + std::vector m_packets; + uint32_t m_curr_idx; + uint32_t m_total_packet_count; + mutable bool m_dumped_to_log; + llvm::raw_ostream *m_stream = nullptr; +}; + +} // namespace process_gdb_remote +} // namespace lldb_private + +LLVM_YAML_IS_DOCUMENT_LIST_VECTOR( + lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Entry) + +namespace llvm { +namespace yaml { + +template <> +struct ScalarEnumerationTraits { + static void enumeration(IO &io, + lldb_private::process_gdb_remote:: + GDBRemoteCommunicationHistory::PacketType &value); +}; + +template <> +struct ScalarTraits { + static void output(const lldb_private::process_gdb_remote:: + GDBRemoteCommunicationHistory::Entry::BinaryData &, + void *, raw_ostream &); + + static StringRef + input(StringRef, void *, + lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Entry:: + BinaryData &); + + static QuotingType mustQuote(StringRef S) { return QuotingType::None; } +}; + +template <> +struct MappingTraits< + lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Entry> { + static void + mapping(IO &io, + lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Entry + &Entry); + + static StringRef validate( + IO &io, + lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Entry &); +}; + +} // namespace yaml +} // namespace llvm + +#endif // liblldb_GDBRemoteCommunicationHistory_h_ diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp new file mode 100644 index 000000000000..50a53b43ed88 --- /dev/null +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp @@ -0,0 +1,203 @@ +//===-- GDBRemoteCommunicationReplayServer.cpp ------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include + +#include "lldb/Host/Config.h" + +#include "GDBRemoteCommunicationReplayServer.h" +#include "ProcessGDBRemoteLog.h" + +// C Includes +// C++ Includes +#include + +// Project includes +#include "lldb/Host/ThreadLauncher.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StringExtractorGDBRemote.h" + +using namespace llvm; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; + +GDBRemoteCommunicationReplayServer::GDBRemoteCommunicationReplayServer() + : GDBRemoteCommunication("gdb-remote.server", + "gdb-remote.server.rx_packet"), + m_async_broadcaster(nullptr, "lldb.gdb-remote.server.async-broadcaster"), + m_async_listener_sp( + Listener::MakeListener("lldb.gdb-remote.server.async-listener")), + m_async_thread_state_mutex(), m_skip_acks(false) { + m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue, + "async thread continue"); + m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit, + "async thread should exit"); + + const uint32_t async_event_mask = + eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit; + m_async_listener_sp->StartListeningForEvents(&m_async_broadcaster, + async_event_mask); +} + +GDBRemoteCommunicationReplayServer::~GDBRemoteCommunicationReplayServer() { + StopAsyncThread(); +} + +GDBRemoteCommunication::PacketResult +GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse( + Timeout timeout, Status &error, bool &interrupt, bool &quit) { + StringExtractorGDBRemote packet; + PacketResult packet_result = WaitForPacketNoLock(packet, timeout, false); + + if (packet_result != PacketResult::Success) { + if (!IsConnected()) { + error.SetErrorString("lost connection"); + quit = true; + } else { + error.SetErrorString("timeout"); + } + return packet_result; + } + + m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); + + if (m_skip_acks) { + const StringExtractorGDBRemote::ServerPacketType packet_type = + packet.GetServerPacketType(); + switch (packet_type) { + case StringExtractorGDBRemote::eServerPacketType_nack: + case StringExtractorGDBRemote::eServerPacketType_ack: + return PacketResult::Success; + default: + break; + } + } else if (packet.GetStringRef() == "QStartNoAckMode") { + m_skip_acks = true; + m_send_acks = false; + } + + while (!m_packet_history.empty()) { + // Pop last packet from the history. + GDBRemoteCommunicationHistory::Entry entry = m_packet_history.back(); + m_packet_history.pop_back(); + + // We only care about what we received from the server. Skip everything + // the client sent. + if (entry.type != GDBRemoteCommunicationHistory::ePacketTypeRecv) + continue; + + return SendRawPacketNoLock(entry.packet.data, true); + } + + quit = true; + + return packet_result; +} + +LLVM_YAML_IS_DOCUMENT_LIST_VECTOR( + std::vector< + lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Entry>) + +llvm::Error +GDBRemoteCommunicationReplayServer::LoadReplayHistory(const FileSpec &path) { + auto error_or_file = MemoryBuffer::getFile(path.GetPath()); + if (auto err = error_or_file.getError()) + return errorCodeToError(err); + + yaml::Input yin((*error_or_file)->getBuffer()); + yin >> m_packet_history; + + if (auto err = yin.error()) + return errorCodeToError(err); + + // We want to manipulate the vector like a stack so we need to reverse the + // order of the packets to have the oldest on at the back. + std::reverse(m_packet_history.begin(), m_packet_history.end()); + + return Error::success(); +} + +bool GDBRemoteCommunicationReplayServer::StartAsyncThread() { + std::lock_guard guard(m_async_thread_state_mutex); + if (!m_async_thread.IsJoinable()) { + // Create a thread that watches our internal state and controls which + // events make it to clients (into the DCProcess event queue). + m_async_thread = ThreadLauncher::LaunchThread( + "", + GDBRemoteCommunicationReplayServer::AsyncThread, this, nullptr); + } + + // Wait for handshake. + m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); + + return m_async_thread.IsJoinable(); +} + +void GDBRemoteCommunicationReplayServer::StopAsyncThread() { + std::lock_guard guard(m_async_thread_state_mutex); + + if (!m_async_thread.IsJoinable()) + return; + + // Request thread to stop. + m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncThreadShouldExit); + + // Disconnect client. + Disconnect(); + + // Stop the thread. + m_async_thread.Join(nullptr); + m_async_thread.Reset(); +} + +void GDBRemoteCommunicationReplayServer::ReceivePacket( + GDBRemoteCommunicationReplayServer &server, bool &done) { + Status error; + bool interrupt; + auto packet_result = server.GetPacketAndSendResponse(std::chrono::seconds(1), + error, interrupt, done); + if (packet_result != GDBRemoteCommunication::PacketResult::Success && + packet_result != + GDBRemoteCommunication::PacketResult::ErrorReplyTimeout) { + done = true; + } else { + server.m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue); + } +} + +thread_result_t GDBRemoteCommunicationReplayServer::AsyncThread(void *arg) { + GDBRemoteCommunicationReplayServer *server = + (GDBRemoteCommunicationReplayServer *)arg; + + EventSP event_sp; + bool done = false; + + while (true) { + if (server->m_async_listener_sp->GetEvent(event_sp, llvm::None)) { + const uint32_t event_type = event_sp->GetType(); + if (event_sp->BroadcasterIs(&server->m_async_broadcaster)) { + switch (event_type) { + case eBroadcastBitAsyncContinue: + ReceivePacket(*server, done); + if (done) + return {}; + break; + case eBroadcastBitAsyncThreadShouldExit: + default: + return {}; + } + } + } + } + + return {}; +} diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h new file mode 100644 index 000000000000..26d65e265463 --- /dev/null +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h @@ -0,0 +1,82 @@ +//===-- GDBRemoteCommunicationReplayServer.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_GDBRemoteCommunicationReplayServer_h_ +#define liblldb_GDBRemoteCommunicationReplayServer_h_ + +// Other libraries and framework includes +#include "GDBRemoteCommunication.h" +#include "GDBRemoteCommunicationHistory.h" + +// Project includes +#include "lldb/Host/HostThread.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/lldb-private-forward.h" +#include "llvm/Support/Error.h" + +// C Includes +// C++ Includes +#include +#include +#include + +class StringExtractorGDBRemote; + +namespace lldb_private { +namespace process_gdb_remote { + +class ProcessGDBRemote; + +/// Dummy GDB server that replays packets from the GDB Remote Communication +/// history. This is used to replay GDB packets. +class GDBRemoteCommunicationReplayServer : public GDBRemoteCommunication { +public: + GDBRemoteCommunicationReplayServer(); + + ~GDBRemoteCommunicationReplayServer() override; + + PacketResult GetPacketAndSendResponse(Timeout timeout, + Status &error, bool &interrupt, + bool &quit); + + bool HandshakeWithClient() { return GetAck() == PacketResult::Success; } + + llvm::Error LoadReplayHistory(const FileSpec &path); + + bool StartAsyncThread(); + void StopAsyncThread(); + +protected: + enum { + eBroadcastBitAsyncContinue = (1 << 0), + eBroadcastBitAsyncThreadShouldExit = (1 << 1), + }; + + static void ReceivePacket(GDBRemoteCommunicationReplayServer &server, + bool &done); + static lldb::thread_result_t AsyncThread(void *arg); + + /// Replay history with the oldest packet at the end. + std::vector m_packet_history; + + /// Server thread. + Broadcaster m_async_broadcaster; + lldb::ListenerSP m_async_listener_sp; + HostThread m_async_thread; + std::recursive_mutex m_async_thread_state_mutex; + + bool m_skip_acks; + +private: + DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationReplayServer); +}; + +} // namespace process_gdb_remote +} // namespace lldb_private + +#endif // liblldb_GDBRemoteCommunicationReplayServer_h_ diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 4fc1fc7a1964..ddcd4cbbeb09 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -1,9 +1,8 @@ //===-- GDBRemoteCommunicationServer.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,11 +12,8 @@ #include "GDBRemoteCommunicationServer.h" -// C Includes -// C++ Includes #include -// Project includes #include "ProcessGDBRemoteLog.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringExtractorGDBRemote.h" diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h index 880caacd6414..f2b2d1ef815f 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h @@ -1,22 +1,17 @@ //===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_GDBRemoteCommunicationServer_h_ #define liblldb_GDBRemoteCommunicationServer_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "GDBRemoteCommunication.h" #include "lldb/lldb-private-forward.h" diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index c5b478378faa..276ca65e8627 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -1,9 +1,8 @@ //===-- GDBRemoteCommunicationServerCommon.cpp ------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,23 +10,21 @@ #include -// C Includes #ifdef __APPLE__ #include #endif -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Config.h" #include "lldb/Host/File.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Host/SafeMachO.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/FileAction.h" @@ -36,12 +33,10 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/JSON.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/StreamGDBRemote.h" #include "lldb/Utility/StreamString.h" #include "llvm/ADT/Triple.h" -// Project includes #include "ProcessGDBRemoteLog.h" #include "lldb/Utility/StringExtractorGDBRemote.h" @@ -353,7 +348,7 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo( std::string file; extractor.GetHexByteString(file); match_info.GetProcessInfo().GetExecutableFile().SetFile( - file, false, FileSpec::Style::native); + file, FileSpec::Style::native); } else if (key.equals("name_match")) { NameMatch name_match = llvm::StringSwitch(value) .Case("equals", NameMatch::Equals) @@ -520,7 +515,8 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open( if (packet.GetChar() == ',') { mode_t mode = packet.GetHexMaxU32(false, 0600); Status error; - const FileSpec path_spec{path, true}; + FileSpec path_spec(path); + FileSystem::Instance().Resolve(path_spec); int fd = ::open(path_spec.GetCString(), flags, mode); const int save_errno = fd == -1 ? errno : 0; StreamString response; @@ -659,12 +655,14 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Mode( std::string path; packet.GetHexByteString(path); if (!path.empty()) { - Status error; - const uint32_t mode = File::GetPermissions(FileSpec{path, true}, error); + FileSpec file_spec(path); + FileSystem::Instance().Resolve(file_spec); + std::error_code ec; + const uint32_t mode = FileSystem::Instance().GetPermissions(file_spec, ec); StreamString response; response.Printf("F%u", mode); - if (mode == 0 || error.Fail()) - response.Printf(",%i", (int)error.GetError()); + if (mode == 0 || ec) + response.Printf(",%i", (int)Status(ec).GetError()); return SendPacketNoLock(response.GetString()); } return SendErrorResponse(23); @@ -698,7 +696,11 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_symlink( packet.GetHexByteStringTerminatedBy(dst, ','); packet.GetChar(); // Skip ',' char packet.GetHexByteString(src); - Status error = FileSystem::Symlink(FileSpec{src, true}, FileSpec{dst, false}); + + FileSpec src_spec(src); + FileSystem::Instance().Resolve(src_spec); + Status error = FileSystem::Instance().Symlink(src_spec, FileSpec(dst)); + StreamString response; response.Printf("F%u,%u", error.GetError(), error.GetError()); return SendPacketNoLock(response.GetString()); @@ -731,9 +733,11 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell( packet.GetHexByteString(working_dir); int status, signo; std::string output; - Status err = Host::RunShellCommand( - path.c_str(), FileSpec{working_dir, true}, &status, &signo, &output, - std::chrono::seconds(10)); + FileSpec working_spec(working_dir); + FileSystem::Instance().Resolve(working_spec); + Status err = + Host::RunShellCommand(path.c_str(), working_spec, &status, &signo, + &output, std::chrono::seconds(10)); StreamGDBRemote response; if (err.Fail()) { response.PutCString("F,"); @@ -884,7 +888,7 @@ GDBRemoteCommunicationServerCommon::Handle_QSetSTDIN( packet.GetHexByteString(path); const bool read = true; const bool write = false; - if (file_action.Open(STDIN_FILENO, FileSpec{path, false}, read, write)) { + if (file_action.Open(STDIN_FILENO, FileSpec(path), read, write)) { m_process_launch_info.AppendFileAction(file_action); return SendOKResponse(); } @@ -900,7 +904,7 @@ GDBRemoteCommunicationServerCommon::Handle_QSetSTDOUT( packet.GetHexByteString(path); const bool read = false; const bool write = true; - if (file_action.Open(STDOUT_FILENO, FileSpec{path, false}, read, write)) { + if (file_action.Open(STDOUT_FILENO, FileSpec(path), read, write)) { m_process_launch_info.AppendFileAction(file_action); return SendOKResponse(); } @@ -916,7 +920,7 @@ GDBRemoteCommunicationServerCommon::Handle_QSetSTDERR( packet.GetHexByteString(path); const bool read = false; const bool write = true; - if (file_action.Open(STDERR_FILENO, FileSpec{path, false}, read, write)) { + if (file_action.Open(STDERR_FILENO, FileSpec(path), read, write)) { m_process_launch_info.AppendFileAction(file_action); return SendOKResponse(); } @@ -1024,7 +1028,7 @@ GDBRemoteCommunicationServerCommon::Handle_A(StringExtractorGDBRemote &packet) { if (success) { if (arg_idx == 0) m_process_launch_info.GetExecutableFile().SetFile( - arg, false, FileSpec::Style::native); + arg, FileSpec::Style::native); m_process_launch_info.GetArguments().AppendArgument(arg); if (log) log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"", @@ -1263,7 +1267,9 @@ FileSpec GDBRemoteCommunicationServerCommon::FindModuleFile( #ifdef __ANDROID__ return HostInfoAndroid::ResolveLibraryPath(module_path, arch); #else - return FileSpec(module_path, true); + FileSpec file_spec(module_path); + FileSystem::Instance().Resolve(file_spec); + return file_spec; #endif } @@ -1272,7 +1278,9 @@ GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple) { ArchSpec arch(triple); - const FileSpec req_module_path_spec(module_path, true); + FileSpec req_module_path_spec(module_path); + FileSystem::Instance().Resolve(req_module_path_spec); + const FileSpec module_path_spec = FindModuleFile(req_module_path_spec.GetPath(), arch); const ModuleSpec module_spec(module_path_spec, arch); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h index e9ab8f1a11de..c9400687b3bf 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h @@ -1,21 +1,16 @@ //===-- GDBRemoteCommunicationServerCommon.h --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_GDBRemoteCommunicationServerCommon_h_ #define liblldb_GDBRemoteCommunicationServerCommon_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/lldb-private-forward.h" diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 50392fa38956..4b618153f981 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -1,9 +1,8 @@ //===-- GDBRemoteCommunicationServerLLGS.cpp --------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,15 +13,10 @@ #include "GDBRemoteCommunicationServerLLGS.h" #include "lldb/Utility/StreamGDBRemote.h" -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/State.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Debug.h" #include "lldb/Host/File.h" @@ -41,12 +35,13 @@ #include "lldb/Utility/JSON.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UriParser.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/ScopedPrinter.h" -// Project includes #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" #include "lldb/Utility/StringExtractorGDBRemote.h" @@ -222,8 +217,10 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() { m_process_launch_info.SetLaunchInSeparateProcessGroup(true); m_process_launch_info.GetFlags().Set(eLaunchFlagDebug); - const bool default_to_use_pty = true; - m_process_launch_info.FinalizeFileActions(nullptr, default_to_use_pty); + if (should_forward_stdio) { + if (llvm::Error Err = m_process_launch_info.SetUpPtyRedirection()) + return Status(std::move(Err)); + } { std::lock_guard guard(m_debugged_process_mutex); @@ -1333,7 +1330,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QSetWorkingDir( packet.SetFilePos(::strlen("QSetWorkingDir:")); std::string path; packet.GetHexByteString(path); - m_process_launch_info.SetWorkingDirectory(FileSpec{path, true}); + m_process_launch_info.SetWorkingDirectory(FileSpec(path)); return SendOKResponse(); } @@ -3220,7 +3217,7 @@ GDBRemoteCommunicationServerLLGS::FindModuleFile(const std::string &module_path, if (m_debugged_process_up ->GetLoadedModuleFileSpec(module_path.c_str(), file_spec) .Success()) { - if (file_spec.Exists()) + if (FileSystem::Instance().Exists(file_spec)) return file_spec; } } diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index 5a74d1acaa23..e26d0591d5ee 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -1,27 +1,22 @@ //===-- GDBRemoteCommunicationServerLLGS.h ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_GDBRemoteCommunicationServerLLGS_h_ #define liblldb_GDBRemoteCommunicationServerLLGS_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Core/Communication.h" #include "lldb/Host/MainLoop.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/lldb-private-forward.h" -// Project includes #include "GDBRemoteCommunicationServerCommon.h" class StringExtractorGDBRemote; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 3ee4e3b6d7ee..fc7fdb2ef519 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -1,9 +1,8 @@ //===-- GDBRemoteCommunicationServerPlatform.cpp ----------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,15 +10,12 @@ #include -// C Includes -// C++ Includes #include #include #include #include #include -// Other libraries and framework includes #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" @@ -38,7 +34,6 @@ #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UriParser.h" -// Project includes #include "lldb/Utility/StringExtractorGDBRemote.h" using namespace lldb; @@ -168,9 +163,6 @@ Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer( StringExtractorGDBRemote &packet) { -#ifdef _WIN32 - return SendErrorResponse(9); -#else // Spawn a local debugserver as a platform so we can then attach or launch a // process... @@ -221,10 +213,9 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer( PacketResult packet_result = SendPacketNoLock(response.GetString()); if (packet_result != PacketResult::Success) { if (debugserver_pid != LLDB_INVALID_PROCESS_ID) - ::kill(debugserver_pid, SIGINT); + Host::Kill(debugserver_pid, SIGINT); } return packet_result; -#endif } GDBRemoteCommunication::PacketResult @@ -532,7 +523,7 @@ const FileSpec &GDBRemoteCommunicationServerPlatform::GetDomainSocketDir() { const char *domainsocket_dir_env = ::getenv("LLDB_DEBUGSERVER_DOMAINSOCKET_DIR"); if (domainsocket_dir_env != nullptr) - g_domainsocket_dir = FileSpec(domainsocket_dir_env, false); + g_domainsocket_dir = FileSpec(domainsocket_dir_env); else g_domainsocket_dir = HostInfo::GetProcessTempDir(); }); @@ -542,15 +533,15 @@ const FileSpec &GDBRemoteCommunicationServerPlatform::GetDomainSocketDir() { FileSpec GDBRemoteCommunicationServerPlatform::GetDomainSocketPath(const char *prefix) { - llvm::SmallString socket_path; - llvm::SmallString socket_name( + llvm::SmallString<128> socket_path; + llvm::SmallString<128> socket_name( (llvm::StringRef(prefix) + ".%%%%%%").str()); FileSpec socket_path_spec(GetDomainSocketDir()); socket_path_spec.AppendPathComponent(socket_name.c_str()); llvm::sys::fs::createUniqueFile(socket_path_spec.GetCString(), socket_path); - return FileSpec(socket_path.c_str(), false); + return FileSpec(socket_path.c_str()); } void GDBRemoteCommunicationServerPlatform::SetPortOffset(uint16_t port_offset) { diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h index aed5106272d1..f0ee77dc1d66 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -1,23 +1,18 @@ //===-- GDBRemoteCommunicationServerPlatform.h ------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_GDBRemoteCommunicationServerPlatform_h_ #define liblldb_GDBRemoteCommunicationServerPlatform_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "GDBRemoteCommunicationServerCommon.h" #include "lldb/Host/Socket.h" diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 07dab751f4b9..11cb034dc535 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -1,25 +1,20 @@ //===-- GDBRemoteRegisterContext.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "GDBRemoteRegisterContext.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" -// Project includes #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" #include "ThreadGDBRemote.h" @@ -462,7 +457,7 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues( ((ProcessGDBRemote *)process)->GetGDBRemote()); const bool use_g_packet = - gdb_comm.AvoidGPackets((ProcessGDBRemote *)process) == false; + !gdb_comm.AvoidGPackets((ProcessGDBRemote *)process); GDBRemoteClientBase::Lock lock(gdb_comm, false); if (lock) { @@ -525,7 +520,7 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues( ((ProcessGDBRemote *)process)->GetGDBRemote()); const bool use_g_packet = - gdb_comm.AvoidGPackets((ProcessGDBRemote *)process) == false; + !gdb_comm.AvoidGPackets((ProcessGDBRemote *)process); GDBRemoteClientBase::Lock lock(gdb_comm, false); if (lock) { diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h index 8ef91af55e0f..25e9b716f8cb 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h @@ -1,21 +1,16 @@ //===-- GDBRemoteRegisterContext.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_GDBRemoteRegisterContext_h_ #define lldb_GDBRemoteRegisterContext_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "Plugins/Process/Utility/DynamicRegisterInfo.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/ConstString.h" diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index fbe809d5f0ba..d2e0313863e2 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1,20 +1,18 @@ //===-- ProcessGDBRemote.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Host/Config.h" -// C Includes #include #include #ifndef LLDB_DISABLE_POSIX #include -#include // for mmap +#include #include #include #endif @@ -22,7 +20,6 @@ #include #include -// C++ Includes #include #include #include @@ -34,7 +31,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/DataFormatters/FormatManager.h" @@ -68,10 +64,11 @@ #include "lldb/Utility/Args.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Reproducer.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" -// Project includes #include "GDBRemoteRegisterContext.h" #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" #include "Plugins/Process/Utility/GDBRemoteSignals.h" @@ -88,6 +85,7 @@ #include "llvm/Support/raw_ostream.h" #define DEBUGSERVER_BASENAME "debugserver" +using namespace llvm; using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_gdb_remote; @@ -101,12 +99,13 @@ namespace lldb { // and get the packet history dumped to a file. void DumpProcessGDBRemotePacketHistory(void *p, const char *path) { StreamFile strm; - Status error(strm.GetFile().Open(path, File::eOpenOptionWrite | - File::eOpenOptionCanCreate)); + Status error = FileSystem::Instance().Open(strm.GetFile(), FileSpec(path), + File::eOpenOptionWrite | + File::eOpenOptionCanCreate); if (error.Success()) ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory(strm); } -} +} // namespace lldb namespace { @@ -157,7 +156,49 @@ static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() { return g_settings_sp; } -} // anonymous namespace end +struct ProcessGDBRemoteInfo { + static const char *name; + static const char *file; +}; + +const char *ProcessGDBRemoteInfo::name = "gdb-remote"; +const char *ProcessGDBRemoteInfo::file = "gdb-remote.yaml"; + +class ProcessGDBRemoteProvider + : public repro::Provider { +public: + typedef ProcessGDBRemoteInfo info; + + ProcessGDBRemoteProvider(const FileSpec &directory) : Provider(directory) { + } + + raw_ostream *GetHistoryStream() { + FileSpec history_file = GetRoot().CopyByAppendingPathComponent(info::file); + + std::error_code EC; + m_stream_up = llvm::make_unique(history_file.GetPath(), EC, + sys::fs::OpenFlags::F_None); + return m_stream_up.get(); + } + + void SetCallback(std::function callback) { + m_callback = std::move(callback); + } + + void Keep() override { m_callback(); } + + void Discard() override { m_callback(); } + + static char ID; + +private: + std::function m_callback; + std::unique_ptr m_stream_up; +}; + +char ProcessGDBRemoteProvider::ID = 0; + +} // namespace // TODO Randomly assigning a port is unsafe. We should get an unused // ephemeral port from the kernel and make sure we reserve it before passing it @@ -233,7 +274,7 @@ bool ProcessGDBRemote::CanDebug(lldb::TargetSP target_sp, case ObjectFile::eTypeUnknown: break; } - return exe_module->GetFileSpec().Exists(); + return FileSystem::Instance().Exists(exe_module->GetFileSpec()); } // However, if there is no executable module, we return true since we might // be preparing to attach. @@ -258,8 +299,8 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, m_addr_to_mmap_size(), m_thread_create_bp_sp(), m_waiting_for_attach(false), m_destroy_tried_resuming(false), m_command_sp(), m_breakpoint_pc_offset(0), - m_initial_tid(LLDB_INVALID_THREAD_ID), m_allow_flash_writes(false), - m_erased_flash_ranges() { + m_initial_tid(LLDB_INVALID_THREAD_ID), m_replay_mode(false), + m_allow_flash_writes(false), m_erased_flash_ranges() { m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue, @@ -267,6 +308,15 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadDidExit, "async thread did exit"); + if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) { + ProcessGDBRemoteProvider &provider = + g->GetOrCreate(); + // Set the history stream to the stream owned by the provider. + m_gdb_comm.SetHistoryStream(provider.GetHistoryStream()); + // Make sure to clear the stream again when we're finished. + provider.SetCallback([&]() { m_gdb_comm.SetHistoryStream(nullptr); }); + } + Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_ASYNC)); const uint32_t async_event_mask = @@ -439,10 +489,10 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { FileSpec target_definition_fspec = GetGlobalPluginProperties()->GetTargetDefinitionFile(); - if (!target_definition_fspec.Exists()) { + if (!FileSystem::Instance().Exists(target_definition_fspec)) { // If the filename doesn't exist, it may be a ~ not having been expanded - // try to resolve it. - target_definition_fspec.ResolvePath(); + FileSystem::Instance().Resolve(target_definition_fspec); } if (target_definition_fspec) { // See if we can get register definitions from a python file @@ -639,7 +689,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { m_register_info.Finalize(GetTarget().GetArchitecture()); } -Status ProcessGDBRemote::WillLaunch(Module *module) { +Status ProcessGDBRemote::WillLaunch(lldb_private::Module *module) { return WillLaunchOrAttach(); } @@ -755,7 +805,7 @@ Status ProcessGDBRemote::WillLaunchOrAttach() { //---------------------------------------------------------------------- // Process Control //---------------------------------------------------------------------- -Status ProcessGDBRemote::DoLaunch(Module *exe_module, +Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module, ProcessLaunchInfo &launch_info) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); Status error; @@ -825,13 +875,13 @@ Status ProcessGDBRemote::DoLaunch(Module *exe_module, if (disable_stdio) { // set to /dev/null unless redirected to a file above if (!stdin_file_spec) - stdin_file_spec.SetFile(FileSystem::DEV_NULL, false, + stdin_file_spec.SetFile(FileSystem::DEV_NULL, FileSpec::Style::native); if (!stdout_file_spec) - stdout_file_spec.SetFile(FileSystem::DEV_NULL, false, + stdout_file_spec.SetFile(FileSystem::DEV_NULL, FileSpec::Style::native); if (!stderr_file_spec) - stderr_file_spec.SetFile(FileSystem::DEV_NULL, false, + stderr_file_spec.SetFile(FileSystem::DEV_NULL, FileSpec::Style::native); } else if (platform_sp && platform_sp->IsHost()) { // If the debugserver is local and we aren't disabling STDIO, lets use @@ -840,7 +890,7 @@ Status ProcessGDBRemote::DoLaunch(Module *exe_module, // does a lot of output. if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) && pty.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, NULL, 0)) { - FileSpec slave_name{pty.GetSlaveName(NULL, 0), false}; + FileSpec slave_name{pty.GetSlaveName(NULL, 0)}; if (!stdin_file_spec) stdin_file_spec = slave_name; @@ -1059,9 +1109,10 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { if (log) log->Printf("ProcessGDBRemote::%s gdb-remote had process architecture, " "using %s %s", - __FUNCTION__, process_arch.GetArchitectureName() - ? process_arch.GetArchitectureName() - : "", + __FUNCTION__, + process_arch.GetArchitectureName() + ? process_arch.GetArchitectureName() + : "", process_arch.GetTriple().getTriple().c_str() ? process_arch.GetTriple().getTriple().c_str() : ""); @@ -1070,9 +1121,10 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { if (log) log->Printf("ProcessGDBRemote::%s gdb-remote did not have process " "architecture, using gdb-remote host architecture %s %s", - __FUNCTION__, process_arch.GetArchitectureName() - ? process_arch.GetArchitectureName() - : "", + __FUNCTION__, + process_arch.GetArchitectureName() + ? process_arch.GetArchitectureName() + : "", process_arch.GetTriple().getTriple().c_str() ? process_arch.GetTriple().getTriple().c_str() : ""); @@ -1084,9 +1136,10 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { if (log) log->Printf( "ProcessGDBRemote::%s analyzing target arch, currently %s %s", - __FUNCTION__, target_arch.GetArchitectureName() - ? target_arch.GetArchitectureName() - : "", + __FUNCTION__, + target_arch.GetArchitectureName() + ? target_arch.GetArchitectureName() + : "", target_arch.GetTriple().getTriple().c_str() ? target_arch.GetTriple().getTriple().c_str() : ""); @@ -1106,9 +1159,10 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { if (log) log->Printf("ProcessGDBRemote::%s remote process is ARM/Apple, " "setting target arch to %s %s", - __FUNCTION__, process_arch.GetArchitectureName() - ? process_arch.GetArchitectureName() - : "", + __FUNCTION__, + process_arch.GetArchitectureName() + ? process_arch.GetArchitectureName() + : "", process_arch.GetTriple().getTriple().c_str() ? process_arch.GetTriple().getTriple().c_str() : ""); @@ -1136,9 +1190,10 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { if (log) log->Printf("ProcessGDBRemote::%s final target arch after " "adjustments for remote architecture: %s %s", - __FUNCTION__, target_arch.GetArchitectureName() - ? target_arch.GetArchitectureName() - : "", + __FUNCTION__, + target_arch.GetArchitectureName() + ? target_arch.GetArchitectureName() + : "", target_arch.GetTriple().getTriple().c_str() ? target_arch.GetTriple().getTriple().c_str() : ""); @@ -1479,7 +1534,7 @@ Status ProcessGDBRemote::DoResume() { new EventDataBytes(continue_packet.GetString().data(), continue_packet.GetSize())); - if (listener_sp->GetEvent(event_sp, std::chrono::seconds(5)) == false) { + if (!listener_sp->GetEvent(event_sp, std::chrono::seconds(5))) { error.SetErrorString("Resume timed out."); if (log) log->Printf("ProcessGDBRemote::DoResume: Resume timed out."); @@ -1833,7 +1888,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( bool handled = false; bool did_exec = false; if (!reason.empty()) { - if (reason.compare("trace") == 0) { + if (reason == "trace") { addr_t pc = thread_sp->GetRegisterContext()->GetPC(); lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess() ->GetBreakpointSiteList() @@ -1851,7 +1906,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( thread_sp->SetStopInfo( StopInfo::CreateStopReasonToTrace(*thread_sp)); handled = true; - } else if (reason.compare("breakpoint") == 0) { + } else if (reason == "breakpoint") { addr_t pc = thread_sp->GetRegisterContext()->GetPC(); lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess() ->GetBreakpointSiteList() @@ -1872,9 +1927,9 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( thread_sp->SetStopInfo(invalid_stop_info_sp); } } - } else if (reason.compare("trap") == 0) { + } else if (reason == "trap") { // Let the trap just use the standard signal stop reason below... - } else if (reason.compare("watchpoint") == 0) { + } else if (reason == "watchpoint") { StringExtractor desc_extractor(description.c_str()); addr_t wp_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); uint32_t wp_index = desc_extractor.GetU32(LLDB_INVALID_INDEX32); @@ -1906,11 +1961,11 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithWatchpointID( *thread_sp, watch_id, wp_hit_addr)); handled = true; - } else if (reason.compare("exception") == 0) { + } else if (reason == "exception") { thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithException( *thread_sp, description.c_str())); handled = true; - } else if (reason.compare("exec") == 0) { + } else if (reason == "exec") { did_exec = true; thread_sp->SetStopInfo( StopInfo::CreateStopReasonWithExec(*thread_sp)); @@ -1935,7 +1990,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( } } - if (!handled && signo && did_exec == false) { + if (!handled && signo && !did_exec) { if (signo == SIGTRAP) { // Currently we are going to assume SIGTRAP means we are either // hitting a breakpoint or hardware single stepping. @@ -2649,7 +2704,7 @@ void ProcessGDBRemote::SetLastStopPacket( // We are are not using non-stop mode, there can only be one last stop // reply packet, so clear the list. - if (GetTarget().GetNonStopModeEnabled() == false) + if (!GetTarget().GetNonStopModeEnabled()) m_stop_packet_stack.clear(); // Add this stop packet to the stop packet stack This stack will get popped @@ -3379,6 +3434,37 @@ Status ProcessGDBRemote::DoSignal(int signo) { return error; } +Status ProcessGDBRemote::ConnectToReplayServer(repro::Loader *loader) { + if (!loader) + return Status("No loader provided."); + + // Construct replay history path. + FileSpec history_file = loader->GetFile(); + if (!history_file) + return Status("No provider for gdb-remote."); + + // Enable replay mode. + m_replay_mode = true; + + // Load replay history. + if (auto error = m_gdb_replay_server.LoadReplayHistory(history_file)) + return Status("Unable to load replay history"); + + // Make a local connection. + if (auto error = GDBRemoteCommunication::ConnectLocally(m_gdb_comm, + m_gdb_replay_server)) + return Status("Unable to connect to replay server"); + + // Start server thread. + m_gdb_replay_server.StartAsyncThread(); + + // Start client thread. + StartAsyncThread(); + + // Do the usual setup. + return ConnectToDebugserver(""); +} + Status ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) { // Make sure we aren't already connected? @@ -3389,6 +3475,9 @@ ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) { if (platform_sp && !platform_sp->IsHost()) return Status("Lost debug server connection"); + if (repro::Loader *loader = repro::Reproducer::Instance().GetLoader()) + return ConnectToReplayServer(loader); + auto error = LaunchAndConnectToDebugserver(process_info); if (error.Fail()) { const char *error_string = error.AsCString(); @@ -3485,7 +3574,7 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver( if (m_gdb_comm.IsConnected()) { // Finish the connection process by doing the handshake without // connecting (send NULL URL) - ConnectToDebugserver(""); + error = ConnectToDebugserver(""); } else { error.SetErrorString("connection failed"); } @@ -3498,7 +3587,7 @@ bool ProcessGDBRemote::MonitorDebugserverProcess( bool exited, // True if the process did exit int signo, // Zero for no signal int exit_status // Exit value of process if signal is zero - ) { +) { // "debugserver_pid" argument passed in is the process ID for debugserver // that we are tracking... Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); @@ -4270,8 +4359,9 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info, return false; feature_node.ForEachChildElementWithName( - "reg", [&target_info, &dyn_reg_info, &cur_reg_num, ®_offset, - &abi_sp](const XMLNode ®_node) -> bool { + "reg", + [&target_info, &dyn_reg_info, &cur_reg_num, ®_offset, + &abi_sp](const XMLNode ®_node) -> bool { std::string gdb_group; std::string gdb_type; ConstString reg_name; @@ -4433,7 +4523,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info, return true; } -} // namespace {} +} // namespace // query the target of gdb-remote for extended target information return: // 'true' on success @@ -4768,7 +4858,8 @@ size_t ProcessGDBRemote::LoadModules(LoadedModuleInfoList &module_list) { if (!modInfo.get_link_map(link_map)) link_map = LLDB_INVALID_ADDRESS; - FileSpec file(mod_name, true); + FileSpec file(mod_name); + FileSystem::Instance().Resolve(file); lldb::ModuleSP module_sp = LoadModuleAtAddress(file, link_map, mod_base, mod_base_is_offset); diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 45bb2d4c28e7..aa9aff5549f3 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -1,24 +1,20 @@ //===-- ProcessGDBRemote.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessGDBRemote_h_ #define liblldb_ProcessGDBRemote_h_ -// C Includes -// C++ Includes #include #include #include #include #include -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/ThreadSafeValue.h" @@ -26,6 +22,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamGDBRemote.h" @@ -36,11 +33,15 @@ #include "lldb/lldb-private-forward.h" #include "GDBRemoteCommunicationClient.h" +#include "GDBRemoteCommunicationReplayServer.h" #include "GDBRemoteRegisterContext.h" #include "llvm/ADT/DenseMap.h" namespace lldb_private { +namespace repro { +class Loader; +} namespace process_gdb_remote { class ThreadGDBRemote; @@ -264,6 +265,7 @@ class ProcessGDBRemote : public Process, }; GDBRemoteCommunicationClient m_gdb_comm; + GDBRemoteCommunicationReplayServer m_gdb_replay_server; std::atomic m_debugserver_pid; std::vector m_stop_packet_stack; // The stop packet // stack replaces @@ -304,6 +306,7 @@ class ProcessGDBRemote : public Process, int64_t m_breakpoint_pc_offset; lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach + bool m_replay_mode; bool m_allow_flash_writes; using FlashRangeVector = lldb_private::RangeVector; using FlashRange = FlashRangeVector::Entry; @@ -331,6 +334,8 @@ class ProcessGDBRemote : public Process, bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override; + Status ConnectToReplayServer(repro::Loader *loader); + Status EstablishConnectionIfNeeded(const ProcessInfo &process_info); Status LaunchAndConnectToDebugserver(const ProcessInfo &process_info); diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp index 8f16b83907cf..8cadc45824b3 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp @@ -1,9 +1,8 @@ //===-- ProcessGDBRemoteLog.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h index 3c5801176690..d9b8d4536afe 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h @@ -1,20 +1,15 @@ //===-- ProcessGDBRemoteLog.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessGDBRemoteLog_h_ #define liblldb_ProcessGDBRemoteLog_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Log.h" #define GDBR_LOG_PROCESS (1u << 1) diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index a525c16b9f13..261b5c919a71 100644 --- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -1,16 +1,14 @@ //===-- ThreadGDBRemote.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ThreadGDBRemote.h" #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/State.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -20,6 +18,7 @@ #include "lldb/Target/UnixSignals.h" #include "lldb/Target/Unwind.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "ProcessGDBRemote.h" @@ -197,13 +196,10 @@ void ThreadGDBRemote::SetQueueLibdispatchQueueAddress( } bool ThreadGDBRemote::ThreadHasQueueInformation() const { - if (m_thread_dispatch_qaddr != 0 && - m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS && - m_dispatch_queue_t != LLDB_INVALID_ADDRESS && - m_queue_kind != eQueueKindUnknown && m_queue_serial_number != 0) { - return true; - } - return false; + return m_thread_dispatch_qaddr != 0 && + m_thread_dispatch_qaddr != LLDB_INVALID_ADDRESS && + m_dispatch_queue_t != LLDB_INVALID_ADDRESS && + m_queue_kind != eQueueKindUnknown && m_queue_serial_number != 0; } LazyBool ThreadGDBRemote::GetAssociatedWithLibdispatchQueue() { diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index 1a5b60aea288..e13a815edf5b 100644 --- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -1,21 +1,16 @@ //===-- ThreadGDBRemote.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadGDBRemote_h_ #define liblldb_ThreadGDBRemote_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 17a4bb540ca6..d3176c1a8ced 100644 --- a/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -1,45 +1,39 @@ //===-- ProcessMachCore.cpp ------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include #include -// C++ Includes #include "llvm/Support/MathExtras.h" #include "llvm/Support/Threading.h" #include -// Other libraries and framework includes #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBuffer.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" -// Project includes #include "ProcessMachCore.h" #include "Plugins/Process/Utility/StopInfoMachException.h" #include "ThreadMachCore.h" // Needed for the plug-in names for the dynamic loaders. -#include "lldb/Utility/SafeMachO.h" +#include "lldb/Host/SafeMachO.h" #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" @@ -67,8 +61,8 @@ lldb::ProcessSP ProcessMachCore::CreateInstance(lldb::TargetSP target_sp, lldb::ProcessSP process_sp; if (crash_file) { const size_t header_size = sizeof(llvm::MachO::mach_header); - auto data_sp = - DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0); + auto data_sp = FileSystem::Instance().CreateDataBuffer( + crash_file->GetPath(), header_size, 0); if (data_sp && data_sp->GetByteSize() == header_size) { DataExtractor data(data_sp, lldb::eByteOrderLittle, 4); @@ -90,7 +84,7 @@ bool ProcessMachCore::CanDebug(lldb::TargetSP target_sp, return true; // For now we are just making sure the file exists for a given module - if (!m_core_module_sp && m_core_file.Exists()) { + if (!m_core_module_sp && FileSystem::Instance().Exists(m_core_file)) { // Don't add the Target's architecture to the ModuleSpec - we may be // working with a core file that doesn't have the correct cpusubtype in the // header but we should still try to use it - @@ -307,36 +301,38 @@ Status ProcessMachCore::DoLoadCore() { // LC_IDENT is very obsolete and should not be used in new code, but if the // load command is present, let's use the contents. std::string corefile_identifier = core_objfile->GetIdentifierString(); - if (found_main_binary_definitively == false - && corefile_identifier.find("Darwin Kernel") != std::string::npos) { - UUID uuid; - addr_t addr = LLDB_INVALID_ADDRESS; - if (corefile_identifier.find("UUID=") != std::string::npos) { - size_t p = corefile_identifier.find("UUID=") + strlen("UUID="); - std::string uuid_str = corefile_identifier.substr(p, 36); - uuid.SetFromStringRef(uuid_str); - } - if (corefile_identifier.find("stext=") != std::string::npos) { - size_t p = corefile_identifier.find("stext=") + strlen("stext="); - if (corefile_identifier[p] == '0' && corefile_identifier[p + 1] == 'x') { - errno = 0; - addr = ::strtoul(corefile_identifier.c_str() + p, NULL, 16); - if (errno != 0 || addr == 0) - addr = LLDB_INVALID_ADDRESS; - } - } - if (uuid.IsValid() && addr != LLDB_INVALID_ADDRESS) { - m_mach_kernel_addr = addr; - found_main_binary_definitively = true; - if (log) - log->Printf("ProcessMachCore::DoLoadCore: Using the kernel address 0x%" PRIx64 - " from LC_IDENT/LC_NOTE 'kern ver str' string: '%s'", addr, corefile_identifier.c_str()); + if (!found_main_binary_definitively && + corefile_identifier.find("Darwin Kernel") != std::string::npos) { + UUID uuid; + addr_t addr = LLDB_INVALID_ADDRESS; + if (corefile_identifier.find("UUID=") != std::string::npos) { + size_t p = corefile_identifier.find("UUID=") + strlen("UUID="); + std::string uuid_str = corefile_identifier.substr(p, 36); + uuid.SetFromStringRef(uuid_str); + } + if (corefile_identifier.find("stext=") != std::string::npos) { + size_t p = corefile_identifier.find("stext=") + strlen("stext="); + if (corefile_identifier[p] == '0' && corefile_identifier[p + 1] == 'x') { + errno = 0; + addr = ::strtoul(corefile_identifier.c_str() + p, NULL, 16); + if (errno != 0 || addr == 0) + addr = LLDB_INVALID_ADDRESS; } + } + if (uuid.IsValid() && addr != LLDB_INVALID_ADDRESS) { + m_mach_kernel_addr = addr; + found_main_binary_definitively = true; + if (log) + log->Printf( + "ProcessMachCore::DoLoadCore: Using the kernel address 0x%" PRIx64 + " from LC_IDENT/LC_NOTE 'kern ver str' string: '%s'", + addr, corefile_identifier.c_str()); + } } - if (found_main_binary_definitively == false - && (m_dyld_addr == LLDB_INVALID_ADDRESS - || m_mach_kernel_addr == LLDB_INVALID_ADDRESS)) { + if (!found_main_binary_definitively && + (m_dyld_addr == LLDB_INVALID_ADDRESS || + m_mach_kernel_addr == LLDB_INVALID_ADDRESS)) { // We need to locate the main executable in the memory ranges we have in // the core file. We need to search for both a user-process dyld binary // and a kernel binary in memory; we must look at all the pages in the @@ -357,16 +353,15 @@ Status ProcessMachCore::DoLoadCore() { } } - if (found_main_binary_definitively == false - && m_mach_kernel_addr != LLDB_INVALID_ADDRESS) { + if (!found_main_binary_definitively && + m_mach_kernel_addr != LLDB_INVALID_ADDRESS) { // In the case of multiple kernel images found in the core file via // exhaustive search, we may not pick the correct one. See if the // DynamicLoaderDarwinKernel's search heuristics might identify the correct // one. Most of the time, I expect the address from SearchForDarwinKernel() // will be the same as the address we found via exhaustive search. - if (GetTarget().GetArchitecture().IsValid() == false && - m_core_module_sp.get()) { + if (!GetTarget().GetArchitecture().IsValid() && m_core_module_sp.get()) { GetTarget().SetArchitecture(m_core_module_sp->GetArchitecture()); } diff --git a/source/Plugins/Process/mach-core/ProcessMachCore.h b/source/Plugins/Process/mach-core/ProcessMachCore.h index 101df6b79115..e973679557a1 100644 --- a/source/Plugins/Process/mach-core/ProcessMachCore.h +++ b/source/Plugins/Process/mach-core/ProcessMachCore.h @@ -1,22 +1,17 @@ //===-- ProcessMachCore.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessMachCore_h_ #define liblldb_ProcessMachCore_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" diff --git a/source/Plugins/Process/mach-core/ThreadMachCore.cpp b/source/Plugins/Process/mach-core/ThreadMachCore.cpp index c262dd47f978..3b128dbca8ca 100644 --- a/source/Plugins/Process/mach-core/ThreadMachCore.cpp +++ b/source/Plugins/Process/mach-core/ThreadMachCore.cpp @@ -1,18 +1,14 @@ //===-- ThreadMachCore.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "ThreadMachCore.h" -#include "lldb/Utility/SafeMachO.h" - #include "lldb/Breakpoint/Watchpoint.h" -#include "lldb/Core/State.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -21,6 +17,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "ProcessMachCore.h" diff --git a/source/Plugins/Process/mach-core/ThreadMachCore.h b/source/Plugins/Process/mach-core/ThreadMachCore.h index a4db484e850f..baaec422cf53 100644 --- a/source/Plugins/Process/mach-core/ThreadMachCore.h +++ b/source/Plugins/Process/mach-core/ThreadMachCore.h @@ -1,21 +1,16 @@ //===-- ThreadMachCore.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadMachCore_h_ #define liblldb_ThreadMachCore_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" class ProcessMachCore; diff --git a/source/Plugins/Process/minidump/CMakeLists.txt b/source/Plugins/Process/minidump/CMakeLists.txt index b898ee1aa144..4126a7ea991c 100644 --- a/source/Plugins/Process/minidump/CMakeLists.txt +++ b/source/Plugins/Process/minidump/CMakeLists.txt @@ -1,6 +1,8 @@ add_lldb_library(lldbPluginProcessMinidump PLUGIN MinidumpTypes.cpp MinidumpParser.cpp + RegisterContextMinidump_ARM.cpp + RegisterContextMinidump_ARM64.cpp RegisterContextMinidump_x86_32.cpp RegisterContextMinidump_x86_64.cpp ProcessMinidump.cpp diff --git a/source/Plugins/Process/minidump/MinidumpParser.cpp b/source/Plugins/Process/minidump/MinidumpParser.cpp index 9a979335e99e..8de7f3ae98f1 100644 --- a/source/Plugins/Process/minidump/MinidumpParser.cpp +++ b/source/Plugins/Process/minidump/MinidumpParser.cpp @@ -1,26 +1,24 @@ //===-- MinidumpParser.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "MinidumpParser.h" #include "NtStructures.h" #include "RegisterContextMinidump_x86_32.h" -// Other libraries and framework includes -#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/LLDBAssert.h" +#include "Plugins/Process/Utility/LinuxProcMaps.h" // C includes // C++ includes #include #include #include +#include using namespace lldb_private; using namespace minidump; @@ -80,8 +78,18 @@ UUID MinidumpParser::GetModuleUUID(const MinidumpModule *module) { // PDB70 record const CvRecordPdb70 *pdb70_uuid = nullptr; Status error = consumeObject(cv_record, pdb70_uuid); - if (!error.Fail()) - return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid)); + if (!error.Fail()) { + auto arch = GetArchitecture(); + // For Apple targets we only need a 16 byte UUID so that we can match + // the UUID in the Module to actual UUIDs from the built binaries. The + // "Age" field is zero in breakpad minidump files for Apple targets, so + // we restrict the UUID to the "Uuid" field so we have a UUID we can use + // to match. + if (arch.GetTriple().getVendor() == llvm::Triple::Apple) + return UUID::fromData(pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid)); + else + return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid)); + } } else if (cv_signature == CvSignature::ElfBuildId) return UUID::fromData(cv_record); @@ -98,11 +106,15 @@ llvm::ArrayRef MinidumpParser::GetThreads() { } llvm::ArrayRef -MinidumpParser::GetThreadContext(const MinidumpThread &td) { - if (td.thread_context.rva + td.thread_context.data_size > GetData().size()) +MinidumpParser::GetThreadContext(const MinidumpLocationDescriptor &location) { + if (location.rva + location.data_size > GetData().size()) return {}; + return GetData().slice(location.rva, location.data_size); +} - return GetData().slice(td.thread_context.rva, td.thread_context.data_size); +llvm::ArrayRef +MinidumpParser::GetThreadContext(const MinidumpThread &td) { + return GetThreadContext(td.thread_context); } llvm::ArrayRef @@ -146,11 +158,14 @@ const MinidumpSystemInfo *MinidumpParser::GetSystemInfo() { } ArchSpec MinidumpParser::GetArchitecture() { - ArchSpec arch_spec; + if (m_arch.IsValid()) + return m_arch; + + // Set the architecture in m_arch const MinidumpSystemInfo *system_info = GetSystemInfo(); if (!system_info) - return arch_spec; + return m_arch; // TODO what to do about big endiand flavors of arm ? // TODO set the arm subarch stuff if the minidump has info about it @@ -196,19 +211,28 @@ ArchSpec MinidumpParser::GetArchitecture() { break; case MinidumpOSPlatform::MacOSX: triple.setOS(llvm::Triple::OSType::MacOSX); + triple.setVendor(llvm::Triple::Apple); + break; + case MinidumpOSPlatform::IOS: + triple.setOS(llvm::Triple::OSType::IOS); + triple.setVendor(llvm::Triple::Apple); break; case MinidumpOSPlatform::Android: triple.setOS(llvm::Triple::OSType::Linux); triple.setEnvironment(llvm::Triple::EnvironmentType::Android); break; - default: + default: { triple.setOS(llvm::Triple::OSType::UnknownOS); + std::string csd_version; + if (auto s = GetMinidumpString(system_info->csd_version_rva)) + csd_version = *s; + if (csd_version.find("Linux") != std::string::npos) + triple.setOS(llvm::Triple::OSType::Linux); break; + } } - - arch_spec.SetTriple(triple); - - return arch_spec; + m_arch.SetTriple(triple); + return m_arch; } const MinidumpMiscInfo *MinidumpParser::GetMiscInfo() { @@ -254,36 +278,45 @@ llvm::ArrayRef MinidumpParser::GetModuleList() { std::vector MinidumpParser::GetFilteredModuleList() { llvm::ArrayRef modules = GetModuleList(); - // map module_name -> pair(load_address, pointer to module struct in memory) - llvm::StringMap> lowest_addr; + // map module_name -> filtered_modules index + typedef llvm::StringMap MapType; + MapType module_name_to_filtered_index; std::vector filtered_modules; - + llvm::Optional name; std::string module_name; for (const auto &module : modules) { name = GetMinidumpString(module.module_name_rva); - + if (!name) continue; - + module_name = name.getValue(); - - auto iter = lowest_addr.end(); - bool exists; - std::tie(iter, exists) = lowest_addr.try_emplace( - module_name, std::make_pair(module.base_of_image, &module)); - - if (exists && module.base_of_image < iter->second.first) - iter->second = std::make_pair(module.base_of_image, &module); - } - - filtered_modules.reserve(lowest_addr.size()); - for (const auto &module : lowest_addr) { - filtered_modules.push_back(module.second.second); + + MapType::iterator iter; + bool inserted; + // See if we have inserted this module aready into filtered_modules. If we + // haven't insert an entry into module_name_to_filtered_index with the + // index where we will insert it if it isn't in the vector already. + std::tie(iter, inserted) = module_name_to_filtered_index.try_emplace( + module_name, filtered_modules.size()); + + if (inserted) { + // This module has not been seen yet, insert it into filtered_modules at + // the index that was inserted into module_name_to_filtered_index using + // "filtered_modules.size()" above. + filtered_modules.push_back(&module); + } else { + // This module has been seen. Modules are sometimes mentioned multiple + // times when they are mapped discontiguously, so find the module with + // the lowest "base_of_image" and use that as the filtered module. + auto dup_module = filtered_modules[iter->second]; + if (module.base_of_image < dup_module->base_of_image) + filtered_modules[iter->second] = &module; + } } - return filtered_modules; } @@ -381,72 +414,153 @@ llvm::ArrayRef MinidumpParser::GetMemory(lldb::addr_t addr, return range->range_ref.slice(offset, overlap); } -llvm::Optional -MinidumpParser::GetMemoryRegionInfo(lldb::addr_t load_addr) { - MemoryRegionInfo info; - llvm::ArrayRef data = GetStream(MinidumpStreamType::MemoryInfoList); +static bool +CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser, + std::vector ®ions) { + auto data = parser.GetStream(MinidumpStreamType::LinuxMaps); if (data.empty()) - return llvm::None; + return false; + ParseLinuxMapRegions(llvm::toStringRef(data), + [&](const lldb_private::MemoryRegionInfo ®ion, + const lldb_private::Status &status) -> bool { + if (status.Success()) + regions.push_back(region); + return true; + }); + return !regions.empty(); +} - std::vector mem_info_list = - MinidumpMemoryInfo::ParseMemoryInfoList(data); +static bool +CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser, + std::vector ®ions) { + auto data = parser.GetStream(MinidumpStreamType::MemoryInfoList); + if (data.empty()) + return false; + auto mem_info_list = MinidumpMemoryInfo::ParseMemoryInfoList(data); if (mem_info_list.empty()) - return llvm::None; + return false; + constexpr auto yes = MemoryRegionInfo::eYes; + constexpr auto no = MemoryRegionInfo::eNo; + regions.reserve(mem_info_list.size()); + for (const auto &entry : mem_info_list) { + MemoryRegionInfo region; + region.GetRange().SetRangeBase(entry->base_address); + region.GetRange().SetByteSize(entry->region_size); + region.SetReadable(entry->isReadable() ? yes : no); + region.SetWritable(entry->isWritable() ? yes : no); + region.SetExecutable(entry->isExecutable() ? yes : no); + region.SetMapped(entry->isMapped() ? yes : no); + regions.push_back(region); + } + return !regions.empty(); +} - const auto yes = MemoryRegionInfo::eYes; - const auto no = MemoryRegionInfo::eNo; +static bool +CreateRegionsCacheFromMemoryList(MinidumpParser &parser, + std::vector ®ions) { + auto data = parser.GetStream(MinidumpStreamType::MemoryList); + if (data.empty()) + return false; + auto memory_list = MinidumpMemoryDescriptor::ParseMemoryList(data); + if (memory_list.empty()) + return false; + regions.reserve(memory_list.size()); + for (const auto &memory_desc : memory_list) { + if (memory_desc.memory.data_size == 0) + continue; + MemoryRegionInfo region; + region.GetRange().SetRangeBase(memory_desc.start_of_memory_range); + region.GetRange().SetByteSize(memory_desc.memory.data_size); + region.SetReadable(MemoryRegionInfo::eYes); + region.SetMapped(MemoryRegionInfo::eYes); + regions.push_back(region); + } + regions.shrink_to_fit(); + return !regions.empty(); +} - const MinidumpMemoryInfo *next_entry = nullptr; - for (const auto &entry : mem_info_list) { - const auto head = entry->base_address; - const auto tail = head + entry->region_size; - - if (head <= load_addr && load_addr < tail) { - info.GetRange().SetRangeBase( - (entry->state != uint32_t(MinidumpMemoryInfoState::MemFree)) - ? head - : load_addr); - info.GetRange().SetRangeEnd(tail); - - const uint32_t PageNoAccess = - static_cast(MinidumpMemoryProtectionContants::PageNoAccess); - info.SetReadable((entry->protect & PageNoAccess) == 0 ? yes : no); - - const uint32_t PageWritable = - static_cast(MinidumpMemoryProtectionContants::PageWritable); - info.SetWritable((entry->protect & PageWritable) != 0 ? yes : no); - - const uint32_t PageExecutable = static_cast( - MinidumpMemoryProtectionContants::PageExecutable); - info.SetExecutable((entry->protect & PageExecutable) != 0 ? yes : no); - - const uint32_t MemFree = - static_cast(MinidumpMemoryInfoState::MemFree); - info.SetMapped((entry->state != MemFree) ? yes : no); - - return info; - } else if (head > load_addr && - (next_entry == nullptr || head < next_entry->base_address)) { - // In case there is no region containing load_addr keep track of the - // nearest region after load_addr so we can return the distance to it. - next_entry = entry; - } +static bool +CreateRegionsCacheFromMemory64List(MinidumpParser &parser, + std::vector ®ions) { + llvm::ArrayRef data = + parser.GetStream(MinidumpStreamType::Memory64List); + if (data.empty()) + return false; + llvm::ArrayRef memory64_list; + uint64_t base_rva; + std::tie(memory64_list, base_rva) = + MinidumpMemoryDescriptor64::ParseMemory64List(data); + + if (memory64_list.empty()) + return false; + + regions.reserve(memory64_list.size()); + for (const auto &memory_desc : memory64_list) { + if (memory_desc.data_size == 0) + continue; + MemoryRegionInfo region; + region.GetRange().SetRangeBase(memory_desc.start_of_memory_range); + region.GetRange().SetByteSize(memory_desc.data_size); + region.SetReadable(MemoryRegionInfo::eYes); + region.SetMapped(MemoryRegionInfo::eYes); + regions.push_back(region); + } + regions.shrink_to_fit(); + return !regions.empty(); +} + +MemoryRegionInfo +MinidumpParser::FindMemoryRegion(lldb::addr_t load_addr) const { + auto begin = m_regions.begin(); + auto end = m_regions.end(); + auto pos = std::lower_bound(begin, end, load_addr); + if (pos != end && pos->GetRange().Contains(load_addr)) + return *pos; + + MemoryRegionInfo region; + if (pos == begin) + region.GetRange().SetRangeBase(0); + else { + auto prev = pos - 1; + if (prev->GetRange().Contains(load_addr)) + return *prev; + region.GetRange().SetRangeBase(prev->GetRange().GetRangeEnd()); } + if (pos == end) + region.GetRange().SetRangeEnd(UINT64_MAX); + else + region.GetRange().SetRangeEnd(pos->GetRange().GetRangeBase()); + region.SetReadable(MemoryRegionInfo::eNo); + region.SetWritable(MemoryRegionInfo::eNo); + region.SetExecutable(MemoryRegionInfo::eNo); + region.SetMapped(MemoryRegionInfo::eNo); + return region; +} + +MemoryRegionInfo +MinidumpParser::GetMemoryRegionInfo(lldb::addr_t load_addr) { + if (!m_parsed_regions) + GetMemoryRegions(); + return FindMemoryRegion(load_addr); +} - // No containing region found. Create an unmapped region that extends to the - // next region or LLDB_INVALID_ADDRESS - info.GetRange().SetRangeBase(load_addr); - info.GetRange().SetRangeEnd((next_entry != nullptr) ? next_entry->base_address - : LLDB_INVALID_ADDRESS); - info.SetReadable(no); - info.SetWritable(no); - info.SetExecutable(no); - info.SetMapped(no); - - // Note that the memory info list doesn't seem to contain ranges in kernel - // space, so if you're walking a stack that has kernel frames, the stack may - // appear truncated. - return info; +const MemoryRegionInfos &MinidumpParser::GetMemoryRegions() { + if (!m_parsed_regions) { + m_parsed_regions = true; + // We haven't cached our memory regions yet we will create the region cache + // once. We create the region cache using the best source. We start with + // the linux maps since they are the most complete and have names for the + // regions. Next we try the MemoryInfoList since it has + // read/write/execute/map data, and then fall back to the MemoryList and + // Memory64List to just get a list of the memory that is mapped in this + // core file + if (!CreateRegionsCacheFromLinuxMaps(*this, m_regions)) + if (!CreateRegionsCacheFromMemoryInfoList(*this, m_regions)) + if (!CreateRegionsCacheFromMemoryList(*this, m_regions)) + CreateRegionsCacheFromMemory64List(*this, m_regions); + llvm::sort(m_regions.begin(), m_regions.end()); + } + return m_regions; } Status MinidumpParser::Initialize() { @@ -531,10 +645,10 @@ Status MinidumpParser::Initialize() { } // Sort the file map ranges by start offset - std::sort(minidump_map.begin(), minidump_map.end(), - [](const FileRange &a, const FileRange &b) { - return a.offset < b.offset; - }); + llvm::sort(minidump_map.begin(), minidump_map.end(), + [](const FileRange &a, const FileRange &b) { + return a.offset < b.offset; + }); // Check for overlapping streams/data structures for (size_t i = 1; i < minidump_map.size(); ++i) { @@ -554,3 +668,48 @@ Status MinidumpParser::Initialize() { return error; } + +#define ENUM_TO_CSTR(ST) case (uint32_t)MinidumpStreamType::ST: return #ST + +llvm::StringRef +MinidumpParser::GetStreamTypeAsString(uint32_t stream_type) { + switch (stream_type) { + ENUM_TO_CSTR(Unused); + ENUM_TO_CSTR(Reserved0); + ENUM_TO_CSTR(Reserved1); + ENUM_TO_CSTR(ThreadList); + ENUM_TO_CSTR(ModuleList); + ENUM_TO_CSTR(MemoryList); + ENUM_TO_CSTR(Exception); + ENUM_TO_CSTR(SystemInfo); + ENUM_TO_CSTR(ThreadExList); + ENUM_TO_CSTR(Memory64List); + ENUM_TO_CSTR(CommentA); + ENUM_TO_CSTR(CommentW); + ENUM_TO_CSTR(HandleData); + ENUM_TO_CSTR(FunctionTable); + ENUM_TO_CSTR(UnloadedModuleList); + ENUM_TO_CSTR(MiscInfo); + ENUM_TO_CSTR(MemoryInfoList); + ENUM_TO_CSTR(ThreadInfoList); + ENUM_TO_CSTR(HandleOperationList); + ENUM_TO_CSTR(Token); + ENUM_TO_CSTR(JavascriptData); + ENUM_TO_CSTR(SystemMemoryInfo); + ENUM_TO_CSTR(ProcessVMCounters); + ENUM_TO_CSTR(BreakpadInfo); + ENUM_TO_CSTR(AssertionInfo); + ENUM_TO_CSTR(LinuxCPUInfo); + ENUM_TO_CSTR(LinuxProcStatus); + ENUM_TO_CSTR(LinuxLSBRelease); + ENUM_TO_CSTR(LinuxCMDLine); + ENUM_TO_CSTR(LinuxEnviron); + ENUM_TO_CSTR(LinuxAuxv); + ENUM_TO_CSTR(LinuxMaps); + ENUM_TO_CSTR(LinuxDSODebug); + ENUM_TO_CSTR(LinuxProcStat); + ENUM_TO_CSTR(LinuxProcUptime); + ENUM_TO_CSTR(LinuxProcFD); + } + return "unknown stream type"; +} diff --git a/source/Plugins/Process/minidump/MinidumpParser.h b/source/Plugins/Process/minidump/MinidumpParser.h index 49b1eef14de5..fa0d6d660c48 100644 --- a/source/Plugins/Process/minidump/MinidumpParser.h +++ b/source/Plugins/Process/minidump/MinidumpParser.h @@ -1,19 +1,17 @@ -//===-- MinidumpParser.h -----------------------------------------*- C++ -//-*-===// +//===-- MinidumpParser.h -----------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_MinidumpParser_h_ #define liblldb_MinidumpParser_h_ -// Project includes #include "MinidumpTypes.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/Status.h" @@ -59,6 +57,9 @@ class MinidumpParser { llvm::ArrayRef GetThreads(); + llvm::ArrayRef + GetThreadContext(const MinidumpLocationDescriptor &location); + llvm::ArrayRef GetThreadContext(const MinidumpThread &td); llvm::ArrayRef GetThreadContextWow64(const MinidumpThread &td); @@ -87,17 +88,31 @@ class MinidumpParser { llvm::ArrayRef GetMemory(lldb::addr_t addr, size_t size); - llvm::Optional GetMemoryRegionInfo(lldb::addr_t); + MemoryRegionInfo GetMemoryRegionInfo(lldb::addr_t load_addr); + + const MemoryRegionInfos &GetMemoryRegions(); // Perform consistency checks and initialize internal data structures Status Initialize(); + static llvm::StringRef GetStreamTypeAsString(uint32_t stream_type); + + const llvm::DenseMap & + GetDirectoryMap() const { + return m_directory_map; + } + private: MinidumpParser(const lldb::DataBufferSP &data_buf_sp); + MemoryRegionInfo FindMemoryRegion(lldb::addr_t load_addr) const; + private: lldb::DataBufferSP m_data_sp; llvm::DenseMap m_directory_map; + ArchSpec m_arch; + MemoryRegionInfos m_regions; + bool m_parsed_regions = false; }; } // end namespace minidump diff --git a/source/Plugins/Process/minidump/MinidumpTypes.cpp b/source/Plugins/Process/minidump/MinidumpTypes.cpp index 77142b0e8483..ab61895faa3a 100644 --- a/source/Plugins/Process/minidump/MinidumpTypes.cpp +++ b/source/Plugins/Process/minidump/MinidumpTypes.cpp @@ -1,16 +1,13 @@ //===-- MinidumpTypes.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "MinidumpTypes.h" -// Other libraries and framework includes // C includes // C++ includes @@ -244,6 +241,8 @@ MinidumpMemoryInfo::ParseMemoryInfoList(llvm::ArrayRef &data) { return {}; std::vector result; + result.reserve(header->num_of_entries); + for (uint64_t i = 0; i < header->num_of_entries; ++i) { result.push_back(reinterpret_cast( data.data() + i * header->size_of_entry)); diff --git a/source/Plugins/Process/minidump/MinidumpTypes.h b/source/Plugins/Process/minidump/MinidumpTypes.h index e83089865b9e..b20f50cadd6f 100644 --- a/source/Plugins/Process/minidump/MinidumpTypes.h +++ b/source/Plugins/Process/minidump/MinidumpTypes.h @@ -1,18 +1,15 @@ //===-- MinidumpTypes.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_MinidumpTypes_h_ #define liblldb_MinidumpTypes_h_ -// Project includes -// Other libraries and framework includes #include "lldb/Utility/Status.h" #include "llvm/ADT/ArrayRef.h" @@ -98,7 +95,10 @@ enum class MinidumpStreamType : uint32_t { LinuxEnviron = 0x47670007, /* /proc/$x/environ */ LinuxAuxv = 0x47670008, /* /proc/$x/auxv */ LinuxMaps = 0x47670009, /* /proc/$x/maps */ - LinuxDSODebug = 0x4767000A + LinuxDSODebug = 0x4767000A, + LinuxProcStat = 0x4767000B, /* /proc/$x/stat */ + LinuxProcUptime = 0x4767000C, /* uptime */ + LinuxProcFD = 0x4767000D, /* /proc/$x/fb */ }; // for MinidumpSystemInfo.processor_arch @@ -258,25 +258,6 @@ struct MinidumpMemoryInfoListHeader { static_assert(sizeof(MinidumpMemoryInfoListHeader) == 16, "sizeof MinidumpMemoryInfoListHeader is not correct!"); -// Reference: -// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680386(v=vs.85).aspx -struct MinidumpMemoryInfo { - llvm::support::ulittle64_t base_address; - llvm::support::ulittle64_t allocation_base; - llvm::support::ulittle32_t allocation_protect; - llvm::support::ulittle32_t alignment1; - llvm::support::ulittle64_t region_size; - llvm::support::ulittle32_t state; - llvm::support::ulittle32_t protect; - llvm::support::ulittle32_t type; - llvm::support::ulittle32_t alignment2; - - static std::vector - ParseMemoryInfoList(llvm::ArrayRef &data); -}; -static_assert(sizeof(MinidumpMemoryInfo) == 48, - "sizeof MinidumpMemoryInfo is not correct!"); - enum class MinidumpMemoryInfoState : uint32_t { MemCommit = 0x1000, MemFree = 0x10000, @@ -312,6 +293,45 @@ enum class MinidumpMemoryProtectionContants : uint32_t { LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ PageTargetsInvalid) }; +// Reference: +// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680386(v=vs.85).aspx +struct MinidumpMemoryInfo { + llvm::support::ulittle64_t base_address; + llvm::support::ulittle64_t allocation_base; + llvm::support::ulittle32_t allocation_protect; + llvm::support::ulittle32_t alignment1; + llvm::support::ulittle64_t region_size; + llvm::support::ulittle32_t state; + llvm::support::ulittle32_t protect; + llvm::support::ulittle32_t type; + llvm::support::ulittle32_t alignment2; + + static std::vector + ParseMemoryInfoList(llvm::ArrayRef &data); + + bool isReadable() const { + const auto mask = MinidumpMemoryProtectionContants::PageNoAccess; + return (static_cast(mask) & protect) == 0; + } + + bool isWritable() const { + const auto mask = MinidumpMemoryProtectionContants::PageWritable; + return (static_cast(mask) & protect) != 0; + } + + bool isExecutable() const { + const auto mask = MinidumpMemoryProtectionContants::PageExecutable; + return (static_cast(mask) & protect) != 0; + } + + bool isMapped() const { + return state != static_cast(MinidumpMemoryInfoState::MemFree); + } +}; + +static_assert(sizeof(MinidumpMemoryInfo) == 48, + "sizeof MinidumpMemoryInfo is not correct!"); + // Reference: // https://msdn.microsoft.com/en-us/library/windows/desktop/ms680517(v=vs.85).aspx struct MinidumpThread { diff --git a/source/Plugins/Process/minidump/NtStructures.h b/source/Plugins/Process/minidump/NtStructures.h index c0afd77358cd..fdb0cfb7981e 100644 --- a/source/Plugins/Process/minidump/NtStructures.h +++ b/source/Plugins/Process/minidump/NtStructures.h @@ -1,9 +1,8 @@ //===-- NtStructures.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/Process/minidump/ProcessMinidump.cpp b/source/Plugins/Process/minidump/ProcessMinidump.cpp index 85e84c9b7a94..cdd8063407b2 100644 --- a/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ b/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -1,34 +1,39 @@ //===-- ProcessMinidump.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "ProcessMinidump.h" #include "ThreadMinidump.h" -// Other libraries and framework includes +#include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/State.h" -#include "lldb/Target/DynamicLoader.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandObject.h" +#include "lldb/Interpreter/CommandObjectMultiword.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Interpreter/OptionArgParser.h" +#include "lldb/Interpreter/OptionGroupBoolean.h" +#include "lldb/Target/JITLoaderList.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Threading.h" +#include "Plugins/Process/Utility/StopInfoMachException.h" + // C includes // C++ includes @@ -75,7 +80,7 @@ class PlaceholderModule : public Module { section_sp, module->base_of_image); } - ObjectFile *GetObjectFile() override { return nullptr; } +ObjectFile *GetObjectFile() override { return nullptr; } SectionList *GetSectionList() override { return Module::GetUnifiedSectionList(); @@ -100,8 +105,8 @@ lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp, lldb::ProcessSP process_sp; // Read enough data for the Minidump header constexpr size_t header_size = sizeof(MinidumpHeader); - auto DataPtr = - DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0); + auto DataPtr = FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(), + header_size, 0); if (!DataPtr) return nullptr; @@ -113,7 +118,8 @@ lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp, if (header == nullptr) return nullptr; - auto AllData = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), -1, 0); + auto AllData = + FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(), -1, 0); if (!AllData) return nullptr; @@ -174,19 +180,21 @@ Status ProcessMinidump::DoLoadCore() { switch (arch.GetMachine()) { case llvm::Triple::x86: case llvm::Triple::x86_64: - // supported + case llvm::Triple::arm: + case llvm::Triple::aarch64: + // Any supported architectures must be listed here and also supported in + // ThreadMinidump::CreateRegisterContextForFrame(). break; - default: error.SetErrorStringWithFormat("unsupported minidump architecture: %s", arch.GetArchitectureName()); return error; } + GetTarget().SetArchitecture(arch, true /*set_platform*/); m_thread_list = m_minidump_parser.GetThreads(); m_active_exception = m_minidump_parser.GetExceptionStream(); ReadModuleList(); - GetTarget().SetArchitecture(arch); llvm::Optional pid = m_minidump_parser.GetPid(); if (!pid) { @@ -198,12 +206,6 @@ Status ProcessMinidump::DoLoadCore() { return error; } -DynamicLoader *ProcessMinidump::GetDynamicLoader() { - if (m_dyld_ap.get() == nullptr) - m_dyld_ap.reset(DynamicLoader::FindPlugin(this, nullptr)); - return m_dyld_ap.get(); -} - ConstString ProcessMinidump::GetPluginName() { return GetPluginNameStatic(); } uint32_t ProcessMinidump::GetPluginVersion() { return 1; } @@ -229,6 +231,11 @@ void ProcessMinidump::RefreshStateAfterStop() { if (arch.GetTriple().getOS() == llvm::Triple::Linux) { stop_info = StopInfo::CreateStopReasonWithSignal( *stop_thread, m_active_exception->exception_record.exception_code); + } else if (arch.GetTriple().getVendor() == llvm::Triple::Apple) { + stop_info = StopInfoMachException::CreateStopReasonWithMachException( + *stop_thread, m_active_exception->exception_record.exception_code, 2, + m_active_exception->exception_record.exception_flags, + m_active_exception->exception_record.exception_address, 0); } else { std::string desc; llvm::raw_string_ostream desc_stream(desc); @@ -284,33 +291,36 @@ ArchSpec ProcessMinidump::GetArchitecture() { Status ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { - Status error; - auto info = m_minidump_parser.GetMemoryRegionInfo(load_addr); - if (!info) { - error.SetErrorString("No valid MemoryRegionInfo found!"); - return error; - } - range_info = info.getValue(); - return error; + range_info = m_minidump_parser.GetMemoryRegionInfo(load_addr); + return Status(); +} + +Status ProcessMinidump::GetMemoryRegions( + lldb_private::MemoryRegionInfos ®ion_list) { + region_list = m_minidump_parser.GetMemoryRegions(); + return Status(); } void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); } bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) { - uint32_t num_threads = 0; - if (m_thread_list.size() > 0) - num_threads = m_thread_list.size(); + for (const MinidumpThread& thread : m_thread_list) { + MinidumpLocationDescriptor context_location = thread.thread_context; + + // If the minidump contains an exception context, use it + if (m_active_exception != nullptr && + m_active_exception->thread_id == thread.thread_id) { + context_location = m_active_exception->thread_context; + } - for (lldb::tid_t tid = 0; tid < num_threads; ++tid) { llvm::ArrayRef context; if (!m_is_wow64) - context = m_minidump_parser.GetThreadContext(m_thread_list[tid]); + context = m_minidump_parser.GetThreadContext(context_location); else - context = m_minidump_parser.GetThreadContextWow64(m_thread_list[tid]); + context = m_minidump_parser.GetThreadContextWow64(thread); - lldb::ThreadSP thread_sp( - new ThreadMinidump(*this, m_thread_list[tid], context)); + lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context)); new_thread_list.AddThread(thread_sp); } return new_thread_list.GetSize(false) > 0; @@ -344,8 +354,8 @@ void ProcessMinidump::ReadModuleList() { } const auto uuid = m_minidump_parser.GetModuleUUID(module); - const auto file_spec = - FileSpec(name.getValue(), true, GetArchitecture().GetTriple()); + auto file_spec = FileSpec(name.getValue(), GetArchitecture().GetTriple()); + FileSystem::Instance().Resolve(file_spec); ModuleSpec module_spec(file_spec, uuid); Status error; lldb::ModuleSP module_sp = GetTarget().GetSharedModule(module_spec, &error); @@ -357,6 +367,12 @@ void ProcessMinidump::ReadModuleList() { // This enables most LLDB functionality involving address-to-module // translations (ex. identifing the module for a stack frame PC) and // modules/sections commands (ex. target modules list, ...) + if (log) { + log->Printf("Unable to locate the matching object file, creating a " + "placeholder module for: %s", + name.getValue().c_str()); + } + auto placeholder_module = std::make_shared(module_spec); placeholder_module->CreateImageSection(module, GetTarget()); @@ -387,3 +403,248 @@ bool ProcessMinidump::GetProcessInfo(ProcessInstanceInfo &info) { } return true; } + +// For minidumps there's no runtime generated code so we don't need JITLoader(s) +// Avoiding them will also speed up minidump loading since JITLoaders normally +// try to set up symbolic breakpoints, which in turn may force loading more +// debug information than needed. +JITLoaderList &ProcessMinidump::GetJITLoaders() { + if (!m_jit_loaders_ap) { + m_jit_loaders_ap = llvm::make_unique(); + } + return *m_jit_loaders_ap; +} + +#define INIT_BOOL(VAR, LONG, SHORT, DESC) \ + VAR(LLDB_OPT_SET_1, false, LONG, SHORT, DESC, false, true) +#define APPEND_OPT(VAR) \ + m_option_group.Append(&VAR, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1) + +class CommandObjectProcessMinidumpDump : public CommandObjectParsed { +private: + OptionGroupOptions m_option_group; + OptionGroupBoolean m_dump_all; + OptionGroupBoolean m_dump_directory; + OptionGroupBoolean m_dump_linux_cpuinfo; + OptionGroupBoolean m_dump_linux_proc_status; + OptionGroupBoolean m_dump_linux_lsb_release; + OptionGroupBoolean m_dump_linux_cmdline; + OptionGroupBoolean m_dump_linux_environ; + OptionGroupBoolean m_dump_linux_auxv; + OptionGroupBoolean m_dump_linux_maps; + OptionGroupBoolean m_dump_linux_proc_stat; + OptionGroupBoolean m_dump_linux_proc_uptime; + OptionGroupBoolean m_dump_linux_proc_fd; + OptionGroupBoolean m_dump_linux_all; + + void SetDefaultOptionsIfNoneAreSet() { + if (m_dump_all.GetOptionValue().GetCurrentValue() || + m_dump_linux_all.GetOptionValue().GetCurrentValue() || + m_dump_directory.GetOptionValue().GetCurrentValue() || + m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue() || + m_dump_linux_proc_status.GetOptionValue().GetCurrentValue() || + m_dump_linux_lsb_release.GetOptionValue().GetCurrentValue() || + m_dump_linux_cmdline.GetOptionValue().GetCurrentValue() || + m_dump_linux_environ.GetOptionValue().GetCurrentValue() || + m_dump_linux_auxv.GetOptionValue().GetCurrentValue() || + m_dump_linux_maps.GetOptionValue().GetCurrentValue() || + m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue() || + m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue() || + m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue()) + return; + // If no options were set, then dump everything + m_dump_all.GetOptionValue().SetCurrentValue(true); + } + bool DumpAll() const { + return m_dump_all.GetOptionValue().GetCurrentValue(); + } + bool DumpDirectory() const { + return DumpAll() || + m_dump_directory.GetOptionValue().GetCurrentValue(); + } + bool DumpLinux() const { + return DumpAll() || m_dump_linux_all.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxCPUInfo() const { + return DumpLinux() || + m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxProcStatus() const { + return DumpLinux() || + m_dump_linux_proc_status.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxProcStat() const { + return DumpLinux() || + m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxLSBRelease() const { + return DumpLinux() || + m_dump_linux_lsb_release.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxCMDLine() const { + return DumpLinux() || + m_dump_linux_cmdline.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxEnviron() const { + return DumpLinux() || + m_dump_linux_environ.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxAuxv() const { + return DumpLinux() || + m_dump_linux_auxv.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxMaps() const { + return DumpLinux() || + m_dump_linux_maps.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxProcUptime() const { + return DumpLinux() || + m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue(); + } + bool DumpLinuxProcFD() const { + return DumpLinux() || + m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue(); + } +public: + + CommandObjectProcessMinidumpDump(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "process plugin dump", + "Dump information from the minidump file.", NULL), + m_option_group(), + INIT_BOOL(m_dump_all, "all", 'a', + "Dump the everything in the minidump."), + INIT_BOOL(m_dump_directory, "directory", 'd', + "Dump the minidump directory map."), + INIT_BOOL(m_dump_linux_cpuinfo, "cpuinfo", 'C', + "Dump linux /proc/cpuinfo."), + INIT_BOOL(m_dump_linux_proc_status, "status", 's', + "Dump linux /proc//status."), + INIT_BOOL(m_dump_linux_lsb_release, "lsb-release", 'r', + "Dump linux /etc/lsb-release."), + INIT_BOOL(m_dump_linux_cmdline, "cmdline", 'c', + "Dump linux /proc//cmdline."), + INIT_BOOL(m_dump_linux_environ, "environ", 'e', + "Dump linux /proc//environ."), + INIT_BOOL(m_dump_linux_auxv, "auxv", 'x', + "Dump linux /proc//auxv."), + INIT_BOOL(m_dump_linux_maps, "maps", 'm', + "Dump linux /proc//maps."), + INIT_BOOL(m_dump_linux_proc_stat, "stat", 'S', + "Dump linux /proc//stat."), + INIT_BOOL(m_dump_linux_proc_uptime, "uptime", 'u', + "Dump linux process uptime."), + INIT_BOOL(m_dump_linux_proc_fd, "fd", 'f', + "Dump linux /proc//fd."), + INIT_BOOL(m_dump_linux_all, "linux", 'l', + "Dump all linux streams.") { + APPEND_OPT(m_dump_all); + APPEND_OPT(m_dump_directory); + APPEND_OPT(m_dump_linux_cpuinfo); + APPEND_OPT(m_dump_linux_proc_status); + APPEND_OPT(m_dump_linux_lsb_release); + APPEND_OPT(m_dump_linux_cmdline); + APPEND_OPT(m_dump_linux_environ); + APPEND_OPT(m_dump_linux_auxv); + APPEND_OPT(m_dump_linux_maps); + APPEND_OPT(m_dump_linux_proc_stat); + APPEND_OPT(m_dump_linux_proc_uptime); + APPEND_OPT(m_dump_linux_proc_fd); + APPEND_OPT(m_dump_linux_all); + m_option_group.Finalize(); + } + + ~CommandObjectProcessMinidumpDump() {} + + Options *GetOptions() override { return &m_option_group; } + + bool DoExecute(Args &command, CommandReturnObject &result) override { + const size_t argc = command.GetArgumentCount(); + if (argc > 0) { + result.AppendErrorWithFormat("'%s' take no arguments, only options", + m_cmd_name.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + SetDefaultOptionsIfNoneAreSet(); + + ProcessMinidump *process = static_cast( + m_interpreter.GetExecutionContext().GetProcessPtr()); + result.SetStatus(eReturnStatusSuccessFinishResult); + Stream &s = result.GetOutputStream(); + MinidumpParser &minidump = process->m_minidump_parser; + if (DumpDirectory()) { + s.Printf("RVA SIZE TYPE MinidumpStreamType\n"); + s.Printf("---------- ---------- ---------- --------------------------\n"); + for (const auto &pair: minidump.GetDirectoryMap()) + s.Printf("0x%8.8x 0x%8.8x 0x%8.8x %s\n", (uint32_t)pair.second.rva, + (uint32_t)pair.second.data_size, pair.first, + MinidumpParser::GetStreamTypeAsString(pair.first).data()); + s.Printf("\n"); + } + auto DumpTextStream = [&](MinidumpStreamType stream_type, + llvm::StringRef label) -> void { + auto bytes = minidump.GetStream(stream_type); + if (!bytes.empty()) { + if (label.empty()) + label = MinidumpParser::GetStreamTypeAsString((uint32_t)stream_type); + s.Printf("%s:\n%s\n\n", label.data(), bytes.data()); + } + }; + auto DumpBinaryStream = [&](MinidumpStreamType stream_type, + llvm::StringRef label) -> void { + auto bytes = minidump.GetStream(stream_type); + if (!bytes.empty()) { + if (label.empty()) + label = MinidumpParser::GetStreamTypeAsString((uint32_t)stream_type); + s.Printf("%s:\n", label.data()); + DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle, + process->GetAddressByteSize()); + DumpDataExtractor(data, &s, 0, lldb::eFormatBytesWithASCII, 1, + bytes.size(), 16, 0, 0, 0); + s.Printf("\n\n"); + } + }; + + if (DumpLinuxCPUInfo()) + DumpTextStream(MinidumpStreamType::LinuxCPUInfo, "/proc/cpuinfo"); + if (DumpLinuxProcStatus()) + DumpTextStream(MinidumpStreamType::LinuxProcStatus, "/proc/PID/status"); + if (DumpLinuxLSBRelease()) + DumpTextStream(MinidumpStreamType::LinuxLSBRelease, "/etc/lsb-release"); + if (DumpLinuxCMDLine()) + DumpTextStream(MinidumpStreamType::LinuxCMDLine, "/proc/PID/cmdline"); + if (DumpLinuxEnviron()) + DumpTextStream(MinidumpStreamType::LinuxEnviron, "/proc/PID/environ"); + if (DumpLinuxAuxv()) + DumpBinaryStream(MinidumpStreamType::LinuxAuxv, "/proc/PID/auxv"); + if (DumpLinuxMaps()) + DumpTextStream(MinidumpStreamType::LinuxMaps, "/proc/PID/maps"); + if (DumpLinuxProcStat()) + DumpTextStream(MinidumpStreamType::LinuxProcStat, "/proc/PID/stat"); + if (DumpLinuxProcUptime()) + DumpTextStream(MinidumpStreamType::LinuxProcUptime, "uptime"); + if (DumpLinuxProcFD()) + DumpTextStream(MinidumpStreamType::LinuxProcFD, "/proc/PID/fd"); + return true; + } +}; + +class CommandObjectMultiwordProcessMinidump : public CommandObjectMultiword { +public: + CommandObjectMultiwordProcessMinidump(CommandInterpreter &interpreter) + : CommandObjectMultiword(interpreter, "process plugin", + "Commands for operating on a ProcessMinidump process.", + "process plugin []") { + LoadSubCommand("dump", + CommandObjectSP(new CommandObjectProcessMinidumpDump(interpreter))); + } + + ~CommandObjectMultiwordProcessMinidump() {} +}; + +CommandObject *ProcessMinidump::GetPluginCommandObject() { + if (!m_command_sp) + m_command_sp.reset(new CommandObjectMultiwordProcessMinidump( + GetTarget().GetDebugger().GetCommandInterpreter())); + return m_command_sp.get(); +} diff --git a/source/Plugins/Process/minidump/ProcessMinidump.h b/source/Plugins/Process/minidump/ProcessMinidump.h index d65ada9009a7..4c56a7232b3c 100644 --- a/source/Plugins/Process/minidump/ProcessMinidump.h +++ b/source/Plugins/Process/minidump/ProcessMinidump.h @@ -1,20 +1,17 @@ //===-- ProcessMinidump.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ProcessMinidump_h_ #define liblldb_ProcessMinidump_h_ -// Project includes #include "MinidumpParser.h" #include "MinidumpTypes.h" -// Other libraries and framework includes #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" @@ -24,8 +21,6 @@ #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" -// C Includes -// C++ Includes namespace lldb_private { @@ -53,9 +48,11 @@ class ProcessMinidump : public Process { bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override; + CommandObject *GetPluginCommandObject() override; + Status DoLoadCore() override; - DynamicLoader *GetDynamicLoader() override; + DynamicLoader *GetDynamicLoader() override { return nullptr; } ConstString GetPluginName() override; @@ -82,6 +79,9 @@ class ProcessMinidump : public Process { Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override; + Status GetMemoryRegions( + lldb_private::MemoryRegionInfos ®ion_list) override; + bool GetProcessInfo(ProcessInstanceInfo &info) override; Status WillResume() override { @@ -102,10 +102,13 @@ class ProcessMinidump : public Process { void ReadModuleList(); + JITLoaderList &GetJITLoaders() override; + private: FileSpec m_core_file; llvm::ArrayRef m_thread_list; const MinidumpExceptionStream *m_active_exception; + lldb::CommandObjectSP m_command_sp; bool m_is_wow64; }; diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp new file mode 100644 index 000000000000..038520e696bc --- /dev/null +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp @@ -0,0 +1,533 @@ +//===-- RegisterContextMinidump_ARM.cpp -------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "RegisterContextMinidump_ARM.h" + +#include "Utility/ARM_DWARF_Registers.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/lldb-enumerations.h" + +// C includes +#include + +// C++ includes + +using namespace lldb; +using namespace lldb_private; +using namespace minidump; + +#define INV LLDB_INVALID_REGNUM +#define OFFSET(r) (offsetof(RegisterContextMinidump_ARM::Context, r)) + +#define DEF_R(i) \ + { \ + "r" #i, nullptr, 4, OFFSET(r) + i * 4, eEncodingUint, eFormatHex, \ + {dwarf_r##i, dwarf_r##i, INV, INV, reg_r##i}, \ + nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_R_ARG(i, n) \ + { \ + "r" #i, "arg" #n, 4, OFFSET(r) + i * 4, eEncodingUint, eFormatHex, \ + {dwarf_r##i, dwarf_r##i, LLDB_REGNUM_GENERIC_ARG1 + i, INV, reg_r##i}, \ + nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_D(i) \ + { \ + "d" #i, nullptr, 8, OFFSET(d) + i * 8, eEncodingVector, \ + eFormatVectorOfUInt8, {dwarf_d##i, dwarf_d##i, INV, INV, reg_d##i}, \ + nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_S(i) \ + { \ + "s" #i, nullptr, 4, OFFSET(s) + i * 4, eEncodingIEEE754, eFormatFloat, \ + {dwarf_s##i, dwarf_s##i, INV, INV, reg_s##i}, \ + nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_Q(i) \ + { \ + "q" #i, nullptr, 16, OFFSET(q) + i * 16, eEncodingVector, \ + eFormatVectorOfUInt8, {dwarf_q##i, dwarf_q##i, INV, INV, reg_q##i}, \ + nullptr, nullptr, nullptr, 0 \ + } + +// Zero based LLDB register numbers for this register context +enum { + // General Purpose Registers + reg_r0, + reg_r1, + reg_r2, + reg_r3, + reg_r4, + reg_r5, + reg_r6, + reg_r7, + reg_r8, + reg_r9, + reg_r10, + reg_r11, + reg_r12, + reg_sp, + reg_lr, + reg_pc, + reg_cpsr, + // Floating Point Registers + reg_fpscr, + reg_d0, + reg_d1, + reg_d2, + reg_d3, + reg_d4, + reg_d5, + reg_d6, + reg_d7, + reg_d8, + reg_d9, + reg_d10, + reg_d11, + reg_d12, + reg_d13, + reg_d14, + reg_d15, + reg_d16, + reg_d17, + reg_d18, + reg_d19, + reg_d20, + reg_d21, + reg_d22, + reg_d23, + reg_d24, + reg_d25, + reg_d26, + reg_d27, + reg_d28, + reg_d29, + reg_d30, + reg_d31, + reg_s0, + reg_s1, + reg_s2, + reg_s3, + reg_s4, + reg_s5, + reg_s6, + reg_s7, + reg_s8, + reg_s9, + reg_s10, + reg_s11, + reg_s12, + reg_s13, + reg_s14, + reg_s15, + reg_s16, + reg_s17, + reg_s18, + reg_s19, + reg_s20, + reg_s21, + reg_s22, + reg_s23, + reg_s24, + reg_s25, + reg_s26, + reg_s27, + reg_s28, + reg_s29, + reg_s30, + reg_s31, + reg_q0, + reg_q1, + reg_q2, + reg_q3, + reg_q4, + reg_q5, + reg_q6, + reg_q7, + reg_q8, + reg_q9, + reg_q10, + reg_q11, + reg_q12, + reg_q13, + reg_q14, + reg_q15, + k_num_regs +}; + +static RegisterInfo g_reg_info_apple_fp = { + "fp", + "r7", + 4, + OFFSET(r) + 7 * 4, + eEncodingUint, + eFormatHex, + {INV, dwarf_r7, LLDB_REGNUM_GENERIC_FP, INV, reg_r7}, + nullptr, + nullptr, + nullptr, + 0}; + +static RegisterInfo g_reg_info_fp = { + "fp", + "r11", + 4, + OFFSET(r) + 11 * 4, + eEncodingUint, + eFormatHex, + {INV, dwarf_r11, LLDB_REGNUM_GENERIC_FP, INV, reg_r11}, + nullptr, + nullptr, + nullptr, + 0}; + +// Register info definitions for this register context +static RegisterInfo g_reg_infos[] = { + DEF_R_ARG(0, 1), + DEF_R_ARG(1, 2), + DEF_R_ARG(2, 3), + DEF_R_ARG(3, 4), + DEF_R(4), + DEF_R(5), + DEF_R(6), + DEF_R(7), + DEF_R(8), + DEF_R(9), + DEF_R(10), + DEF_R(11), + DEF_R(12), + {"sp", + "r13", + 4, + OFFSET(r) + 13 * 4, + eEncodingUint, + eFormatHex, + {INV, dwarf_sp, LLDB_REGNUM_GENERIC_SP, INV, reg_sp}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "r14", + 4, + OFFSET(r) + 14 * 4, + eEncodingUint, + eFormatHex, + {INV, dwarf_lr, LLDB_REGNUM_GENERIC_RA, INV, reg_lr}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + "r15", + 4, + OFFSET(r) + 15 * 4, + eEncodingUint, + eFormatHex, + {INV, dwarf_pc, LLDB_REGNUM_GENERIC_PC, INV, reg_pc}, + nullptr, + nullptr, + nullptr, + 0}, + {"cpsr", + "psr", + 4, + OFFSET(cpsr), + eEncodingUint, + eFormatHex, + {INV, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, INV, reg_cpsr}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpscr", + nullptr, + 8, + OFFSET(fpscr), + eEncodingUint, + eFormatHex, + {INV, INV, INV, INV, reg_fpscr}, + nullptr, + nullptr, + nullptr, + 0}, + DEF_D(0), + DEF_D(1), + DEF_D(2), + DEF_D(3), + DEF_D(4), + DEF_D(5), + DEF_D(6), + DEF_D(7), + DEF_D(8), + DEF_D(9), + DEF_D(10), + DEF_D(11), + DEF_D(12), + DEF_D(13), + DEF_D(14), + DEF_D(15), + DEF_D(16), + DEF_D(17), + DEF_D(18), + DEF_D(19), + DEF_D(20), + DEF_D(21), + DEF_D(22), + DEF_D(23), + DEF_D(24), + DEF_D(25), + DEF_D(26), + DEF_D(27), + DEF_D(28), + DEF_D(29), + DEF_D(30), + DEF_D(31), + DEF_S(0), + DEF_S(1), + DEF_S(2), + DEF_S(3), + DEF_S(4), + DEF_S(5), + DEF_S(6), + DEF_S(7), + DEF_S(8), + DEF_S(9), + DEF_S(10), + DEF_S(11), + DEF_S(12), + DEF_S(13), + DEF_S(14), + DEF_S(15), + DEF_S(16), + DEF_S(17), + DEF_S(18), + DEF_S(19), + DEF_S(20), + DEF_S(21), + DEF_S(22), + DEF_S(23), + DEF_S(24), + DEF_S(25), + DEF_S(26), + DEF_S(27), + DEF_S(28), + DEF_S(29), + DEF_S(30), + DEF_S(31), + DEF_Q(0), + DEF_Q(1), + DEF_Q(2), + DEF_Q(3), + DEF_Q(4), + DEF_Q(5), + DEF_Q(6), + DEF_Q(7), + DEF_Q(8), + DEF_Q(9), + DEF_Q(10), + DEF_Q(11), + DEF_Q(12), + DEF_Q(13), + DEF_Q(14), + DEF_Q(15)}; + +constexpr size_t k_num_reg_infos = llvm::array_lengthof(g_reg_infos); + +// ARM general purpose registers. +const uint32_t g_gpr_regnums[] = { + reg_r0, + reg_r1, + reg_r2, + reg_r3, + reg_r4, + reg_r5, + reg_r6, + reg_r7, + reg_r8, + reg_r9, + reg_r10, + reg_r11, + reg_r12, + reg_sp, + reg_lr, + reg_pc, + reg_cpsr, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; +const uint32_t g_fpu_regnums[] = { + reg_fpscr, + reg_d0, + reg_d1, + reg_d2, + reg_d3, + reg_d4, + reg_d5, + reg_d6, + reg_d7, + reg_d8, + reg_d9, + reg_d10, + reg_d11, + reg_d12, + reg_d13, + reg_d14, + reg_d15, + reg_d16, + reg_d17, + reg_d18, + reg_d19, + reg_d20, + reg_d21, + reg_d22, + reg_d23, + reg_d24, + reg_d25, + reg_d26, + reg_d27, + reg_d28, + reg_d29, + reg_d30, + reg_d31, + reg_s0, + reg_s1, + reg_s2, + reg_s3, + reg_s4, + reg_s5, + reg_s6, + reg_s7, + reg_s8, + reg_s9, + reg_s10, + reg_s11, + reg_s12, + reg_s13, + reg_s14, + reg_s15, + reg_s16, + reg_s17, + reg_s18, + reg_s19, + reg_s20, + reg_s21, + reg_s22, + reg_s23, + reg_s24, + reg_s25, + reg_s26, + reg_s27, + reg_s28, + reg_s29, + reg_s30, + reg_s31, + reg_q0, + reg_q1, + reg_q2, + reg_q3, + reg_q4, + reg_q5, + reg_q6, + reg_q7, + reg_q8, + reg_q9, + reg_q10, + reg_q11, + reg_q12, + reg_q13, + reg_q14, + reg_q15, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +// Skip the last LLDB_INVALID_REGNUM in each count below by subtracting 1 +constexpr size_t k_num_gpr_regs = llvm::array_lengthof(g_gpr_regnums) - 1; +constexpr size_t k_num_fpu_regs = llvm::array_lengthof(g_fpu_regnums) - 1; + +static RegisterSet g_reg_sets[] = { + {"General Purpose Registers", "gpr", k_num_gpr_regs, g_gpr_regnums}, + {"Floating Point Registers", "fpu", k_num_fpu_regs, g_fpu_regnums}, +}; + +constexpr size_t k_num_reg_sets = llvm::array_lengthof(g_reg_sets); + +RegisterContextMinidump_ARM::RegisterContextMinidump_ARM( + Thread &thread, const DataExtractor &data, bool apple) + : RegisterContext(thread, 0), m_apple(apple) { + lldb::offset_t offset = 0; + m_regs.context_flags = data.GetU32(&offset); + for (unsigned i = 0; i < llvm::array_lengthof(m_regs.r); ++i) + m_regs.r[i] = data.GetU32(&offset); + m_regs.cpsr = data.GetU32(&offset); + m_regs.fpscr = data.GetU64(&offset); + for (unsigned i = 0; i < llvm::array_lengthof(m_regs.d); ++i) + m_regs.d[i] = data.GetU64(&offset); + lldbassert(k_num_regs == k_num_reg_infos); +} + +size_t RegisterContextMinidump_ARM::GetRegisterCount() { return k_num_regs; } + +const RegisterInfo * +RegisterContextMinidump_ARM::GetRegisterInfoAtIndex(size_t reg) { + if (reg < k_num_reg_infos) { + if (m_apple) { + if (reg == reg_r7) + return &g_reg_info_apple_fp; + } else { + if (reg == reg_r11) + return &g_reg_info_fp; + } + return &g_reg_infos[reg]; + } + return nullptr; +} + +size_t RegisterContextMinidump_ARM::GetRegisterSetCount() { + return k_num_reg_sets; +} + +const RegisterSet *RegisterContextMinidump_ARM::GetRegisterSet(size_t set) { + if (set < k_num_reg_sets) + return &g_reg_sets[set]; + return nullptr; +} + +const char *RegisterContextMinidump_ARM::GetRegisterName(unsigned reg) { + if (reg < k_num_reg_infos) + return g_reg_infos[reg].name; + return nullptr; +} + +bool RegisterContextMinidump_ARM::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; + reg_value.SetFromMemoryData( + reg_info, (const uint8_t *)&m_regs + reg_info->byte_offset, + reg_info->byte_size, lldb::eByteOrderLittle, error); + return error.Success(); +} + +bool RegisterContextMinidump_ARM::WriteRegister(const RegisterInfo *, + const RegisterValue &) { + return false; +} + +uint32_t RegisterContextMinidump_ARM::ConvertRegisterKindToRegisterNumber( + lldb::RegisterKind kind, uint32_t num) { + for (size_t i = 0; i < k_num_regs; ++i) { + if (g_reg_infos[i].kinds[kind] == num) + return i; + } + return LLDB_INVALID_REGNUM; +} diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h new file mode 100644 index 000000000000..eff8cdfef00a --- /dev/null +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h @@ -0,0 +1,92 @@ +//===-- RegisterContextMinidump_ARM.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_RegisterContextMinidump_ARM_h_ +#define liblldb_RegisterContextMinidump_ARM_h_ + +#include "MinidumpTypes.h" + +#include "Plugins/Process/Utility/RegisterInfoInterface.h" + +#include "lldb/Target/RegisterContext.h" + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitmaskEnum.h" + +// C includes +// C++ includes + +namespace lldb_private { + +namespace minidump { + +LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); + +class RegisterContextMinidump_ARM : public lldb_private::RegisterContext { +public: + RegisterContextMinidump_ARM(lldb_private::Thread &thread, + const DataExtractor &data, bool apple); + + ~RegisterContextMinidump_ARM() override = default; + + void InvalidateAllRegisters() override { + // Do nothing... registers are always valid... + } + + size_t GetRegisterCount() override; + + const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; + + size_t GetRegisterSetCount() override; + + const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; + + const char *GetRegisterName(unsigned reg); + + bool ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) override; + + bool WriteRegister(const RegisterInfo *reg_info, + const RegisterValue ®_value) override; + + uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, + uint32_t num) override; + + // Reference: see breakpad/crashpad source + struct QRegValue { + uint64_t lo; + uint64_t hi; + }; + + struct Context { + uint32_t context_flags; + uint32_t r[16]; + uint32_t cpsr; + uint64_t fpscr; + union { + uint64_t d[32]; + uint32_t s[32]; + QRegValue q[16]; + }; + uint32_t extra[8]; + }; + +protected: + enum class Flags : uint32_t { + ARM_Flag = 0x40000000, + Integer = ARM_Flag | 0x00000002, + FloatingPoint = ARM_Flag | 0x00000004, + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ FloatingPoint) + }; + Context m_regs; + const bool m_apple; // True if this is an Apple ARM where FP is R7 +}; + +} // end namespace minidump +} // end namespace lldb_private +#endif // liblldb_RegisterContextMinidump_ARM_h_ diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp new file mode 100644 index 000000000000..a5c54d73e93f --- /dev/null +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp @@ -0,0 +1,833 @@ +//===-- RegisterContextMinidump_ARM64.cpp -----------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "RegisterContextMinidump_ARM64.h" + +#include "Utility/ARM64_DWARF_Registers.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/lldb-enumerations.h" + +// C includes +#include + +// C++ includes + +using namespace lldb; +using namespace lldb_private; +using namespace minidump; + +#define INV LLDB_INVALID_REGNUM +#define OFFSET(r) (offsetof(RegisterContextMinidump_ARM64::Context, r)) + +#define DEF_X(i) \ + { \ + "x" #i, nullptr, 8, OFFSET(x) + i * 8, eEncodingUint, eFormatHex, \ + {arm64_dwarf::x##i, arm64_dwarf::x##i, INV, INV, reg_x##i}, \ + nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_W(i) \ + { \ + "w" #i, nullptr, 4, OFFSET(x) + i * 8, eEncodingUint, eFormatHex, \ + {INV, INV, INV, INV, reg_w##i}, nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_X_ARG(i, n) \ + { \ + "x" #i, "arg" #n, 8, OFFSET(x) + i * 8, eEncodingUint, eFormatHex, \ + {arm64_dwarf::x##i, arm64_dwarf::x##i, LLDB_REGNUM_GENERIC_ARG1 + i, \ + INV, reg_x##i}, nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_V(i) \ + { \ + "v" #i, nullptr, 16, OFFSET(v) + i * 16, eEncodingVector, \ + eFormatVectorOfUInt8, {arm64_dwarf::v##i, arm64_dwarf::v##i, INV, INV, \ + reg_v##i}, nullptr, nullptr, nullptr, 0 \ + } + +#define DEF_D(i) \ + { \ + "d" #i, nullptr, 8, OFFSET(v) + i * 16, eEncodingVector, \ + eFormatVectorOfUInt8, {INV, INV, INV, INV, reg_d##i}, nullptr, \ + nullptr, nullptr, 0 \ + } + +#define DEF_S(i) \ + { \ + "s" #i, nullptr, 4, OFFSET(v) + i * 16, eEncodingVector, \ + eFormatVectorOfUInt8, {INV, INV, INV, INV, reg_s##i}, nullptr, \ + nullptr, nullptr, 0 \ + } + +#define DEF_H(i) \ + { \ + "h" #i, nullptr, 2, OFFSET(v) + i * 16, eEncodingVector, \ + eFormatVectorOfUInt8, {INV, INV, INV, INV, reg_h##i}, nullptr, \ + nullptr, nullptr, 0 \ + } + +// Zero based LLDB register numbers for this register context +enum { + // General Purpose Registers + reg_x0 = 0, + reg_x1, + reg_x2, + reg_x3, + reg_x4, + reg_x5, + reg_x6, + reg_x7, + reg_x8, + reg_x9, + reg_x10, + reg_x11, + reg_x12, + reg_x13, + reg_x14, + reg_x15, + reg_x16, + reg_x17, + reg_x18, + reg_x19, + reg_x20, + reg_x21, + reg_x22, + reg_x23, + reg_x24, + reg_x25, + reg_x26, + reg_x27, + reg_x28, + reg_fp, + reg_lr, + reg_sp, + reg_pc, + reg_w0, + reg_w1, + reg_w2, + reg_w3, + reg_w4, + reg_w5, + reg_w6, + reg_w7, + reg_w8, + reg_w9, + reg_w10, + reg_w11, + reg_w12, + reg_w13, + reg_w14, + reg_w15, + reg_w16, + reg_w17, + reg_w18, + reg_w19, + reg_w20, + reg_w21, + reg_w22, + reg_w23, + reg_w24, + reg_w25, + reg_w26, + reg_w27, + reg_w28, + reg_w29, + reg_w30, + reg_w31, + reg_cpsr, + // Floating Point Registers + reg_fpsr, + reg_fpcr, + reg_v0, + reg_v1, + reg_v2, + reg_v3, + reg_v4, + reg_v5, + reg_v6, + reg_v7, + reg_v8, + reg_v9, + reg_v10, + reg_v11, + reg_v12, + reg_v13, + reg_v14, + reg_v15, + reg_v16, + reg_v17, + reg_v18, + reg_v19, + reg_v20, + reg_v21, + reg_v22, + reg_v23, + reg_v24, + reg_v25, + reg_v26, + reg_v27, + reg_v28, + reg_v29, + reg_v30, + reg_v31, + reg_d0, + reg_d1, + reg_d2, + reg_d3, + reg_d4, + reg_d5, + reg_d6, + reg_d7, + reg_d8, + reg_d9, + reg_d10, + reg_d11, + reg_d12, + reg_d13, + reg_d14, + reg_d15, + reg_d16, + reg_d17, + reg_d18, + reg_d19, + reg_d20, + reg_d21, + reg_d22, + reg_d23, + reg_d24, + reg_d25, + reg_d26, + reg_d27, + reg_d28, + reg_d29, + reg_d30, + reg_d31, + reg_s0, + reg_s1, + reg_s2, + reg_s3, + reg_s4, + reg_s5, + reg_s6, + reg_s7, + reg_s8, + reg_s9, + reg_s10, + reg_s11, + reg_s12, + reg_s13, + reg_s14, + reg_s15, + reg_s16, + reg_s17, + reg_s18, + reg_s19, + reg_s20, + reg_s21, + reg_s22, + reg_s23, + reg_s24, + reg_s25, + reg_s26, + reg_s27, + reg_s28, + reg_s29, + reg_s30, + reg_s31, + reg_h0, + reg_h1, + reg_h2, + reg_h3, + reg_h4, + reg_h5, + reg_h6, + reg_h7, + reg_h8, + reg_h9, + reg_h10, + reg_h11, + reg_h12, + reg_h13, + reg_h14, + reg_h15, + reg_h16, + reg_h17, + reg_h18, + reg_h19, + reg_h20, + reg_h21, + reg_h22, + reg_h23, + reg_h24, + reg_h25, + reg_h26, + reg_h27, + reg_h28, + reg_h29, + reg_h30, + reg_h31, + k_num_regs +}; + +// Register info definitions for this register context +static RegisterInfo g_reg_infos[] = { + DEF_X_ARG(0, 1), + DEF_X_ARG(1, 2), + DEF_X_ARG(2, 3), + DEF_X_ARG(3, 4), + DEF_X_ARG(4, 5), + DEF_X_ARG(5, 6), + DEF_X_ARG(6, 7), + DEF_X_ARG(7, 8), + DEF_X(8), + DEF_X(9), + DEF_X(10), + DEF_X(11), + DEF_X(12), + DEF_X(13), + DEF_X(14), + DEF_X(15), + DEF_X(16), + DEF_X(17), + DEF_X(18), + DEF_X(19), + DEF_X(20), + DEF_X(21), + DEF_X(22), + DEF_X(23), + DEF_X(24), + DEF_X(25), + DEF_X(26), + DEF_X(27), + DEF_X(28), + {"fp", + "x29", + 8, + OFFSET(x) + 29 * 8, + eEncodingUint, + eFormatHex, + {arm64_dwarf::x29, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, INV, reg_fp}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "x30", + 8, + OFFSET(x) + 30 * 8, + eEncodingUint, + eFormatHex, + {arm64_dwarf::x30, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, INV, reg_lr}, + nullptr, + nullptr, + nullptr, + 0}, + {"sp", + "x31", + 8, + OFFSET(x) + 31 * 8, + eEncodingUint, + eFormatHex, + {arm64_dwarf::x31, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, INV, reg_sp}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + nullptr, + 8, + OFFSET(pc), + eEncodingUint, + eFormatHex, + {arm64_dwarf::pc, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, INV, reg_pc}, + nullptr, + nullptr, + nullptr, + 0}, + // w0 - w31 + DEF_W(0), + DEF_W(1), + DEF_W(2), + DEF_W(3), + DEF_W(4), + DEF_W(5), + DEF_W(6), + DEF_W(7), + DEF_W(8), + DEF_W(9), + DEF_W(10), + DEF_W(11), + DEF_W(12), + DEF_W(13), + DEF_W(14), + DEF_W(15), + DEF_W(16), + DEF_W(17), + DEF_W(18), + DEF_W(19), + DEF_W(20), + DEF_W(21), + DEF_W(22), + DEF_W(23), + DEF_W(24), + DEF_W(25), + DEF_W(26), + DEF_W(27), + DEF_W(28), + DEF_W(29), + DEF_W(30), + DEF_W(31), + {"cpsr", + "psr", + 4, + OFFSET(cpsr), + eEncodingUint, + eFormatHex, + {INV, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, INV, reg_cpsr}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpsr", + nullptr, + 4, + OFFSET(fpsr), + eEncodingUint, + eFormatHex, + {INV, INV, INV, INV, reg_fpsr}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpcr", + nullptr, + 4, + OFFSET(fpcr), + eEncodingUint, + eFormatHex, + {INV, INV, INV, INV, reg_fpcr}, + nullptr, + nullptr, + nullptr, + 0}, + // v0 - v31 + DEF_V(0), + DEF_V(1), + DEF_V(2), + DEF_V(3), + DEF_V(4), + DEF_V(5), + DEF_V(6), + DEF_V(7), + DEF_V(8), + DEF_V(9), + DEF_V(10), + DEF_V(11), + DEF_V(12), + DEF_V(13), + DEF_V(14), + DEF_V(15), + DEF_V(16), + DEF_V(17), + DEF_V(18), + DEF_V(19), + DEF_V(20), + DEF_V(21), + DEF_V(22), + DEF_V(23), + DEF_V(24), + DEF_V(25), + DEF_V(26), + DEF_V(27), + DEF_V(28), + DEF_V(29), + DEF_V(30), + DEF_V(31), + // d0 - d31 + DEF_D(0), + DEF_D(1), + DEF_D(2), + DEF_D(3), + DEF_D(4), + DEF_D(5), + DEF_D(6), + DEF_D(7), + DEF_D(8), + DEF_D(9), + DEF_D(10), + DEF_D(11), + DEF_D(12), + DEF_D(13), + DEF_D(14), + DEF_D(15), + DEF_D(16), + DEF_D(17), + DEF_D(18), + DEF_D(19), + DEF_D(20), + DEF_D(21), + DEF_D(22), + DEF_D(23), + DEF_D(24), + DEF_D(25), + DEF_D(26), + DEF_D(27), + DEF_D(28), + DEF_D(29), + DEF_D(30), + DEF_D(31), + // s0 - s31 + DEF_S(0), + DEF_S(1), + DEF_S(2), + DEF_S(3), + DEF_S(4), + DEF_S(5), + DEF_S(6), + DEF_S(7), + DEF_S(8), + DEF_S(9), + DEF_S(10), + DEF_S(11), + DEF_S(12), + DEF_S(13), + DEF_S(14), + DEF_S(15), + DEF_S(16), + DEF_S(17), + DEF_S(18), + DEF_S(19), + DEF_S(20), + DEF_S(21), + DEF_S(22), + DEF_S(23), + DEF_S(24), + DEF_S(25), + DEF_S(26), + DEF_S(27), + DEF_S(28), + DEF_S(29), + DEF_S(30), + DEF_S(31), + // h0 - h31 + DEF_H(0), + DEF_H(1), + DEF_H(2), + DEF_H(3), + DEF_H(4), + DEF_H(5), + DEF_H(6), + DEF_H(7), + DEF_H(8), + DEF_H(9), + DEF_H(10), + DEF_H(11), + DEF_H(12), + DEF_H(13), + DEF_H(14), + DEF_H(15), + DEF_H(16), + DEF_H(17), + DEF_H(18), + DEF_H(19), + DEF_H(20), + DEF_H(21), + DEF_H(22), + DEF_H(23), + DEF_H(24), + DEF_H(25), + DEF_H(26), + DEF_H(27), + DEF_H(28), + DEF_H(29), + DEF_H(30), + DEF_H(31), +}; + +constexpr size_t k_num_reg_infos = llvm::array_lengthof(g_reg_infos); + +// ARM64 general purpose registers. +const uint32_t g_gpr_regnums[] = { + reg_x0, + reg_x1, + reg_x2, + reg_x3, + reg_x4, + reg_x5, + reg_x6, + reg_x7, + reg_x8, + reg_x9, + reg_x10, + reg_x11, + reg_x12, + reg_x13, + reg_x14, + reg_x15, + reg_x16, + reg_x17, + reg_x18, + reg_x19, + reg_x20, + reg_x21, + reg_x22, + reg_x23, + reg_x24, + reg_x25, + reg_x26, + reg_x27, + reg_x28, + reg_fp, + reg_lr, + reg_sp, + reg_w0, + reg_w1, + reg_w2, + reg_w3, + reg_w4, + reg_w5, + reg_w6, + reg_w7, + reg_w8, + reg_w9, + reg_w10, + reg_w11, + reg_w12, + reg_w13, + reg_w14, + reg_w15, + reg_w16, + reg_w17, + reg_w18, + reg_w19, + reg_w20, + reg_w21, + reg_w22, + reg_w23, + reg_w24, + reg_w25, + reg_w26, + reg_w27, + reg_w28, + reg_w29, + reg_w30, + reg_w31, + reg_pc, + reg_cpsr, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; +const uint32_t g_fpu_regnums[] = { + reg_v0, + reg_v1, + reg_v2, + reg_v3, + reg_v4, + reg_v5, + reg_v6, + reg_v7, + reg_v8, + reg_v9, + reg_v10, + reg_v11, + reg_v12, + reg_v13, + reg_v14, + reg_v15, + reg_v16, + reg_v17, + reg_v18, + reg_v19, + reg_v20, + reg_v21, + reg_v22, + reg_v23, + reg_v24, + reg_v25, + reg_v26, + reg_v27, + reg_v28, + reg_v29, + reg_v30, + reg_v31, + reg_d0, + reg_d1, + reg_d2, + reg_d3, + reg_d4, + reg_d5, + reg_d6, + reg_d7, + reg_d8, + reg_d9, + reg_d10, + reg_d11, + reg_d12, + reg_d13, + reg_d14, + reg_d15, + reg_d16, + reg_d17, + reg_d18, + reg_d19, + reg_d20, + reg_d21, + reg_d22, + reg_d23, + reg_d24, + reg_d25, + reg_d26, + reg_d27, + reg_d28, + reg_d29, + reg_d30, + reg_d31, + reg_s0, + reg_s1, + reg_s2, + reg_s3, + reg_s4, + reg_s5, + reg_s6, + reg_s7, + reg_s8, + reg_s9, + reg_s10, + reg_s11, + reg_s12, + reg_s13, + reg_s14, + reg_s15, + reg_s16, + reg_s17, + reg_s18, + reg_s19, + reg_s20, + reg_s21, + reg_s22, + reg_s23, + reg_s24, + reg_s25, + reg_s26, + reg_s27, + reg_s28, + reg_s29, + reg_s30, + reg_s31, + reg_h0, + reg_h1, + reg_h2, + reg_h3, + reg_h4, + reg_h5, + reg_h6, + reg_h7, + reg_h8, + reg_h9, + reg_h10, + reg_h11, + reg_h12, + reg_h13, + reg_h14, + reg_h15, + reg_h16, + reg_h17, + reg_h18, + reg_h19, + reg_h20, + reg_h21, + reg_h22, + reg_h23, + reg_h24, + reg_h25, + reg_h26, + reg_h27, + reg_h28, + reg_h29, + reg_h30, + reg_h31, + reg_fpsr, + reg_fpcr, + LLDB_INVALID_REGNUM // register sets need to end with this flag +}; + +// Skip the last LLDB_INVALID_REGNUM in each count below by subtracting 1 +constexpr size_t k_num_gpr_regs = llvm::array_lengthof(g_gpr_regnums) - 1; +constexpr size_t k_num_fpu_regs = llvm::array_lengthof(g_fpu_regnums) - 1; + +static RegisterSet g_reg_sets[] = { + {"General Purpose Registers", "gpr", k_num_gpr_regs, g_gpr_regnums}, + {"Floating Point Registers", "fpu", k_num_fpu_regs, g_fpu_regnums}, +}; + +constexpr size_t k_num_reg_sets = llvm::array_lengthof(g_reg_sets); + +RegisterContextMinidump_ARM64::RegisterContextMinidump_ARM64( + Thread &thread, const DataExtractor &data) + : RegisterContext(thread, 0) { + lldb::offset_t offset = 0; + m_regs.context_flags = data.GetU64(&offset); + for (unsigned i = 0; i < 32; ++i) + m_regs.x[i] = data.GetU64(&offset); + m_regs.pc = data.GetU64(&offset); + m_regs.cpsr = data.GetU32(&offset); + m_regs.fpsr = data.GetU32(&offset); + m_regs.fpcr = data.GetU32(&offset); + auto regs_data = data.GetData(&offset, sizeof(m_regs.v)); + if (regs_data) + memcpy(m_regs.v, regs_data, sizeof(m_regs.v)); + assert(k_num_regs == k_num_reg_infos); +} +size_t RegisterContextMinidump_ARM64::GetRegisterCount() { return k_num_regs; } + +const RegisterInfo * +RegisterContextMinidump_ARM64::GetRegisterInfoAtIndex(size_t reg) { + if (reg < k_num_reg_infos) + return &g_reg_infos[reg]; + return nullptr; +} + +size_t RegisterContextMinidump_ARM64::GetRegisterSetCount() { + return k_num_reg_sets; +} + +const RegisterSet *RegisterContextMinidump_ARM64::GetRegisterSet(size_t set) { + if (set < k_num_reg_sets) + return &g_reg_sets[set]; + return nullptr; +} + +const char *RegisterContextMinidump_ARM64::GetRegisterName(unsigned reg) { + if (reg < k_num_reg_infos) + return g_reg_infos[reg].name; + return nullptr; +} + +bool RegisterContextMinidump_ARM64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) { + Status error; + reg_value.SetFromMemoryData( + reg_info, (const uint8_t *)&m_regs + reg_info->byte_offset, + reg_info->byte_size, lldb::eByteOrderLittle, error); + return error.Success(); +} + +bool RegisterContextMinidump_ARM64::WriteRegister(const RegisterInfo *, + const RegisterValue &) { + return false; +} + +uint32_t RegisterContextMinidump_ARM64::ConvertRegisterKindToRegisterNumber( + lldb::RegisterKind kind, uint32_t num) { + for (size_t i = 0; i < k_num_regs; ++i) { + if (g_reg_infos[i].kinds[kind] == num) + return i; + } + return LLDB_INVALID_REGNUM; +} diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h new file mode 100644 index 000000000000..f9e7f39eea60 --- /dev/null +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h @@ -0,0 +1,82 @@ +//===-- RegisterContextMinidump_ARM64.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_RegisterContextMinidump_ARM64_h_ +#define liblldb_RegisterContextMinidump_ARM64_h_ + +#include "MinidumpTypes.h" + +#include "Plugins/Process/Utility/RegisterInfoInterface.h" +#include "lldb/Target/RegisterContext.h" + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitmaskEnum.h" + +// C includes +// C++ includes + +namespace lldb_private { + +namespace minidump { + +LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); + +class RegisterContextMinidump_ARM64 : public lldb_private::RegisterContext { +public: + RegisterContextMinidump_ARM64(lldb_private::Thread &thread, + const DataExtractor &data); + + ~RegisterContextMinidump_ARM64() override = default; + + void InvalidateAllRegisters() override { + // Do nothing... registers are always valid... + } + + size_t GetRegisterCount() override; + + const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; + + size_t GetRegisterSetCount() override; + + const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; + + const char *GetRegisterName(unsigned reg); + + bool ReadRegister(const RegisterInfo *reg_info, + RegisterValue ®_value) override; + + bool WriteRegister(const RegisterInfo *reg_info, + const RegisterValue ®_value) override; + + uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, + uint32_t num) override; + + // Reference: see breakpad/crashpad source + struct Context { + uint64_t context_flags; + uint64_t x[32]; + uint64_t pc; + uint32_t cpsr; + uint32_t fpsr; + uint32_t fpcr; + uint8_t v[32 * 16]; // 32 128-bit floating point registers + }; + +protected: + enum class Flags : uint32_t { + ARM64_Flag = 0x80000000, + Integer = ARM64_Flag | 0x00000002, + FloatingPoint = ARM64_Flag | 0x00000004, + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ FloatingPoint) + }; + Context m_regs; +}; + +} // end namespace minidump +} // end namespace lldb_private +#endif // liblldb_RegisterContextMinidump_ARM64_h_ diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp index 7605f8b143af..8ac2abb22093 100644 --- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp @@ -1,16 +1,13 @@ //===-- RegisterContextMinidump_x86_32.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "RegisterContextMinidump_x86_32.h" -// Other libraries and framework includes #include "lldb/Utility/DataBufferHeap.h" // C includes diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h index e18bb3b4f5d9..d787f78ec7d3 100644 --- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h @@ -1,19 +1,16 @@ //===-- RegisterContextMinidump_x86_32.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextMinidump_x86_32_h_ #define liblldb_RegisterContextMinidump_x86_32_h_ -// Project includes #include "MinidumpTypes.h" -// Other libraries and framework includes #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "Plugins/Process/Utility/lldb-x86-register-enums.h" diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp index ba1cb6dbf3ef..515ccf6b2c3c 100644 --- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp @@ -1,16 +1,13 @@ //===-- RegisterContextMinidump_x86_64.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "RegisterContextMinidump_x86_64.h" -// Other libraries and framework includes #include "lldb/Utility/DataBufferHeap.h" // C includes diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h index 9ba2ee9f29ad..34ddd477a9d1 100644 --- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h +++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h @@ -1,19 +1,16 @@ //===-- RegisterContextMinidump_x86_64.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_RegisterContextMinidump_h_ #define liblldb_RegisterContextMinidump_h_ -// Project includes #include "MinidumpTypes.h" -// Other libraries and framework includes #include "Plugins/Process/Utility/RegisterInfoInterface.h" #include "Plugins/Process/Utility/lldb-x86-register-enums.h" diff --git a/source/Plugins/Process/minidump/ThreadMinidump.cpp b/source/Plugins/Process/minidump/ThreadMinidump.cpp index 3fafb6134e7f..340ed3c1aff0 100644 --- a/source/Plugins/Process/minidump/ThreadMinidump.cpp +++ b/source/Plugins/Process/minidump/ThreadMinidump.cpp @@ -1,20 +1,19 @@ //===-- ThreadMinidump.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "ThreadMinidump.h" #include "ProcessMinidump.h" +#include "RegisterContextMinidump_ARM.h" +#include "RegisterContextMinidump_ARM64.h" #include "RegisterContextMinidump_x86_32.h" #include "RegisterContextMinidump_x86_64.h" -// Other libraries and framework includes #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" #include "Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h" @@ -27,8 +26,6 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" -// C Includes -// C++ Includes using namespace lldb; using namespace lldb_private; @@ -54,7 +51,6 @@ RegisterContextSP ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) { RegisterContextSP reg_ctx_sp; uint32_t concrete_frame_idx = 0; - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); if (frame) concrete_frame_idx = frame->GetConcreteFrameIndex(); @@ -88,15 +84,22 @@ ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) { *this, reg_interface, gpregset, {})); break; } - default: + case llvm::Triple::aarch64: { + DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(), + lldb::eByteOrderLittle, 8); + m_thread_reg_ctx_sp.reset(new RegisterContextMinidump_ARM64(*this, data)); break; } - - if (!reg_interface) { - if (log) - log->Printf("elf-core::%s:: Architecture(%d) not supported", - __FUNCTION__, arch.GetMachine()); - assert(false && "Architecture not supported"); + case llvm::Triple::arm: { + DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(), + lldb::eByteOrderLittle, 8); + const bool apple = arch.GetTriple().getVendor() == llvm::Triple::Apple; + m_thread_reg_ctx_sp.reset( + new RegisterContextMinidump_ARM(*this, data, apple)); + break; + } + default: + break; } reg_ctx_sp = m_thread_reg_ctx_sp; diff --git a/source/Plugins/Process/minidump/ThreadMinidump.h b/source/Plugins/Process/minidump/ThreadMinidump.h index 74ac44f74dcf..75401a16676c 100644 --- a/source/Plugins/Process/minidump/ThreadMinidump.h +++ b/source/Plugins/Process/minidump/ThreadMinidump.h @@ -1,23 +1,18 @@ //===-- ThreadMinidump.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ThreadMinidump_h_ #define liblldb_ThreadMinidump_h_ -// Project includes #include "MinidumpTypes.h" -// Other libraries and framework includes #include "lldb/Target/Thread.h" -// C Includes -// C++ Includes namespace lldb_private { diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp index ab4603e68705..f87dcd8cb3a4 100644 --- a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp +++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp @@ -1,9 +1,8 @@ //===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h index 824579472b5e..2b0e272f6f36 100644 --- a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h +++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h @@ -1,19 +1,14 @@ //===-- ScriptInterpreterNone.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_ScriptInterpreterNone_h_ #define liblldb_ScriptInterpreterNone_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/ScriptInterpreter.h" namespace lldb_private { diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 90d8ab97fb73..88759e320428 100644 --- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -1,9 +1,8 @@ //===-- PythonDataObjects.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -222,9 +221,7 @@ PythonBytes::~PythonBytes() {} bool PythonBytes::Check(PyObject *py_obj) { if (!py_obj) return false; - if (PyBytes_Check(py_obj)) - return true; - return false; + return PyBytes_Check(py_obj); } void PythonBytes::Reset(PyRefType type, PyObject *py_obj) { @@ -294,9 +291,7 @@ PythonByteArray::~PythonByteArray() {} bool PythonByteArray::Check(PyObject *py_obj) { if (!py_obj) return false; - if (PyByteArray_Check(py_obj)) - return true; - return false; + return PyByteArray_Check(py_obj); } void PythonByteArray::Reset(PyRefType type, PyObject *py_obj) { @@ -939,7 +934,8 @@ PythonFile::PythonFile() : PythonObject() {} PythonFile::PythonFile(File &file, const char *mode) { Reset(file, mode); } PythonFile::PythonFile(const char *path, const char *mode) { - lldb_private::File file(path, GetOptionsFromMode(mode)); + lldb_private::File file; + FileSystem::Instance().Open(file, FileSpec(path), GetOptionsFromMode(mode)); Reset(file, mode); } diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index beeb64782367..bc6c3c59e4a9 100644 --- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -1,9 +1,8 @@ //===-- PythonDataObjects.h--------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,10 +14,6 @@ // LLDB Python header must be included first #include "lldb-python.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" #include "lldb/Host/File.h" diff --git a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp index d28a8033820a..c9d834ce6868 100644 --- a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp +++ b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp @@ -1,9 +1,8 @@ //===-- PythonExceptionState.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h index 20f4b4c6329d..3a88aa037776 100644 --- a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h +++ b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h @@ -1,9 +1,8 @@ //===-- PythonExceptionState.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 536ced89c73a..f2dbe0ad4cce 100644 --- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1,9 +1,8 @@ //===-- ScriptInterpreterPython.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -137,6 +136,9 @@ struct InitializePythonRAII { InitializePythonHome(); + // Register _lldb as a built-in module. + PyImport_AppendInittab("_lldb", g_swig_init_callback); + // Python < 3.2 and Python >= 3.2 reversed the ordering requirements for // calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you // call `PyEval_InitThreads` first, and >= 3.2 requires that you call it last. @@ -205,7 +207,7 @@ ScriptInterpreterPython::Locker::Locker(ScriptInterpreterPython *py_interpreter, m_python_interpreter(py_interpreter) { DoAcquireLock(); if ((on_entry & InitSession) == InitSession) { - if (DoInitSession(on_entry, in, out, err) == false) { + if (!DoInitSession(on_entry, in, out, err)) { // Don't teardown the session if we didn't init it. m_teardown_session = false; } @@ -826,11 +828,15 @@ bool ScriptInterpreterPython::ExecuteOneLine( error_file_sp); } else { input_file_sp.reset(new StreamFile()); - input_file_sp->GetFile().Open(FileSystem::DEV_NULL, - File::eOpenOptionRead); + FileSystem::Instance().Open(input_file_sp->GetFile(), + FileSpec(FileSystem::DEV_NULL), + File::eOpenOptionRead); + output_file_sp.reset(new StreamFile()); - output_file_sp->GetFile().Open(FileSystem::DEV_NULL, - File::eOpenOptionWrite); + FileSystem::Instance().Open(output_file_sp->GetFile(), + FileSpec(FileSystem::DEV_NULL), + File::eOpenOptionWrite); + error_file_sp = output_file_sp; } @@ -1544,7 +1550,7 @@ lldb::ValueObjectListSP ScriptInterpreterPython::GetRecognizedArguments( if (py_return.get()) { PythonList result_list(PyRefType::Borrowed, py_return.get()); ValueObjectListSP result = ValueObjectListSP(new ValueObjectList()); - for (int i = 0; i < result_list.GetSize(); i++) { + for (size_t i = 0; i < result_list.GetSize(); i++) { PyObject *item = result_list.GetItemAtIndex(i).get(); lldb::SBValue *sb_value_ptr = (lldb::SBValue *)g_swig_cast_to_sbvalue(item); @@ -2014,7 +2020,7 @@ ScriptInterpreterPython::ScriptedBreakpointResolverSearchDepth( StructuredData::ObjectSP ScriptInterpreterPython::LoadPluginModule(const FileSpec &file_spec, lldb_private::Status &error) { - if (!file_spec.Exists()) { + if (!FileSystem::Instance().Exists(file_spec)) { error.SetErrorString("no such file"); return StructuredData::ObjectSP(); } @@ -2746,7 +2752,8 @@ bool ScriptInterpreterPython::LoadScriptingModule( lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this(); { - FileSpec target_file(pathname, true); + FileSpec target_file(pathname); + FileSystem::Instance().Resolve(target_file); std::string basename(target_file.GetFilename().GetCString()); StreamString command_stream; @@ -2830,7 +2837,7 @@ bool ScriptInterpreterPython::LoadScriptingModule( bool was_imported = (was_imported_globally || was_imported_locally); - if (was_imported == true && can_reload == false) { + if (was_imported && !can_reload) { error.SetErrorString("module already imported"); return false; } diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h index 7314bba7cc65..54c38eddc73d 100644 --- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h +++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h @@ -1,9 +1,8 @@ //===-- ScriptInterpreterPython.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,14 +15,10 @@ #else -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "PythonDataObjects.h" #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Core/IOHandler.h" diff --git a/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/source/Plugins/ScriptInterpreter/Python/lldb-python.h index f929baade2e4..8796f1d944b9 100644 --- a/source/Plugins/ScriptInterpreter/Python/lldb-python.h +++ b/source/Plugins/ScriptInterpreter/Python/lldb-python.h @@ -1,9 +1,8 @@ //===-- lldb-python.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index d00a17d39e6a..f5bf13036e40 100644 --- a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -1,9 +1,8 @@ //===-- StructuredDataDarwinLog.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -482,11 +481,11 @@ static constexpr OptionDefinition g_enable_option_table[] = { "message."}, {LLDB_OPT_SET_ALL, false, "subsystem", 's', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, - "Include the subsystem in the the message header when displaying " + "Include the subsystem in the message header when displaying " "a log message."}, {LLDB_OPT_SET_ALL, false, "category", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, - "Include the category in the the message header when displaying " + "Include the category in the message header when displaying " "a log message."}, {LLDB_OPT_SET_ALL, false, "activity-chain", 'C', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, @@ -1677,7 +1676,7 @@ void StructuredDataDarwinLog::AddInitCompletionHook(Process &process) { // Build up the module list. FileSpecList module_spec_list; auto module_file_spec = - FileSpec(GetGlobalProperties()->GetLoggingModuleName(), false); + FileSpec(GetGlobalProperties()->GetLoggingModuleName()); module_spec_list.Append(module_file_spec); // We aren't specifying a source file set. diff --git a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h index 77b6e7be71c7..8571662e53fd 100644 --- a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h +++ b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h @@ -1,9 +1,8 @@ //===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/Breakpad/CMakeLists.txt b/source/Plugins/SymbolFile/Breakpad/CMakeLists.txt new file mode 100644 index 000000000000..e93d0618a0e4 --- /dev/null +++ b/source/Plugins/SymbolFile/Breakpad/CMakeLists.txt @@ -0,0 +1,12 @@ +add_lldb_library(lldbPluginSymbolFileBreakpad PLUGIN + SymbolFileBreakpad.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbSymbol + lldbUtility + lldbPluginObjectFileBreakpad + LINK_COMPONENTS + Support + ) diff --git a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp new file mode 100644 index 000000000000..98d2e9296dcf --- /dev/null +++ b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -0,0 +1,220 @@ +//===-- SymbolFileBreakpad.cpp ----------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h" +#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h" +#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Section.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/TypeMap.h" +#include "lldb/Utility/Log.h" +#include "llvm/ADT/StringExtras.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::breakpad; + +namespace { +class LineIterator { +public: + // begin iterator for sections of given type + LineIterator(ObjectFile &obj, Record::Kind section_type) + : m_obj(&obj), m_section_type(toString(section_type)), + m_next_section_idx(0) { + ++*this; + } + + // end iterator + explicit LineIterator(ObjectFile &obj) + : m_obj(&obj), + m_next_section_idx(m_obj->GetSectionList()->GetNumSections(0)) {} + + friend bool operator!=(const LineIterator &lhs, const LineIterator &rhs) { + assert(lhs.m_obj == rhs.m_obj); + if (lhs.m_next_section_idx != rhs.m_next_section_idx) + return true; + if (lhs.m_next_text.data() != rhs.m_next_text.data()) + return true; + assert(lhs.m_current_text == rhs.m_current_text); + assert(rhs.m_next_text == rhs.m_next_text); + return false; + } + + const LineIterator &operator++(); + llvm::StringRef operator*() const { return m_current_text; } + +private: + ObjectFile *m_obj; + ConstString m_section_type; + uint32_t m_next_section_idx; + llvm::StringRef m_current_text; + llvm::StringRef m_next_text; +}; +} // namespace + +const LineIterator &LineIterator::operator++() { + const SectionList &list = *m_obj->GetSectionList(); + size_t num_sections = list.GetNumSections(0); + while (m_next_text.empty() && m_next_section_idx < num_sections) { + Section § = *list.GetSectionAtIndex(m_next_section_idx++); + if (sect.GetName() != m_section_type) + continue; + DataExtractor data; + m_obj->ReadSectionData(§, data); + m_next_text = + llvm::StringRef(reinterpret_cast(data.GetDataStart()), + data.GetByteSize()); + } + std::tie(m_current_text, m_next_text) = m_next_text.split('\n'); + return *this; +} + +static llvm::iterator_range lines(ObjectFile &obj, + Record::Kind section_type) { + return llvm::make_range(LineIterator(obj, section_type), LineIterator(obj)); +} + +void SymbolFileBreakpad::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); +} + +void SymbolFileBreakpad::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); +} + +ConstString SymbolFileBreakpad::GetPluginNameStatic() { + static ConstString g_name("breakpad"); + return g_name; +} + +uint32_t SymbolFileBreakpad::CalculateAbilities() { + if (!m_obj_file) + return 0; + if (m_obj_file->GetPluginName() != ObjectFileBreakpad::GetPluginNameStatic()) + return 0; + + return CompileUnits | Functions; +} + +uint32_t SymbolFileBreakpad::GetNumCompileUnits() { + // TODO + return 0; +} + +CompUnitSP SymbolFileBreakpad::ParseCompileUnitAtIndex(uint32_t index) { + // TODO + return nullptr; +} + +size_t SymbolFileBreakpad::ParseFunctions(CompileUnit &comp_unit) { + // TODO + return 0; +} + +bool SymbolFileBreakpad::ParseLineTable(CompileUnit &comp_unit) { + // TODO + return 0; +} + +uint32_t +SymbolFileBreakpad::ResolveSymbolContext(const Address &so_addr, + SymbolContextItem resolve_scope, + SymbolContext &sc) { + // TODO + return 0; +} + +uint32_t SymbolFileBreakpad::FindFunctions( + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + FunctionNameType name_type_mask, bool include_inlines, bool append, + SymbolContextList &sc_list) { + // TODO + if (!append) + sc_list.Clear(); + return sc_list.GetSize(); +} + +uint32_t SymbolFileBreakpad::FindFunctions(const RegularExpression ®ex, + bool include_inlines, bool append, + SymbolContextList &sc_list) { + // TODO + if (!append) + sc_list.Clear(); + return sc_list.GetSize(); +} + +uint32_t SymbolFileBreakpad::FindTypes( + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, + llvm::DenseSet &searched_symbol_files, TypeMap &types) { + if (!append) + types.Clear(); + return types.GetSize(); +} + +size_t +SymbolFileBreakpad::FindTypes(const std::vector &context, + bool append, TypeMap &types) { + if (!append) + types.Clear(); + return types.GetSize(); +} + +void SymbolFileBreakpad::AddSymbols(Symtab &symtab) { + Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS); + Module &module = *m_obj_file->GetModule(); + addr_t base = module.GetObjectFile()->GetBaseAddress().GetFileAddress(); + if (base == LLDB_INVALID_ADDRESS) { + LLDB_LOG(log, "Unable to fetch the base address of object file. Skipping " + "symtab population."); + return; + } + + const SectionList &list = *module.GetSectionList(); + llvm::DenseMap symbols; + auto add_symbol = [&](addr_t address, llvm::Optional size, + llvm::StringRef name) { + address += base; + SectionSP section_sp = list.FindSectionContainingFileAddress(address); + if (!section_sp) { + LLDB_LOG(log, + "Ignoring symbol {0}, whose address ({1}) is outside of the " + "object file. Mismatched symbol file?", + name, address); + return; + } + symbols.try_emplace( + address, /*symID*/ 0, Mangled(name, /*is_mangled*/ false), + eSymbolTypeCode, /*is_global*/ true, /*is_debug*/ false, + /*is_trampoline*/ false, /*is_artificial*/ false, + AddressRange(section_sp, address - section_sp->GetFileAddress(), + size.getValueOr(0)), + size.hasValue(), /*contains_linker_annotations*/ false, /*flags*/ 0); + }; + + for (llvm::StringRef line : lines(*m_obj_file, Record::Func)) { + if (auto record = FuncRecord::parse(line)) + add_symbol(record->Address, record->Size, record->Name); + } + + for (llvm::StringRef line : lines(*m_obj_file, Record::Public)) { + if (auto record = PublicRecord::parse(line)) + add_symbol(record->Address, llvm::None, record->Name); + else + LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line); + } + + for (auto &KV : symbols) + symtab.AddSymbol(std::move(KV.second)); + symtab.CalculateSymbolSizes(); +} diff --git a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h index ef3073b341d5..c06aea9d6f1f 100644 --- a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h +++ b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h @@ -9,9 +9,6 @@ #ifndef LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H #define LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H -#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h" -#include "lldb/Core/FileSpecList.h" -#include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolFile.h" namespace lldb_private { @@ -66,12 +63,14 @@ class SymbolFileBreakpad : public SymbolFile { bool ParseDebugMacros(CompileUnit &comp_unit) override { return false; } bool ParseSupportFiles(CompileUnit &comp_unit, - FileSpecList &support_files) override; + FileSpecList &support_files) override { + return false; + } size_t ParseTypes(CompileUnit &cu) override { return 0; } bool ParseImportedModules( const SymbolContext &sc, - std::vector &imported_modules) override { + std::vector &imported_modules) override { return false; } @@ -99,11 +98,6 @@ class SymbolFileBreakpad : public SymbolFile { lldb::SymbolContextItem resolve_scope, SymbolContext &sc) override; - uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, - bool check_inlines, - lldb::SymbolContextItem resolve_scope, - SymbolContextList &sc_list) override; - size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override { return 0; @@ -143,66 +137,6 @@ class SymbolFileBreakpad : public SymbolFile { uint32_t GetPluginVersion() override { return 1; } private: - // A class representing a position in the breakpad file. Useful for - // remembering the position so we can go back to it later and parse more data. - // Can be converted to/from a LineIterator, but it has a much smaller memory - // footprint. - struct Bookmark { - uint32_t section; - size_t offset; - }; - - // At iterator class for simplifying algorithms reading data from the breakpad - // file. It iterates over all records (lines) in the sections of a given type. - // It also supports saving a specific position (via the GetBookmark() method) - // and then resuming from it afterwards. - class LineIterator; - - // Return an iterator range for all records in the given object file of the - // given type. - llvm::iterator_range lines(Record::Kind section_type); - - // Breakpad files do not contain sufficient information to correctly - // reconstruct compile units. The approach chosen here is to treat each - // function as a compile unit. The compile unit name is the name if the first - // line entry belonging to this function. - // This class is our internal representation of a compile unit. It stores the - // CompileUnit object and a bookmark pointing to the FUNC record of the - // compile unit function. It also lazily construct the list of support files - // and line table entries for the compile unit, when these are needed. - class CompUnitData { - public: - CompUnitData(Bookmark bookmark) : bookmark(bookmark) {} - - CompUnitData() = default; - CompUnitData(const CompUnitData &rhs) : bookmark(rhs.bookmark) {} - CompUnitData &operator=(const CompUnitData &rhs) { - bookmark = rhs.bookmark; - support_files.reset(); - line_table_up.reset(); - return *this; - } - friend bool operator<(const CompUnitData &lhs, const CompUnitData &rhs) { - return std::tie(lhs.bookmark.section, lhs.bookmark.offset) < - std::tie(rhs.bookmark.section, rhs.bookmark.offset); - } - - Bookmark bookmark; - llvm::Optional support_files; - std::unique_ptr line_table_up; - - }; - - SymbolVendor &GetSymbolVendor(); - lldb::addr_t GetBaseFileAddress(); - void ParseFileRecords(); - void ParseCUData(); - void ParseLineTableAndSupportFiles(CompileUnit &cu, CompUnitData &data); - - using CompUnitMap = RangeDataVector; - - llvm::Optional> m_files; - llvm::Optional m_cu_data; }; } // namespace breakpad diff --git a/source/Plugins/SymbolFile/CMakeLists.txt b/source/Plugins/SymbolFile/CMakeLists.txt index 98510704ce73..ad1c92bd8469 100644 --- a/source/Plugins/SymbolFile/CMakeLists.txt +++ b/source/Plugins/SymbolFile/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(Breakpad) add_subdirectory(DWARF) add_subdirectory(Symtab) +add_subdirectory(NativePDB) add_subdirectory(PDB) diff --git a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index db75cf9c3bb3..926fa507eaf5 100644 --- a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -1,9 +1,8 @@ //===-- AppleDWARFIndex.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h index ea133d0e73cf..188b97ad15a0 100644 --- a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h +++ b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h @@ -1,9 +1,8 @@ //===-- AppleDWARFIndex.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 0cd0f0c0272a..626d1a95b76f 100644 --- a/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -1,9 +1,8 @@ //===-- DIERef.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DIERef.h b/source/Plugins/SymbolFile/DWARF/DIERef.h index cb28c890c25a..a867a5f41d1f 100644 --- a/source/Plugins/SymbolFile/DWARF/DIERef.h +++ b/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -1,9 +1,8 @@ //===-- DIERef.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h index b439d7fe590f..e7927b31b9c3 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h @@ -1,9 +1,8 @@ //===-- DWARFASTParser.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,6 +17,7 @@ class DWARFDIE; namespace lldb_private { +class CompileUnit; class ExecutionContext; } class SymbolFileDWARF; @@ -32,7 +32,7 @@ class DWARFASTParser { bool *type_is_new_ptr) = 0; virtual lldb_private::Function * - ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, + ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) = 0; virtual bool diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index be7d4aba5e4f..32832917ccf2 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1,9 +1,8 @@ //===-- DWARFASTParserClang.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -125,7 +124,7 @@ ClangASTImporter &DWARFASTParserClang::GetClangASTImporter() { } /// Detect a forward declaration that is nested in a DW_TAG_module. -static bool isClangModuleFwdDecl(const DWARFDIE &Die) { +static bool IsClangModuleFwdDecl(const DWARFDIE &Die) { if (!Die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0)) return false; auto Parent = Die.GetParent(); @@ -142,30 +141,31 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) { if (!dwo_module_sp) return TypeSP(); - // This type comes from an external DWO module. - std::vector dwo_context; - die.GetDeclContext(dwo_context); + // If this type comes from a Clang module, look in the DWARF section + // of the pcm file in the module cache. Clang generates DWO skeleton + // units as breadcrumbs to find them. + std::vector decl_context; + die.GetDeclContext(decl_context); TypeMap dwo_types; - if (!dwo_module_sp->GetSymbolVendor()->FindTypes(dwo_context, true, + if (!dwo_module_sp->GetSymbolVendor()->FindTypes(decl_context, true, dwo_types)) { - if (!isClangModuleFwdDecl(die)) + if (!IsClangModuleFwdDecl(die)) return TypeSP(); // Since this this type is defined in one of the Clang modules imported by // this symbol file, search all of them. - auto *SymFile = die.GetCU()->GetSymbolFileDWARF(); - for (const auto &NameModule : SymFile->getExternalTypeModules()) { - if (!NameModule.second) + auto *sym_file = die.GetCU()->GetSymbolFileDWARF(); + for (const auto &name_module : sym_file->getExternalTypeModules()) { + if (!name_module.second) continue; - SymbolVendor *SymVendor = NameModule.second->GetSymbolVendor(); - if (SymVendor->FindTypes(dwo_context, true, dwo_types)) + SymbolVendor *sym_vendor = name_module.second->GetSymbolVendor(); + if (sym_vendor->FindTypes(decl_context, true, dwo_types)) break; } } - const size_t num_dwo_types = dwo_types.GetSize(); - if (num_dwo_types != 1) + if (dwo_types.GetSize() != 1) return TypeSP(); // We found a real definition for this type in the Clang module, so lets use @@ -264,7 +264,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, const char *mangled_name_cstr = NULL; ConstString type_name_const_str; Type::ResolveState resolve_state = Type::eResolveStateUnresolved; - uint64_t byte_size = 0; + llvm::Optional byte_size; Declaration decl; Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; @@ -307,14 +307,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: - type_name_cstr = form_value.AsCString(); - // Work around a bug in llvm-gcc where they give a name to a - // reference type which doesn't include the "&"... - if (tag == DW_TAG_reference_type) { - if (strchr(type_name_cstr, '&') == NULL) - type_name_cstr = NULL; - } if (type_name_cstr) type_name_const_str.SetCString(type_name_cstr); break; @@ -393,7 +386,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, case DW_TAG_base_type: resolve_state = Type::eResolveStateFull; clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize( - type_name_cstr, encoding, byte_size * 8); + type_name_cstr, encoding, byte_size.getValueOr(0) * 8); break; case DW_TAG_pointer_type: @@ -421,8 +414,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID || - encoding_data_type == Type::eEncodingIsTypedefUID) && - sc.comp_unit != NULL) { + encoding_data_type == Type::eEncodingIsTypedefUID)) { if (tag == DW_TAG_pointer_type) { DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type); @@ -543,7 +535,6 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, case DW_TAG_class_type: { // Set a bit that lets us know that we are currently parsing this dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; - bool byte_size_valid = false; LanguageType class_language = eLanguageTypeUnknown; bool is_complete_objc_class = false; @@ -558,16 +549,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: - if (die.GetCU()->DW_AT_decl_file_attributes_are_invalid()) { - // llvm-gcc outputs invalid DW_AT_decl_file attributes that - // always point to the compile unit file, so we clear this - // invalid value so that we can still unique types - // efficiently. - decl.SetFile(FileSpec("", false)); - } else - decl.SetFile( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( - form_value.Unsigned())); + decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( + form_value.Unsigned())); break; case DW_AT_decl_line: @@ -585,7 +568,6 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, case DW_AT_byte_size: byte_size = form_value.Unsigned(); - byte_size_valid = true; break; case DW_AT_accessibility: @@ -645,7 +627,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (dwarf->GetUniqueDWARFASTTypeMap().Find( unique_typename, die, unique_decl, - byte_size_valid ? byte_size : -1, *unique_ast_entry_ap)) { + byte_size ? *byte_size : -1, *unique_ast_entry_ap)) { type_sp = unique_ast_entry_ap->m_type_sp; if (type_sp) { dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); @@ -670,8 +652,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, default_accessibility = eAccessPrivate; } - if (byte_size_valid && byte_size == 0 && type_name_cstr && - die.HasChildren() == false && + if (byte_size && *byte_size == 0 && type_name_cstr && + !die.HasChildren() && sc.comp_unit->GetLanguage() == eLanguageTypeObjC) { // Work around an issue with clang at the moment where forward // declarations for objective C classes are emitted as: @@ -873,7 +855,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, unique_ast_entry_ap->m_type_sp = type_sp; unique_ast_entry_ap->m_die = die; unique_ast_entry_ap->m_declaration = unique_decl; - unique_ast_entry_ap->m_byte_size = byte_size; + unique_ast_entry_ap->m_byte_size = byte_size.getValueOr(0); dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename, *unique_ast_entry_ap); @@ -909,7 +891,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, // has child classes or types that require the class to be created // for use as their decl contexts the class will be ready to accept // these child definitions. - if (die.HasChildren() == false) { + if (!die.HasChildren()) { // No children for this struct/union/class, lets finish it if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) { ClangASTContext::CompleteTagDeclarationDefinition(clang_type); @@ -1100,10 +1082,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, } if (!enumerator_clang_type) { - if (byte_size > 0) { + if (byte_size) { enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize( - NULL, DW_ATE_signed, byte_size * 8); + NULL, DW_ATE_signed, *byte_size * 8); } else { enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt); } @@ -1131,7 +1113,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, bool is_signed = false; enumerator_clang_type.IsIntegerType(is_signed); ParseChildEnumerators(cu_sc, clang_type, is_signed, - type_sp->GetByteSize(), die); + type_sp->GetByteSize().getValueOr(0), die); } ClangASTContext::CompleteTagDeclarationDefinition(clang_type); } else { @@ -1308,10 +1290,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (die.HasChildren()) { bool skip_artificial = true; - ParseChildParameters(sc, containing_decl_ctx, die, skip_artificial, - is_static, is_variadic, has_template_params, - function_param_types, function_param_decls, - type_quals); + ParseChildParameters(*sc.comp_unit, containing_decl_ctx, die, + skip_artificial, is_static, is_variadic, + has_template_params, function_param_types, + function_param_decls, type_quals); } bool ignore_containing_context = false; @@ -1669,9 +1651,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, } } } - type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL, - LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, - clang_type, Type::eResolveStateFull)); + type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, + llvm::None, NULL, LLDB_INVALID_UID, + Type::eEncodingIsUID, &decl, clang_type, + Type::eResolveStateFull)); assert(type_sp.get()); } break; @@ -1680,7 +1663,6 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; DWARFFormValue type_die_form; - int64_t first_index = 0; uint32_t byte_stride = 0; uint32_t bit_stride = 0; bool is_vector = false; @@ -1750,17 +1732,16 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, if (element_type) { auto array_info = ParseChildArrayInfo(die); if (array_info) { - first_index = array_info->first_index; byte_stride = array_info->byte_stride; bit_stride = array_info->bit_stride; } if (byte_stride == 0 && bit_stride == 0) - byte_stride = element_type->GetByteSize(); + byte_stride = element_type->GetByteSize().getValueOr(0); CompilerType array_element_type = element_type->GetForwardCompilerType(); if (ClangASTContext::IsCXXClassType(array_element_type) && - array_element_type.GetCompleteType() == false) { + !array_element_type.GetCompleteType()) { ModuleSP module_sp = die.GetModule(); if (module_sp) { if (die.GetCU()->GetProducer() == eProducerClang) @@ -1865,7 +1846,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, clang_type = ClangASTContext::CreateMemberPointerType( class_clang_type, pointee_clang_type); - if (auto clang_type_size = clang_type.GetByteSize(nullptr)) { + if (llvm::Optional clang_type_size = + clang_type.GetByteSize(nullptr)) { byte_size = *clang_type_size; type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL, LLDB_INVALID_UID, @@ -2061,7 +2043,7 @@ bool DWARFASTParserClang::ParseTemplateDIE( clang_type.IsIntegerOrEnumerationType(is_signed); if (tag == DW_TAG_template_value_parameter && uval64_valid) { - auto size = clang_type.GetBitSize(nullptr); + llvm::Optional size = clang_type.GetBitSize(nullptr); if (!size) return false; llvm::APInt apint(*size, uval64, is_signed); @@ -2116,95 +2098,6 @@ bool DWARFASTParserClang::ParseTemplateParameterInfos( return template_param_infos.args.size() == template_param_infos.names.size(); } -// Checks whether m1 is an overload of m2 (as opposed to an override). This is -// called by addOverridesForMethod to distinguish overrides (which share a -// vtable entry) from overloads (which require distinct entries). -static bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) { - // FIXME: This should detect covariant return types, but currently doesn't. - lldbassert(&m1->getASTContext() == &m2->getASTContext() && - "Methods should have the same AST context"); - clang::ASTContext &context = m1->getASTContext(); - - const auto *m1Type = - llvm::cast( - context.getCanonicalType(m1->getType())); - - const auto *m2Type = - llvm::cast( - context.getCanonicalType(m2->getType())); - - auto compareArgTypes = - [&context](const clang::QualType &m1p, const clang::QualType &m2p) { - return context.hasSameType(m1p.getUnqualifiedType(), - m2p.getUnqualifiedType()); - }; - - // FIXME: In C++14 and later, we can just pass m2Type->param_type_end() - // as a fourth parameter to std::equal(). - return (m1->getNumParams() != m2->getNumParams()) || - !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(), - m2Type->param_type_begin(), compareArgTypes); -} - -// If decl is a virtual method, walk the base classes looking for methods that -// decl overrides. This table of overridden methods is used by IRGen to -// determine the vtable layout for decl's parent class. -static void addOverridesForMethod(clang::CXXMethodDecl *decl) { - if (!decl->isVirtual()) - return; - - clang::CXXBasePaths paths; - - auto find_overridden_methods = - [decl](const clang::CXXBaseSpecifier *specifier, clang::CXXBasePath &path) { - if (auto *base_record = - llvm::dyn_cast( - specifier->getType()->getAs()->getDecl())) { - - clang::DeclarationName name = decl->getDeclName(); - - // If this is a destructor, check whether the base class destructor is - // virtual. - if (name.getNameKind() == clang::DeclarationName::CXXDestructorName) - if (auto *baseDtorDecl = base_record->getDestructor()) { - if (baseDtorDecl->isVirtual()) { - path.Decls = baseDtorDecl; - return true; - } else - return false; - } - - // Otherwise, search for name in the base class. - for (path.Decls = base_record->lookup(name); !path.Decls.empty(); - path.Decls = path.Decls.slice(1)) { - if (auto *method_decl = - llvm::dyn_cast(path.Decls.front())) - if (method_decl->isVirtual() && !isOverload(decl, method_decl)) { - path.Decls = method_decl; - return true; - } - } - } - - return false; - }; - - if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) { - for (auto *overridden_decl : paths.found_decls()) - decl->addOverriddenMethod( - llvm::cast(overridden_decl)); - } -} - -// If clang_type is a CXXRecordDecl, builds the method override list for each -// of its virtual methods. -static void addMethodOverrides(ClangASTContext &ast, CompilerType &clang_type) { - if (auto *record = - ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType())) - for (auto *method : record->methods()) - addOverridesForMethod(method); -} - bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, CompilerType &clang_type) { @@ -2295,14 +2188,14 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, } SymbolContext sc(die.GetLLDBCompileUnit()); - std::vector base_classes; + std::vector> bases; std::vector member_accessibilities; bool is_a_class = false; // Parse members and base classes first DWARFDIECollection member_function_dies; DelayedPropertyList delayed_properties; - ParseChildMembers(sc, die, clang_type, class_language, base_classes, + ParseChildMembers(sc, die, clang_type, class_language, bases, member_accessibilities, member_function_dies, delayed_properties, default_accessibility, is_a_class, layout_info); @@ -2366,17 +2259,17 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, &member_accessibilities.front(), member_accessibilities.size()); } - if (!base_classes.empty()) { + if (!bases.empty()) { // Make sure all base classes refer to complete types and not forward // declarations. If we don't do this, clang will crash with an - // assertion in the call to clang_type.SetBaseClassesForClassType() - for (auto &base_class : base_classes) { + // assertion in the call to clang_type.TransferBaseClasses() + for (const auto &base_class : bases) { clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo(); if (type_source_info) { CompilerType base_class_type( &m_ast, type_source_info->getType().getAsOpaquePtr()); - if (base_class_type.GetCompleteType() == false) { + if (!base_class_type.GetCompleteType()) { auto module = dwarf->GetObjectFile()->GetModule(); module->ReportError(":: Class '%s' has a base class '%s' which " "does not have a complete definition.", @@ -2389,7 +2282,7 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, // We have no choice other than to pretend that the base class // is complete. If we don't do this, clang will crash when we // call setBases() inside of - // "clang_type.SetBaseClassesForClassType()" below. Since we + // "clang_type.TransferBaseClasses()" below. Since we // provide layout assistance, all ivars in this class and other // classes will be fine, this is the best we can do short of // crashing. @@ -2401,19 +2294,14 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, } } } - m_ast.SetBaseClassesForClassType(clang_type.GetOpaqueQualType(), - &base_classes.front(), - base_classes.size()); - - // Clang will copy each CXXBaseSpecifier in "base_classes" so we have - // to free them all. - ClangASTContext::DeleteBaseClassSpecifiers(&base_classes.front(), - base_classes.size()); + + m_ast.TransferBaseClasses(clang_type.GetOpaqueQualType(), + std::move(bases)); } } } - addMethodOverrides(m_ast, clang_type); + m_ast.AddMethodOverridesForCXXRecordType(clang_type.GetOpaqueQualType()); ClangASTContext::BuildIndirectFields(clang_type); ClangASTContext::CompleteTagDeclarationDefinition(clang_type); @@ -2421,7 +2309,7 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, !layout_info.base_offsets.empty() || !layout_info.vbase_offsets.empty()) { if (type) - layout_info.bit_size = type->GetByteSize() * 8; + layout_info.bit_size = type->GetByteSize().getValueOr(0) * 8; if (layout_info.bit_size == 0) layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8; @@ -2505,8 +2393,8 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, SymbolContext sc(die.GetLLDBCompileUnit()); bool is_signed = false; clang_type.IsIntegerType(is_signed); - ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), - die); + ParseChildEnumerators(sc, clang_type, is_signed, + type->GetByteSize().getValueOr(0), die); } ClangASTContext::CompleteTagDeclarationDefinition(clang_type); } @@ -2669,7 +2557,7 @@ class DIEStack { }; #endif -Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, +Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit, const DWARFDIE &die) { DWARFRangeList func_ranges; const char *name = NULL; @@ -2730,9 +2618,9 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(die, nullptr); - ParseChildParameters(sc, containing_decl_ctx, die, true, is_static, - is_variadic, has_template_params, param_types, - param_decls, type_quals); + ParseChildParameters(comp_unit, containing_decl_ctx, die, true, + is_static, is_variadic, has_template_params, + param_types, param_decls, type_quals); sstr << "("; for (size_t i = 0; i < param_types.size(); i++) { if (i > 0) @@ -2753,7 +2641,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, std::unique_ptr decl_ap; if (decl_file != 0 || decl_line != 0 || decl_column != 0) decl_ap.reset(new Declaration( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), + comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); SymbolFileDWARF *dwarf = die.GetDWARF(); @@ -2764,7 +2652,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, if (dwarf->FixupAddress(func_range.GetBaseAddress())) { const user_id_t func_user_id = die.GetID(); - func_sp.reset(new Function(sc.comp_unit, + func_sp.reset(new Function(&comp_unit, func_user_id, // UserID is the DIE offset func_user_id, func_name, func_type, func_range)); // first address range @@ -2772,7 +2660,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, if (func_sp.get() != NULL) { if (frame_base.IsValid()) func_sp->GetFrameBaseExpression() = frame_base; - sc.comp_unit->AddFunction(func_sp); + comp_unit.AddFunction(func_sp); return func_sp.get(); } } @@ -2784,7 +2672,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, bool DWARFASTParserClang::ParseChildMembers( const SymbolContext &sc, const DWARFDIE &parent_die, CompilerType &class_clang_type, const LanguageType class_language, - std::vector &base_classes, + std::vector> &base_classes, std::vector &member_accessibilities, DWARFDIECollection &member_function_dies, DelayedPropertyList &delayed_properties, AccessType &default_accessibility, @@ -2830,7 +2718,7 @@ bool DWARFASTParserClang::ParseChildMembers( AccessType accessibility = eAccessNone; uint32_t member_byte_offset = (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX; - size_t byte_size = 0; + llvm::Optional byte_size; int64_t bit_offset = 0; uint64_t data_bit_offset = UINT64_MAX; size_t bit_size = 0; @@ -2973,7 +2861,7 @@ bool DWARFASTParserClang::ParseChildMembers( // with a crash if we try to use this type in an expression when clang // becomes unhappy with its recycled debug info. - if (byte_size == 0 && bit_offset < 0) { + if (byte_size.getValueOr(0) == 0 && bit_offset < 0) { bit_size = 0; bit_offset = 0; } @@ -2983,15 +2871,6 @@ bool DWARFASTParserClang::ParseChildMembers( class_language == eLanguageTypeObjC_plus_plus) accessibility = eAccessNone; - if (member_idx == 0 && !is_artificial && name && - (strstr(name, "_vptr$") == name)) { - // Not all compilers will mark the vtable pointer member as - // artificial (llvm-gcc). We can't have the virtual members in our - // classes otherwise it throws off all child offsets since we end up - // having and extra pointer sized member in our class layouts. - is_artificial = true; - } - // Handle static members if (is_external && member_byte_offset == UINT32_MAX) { Type *var_type = die.ResolveTypeUID(DIERef(encoding_form)); @@ -3006,7 +2885,7 @@ bool DWARFASTParserClang::ParseChildMembers( break; } - if (is_artificial == false) { + if (!is_artificial) { Type *member_type = die.ResolveTypeUID(DIERef(encoding_form)); clang::FieldDecl *field_decl = NULL; @@ -3044,12 +2923,12 @@ bool DWARFASTParserClang::ParseChildMembers( if (data_bit_offset != UINT64_MAX) { this_field_info.bit_offset = data_bit_offset; } else { - if (byte_size == 0) + if (!byte_size) byte_size = member_type->GetByteSize(); ObjectFile *objfile = die.GetDWARF()->GetObjectFile(); if (objfile->GetByteOrder() == eByteOrderLittle) { - this_field_info.bit_offset += byte_size * 8; + this_field_info.bit_offset += byte_size.getValueOr(0) * 8; this_field_info.bit_offset -= (bit_offset + bit_size); } else { this_field_info.bit_offset += bit_offset; @@ -3147,7 +3026,7 @@ bool DWARFASTParserClang::ParseChildMembers( if (anon_field_info.IsValid()) { clang::FieldDecl *unnamed_bitfield_decl = ClangASTContext::AddFieldToRecordType( - class_clang_type, NULL, + class_clang_type, llvm::StringRef(), m_ast.GetBuiltinTypeForEncodingAndBitSize( eEncodingSint, word_width), accessibility, anon_field_info.bit_size); @@ -3204,7 +3083,7 @@ bool DWARFASTParserClang::ParseChildMembers( } if (ClangASTContext::IsCXXClassType(member_clang_type) && - member_clang_type.GetCompleteType() == false) { + !member_clang_type.GetCompleteType()) { if (die.GetCU()->GetProducer() == eProducerClang) module_sp->ReportError( "DWARF DIE at 0x%8.8x (class %s) has a member variable " @@ -3389,9 +3268,14 @@ bool DWARFASTParserClang::ParseChildMembers( if (class_language == eLanguageTypeObjC) { ast->SetObjCSuperClass(class_clang_type, base_class_clang_type); } else { - base_classes.push_back(ast->CreateBaseClassSpecifier( - base_class_clang_type.GetOpaqueQualType(), accessibility, - is_virtual, is_base_of_class)); + std::unique_ptr result = + ast->CreateBaseClassSpecifier( + base_class_clang_type.GetOpaqueQualType(), accessibility, + is_virtual, is_base_of_class); + if (!result) + break; + + base_classes.push_back(std::move(result)); if (is_virtual) { // Do not specify any offset for virtual inheritance. The DWARF @@ -3425,7 +3309,7 @@ bool DWARFASTParserClang::ParseChildMembers( } size_t DWARFASTParserClang::ParseChildParameters( - const SymbolContext &sc, clang::DeclContext *containing_decl_ctx, + CompileUnit &comp_unit, clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, bool &has_template_params, std::vector &function_param_types, @@ -3457,7 +3341,7 @@ size_t DWARFASTParserClang::ParseChildParameters( if (attributes.ExtractFormValueAtIndex(i, form_value)) { switch (attr) { case DW_AT_decl_file: - decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex( + decl.SetFile(comp_unit.GetSupportFiles().GetFileSpecAtIndex( form_value.Unsigned())); break; case DW_AT_decl_line: @@ -3523,8 +3407,9 @@ size_t DWARFASTParserClang::ParseChildParameters( function_param_types.push_back(type->GetForwardCompilerType()); clang::ParmVarDecl *param_var_decl = - m_ast.CreateParameterDeclaration( - name, type->GetForwardCompilerType(), storage); + m_ast.CreateParameterDeclaration(containing_decl_ctx, name, + type->GetForwardCompilerType(), + storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 5eb3eabfb707..75411c220448 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -1,24 +1,19 @@ //===-- DWARFASTParserClang.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARF_DWARFASTParserClang_h_ #define SymbolFileDWARF_DWARFASTParserClang_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "clang/AST/CharUnits.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" -// Project includes #include "DWARFASTParser.h" #include "DWARFDefines.h" #include "lldb/Core/ClangForward.h" @@ -26,6 +21,9 @@ #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" +namespace lldb_private { +class CompileUnit; +} class DWARFDebugInfoEntry; class DWARFDIECollection; class SymbolFileDWARF; @@ -42,7 +40,7 @@ class DWARFASTParserClang : public DWARFASTParser { bool *type_is_new_ptr) override; lldb_private::Function * - ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, + ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) override; bool @@ -81,19 +79,19 @@ class DWARFASTParserClang : public DWARFASTParser { lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); - bool - ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die, - lldb_private::CompilerType &class_compiler_type, - const lldb::LanguageType class_language, - std::vector &base_classes, - std::vector &member_accessibilities, - DWARFDIECollection &member_function_dies, - DelayedPropertyList &delayed_properties, - lldb::AccessType &default_accessibility, bool &is_a_class, - lldb_private::ClangASTImporter::LayoutInfo &layout_info); + bool ParseChildMembers( + const lldb_private::SymbolContext &sc, const DWARFDIE &die, + lldb_private::CompilerType &class_compiler_type, + const lldb::LanguageType class_language, + std::vector> &base_classes, + std::vector &member_accessibilities, + DWARFDIECollection &member_function_dies, + DelayedPropertyList &delayed_properties, + lldb::AccessType &default_accessibility, bool &is_a_class, + lldb_private::ClangASTImporter::LayoutInfo &layout_info); size_t - ParseChildParameters(const lldb_private::SymbolContext &sc, + ParseChildParameters(lldb_private::CompileUnit &comp_unit, clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp index 841814bf4424..074b19e6beb8 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.cpp @@ -279,8 +279,8 @@ void DWARFASTParserSwift::GetClangType(const DWARFDIE &die, } } -Function *DWARFASTParserSwift::ParseFunctionFromDWARF(const SymbolContext &sc, - const DWARFDIE &die) { +Function *DWARFASTParserSwift::ParseFunctionFromDWARF( + lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) { DWARFRangeList func_ranges; const char *name = NULL; const char *mangled = NULL; @@ -341,19 +341,19 @@ Function *DWARFASTParserSwift::ParseFunctionFromDWARF(const SymbolContext &sc, std::unique_ptr decl_ap; if (decl_file != 0 || decl_line != 0 || decl_column != 0) decl_ap.reset(new Declaration( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), + comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); if (dwarf->FixupAddress(func_range.GetBaseAddress())) { const user_id_t func_user_id = die.GetID(); - func_sp.reset(new Function(sc.comp_unit, func_user_id, func_user_id, + func_sp.reset(new Function(&comp_unit, func_user_id, func_user_id, func_name, nullptr, func_range, can_throw)); // first address range if (func_sp.get() != NULL) { if (frame_base.IsValid()) func_sp->GetFrameBaseExpression() = frame_base; - sc.comp_unit->AddFunction(func_sp); + comp_unit.AddFunction(func_sp); return func_sp.get(); } } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.h index 408a18980936..0f72b91ae767 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwift.h @@ -30,7 +30,7 @@ class DWARFASTParserSwift : public DWARFASTParser { bool *type_is_new_ptr) override; lldb_private::Function * - ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, + ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die) override; bool diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp index a765be0b46d0..c384baafa1ac 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp @@ -1,9 +1,8 @@ //===-- DWARFAbbreviationDeclaration.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -41,9 +40,13 @@ bool DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor &data, while (data.ValidOffset(*offset_ptr)) { dw_attr_t attr = data.GetULEB128(offset_ptr); dw_form_t form = data.GetULEB128(offset_ptr); + DWARFFormValue::ValueType val; + + if (form == DW_FORM_implicit_const) + val.value.sval = data.GetULEB128(offset_ptr); if (attr && form) - m_attributes.push_back(DWARFAttribute(attr, form)); + m_attributes.push_back(DWARFAttribute(attr, form, val)); else break; } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h index b2296c455d6a..9f1e7fdb7f3b 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h @@ -1,9 +1,8 @@ //===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -35,20 +34,11 @@ class DWARFAbbreviationDeclaration { dw_form_t GetFormByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0; } - bool GetAttrAndFormByIndex(uint32_t idx, dw_attr_t &attr, - dw_form_t &form) const { - if (m_attributes.size() > idx) { - m_attributes[idx].get(attr, form); - return true; - } - attr = form = 0; - return false; - } - // idx is assumed to be valid when calling GetAttrAndFormByIndexUnchecked() - void GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t &attr, - dw_form_t &form) const { - m_attributes[idx].get(attr, form); + // idx is assumed to be valid when calling GetAttrAndFormByIndex() + void GetAttrAndFormValueByIndex(uint32_t idx, dw_attr_t &attr, + DWARFFormValue &form_value) const { + m_attributes[idx].get(attr, form_value.FormRef(), form_value.ValueRef()); } dw_form_t GetFormByIndexUnchecked(uint32_t idx) const { return m_attributes[idx].get_form(); diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp index 2586d1f18530..734283307dbd 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -1,9 +1,8 @@ //===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,10 +25,10 @@ uint32_t DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const { return UINT32_MAX; } -void DWARFAttributes::Append(const DWARFUnit *cu, - dw_offset_t attr_die_offset, dw_attr_t attr, - dw_form_t form) { - AttributeValue attr_value = {cu, attr_die_offset, {attr, form}}; +void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset, + dw_attr_t attr, dw_form_t form) { + AttributeValue attr_value = { + cu, attr_die_offset, {attr, form, DWARFFormValue::ValueType()}}; m_infos.push_back(attr_value); } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h index db4324cf7725..0964abeecc56 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -1,9 +1,8 @@ //===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,15 +10,17 @@ #define SymbolFileDWARF_DWARFAttribute_h_ #include "DWARFDefines.h" +#include "DWARFFormValue.h" #include "llvm/ADT/SmallVector.h" #include class DWARFUnit; -class DWARFFormValue; class DWARFAttribute { public: - DWARFAttribute(dw_attr_t attr, dw_form_t form) : m_attr(attr), m_form(form) {} + DWARFAttribute(dw_attr_t attr, dw_form_t form, + DWARFFormValue::ValueType value) + : m_attr(attr), m_form(form), m_value(value) {} void set(dw_attr_t attr, dw_form_t form) { m_attr = attr; @@ -29,9 +30,11 @@ class DWARFAttribute { void set_form(dw_form_t form) { m_form = form; } dw_attr_t get_attr() const { return m_attr; } dw_form_t get_form() const { return m_form; } - void get(dw_attr_t &attr, dw_form_t &form) const { + void get(dw_attr_t &attr, dw_form_t &form, + DWARFFormValue::ValueType &val) const { attr = m_attr; form = m_form; + val = m_value; } bool operator==(const DWARFAttribute &rhs) const { return m_attr == rhs.m_attr && m_form == rhs.m_form; @@ -43,6 +46,7 @@ class DWARFAttribute { protected: dw_attr_t m_attr; dw_form_t m_form; + DWARFFormValue::ValueType m_value; }; class DWARFAttributes { diff --git a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp index 077de9604f1d..63b77ff962a5 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -1,9 +1,8 @@ //===-- DWARFBaseDIE.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h index 2163a027ffbc..ba9a32f062ac 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h @@ -1,9 +1,8 @@ //===-- DWARFBaseDIE.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index 8541f1cfe1f6..e6d1f9a18424 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -1,9 +1,8 @@ //===-- DWARFCompileUnit.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -34,8 +33,18 @@ DWARFUnitSP DWARFCompileUnit::Extract(SymbolFileDWARF *dwarf2Data, cu_sp->m_length = debug_info.GetDWARFInitialLength(offset_ptr); cu_sp->m_is_dwarf64 = debug_info.IsDWARF64(); cu_sp->m_version = debug_info.GetU16(offset_ptr); - abbr_offset = debug_info.GetDWARFOffset(offset_ptr); - cu_sp->m_addr_size = debug_info.GetU8(offset_ptr); + + if (cu_sp->m_version == 5) { + cu_sp->m_unit_type = debug_info.GetU8(offset_ptr); + cu_sp->m_addr_size = debug_info.GetU8(offset_ptr); + abbr_offset = debug_info.GetDWARFOffset(offset_ptr); + + if (cu_sp->m_unit_type == llvm::dwarf::DW_UT_skeleton) + cu_sp->m_dwo_id = debug_info.GetU64(offset_ptr); + } else { + abbr_offset = debug_info.GetDWARFOffset(offset_ptr); + cu_sp->m_addr_size = debug_info.GetU8(offset_ptr); + } bool length_OK = debug_info.ValidOffset(cu_sp->GetNextCompileUnitOffset() - 1); @@ -65,6 +74,23 @@ void DWARFCompileUnit::Dump(Stream *s) const { GetNextCompileUnitOffset()); } +uint32_t DWARFCompileUnit::GetHeaderByteSize() const { + if (m_version < 5) + return m_is_dwarf64 ? 23 : 11; + + switch (m_unit_type) { + case llvm::dwarf::DW_UT_compile: + case llvm::dwarf::DW_UT_partial: + return 12; + case llvm::dwarf::DW_UT_skeleton: + case llvm::dwarf::DW_UT_split_compile: + return 20; + case llvm::dwarf::DW_UT_type: + case llvm::dwarf::DW_UT_split_type: + return 24; + } + llvm_unreachable("invalid UnitType."); +} const lldb_private::DWARFDataExtractor &DWARFCompileUnit::GetData() const { return m_dwarf->get_debug_info_data(); diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index 9c1fc82f58b7..5ace0c7ad477 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -1,9 +1,8 @@ //===-- DWARFCompileUnit.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,8 +12,6 @@ #include "DWARFUnit.h" class DWARFCompileUnit : public DWARFUnit { - friend class DWARFUnit; - public: static DWARFUnitSP Extract(SymbolFileDWARF *dwarf2Data, const lldb_private::DWARFDataExtractor &debug_info, @@ -37,9 +34,7 @@ class DWARFCompileUnit : public DWARFUnit { /// @return /// Byte size of the compile unit header //------------------------------------------------------------------ - uint32_t GetHeaderByteSize() const override { - return m_is_dwarf64 ? 23 : 11; - } + uint32_t GetHeaderByteSize() const override; private: DWARFCompileUnit(SymbolFileDWARF *dwarf2Data); diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp index 22b70b2d6852..36960dfe8f85 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -1,9 +1,8 @@ //===-- DWARFDIE.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/source/Plugins/SymbolFile/DWARF/DWARFDIE.h index b0d06a886ac1..a4d99684eef0 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDIE.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.h @@ -1,9 +1,8 @@ //===-- DWARFDIE.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp index 1e5bf619f798..bf463dd18277 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp @@ -1,9 +1,8 @@ //===-- DWARFDIECollection.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h index e1e73e71ae7f..3cb3f2e8f6a3 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h @@ -1,9 +1,8 @@ //===-- DWARFDIECollection.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp index 2fcdd34d532f..1e4b95fe4288 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp @@ -1,9 +1,8 @@ //===-- DWARFDataExtractor.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h index ce0bfb3931d5..03e390c4618c 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h @@ -1,16 +1,14 @@ //===-- DWARFDataExtractor.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_DWARFDataExtractor_h_ #define liblldb_DWARFDataExtractor_h_ -// Other libraries and framework includes. #include "lldb/Core/dwarf.h" #include "lldb/Utility/DataExtractor.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp index affe4b85bdab..2fd772c933fb 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugAbbrev.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h index 2bacb6349b6f..68527aea2b36 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h @@ -1,9 +1,8 @@ //===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp index 00265361f865..ad3709541d79 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugArangeSet.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h index ae6319a13d0e..6fca5bf3987f 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h @@ -1,9 +1,8 @@ //===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index 02f528d571b0..55d2f6ffe1e3 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugAranges.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h index 6524cb3ce483..622f10699d90 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h @@ -1,9 +1,8 @@ //===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -19,7 +18,7 @@ class SymbolFileDWARF; class DWARFDebugAranges { protected: - typedef lldb_private::RangeDataArray + typedef lldb_private::RangeDataVector RangeToDIE; public: diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index dadc30dc918a..41f3f07c6815 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugInfo.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index fc6085f99a21..4e92d1aab9de 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -1,9 +1,8 @@ //===-- DWARFDebugInfo.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 005d13bf89ea..70cdb8285646 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugInfoEntry.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -40,9 +39,8 @@ bool DWARFDebugInfoEntry::FastExtract( m_offset = *offset_ptr; m_parent_idx = 0; m_sibling_idx = 0; - m_empty_children = false; const uint64_t abbr_idx = debug_info_data.GetULEB128(offset_ptr); - assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE)); + lldbassert(abbr_idx <= UINT16_MAX); m_abbr_idx = abbr_idx; // assert (fixed_form_sizes); // For best performance this should be @@ -119,21 +117,33 @@ bool DWARFDebugInfoEntry::FastExtract( break; // 1 byte values + case DW_FORM_addrx1: case DW_FORM_data1: case DW_FORM_flag: case DW_FORM_ref1: + case DW_FORM_strx1: form_size = 1; break; // 2 byte values + case DW_FORM_addrx2: case DW_FORM_data2: case DW_FORM_ref2: + case DW_FORM_strx2: form_size = 2; break; + // 3 byte values + case DW_FORM_addrx3: + case DW_FORM_strx3: + form_size = 3; + break; + // 4 byte values + case DW_FORM_addrx4: case DW_FORM_data4: case DW_FORM_ref4: + case DW_FORM_strx4: form_size = 4; break; @@ -145,11 +155,14 @@ bool DWARFDebugInfoEntry::FastExtract( break; // signed or unsigned LEB 128 values + case DW_FORM_addrx: + case DW_FORM_rnglistx: case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: case DW_FORM_GNU_addr_index: case DW_FORM_GNU_str_index: + case DW_FORM_strx: debug_info_data.Skip_LEB128(&offset); break; @@ -166,6 +179,10 @@ bool DWARFDebugInfoEntry::FastExtract( debug_info_data.GetU32(&offset); break; + case DW_FORM_implicit_const: + form_size = 0; + break; + default: *offset_ptr = m_offset; return false; @@ -208,7 +225,7 @@ bool DWARFDebugInfoEntry::Extract(SymbolFileDWARF *dwarf2Data, m_offset = offset; const uint64_t abbr_idx = debug_info_data.GetULEB128(&offset); - assert(abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE)); + lldbassert(abbr_idx <= UINT16_MAX); m_abbr_idx = abbr_idx; if (abbr_idx) { const DWARFAbbreviationDeclaration *abbrevDecl = @@ -225,15 +242,14 @@ bool DWARFDebugInfoEntry::Extract(SymbolFileDWARF *dwarf2Data, // Skip all data in the .debug_info for the attributes const uint32_t numAttributes = abbrevDecl->NumAttributes(); - uint32_t i; - dw_attr_t attr; - dw_form_t form; - for (i = 0; i < numAttributes; ++i) { - abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); + for (uint32_t i = 0; i < numAttributes; ++i) { + DWARFFormValue form_value(cu); + dw_attr_t attr; + abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value); + dw_form_t form = form_value.Form(); if (isCompileUnitTag && ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) { - DWARFFormValue form_value(cu, form); if (form_value.ExtractValue(debug_info_data, &offset)) { if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc) const_cast(cu)->SetBaseAddress( @@ -279,6 +295,7 @@ bool DWARFDebugInfoEntry::Extract(SymbolFileDWARF *dwarf2Data, // 0 sized form case DW_FORM_flag_present: + case DW_FORM_implicit_const: form_size = 0; break; @@ -370,6 +387,13 @@ void DWARFDebugInfoEntry::DumpAncestry(SymbolFileDWARF *dwarf2Data, Dump(dwarf2Data, cu, s, recurse_depth); } +static dw_offset_t GetRangesOffset(const DWARFDebugRangesBase *debug_ranges, + DWARFFormValue &form_value) { + if (form_value.Form() == DW_FORM_rnglistx) + return debug_ranges->GetOffset(form_value.Unsigned()); + return form_value.Unsigned(); +} + //---------------------------------------------------------------------- // GetDIENamesAndRanges // @@ -409,14 +433,13 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges( return false; const uint32_t numAttributes = abbrevDecl->NumAttributes(); - uint32_t i; - dw_attr_t attr; - dw_form_t form; bool do_offset = false; - for (i = 0; i < numAttributes; ++i) { - abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); - DWARFFormValue form_value(cu, form); + for (uint32_t i = 0; i < numAttributes; ++i) { + DWARFFormValue form_value(cu); + dw_attr_t attr; + abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value); + if (form_value.ExtractValue(debug_info_data, &offset)) { switch (attr) { case DW_AT_low_pc: @@ -446,20 +469,15 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges( break; case DW_AT_ranges: { - const DWARFDebugRanges *debug_ranges = dwarf2Data->DebugRanges(); - if (debug_ranges) { - debug_ranges->FindRanges(cu->GetRangesBase(), form_value.Unsigned(), ranges); - // All DW_AT_ranges are relative to the base address of the compile - // unit. We add the compile unit base address to make sure all the - // addresses are properly fixed up. - ranges.Slide(cu->GetBaseAddress()); - } else { + const DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges(); + if (debug_ranges) + debug_ranges->FindRanges(cu, GetRangesOffset(debug_ranges, form_value), ranges); + else cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError( "{0x%8.8x}: DIE has DW_AT_ranges(0x%" PRIx64 ") attribute yet DWARF has no .debug_ranges, please file a bug " "and attach the file at the start of this error message", m_offset, form_value.Unsigned()); - } } break; case DW_AT_name: @@ -521,7 +539,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges( block_length); } else { const DWARFDataExtractor &debug_loc_data = - dwarf2Data->get_debug_loc_data(); + dwarf2Data->DebugLocData(); const dw_offset_t debug_loc_offset = form_value.Unsigned(); size_t loc_list_length = DWARFExpression::LocationListSize( @@ -606,14 +624,13 @@ void DWARFDebugInfoEntry::Dump(SymbolFileDWARF *dwarf2Data, // Dump all data in the .debug_info for the attributes const uint32_t numAttributes = abbrevDecl->NumAttributes(); - uint32_t i; - dw_attr_t attr; - dw_form_t form; - for (i = 0; i < numAttributes; ++i) { - abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); + for (uint32_t i = 0; i < numAttributes; ++i) { + DWARFFormValue form_value(cu); + dw_attr_t attr; + abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value); DumpAttribute(dwarf2Data, cu, debug_info_data, &offset, s, attr, - form); + form_value); } const DWARFDebugInfoEntry *child = GetFirstChild(); @@ -663,23 +680,21 @@ void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data, void DWARFDebugInfoEntry::DumpAttribute( SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, - Stream &s, dw_attr_t attr, dw_form_t form) { + Stream &s, dw_attr_t attr, DWARFFormValue &form_value) { bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm); s.Printf(" "); s.Indent(DW_AT_value_to_name(attr)); if (show_form) { - s.Printf("[%s", DW_FORM_value_to_name(form)); + s.Printf("[%s", DW_FORM_value_to_name(form_value.Form())); } - DWARFFormValue form_value(cu, form); - if (!form_value.ExtractValue(debug_info_data, offset_ptr)) return; if (show_form) { - if (form == DW_FORM_indirect) { + if (form_value.Form() == DW_FORM_indirect) { s.Printf(" [%s]", DW_FORM_value_to_name(form_value.Form())); } @@ -719,7 +734,7 @@ void DWARFDebugInfoEntry::DumpAttribute( uint64_t debug_loc_offset = form_value.Unsigned(); if (dwarf2Data) { DWARFExpression::PrintDWARFLocationList( - s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset); + s, cu, dwarf2Data->DebugLocData(), debug_loc_offset); } } } break; @@ -740,11 +755,13 @@ void DWARFDebugInfoEntry::DumpAttribute( } break; case DW_AT_ranges: { - lldb::offset_t ranges_offset = form_value.Unsigned(); + if (!dwarf2Data) + break; + lldb::offset_t ranges_offset = + GetRangesOffset(dwarf2Data->DebugRanges(), form_value); dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0; - if (dwarf2Data) - DWARFDebugRanges::Dump(s, dwarf2Data->get_debug_ranges_data(), - &ranges_offset, base_addr); + DWARFDebugRanges::Dump(s, dwarf2Data->get_debug_ranges_data(), + &ranges_offset, base_addr); } break; default: @@ -786,11 +803,11 @@ size_t DWARFDebugInfoEntry::GetAttributes( cu->GetAddressByteSize(), cu->IsDWARF64()); const uint32_t num_attributes = abbrevDecl->NumAttributes(); - uint32_t i; - dw_attr_t attr; - dw_form_t form; - for (i = 0; i < num_attributes; ++i) { - abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); + for (uint32_t i = 0; i < num_attributes; ++i) { + DWARFFormValue form_value(cu); + dw_attr_t attr; + abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value); + const dw_form_t form = form_value.Form(); // If we are tracking down DW_AT_specification or DW_AT_abstract_origin // attributes, the depth will be non-zero. We need to omit certain @@ -811,7 +828,6 @@ size_t DWARFDebugInfoEntry::GetAttributes( } if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin)) { - DWARFFormValue form_value(cu, form); if (form_value.ExtractValue(debug_info_data, &offset)) { dw_offset_t die_offset = form_value.Reference(); DWARFDIE spec_die = @@ -1064,14 +1080,11 @@ size_t DWARFDebugInfoEntry::GetAttributeAddressRanges( bool check_specification_or_abstract_origin) const { ranges.Clear(); - dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned( - dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET, - check_specification_or_abstract_origin); - if (debug_ranges_offset != DW_INVALID_OFFSET) { - DWARFDebugRanges *debug_ranges = dwarf2Data->DebugRanges(); - - debug_ranges->FindRanges(cu->GetRangesBase(), debug_ranges_offset, ranges); - ranges.Slide(cu->GetBaseAddress()); + DWARFFormValue form_value; + if (GetAttributeValue(dwarf2Data, cu, DW_AT_ranges, form_value)) { + if (DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges()) + debug_ranges->FindRanges(cu, GetRangesOffset(debug_ranges, form_value), + ranges); } else if (check_hi_lo_pc) { dw_addr_t lo_pc = LLDB_INVALID_ADDRESS; dw_addr_t hi_pc = LLDB_INVALID_ADDRESS; @@ -1722,16 +1735,13 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address, ((function_die != NULL) || (block_die != NULL)); } } else { - dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned( - dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET); - if (debug_ranges_offset != DW_INVALID_OFFSET) { + DWARFFormValue form_value; + if (GetAttributeValue(dwarf2Data, cu, DW_AT_ranges, form_value)) { DWARFRangeList ranges; - DWARFDebugRanges *debug_ranges = dwarf2Data->DebugRanges(); - debug_ranges->FindRanges(cu->GetRangesBase(), debug_ranges_offset, ranges); - // All DW_AT_ranges are relative to the base address of the compile - // unit. We add the compile unit base address to make sure all the - // addresses are properly fixed up. - ranges.Slide(cu->GetBaseAddress()); + DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges(); + debug_ranges->FindRanges( + cu, GetRangesOffset(debug_ranges, form_value), ranges); + if (ranges.FindEntryThatContains(address)) { found_address = true; // puts("***MATCH***"); @@ -1838,7 +1848,6 @@ void DWARFDebugInfoEntry::DumpDIECollection( bool DWARFDebugInfoEntry::operator==(const DWARFDebugInfoEntry &rhs) const { return m_offset == rhs.m_offset && m_parent_idx == rhs.m_parent_idx && m_sibling_idx == rhs.m_sibling_idx && - m_empty_children == rhs.m_empty_children && m_abbr_idx == rhs.m_abbr_idx && m_has_children == rhs.m_has_children && m_tag == rhs.m_tag; } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h index 5002a2e239dc..b278c9a8960a 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -1,9 +1,8 @@ //===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -43,7 +42,6 @@ typedef UInt32ToDIEMMap::const_iterator UInt32ToDIEMMapConstIter; class DWARFDeclContext; #define DIE_SIBLING_IDX_BITSIZE 31 -#define DIE_ABBR_IDX_BITSIZE 15 class DWARFDebugInfoEntry { public: @@ -57,8 +55,7 @@ class DWARFDebugInfoEntry { DWARFDebugInfoEntry() : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0), - m_empty_children(false), m_abbr_idx(0), m_has_children(false), - m_tag(0) {} + m_has_children(false), m_abbr_idx(0), m_tag(0) {} explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; } bool operator==(const DWARFDebugInfoEntry &rhs) const; @@ -182,7 +179,7 @@ class DWARFDebugInfoEntry { DumpAttribute(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, const lldb_private::DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr, lldb_private::Stream &s, - dw_attr_t attr, dw_form_t form); + dw_attr_t attr, DWARFFormValue &form_value); // This one dumps the comp unit name, objfile name and die offset for this die // so the stream S. void DumpLocation(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu, @@ -231,10 +228,10 @@ class DWARFDebugInfoEntry { // we don't need to store our child pointer, if we have a child it will // be the next entry in the list... DWARFDebugInfoEntry *GetFirstChild() { - return (HasChildren() && !m_empty_children) ? this + 1 : NULL; + return HasChildren() ? this + 1 : NULL; } const DWARFDebugInfoEntry *GetFirstChild() const { - return (HasChildren() && !m_empty_children) ? this + 1 : NULL; + return HasChildren() ? this + 1 : NULL; } void GetDeclContextDIEs(DWARFUnit *cu, @@ -275,10 +272,6 @@ class DWARFDebugInfoEntry { void SetParentIndex(uint32_t idx) { m_parent_idx = idx; } - bool GetEmptyChildren() const { return m_empty_children; } - - void SetEmptyChildren(bool b) { m_empty_children = b; } - static void DumpDIECollection(lldb_private::Stream &strm, DWARFDebugInfoEntry::collection &die_collection); @@ -289,13 +282,13 @@ class DWARFDebugInfoEntry { uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. // If zero this die has no parent uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling. - m_empty_children : 1; // If a DIE says it had children, yet it just - // contained a NULL tag, this will be set. - uint32_t m_abbr_idx : DIE_ABBR_IDX_BITSIZE, - m_has_children : 1, // Set to 1 if this DIE has children - m_tag : 16; // A copy of the DW_TAG value so we don't - // have to go through the compile unit - // abbrev table + // If it is zero, then the DIE doesn't have children, or the + // DWARF claimed it had children but the DIE only contained + // a single NULL terminating child. + m_has_children : 1; + uint16_t m_abbr_idx; + uint16_t m_tag; // A copy of the DW_TAG value so we don't have to go through + // the compile unit abbrev table }; #endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_ diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp index 317ea4c22c66..1be4a3124b65 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugLine.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,6 +17,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/Timer.h" +#include "DWARFUnit.h" #include "LogChannelDWARF.h" #include "SymbolFileDWARF.h" @@ -41,7 +41,7 @@ void DWARFDebugLine::Parse(const DWARFDataExtractor &debug_line_data) { if (line_table_sp.get() == NULL) break; - if (ParseStatementTable(debug_line_data, &offset, line_table_sp.get())) { + if (ParseStatementTable(debug_line_data, &offset, line_table_sp.get(), nullptr)) { // Make sure we don't don't loop infinitely if (offset <= debug_line_offset) break; @@ -127,7 +127,7 @@ DWARFDebugLine::DumpStatementTable(Log *log, "--------\n", debug_line_offset); - if (ParseStatementTable(debug_line_data, &offset, DumpStateToFile, log)) + if (ParseStatementTable(debug_line_data, &offset, DumpStateToFile, log, nullptr)) return offset; else return debug_line_offset + 1; // Skip to next byte in .debug_line section @@ -366,17 +366,38 @@ void DWARFDebugLine::Parse(const DWARFDataExtractor &debug_line_data, void *userData) { lldb::offset_t offset = 0; if (debug_line_data.ValidOffset(offset)) { - if (!ParseStatementTable(debug_line_data, &offset, callback, userData)) + if (!ParseStatementTable(debug_line_data, &offset, callback, userData, nullptr)) ++offset; // Skip to next byte in .debug_line section } } +namespace { +struct EntryDescriptor { + dw_sleb128_t code; + dw_sleb128_t form; +}; + +static std::vector +ReadDescriptors(const DWARFDataExtractor &debug_line_data, + lldb::offset_t *offset_ptr) { + std::vector ret; + uint8_t n = debug_line_data.GetU8(offset_ptr); + for (uint8_t i = 0; i < n; ++i) { + EntryDescriptor ent; + ent.code = debug_line_data.GetULEB128(offset_ptr); + ent.form = debug_line_data.GetULEB128(offset_ptr); + ret.push_back(ent); + } + return ret; +} +} // namespace + //---------------------------------------------------------------------- // DWARFDebugLine::ParsePrologue //---------------------------------------------------------------------- bool DWARFDebugLine::ParsePrologue(const DWARFDataExtractor &debug_line_data, lldb::offset_t *offset_ptr, - Prologue *prologue) { + Prologue *prologue, DWARFUnit *dwarf_cu) { const lldb::offset_t prologue_offset = *offset_ptr; // DEBUG_PRINTF("0x%8.8x: ParsePrologue()\n", *offset_ptr); @@ -386,9 +407,14 @@ bool DWARFDebugLine::ParsePrologue(const DWARFDataExtractor &debug_line_data, const char *s; prologue->total_length = debug_line_data.GetDWARFInitialLength(offset_ptr); prologue->version = debug_line_data.GetU16(offset_ptr); - if (prologue->version < 2 || prologue->version > 4) + if (prologue->version < 2 || prologue->version > 5) return false; + if (prologue->version >= 5) { + prologue->address_size = debug_line_data.GetU8(offset_ptr); + prologue->segment_selector_size = debug_line_data.GetU8(offset_ptr); + } + prologue->prologue_length = debug_line_data.GetDWARFOffset(offset_ptr); const lldb::offset_t end_prologue_offset = prologue->prologue_length + *offset_ptr; @@ -410,25 +436,83 @@ bool DWARFDebugLine::ParsePrologue(const DWARFDataExtractor &debug_line_data, prologue->standard_opcode_lengths.push_back(op_len); } - while (*offset_ptr < end_prologue_offset) { - s = debug_line_data.GetCStr(offset_ptr); - if (s && s[0]) - prologue->include_directories.push_back(s); - else - break; - } + if (prologue->version >= 5) { + std::vector dirEntryFormatV = + ReadDescriptors(debug_line_data, offset_ptr); + uint8_t dirCount = debug_line_data.GetULEB128(offset_ptr); + for (int i = 0; i < dirCount; ++i) { + for (EntryDescriptor &ent : dirEntryFormatV) { + DWARFFormValue value(dwarf_cu, ent.form); + if (ent.code != DW_LNCT_path) { + if (!value.SkipValue(debug_line_data, offset_ptr)) + return false; + continue; + } - while (*offset_ptr < end_prologue_offset) { - const char *name = debug_line_data.GetCStr(offset_ptr); - if (name && name[0]) { - FileNameEntry fileEntry; - fileEntry.name = name; - fileEntry.dir_idx = debug_line_data.GetULEB128(offset_ptr); - fileEntry.mod_time = debug_line_data.GetULEB128(offset_ptr); - fileEntry.length = debug_line_data.GetULEB128(offset_ptr); - prologue->file_names.push_back(fileEntry); - } else - break; + if (!value.ExtractValue(debug_line_data, offset_ptr)) + return false; + prologue->include_directories.push_back(value.AsCString()); + } + } + + std::vector filesEntryFormatV = + ReadDescriptors(debug_line_data, offset_ptr); + llvm::DenseSet> seen; + uint8_t n = debug_line_data.GetULEB128(offset_ptr); + for (int i = 0; i < n; ++i) { + FileNameEntry entry; + for (EntryDescriptor &ent : filesEntryFormatV) { + DWARFFormValue value(dwarf_cu, ent.form); + if (!value.ExtractValue(debug_line_data, offset_ptr)) + return false; + + switch (ent.code) { + case DW_LNCT_path: + entry.name = value.AsCString(); + break; + case DW_LNCT_directory_index: + entry.dir_idx = value.Unsigned(); + break; + case DW_LNCT_timestamp: + entry.mod_time = value.Unsigned(); + break; + case DW_LNCT_size: + entry.length = value.Unsigned(); + break; + case DW_LNCT_MD5: + assert(value.Unsigned() == 16); + std::uninitialized_copy_n(value.BlockData(), 16, + entry.checksum.Bytes.begin()); + break; + default: + break; + } + } + + if (seen.insert(entry.checksum.words()).second) + prologue->file_names.push_back(entry); + } + } else { + while (*offset_ptr < end_prologue_offset) { + s = debug_line_data.GetCStr(offset_ptr); + if (s && s[0]) + prologue->include_directories.push_back(s); + else + break; + } + + while (*offset_ptr < end_prologue_offset) { + const char *name = debug_line_data.GetCStr(offset_ptr); + if (name && name[0]) { + FileNameEntry fileEntry; + fileEntry.name = name; + fileEntry.dir_idx = debug_line_data.GetULEB128(offset_ptr); + fileEntry.mod_time = debug_line_data.GetULEB128(offset_ptr); + fileEntry.length = debug_line_data.GetULEB128(offset_ptr); + prologue->file_names.push_back(fileEntry); + } else + break; + } } // XXX GNU as is broken for 64-Bit DWARF @@ -444,12 +528,11 @@ bool DWARFDebugLine::ParsePrologue(const DWARFDataExtractor &debug_line_data, bool DWARFDebugLine::ParseSupportFiles( const lldb::ModuleSP &module_sp, const DWARFDataExtractor &debug_line_data, - const lldb_private::FileSpec &cu_comp_dir, dw_offset_t stmt_list, - FileSpecList &support_files) { + dw_offset_t stmt_list, FileSpecList &support_files, DWARFUnit *dwarf_cu) { lldb::offset_t offset = stmt_list; Prologue prologue; - if (!ParsePrologue(debug_line_data, &offset, &prologue)) { + if (!ParsePrologue(debug_line_data, &offset, &prologue, dwarf_cu)) { Host::SystemLog(Host::eSystemLogError, "error: parsing line table prologue " "at 0x%8.8x (parsing ended around " "0x%8.8" PRIx64 "\n", @@ -461,9 +544,11 @@ bool DWARFDebugLine::ParseSupportFiles( std::string remapped_file; for (uint32_t file_idx = 1; - prologue.GetFile(file_idx, cu_comp_dir, file_spec); ++file_idx) { + prologue.GetFile(file_idx, dwarf_cu->GetCompilationDirectory(), + dwarf_cu->GetPathStyle(), file_spec); + ++file_idx) { if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file)) - file_spec.SetFile(remapped_file, false, FileSpec::Style::native); + file_spec.SetFile(remapped_file, FileSpec::Style::native); support_files.Append(file_spec); } return true; @@ -478,7 +563,7 @@ bool DWARFDebugLine::ParseSupportFiles( //---------------------------------------------------------------------- bool DWARFDebugLine::ParseStatementTable( const DWARFDataExtractor &debug_line_data, lldb::offset_t *offset_ptr, - DWARFDebugLine::State::Callback callback, void *userData) { + DWARFDebugLine::State::Callback callback, void *userData, DWARFUnit *dwarf_cu) { Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE)); Prologue::shared_ptr prologue(new Prologue()); @@ -489,7 +574,7 @@ bool DWARFDebugLine::ParseStatementTable( func_cat, "DWARFDebugLine::ParseStatementTable (.debug_line[0x%8.8x])", debug_line_offset); - if (!ParsePrologue(debug_line_data, offset_ptr, prologue.get())) { + if (!ParsePrologue(debug_line_data, offset_ptr, prologue.get(), dwarf_cu)) { if (log) log->Error("failed to parse DWARF line table prologue"); // Restore our offset and return false to indicate failure! @@ -775,9 +860,9 @@ static void ParseStatementTableCallback(dw_offset_t offset, //---------------------------------------------------------------------- bool DWARFDebugLine::ParseStatementTable( const DWARFDataExtractor &debug_line_data, lldb::offset_t *offset_ptr, - LineTable *line_table) { + LineTable *line_table, DWARFUnit *dwarf_cu) { return ParseStatementTable(debug_line_data, offset_ptr, - ParseStatementTableCallback, line_table); + ParseStatementTableCallback, line_table, dwarf_cu); } inline bool DWARFDebugLine::Prologue::IsValid() const { @@ -863,10 +948,12 @@ void DWARFDebugLine::Prologue::Dump(Log *log) { //} bool DWARFDebugLine::Prologue::GetFile(uint32_t file_idx, - const lldb_private::FileSpec &comp_dir, FileSpec &file) const { + const FileSpec &comp_dir, + FileSpec::Style style, + FileSpec &file) const { uint32_t idx = file_idx - 1; // File indexes are 1 based... if (idx < file_names.size()) { - file.SetFile(file_names[idx].name, false, FileSpec::Style::native); + file.SetFile(file_names[idx].name, style); if (file.IsRelative()) { if (file_names[idx].dir_idx > 0) { const uint32_t dir_idx = file_names[idx].dir_idx - 1; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h index 3ab15ac59028..6eda78d75e64 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h @@ -1,9 +1,8 @@ //===-- DWARFDebugLine.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,11 +13,15 @@ #include #include +#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-private.h" #include "DWARFDataExtractor.h" #include "DWARFDefines.h" +#include "llvm/Support/MD5.h" + +class DWARFUnit; class SymbolFileDWARF; //---------------------------------------------------------------------- @@ -36,6 +39,7 @@ class DWARFDebugLine { dw_sleb128_t dir_idx; dw_sleb128_t mod_time; dw_sleb128_t length; + llvm::MD5::MD5Result checksum; }; //------------------------------------------------------------------ @@ -55,6 +59,10 @@ class DWARFDebugLine { // total_length field itself). uint16_t version; // Version identifier for the statement information format. + + uint8_t address_size; + uint8_t segment_selector_size; + uint32_t prologue_length; // The number of bytes following the // prologue_length field to the beginning of the // first byte of the statement program itself. @@ -91,6 +99,7 @@ class DWARFDebugLine { file_names.clear(); } bool GetFile(uint32_t file_idx, const lldb_private::FileSpec &cu_comp_dir, + lldb_private::FileSpec::Style style, lldb_private::FileSpec &file) const; }; @@ -199,16 +208,17 @@ class DWARFDebugLine { static bool ParseSupportFiles(const lldb::ModuleSP &module_sp, const lldb_private::DWARFDataExtractor &debug_line_data, - const lldb_private::FileSpec &cu_comp_dir, dw_offset_t stmt_list, - lldb_private::FileSpecList &support_files); + lldb_private::FileSpecList &support_files, + DWARFUnit *dwarf_cu); static bool ParsePrologue(const lldb_private::DWARFDataExtractor &debug_line_data, - lldb::offset_t *offset_ptr, Prologue *prologue); + lldb::offset_t *offset_ptr, Prologue *prologue, + DWARFUnit *dwarf_cu = nullptr); static bool ParseStatementTable(const lldb_private::DWARFDataExtractor &debug_line_data, lldb::offset_t *offset_ptr, State::Callback callback, - void *userData); + void *userData, DWARFUnit *dwarf_cu); static dw_offset_t DumpStatementTable(lldb_private::Log *log, const lldb_private::DWARFDataExtractor &debug_line_data, @@ -219,7 +229,8 @@ class DWARFDebugLine { const dw_offset_t line_offset, uint32_t flags); static bool ParseStatementTable(const lldb_private::DWARFDataExtractor &debug_line_data, - lldb::offset_t *offset_ptr, LineTable *line_table); + lldb::offset_t *offset_ptr, LineTable *line_table, + DWARFUnit *dwarf_cu); static void Parse(const lldb_private::DWARFDataExtractor &debug_line_data, DWARFDebugLine::State::Callback callback, void *userData); // static void AppendLineTableData(const DWARFDebugLine::Prologue* prologue, diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp index 19074b8865ff..45e070bee43d 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugMacinfo.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h index ec9dc85669c4..48e57b27f693 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h @@ -1,9 +1,8 @@ //===-- DWARFDebugMacinfo.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp index f078fbd44f2f..ebd11ea562d3 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugMacinfoEntry.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h index 96829c2fc09b..2a6072880d50 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h @@ -1,9 +1,8 @@ //===-- DWARFDebugMacinfoEntry.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp index 1c31d1c42598..4238be7ec1c3 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp @@ -1,9 +1,8 @@ //===-- DWARFDebugMacro.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,7 +24,7 @@ DWARFDebugMacroHeader::ParseHeader(const DWARFDataExtractor &debug_macro_data, header.m_version = debug_macro_data.GetU16(offset); uint8_t flags = debug_macro_data.GetU8(offset); - header.m_offset_is_64_bit = flags & OFFSET_SIZE_MASK ? true : false; + header.m_offset_is_64_bit = (flags & OFFSET_SIZE_MASK) != 0; if (flags & DEBUG_LINE_OFFSET_MASK) { if (header.m_offset_is_64_bit) diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h index 021b434cd457..c3a93a9f4d14 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h @@ -1,10 +1,9 @@ //===-- DWARFDebugMacro.h ----------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp index 89e27efb3cc2..9d54500fba23 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -1,13 +1,13 @@ //===-- DWARFDebugRanges.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "DWARFDebugRanges.h" +#include "DWARFUnit.h" #include "SymbolFileDWARF.h" #include "lldb/Utility/Stream.h" #include @@ -29,8 +29,6 @@ static dw_addr_t GetBaseAddressMarker(uint32_t addr_size) { DWARFDebugRanges::DWARFDebugRanges() : m_range_map() {} -DWARFDebugRanges::~DWARFDebugRanges() {} - void DWARFDebugRanges::Extract(SymbolFileDWARF *dwarf2Data) { DWARFRangeList range_list; lldb::offset_t offset = 0; @@ -112,14 +110,185 @@ void DWARFDebugRanges::Dump(Stream &s, } } -bool DWARFDebugRanges::FindRanges(dw_addr_t debug_ranges_base, +bool DWARFDebugRanges::FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, DWARFRangeList &range_list) const { - dw_addr_t debug_ranges_address = debug_ranges_base + debug_ranges_offset; + dw_addr_t debug_ranges_address = cu->GetRangesBase() + debug_ranges_offset; range_map_const_iterator pos = m_range_map.find(debug_ranges_address); if (pos != m_range_map.end()) { range_list = pos->second; + + // All DW_AT_ranges are relative to the base address of the compile + // unit. We add the compile unit base address to make sure all the + // addresses are properly fixed up. + range_list.Slide(cu->GetBaseAddress()); return true; } return false; } + +uint64_t DWARFDebugRanges::GetOffset(size_t Index) const { + lldbassert(false && "DW_FORM_rnglistx is not present before DWARF5"); + return 0; +} + +bool DWARFDebugRngLists::ExtractRangeList( + const DWARFDataExtractor &data, uint8_t addrSize, + lldb::offset_t *offset_ptr, std::vector &rangeList) { + rangeList.clear(); + + bool error = false; + while (!error) { + switch (data.GetU8(offset_ptr)) { + case DW_RLE_end_of_list: + return true; + + case DW_RLE_start_length: { + dw_addr_t begin = data.GetMaxU64(offset_ptr, addrSize); + dw_addr_t len = data.GetULEB128(offset_ptr); + rangeList.push_back({DW_RLE_start_length, begin, len}); + break; + } + + case DW_RLE_start_end: { + dw_addr_t begin = data.GetMaxU64(offset_ptr, addrSize); + dw_addr_t end = data.GetMaxU64(offset_ptr, addrSize); + rangeList.push_back({DW_RLE_start_end, begin, end}); + break; + } + + case DW_RLE_base_address: { + dw_addr_t base = data.GetMaxU64(offset_ptr, addrSize); + rangeList.push_back({DW_RLE_base_address, base, 0}); + break; + } + + case DW_RLE_offset_pair: { + dw_addr_t begin = data.GetULEB128(offset_ptr); + dw_addr_t end = data.GetULEB128(offset_ptr); + rangeList.push_back({DW_RLE_offset_pair, begin, end}); + break; + } + + case DW_RLE_base_addressx: { + dw_addr_t base = data.GetULEB128(offset_ptr); + rangeList.push_back({DW_RLE_base_addressx, base, 0}); + break; + } + + case DW_RLE_startx_endx: { + dw_addr_t start = data.GetULEB128(offset_ptr); + dw_addr_t end = data.GetULEB128(offset_ptr); + rangeList.push_back({DW_RLE_startx_endx, start, end}); + break; + } + + case DW_RLE_startx_length: { + dw_addr_t start = data.GetULEB128(offset_ptr); + dw_addr_t length = data.GetULEB128(offset_ptr); + rangeList.push_back({DW_RLE_startx_length, start, length}); + break; + } + + default: + lldbassert(0 && "unknown range list entry encoding"); + error = true; + } + } + + return false; +} + +static uint64_t ReadAddressFromDebugAddrSection(const DWARFUnit *cu, + uint32_t index) { + uint32_t index_size = cu->GetAddressByteSize(); + dw_offset_t addr_base = cu->GetAddrBase(); + lldb::offset_t offset = addr_base + index * index_size; + return cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset, + index_size); +} + +bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu, + dw_offset_t debug_ranges_offset, + DWARFRangeList &range_list) const { + range_list.Clear(); + dw_addr_t debug_ranges_address = cu->GetRangesBase() + debug_ranges_offset; + auto pos = m_range_map.find(debug_ranges_address); + if (pos != m_range_map.end()) { + dw_addr_t BaseAddr = cu->GetBaseAddress(); + for (const RngListEntry &E : pos->second) { + switch (E.encoding) { + case DW_RLE_start_length: + range_list.Append(DWARFRangeList::Entry(E.value0, E.value1)); + break; + case DW_RLE_base_address: + BaseAddr = E.value0; + break; + case DW_RLE_start_end: + range_list.Append(DWARFRangeList::Entry(E.value0, E.value1 - E.value0)); + break; + case DW_RLE_offset_pair: + range_list.Append( + DWARFRangeList::Entry(BaseAddr + E.value0, E.value1 - E.value0)); + break; + case DW_RLE_base_addressx: { + BaseAddr = ReadAddressFromDebugAddrSection(cu, E.value0); + break; + } + case DW_RLE_startx_endx: { + dw_addr_t start = ReadAddressFromDebugAddrSection(cu, E.value0); + dw_addr_t end = ReadAddressFromDebugAddrSection(cu, E.value1); + range_list.Append(DWARFRangeList::Entry(start, end - start)); + break; + } + case DW_RLE_startx_length: { + dw_addr_t start = ReadAddressFromDebugAddrSection(cu, E.value0); + range_list.Append(DWARFRangeList::Entry(start, E.value1)); + break; + } + default: + llvm_unreachable("unexpected encoding"); + } + } + return true; + } + return false; +} + +void DWARFDebugRngLists::Extract(SymbolFileDWARF *dwarf2Data) { + const DWARFDataExtractor &data = dwarf2Data->get_debug_rnglists_data(); + lldb::offset_t offset = 0; + + uint64_t length = data.GetU32(&offset); + bool isDwarf64 = (length == 0xffffffff); + if (isDwarf64) + length = data.GetU64(&offset); + lldb::offset_t end = offset + length; + + // Check version. + if (data.GetU16(&offset) < 5) + return; + + uint8_t addrSize = data.GetU8(&offset); + + // We do not support non-zero segment selector size. + if (data.GetU8(&offset) != 0) { + lldbassert(0 && "not implemented"); + return; + } + + uint32_t offsetsAmount = data.GetU32(&offset); + for (uint32_t i = 0; i < offsetsAmount; ++i) + Offsets.push_back(data.GetMaxU64(&offset, isDwarf64 ? 8 : 4)); + + lldb::offset_t listOffset = offset; + std::vector rangeList; + while (offset < end && ExtractRangeList(data, addrSize, &offset, rangeList)) { + m_range_map[listOffset] = rangeList; + listOffset = offset; + } +} + +uint64_t DWARFDebugRngLists::GetOffset(size_t Index) const { + return Offsets[Index]; +} diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h index f514359e00a4..26fd6c3c79f5 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h @@ -1,9 +1,8 @@ //===-- DWARFDebugRanges.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,17 +14,28 @@ #include -class DWARFDebugRanges { +class DWARFDebugRangesBase { +public: + virtual ~DWARFDebugRangesBase(){}; + + virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0; + virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, + DWARFRangeList &range_list) const = 0; + virtual uint64_t GetOffset(size_t Index) const = 0; +}; + +class DWARFDebugRanges final : public DWARFDebugRangesBase { public: DWARFDebugRanges(); - ~DWARFDebugRanges(); - void Extract(SymbolFileDWARF *dwarf2Data); + + void Extract(SymbolFileDWARF *dwarf2Data) override; + bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, + DWARFRangeList &range_list) const override; + uint64_t GetOffset(size_t Index) const override; + static void Dump(lldb_private::Stream &s, const lldb_private::DWARFDataExtractor &debug_ranges_data, lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr); - bool FindRanges(dw_addr_t debug_ranges_base, - dw_offset_t debug_ranges_offset, - DWARFRangeList &range_list) const; protected: bool Extract(SymbolFileDWARF *dwarf2Data, lldb::offset_t *offset_ptr, @@ -37,4 +47,27 @@ class DWARFDebugRanges { range_map m_range_map; }; +// DWARF v5 .debug_rnglists section. +class DWARFDebugRngLists final : public DWARFDebugRangesBase { + struct RngListEntry { + uint8_t encoding; + uint64_t value0; + uint64_t value1; + }; + +public: + void Extract(SymbolFileDWARF *dwarf2Data) override; + bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, + DWARFRangeList &range_list) const override; + uint64_t GetOffset(size_t Index) const override; + +protected: + bool ExtractRangeList(const lldb_private::DWARFDataExtractor &data, + uint8_t addrSize, lldb::offset_t *offset_ptr, + std::vector &list); + + std::vector Offsets; + std::map> m_range_map; +}; + #endif // SymbolFileDWARF_DWARFDebugRanges_h_ diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp index dbaf0b0ed127..455cb01e71a4 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp @@ -1,9 +1,8 @@ //===-- DWARFDeclContext.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h index 1f3c59768fdf..240829edd4f4 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h @@ -1,22 +1,17 @@ //===-- DWARFDeclContext.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARF_DWARFDeclContext_h_ #define SymbolFileDWARF_DWARFDeclContext_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "lldb/Utility/ConstString.h" -// Project includes #include "DWARFDefines.h" //---------------------------------------------------------------------- diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp index 1d927ba3bca3..27e4639c6952 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp @@ -1,9 +1,8 @@ //===-- DWARFDefines.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -504,9 +503,9 @@ const char *DW_MACINFO_value_to_name(uint32_t val) { return llvmstr.data(); } -const char *DW_CFA_value_to_name(uint32_t val) { +const char *DW_CFA_value_to_name(uint32_t val, llvm::Triple::ArchType Arch) { static char invalid[100]; - llvm::StringRef llvmstr = llvm::dwarf::CallFrameString(val); + llvm::StringRef llvmstr = llvm::dwarf::CallFrameString(val, Arch); if (llvmstr.empty()) { snprintf(invalid, sizeof(invalid), "Unknown DW_CFA constant: 0x%x", val); return invalid; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDefines.h b/source/Plugins/SymbolFile/DWARF/DWARFDefines.h index 926f83b3564a..101e9ad5deb7 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDefines.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDefines.h @@ -1,9 +1,8 @@ //===-- DWARFDefines.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -64,7 +63,7 @@ const char *DW_LNE_value_to_name(uint32_t val); const char *DW_MACINFO_value_to_name(uint32_t val); -const char *DW_CFA_value_to_name(uint32_t val); +const char *DW_CFA_value_to_name(uint32_t val, llvm::Triple::ArchType Arch); const char *DW_GNU_EH_PE_value_to_name(uint32_t val); diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 543d2d60e487..bc0acfbe155a 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -1,9 +1,8 @@ //===-- DWARFFormValue.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -154,6 +153,9 @@ DWARFFormValue::GetFixedFormSizesForAddressSize(uint8_t addr_size, DWARFFormValue::DWARFFormValue() : m_cu(NULL), m_form(0), m_value() {} +DWARFFormValue::DWARFFormValue(const DWARFUnit *cu) + : m_cu(cu), m_form(0), m_value() {} + DWARFFormValue::DWARFFormValue(const DWARFUnit *cu, dw_form_t form) : m_cu(cu), m_form(form), m_value() {} @@ -165,6 +167,9 @@ void DWARFFormValue::Clear() { bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr) { + if (m_form == DW_FORM_implicit_const) + return true; + bool indirect = false; bool is_block = false; m_value.data = NULL; @@ -176,8 +181,12 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, switch (m_form) { case DW_FORM_addr: assert(m_cu); - m_value.value.uval = data.GetMaxU64( - offset_ptr, DWARFUnit::GetAddressByteSize(m_cu)); + m_value.value.uval = + data.GetMaxU64(offset_ptr, DWARFUnit::GetAddressByteSize(m_cu)); + break; + case DW_FORM_block1: + m_value.value.uval = data.GetU8(offset_ptr); + is_block = true; break; case DW_FORM_block2: m_value.value.uval = data.GetU16(offset_ptr); @@ -187,94 +196,82 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data, m_value.value.uval = data.GetU32(offset_ptr); is_block = true; break; - case DW_FORM_data2: - m_value.value.uval = data.GetU16(offset_ptr); - break; - case DW_FORM_data4: - m_value.value.uval = data.GetU32(offset_ptr); - break; - case DW_FORM_data8: - m_value.value.uval = data.GetU64(offset_ptr); - break; - case DW_FORM_string: - m_value.value.cstr = data.GetCStr(offset_ptr); + case DW_FORM_data16: + m_value.value.uval = 16; + is_block = true; break; case DW_FORM_exprloc: case DW_FORM_block: m_value.value.uval = data.GetULEB128(offset_ptr); is_block = true; break; - case DW_FORM_block1: - m_value.value.uval = data.GetU8(offset_ptr); - is_block = true; - break; - case DW_FORM_data1: - m_value.value.uval = data.GetU8(offset_ptr); - break; - case DW_FORM_flag: - m_value.value.uval = data.GetU8(offset_ptr); + case DW_FORM_string: + m_value.value.cstr = data.GetCStr(offset_ptr); break; case DW_FORM_sdata: m_value.value.sval = data.GetSLEB128(offset_ptr); break; case DW_FORM_strp: + case DW_FORM_line_strp: + case DW_FORM_sec_offset: assert(m_cu); m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4); break; - // case DW_FORM_APPLE_db_str: - case DW_FORM_udata: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; - case DW_FORM_ref_addr: - assert(m_cu); - ref_addr_size = 4; - if (m_cu->GetVersion() <= 2) - ref_addr_size = m_cu->GetAddressByteSize(); - else - ref_addr_size = m_cu->IsDWARF64() ? 8 : 4; - m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); - break; + case DW_FORM_addrx1: + case DW_FORM_strx1: case DW_FORM_ref1: + case DW_FORM_data1: + case DW_FORM_flag: m_value.value.uval = data.GetU8(offset_ptr); break; + case DW_FORM_addrx2: + case DW_FORM_strx2: case DW_FORM_ref2: + case DW_FORM_data2: m_value.value.uval = data.GetU16(offset_ptr); break; + case DW_FORM_addrx3: + case DW_FORM_strx3: + m_value.value.uval = data.GetMaxU64(offset_ptr, 3); + break; + case DW_FORM_addrx4: + case DW_FORM_strx4: case DW_FORM_ref4: + case DW_FORM_data4: m_value.value.uval = data.GetU32(offset_ptr); break; + case DW_FORM_data8: case DW_FORM_ref8: + case DW_FORM_ref_sig8: m_value.value.uval = data.GetU64(offset_ptr); break; + case DW_FORM_addrx: + case DW_FORM_rnglistx: + case DW_FORM_strx: + case DW_FORM_udata: case DW_FORM_ref_udata: + case DW_FORM_GNU_str_index: + case DW_FORM_GNU_addr_index: m_value.value.uval = data.GetULEB128(offset_ptr); break; + case DW_FORM_ref_addr: + assert(m_cu); + if (m_cu->GetVersion() <= 2) + ref_addr_size = m_cu->GetAddressByteSize(); + else + ref_addr_size = m_cu->IsDWARF64() ? 8 : 4; + m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size); + break; case DW_FORM_indirect: m_form = data.GetULEB128(offset_ptr); indirect = true; break; - - case DW_FORM_sec_offset: - assert(m_cu); - m_value.value.uval = - data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4); - break; case DW_FORM_flag_present: m_value.value.uval = 1; break; - case DW_FORM_ref_sig8: - m_value.value.uval = data.GetU64(offset_ptr); - break; - case DW_FORM_GNU_str_index: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; - case DW_FORM_GNU_addr_index: - m_value.value.uval = data.GetULEB128(offset_ptr); - break; default: return false; - break; } } while (indirect); @@ -346,49 +343,65 @@ bool DWARFFormValue::SkipValue(dw_form_t form, // 0 bytes values (implied from DW_FORM) case DW_FORM_flag_present: + case DW_FORM_implicit_const: return true; - // 1 byte values - case DW_FORM_data1: - case DW_FORM_flag: - case DW_FORM_ref1: - *offset_ptr += 1; - return true; + // 1 byte values + case DW_FORM_addrx1: + case DW_FORM_data1: + case DW_FORM_flag: + case DW_FORM_ref1: + case DW_FORM_strx1: + *offset_ptr += 1; + return true; - // 2 byte values - case DW_FORM_data2: - case DW_FORM_ref2: - *offset_ptr += 2; - return true; + // 2 byte values + case DW_FORM_addrx2: + case DW_FORM_data2: + case DW_FORM_ref2: + case DW_FORM_strx2: + *offset_ptr += 2; + return true; - // 32 bit for DWARF 32, 64 for DWARF 64 - case DW_FORM_sec_offset: - case DW_FORM_strp: - assert(cu); - *offset_ptr += (cu->IsDWARF64() ? 8 : 4); - return true; + // 3 byte values + case DW_FORM_addrx3: + case DW_FORM_strx3: + *offset_ptr += 3; + return true; - // 4 byte values - case DW_FORM_data4: - case DW_FORM_ref4: - *offset_ptr += 4; - return true; + // 32 bit for DWARF 32, 64 for DWARF 64 + case DW_FORM_sec_offset: + case DW_FORM_strp: + assert(cu); + *offset_ptr += (cu->IsDWARF64() ? 8 : 4); + return true; - // 8 byte values - case DW_FORM_data8: - case DW_FORM_ref8: - case DW_FORM_ref_sig8: - *offset_ptr += 8; - return true; + // 4 byte values + case DW_FORM_addrx4: + case DW_FORM_data4: + case DW_FORM_ref4: + case DW_FORM_strx4: + *offset_ptr += 4; + return true; - // signed or unsigned LEB 128 values - case DW_FORM_sdata: - case DW_FORM_udata: - case DW_FORM_ref_udata: - case DW_FORM_GNU_addr_index: - case DW_FORM_GNU_str_index: - debug_info_data.Skip_LEB128(offset_ptr); - return true; + // 8 byte values + case DW_FORM_data8: + case DW_FORM_ref8: + case DW_FORM_ref_sig8: + *offset_ptr += 8; + return true; + + // signed or unsigned LEB 128 values + case DW_FORM_addrx: + case DW_FORM_rnglistx: + case DW_FORM_sdata: + case DW_FORM_udata: + case DW_FORM_ref_udata: + case DW_FORM_GNU_addr_index: + case DW_FORM_GNU_str_index: + case DW_FORM_strx: + debug_info_data.Skip_LEB128(offset_ptr); + return true; case DW_FORM_indirect: { dw_form_t indirect_form = debug_info_data.GetULEB128(offset_ptr); @@ -546,6 +559,26 @@ const char *DWARFFormValue::AsCString() const { index_size); return symbol_file->get_debug_str_data().PeekCStr(str_offset); } + + if (m_form == DW_FORM_strx || m_form == DW_FORM_strx1 || + m_form == DW_FORM_strx2 || m_form == DW_FORM_strx3 || + m_form == DW_FORM_strx4) { + + // The same code as above. + if (!symbol_file) + return nullptr; + + uint32_t indexSize = m_cu->IsDWARF64() ? 8 : 4; + lldb::offset_t offset = + m_cu->GetStrOffsetsBase() + m_value.value.uval * indexSize; + dw_offset_t strOffset = + symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset, indexSize); + return symbol_file->get_debug_str_data().PeekCStr(strOffset); + } + + if (m_form == DW_FORM_line_strp) + return symbol_file->get_debug_line_str_data().PeekCStr(m_value.value.uval); + return nullptr; } @@ -556,7 +589,9 @@ dw_addr_t DWARFFormValue::Address() const { return Unsigned(); assert(m_cu); - assert(m_form == DW_FORM_GNU_addr_index); + assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx || + m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 || + m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4); if (!symbol_file) return 0; @@ -733,6 +768,8 @@ int DWARFFormValue::Compare(const DWARFFormValue &a_value, bool DWARFFormValue::FormIsSupported(dw_form_t form) { switch (form) { case DW_FORM_addr: + case DW_FORM_addrx: + case DW_FORM_rnglistx: case DW_FORM_block2: case DW_FORM_block4: case DW_FORM_data2: @@ -745,6 +782,11 @@ bool DWARFFormValue::FormIsSupported(dw_form_t form) { case DW_FORM_flag: case DW_FORM_sdata: case DW_FORM_strp: + case DW_FORM_strx: + case DW_FORM_strx1: + case DW_FORM_strx2: + case DW_FORM_strx3: + case DW_FORM_strx4: case DW_FORM_udata: case DW_FORM_ref_addr: case DW_FORM_ref1: @@ -759,6 +801,7 @@ bool DWARFFormValue::FormIsSupported(dw_form_t form) { case DW_FORM_ref_sig8: case DW_FORM_GNU_str_index: case DW_FORM_GNU_addr_index: + case DW_FORM_implicit_const: return true; default: break; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h index ef1a693b37c9..f9d86b449f89 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -1,9 +1,8 @@ //===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,9 +10,10 @@ #define SymbolFileDWARF_DWARFFormValue_h_ #include "DWARFDataExtractor.h" -#include // for NULL +#include class DWARFUnit; +class SymbolFileDWARF; class DWARFFormValue { public: @@ -55,12 +55,17 @@ class DWARFFormValue { }; DWARFFormValue(); + DWARFFormValue(const DWARFUnit *cu); DWARFFormValue(const DWARFUnit *cu, dw_form_t form); const DWARFUnit *GetCompileUnit() const { return m_cu; } void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; } dw_form_t Form() const { return m_form; } + dw_form_t& FormRef() { return m_form; } void SetForm(dw_form_t form) { m_form = form; } const ValueType &Value() const { return m_value; } + ValueType &ValueRef() { return m_value; } + void SetValue(const ValueType &val) { m_value = val; } + void Dump(lldb_private::Stream &s) const; bool ExtractValue(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr); diff --git a/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp index 4577f0557a1d..b7f7329fa98b 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -1,9 +1,8 @@ //===-- DWARFIndex.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/source/Plugins/SymbolFile/DWARF/DWARFIndex.h index 77af67b8e60f..28feab510348 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -1,9 +1,8 @@ //===-- DWARFIndex.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index f44b2bb97b2b..6f4d6625822b 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -1,9 +1,8 @@ //===-- DWARFUnit.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -191,13 +190,6 @@ void DWARFUnit::ExtractDIEsRWLocked() { IsDWARF64()); while (offset < next_cu_offset && die.FastExtract(data, this, fixed_form_sizes, &offset)) { - // if (log) - // log->Printf("0x%8.8x: %*.*s%s%s", - // die.GetOffset(), - // depth * 2, depth * 2, "", - // DW_TAG_value_to_name (die.Tag()), - // die.HasChildren() ? " *" : ""); - const bool null_die = die.IsNULL(); if (depth == 0) { assert(m_die_array.empty() && "Compile unit DIE already added"); @@ -223,7 +215,7 @@ void DWARFUnit::ExtractDIEsRWLocked() { // the list (saves up to 25% in C++ code), we need a way to let the // DIE know that it actually doesn't have children. if (!m_die_array.empty()) - m_die_array.back().SetEmptyChildren(true); + m_die_array.back().SetHasChildren(false); } } else { die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]); @@ -244,9 +236,6 @@ void DWARFUnit::ExtractDIEsRWLocked() { if (depth > 0) --depth; - if (depth == 0) - break; // We are done with this compile unit! - prev_die_had_children = false; } else { die_index_stack.back() = m_die_array.size() - 1; @@ -258,10 +247,17 @@ void DWARFUnit::ExtractDIEsRWLocked() { } prev_die_had_children = die_has_children; } + + if (depth == 0) + break; // We are done with this compile unit! } if (!m_die_array.empty()) { - lldbassert(!m_first_die || m_first_die == m_die_array.front()); + if (m_first_die) { + // Only needed for the assertion. + m_first_die.SetHasChildren(m_die_array.front().HasChildren()); + lldbassert(m_first_die == m_die_array.front()); + } m_first_die = m_die_array.front(); } @@ -301,8 +297,46 @@ void DWARFUnit::ExtractDIEsEndCheck(lldb::offset_t offset) const { } } +// This is used when a split dwarf is enabled. +// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute +// that points to the first string offset of the CU contribution to the +// .debug_str_offsets. At the same time, the corresponding split debug unit also +// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and +// for that case, we should find the offset (skip the section header). +static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) { + lldb::offset_t baseOffset = 0; + + const DWARFDataExtractor &strOffsets = + dwo_cu->GetSymbolFileDWARF()->get_debug_str_offsets_data(); + uint64_t length = strOffsets.GetU32(&baseOffset); + if (length == 0xffffffff) + length = strOffsets.GetU64(&baseOffset); + + // Check version. + if (strOffsets.GetU16(&baseOffset) < 5) + return; + + // Skip padding. + baseOffset += 2; + + dwo_cu->SetStrOffsetsBase(baseOffset); +} + // m_die_array_mutex must be already held as read/write. void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) { + dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned( + m_dwarf, this, DW_AT_addr_base, LLDB_INVALID_ADDRESS); + if (addr_base != LLDB_INVALID_ADDRESS) + SetAddrBase(addr_base); + + dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned( + m_dwarf, this, DW_AT_rnglists_base, LLDB_INVALID_ADDRESS); + if (ranges_base != LLDB_INVALID_ADDRESS) + SetRangesBase(ranges_base); + + SetStrOffsetsBase(cu_die.GetAttributeValueAsUnsigned( + m_dwarf, this, DW_AT_str_offsets_base, 0)); + uint64_t base_addr = cu_die.GetAttributeValueAsAddress( m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (base_addr == LLDB_INVALID_ADDRESS) @@ -333,11 +367,25 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) { m_dwo_symbol_file = std::move(dwo_symbol_file); - dw_addr_t addr_base = - cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_addr_base, 0); - dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned( - m_dwarf, this, DW_AT_GNU_ranges_base, 0); - dwo_cu->SetAddrBase(addr_base, ranges_base, m_offset); + // Here for DWO CU we want to use the address base set in the skeleton unit + // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base + // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_* + // attributes which were applicable to the DWO units. The corresponding + // DW_AT_* attributes standardized in DWARF v5 are also applicable to the main + // unit in contrast. + if (addr_base == LLDB_INVALID_ADDRESS) + addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, + DW_AT_GNU_addr_base, 0); + dwo_cu->SetAddrBase(addr_base); + + if (ranges_base == LLDB_INVALID_ADDRESS) + ranges_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, + DW_AT_GNU_ranges_base, 0); + dwo_cu->SetRangesBase(ranges_base); + + dwo_cu->SetBaseObjOffset(m_offset); + + SetDwoStrOffsetsBase(dwo_cu); } DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) { @@ -395,14 +443,20 @@ dw_offset_t DWARFUnit::GetAbbrevOffset() const { return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET; } -void DWARFUnit::SetAddrBase(dw_addr_t addr_base, - dw_addr_t ranges_base, - dw_offset_t base_obj_offset) { - m_addr_base = addr_base; +void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; } + +void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) { m_ranges_base = ranges_base; +} + +void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) { m_base_obj_offset = base_obj_offset; } +void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) { + m_str_offsets_base = str_offsets_base; +} + // It may be called only with m_die_array_mutex held R/W. void DWARFUnit::ClearDIEsRWLocked() { m_die_array.clear(); @@ -586,9 +640,7 @@ void DWARFUnit::SetUserData(void *d) { } bool DWARFUnit::Supports_DW_AT_APPLE_objc_complete_type() { - if (GetProducer() == eProducerLLVMGCC) - return false; - return true; + return GetProducer() != eProducerLLVMGCC; } bool DWARFUnit::DW_AT_decl_file_attributes_are_invalid() { @@ -600,11 +652,8 @@ bool DWARFUnit::DW_AT_decl_file_attributes_are_invalid() { bool DWARFUnit::Supports_unnamed_objc_bitfields() { if (GetProducer() == eProducerClang) { const uint32_t major_version = GetProducerVersionMajor(); - if (major_version > 425 || - (major_version == 425 && GetProducerVersionUpdate() >= 13)) - return true; - else - return false; + return major_version > 425 || + (major_version == 425 && GetProducerVersionUpdate() >= 13); } return true; // Assume all other compilers didn't have incorrect ObjC bitfield // info @@ -716,6 +765,80 @@ bool DWARFUnit::GetIsOptimized() { return m_is_optimized == eLazyBoolYes; } +FileSpec::Style DWARFUnit::GetPathStyle() { + if (!m_comp_dir) + ComputeCompDirAndGuessPathStyle(); + return m_comp_dir->GetPathStyle(); +} + +const FileSpec &DWARFUnit::GetCompilationDirectory() { + if (!m_comp_dir) + ComputeCompDirAndGuessPathStyle(); + return *m_comp_dir; +} + +// DWARF2/3 suggests the form hostname:pathname for compilation directory. +// Remove the host part if present. +static llvm::StringRef +removeHostnameFromPathname(llvm::StringRef path_from_dwarf) { + llvm::StringRef host, path; + std::tie(host, path) = path_from_dwarf.split(':'); + + if (host.contains('/')) + return path_from_dwarf; + + // check whether we have a windows path, and so the first character is a + // drive-letter not a hostname. + if (host.size() == 1 && llvm::isAlpha(host[0]) && path.startswith("\\")) + return path_from_dwarf; + + return path; +} + +static FileSpec resolveCompDir(const FileSpec &path) { + bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex( + 0, path, /*full*/ true) != UINT32_MAX; + + if (!is_symlink) + return path; + + namespace fs = llvm::sys::fs; + if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file) + return path; + + FileSpec resolved_symlink; + const auto error = FileSystem::Instance().Readlink(path, resolved_symlink); + if (error.Success()) + return resolved_symlink; + + return path; +} + +void DWARFUnit::ComputeCompDirAndGuessPathStyle() { + m_comp_dir = FileSpec(); + const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly(); + if (!die) + return; + + auto guess = [](llvm::StringRef str) { + if (str.startswith("/")) + return FileSpec::Style::posix; + if (str.size() > 3 && llvm::isAlpha(str[0]) && str.substr(1, 2) == ":\\") + return FileSpec::Style::windows; + return FileSpec::Style::native; + }; + llvm::StringRef comp_dir = removeHostnameFromPathname( + die->GetAttributeValueAsString(m_dwarf, this, DW_AT_comp_dir, NULL)); + if (!comp_dir.empty()) { + m_comp_dir = resolveCompDir(FileSpec(comp_dir, guess(comp_dir))); + } else { + // Try to detect the style based on the DW_AT_name attribute, but just store + // the detected style in the m_comp_dir field. + m_comp_dir = FileSpec("", guess(die->GetAttributeValueAsString( + m_dwarf, this, DW_AT_name, NULL))); + } +} + SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() const { return m_dwo_symbol_file.get(); } diff --git a/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index c9e48c538bc1..be820e9e20d8 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -1,9 +1,8 @@ //===-- DWARFUnit.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -33,8 +32,6 @@ enum DWARFProducer { }; class DWARFUnit { - friend class DWARFCompileUnit; - using die_iterator_range = llvm::iterator_range; @@ -113,8 +110,11 @@ class DWARFUnit { dw_addr_t GetBaseAddress() const { return m_base_addr; } dw_addr_t GetAddrBase() const { return m_addr_base; } dw_addr_t GetRangesBase() const { return m_ranges_base; } - void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base, - dw_offset_t base_obj_offset); + dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; } + void SetAddrBase(dw_addr_t addr_base); + void SetRangesBase(dw_addr_t ranges_base); + void SetBaseObjOffset(dw_offset_t base_obj_offset); + void SetStrOffsetsBase(dw_offset_t str_offsets_base); void BuildAddressRangeTable(SymbolFileDWARF *dwarf, DWARFDebugAranges *debug_aranges); @@ -168,6 +168,9 @@ class DWARFUnit { bool GetIsOptimized(); + const lldb_private::FileSpec &GetCompilationDirectory(); + lldb_private::FileSpec::Style GetPathStyle(); + SymbolFileDWARFDwo *GetDwoSymbolFile() const; dw_offset_t GetBaseObjOffset() const; @@ -204,6 +207,8 @@ class DWARFUnit { dw_offset_t m_length = 0; uint16_t m_version = 0; uint8_t m_addr_size = 0; + uint8_t m_unit_type = 0; + uint64_t m_dwo_id = 0; DWARFProducer m_producer = eProducerInvalid; uint32_t m_producer_version_major = 0; uint32_t m_producer_version_minor = 0; @@ -211,12 +216,13 @@ class DWARFUnit { lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown; bool m_is_dwarf64 = false; lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate; + llvm::Optional m_comp_dir; dw_addr_t m_addr_base = 0; // Value of DW_AT_addr_base dw_addr_t m_ranges_base = 0; // Value of DW_AT_ranges_base // If this is a dwo compile unit this is the offset of the base compile unit // in the main object file dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET; - + dw_offset_t m_str_offsets_base = 0; // Value of DW_AT_str_offsets_base. // Offset of the initial length field. dw_offset_t m_offset; @@ -246,6 +252,8 @@ class DWARFUnit { void AddUnitDIE(const DWARFDebugInfoEntry &cu_die); void ExtractDIEsEndCheck(lldb::offset_t offset) const; + void ComputeCompDirAndGuessPathStyle(); + DISALLOW_COPY_AND_ASSIGN(DWARFUnit); }; diff --git a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 614ff470d161..4b5c07f86896 100644 --- a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -1,9 +1,8 @@ //===-- DebugNamesDWARFIndex.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -225,7 +224,8 @@ void DebugNamesDWARFIndex::GetFunctions( const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, std::vector &dies) { - m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, dies); + std::vector v; + m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, v); for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name.GetStringRef())) { @@ -235,8 +235,13 @@ void DebugNamesDWARFIndex::GetFunctions( if (DIERef ref = ToDIERef(entry)) ProcessFunctionDIE(name.GetStringRef(), ref, info, parent_decl_ctx, - name_type_mask, dies); + name_type_mask, v); } + + std::set seen; + for (DWARFDIE die : v) + if (seen.insert(die.GetDIE()).second) + dies.push_back(die); } void DebugNamesDWARFIndex::GetFunctions(const RegularExpression ®ex, diff --git a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h index 30423c7ca2a2..09a0796d1342 100644 --- a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h +++ b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h @@ -1,9 +1,8 @@ //===-- DebugNamesDWARFIndex.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp index 5c6fffa07cf0..e61721556e4c 100644 --- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -1,9 +1,8 @@ //===-- HashedNameToDIE.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index b61308f0b232..7da8b701db1c 100644 --- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -1,9 +1,8 @@ //===-- HashedNameToDIE.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp index 0b06713f9543..11491c1a9ea2 100644 --- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp +++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp @@ -1,9 +1,8 @@ //===-- LogChannelDWARF.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h index 0293fbd7c495..2a183ff56ec0 100644 --- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h +++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h @@ -1,19 +1,14 @@ //===-- LogChannelDWARF.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARF_LogChannelDWARF_h_ #define SymbolFileDWARF_LogChannelDWARF_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Log.h" #define DWARF_LOG_DEBUG_INFO (1u << 1) diff --git a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 6dd670920afd..1ee6fa0f4006 100644 --- a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -1,9 +1,8 @@ //===-- ManualDWARFIndex.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h index 79ab1d95b380..773a8ec08071 100644 --- a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h +++ b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h @@ -1,9 +1,8 @@ //===-- ManulaDWARFIndex.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp index c8d6bba16976..6a47a2ae0e7a 100644 --- a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -1,9 +1,8 @@ //===-- NameToDIE.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/source/Plugins/SymbolFile/DWARF/NameToDIE.h index bba44fda3c04..e969f27e348c 100644 --- a/source/Plugins/SymbolFile/DWARF/NameToDIE.h +++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.h @@ -1,9 +1,8 @@ //===-- NameToDIE.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 37d648efa795..e9fbc31bf995 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1,15 +1,13 @@ //===-- SymbolFileDWARF.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "SymbolFileDWARF.h" -// Other libraries and framework includes #include "llvm/Support/Casting.h" #include "llvm/Support/Threading.h" @@ -17,12 +15,12 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" @@ -160,64 +158,8 @@ static const SymbolFileDWARFPropertiesSP &GetGlobalPluginProperties() { } // anonymous namespace end -static const char *removeHostnameFromPathname(const char *path_from_dwarf) { - if (!path_from_dwarf || !path_from_dwarf[0]) { - return path_from_dwarf; - } - - const char *colon_pos = strchr(path_from_dwarf, ':'); - if (nullptr == colon_pos) { - return path_from_dwarf; - } - - const char *slash_pos = strchr(path_from_dwarf, '/'); - if (slash_pos && (slash_pos < colon_pos)) { - return path_from_dwarf; - } - - // check whether we have a windows path, and so the first character is a - // drive-letter not a hostname. - if (colon_pos == path_from_dwarf + 1 && isalpha(*path_from_dwarf) && - strlen(path_from_dwarf) > 2 && '\\' == path_from_dwarf[2]) { - return path_from_dwarf; - } - - return colon_pos + 1; -} - -static FileSpec resolveCompDir(const char *path_from_dwarf) { - if (!path_from_dwarf) - return FileSpec(); - - // DWARF2/3 suggests the form hostname:pathname for compilation directory. - // Remove the host part if present. - const char *local_path = removeHostnameFromPathname(path_from_dwarf); - if (!local_path) - return FileSpec(); - - bool is_symlink = false; - // Always normalize our compile unit directory to get rid of redundant - // slashes and other path anomalies before we use it for path prepending - FileSpec local_spec(local_path, false); - const auto &file_specs = GetGlobalPluginProperties()->GetSymLinkPaths(); - for (size_t i = 0; i < file_specs.GetSize() && !is_symlink; ++i) - is_symlink = FileSpec::Equal(file_specs.GetFileSpecAtIndex(i), - local_spec, true); - - if (!is_symlink) - return local_spec; - - namespace fs = llvm::sys::fs; - if (fs::get_file_type(local_spec.GetPath(), false) != - fs::file_type::symlink_file) - return local_spec; - - FileSpec resolved_symlink; - const auto error = FileSystem::Readlink(local_spec, resolved_symlink); - if (error.Success()) - return resolved_symlink; - - return local_spec; +const FileSpecList &SymbolFileDWARF::GetSymlinkPaths() { + return GetGlobalPluginProperties()->GetSymLinkPaths(); } static inline bool IsSwiftLanguage(LanguageType language) { @@ -347,7 +289,7 @@ void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset, } size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope, - uint32_t type_mask, TypeList &type_list) + TypeClass type_mask, TypeList &type_list) { ASSERT_MODULE_LOCK(this); @@ -420,9 +362,9 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile) m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(), m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(), m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(), - m_data_debug_ranges(), m_data_debug_str(), m_data_apple_names(), - m_data_apple_types(), m_data_apple_namespaces(), m_abbr(), m_info(), - m_line(), m_fetched_external_modules(false), + m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(), + m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(), + m_abbr(), m_info(), m_line(), m_fetched_external_modules(false), m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(), m_unique_ast_type_map() {} @@ -501,7 +443,7 @@ void SymbolFileDWARF::InitializeObject() { } bool SymbolFileDWARF::SupportedVersion(uint16_t version) { - return version == 2 || version == 3 || version == 4; + return version >= 2 && version <= 5; } uint32_t SymbolFileDWARF::CalculateAbilities() { @@ -652,19 +594,40 @@ const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_data() { return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line); } +const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str); +} + const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() { return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro); } +const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() { + const DWARFDataExtractor &debugLocData = get_debug_loc_data(); + if (debugLocData.GetByteSize() > 0) + return debugLocData; + return get_debug_loclists_data(); +} + const DWARFDataExtractor &SymbolFileDWARF::get_debug_loc_data() { return GetCachedSectionData(eSectionTypeDWARFDebugLoc, m_data_debug_loc); } +const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugLocLists, + m_data_debug_loclists); +} + const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() { return GetCachedSectionData(eSectionTypeDWARFDebugRanges, m_data_debug_ranges); } +const DWARFDataExtractor &SymbolFileDWARF::get_debug_rnglists_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugRngLists, + m_data_debug_rnglists); +} + const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_data() { return GetCachedSectionData(eSectionTypeDWARFDebugStr, m_data_debug_str); } @@ -754,21 +717,24 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) { return NULL; } -DWARFDebugRanges *SymbolFileDWARF::DebugRanges() { +DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() { if (m_ranges.get() == NULL) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION, static_cast(this)); - if (get_debug_ranges_data().GetByteSize() > 0) { + + if (get_debug_ranges_data().GetByteSize() > 0) m_ranges.reset(new DWARFDebugRanges()); - if (m_ranges.get()) - m_ranges->Extract(this); - } + else if (get_debug_rnglists_data().GetByteSize() > 0) + m_ranges.reset(new DWARFDebugRngLists()); + + if (m_ranges.get()) + m_ranges->Extract(this); } return m_ranges.get(); } -const DWARFDebugRanges *SymbolFileDWARF::DebugRanges() const { +const DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() const { return m_ranges.get(); } @@ -793,23 +759,17 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFUnit *dwarf_cu, if (module_sp) { const DWARFDIE cu_die = dwarf_cu->DIE(); if (cu_die) { - FileSpec cu_file_spec{cu_die.GetName(), false}; + FileSpec cu_file_spec(cu_die.GetName(), dwarf_cu->GetPathStyle()); if (cu_file_spec) { // If we have a full path to the compile unit, we don't need to // resolve the file. This can be expensive e.g. when the source - // files are - // NFS mounted. - if (cu_file_spec.IsRelative()) { - const char *cu_comp_dir{ - cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr)}; - cu_file_spec.PrependPathComponent(resolveCompDir(cu_comp_dir)); - } + // files are NFS mounted. + cu_file_spec.MakeAbsolute(dwarf_cu->GetCompilationDirectory()); std::string remapped_file; if (module_sp->RemapSourceFile(cu_file_spec.GetPath(), remapped_file)) - cu_file_spec.SetFile(remapped_file, false, - FileSpec::Style::native); + cu_file_spec.SetFile(remapped_file, FileSpec::Style::native); } LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF( @@ -869,8 +829,8 @@ CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) { return cu_sp; } -Function *SymbolFileDWARF::ParseCompileUnitFunction(const SymbolContext &sc, - const DWARFDIE &die) { +Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit, + const DWARFDIE &die) { ASSERT_MODULE_LOCK(this); if (die.IsValid()) { TypeSystem *type_system = @@ -879,7 +839,7 @@ Function *SymbolFileDWARF::ParseCompileUnitFunction(const SymbolContext &sc, if (type_system) { DWARFASTParser *dwarf_ast = type_system->GetDWARFParser(); if (dwarf_ast) - return dwarf_ast->ParseFunctionFromDWARF(sc, die); + return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die); } } return nullptr; @@ -893,22 +853,19 @@ bool SymbolFileDWARF::FixupAddress(Address &addr) { // This is a normal DWARF file, no address fixups need to happen return true; } -lldb::LanguageType -SymbolFileDWARF::ParseCompileUnitLanguage(const SymbolContext &sc) { +lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) return dwarf_cu->GetLanguageType(); else return eLanguageTypeUnknown; } -size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { +size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); size_t functions_added = 0; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { DWARFDIECollection function_dies; const size_t num_functions = @@ -916,8 +873,8 @@ size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { size_t func_idx; for (func_idx = 0; func_idx < num_functions; ++func_idx) { DWARFDIE die = function_dies.GetDIEAtIndex(func_idx); - if (sc.comp_unit->FindFunctionByUID(die.GetID()).get() == NULL) { - if (ParseCompileUnitFunction(sc, die)) + if (comp_unit.FindFunctionByUID(die.GetID()).get() == NULL) { + if (ParseFunction(comp_unit, die)) ++functions_added; } } @@ -926,36 +883,32 @@ size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { return functions_added; } -bool SymbolFileDWARF::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { +bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly(); if (cu_die) { - FileSpec cu_comp_dir = resolveCompDir( - cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr)); const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned( DW_AT_stmt_list, DW_INVALID_OFFSET); if (stmt_list != DW_INVALID_OFFSET) { // All file indexes in DWARF are one based and a file of index zero is // supposed to be the compile unit itself. - support_files.Append(*sc.comp_unit); + support_files.Append(comp_unit); return DWARFDebugLine::ParseSupportFiles( - sc.comp_unit->GetModule(), get_debug_line_data(), cu_comp_dir, - stmt_list, support_files); + comp_unit.GetModule(), get_debug_line_data(), stmt_list, + support_files, dwarf_cu); } } } return false; } -bool SymbolFileDWARF::ParseCompileUnitIsOptimized( - const lldb_private::SymbolContext &sc) { +bool SymbolFileDWARF::ParseIsOptimized(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) return dwarf_cu->GetIsOptimized(); return false; @@ -1057,13 +1010,12 @@ static void ParseDWARFLineTableCallback(dw_offset_t offset, } } -bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { +bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - if (sc.comp_unit->GetLineTable() != NULL) + if (comp_unit.GetLineTable() != NULL) return true; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly(); if (dwarf_cu_die) { @@ -1071,7 +1023,7 @@ bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list, DW_INVALID_OFFSET); if (cu_line_offset != DW_INVALID_OFFSET) { - std::unique_ptr line_table_ap(new LineTable(sc.comp_unit)); + std::unique_ptr line_table_ap(new LineTable(&comp_unit)); if (line_table_ap.get()) { ParseDWARFLineTableCallbackInfo info; info.line_table = line_table_ap.get(); @@ -1084,9 +1036,7 @@ bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { * #0 * for MIPS. Use ArchSpec to clear the bit #0. */ - ArchSpec arch; - GetObjectFile()->GetArchitecture(arch); - switch (arch.GetMachine()) { + switch (GetObjectFile()->GetArchitecture().GetMachine()) { case llvm::Triple::mips: case llvm::Triple::mipsel: case llvm::Triple::mips64: @@ -1101,17 +1051,17 @@ bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) { lldb::offset_t offset = cu_line_offset; DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, - &info); + &info, dwarf_cu); SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); if (debug_map_symfile) { // We have an object file that has a line table with addresses that // are not linked. We need to link the line table and convert the // addresses that are relative to the .o file into addresses for // the main executable. - sc.comp_unit->SetLineTable( + comp_unit.SetLineTable( debug_map_symfile->LinkOSOLineTable(this, line_table_ap.get())); } else { - sc.comp_unit->SetLineTable(line_table_ap.release()); + comp_unit.SetLineTable(line_table_ap.release()); return true; } } @@ -1143,11 +1093,10 @@ SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) { return debug_macros_sp; } -bool SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext &sc) { +bool SymbolFileDWARF::ParseDebugMacros(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit); - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu == nullptr) return false; @@ -1163,16 +1112,14 @@ bool SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext &sc) { if (sect_offset == DW_INVALID_OFFSET) return false; - sc.comp_unit->SetDebugMacros(ParseDebugMacros(§_offset)); + comp_unit.SetDebugMacros(ParseDebugMacros(§_offset)); return true; } -size_t SymbolFileDWARF::ParseFunctionBlocks(const SymbolContext &sc, - Block *parent_block, - const DWARFDIE &orig_die, - addr_t subprogram_low_pc, - uint32_t depth) { +size_t SymbolFileDWARF::ParseBlocksRecursive( + lldb_private::CompileUnit &comp_unit, Block *parent_block, + const DWARFDIE &orig_die, addr_t subprogram_low_pc, uint32_t depth) { size_t blocks_added = 0; DWARFDIE die = orig_die; while (die) { @@ -1251,13 +1198,13 @@ size_t SymbolFileDWARF::ParseFunctionBlocks(const SymbolContext &sc, std::unique_ptr decl_ap; if (decl_file != 0 || decl_line != 0 || decl_column != 0) decl_ap.reset(new Declaration( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), + comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); std::unique_ptr call_ap; if (call_file != 0 || call_line != 0 || call_column != 0) call_ap.reset(new Declaration( - sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(call_file), + comp_unit.GetSupportFiles().GetFileSpecAtIndex(call_file), call_line, call_column)); block->SetInlinedFunctionInfo(name, mangled_name, decl_ap.get(), @@ -1267,8 +1214,9 @@ size_t SymbolFileDWARF::ParseFunctionBlocks(const SymbolContext &sc, ++blocks_added; if (die.HasChildren()) { - blocks_added += ParseFunctionBlocks(sc, block, die.GetFirstChild(), - subprogram_low_pc, depth + 1); + blocks_added += + ParseBlocksRecursive(comp_unit, block, die.GetFirstChild(), + subprogram_low_pc, depth + 1); } } } break; @@ -1585,7 +1533,7 @@ bool SymbolFileDWARF::GetFunction(const DWARFDIE &die, SymbolContext &sc) { sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, die); + sc.function = ParseFunction(*sc.comp_unit, die); if (sc.function) { sc.module_sp = sc.function->CalculateSymbolContextModule(); @@ -1638,18 +1586,20 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit( return dwo_symfile; } - FileSpec dwo_file(dwo_name, true); + FileSpec dwo_file(dwo_name); + FileSystem::Instance().Resolve(dwo_file); if (dwo_file.IsRelative()) { const char *comp_dir = cu_die.GetAttributeValueAsString( this, &dwarf_cu, DW_AT_comp_dir, nullptr); if (!comp_dir) return nullptr; - dwo_file.SetFile(comp_dir, true, FileSpec::Style::native); + dwo_file.SetFile(comp_dir, FileSpec::Style::native); + FileSystem::Instance().Resolve(dwo_file); dwo_file.AppendPathComponent(dwo_name); } - if (!dwo_file.Exists()) + if (!FileSystem::Instance().Exists(dwo_file)) return nullptr; const lldb::offset_t file_offset = 0; @@ -1657,7 +1607,8 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit( lldb::offset_t dwo_file_data_offset = 0; ObjectFileSP dwo_obj_file = ObjectFile::FindPlugin( GetObjectFile()->GetModule(), &dwo_file, file_offset, - dwo_file.GetByteSize(), dwo_file_data_sp, dwo_file_data_offset); + FileSystem::Instance().GetByteSize(dwo_file), dwo_file_data_sp, + dwo_file_data_offset); if (dwo_obj_file == nullptr) return nullptr; @@ -1676,7 +1627,7 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() { DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx); const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly(); - if (die && die.HasChildren() == false) { + if (die && !die.HasChildren()) { const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr); if (name) { @@ -1688,14 +1639,15 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() { die.GetAttributeValueAsString(DW_AT_GNU_dwo_name, nullptr); if (dwo_path) { ModuleSpec dwo_module_spec; - dwo_module_spec.GetFileSpec().SetFile(dwo_path, false, + dwo_module_spec.GetFileSpec().SetFile(dwo_path, FileSpec::Style::native); if (dwo_module_spec.GetFileSpec().IsRelative()) { const char *comp_dir = die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr); if (comp_dir) { - dwo_module_spec.GetFileSpec().SetFile(comp_dir, true, + dwo_module_spec.GetFileSpec().SetFile(comp_dir, FileSpec::Style::native); + FileSystem::Instance().Resolve(dwo_module_spec.GetFileSpec()); dwo_module_spec.GetFileSpec().AppendPathComponent(dwo_path); } } @@ -1769,7 +1721,8 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() { location_result.GetScalar().ULongLong(); lldb::addr_t byte_size = 1; if (var_sp->GetType()) - byte_size = var_sp->GetType()->GetByteSize(); + byte_size = + var_sp->GetType()->GetByteSize().getValueOr(0); m_global_aranges_ap->Append(GlobalVariableMap::Entry( file_addr, byte_size, var_sp.get())); } @@ -1786,7 +1739,7 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() { } uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + SymbolContextItem resolve_scope, SymbolContext &sc) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, @@ -1844,7 +1797,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, function_die); + sc.function = ParseFunction(*sc.comp_unit, function_die); if (sc.function && (resolve_scope & eSymbolContextBlock)) block_die = function_die.LookupDeepestBlock(file_vm_addr); @@ -1920,7 +1873,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr, uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + SymbolContextItem resolve_scope, SymbolContextList &sc_list) { const uint32_t prev_size = sc_list.GetSize(); if (resolve_scope & eSymbolContextCompUnit) { @@ -1985,7 +1938,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec, .get(); if (sc.function == NULL) sc.function = - ParseCompileUnitFunction(sc, function_die); + ParseFunction(*sc.comp_unit, function_die); if (sc.function && (resolve_scope & eSymbolContextBlock)) @@ -2261,7 +2214,7 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die, sc.block = function_block.FindBlockByID(inlined_die.GetID()); if (sc.block == NULL) sc.block = function_block.FindBlockByID(inlined_die.GetOffset()); - if (sc.block == NULL || sc.block->GetStartAddress(addr) == false) + if (sc.block == NULL || !sc.block->GetStartAddress(addr)) addr.Clear(); } else { sc.block = NULL; @@ -2297,11 +2250,10 @@ bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx, return false; } -uint32_t -SymbolFileDWARF::FindFunctions(const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, - bool append, SymbolContextList &sc_list) { +uint32_t SymbolFileDWARF::FindFunctions( + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + FunctionNameType name_type_mask, bool include_inlines, bool append, + SymbolContextList &sc_list) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, "SymbolFileDWARF::FindFunctions (name = '%s')", name.AsCString()); @@ -2444,9 +2396,8 @@ void SymbolFileDWARF::GetMangledNamesForFunction( } uint32_t SymbolFileDWARF::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { // If we aren't appending the results to this list, then clear the list @@ -2535,8 +2486,8 @@ uint32_t SymbolFileDWARF::FindTypes( SymbolVendor *sym_vendor = external_module_sp->GetSymbolVendor(); if (sym_vendor) { const uint32_t num_external_matches = - sym_vendor->FindTypes(sc, name, parent_decl_ctx, append, - max_matches, searched_symbol_files, types); + sym_vendor->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); if (num_external_matches) return num_external_matches; } @@ -2598,7 +2549,7 @@ size_t SymbolFileDWARF::FindTypes(const std::vector &context, } CompilerDeclContext -SymbolFileDWARF::FindNamespace(const SymbolContext &sc, const ConstString &name, +SymbolFileDWARF::FindNamespace(const ConstString &name, const CompilerDeclContext *parent_decl_ctx) { Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); @@ -3264,41 +3215,36 @@ size_t SymbolFileDWARF::ParseTypes(const SymbolContext &sc, return types_added; } -size_t SymbolFileDWARF::ParseFunctionBlocks(const SymbolContext &sc) { +size_t SymbolFileDWARF::ParseBlocksRecursive(Function &func) { ASSERT_MODULE_LOCK(this); - assert(sc.comp_unit && sc.function); + CompileUnit *comp_unit = func.GetCompileUnit(); + lldbassert(comp_unit); + + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(comp_unit); + if (!dwarf_cu) + return 0; + size_t functions_added = 0; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); - if (dwarf_cu) { - const dw_offset_t function_die_offset = sc.function->GetID(); - DWARFDIE function_die = dwarf_cu->GetDIE(function_die_offset); - if (function_die) { - ParseFunctionBlocks(sc, &sc.function->GetBlock(false), function_die, - LLDB_INVALID_ADDRESS, 0); - } + const dw_offset_t function_die_offset = func.GetID(); + DWARFDIE function_die = dwarf_cu->GetDIE(function_die_offset); + if (function_die) { + ParseBlocksRecursive(*comp_unit, &func.GetBlock(false), function_die, + LLDB_INVALID_ADDRESS, 0); } return functions_added; } -size_t SymbolFileDWARF::ParseTypes(const SymbolContext &sc) { +size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) { ASSERT_MODULE_LOCK(this); - // At least a compile unit must be valid - assert(sc.comp_unit); size_t types_added = 0; - DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit); if (dwarf_cu) { - if (sc.function) { - dw_offset_t function_die_offset = sc.function->GetID(); - DWARFDIE func_die = dwarf_cu->GetDIE(function_die_offset); - if (func_die && func_die.HasChildren()) { - types_added = ParseTypes(sc, func_die.GetFirstChild(), true, true); - } - } else { - DWARFDIE dwarf_cu_die = dwarf_cu->DIE(); - if (dwarf_cu_die && dwarf_cu_die.HasChildren()) { - types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true); - } + DWARFDIE dwarf_cu_die = dwarf_cu->DIE(); + if (dwarf_cu_die && dwarf_cu_die.HasChildren()) { + SymbolContext sc; + sc.comp_unit = &comp_unit; + types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true); } } @@ -3500,7 +3446,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, uint32_t block_length = form_value.Unsigned(); location.CopyOpcodeData(module, data, block_offset, block_length); } else { - const DWARFDataExtractor &debug_loc_data = get_debug_loc_data(); + const DWARFDataExtractor &debug_loc_data = DebugLocData(); const dw_offset_t debug_loc_offset = form_value.Unsigned(); size_t loc_list_length = DWARFExpression::LocationListSize( @@ -3521,22 +3467,10 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, case DW_AT_start_scope: { if (form_value.Form() == DW_FORM_sec_offset) { DWARFRangeList dwarf_scope_ranges; - const DWARFDebugRanges *debug_ranges = DebugRanges(); - debug_ranges->FindRanges(die.GetCU()->GetRangesBase(), + const DWARFDebugRangesBase *debug_ranges = DebugRanges(); + debug_ranges->FindRanges(die.GetCU(), form_value.Unsigned(), dwarf_scope_ranges); - - // All DW_AT_start_scope are relative to the base address of the - // compile unit. We add the compile unit base address to make - // sure all the addresses are properly fixed up. - for (size_t i = 0, count = dwarf_scope_ranges.GetSize(); - i < count; ++i) { - const DWARFRangeList::Entry &range = - dwarf_scope_ranges.GetEntryRef(i); - scope_ranges.Append(range.GetRangeBase() + - die.GetCU()->GetBaseAddress(), - range.GetByteSize()); - } } else { // TODO: Handle the case when DW_AT_start_scope have form // constant. The @@ -3761,9 +3695,10 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, new SymbolFileType(*this, DIERef(type_die_form).GetUID(this))); if (const_value.Form() && type_sp && type_sp->GetType()) - location.CopyOpcodeData(const_value.Unsigned(), - type_sp->GetType()->GetByteSize(), - die.GetCU()->GetAddressByteSize()); + location.CopyOpcodeData( + const_value.Unsigned(), + type_sp->GetType()->GetByteSize().getValueOr(0), + die.GetCU()->GetAddressByteSize()); var_sp.reset(new Variable(die.GetID(), name, mangled, type_sp, scope, symbol_context_scope, scope_ranges, &decl, @@ -4011,6 +3946,14 @@ uint32_t SymbolFileDWARF::GetPluginVersion() { return 1; } void SymbolFileDWARF::Dump(lldb_private::Stream &s) { m_index->Dump(s); } +void SymbolFileDWARF::DumpClangAST(Stream &s) { + TypeSystem *ts = GetTypeSystemForLanguage(eLanguageTypeC_plus_plus); + ClangASTContext *clang = llvm::dyn_cast_or_null(ts); + if (!clang) + return; + clang->Dump(s); +} + SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() { if (m_debug_map_symfile == NULL && !m_debug_map_module_wp.expired()) { lldb::ModuleSP module_sp(m_debug_map_module_wp.lock()); @@ -4026,6 +3969,8 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() { DWARFExpression::LocationListFormat SymbolFileDWARF::GetLocationListFormat() const { + if (m_data_debug_loclists.m_data.GetByteSize() > 0) + return DWARFExpression::LocLists; return DWARFExpression::RegularLocationList; } @@ -4034,9 +3979,9 @@ SymbolFileDWARFDwp *SymbolFileDWARF::GetDwpSymbolFile() { ModuleSpec module_spec; module_spec.GetFileSpec() = m_obj_file->GetFileSpec(); module_spec.GetSymbolFileSpec() = - FileSpec(m_obj_file->GetFileSpec().GetPath() + ".dwp", false); + FileSpec(m_obj_file->GetFileSpec().GetPath() + ".dwp"); FileSpec dwp_filespec = Symbols::LocateExecutableSymbolFile(module_spec); - if (dwp_filespec.Exists()) { + if (FileSystem::Instance().Exists(dwp_filespec)) { m_dwp_symfile = SymbolFileDWARFDwp::Create(GetObjectFile()->GetModule(), dwp_filespec); } diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 0766f92dddc3..c447768d7ea2 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -1,17 +1,14 @@ //===-- SymbolFileDWARF.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARF_SymbolFileDWARF_h_ #define SymbolFileDWARF_SymbolFileDWARF_h_ -// C Includes -// C++ Includes #include #include #include @@ -19,7 +16,6 @@ #include #include -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Threading.h" @@ -35,7 +31,6 @@ #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" -// Project includes #include "DWARFDataExtractor.h" #include "DWARFDefines.h" #include "DWARFIndex.h" @@ -54,7 +49,7 @@ class DWARFDebugAranges; class DWARFDebugInfo; class DWARFDebugInfoEntry; class DWARFDebugLine; -class DWARFDebugRanges; +class DWARFDebugRangesBase; class DWARFDeclContext; class DWARFDIECollection; class DWARFFormValue; @@ -92,6 +87,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, static lldb_private::SymbolFile * CreateInstance(lldb_private::ObjectFile *obj_file); + static const lldb_private::FileSpecList &GetSymlinkPaths(); + //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ @@ -113,31 +110,26 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; lldb::LanguageType - ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override; + ParseLanguage(lldb_private::CompileUnit &comp_unit) override; - size_t - ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override; + size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; - bool - ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override; + bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; - bool - ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override; + bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; - bool ParseCompileUnitSupportFiles( - const lldb_private::SymbolContext &sc, - lldb_private::FileSpecList &support_files) override; + bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, + lldb_private::FileSpecList &support_files) override; - bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) override; + bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override; + + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; bool ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) override; - size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t ParseBlocksRecursive(lldb_private::Function &func) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; @@ -170,12 +162,13 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override; uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override; uint32_t ResolveSymbolContext(const lldb_private::FileSpec &file_spec, uint32_t line, - bool check_inlines, uint32_t resolve_scope, + bool check_inlines, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override; uint32_t @@ -191,8 +184,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, uint32_t FindFunctions(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) override; + lldb::FunctionNameType name_type_mask, bool include_inlines, + bool append, lldb_private::SymbolContextList &sc_list) override; uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, bool include_inlines, bool append, @@ -203,8 +196,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, std::vector &mangled_names) override; uint32_t - FindTypes(const lldb_private::SymbolContext &sc, - const lldb_private::ConstString &name, + FindTypes(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, @@ -216,14 +208,13 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, lldb_private::TypeList *GetTypeList() override; size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override; lldb_private::TypeSystem * GetTypeSystemForLanguage(lldb::LanguageType language) override; lldb_private::CompilerDeclContext FindNamespace( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx) override; @@ -247,17 +238,20 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, uint32_t GetPluginVersion() override; - const lldb_private::DWARFDataExtractor &get_debug_abbrev_data(); - const lldb_private::DWARFDataExtractor &get_debug_addr_data(); + virtual const lldb_private::DWARFDataExtractor &get_debug_abbrev_data(); + virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data(); const lldb_private::DWARFDataExtractor &get_debug_aranges_data(); const lldb_private::DWARFDataExtractor &get_debug_frame_data(); - const lldb_private::DWARFDataExtractor &get_debug_info_data(); + virtual const lldb_private::DWARFDataExtractor &get_debug_info_data(); const lldb_private::DWARFDataExtractor &get_debug_line_data(); + const lldb_private::DWARFDataExtractor &get_debug_line_str_data(); const lldb_private::DWARFDataExtractor &get_debug_macro_data(); const lldb_private::DWARFDataExtractor &get_debug_loc_data(); + const lldb_private::DWARFDataExtractor &get_debug_loclists_data(); const lldb_private::DWARFDataExtractor &get_debug_ranges_data(); - const lldb_private::DWARFDataExtractor &get_debug_str_data(); - const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data(); + const lldb_private::DWARFDataExtractor &get_debug_rnglists_data(); + virtual const lldb_private::DWARFDataExtractor &get_debug_str_data(); + virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data(); const lldb_private::DWARFDataExtractor &get_debug_types_data(); const lldb_private::DWARFDataExtractor &get_apple_names_data(); const lldb_private::DWARFDataExtractor &get_apple_types_data(); @@ -273,9 +267,11 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, const DWARFDebugInfo *DebugInfo() const; - DWARFDebugRanges *DebugRanges(); + DWARFDebugRangesBase *DebugRanges(); + + const DWARFDebugRangesBase *DebugRanges() const; - const DWARFDebugRanges *DebugRanges() const; + const lldb_private::DWARFDataExtractor &DebugLocData(); static bool SupportedVersion(uint16_t version); @@ -334,6 +330,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, void Dump(lldb_private::Stream &s) override; + void DumpClangAST(lldb_private::Stream &s) override; + protected: typedef llvm::DenseMap DIEToTypePtr; @@ -368,14 +366,13 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, bool GetFunction(const DWARFDIE &die, lldb_private::SymbolContext &sc); - lldb_private::Function * - ParseCompileUnitFunction(const lldb_private::SymbolContext &sc, - const DWARFDIE &die); + lldb_private::Function *ParseFunction(lldb_private::CompileUnit &comp_unit, + const DWARFDIE &die); - size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc, - lldb_private::Block *parent_block, - const DWARFDIE &die, - lldb::addr_t subprogram_low_pc, uint32_t depth); + size_t ParseBlocksRecursive(lldb_private::CompileUnit &comp_unit, + lldb_private::Block *parent_block, + const DWARFDIE &die, + lldb::addr_t subprogram_low_pc, uint32_t depth); size_t ParseTypes(const lldb_private::SymbolContext &sc, const DWARFDIE &die, bool parse_siblings, bool parse_children); @@ -491,9 +488,12 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, DWARFDataSegment m_data_debug_frame; DWARFDataSegment m_data_debug_info; DWARFDataSegment m_data_debug_line; + DWARFDataSegment m_data_debug_line_str; DWARFDataSegment m_data_debug_macro; DWARFDataSegment m_data_debug_loc; + DWARFDataSegment m_data_debug_loclists; DWARFDataSegment m_data_debug_ranges; + DWARFDataSegment m_data_debug_rnglists; DWARFDataSegment m_data_debug_str; DWARFDataSegment m_data_debug_str_offsets; DWARFDataSegment m_data_debug_types; @@ -524,7 +524,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, typedef std::shared_ptr> DIERefSetSP; typedef std::unordered_map NameToOffsetMap; NameToOffsetMap m_function_scope_qualified_name_map; - std::unique_ptr m_ranges; + std::unique_ptr m_ranges; UniqueDWARFASTTypeMap m_unique_ast_type_map; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp; diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index ad1ae2c9a594..697e3ac24a46 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1,16 +1,11 @@ //===-- SymbolFileDWARFDebugMap.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "SymbolFileDWARFDebugMap.h" #include "DWARFDebugAranges.h" @@ -91,11 +86,10 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap( const uint32_t oso_end_idx = comp_unit_info->last_symbol_index + 1; for (uint32_t idx = comp_unit_info->first_symbol_index + 2; // Skip the N_SO and N_OSO - idx < oso_end_idx; - ++idx) { + idx < oso_end_idx; ++idx) { Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx); if (exe_symbol) { - if (exe_symbol->IsDebug() == false) + if (!exe_symbol->IsDebug()) continue; switch (exe_symbol->GetType()) { @@ -185,7 +179,7 @@ class DebugMapModule : public Module { GetSymbolVendor(bool can_create = true, lldb_private::Stream *feedback_strm = NULL) override { // Scope for locker - if (m_symfile_ap.get() || can_create == false) + if (m_symfile_ap.get() || !can_create) return m_symfile_ap.get(); ModuleSP exe_module_sp(m_exe_module_wp.lock()); @@ -352,7 +346,7 @@ void SymbolFileDWARFDebugMap::InitOSO() { so_symbol->GetType() == eSymbolTypeSourceFile && oso_symbol->GetType() == eSymbolTypeObjectFile) { m_compile_unit_infos[i].so_file.SetFile( - so_symbol->GetName().AsCString(), false, FileSpec::Style::native); + so_symbol->GetName().AsCString(), FileSpec::Style::native); m_compile_unit_infos[i].oso_path = oso_symbol->GetName(); m_compile_unit_infos[i].oso_mod_time = llvm::sys::toTimePoint(oso_symbol->GetIntegerValue(0)); @@ -422,13 +416,13 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo( m_oso_map[{comp_unit_info->oso_path, comp_unit_info->oso_mod_time}] = comp_unit_info->oso_sp; const char *oso_path = comp_unit_info->oso_path.GetCString(); - FileSpec oso_file(oso_path, false); + FileSpec oso_file(oso_path); ConstString oso_object; - if (oso_file.Exists()) { + if (FileSystem::Instance().Exists(oso_file)) { // The modification time returned by the FS can have a higher precision // than the one from the CU. auto oso_mod_time = std::chrono::time_point_cast( - FileSystem::GetModificationTime(oso_file)); + FileSystem::Instance().GetModificationTime(oso_file)); if (oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is " @@ -494,7 +488,12 @@ ObjectFile *SymbolFileDWARFDebugMap::GetObjectFileByOSOIndex(uint32_t oso_idx) { SymbolFileDWARF * SymbolFileDWARFDebugMap::GetSymbolFile(const SymbolContext &sc) { - CompileUnitInfo *comp_unit_info = GetCompUnitInfo(sc); + return GetSymbolFile(*sc.comp_unit); +} + +SymbolFileDWARF * +SymbolFileDWARFDebugMap::GetSymbolFile(const CompileUnit &comp_unit) { + CompileUnitInfo *comp_unit_info = GetCompUnitInfo(comp_unit); if (comp_unit_info) return GetSymbolFileByCompUnitInfo(comp_unit_info); return NULL; @@ -602,9 +601,14 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { SymbolFileDWARFDebugMap::CompileUnitInfo * SymbolFileDWARFDebugMap::GetCompUnitInfo(const SymbolContext &sc) { + return GetCompUnitInfo(*sc.comp_unit); +} + +SymbolFileDWARFDebugMap::CompileUnitInfo * +SymbolFileDWARFDebugMap::GetCompUnitInfo(const CompileUnit &comp_unit) { const uint32_t cu_count = GetNumCompileUnits(); for (uint32_t i = 0; i < cu_count; ++i) { - if (sc.comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) + if (comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) return &m_compile_unit_infos[i]; } return NULL; @@ -622,50 +626,46 @@ size_t SymbolFileDWARFDebugMap::GetCompUnitInfosForModule( } lldb::LanguageType -SymbolFileDWARFDebugMap::ParseCompileUnitLanguage(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitLanguage(sc); + return oso_dwarf->ParseLanguage(comp_unit); return eLanguageTypeUnknown; } -size_t -SymbolFileDWARFDebugMap::ParseCompileUnitFunctions(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitFunctions(sc); + return oso_dwarf->ParseFunctions(comp_unit); return 0; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitLineTable( - const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseLineTable(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitLineTable(sc); + return oso_dwarf->ParseLineTable(comp_unit); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitDebugMacros( - const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitDebugMacros(sc); + return oso_dwarf->ParseDebugMacros(comp_unit); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitSupportFiles(sc, support_files); + return oso_dwarf->ParseSupportFiles(comp_unit, support_files); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitIsOptimized( - const lldb_private::SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitIsOptimized(sc); + return oso_dwarf->ParseIsOptimized(comp_unit); return false; } @@ -677,17 +677,21 @@ bool SymbolFileDWARFDebugMap::ParseImportedModules( return false; } -size_t SymbolFileDWARFDebugMap::ParseFunctionBlocks(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseBlocksRecursive(Function &func) { + CompileUnit *comp_unit = func.GetCompileUnit(); + if (!comp_unit) + return 0; + + SymbolFileDWARF *oso_dwarf = GetSymbolFile(*comp_unit); if (oso_dwarf) - return oso_dwarf->ParseFunctionBlocks(sc); + return oso_dwarf->ParseBlocksRecursive(func); return 0; } -size_t SymbolFileDWARFDebugMap::ParseTypes(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseTypes(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseTypes(sc); + return oso_dwarf->ParseTypes(comp_unit); return 0; } @@ -732,8 +736,10 @@ bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) { return success; } -uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( - const Address &exe_so_addr, uint32_t resolve_scope, SymbolContext &sc) { +uint32_t +SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr, + SymbolContextItem resolve_scope, + SymbolContext &sc) { uint32_t resolved_flags = 0; Symtab *symtab = m_obj_file->GetSymtab(); if (symtab) { @@ -775,7 +781,7 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, SymbolContextList &sc_list) { + SymbolContextItem resolve_scope, SymbolContextList &sc_list) { const uint32_t initial = sc_list.GetSize(); const uint32_t cu_count = GetNumCompileUnits(); @@ -807,8 +813,7 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( const ConstString &name, const CompilerDeclContext *parent_decl_ctx, const std::vector &indexes, // Indexes into the symbol table that match "name" - uint32_t max_matches, - VariableList &variables) { + uint32_t max_matches, VariableList &variables) { const uint32_t original_size = variables.GetSize(); const size_t match_count = indexes.size(); for (size_t i = 0; i < match_count; ++i) { @@ -992,7 +997,7 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp, uint32_t SymbolFileDWARFDebugMap::FindFunctions( const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, @@ -1047,7 +1052,7 @@ uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, } size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, TypeList &type_list) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, @@ -1160,7 +1165,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( // Only search all .o files for the definition if we don't need the // implementation because otherwise, with a valid debug map we should have // the ObjC class symbol and the code above should have found it. - if (must_be_implementation == false) { + if (!must_be_implementation) { TypeSP type_sp; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { @@ -1175,32 +1180,20 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( } uint32_t SymbolFileDWARFDebugMap::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { if (!append) types.Clear(); const uint32_t initial_types_size = types.GetSize(); - SymbolFileDWARF *oso_dwarf; - if (sc.comp_unit) { - oso_dwarf = GetSymbolFile(sc); - if (oso_dwarf) - return oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, - max_matches, searched_symbol_files, types); - } else { - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, max_matches, - searched_symbol_files, types); - if (types.GetSize() >= max_matches) - return true; - else - return false; - }); - } + ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { + oso_dwarf->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); + return types.GetSize() >= max_matches; + }); return types.GetSize() - initial_types_size; } @@ -1219,27 +1212,26 @@ uint32_t SymbolFileDWARFDebugMap::FindTypes( //} CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const CompilerDeclContext *parent_decl_ctx) { CompilerDeclContext matching_namespace; - SymbolFileDWARF *oso_dwarf; - if (sc.comp_unit) { - oso_dwarf = GetSymbolFile(sc); - if (oso_dwarf) - matching_namespace = oso_dwarf->FindNamespace(sc, name, parent_decl_ctx); - } else { - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - matching_namespace = oso_dwarf->FindNamespace(sc, name, parent_decl_ctx); + ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { + matching_namespace = oso_dwarf->FindNamespace(name, parent_decl_ctx); - return (bool)matching_namespace; - }); - } + return (bool)matching_namespace; + }); return matching_namespace; } +void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s) { + ForEachSymbolFile([&s](SymbolFileDWARF *oso_dwarf) -> bool { + oso_dwarf->DumpClangAST(s); + return true; + }); +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ @@ -1484,12 +1476,12 @@ SymbolFileDWARFDebugMap::GetASTData(lldb::LanguageType language) { done = true; } else { // Try to load the specified file. - FileSpec file_spec(symbol->GetName().GetCString(), false); - if (file_spec.Exists()) { + FileSpec file_spec(symbol->GetName().GetCString()); + if (FileSystem::Instance().Exists(file_spec)) { // We found the source data for the AST data blob. // Read it in and add it to our return vector. std::shared_ptr data_buf_sp - = DataBufferLLVM::CreateFromPath(file_spec.GetPath()); + = FileSystem::Instance().CreateDataBuffer(file_spec.GetPath()); if (data_buf_sp) { ast_datas.push_back(data_buf_sp); if (log) diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index f6670df8c3af..f741bc0fb8e8 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -1,9 +1,8 @@ //===-- SymbolFileDWARFDebugMap.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -57,23 +56,25 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; lldb::LanguageType - ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override; - size_t - ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override; - bool - ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override; - bool - ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override; - bool ParseCompileUnitSupportFiles( - const lldb_private::SymbolContext &sc, - lldb_private::FileSpecList &support_files) override; - bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) override; + ParseLanguage(lldb_private::CompileUnit &comp_unit) override; + + size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; + + bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; + + bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; + + bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, + lldb_private::FileSpecList &support_files) override; + + bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override; + + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; + bool ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) override; - size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t ParseBlocksRecursive(lldb_private::Function &func) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; @@ -91,11 +92,12 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { bool CompleteType(lldb_private::CompilerType &compiler_type) override; uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override; uint32_t ResolveSymbolContext(const lldb_private::FileSpec &file_spec, uint32_t line, - bool check_inlines, uint32_t resolve_scope, + bool check_inlines, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override; uint32_t FindGlobalVariables(const lldb_private::ConstString &name, @@ -108,24 +110,22 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { uint32_t FindFunctions(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) override; + lldb::FunctionNameType name_type_mask, bool include_inlines, + bool append, lldb_private::SymbolContextList &sc_list) override; uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) override; uint32_t - FindTypes(const lldb_private::SymbolContext &sc, - const lldb_private::ConstString &name, + FindTypes(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, lldb_private::TypeMap &types) override; lldb_private::CompilerDeclContext FindNamespace( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx) override; size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override; std::vector ParseCallEdgesInFunction(lldb_private::UserID func_id) override; @@ -133,6 +133,8 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { std::vector GetASTData(lldb::LanguageType language) override; + void DumpClangAST(lldb_private::Stream &s) override; + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ @@ -200,6 +202,7 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { bool GetFileSpecForSO(uint32_t oso_idx, lldb_private::FileSpec &file_spec); CompileUnitInfo *GetCompUnitInfo(const lldb_private::SymbolContext &sc); + CompileUnitInfo *GetCompUnitInfo(const lldb_private::CompileUnit &comp_unit); size_t GetCompUnitInfosForModule(const lldb_private::Module *oso_module, std::vector &cu_infos); @@ -217,6 +220,7 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile { uint32_t GetCompUnitInfoIndex(const CompileUnitInfo *comp_unit_info); SymbolFileDWARF *GetSymbolFile(const lldb_private::SymbolContext &sc); + SymbolFileDWARF *GetSymbolFile(const lldb_private::CompileUnit &comp_unit); SymbolFileDWARF *GetSymbolFileByCompUnitInfo(CompileUnitInfo *comp_unit_info); diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index 15fe362fa117..07b458ca0c76 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -1,9 +1,8 @@ //===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -61,14 +60,6 @@ SymbolFileDWARFDwo::ParseCompileUnit(DWARFUnit *dwarf_cu, } DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() { - // A clang module is found via a skeleton CU, but is not a proper DWO. - // Clang modules have a .debug_info section instead of the *_dwo variant. - if (auto *section_list = m_obj_file->GetSectionList(false)) - if (auto section_sp = - section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true)) - if (!section_sp->GetName().GetStringRef().endswith("dwo")) - return nullptr; - // Only dwo files with 1 compile unit is supported if (GetNumCompileUnits() == 1) return DebugInfo()->GetCompileUnitAtIndex(0); @@ -126,6 +117,37 @@ DWARFUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() { return m_base_dwarf_cu; } +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo, + m_data_debug_abbrev); +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() { + // For single file split dwarf case (when we have .dwo sections in a .o), + // we do not want to use the .debug_addr section from .o file, + // but want to get one from the final executable. + // For regular split debug case, .dwo file does not contain the + // .debug_addr, so we would always fall back to such lookup anyways. + llvm::call_once(m_data_debug_addr.m_flag, [this] { + SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr, + std::ref(m_data_debug_addr.m_data)); + }); + return m_data_debug_addr.m_data; +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info); +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str); +} + +const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() { + return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsetsDwo, + m_data_debug_str_offsets); +} + SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() { return m_base_dwarf_cu->GetSymbolFileDWARF(); } diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h index 483a19512a36..75363ac6e2cb 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -1,19 +1,14 @@ //===-- SymbolFileDWARFDwo.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_ #define SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "SymbolFileDWARF.h" class SymbolFileDWARFDwo : public SymbolFileDWARF { @@ -50,6 +45,12 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF { DWARFUnit *GetBaseCompileUnit() override; + const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override; + const lldb_private::DWARFDataExtractor &get_debug_addr_data() override; + const lldb_private::DWARFDataExtractor &get_debug_info_data() override; + const lldb_private::DWARFDataExtractor &get_debug_str_data() override; + const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override; + protected: void LoadSectionData(lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data) override; diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp index 403c10fe65ea..17f91a7b91ae 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp @@ -1,9 +1,8 @@ //===-- SymbolFileDWARFDwoDwp.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h index b1b505b5899f..4e57b1c265e8 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h @@ -1,19 +1,14 @@ //===-- SymbolFileDWARFDwoDwp.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARFDwoDwp_SymbolFileDWARFDwoDwp_h_ #define SymbolFileDWARFDwoDwp_SymbolFileDWARFDwoDwp_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "SymbolFileDWARFDwo.h" #include "SymbolFileDWARFDwp.h" diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp index ae10e7179e33..4d00a81afd7a 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp @@ -1,18 +1,13 @@ //===-- SymbolFileDWARFDwp.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "SymbolFileDWARFDwp.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" @@ -30,7 +25,7 @@ lldbSectTypeToLlvmSectionKind(lldb::SectionType type) { case lldb::eSectionTypeDWARFDebugLine: return llvm::DW_SECT_LINE; case lldb::eSectionTypeDWARFDebugLoc: - return llvm::DW_SECT_LOC; + return llvm::DW_SECT_LOC; case lldb::eSectionTypeDWARFDebugStrOffsets: return llvm::DW_SECT_STR_OFFSETS; // case lldb::eSectionTypeDWARFDebugMacinfo: @@ -50,7 +45,8 @@ SymbolFileDWARFDwp::Create(lldb::ModuleSP module_sp, lldb::DataBufferSP file_data_sp; lldb::offset_t file_data_offset = 0; lldb::ObjectFileSP obj_file = lldb_private::ObjectFile::FindPlugin( - module_sp, &file_spec, file_offset, file_spec.GetByteSize(), file_data_sp, + module_sp, &file_spec, file_offset, + lldb_private::FileSystem::Instance().GetByteSize(file_spec), file_data_sp, file_data_offset); if (obj_file == nullptr) return nullptr; diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h index 470d1c5b1c48..452ef0ab07de 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h @@ -1,23 +1,18 @@ //===-- SymbolFileDWARFDwp.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 SymbolFileDWARFDwp_SymbolFileDWARFDwp_h_ #define SymbolFileDWARFDwp_SymbolFileDWARFDwp_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" -// Project includes #include "lldb/Core/Module.h" #include "DWARFDataExtractor.h" diff --git a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp index 8273d975e57d..0f5262d2f454 100644 --- a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -1,18 +1,13 @@ //===-- UniqueDWARFASTType.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "UniqueDWARFASTType.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/Declaration.h" bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die, diff --git a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h index 5d51044cbe1a..bda65e2f375f 100644 --- a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h +++ b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h @@ -1,23 +1,18 @@ //===-- UniqueDWARFASTType.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_UniqueDWARFASTType_h_ #define lldb_UniqueDWARFASTType_h_ -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes #include "DWARFDIE.h" #include "lldb/Symbol/Declaration.h" diff --git a/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt b/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt new file mode 100644 index 000000000000..da2d7fe8108a --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt @@ -0,0 +1,21 @@ +add_lldb_library(lldbPluginSymbolFileNativePDB PLUGIN + CompileUnitIndex.cpp + DWARFLocationExpression.cpp + PdbAstBuilder.cpp + PdbIndex.cpp + PdbSymUid.cpp + PdbUtil.cpp + SymbolFileNativePDB.cpp + UdtRecordCompleter.cpp + + LINK_LIBS + clangAST + clangLex + lldbCore + lldbSymbol + lldbUtility + LINK_COMPONENTS + DebugInfoCodeView + DebugInfoPDB + Support + ) diff --git a/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp new file mode 100644 index 000000000000..c8e530353fe4 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp @@ -0,0 +1,216 @@ +//===-- CompileUnitIndex.cpp ------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "CompileUnitIndex.h" + +#include "PdbIndex.h" +#include "PdbUtil.h" + +#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" +#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" +#include "llvm/DebugInfo/PDB/Native/DbiStream.h" +#include "llvm/DebugInfo/PDB/Native/InfoStream.h" +#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" +#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" +#include "llvm/Support/Path.h" + +#include "lldb/Utility/LLDBAssert.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::npdb; +using namespace llvm::codeview; +using namespace llvm::pdb; + +static bool IsMainFile(llvm::StringRef main, llvm::StringRef other) { + if (main == other) + return true; + + // If the files refer to the local file system, we can just ask the file + // system if they're equivalent. But if the source isn't present on disk + // then we still want to try. + if (llvm::sys::fs::equivalent(main, other)) + return true; + + llvm::SmallString<64> normalized(other); + llvm::sys::path::native(normalized); + return main.equals_lower(normalized); +} + +static void ParseCompile3(const CVSymbol &sym, CompilandIndexItem &cci) { + cci.m_compile_opts.emplace(); + llvm::cantFail( + SymbolDeserializer::deserializeAs(sym, *cci.m_compile_opts)); +} + +static void ParseObjname(const CVSymbol &sym, CompilandIndexItem &cci) { + cci.m_obj_name.emplace(); + llvm::cantFail( + SymbolDeserializer::deserializeAs(sym, *cci.m_obj_name)); +} + +static void ParseBuildInfo(PdbIndex &index, const CVSymbol &sym, + CompilandIndexItem &cci) { + BuildInfoSym bis(SymbolRecordKind::BuildInfoSym); + llvm::cantFail(SymbolDeserializer::deserializeAs(sym, bis)); + + // S_BUILDINFO just points to an LF_BUILDINFO in the IPI stream. Let's do + // a little extra work to pull out the LF_BUILDINFO. + LazyRandomTypeCollection &types = index.ipi().typeCollection(); + llvm::Optional cvt = types.tryGetType(bis.BuildId); + + if (!cvt || cvt->kind() != LF_BUILDINFO) + return; + + BuildInfoRecord bir; + llvm::cantFail(TypeDeserializer::deserializeAs(*cvt, bir)); + cci.m_build_info.assign(bir.ArgIndices.begin(), bir.ArgIndices.end()); +} + +static void ParseExtendedInfo(PdbIndex &index, CompilandIndexItem &item) { + const CVSymbolArray &syms = item.m_debug_stream.getSymbolArray(); + + // This is a private function, it shouldn't be called if the information + // has already been parsed. + lldbassert(!item.m_obj_name); + lldbassert(!item.m_compile_opts); + lldbassert(item.m_build_info.empty()); + + // We're looking for 3 things. S_COMPILE3, S_OBJNAME, and S_BUILDINFO. + int found = 0; + for (const CVSymbol &sym : syms) { + switch (sym.kind()) { + case S_COMPILE3: + ParseCompile3(sym, item); + break; + case S_OBJNAME: + ParseObjname(sym, item); + break; + case S_BUILDINFO: + ParseBuildInfo(index, sym, item); + break; + default: + continue; + } + if (++found >= 3) + break; + } +} + +CompilandIndexItem::CompilandIndexItem( + PdbCompilandId id, llvm::pdb::ModuleDebugStreamRef debug_stream, + llvm::pdb::DbiModuleDescriptor descriptor) + : m_id(id), m_debug_stream(std::move(debug_stream)), + m_module_descriptor(std::move(descriptor)) {} + +CompilandIndexItem &CompileUnitIndex::GetOrCreateCompiland(uint16_t modi) { + auto result = m_comp_units.try_emplace(modi, nullptr); + if (!result.second) + return *result.first->second; + + // Find the module list and load its debug information stream and cache it + // since we need to use it for almost all interesting operations. + const DbiModuleList &modules = m_index.dbi().modules(); + llvm::pdb::DbiModuleDescriptor descriptor = modules.getModuleDescriptor(modi); + uint16_t stream = descriptor.getModuleStreamIndex(); + std::unique_ptr stream_data = + m_index.pdb().createIndexedStream(stream); + llvm::pdb::ModuleDebugStreamRef debug_stream(descriptor, + std::move(stream_data)); + cantFail(debug_stream.reload()); + + std::unique_ptr &cci = result.first->second; + + cci = llvm::make_unique( + PdbCompilandId{modi}, std::move(debug_stream), std::move(descriptor)); + ParseExtendedInfo(m_index, *cci); + + cci->m_strings.initialize(debug_stream.getSubsectionsArray()); + PDBStringTable &strings = cantFail(m_index.pdb().getStringTable()); + cci->m_strings.setStrings(strings.getStringTable()); + + // We want the main source file to always comes first. Note that we can't + // just push_back the main file onto the front because `GetMainSourceFile` + // computes it in such a way that it doesn't own the resulting memory. So we + // have to iterate the module file list comparing each one to the main file + // name until we find it, and we can cache that one since the memory is backed + // by a contiguous chunk inside the mapped PDB. + llvm::SmallString<64> main_file = GetMainSourceFile(*cci); + std::string s = main_file.str(); + llvm::sys::path::native(main_file); + + uint32_t file_count = modules.getSourceFileCount(modi); + cci->m_file_list.reserve(file_count); + bool found_main_file = false; + for (llvm::StringRef file : modules.source_files(modi)) { + if (!found_main_file && IsMainFile(main_file, file)) { + cci->m_file_list.insert(cci->m_file_list.begin(), file); + found_main_file = true; + continue; + } + cci->m_file_list.push_back(file); + } + + return *cci; +} + +const CompilandIndexItem *CompileUnitIndex::GetCompiland(uint16_t modi) const { + auto iter = m_comp_units.find(modi); + if (iter == m_comp_units.end()) + return nullptr; + return iter->second.get(); +} + +CompilandIndexItem *CompileUnitIndex::GetCompiland(uint16_t modi) { + auto iter = m_comp_units.find(modi); + if (iter == m_comp_units.end()) + return nullptr; + return iter->second.get(); +} + +llvm::SmallString<64> +CompileUnitIndex::GetMainSourceFile(const CompilandIndexItem &item) const { + // LF_BUILDINFO contains a list of arg indices which point to LF_STRING_ID + // records in the IPI stream. The order of the arg indices is as follows: + // [0] - working directory where compiler was invoked. + // [1] - absolute path to compiler binary + // [2] - source file name + // [3] - path to compiler generated PDB (the /Zi PDB, although this entry gets + // added even when using /Z7) + // [4] - full command line invocation. + // + // We need to form the path [0]\[2] to generate the full path to the main + // file.source + if (item.m_build_info.size() < 3) + return {""}; + + LazyRandomTypeCollection &types = m_index.ipi().typeCollection(); + + StringIdRecord working_dir; + StringIdRecord file_name; + CVType dir_cvt = types.getType(item.m_build_info[0]); + CVType file_cvt = types.getType(item.m_build_info[2]); + llvm::cantFail( + TypeDeserializer::deserializeAs(dir_cvt, working_dir)); + llvm::cantFail( + TypeDeserializer::deserializeAs(file_cvt, file_name)); + + llvm::sys::path::Style style = working_dir.String.startswith("/") + ? llvm::sys::path::Style::posix + : llvm::sys::path::Style::windows; + if (llvm::sys::path::is_absolute(file_name.String, style)) + return file_name.String; + + llvm::SmallString<64> absolute_path = working_dir.String; + llvm::sys::path::append(absolute_path, file_name.String); + return absolute_path; +} diff --git a/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h new file mode 100644 index 000000000000..44a1c8cdd9c2 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h @@ -0,0 +1,94 @@ +//===-- CompileUnitIndex.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 LLDB_PLUGINS_SYMBOLFILENATIVEPDB_COMPILEUNITINDEX_H +#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_COMPILEUNITINDEX_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/IntervalMap.h" +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" +#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +#include "PdbSymUid.h" + +#include +#include + +namespace lldb_private { + +namespace npdb { +class PdbIndex; + +/// Represents a single compile unit. This class is useful for collecting the +/// important accessors and information about a compile unit from disparate +/// parts of the PDB into a single place, simplifying acess to compile unit +/// information for the callers. +struct CompilandIndexItem { + CompilandIndexItem(PdbCompilandId m_id, + llvm::pdb::ModuleDebugStreamRef debug_stream, + llvm::pdb::DbiModuleDescriptor descriptor); + + // index of this compile unit. + PdbCompilandId m_id; + + // debug stream. + llvm::pdb::ModuleDebugStreamRef m_debug_stream; + + // dbi module descriptor. + llvm::pdb::DbiModuleDescriptor m_module_descriptor; + + llvm::codeview::StringsAndChecksumsRef m_strings; + + // List of files which contribute to this compiland. + std::vector m_file_list; + + // Maps virtual address to global symbol id, which can then be used to + // locate the exact compile unit and offset of the symbol. Note that this + // is intentionally an ordered map so that we can find all symbols up to a + // given starting address. + std::map m_symbols_by_va; + + // S_COMPILE3 sym describing compilation settings for the module. + llvm::Optional m_compile_opts; + + // S_OBJNAME sym describing object name. + llvm::Optional m_obj_name; + + // LF_BUILDINFO sym describing source file name, working directory, + // command line, etc. This usually contains exactly 5 items which + // are references to other strings. + llvm::SmallVector m_build_info; +}; + +/// Indexes information about all compile units. This is really just a map of +/// global compile unit index to |CompilandIndexItem| structures. +class CompileUnitIndex { + PdbIndex &m_index; + llvm::DenseMap> m_comp_units; + +public: + explicit CompileUnitIndex(PdbIndex &index) : m_index(index) {} + + CompilandIndexItem &GetOrCreateCompiland(uint16_t modi); + + const CompilandIndexItem *GetCompiland(uint16_t modi) const; + + CompilandIndexItem *GetCompiland(uint16_t modi); + + llvm::SmallString<64> GetMainSourceFile(const CompilandIndexItem &item) const; +}; +} // namespace npdb +} // namespace lldb_private + +#endif diff --git a/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp new file mode 100644 index 000000000000..e26dabd59753 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp @@ -0,0 +1,672 @@ +//===-- DWARFLocationExpression.cpp -----------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "DWARFLocationExpression.h" + +#include "Plugins/Process/Utility/lldb-x86-register-enums.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/Section.h" +#include "lldb/Core/StreamBuffer.h" +#include "lldb/Expression/DWARFExpression.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" +#include "llvm/Support/Endian.h" + +#include "PdbUtil.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::npdb; +using namespace llvm::codeview; +using namespace llvm::pdb; + +static const uint32_t g_code_view_to_lldb_registers_x86[] = { + LLDB_INVALID_REGNUM, // NONE + lldb_al_i386, // AL + lldb_cl_i386, // CL + lldb_dl_i386, // DL + lldb_bl_i386, // BL + lldb_ah_i386, // AH + lldb_ch_i386, // CH + lldb_dh_i386, // DH + lldb_bh_i386, // BH + lldb_ax_i386, // AX + lldb_cx_i386, // CX + lldb_dx_i386, // DX + lldb_bx_i386, // BX + lldb_sp_i386, // SP + lldb_bp_i386, // BP + lldb_si_i386, // SI + lldb_di_i386, // DI + lldb_eax_i386, // EAX + lldb_ecx_i386, // ECX + lldb_edx_i386, // EDX + lldb_ebx_i386, // EBX + lldb_esp_i386, // ESP + lldb_ebp_i386, // EBP + lldb_esi_i386, // ESI + lldb_edi_i386, // EDI + lldb_es_i386, // ES + lldb_cs_i386, // CS + lldb_ss_i386, // SS + lldb_ds_i386, // DS + lldb_fs_i386, // FS + lldb_gs_i386, // GS + LLDB_INVALID_REGNUM, // IP + LLDB_INVALID_REGNUM, // FLAGS + lldb_eip_i386, // EIP + lldb_eflags_i386, // EFLAGS + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // TEMP + LLDB_INVALID_REGNUM, // TEMPH + LLDB_INVALID_REGNUM, // QUOTE + LLDB_INVALID_REGNUM, // PCDR3 + LLDB_INVALID_REGNUM, // PCDR4 + LLDB_INVALID_REGNUM, // PCDR5 + LLDB_INVALID_REGNUM, // PCDR6 + LLDB_INVALID_REGNUM, // PCDR7 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // CR0 + LLDB_INVALID_REGNUM, // CR1 + LLDB_INVALID_REGNUM, // CR2 + LLDB_INVALID_REGNUM, // CR3 + LLDB_INVALID_REGNUM, // CR4 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_dr0_i386, // DR0 + lldb_dr1_i386, // DR1 + lldb_dr2_i386, // DR2 + lldb_dr3_i386, // DR3 + lldb_dr4_i386, // DR4 + lldb_dr5_i386, // DR5 + lldb_dr6_i386, // DR6 + lldb_dr7_i386, // DR7 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // GDTR + LLDB_INVALID_REGNUM, // GDTL + LLDB_INVALID_REGNUM, // IDTR + LLDB_INVALID_REGNUM, // IDTL + LLDB_INVALID_REGNUM, // LDTR + LLDB_INVALID_REGNUM, // TR + LLDB_INVALID_REGNUM, // PSEUDO1 + LLDB_INVALID_REGNUM, // PSEUDO2 + LLDB_INVALID_REGNUM, // PSEUDO3 + LLDB_INVALID_REGNUM, // PSEUDO4 + LLDB_INVALID_REGNUM, // PSEUDO5 + LLDB_INVALID_REGNUM, // PSEUDO6 + LLDB_INVALID_REGNUM, // PSEUDO7 + LLDB_INVALID_REGNUM, // PSEUDO8 + LLDB_INVALID_REGNUM, // PSEUDO9 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_st0_i386, // ST0 + lldb_st1_i386, // ST1 + lldb_st2_i386, // ST2 + lldb_st3_i386, // ST3 + lldb_st4_i386, // ST4 + lldb_st5_i386, // ST5 + lldb_st6_i386, // ST6 + lldb_st7_i386, // ST7 + LLDB_INVALID_REGNUM, // CTRL + LLDB_INVALID_REGNUM, // STAT + LLDB_INVALID_REGNUM, // TAG + LLDB_INVALID_REGNUM, // FPIP + LLDB_INVALID_REGNUM, // FPCS + LLDB_INVALID_REGNUM, // FPDO + LLDB_INVALID_REGNUM, // FPDS + LLDB_INVALID_REGNUM, // ISEM + LLDB_INVALID_REGNUM, // FPEIP + LLDB_INVALID_REGNUM, // FPEDO + lldb_mm0_i386, // MM0 + lldb_mm1_i386, // MM1 + lldb_mm2_i386, // MM2 + lldb_mm3_i386, // MM3 + lldb_mm4_i386, // MM4 + lldb_mm5_i386, // MM5 + lldb_mm6_i386, // MM6 + lldb_mm7_i386, // MM7 + lldb_xmm0_i386, // XMM0 + lldb_xmm1_i386, // XMM1 + lldb_xmm2_i386, // XMM2 + lldb_xmm3_i386, // XMM3 + lldb_xmm4_i386, // XMM4 + lldb_xmm5_i386, // XMM5 + lldb_xmm6_i386, // XMM6 + lldb_xmm7_i386 // XMM7 +}; + +static const uint32_t g_code_view_to_lldb_registers_x86_64[] = { + LLDB_INVALID_REGNUM, // NONE + lldb_al_x86_64, // AL + lldb_cl_x86_64, // CL + lldb_dl_x86_64, // DL + lldb_bl_x86_64, // BL + lldb_ah_x86_64, // AH + lldb_ch_x86_64, // CH + lldb_dh_x86_64, // DH + lldb_bh_x86_64, // BH + lldb_ax_x86_64, // AX + lldb_cx_x86_64, // CX + lldb_dx_x86_64, // DX + lldb_bx_x86_64, // BX + lldb_sp_x86_64, // SP + lldb_bp_x86_64, // BP + lldb_si_x86_64, // SI + lldb_di_x86_64, // DI + lldb_eax_x86_64, // EAX + lldb_ecx_x86_64, // ECX + lldb_edx_x86_64, // EDX + lldb_ebx_x86_64, // EBX + lldb_esp_x86_64, // ESP + lldb_ebp_x86_64, // EBP + lldb_esi_x86_64, // ESI + lldb_edi_x86_64, // EDI + lldb_es_x86_64, // ES + lldb_cs_x86_64, // CS + lldb_ss_x86_64, // SS + lldb_ds_x86_64, // DS + lldb_fs_x86_64, // FS + lldb_gs_x86_64, // GS + LLDB_INVALID_REGNUM, // IP + LLDB_INVALID_REGNUM, // FLAGS + LLDB_INVALID_REGNUM, // EIP + LLDB_INVALID_REGNUM, // EFLAGS + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // TEMP + LLDB_INVALID_REGNUM, // TEMPH + LLDB_INVALID_REGNUM, // QUOTE + LLDB_INVALID_REGNUM, // PCDR3 + LLDB_INVALID_REGNUM, // PCDR4 + LLDB_INVALID_REGNUM, // PCDR5 + LLDB_INVALID_REGNUM, // PCDR6 + LLDB_INVALID_REGNUM, // PCDR7 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // CR0 + LLDB_INVALID_REGNUM, // CR1 + LLDB_INVALID_REGNUM, // CR2 + LLDB_INVALID_REGNUM, // CR3 + LLDB_INVALID_REGNUM, // CR4 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_dr0_x86_64, // DR0 + lldb_dr1_x86_64, // DR1 + lldb_dr2_x86_64, // DR2 + lldb_dr3_x86_64, // DR3 + lldb_dr4_x86_64, // DR4 + lldb_dr5_x86_64, // DR5 + lldb_dr6_x86_64, // DR6 + lldb_dr7_x86_64, // DR7 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // GDTR + LLDB_INVALID_REGNUM, // GDTL + LLDB_INVALID_REGNUM, // IDTR + LLDB_INVALID_REGNUM, // IDTL + LLDB_INVALID_REGNUM, // LDTR + LLDB_INVALID_REGNUM, // TR + LLDB_INVALID_REGNUM, // PSEUDO1 + LLDB_INVALID_REGNUM, // PSEUDO2 + LLDB_INVALID_REGNUM, // PSEUDO3 + LLDB_INVALID_REGNUM, // PSEUDO4 + LLDB_INVALID_REGNUM, // PSEUDO5 + LLDB_INVALID_REGNUM, // PSEUDO6 + LLDB_INVALID_REGNUM, // PSEUDO7 + LLDB_INVALID_REGNUM, // PSEUDO8 + LLDB_INVALID_REGNUM, // PSEUDO9 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_st0_x86_64, // ST0 + lldb_st1_x86_64, // ST1 + lldb_st2_x86_64, // ST2 + lldb_st3_x86_64, // ST3 + lldb_st4_x86_64, // ST4 + lldb_st5_x86_64, // ST5 + lldb_st6_x86_64, // ST6 + lldb_st7_x86_64, // ST7 + LLDB_INVALID_REGNUM, // CTRL + LLDB_INVALID_REGNUM, // STAT + LLDB_INVALID_REGNUM, // TAG + LLDB_INVALID_REGNUM, // FPIP + LLDB_INVALID_REGNUM, // FPCS + LLDB_INVALID_REGNUM, // FPDO + LLDB_INVALID_REGNUM, // FPDS + LLDB_INVALID_REGNUM, // ISEM + LLDB_INVALID_REGNUM, // FPEIP + LLDB_INVALID_REGNUM, // FPEDO + lldb_mm0_x86_64, // MM0 + lldb_mm1_x86_64, // MM1 + lldb_mm2_x86_64, // MM2 + lldb_mm3_x86_64, // MM3 + lldb_mm4_x86_64, // MM4 + lldb_mm5_x86_64, // MM5 + lldb_mm6_x86_64, // MM6 + lldb_mm7_x86_64, // MM7 + lldb_xmm0_x86_64, // XMM0 + lldb_xmm1_x86_64, // XMM1 + lldb_xmm2_x86_64, // XMM2 + lldb_xmm3_x86_64, // XMM3 + lldb_xmm4_x86_64, // XMM4 + lldb_xmm5_x86_64, // XMM5 + lldb_xmm6_x86_64, // XMM6 + lldb_xmm7_x86_64, // XMM7 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, + lldb_mxcsr_x86_64, // MXCSR + LLDB_INVALID_REGNUM, // EDXEAX + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // EMM0L + LLDB_INVALID_REGNUM, // EMM1L + LLDB_INVALID_REGNUM, // EMM2L + LLDB_INVALID_REGNUM, // EMM3L + LLDB_INVALID_REGNUM, // EMM4L + LLDB_INVALID_REGNUM, // EMM5L + LLDB_INVALID_REGNUM, // EMM6L + LLDB_INVALID_REGNUM, // EMM7L + LLDB_INVALID_REGNUM, // EMM0H + LLDB_INVALID_REGNUM, // EMM1H + LLDB_INVALID_REGNUM, // EMM2H + LLDB_INVALID_REGNUM, // EMM3H + LLDB_INVALID_REGNUM, // EMM4H + LLDB_INVALID_REGNUM, // EMM5H + LLDB_INVALID_REGNUM, // EMM6H + LLDB_INVALID_REGNUM, // EMM7H + LLDB_INVALID_REGNUM, // MM00 + LLDB_INVALID_REGNUM, // MM01 + LLDB_INVALID_REGNUM, // MM10 + LLDB_INVALID_REGNUM, // MM11 + LLDB_INVALID_REGNUM, // MM20 + LLDB_INVALID_REGNUM, // MM21 + LLDB_INVALID_REGNUM, // MM30 + LLDB_INVALID_REGNUM, // MM31 + LLDB_INVALID_REGNUM, // MM40 + LLDB_INVALID_REGNUM, // MM41 + LLDB_INVALID_REGNUM, // MM50 + LLDB_INVALID_REGNUM, // MM51 + LLDB_INVALID_REGNUM, // MM60 + LLDB_INVALID_REGNUM, // MM61 + LLDB_INVALID_REGNUM, // MM70 + LLDB_INVALID_REGNUM, // MM71 + lldb_xmm8_x86_64, // XMM8 + lldb_xmm9_x86_64, // XMM9 + lldb_xmm10_x86_64, // XMM10 + lldb_xmm11_x86_64, // XMM11 + lldb_xmm12_x86_64, // XMM12 + lldb_xmm13_x86_64, // XMM13 + lldb_xmm14_x86_64, // XMM14 + lldb_xmm15_x86_64, // XMM15 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, + lldb_sil_x86_64, // SIL + lldb_dil_x86_64, // DIL + lldb_bpl_x86_64, // BPL + lldb_spl_x86_64, // SPL + lldb_rax_x86_64, // RAX + lldb_rbx_x86_64, // RBX + lldb_rcx_x86_64, // RCX + lldb_rdx_x86_64, // RDX + lldb_rsi_x86_64, // RSI + lldb_rdi_x86_64, // RDI + lldb_rbp_x86_64, // RBP + lldb_rsp_x86_64, // RSP + lldb_r8_x86_64, // R8 + lldb_r9_x86_64, // R9 + lldb_r10_x86_64, // R10 + lldb_r11_x86_64, // R11 + lldb_r12_x86_64, // R12 + lldb_r13_x86_64, // R13 + lldb_r14_x86_64, // R14 + lldb_r15_x86_64, // R15 + lldb_r8l_x86_64, // R8B + lldb_r9l_x86_64, // R9B + lldb_r10l_x86_64, // R10B + lldb_r11l_x86_64, // R11B + lldb_r12l_x86_64, // R12B + lldb_r13l_x86_64, // R13B + lldb_r14l_x86_64, // R14B + lldb_r15l_x86_64, // R15B + lldb_r8w_x86_64, // R8W + lldb_r9w_x86_64, // R9W + lldb_r10w_x86_64, // R10W + lldb_r11w_x86_64, // R11W + lldb_r12w_x86_64, // R12W + lldb_r13w_x86_64, // R13W + lldb_r14w_x86_64, // R14W + lldb_r15w_x86_64, // R15W + lldb_r8d_x86_64, // R8D + lldb_r9d_x86_64, // R9D + lldb_r10d_x86_64, // R10D + lldb_r11d_x86_64, // R11D + lldb_r12d_x86_64, // R12D + lldb_r13d_x86_64, // R13D + lldb_r14d_x86_64, // R14D + lldb_r15d_x86_64, // R15D + lldb_ymm0_x86_64, // AMD64_YMM0 + lldb_ymm1_x86_64, // AMD64_YMM1 + lldb_ymm2_x86_64, // AMD64_YMM2 + lldb_ymm3_x86_64, // AMD64_YMM3 + lldb_ymm4_x86_64, // AMD64_YMM4 + lldb_ymm5_x86_64, // AMD64_YMM5 + lldb_ymm6_x86_64, // AMD64_YMM6 + lldb_ymm7_x86_64, // AMD64_YMM7 + lldb_ymm8_x86_64, // AMD64_YMM8 + lldb_ymm9_x86_64, // AMD64_YMM9 + lldb_ymm10_x86_64, // AMD64_YMM10 + lldb_ymm11_x86_64, // AMD64_YMM11 + lldb_ymm12_x86_64, // AMD64_YMM12 + lldb_ymm13_x86_64, // AMD64_YMM13 + lldb_ymm14_x86_64, // AMD64_YMM14 + lldb_ymm15_x86_64, // AMD64_YMM15 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_bnd0_x86_64, // BND0 + lldb_bnd1_x86_64, // BND1 + lldb_bnd2_x86_64 // BND2 +}; + +uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type, + llvm::codeview::RegisterId register_id) { + switch (arch_type) { + case llvm::Triple::x86: + if (static_cast(register_id) < + sizeof(g_code_view_to_lldb_registers_x86) / + sizeof(g_code_view_to_lldb_registers_x86[0])) + return g_code_view_to_lldb_registers_x86[static_cast( + register_id)]; + + switch (register_id) { + case llvm::codeview::RegisterId::MXCSR: + return lldb_mxcsr_i386; + case llvm::codeview::RegisterId::BND0: + return lldb_bnd0_i386; + case llvm::codeview::RegisterId::BND1: + return lldb_bnd1_i386; + case llvm::codeview::RegisterId::BND2: + return lldb_bnd2_i386; + default: + return LLDB_INVALID_REGNUM; + } + case llvm::Triple::x86_64: + if (static_cast(register_id) < + sizeof(g_code_view_to_lldb_registers_x86_64) / + sizeof(g_code_view_to_lldb_registers_x86_64[0])) + return g_code_view_to_lldb_registers_x86_64[static_cast( + register_id)]; + + return LLDB_INVALID_REGNUM; + default: + return LLDB_INVALID_REGNUM; + } +} + +uint32_t GetGenericRegisterNumber(llvm::codeview::RegisterId register_id) { + if (register_id == llvm::codeview::RegisterId::VFRAME) + return LLDB_REGNUM_GENERIC_FP; + + return LLDB_INVALID_REGNUM; +} + +static uint32_t GetRegisterNumber(llvm::Triple::ArchType arch_type, + llvm::codeview::RegisterId register_id, + RegisterKind ®ister_kind) { + register_kind = eRegisterKindLLDB; + uint32_t reg_num = GetLLDBRegisterNumber(arch_type, register_id); + if (reg_num != LLDB_INVALID_REGNUM) + return reg_num; + + register_kind = eRegisterKindGeneric; + return GetGenericRegisterNumber(register_id); +} + +static bool IsSimpleTypeSignedInteger(SimpleTypeKind kind) { + switch (kind) { + case SimpleTypeKind::Int128: + case SimpleTypeKind::Int64: + case SimpleTypeKind::Int64Quad: + case SimpleTypeKind::Int32: + case SimpleTypeKind::Int32Long: + case SimpleTypeKind::Int16: + case SimpleTypeKind::Int16Short: + case SimpleTypeKind::Float128: + case SimpleTypeKind::Float80: + case SimpleTypeKind::Float64: + case SimpleTypeKind::Float32: + case SimpleTypeKind::Float16: + case SimpleTypeKind::NarrowCharacter: + case SimpleTypeKind::SignedCharacter: + case SimpleTypeKind::SByte: + return true; + default: + return false; + } +} + +static std::pair GetIntegralTypeInfo(TypeIndex ti, + TpiStream &tpi) { + if (ti.isSimple()) { + SimpleTypeKind stk = ti.getSimpleKind(); + return {GetTypeSizeForSimpleKind(stk), IsSimpleTypeSignedInteger(stk)}; + } + + CVType cvt = tpi.getType(ti); + switch (cvt.kind()) { + case LF_MODIFIER: { + ModifierRecord mfr; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, mfr)); + return GetIntegralTypeInfo(mfr.ModifiedType, tpi); + } + case LF_POINTER: { + PointerRecord pr; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, pr)); + return GetIntegralTypeInfo(pr.ReferentType, tpi); + } + case LF_ENUM: { + EnumRecord er; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, er)); + return GetIntegralTypeInfo(er.UnderlyingType, tpi); + } + default: + assert(false && "Type is not integral!"); + return {0, false}; + } +} + +template +static DWARFExpression MakeLocationExpressionInternal(lldb::ModuleSP module, + StreamWriter &&writer) { + const ArchSpec &architecture = module->GetArchitecture(); + ByteOrder byte_order = architecture.GetByteOrder(); + uint32_t address_size = architecture.GetAddressByteSize(); + uint32_t byte_size = architecture.GetDataByteSize(); + if (byte_order == eByteOrderInvalid || address_size == 0) + return DWARFExpression(nullptr); + + RegisterKind register_kind = eRegisterKindDWARF; + StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order); + + if (!writer(stream, register_kind)) + return DWARFExpression(nullptr); + + DataBufferSP buffer = + std::make_shared(stream.GetData(), stream.GetSize()); + DataExtractor extractor(buffer, byte_order, address_size, byte_size); + DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize()); + result.SetRegisterKind(register_kind); + + return result; +} + +static DWARFExpression MakeRegisterBasedLocationExpressionInternal( + llvm::codeview::RegisterId reg, llvm::Optional relative_offset, + lldb::ModuleSP module) { + return MakeLocationExpressionInternal( + module, [&](Stream &stream, RegisterKind ®ister_kind) -> bool { + uint32_t reg_num = GetRegisterNumber( + module->GetArchitecture().GetMachine(), reg, register_kind); + if (reg_num == LLDB_INVALID_REGNUM) + return false; + + if (reg_num > 31) { + llvm::dwarf::LocationAtom base = relative_offset + ? llvm::dwarf::DW_OP_bregx + : llvm::dwarf::DW_OP_regx; + stream.PutHex8(base); + stream.PutULEB128(reg_num); + } else { + llvm::dwarf::LocationAtom base = relative_offset + ? llvm::dwarf::DW_OP_breg0 + : llvm::dwarf::DW_OP_reg0; + stream.PutHex8(base + reg_num); + } + + if (relative_offset) + stream.PutSLEB128(*relative_offset); + + return true; + }); +} + +DWARFExpression lldb_private::npdb::MakeEnregisteredLocationExpression( + llvm::codeview::RegisterId reg, lldb::ModuleSP module) { + return MakeRegisterBasedLocationExpressionInternal(reg, llvm::None, module); +} + +DWARFExpression lldb_private::npdb::MakeRegRelLocationExpression( + llvm::codeview::RegisterId reg, int32_t offset, lldb::ModuleSP module) { + return MakeRegisterBasedLocationExpressionInternal(reg, offset, module); +} + +DWARFExpression lldb_private::npdb::MakeGlobalLocationExpression( + uint16_t section, uint32_t offset, ModuleSP module) { + assert(section > 0); + assert(module); + + return MakeLocationExpressionInternal( + module, [&](Stream &stream, RegisterKind ®ister_kind) -> bool { + stream.PutHex8(llvm::dwarf::DW_OP_addr); + + SectionList *section_list = module->GetSectionList(); + assert(section_list); + + // Section indices in PDB are 1-based, but in DWARF they are 0-based, so + // we need to subtract 1. + uint32_t section_idx = section - 1; + if (section_idx >= section_list->GetSize()) + return false; + + auto section_ptr = section_list->GetSectionAtIndex(section_idx); + if (!section_ptr) + return false; + + stream.PutMaxHex64(section_ptr->GetFileAddress() + offset, + stream.GetAddressByteSize(), stream.GetByteOrder()); + + return true; + }); +} + +DWARFExpression lldb_private::npdb::MakeConstantLocationExpression( + TypeIndex underlying_ti, TpiStream &tpi, const llvm::APSInt &constant, + ModuleSP module) { + const ArchSpec &architecture = module->GetArchitecture(); + uint32_t address_size = architecture.GetAddressByteSize(); + + size_t size = 0; + bool is_signed = false; + std::tie(size, is_signed) = GetIntegralTypeInfo(underlying_ti, tpi); + + union { + llvm::support::little64_t I; + llvm::support::ulittle64_t U; + } Value; + + std::shared_ptr buffer = std::make_shared(); + buffer->SetByteSize(size); + + llvm::ArrayRef bytes; + if (is_signed) { + Value.I = constant.getSExtValue(); + } else { + Value.U = constant.getZExtValue(); + } + + bytes = llvm::makeArrayRef(reinterpret_cast(&Value), 8) + .take_front(size); + buffer->CopyData(bytes.data(), size); + DataExtractor extractor(buffer, lldb::eByteOrderLittle, address_size); + DWARFExpression result(nullptr, extractor, nullptr, 0, size); + return result; +} diff --git a/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h new file mode 100644 index 000000000000..e714712e5bf7 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h @@ -0,0 +1,41 @@ +//===-- DWARFLocationExpression.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 LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_DWARFLOCATIONEXPRESSION_H +#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_DWARFLOCATIONEXPRESSION_H + +#include "lldb/lldb-forward.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" + +namespace llvm { +class APSInt; +namespace codeview { +class TypeIndex; +} +namespace pdb { +class TpiStream; +} +} // namespace llvm +namespace lldb_private { +namespace npdb { +DWARFExpression +MakeEnregisteredLocationExpression(llvm::codeview::RegisterId reg, + lldb::ModuleSP module); + +DWARFExpression MakeRegRelLocationExpression(llvm::codeview::RegisterId reg, + int32_t offset, + lldb::ModuleSP module); +DWARFExpression MakeGlobalLocationExpression(uint16_t section, uint32_t offset, + lldb::ModuleSP module); +DWARFExpression MakeConstantLocationExpression( + llvm::codeview::TypeIndex underlying_ti, llvm::pdb::TpiStream &tpi, + const llvm::APSInt &constant, lldb::ModuleSP module); +} // namespace npdb +} // namespace lldb_private + +#endif diff --git a/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp new file mode 100644 index 000000000000..6e5640c1ea0c --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -0,0 +1,1356 @@ +#include "PdbAstBuilder.h" + +#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" +#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" +#include "llvm/DebugInfo/CodeView/RecordName.h" +#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h" +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/DebugInfo/PDB/Native/DbiStream.h" +#include "llvm/DebugInfo/PDB/Native/PublicsStream.h" +#include "llvm/DebugInfo/PDB/Native/SymbolStream.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" +#include "llvm/Demangle/MicrosoftDemangle.h" + +#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h" +#include "lldb/Core/Module.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" +#include "lldb/Symbol/ClangUtil.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Utility/LLDBAssert.h" + +#include "PdbUtil.h" +#include "UdtRecordCompleter.h" + +using namespace lldb_private; +using namespace lldb_private::npdb; +using namespace llvm::codeview; +using namespace llvm::pdb; + +static llvm::Optional FindSymbolScope(PdbIndex &index, + PdbCompilandSymId id) { + CVSymbol sym = index.ReadSymbolRecord(id); + if (symbolOpensScope(sym.kind())) { + // If this exact symbol opens a scope, we can just directly access its + // parent. + id.offset = getScopeParentOffset(sym); + // Global symbols have parent offset of 0. Return llvm::None to indicate + // this. + if (id.offset == 0) + return llvm::None; + return id; + } + + // Otherwise we need to start at the beginning and iterate forward until we + // reach (or pass) this particular symbol + CompilandIndexItem &cii = index.compilands().GetOrCreateCompiland(id.modi); + const CVSymbolArray &syms = cii.m_debug_stream.getSymbolArray(); + + auto begin = syms.begin(); + auto end = syms.at(id.offset); + std::vector scope_stack; + + while (begin != end) { + if (id.offset == begin.offset()) { + // We have a match! Return the top of the stack + if (scope_stack.empty()) + return llvm::None; + return scope_stack.back(); + } + if (begin.offset() > id.offset) { + // We passed it. We couldn't even find this symbol record. + lldbassert(false && "Invalid compiland symbol id!"); + return llvm::None; + } + + // We haven't found the symbol yet. Check if we need to open or close the + // scope stack. + if (symbolOpensScope(begin->kind())) { + // We can use the end offset of the scope to determine whether or not + // we can just outright skip this entire scope. + uint32_t scope_end = getScopeEndOffset(*begin); + if (scope_end < id.modi) { + begin = syms.at(scope_end); + } else { + // The symbol we're looking for is somewhere in this scope. + scope_stack.emplace_back(id.modi, begin.offset()); + } + } else if (symbolEndsScope(begin->kind())) { + scope_stack.pop_back(); + } + ++begin; + } + + return llvm::None; +} + +static clang::TagTypeKind TranslateUdtKind(const TagRecord &cr) { + switch (cr.Kind) { + case TypeRecordKind::Class: + return clang::TTK_Class; + case TypeRecordKind::Struct: + return clang::TTK_Struct; + case TypeRecordKind::Union: + return clang::TTK_Union; + case TypeRecordKind::Interface: + return clang::TTK_Interface; + case TypeRecordKind::Enum: + return clang::TTK_Enum; + default: + lldbassert(false && "Invalid tag record kind!"); + return clang::TTK_Struct; + } +} + +static bool IsCVarArgsFunction(llvm::ArrayRef args) { + if (args.empty()) + return false; + return args.back() == TypeIndex::None(); +} + +static bool +AnyScopesHaveTemplateParams(llvm::ArrayRef scopes) { + for (llvm::ms_demangle::Node *n : scopes) { + auto *idn = static_cast(n); + if (idn->TemplateParams) + return true; + } + return false; +} + +static ClangASTContext &GetClangASTContext(ObjectFile &obj) { + TypeSystem *ts = + obj.GetModule()->GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + lldbassert(ts); + return static_cast(*ts); +} + +static llvm::Optional +TranslateCallingConvention(llvm::codeview::CallingConvention conv) { + using CC = llvm::codeview::CallingConvention; + switch (conv) { + + case CC::NearC: + case CC::FarC: + return clang::CallingConv::CC_C; + case CC::NearPascal: + case CC::FarPascal: + return clang::CallingConv::CC_X86Pascal; + case CC::NearFast: + case CC::FarFast: + return clang::CallingConv::CC_X86FastCall; + case CC::NearStdCall: + case CC::FarStdCall: + return clang::CallingConv::CC_X86StdCall; + case CC::ThisCall: + return clang::CallingConv::CC_X86ThisCall; + case CC::NearVector: + return clang::CallingConv::CC_X86VectorCall; + default: + return llvm::None; + } +} + +static llvm::Optional +GetNestedTagDefinition(const NestedTypeRecord &Record, + const CVTagRecord &parent, TpiStream &tpi) { + // An LF_NESTTYPE is essentially a nested typedef / using declaration, but it + // is also used to indicate the primary definition of a nested class. That is + // to say, if you have: + // struct A { + // struct B {}; + // using C = B; + // }; + // Then in the debug info, this will appear as: + // LF_STRUCTURE `A::B` [type index = N] + // LF_STRUCTURE `A` + // LF_NESTTYPE [name = `B`, index = N] + // LF_NESTTYPE [name = `C`, index = N] + // In order to accurately reconstruct the decl context hierarchy, we need to + // know which ones are actual definitions and which ones are just aliases. + + // If it's a simple type, then this is something like `using foo = int`. + if (Record.Type.isSimple()) + return llvm::None; + + CVType cvt = tpi.getType(Record.Type); + + if (!IsTagRecord(cvt)) + return llvm::None; + + // If it's an inner definition, then treat whatever name we have here as a + // single component of a mangled name. So we can inject it into the parent's + // mangled name to see if it matches. + CVTagRecord child = CVTagRecord::create(cvt); + std::string qname = parent.asTag().getUniqueName(); + if (qname.size() < 4 || child.asTag().getUniqueName().size() < 4) + return llvm::None; + + // qname[3] is the tag type identifier (struct, class, union, etc). Since the + // inner tag type is not necessarily the same as the outer tag type, re-write + // it to match the inner tag type. + qname[3] = child.asTag().getUniqueName()[3]; + std::string piece; + if (qname[3] == 'W') + piece = "4"; + piece += Record.Name; + piece.push_back('@'); + qname.insert(4, std::move(piece)); + if (qname != child.asTag().UniqueName) + return llvm::None; + + return std::move(child); +} + +PdbAstBuilder::PdbAstBuilder(ObjectFile &obj, PdbIndex &index) + : m_index(index), m_clang(GetClangASTContext(obj)) { + BuildParentMap(); +} + +clang::DeclContext &PdbAstBuilder::GetTranslationUnitDecl() { + return *m_clang.GetTranslationUnitDecl(); +} + +std::pair +PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) { + // FIXME: Move this to GetDeclContextContainingUID. + if (!record.hasUniqueName()) + return CreateDeclInfoForUndecoratedName(record.Name); + + llvm::ms_demangle::Demangler demangler; + StringView sv(record.UniqueName.begin(), record.UniqueName.size()); + llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv); + if (demangler.Error) + return {m_clang.GetTranslationUnitDecl(), record.UniqueName}; + + llvm::ms_demangle::IdentifierNode *idn = + ttn->QualifiedName->getUnqualifiedIdentifier(); + std::string uname = idn->toString(llvm::ms_demangle::OF_NoTagSpecifier); + + llvm::ms_demangle::NodeArrayNode *name_components = + ttn->QualifiedName->Components; + llvm::ArrayRef scopes(name_components->Nodes, + name_components->Count - 1); + + clang::DeclContext *context = m_clang.GetTranslationUnitDecl(); + + // If this type doesn't have a parent type in the debug info, then the best we + // can do is to say that it's either a series of namespaces (if the scope is + // non-empty), or the translation unit (if the scope is empty). + auto parent_iter = m_parent_types.find(ti); + if (parent_iter == m_parent_types.end()) { + if (scopes.empty()) + return {context, uname}; + + // If there is no parent in the debug info, but some of the scopes have + // template params, then this is a case of bad debug info. See, for + // example, llvm.org/pr39607. We don't want to create an ambiguity between + // a NamespaceDecl and a CXXRecordDecl, so instead we create a class at + // global scope with the fully qualified name. + if (AnyScopesHaveTemplateParams(scopes)) + return {context, record.Name}; + + for (llvm::ms_demangle::Node *scope : scopes) { + auto *nii = static_cast(scope); + std::string str = nii->toString(); + context = m_clang.GetUniqueNamespaceDeclaration(str.c_str(), context); + } + return {context, uname}; + } + + // Otherwise, all we need to do is get the parent type of this type and + // recurse into our lazy type creation / AST reconstruction logic to get an + // LLDB TypeSP for the parent. This will cause the AST to automatically get + // the right DeclContext created for any parent. + clang::QualType parent_qt = GetOrCreateType(parent_iter->second); + + context = clang::TagDecl::castToDeclContext(parent_qt->getAsTagDecl()); + return {context, uname}; +} + +void PdbAstBuilder::BuildParentMap() { + LazyRandomTypeCollection &types = m_index.tpi().typeCollection(); + + llvm::DenseMap forward_to_full; + llvm::DenseMap full_to_forward; + + struct RecordIndices { + TypeIndex forward; + TypeIndex full; + }; + + llvm::StringMap record_indices; + + for (auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) { + CVType type = types.getType(*ti); + if (!IsTagRecord(type)) + continue; + + CVTagRecord tag = CVTagRecord::create(type); + + RecordIndices &indices = record_indices[tag.asTag().getUniqueName()]; + if (tag.asTag().isForwardRef()) + indices.forward = *ti; + else + indices.full = *ti; + + if (indices.full != TypeIndex::None() && + indices.forward != TypeIndex::None()) { + forward_to_full[indices.forward] = indices.full; + full_to_forward[indices.full] = indices.forward; + } + + // We're looking for LF_NESTTYPE records in the field list, so ignore + // forward references (no field list), and anything without a nested class + // (since there won't be any LF_NESTTYPE records). + if (tag.asTag().isForwardRef() || !tag.asTag().containsNestedClass()) + continue; + + struct ProcessTpiStream : public TypeVisitorCallbacks { + ProcessTpiStream(PdbIndex &index, TypeIndex parent, + const CVTagRecord &parent_cvt, + llvm::DenseMap &parents) + : index(index), parents(parents), parent(parent), + parent_cvt(parent_cvt) {} + + PdbIndex &index; + llvm::DenseMap &parents; + + unsigned unnamed_type_index = 1; + TypeIndex parent; + const CVTagRecord &parent_cvt; + + llvm::Error visitKnownMember(CVMemberRecord &CVR, + NestedTypeRecord &Record) override { + std::string unnamed_type_name; + if (Record.Name.empty()) { + unnamed_type_name = + llvm::formatv("", unnamed_type_index).str(); + Record.Name = unnamed_type_name; + ++unnamed_type_index; + } + llvm::Optional tag = + GetNestedTagDefinition(Record, parent_cvt, index.tpi()); + if (!tag) + return llvm::ErrorSuccess(); + + parents[Record.Type] = parent; + return llvm::ErrorSuccess(); + } + }; + + CVType field_list = m_index.tpi().getType(tag.asTag().FieldList); + ProcessTpiStream process(m_index, *ti, tag, m_parent_types); + llvm::Error error = visitMemberRecordStream(field_list.data(), process); + if (error) + llvm::consumeError(std::move(error)); + } + + // Now that we know the forward -> full mapping of all type indices, we can + // re-write all the indices. At the end of this process, we want a mapping + // consisting of fwd -> full and full -> full for all child -> parent indices. + // We can re-write the values in place, but for the keys, we must save them + // off so that we don't modify the map in place while also iterating it. + std::vector full_keys; + std::vector fwd_keys; + for (auto &entry : m_parent_types) { + TypeIndex key = entry.first; + TypeIndex value = entry.second; + + auto iter = forward_to_full.find(value); + if (iter != forward_to_full.end()) + entry.second = iter->second; + + iter = forward_to_full.find(key); + if (iter != forward_to_full.end()) + fwd_keys.push_back(key); + else + full_keys.push_back(key); + } + for (TypeIndex fwd : fwd_keys) { + TypeIndex full = forward_to_full[fwd]; + m_parent_types[full] = m_parent_types[fwd]; + } + for (TypeIndex full : full_keys) { + TypeIndex fwd = full_to_forward[full]; + m_parent_types[fwd] = m_parent_types[full]; + } + + // Now that +} + +static bool isLocalVariableType(SymbolKind K) { + switch (K) { + case S_REGISTER: + case S_REGREL32: + case S_LOCAL: + return true; + default: + break; + } + return false; +} + +static std::string +RenderScopeList(llvm::ArrayRef nodes) { + lldbassert(!nodes.empty()); + + std::string result = nodes.front()->toString(); + nodes = nodes.drop_front(); + while (!nodes.empty()) { + result += "::"; + result += nodes.front()->toString(llvm::ms_demangle::OF_NoTagSpecifier); + nodes = nodes.drop_front(); + } + return result; +} + +static llvm::Optional FindPublicSym(const SegmentOffset &addr, + SymbolStream &syms, + PublicsStream &publics) { + llvm::FixedStreamArray addr_map = publics.getAddressMap(); + auto iter = std::lower_bound( + addr_map.begin(), addr_map.end(), addr, + [&](const ulittle32_t &x, const SegmentOffset &y) { + CVSymbol s1 = syms.readRecord(x); + lldbassert(s1.kind() == S_PUB32); + PublicSym32 p1; + llvm::cantFail(SymbolDeserializer::deserializeAs(s1, p1)); + if (p1.Segment < y.segment) + return true; + return p1.Offset < y.offset; + }); + if (iter == addr_map.end()) + return llvm::None; + CVSymbol sym = syms.readRecord(*iter); + lldbassert(sym.kind() == S_PUB32); + PublicSym32 p; + llvm::cantFail(SymbolDeserializer::deserializeAs(sym, p)); + if (p.Segment == addr.segment && p.Offset == addr.offset) + return p; + return llvm::None; +} + +clang::Decl *PdbAstBuilder::GetOrCreateSymbolForId(PdbCompilandSymId id) { + CVSymbol cvs = m_index.ReadSymbolRecord(id); + + if (isLocalVariableType(cvs.kind())) { + clang::DeclContext *scope = GetParentDeclContext(id); + clang::Decl *scope_decl = clang::Decl::castFromDeclContext(scope); + PdbCompilandSymId scope_id(id.modi, m_decl_to_status[scope_decl].uid); + return GetOrCreateVariableDecl(scope_id, id); + } + + switch (cvs.kind()) { + case S_GPROC32: + case S_LPROC32: + return GetOrCreateFunctionDecl(id); + case S_GDATA32: + case S_LDATA32: + case S_GTHREAD32: + case S_CONSTANT: + // global variable + return nullptr; + case S_BLOCK32: + return GetOrCreateBlockDecl(id); + default: + return nullptr; + } +} + +clang::Decl *PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid) { + if (clang::Decl *result = TryGetDecl(uid)) + return result; + + clang::Decl *result = nullptr; + switch (uid.kind()) { + case PdbSymUidKind::CompilandSym: + result = GetOrCreateSymbolForId(uid.asCompilandSym()); + break; + case PdbSymUidKind::Type: { + clang::QualType qt = GetOrCreateType(uid.asTypeSym()); + if (auto *tag = qt->getAsTagDecl()) { + result = tag; + break; + } + return nullptr; + } + default: + return nullptr; + } + m_uid_to_decl[toOpaqueUid(uid)] = result; + return result; +} + +clang::DeclContext *PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) { + if (uid.kind() == PdbSymUidKind::CompilandSym) { + if (uid.asCompilandSym().offset == 0) + return &GetTranslationUnitDecl(); + } + + clang::Decl *decl = GetOrCreateDeclForUid(uid); + if (!decl) + return nullptr; + + return clang::Decl::castToDeclContext(decl); +} + +std::pair +PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) { + MSVCUndecoratedNameParser parser(name); + llvm::ArrayRef specs = parser.GetSpecifiers(); + + clang::DeclContext *context = &GetTranslationUnitDecl(); + + llvm::StringRef uname = specs.back().GetBaseName(); + specs = specs.drop_back(); + if (specs.empty()) + return {context, name}; + + llvm::StringRef scope_name = specs.back().GetFullName(); + + // It might be a class name, try that first. + std::vector types = m_index.tpi().findRecordsByName(scope_name); + while (!types.empty()) { + clang::QualType qt = GetOrCreateType(types.back()); + clang::TagDecl *tag = qt->getAsTagDecl(); + if (tag) + return {clang::TagDecl::castToDeclContext(tag), uname}; + types.pop_back(); + } + + // If that fails, treat it as a series of namespaces. + for (const MSVCUndecoratedNameSpecifier &spec : specs) { + std::string ns_name = spec.GetBaseName().str(); + context = m_clang.GetUniqueNamespaceDeclaration(ns_name.c_str(), context); + } + return {context, uname}; +} + +clang::DeclContext * +PdbAstBuilder::GetParentDeclContextForSymbol(const CVSymbol &sym) { + if (!SymbolHasAddress(sym)) + return CreateDeclInfoForUndecoratedName(getSymbolName(sym)).first; + SegmentOffset addr = GetSegmentAndOffset(sym); + llvm::Optional pub = + FindPublicSym(addr, m_index.symrecords(), m_index.publics()); + if (!pub) + return CreateDeclInfoForUndecoratedName(getSymbolName(sym)).first; + + llvm::ms_demangle::Demangler demangler; + StringView name{pub->Name.begin(), pub->Name.size()}; + llvm::ms_demangle::SymbolNode *node = demangler.parse(name); + if (!node) + return &GetTranslationUnitDecl(); + llvm::ArrayRef name_components{ + node->Name->Components->Nodes, node->Name->Components->Count - 1}; + + if (!name_components.empty()) { + // Render the current list of scope nodes as a fully qualified name, and + // look it up in the debug info as a type name. If we find something, + // this is a type (which may itself be prefixed by a namespace). If we + // don't, this is a list of namespaces. + std::string qname = RenderScopeList(name_components); + std::vector matches = m_index.tpi().findRecordsByName(qname); + while (!matches.empty()) { + clang::QualType qt = GetOrCreateType(matches.back()); + clang::TagDecl *tag = qt->getAsTagDecl(); + if (tag) + return clang::TagDecl::castToDeclContext(tag); + matches.pop_back(); + } + } + + // It's not a type. It must be a series of namespaces. + clang::DeclContext *context = &GetTranslationUnitDecl(); + while (!name_components.empty()) { + std::string ns = name_components.front()->toString(); + context = m_clang.GetUniqueNamespaceDeclaration(ns.c_str(), context); + name_components = name_components.drop_front(); + } + return context; +} + +clang::DeclContext *PdbAstBuilder::GetParentDeclContext(PdbSymUid uid) { + // We must do this *without* calling GetOrCreate on the current uid, as + // that would be an infinite recursion. + switch (uid.kind()) { + case PdbSymUidKind::CompilandSym: { + llvm::Optional scope = + FindSymbolScope(m_index, uid.asCompilandSym()); + if (scope) + return GetOrCreateDeclContextForUid(*scope); + + CVSymbol sym = m_index.ReadSymbolRecord(uid.asCompilandSym()); + return GetParentDeclContextForSymbol(sym); + } + case PdbSymUidKind::Type: { + // It could be a namespace, class, or global. We don't support nested + // functions yet. Anyway, we just need to consult the parent type map. + PdbTypeSymId type_id = uid.asTypeSym(); + auto iter = m_parent_types.find(type_id.index); + if (iter == m_parent_types.end()) + return &GetTranslationUnitDecl(); + return GetOrCreateDeclContextForUid(PdbTypeSymId(iter->second)); + } + case PdbSymUidKind::FieldListMember: + // In this case the parent DeclContext is the one for the class that this + // member is inside of. + break; + case PdbSymUidKind::GlobalSym: { + // If this refers to a compiland symbol, just recurse in with that symbol. + // The only other possibilities are S_CONSTANT and S_UDT, in which case we + // need to parse the undecorated name to figure out the scope, then look + // that up in the TPI stream. If it's found, it's a type, othewrise it's + // a series of namespaces. + // FIXME: do this. + CVSymbol global = m_index.ReadSymbolRecord(uid.asGlobalSym()); + switch (global.kind()) { + case SymbolKind::S_GDATA32: + case SymbolKind::S_LDATA32: + return GetParentDeclContextForSymbol(global); + case SymbolKind::S_PROCREF: + case SymbolKind::S_LPROCREF: { + ProcRefSym ref{global.kind()}; + llvm::cantFail( + SymbolDeserializer::deserializeAs(global, ref)); + PdbCompilandSymId cu_sym_id{ref.modi(), ref.SymOffset}; + return GetParentDeclContext(cu_sym_id); + } + case SymbolKind::S_CONSTANT: + case SymbolKind::S_UDT: + return CreateDeclInfoForUndecoratedName(getSymbolName(global)).first; + default: + break; + } + break; + } + default: + break; + } + return &GetTranslationUnitDecl(); +} + +bool PdbAstBuilder::CompleteType(clang::QualType qt) { + clang::TagDecl *tag = qt->getAsTagDecl(); + if (!tag) + return false; + + return CompleteTagDecl(*tag); +} + +bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) { + // If this is not in our map, it's an error. + auto status_iter = m_decl_to_status.find(&tag); + lldbassert(status_iter != m_decl_to_status.end()); + + // If it's already complete, just return. + DeclStatus &status = status_iter->second; + if (status.resolved) + return true; + + PdbTypeSymId type_id = PdbSymUid(status.uid).asTypeSym(); + + lldbassert(IsTagRecord(type_id, m_index.tpi())); + + clang::QualType tag_qt = m_clang.getASTContext()->getTypeDeclType(&tag); + ClangASTContext::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false); + + TypeIndex tag_ti = type_id.index; + CVType cvt = m_index.tpi().getType(tag_ti); + if (cvt.kind() == LF_MODIFIER) + tag_ti = LookThroughModifierRecord(cvt); + + PdbTypeSymId best_ti = GetBestPossibleDecl(tag_ti, m_index.tpi()); + cvt = m_index.tpi().getType(best_ti.index); + lldbassert(IsTagRecord(cvt)); + + if (IsForwardRefUdt(cvt)) { + // If we can't find a full decl for this forward ref anywhere in the debug + // info, then we have no way to complete it. + return false; + } + + TypeIndex field_list_ti = GetFieldListIndex(cvt); + CVType field_list_cvt = m_index.tpi().getType(field_list_ti); + if (field_list_cvt.kind() != LF_FIELDLIST) + return false; + + // Visit all members of this class, then perform any finalization necessary + // to complete the class. + CompilerType ct = ToCompilerType(tag_qt); + UdtRecordCompleter completer(best_ti, ct, tag, *this, m_index.tpi()); + auto error = + llvm::codeview::visitMemberRecordStream(field_list_cvt.data(), completer); + completer.complete(); + + status.resolved = true; + if (!error) + return true; + + llvm::consumeError(std::move(error)); + return false; +} + +clang::QualType PdbAstBuilder::CreateSimpleType(TypeIndex ti) { + if (ti == TypeIndex::NullptrT()) + return GetBasicType(lldb::eBasicTypeNullPtr); + + if (ti.getSimpleMode() != SimpleTypeMode::Direct) { + clang::QualType direct_type = GetOrCreateType(ti.makeDirect()); + return m_clang.getASTContext()->getPointerType(direct_type); + } + + if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated) + return {}; + + lldb::BasicType bt = GetCompilerTypeForSimpleKind(ti.getSimpleKind()); + if (bt == lldb::eBasicTypeInvalid) + return {}; + + return GetBasicType(bt); +} + +clang::QualType PdbAstBuilder::CreatePointerType(const PointerRecord &pointer) { + clang::QualType pointee_type = GetOrCreateType(pointer.ReferentType); + + // This can happen for pointers to LF_VTSHAPE records, which we shouldn't + // create in the AST. + if (pointee_type.isNull()) + return {}; + + if (pointer.isPointerToMember()) { + MemberPointerInfo mpi = pointer.getMemberInfo(); + clang::QualType class_type = GetOrCreateType(mpi.ContainingType); + + return m_clang.getASTContext()->getMemberPointerType( + pointee_type, class_type.getTypePtr()); + } + + clang::QualType pointer_type; + if (pointer.getMode() == PointerMode::LValueReference) + pointer_type = + m_clang.getASTContext()->getLValueReferenceType(pointee_type); + else if (pointer.getMode() == PointerMode::RValueReference) + pointer_type = + m_clang.getASTContext()->getRValueReferenceType(pointee_type); + else + pointer_type = m_clang.getASTContext()->getPointerType(pointee_type); + + if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None) + pointer_type.addConst(); + + if ((pointer.getOptions() & PointerOptions::Volatile) != PointerOptions::None) + pointer_type.addVolatile(); + + if ((pointer.getOptions() & PointerOptions::Restrict) != PointerOptions::None) + pointer_type.addRestrict(); + + return pointer_type; +} + +clang::QualType +PdbAstBuilder::CreateModifierType(const ModifierRecord &modifier) { + clang::QualType unmodified_type = GetOrCreateType(modifier.ModifiedType); + if (unmodified_type.isNull()) + return {}; + + if ((modifier.Modifiers & ModifierOptions::Const) != ModifierOptions::None) + unmodified_type.addConst(); + if ((modifier.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None) + unmodified_type.addVolatile(); + + return unmodified_type; +} + +clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id, + const TagRecord &record) { + clang::DeclContext *context = nullptr; + std::string uname; + std::tie(context, uname) = CreateDeclInfoForType(record, id.index); + clang::TagTypeKind ttk = TranslateUdtKind(record); + lldb::AccessType access = + (ttk == clang::TTK_Class) ? lldb::eAccessPrivate : lldb::eAccessPublic; + + ClangASTMetadata metadata; + metadata.SetUserID(toOpaqueUid(id)); + metadata.SetIsDynamicCXXType(false); + + CompilerType ct = + m_clang.CreateRecordType(context, access, uname.c_str(), ttk, + lldb::eLanguageTypeC_plus_plus, &metadata); + + lldbassert(ct.IsValid()); + + ClangASTContext::StartTagDeclarationDefinition(ct); + + // Even if it's possible, don't complete it at this point. Just mark it + // forward resolved, and if/when LLDB needs the full definition, it can + // ask us. + clang::QualType result = + clang::QualType::getFromOpaquePtr(ct.GetOpaqueQualType()); + + ClangASTContext::SetHasExternalStorage(result.getAsOpaquePtr(), true); + return result; +} + +clang::Decl *PdbAstBuilder::TryGetDecl(PdbSymUid uid) const { + auto iter = m_uid_to_decl.find(toOpaqueUid(uid)); + if (iter != m_uid_to_decl.end()) + return iter->second; + return nullptr; +} + +clang::NamespaceDecl * +PdbAstBuilder::GetOrCreateNamespaceDecl(llvm::StringRef name, + clang::DeclContext &context) { + return m_clang.GetUniqueNamespaceDeclaration(name.str().c_str(), &context); +} + +clang::BlockDecl * +PdbAstBuilder::GetOrCreateBlockDecl(PdbCompilandSymId block_id) { + if (clang::Decl *decl = TryGetDecl(block_id)) + return llvm::dyn_cast(decl); + + clang::DeclContext *scope = GetParentDeclContext(block_id); + + clang::BlockDecl *block_decl = m_clang.CreateBlockDeclaration(scope); + m_uid_to_decl.insert({toOpaqueUid(block_id), block_decl}); + + DeclStatus status; + status.resolved = true; + status.uid = toOpaqueUid(block_id); + m_decl_to_status.insert({block_decl, status}); + + return block_decl; +} + +clang::VarDecl *PdbAstBuilder::CreateVariableDecl(PdbSymUid uid, CVSymbol sym, + clang::DeclContext &scope) { + VariableInfo var_info = GetVariableNameInfo(sym); + clang::QualType qt = GetOrCreateType(var_info.type); + + clang::VarDecl *var_decl = m_clang.CreateVariableDeclaration( + &scope, var_info.name.str().c_str(), qt); + + m_uid_to_decl[toOpaqueUid(uid)] = var_decl; + DeclStatus status; + status.resolved = true; + status.uid = toOpaqueUid(uid); + m_decl_to_status.insert({var_decl, status}); + return var_decl; +} + +clang::VarDecl * +PdbAstBuilder::GetOrCreateVariableDecl(PdbCompilandSymId scope_id, + PdbCompilandSymId var_id) { + if (clang::Decl *decl = TryGetDecl(var_id)) + return llvm::dyn_cast(decl); + + clang::DeclContext *scope = GetOrCreateDeclContextForUid(scope_id); + + CVSymbol sym = m_index.ReadSymbolRecord(var_id); + return CreateVariableDecl(PdbSymUid(var_id), sym, *scope); +} + +clang::VarDecl *PdbAstBuilder::GetOrCreateVariableDecl(PdbGlobalSymId var_id) { + if (clang::Decl *decl = TryGetDecl(var_id)) + return llvm::dyn_cast(decl); + + CVSymbol sym = m_index.ReadSymbolRecord(var_id); + return CreateVariableDecl(PdbSymUid(var_id), sym, GetTranslationUnitDecl()); +} + +clang::TypedefNameDecl * +PdbAstBuilder::GetOrCreateTypedefDecl(PdbGlobalSymId id) { + if (clang::Decl *decl = TryGetDecl(id)) + return llvm::dyn_cast(decl); + + CVSymbol sym = m_index.ReadSymbolRecord(id); + lldbassert(sym.kind() == S_UDT); + UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs(sym)); + + clang::DeclContext *scope = GetParentDeclContext(id); + + PdbTypeSymId real_type_id{udt.Type, false}; + clang::QualType qt = GetOrCreateType(real_type_id); + + std::string uname = DropNameScope(udt.Name); + + CompilerType ct = m_clang.CreateTypedefType(ToCompilerType(qt), uname.c_str(), + ToCompilerDeclContext(*scope)); + clang::TypedefNameDecl *tnd = m_clang.GetAsTypedefDecl(ct); + DeclStatus status; + status.resolved = true; + status.uid = toOpaqueUid(id); + m_decl_to_status.insert({tnd, status}); + return tnd; +} + +clang::QualType PdbAstBuilder::GetBasicType(lldb::BasicType type) { + CompilerType ct = m_clang.GetBasicType(type); + return clang::QualType::getFromOpaquePtr(ct.GetOpaqueQualType()); +} + +clang::QualType PdbAstBuilder::CreateType(PdbTypeSymId type) { + if (type.index.isSimple()) + return CreateSimpleType(type.index); + + CVType cvt = m_index.tpi().getType(type.index); + + if (cvt.kind() == LF_MODIFIER) { + ModifierRecord modifier; + llvm::cantFail( + TypeDeserializer::deserializeAs(cvt, modifier)); + return CreateModifierType(modifier); + } + + if (cvt.kind() == LF_POINTER) { + PointerRecord pointer; + llvm::cantFail( + TypeDeserializer::deserializeAs(cvt, pointer)); + return CreatePointerType(pointer); + } + + if (IsTagRecord(cvt)) { + CVTagRecord tag = CVTagRecord::create(cvt); + if (tag.kind() == CVTagRecord::Union) + return CreateRecordType(type.index, tag.asUnion()); + if (tag.kind() == CVTagRecord::Enum) + return CreateEnumType(type.index, tag.asEnum()); + return CreateRecordType(type.index, tag.asClass()); + } + + if (cvt.kind() == LF_ARRAY) { + ArrayRecord ar; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, ar)); + return CreateArrayType(ar); + } + + if (cvt.kind() == LF_PROCEDURE) { + ProcedureRecord pr; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, pr)); + return CreateFunctionType(pr.ArgumentList, pr.ReturnType, pr.CallConv); + } + + if (cvt.kind() == LF_MFUNCTION) { + MemberFunctionRecord mfr; + llvm::cantFail( + TypeDeserializer::deserializeAs(cvt, mfr)); + return CreateFunctionType(mfr.ArgumentList, mfr.ReturnType, mfr.CallConv); + } + + return {}; +} + +clang::QualType PdbAstBuilder::GetOrCreateType(PdbTypeSymId type) { + lldb::user_id_t uid = toOpaqueUid(type); + auto iter = m_uid_to_type.find(uid); + if (iter != m_uid_to_type.end()) + return iter->second; + + PdbTypeSymId best_type = GetBestPossibleDecl(type, m_index.tpi()); + + clang::QualType qt; + if (best_type.index != type.index) { + // This is a forward decl. Call GetOrCreate on the full decl, then map the + // forward decl id to the full decl QualType. + clang::QualType qt = GetOrCreateType(best_type); + m_uid_to_type[toOpaqueUid(type)] = qt; + return qt; + } + + // This is either a full decl, or a forward decl with no matching full decl + // in the debug info. + qt = CreateType(type); + m_uid_to_type[toOpaqueUid(type)] = qt; + if (IsTagRecord(type, m_index.tpi())) { + clang::TagDecl *tag = qt->getAsTagDecl(); + lldbassert(m_decl_to_status.count(tag) == 0); + + DeclStatus &status = m_decl_to_status[tag]; + status.uid = uid; + status.resolved = false; + } + return qt; +} + +clang::FunctionDecl * +PdbAstBuilder::GetOrCreateFunctionDecl(PdbCompilandSymId func_id) { + if (clang::Decl *decl = TryGetDecl(func_id)) + return llvm::dyn_cast(decl); + + clang::DeclContext *parent = GetParentDeclContext(PdbSymUid(func_id)); + std::string context_name; + if (clang::NamespaceDecl *ns = llvm::dyn_cast(parent)) { + context_name = ns->getQualifiedNameAsString(); + } else if (clang::TagDecl *tag = llvm::dyn_cast(parent)) { + context_name = tag->getQualifiedNameAsString(); + } + + CVSymbol cvs = m_index.ReadSymbolRecord(func_id); + ProcSym proc(static_cast(cvs.kind())); + llvm::cantFail(SymbolDeserializer::deserializeAs(cvs, proc)); + + PdbTypeSymId type_id(proc.FunctionType); + clang::QualType qt = GetOrCreateType(type_id); + if (qt.isNull()) + return nullptr; + + clang::StorageClass storage = clang::SC_None; + if (proc.Kind == SymbolRecordKind::ProcSym) + storage = clang::SC_Static; + + const clang::FunctionProtoType *func_type = + llvm::dyn_cast(qt); + + CompilerType func_ct = ToCompilerType(qt); + + llvm::StringRef proc_name = proc.Name; + proc_name.consume_front(context_name); + proc_name.consume_front("::"); + + clang::FunctionDecl *function_decl = m_clang.CreateFunctionDeclaration( + parent, proc_name.str().c_str(), func_ct, storage, false); + + lldbassert(m_uid_to_decl.count(toOpaqueUid(func_id)) == 0); + m_uid_to_decl[toOpaqueUid(func_id)] = function_decl; + DeclStatus status; + status.resolved = true; + status.uid = toOpaqueUid(func_id); + m_decl_to_status.insert({function_decl, status}); + + CreateFunctionParameters(func_id, *function_decl, func_type->getNumParams()); + + return function_decl; +} + +void PdbAstBuilder::CreateFunctionParameters(PdbCompilandSymId func_id, + clang::FunctionDecl &function_decl, + uint32_t param_count) { + CompilandIndexItem *cii = m_index.compilands().GetCompiland(func_id.modi); + CVSymbolArray scope = + cii->m_debug_stream.getSymbolArrayForScope(func_id.offset); + + auto begin = scope.begin(); + auto end = scope.end(); + std::vector params; + while (begin != end && param_count > 0) { + uint32_t record_offset = begin.offset(); + CVSymbol sym = *begin++; + + TypeIndex param_type; + llvm::StringRef param_name; + switch (sym.kind()) { + case S_REGREL32: { + RegRelativeSym reg(SymbolRecordKind::RegRelativeSym); + cantFail(SymbolDeserializer::deserializeAs(sym, reg)); + param_type = reg.Type; + param_name = reg.Name; + break; + } + case S_REGISTER: { + RegisterSym reg(SymbolRecordKind::RegisterSym); + cantFail(SymbolDeserializer::deserializeAs(sym, reg)); + param_type = reg.Index; + param_name = reg.Name; + break; + } + case S_LOCAL: { + LocalSym local(SymbolRecordKind::LocalSym); + cantFail(SymbolDeserializer::deserializeAs(sym, local)); + if ((local.Flags & LocalSymFlags::IsParameter) == LocalSymFlags::None) + continue; + param_type = local.Type; + param_name = local.Name; + break; + } + case S_BLOCK32: + // All parameters should come before the first block. If that isn't the + // case, then perhaps this is bad debug info that doesn't contain + // information about all parameters. + return; + default: + continue; + } + + PdbCompilandSymId param_uid(func_id.modi, record_offset); + clang::QualType qt = GetOrCreateType(param_type); + + CompilerType param_type_ct(&m_clang, qt.getAsOpaquePtr()); + clang::ParmVarDecl *param = m_clang.CreateParameterDeclaration( + &function_decl, param_name.str().c_str(), param_type_ct, + clang::SC_None); + lldbassert(m_uid_to_decl.count(toOpaqueUid(param_uid)) == 0); + + m_uid_to_decl[toOpaqueUid(param_uid)] = param; + params.push_back(param); + --param_count; + } + + if (!params.empty()) + m_clang.SetFunctionParameters(&function_decl, params.data(), params.size()); +} + +clang::QualType PdbAstBuilder::CreateEnumType(PdbTypeSymId id, + const EnumRecord &er) { + clang::DeclContext *decl_context = nullptr; + std::string uname; + std::tie(decl_context, uname) = CreateDeclInfoForType(er, id.index); + clang::QualType underlying_type = GetOrCreateType(er.UnderlyingType); + + Declaration declaration; + CompilerType enum_ct = m_clang.CreateEnumerationType( + uname.c_str(), decl_context, declaration, ToCompilerType(underlying_type), + er.isScoped()); + + ClangASTContext::StartTagDeclarationDefinition(enum_ct); + ClangASTContext::SetHasExternalStorage(enum_ct.GetOpaqueQualType(), true); + + return clang::QualType::getFromOpaquePtr(enum_ct.GetOpaqueQualType()); +} + +clang::QualType PdbAstBuilder::CreateArrayType(const ArrayRecord &ar) { + clang::QualType element_type = GetOrCreateType(ar.ElementType); + + uint64_t element_count = + ar.Size / GetSizeOfType({ar.ElementType}, m_index.tpi()); + + CompilerType array_ct = m_clang.CreateArrayType(ToCompilerType(element_type), + element_count, false); + return clang::QualType::getFromOpaquePtr(array_ct.GetOpaqueQualType()); +} + +clang::QualType PdbAstBuilder::CreateFunctionType( + TypeIndex args_type_idx, TypeIndex return_type_idx, + llvm::codeview::CallingConvention calling_convention) { + TpiStream &stream = m_index.tpi(); + CVType args_cvt = stream.getType(args_type_idx); + ArgListRecord args; + llvm::cantFail( + TypeDeserializer::deserializeAs(args_cvt, args)); + + llvm::ArrayRef arg_indices = llvm::makeArrayRef(args.ArgIndices); + bool is_variadic = IsCVarArgsFunction(arg_indices); + if (is_variadic) + arg_indices = arg_indices.drop_back(); + + std::vector arg_types; + arg_types.reserve(arg_indices.size()); + + for (TypeIndex arg_index : arg_indices) { + clang::QualType arg_type = GetOrCreateType(arg_index); + arg_types.push_back(ToCompilerType(arg_type)); + } + + clang::QualType return_type = GetOrCreateType(return_type_idx); + + llvm::Optional cc = + TranslateCallingConvention(calling_convention); + if (!cc) + return {}; + + CompilerType return_ct = ToCompilerType(return_type); + CompilerType func_sig_ast_type = m_clang.CreateFunctionType( + return_ct, arg_types.data(), arg_types.size(), is_variadic, 0, *cc); + + return clang::QualType::getFromOpaquePtr( + func_sig_ast_type.GetOpaqueQualType()); +} + +static bool isTagDecl(clang::DeclContext &context) { + return !!llvm::dyn_cast(&context); +} + +static bool isFunctionDecl(clang::DeclContext &context) { + return !!llvm::dyn_cast(&context); +} + +static bool isBlockDecl(clang::DeclContext &context) { + return !!llvm::dyn_cast(&context); +} + +void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf( + llvm::Optional parent) { + TypeIndex ti{m_index.tpi().TypeIndexBegin()}; + for (const CVType &cvt : m_index.tpi().typeArray()) { + PdbTypeSymId tid{ti}; + ++ti; + + if (!IsTagRecord(cvt)) + continue; + + CVTagRecord tag = CVTagRecord::create(cvt); + + if (!parent.hasValue()) { + clang::QualType qt = GetOrCreateType(tid); + CompleteType(qt); + continue; + } + + // Call CreateDeclInfoForType unconditionally so that the namespace info + // gets created. But only call CreateRecordType if the namespace name + // matches. + clang::DeclContext *context = nullptr; + std::string uname; + std::tie(context, uname) = CreateDeclInfoForType(tag.asTag(), tid.index); + if (!context->isNamespace()) + continue; + + clang::NamespaceDecl *ns = llvm::dyn_cast(context); + std::string actual_ns = ns->getQualifiedNameAsString(); + if (llvm::StringRef(actual_ns).startswith(*parent)) { + clang::QualType qt = GetOrCreateType(tid); + CompleteType(qt); + continue; + } + } + + uint32_t module_count = m_index.dbi().modules().getModuleCount(); + for (uint16_t modi = 0; modi < module_count; ++modi) { + CompilandIndexItem &cii = m_index.compilands().GetOrCreateCompiland(modi); + const CVSymbolArray &symbols = cii.m_debug_stream.getSymbolArray(); + auto iter = symbols.begin(); + while (iter != symbols.end()) { + PdbCompilandSymId sym_id{modi, iter.offset()}; + + switch (iter->kind()) { + case S_GPROC32: + case S_LPROC32: + GetOrCreateFunctionDecl(sym_id); + iter = symbols.at(getScopeEndOffset(*iter)); + break; + case S_GDATA32: + case S_GTHREAD32: + case S_LDATA32: + case S_LTHREAD32: + GetOrCreateVariableDecl(PdbCompilandSymId(modi, 0), sym_id); + ++iter; + break; + default: + ++iter; + continue; + } + } + } +} + +static CVSymbolArray skipFunctionParameters(clang::Decl &decl, + const CVSymbolArray &symbols) { + clang::FunctionDecl *func_decl = llvm::dyn_cast(&decl); + if (!func_decl) + return symbols; + unsigned int params = func_decl->getNumParams(); + if (params == 0) + return symbols; + + CVSymbolArray result = symbols; + + while (!result.empty()) { + if (params == 0) + return result; + + CVSymbol sym = *result.begin(); + result.drop_front(); + + if (!isLocalVariableType(sym.kind())) + continue; + + --params; + } + return result; +} + +void PdbAstBuilder::ParseBlockChildren(PdbCompilandSymId block_id) { + CVSymbol sym = m_index.ReadSymbolRecord(block_id); + lldbassert(sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32 || + sym.kind() == S_BLOCK32); + CompilandIndexItem &cii = + m_index.compilands().GetOrCreateCompiland(block_id.modi); + CVSymbolArray symbols = + cii.m_debug_stream.getSymbolArrayForScope(block_id.offset); + + // Function parameters should already have been created when the function was + // parsed. + if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32) + symbols = + skipFunctionParameters(*m_uid_to_decl[toOpaqueUid(block_id)], symbols); + + auto begin = symbols.begin(); + while (begin != symbols.end()) { + PdbCompilandSymId child_sym_id(block_id.modi, begin.offset()); + GetOrCreateSymbolForId(child_sym_id); + if (begin->kind() == S_BLOCK32) { + ParseBlockChildren(child_sym_id); + begin = symbols.at(getScopeEndOffset(*begin)); + } + ++begin; + } +} + +void PdbAstBuilder::ParseDeclsForSimpleContext(clang::DeclContext &context) { + + clang::Decl *decl = clang::Decl::castFromDeclContext(&context); + lldbassert(decl); + + auto iter = m_decl_to_status.find(decl); + lldbassert(iter != m_decl_to_status.end()); + + if (auto *tag = llvm::dyn_cast(&context)) { + CompleteTagDecl(*tag); + return; + } + + if (isFunctionDecl(context) || isBlockDecl(context)) { + PdbCompilandSymId block_id = PdbSymUid(iter->second.uid).asCompilandSym(); + ParseBlockChildren(block_id); + } +} + +void PdbAstBuilder::ParseDeclsForContext(clang::DeclContext &context) { + // Namespaces aren't explicitly represented in the debug info, and the only + // way to parse them is to parse all type info, demangling every single type + // and trying to reconstruct the DeclContext hierarchy this way. Since this + // is an expensive operation, we have to special case it so that we do other + // work (such as parsing the items that appear within the namespaces) at the + // same time. + if (context.isTranslationUnit()) { + ParseAllNamespacesPlusChildrenOf(llvm::None); + return; + } + + if (context.isNamespace()) { + clang::NamespaceDecl &ns = *llvm::dyn_cast(&context); + std::string qname = ns.getQualifiedNameAsString(); + ParseAllNamespacesPlusChildrenOf(llvm::StringRef{qname}); + return; + } + + if (isTagDecl(context) || isFunctionDecl(context) || isBlockDecl(context)) { + ParseDeclsForSimpleContext(context); + return; + } +} + +CompilerDecl PdbAstBuilder::ToCompilerDecl(clang::Decl &decl) { + return {&m_clang, &decl}; +} + +CompilerType PdbAstBuilder::ToCompilerType(clang::QualType qt) { + return {&m_clang, qt.getAsOpaquePtr()}; +} + +CompilerDeclContext +PdbAstBuilder::ToCompilerDeclContext(clang::DeclContext &context) { + return {&m_clang, &context}; +} + +clang::DeclContext * +PdbAstBuilder::FromCompilerDeclContext(CompilerDeclContext context) { + return static_cast(context.GetOpaqueDeclContext()); +} + +void PdbAstBuilder::Dump(Stream &stream) { m_clang.Dump(stream); } diff --git a/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h new file mode 100644 index 000000000000..761d11bf2739 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h @@ -0,0 +1,144 @@ +//===-- PdbAstBuilder.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 LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H +#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" + +#include "lldb/Symbol/ClangASTImporter.h" + +#include "PdbIndex.h" +#include "PdbSymUid.h" + +namespace clang { +class TagDecl; +class DeclContext; +class Decl; +class QualType; +class FunctionDecl; +class NamespaceDecl; +} // namespace clang + +namespace llvm { +namespace codeview { +class ProcSym; +} +} // namespace llvm + +namespace lldb_private { +class ClangASTImporter; +class ObjectFile; + +namespace npdb { +class PdbIndex; +struct VariableInfo; + +struct DeclStatus { + DeclStatus() = default; + DeclStatus(lldb::user_id_t uid, bool resolved) + : uid(uid), resolved(resolved) {} + lldb::user_id_t uid = 0; + bool resolved = false; +}; + +class PdbAstBuilder { +public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + PdbAstBuilder(ObjectFile &obj, PdbIndex &index); + + clang::DeclContext &GetTranslationUnitDecl(); + + clang::Decl *GetOrCreateDeclForUid(PdbSymUid uid); + clang::DeclContext *GetOrCreateDeclContextForUid(PdbSymUid uid); + clang::DeclContext *GetParentDeclContext(PdbSymUid uid); + + clang::NamespaceDecl *GetOrCreateNamespaceDecl(llvm::StringRef name, + clang::DeclContext &context); + clang::FunctionDecl *GetOrCreateFunctionDecl(PdbCompilandSymId func_id); + clang::BlockDecl *GetOrCreateBlockDecl(PdbCompilandSymId block_id); + clang::VarDecl *GetOrCreateVariableDecl(PdbCompilandSymId scope_id, + PdbCompilandSymId var_id); + clang::VarDecl *GetOrCreateVariableDecl(PdbGlobalSymId var_id); + clang::TypedefNameDecl *GetOrCreateTypedefDecl(PdbGlobalSymId id); + void ParseDeclsForContext(clang::DeclContext &context); + + clang::QualType GetBasicType(lldb::BasicType type); + clang::QualType GetOrCreateType(PdbTypeSymId type); + + bool CompleteTagDecl(clang::TagDecl &tag); + bool CompleteType(clang::QualType qt); + + CompilerDecl ToCompilerDecl(clang::Decl &decl); + CompilerType ToCompilerType(clang::QualType qt); + CompilerDeclContext ToCompilerDeclContext(clang::DeclContext &context); + clang::DeclContext *FromCompilerDeclContext(CompilerDeclContext context); + + ClangASTContext &clang() { return m_clang; } + ClangASTImporter &importer() { return m_importer; } + + void Dump(Stream &stream); + +private: + clang::Decl *TryGetDecl(PdbSymUid uid) const; + + using TypeIndex = llvm::codeview::TypeIndex; + + clang::QualType + CreatePointerType(const llvm::codeview::PointerRecord &pointer); + clang::QualType + CreateModifierType(const llvm::codeview::ModifierRecord &modifier); + clang::QualType CreateArrayType(const llvm::codeview::ArrayRecord &array); + clang::QualType CreateRecordType(PdbTypeSymId id, + const llvm::codeview::TagRecord &record); + clang::QualType CreateEnumType(PdbTypeSymId id, + const llvm::codeview::EnumRecord &record); + clang::QualType + CreateFunctionType(TypeIndex args_type_idx, TypeIndex return_type_idx, + llvm::codeview::CallingConvention calling_convention); + clang::QualType CreateType(PdbTypeSymId type); + + void CreateFunctionParameters(PdbCompilandSymId func_id, + clang::FunctionDecl &function_decl, + uint32_t param_count); + clang::Decl *GetOrCreateSymbolForId(PdbCompilandSymId id); + clang::VarDecl *CreateVariableDecl(PdbSymUid uid, + llvm::codeview::CVSymbol sym, + clang::DeclContext &scope); + clang::DeclContext * + GetParentDeclContextForSymbol(const llvm::codeview::CVSymbol &sym); + + void ParseAllNamespacesPlusChildrenOf(llvm::Optional parent); + void ParseDeclsForSimpleContext(clang::DeclContext &context); + void ParseBlockChildren(PdbCompilandSymId block_id); + + void BuildParentMap(); + std::pair + CreateDeclInfoForType(const llvm::codeview::TagRecord &record, TypeIndex ti); + std::pair + CreateDeclInfoForUndecoratedName(llvm::StringRef uname); + clang::QualType CreateSimpleType(TypeIndex ti); + + PdbIndex &m_index; + ClangASTContext &m_clang; + + ClangASTImporter m_importer; + + llvm::DenseMap m_parent_types; + llvm::DenseMap m_decl_to_status; + llvm::DenseMap m_uid_to_decl; + llvm::DenseMap m_uid_to_type; +}; + +} // namespace npdb +} // namespace lldb_private + +#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_ diff --git a/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp b/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp new file mode 100644 index 000000000000..31a31be57283 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp @@ -0,0 +1,199 @@ +//===-- PdbIndex.cpp --------------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "PdbIndex.h" +#include "PdbUtil.h" + +#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" +#include "llvm/DebugInfo/PDB/Native/DbiStream.h" +#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" +#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h" +#include "llvm/DebugInfo/PDB/Native/PDBFile.h" +#include "llvm/DebugInfo/PDB/Native/PublicsStream.h" +#include "llvm/DebugInfo/PDB/Native/SymbolStream.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" +#include "llvm/Object/COFF.h" +#include "llvm/Support/Error.h" + +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/lldb-defines.h" + +using namespace lldb_private; +using namespace lldb_private::npdb; +using namespace llvm::codeview; +using namespace llvm::pdb; + +PdbIndex::PdbIndex() : m_cus(*this), m_va_to_modi(m_allocator) {} + +#define ASSIGN_PTR_OR_RETURN(result_ptr, expr) \ + { \ + auto expected_result = expr; \ + if (!expected_result) \ + return expected_result.takeError(); \ + result_ptr = &expected_result.get(); \ + } + +llvm::Expected> +PdbIndex::create(std::unique_ptr file) { + lldbassert(file); + + std::unique_ptr result(new PdbIndex()); + ASSIGN_PTR_OR_RETURN(result->m_dbi, file->getPDBDbiStream()); + ASSIGN_PTR_OR_RETURN(result->m_tpi, file->getPDBTpiStream()); + ASSIGN_PTR_OR_RETURN(result->m_ipi, file->getPDBIpiStream()); + ASSIGN_PTR_OR_RETURN(result->m_info, file->getPDBInfoStream()); + ASSIGN_PTR_OR_RETURN(result->m_publics, file->getPDBPublicsStream()); + ASSIGN_PTR_OR_RETURN(result->m_globals, file->getPDBGlobalsStream()); + ASSIGN_PTR_OR_RETURN(result->m_symrecords, file->getPDBSymbolStream()); + + result->m_tpi->buildHashMap(); + + result->m_file = std::move(file); + + return std::move(result); +} + +lldb::addr_t PdbIndex::MakeVirtualAddress(uint16_t segment, + uint32_t offset) const { + // Segment indices are 1-based. + lldbassert(segment > 0); + + uint32_t max_section = dbi().getSectionHeaders().size(); + lldbassert(segment <= max_section + 1); + + // If this is an absolute symbol, it's indicated by the magic section index + // |max_section+1|. In this case, the offset is meaningless, so just return. + if (segment == max_section + 1) + return LLDB_INVALID_ADDRESS; + + const llvm::object::coff_section &cs = dbi().getSectionHeaders()[segment - 1]; + return m_load_address + static_cast(cs.VirtualAddress) + + static_cast(offset); +} + +lldb::addr_t PdbIndex::MakeVirtualAddress(const SegmentOffset &so) const { + return MakeVirtualAddress(so.segment, so.offset); +} + +llvm::Optional +PdbIndex::GetModuleIndexForAddr(uint16_t segment, uint32_t offset) const { + return GetModuleIndexForVa(MakeVirtualAddress(segment, offset)); +} + +llvm::Optional PdbIndex::GetModuleIndexForVa(lldb::addr_t va) const { + auto iter = m_va_to_modi.find(va); + if (iter == m_va_to_modi.end()) + return llvm::None; + + return iter.value(); +} + +void PdbIndex::ParseSectionContribs() { + class Visitor : public ISectionContribVisitor { + PdbIndex &m_ctx; + llvm::IntervalMap &m_imap; + + public: + Visitor(PdbIndex &ctx, llvm::IntervalMap &imap) + : m_ctx(ctx), m_imap(imap) {} + + void visit(const SectionContrib &C) override { + if (C.Size == 0) + return; + + uint64_t va = m_ctx.MakeVirtualAddress(C.ISect, C.Off); + uint64_t end = va + C.Size; + // IntervalMap's start and end represent a closed range, not a half-open + // range, so we have to subtract 1. + m_imap.insert(va, end - 1, C.Imod); + } + void visit(const SectionContrib2 &C) override { visit(C.Base); } + }; + Visitor v(*this, m_va_to_modi); + dbi().visitSectionContributions(v); +} + +void PdbIndex::BuildAddrToSymbolMap(CompilandIndexItem &cci) { + lldbassert(cci.m_symbols_by_va.empty() && + "Addr to symbol map is already built!"); + uint16_t modi = cci.m_id.modi; + const CVSymbolArray &syms = cci.m_debug_stream.getSymbolArray(); + for (auto iter = syms.begin(); iter != syms.end(); ++iter) { + if (!SymbolHasAddress(*iter)) + continue; + + SegmentOffset so = GetSegmentAndOffset(*iter); + lldb::addr_t va = MakeVirtualAddress(so); + + PdbCompilandSymId cu_sym_id(modi, iter.offset()); + + // If the debug info is incorrect, we could have multiple symbols with the + // same address. So use try_emplace instead of insert, and the first one + // will win. + cci.m_symbols_by_va.insert(std::make_pair(va, PdbSymUid(cu_sym_id))); + } +} + +std::vector PdbIndex::FindSymbolsByVa(lldb::addr_t va) { + std::vector result; + + llvm::Optional modi = GetModuleIndexForVa(va); + if (!modi) + return result; + + CompilandIndexItem &cci = compilands().GetOrCreateCompiland(*modi); + if (cci.m_symbols_by_va.empty()) + BuildAddrToSymbolMap(cci); + + // The map is sorted by starting address of the symbol. So for example + // we could (in theory) have this situation + // + // [------------------] + // [----------] + // [-----------] + // [-------------] + // [----] + // [-----] + // ^ Address we're searching for + // In order to find this, we use the upper_bound of the key value which would + // be the first symbol whose starting address is higher than the element we're + // searching for. + + auto ub = cci.m_symbols_by_va.upper_bound(va); + + for (auto iter = cci.m_symbols_by_va.begin(); iter != ub; ++iter) { + PdbCompilandSymId cu_sym_id = iter->second.asCompilandSym(); + CVSymbol sym = ReadSymbolRecord(cu_sym_id); + + SegmentOffsetLength sol; + if (SymbolIsCode(sym)) + sol = GetSegmentOffsetAndLength(sym); + else + sol.so = GetSegmentAndOffset(sym); + + lldb::addr_t start = MakeVirtualAddress(sol.so); + lldb::addr_t end = start + sol.length; + if (va >= start && va < end) + result.push_back({std::move(sym), iter->second}); + } + + return result; +} + +CVSymbol PdbIndex::ReadSymbolRecord(PdbCompilandSymId cu_sym) const { + // We need to subtract 4 here to adjust for the codeview debug magic + // at the beginning of the debug info stream. + const CompilandIndexItem *cci = compilands().GetCompiland(cu_sym.modi); + auto iter = cci->m_debug_stream.getSymbolArray().at(cu_sym.offset); + lldbassert(iter != cci->m_debug_stream.getSymbolArray().end()); + return *iter; +} + +CVSymbol PdbIndex::ReadSymbolRecord(PdbGlobalSymId global) const { + return symrecords().readRecord(global.offset); +} diff --git a/source/Plugins/SymbolFile/NativePDB/PdbIndex.h b/source/Plugins/SymbolFile/NativePDB/PdbIndex.h new file mode 100644 index 000000000000..72f6effa2222 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbIndex.h @@ -0,0 +1,161 @@ +//===-- PdbIndex.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 LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBINDEX_H +#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBINDEX_H + +#include "lldb/lldb-types.h" +#include "llvm/ADT/IntervalMap.h" +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/PDB/Native/PDBFile.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +#include "CompileUnitIndex.h" +#include "PdbSymUid.h" + +#include +#include + +namespace llvm { +namespace pdb { +class DbiStream; +class TpiStream; +class TpiStream; +class InfoStream; +class PublicsStream; +class GlobalsStream; +class SymbolStream; +} // namespace pdb +} // namespace llvm + +namespace lldb_private { +namespace npdb { +struct SegmentOffset; + +/// PdbIndex - Lazy access to the important parts of a PDB file. +/// +/// This is a layer on top of LLVM's native PDB support libraries which cache +/// certain data when it is accessed the first time. The entire PDB file is +/// mapped into memory, and the underlying support libraries vend out memory +/// that is always backed by the file, so it is safe to hold StringRefs and +/// ArrayRefs into the backing memory as long as the PdbIndex instance is +/// alive. +class PdbIndex { + + /// The underlying PDB file. + std::unique_ptr m_file; + + /// The DBI stream. This contains general high level information about the + /// features present in the PDB file, compile units (such as the information + /// necessary to locate full symbol information for each compile unit), + /// section contributions, and other data which is not specifically symbol or + /// type records. + llvm::pdb::DbiStream *m_dbi = nullptr; + + /// TPI (types) and IPI (indices) streams. These are both in the exact same + /// format with different data. Most type records are stored in the TPI + /// stream but certain specific types of records are stored in the IPI stream. + /// The IPI stream records can refer to the records in the TPI stream, but not + /// the other way around. + llvm::pdb::TpiStream *m_tpi = nullptr; + llvm::pdb::TpiStream *m_ipi = nullptr; + + /// This is called the "PDB Stream" in the Microsoft reference implementation. + /// It contains information about the structure of the file, as well as fields + /// used to match EXE and PDB. + llvm::pdb::InfoStream *m_info = nullptr; + + /// Publics stream. Is actually a serialized hash table where the keys are + /// addresses of symbols in the executable, and values are a record containing + /// mangled names and an index which can be used to locate more detailed info + /// about the symbol in the Symbol Records stream. The publics stream only + /// contains info about externally visible symbols. + llvm::pdb::PublicsStream *m_publics = nullptr; + + /// Globals stream. Contrary to its name, this does not contain information + /// about all "global variables" or "global functions". Rather, it is the + /// "global symbol table", i.e. it contains information about *every* symbol + /// in the executable. It is a hash table keyed on name, whose values are + /// indices into the symbol records stream to find the full record. + llvm::pdb::GlobalsStream *m_globals = nullptr; + + /// Symbol records stream. The publics and globals stream refer to records + /// in this stream. For some records, like constants and typedefs, the + /// complete record lives in this stream. For other symbol types, such as + /// functions, data, and other things that have been materialied into a + /// specific compile unit, the records here simply provide a reference + /// necessary to locate the full information. + llvm::pdb::SymbolStream *m_symrecords = nullptr; + + /// Index of all compile units, mapping identifier to |CompilandIndexItem| + /// instance. + CompileUnitIndex m_cus; + + /// An allocator for the interval maps + llvm::IntervalMap::Allocator m_allocator; + + /// Maps virtual address to module index + llvm::IntervalMap m_va_to_modi; + + /// The address at which the program has been loaded into memory. + lldb::addr_t m_load_address = 0; + + PdbIndex(); + + void BuildAddrToSymbolMap(CompilandIndexItem &cci); + +public: + static llvm::Expected> + create(std::unique_ptr); + + void SetLoadAddress(lldb::addr_t addr) { m_load_address = addr; } + void ParseSectionContribs(); + + llvm::pdb::PDBFile &pdb() { return *m_file; } + const llvm::pdb::PDBFile &pdb() const { return *m_file; } + + llvm::pdb::DbiStream &dbi() { return *m_dbi; } + const llvm::pdb::DbiStream &dbi() const { return *m_dbi; } + + llvm::pdb::TpiStream &tpi() { return *m_tpi; } + const llvm::pdb::TpiStream &tpi() const { return *m_tpi; } + + llvm::pdb::TpiStream &ipi() { return *m_ipi; } + const llvm::pdb::TpiStream &ipi() const { return *m_ipi; } + + llvm::pdb::InfoStream &info() { return *m_info; } + const llvm::pdb::InfoStream &info() const { return *m_info; } + + llvm::pdb::PublicsStream &publics() { return *m_publics; } + const llvm::pdb::PublicsStream &publics() const { return *m_publics; } + + llvm::pdb::GlobalsStream &globals() { return *m_globals; } + const llvm::pdb::GlobalsStream &globals() const { return *m_globals; } + + llvm::pdb::SymbolStream &symrecords() { return *m_symrecords; } + const llvm::pdb::SymbolStream &symrecords() const { return *m_symrecords; } + + CompileUnitIndex &compilands() { return m_cus; } + const CompileUnitIndex &compilands() const { return m_cus; } + + lldb::addr_t MakeVirtualAddress(uint16_t segment, uint32_t offset) const; + lldb::addr_t MakeVirtualAddress(const SegmentOffset &so) const; + + std::vector FindSymbolsByVa(lldb::addr_t va); + + llvm::codeview::CVSymbol ReadSymbolRecord(PdbCompilandSymId cu_sym) const; + llvm::codeview::CVSymbol ReadSymbolRecord(PdbGlobalSymId global) const; + + llvm::Optional GetModuleIndexForAddr(uint16_t segment, + uint32_t offset) const; + llvm::Optional GetModuleIndexForVa(lldb::addr_t va) const; +}; +} // namespace npdb +} // namespace lldb_private + +#endif diff --git a/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp new file mode 100644 index 000000000000..e5ad23f813eb --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp @@ -0,0 +1,160 @@ +//===-- PdbSymUid.cpp -------------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "PdbSymUid.h" + +using namespace lldb_private; +using namespace lldb_private::npdb; +using namespace llvm::codeview; + +namespace { +struct GenericIdRepr { + uint64_t tag : 4; + uint64_t data : 60; +}; + +struct CompilandIdRepr { + uint64_t tag : 4; + uint64_t modi : 16; + uint64_t unused : 44; +}; + +struct CompilandSymIdRepr { + uint64_t tag : 4; + uint64_t modi : 16; + uint64_t offset : 32; + uint64_t unused : 12; +}; + +struct GlobalSymIdRepr { + uint64_t tag : 4; + uint64_t offset : 32; + uint64_t pub : 1; + uint64_t unused : 27; +}; + +struct TypeSymIdRepr { + uint64_t tag : 4; + uint64_t index : 32; + uint64_t ipi : 1; + uint64_t unused : 27; +}; + +struct FieldListMemberIdRepr { + uint64_t tag : 4; + uint64_t index : 32; + uint64_t offset : 16; + uint64_t unused : 12; +}; + +static_assert(sizeof(CompilandIdRepr) == 8, "Invalid structure size!"); +static_assert(sizeof(CompilandSymIdRepr) == 8, "Invalid structure size!"); +static_assert(sizeof(GlobalSymIdRepr) == 8, "Invalid structure size!"); +static_assert(sizeof(TypeSymIdRepr) == 8, "Invalid structure size!"); +static_assert(sizeof(FieldListMemberIdRepr) == 8, "Invalid structure size!"); +} // namespace + +template static OutT repr_cast(const InT &value) { + OutT result; + ::memcpy(&result, &value, sizeof(value)); + return result; +} + +PdbSymUid::PdbSymUid(const PdbCompilandId &cid) { + CompilandIdRepr repr; + ::memset(&repr, 0, sizeof(repr)); + repr.modi = cid.modi; + repr.tag = static_cast(PdbSymUidKind::Compiland); + m_repr = repr_cast(repr); +} + +PdbSymUid::PdbSymUid(const PdbCompilandSymId &csid) { + CompilandSymIdRepr repr; + ::memset(&repr, 0, sizeof(repr)); + repr.modi = csid.modi; + repr.offset = csid.offset; + repr.tag = static_cast(PdbSymUidKind::CompilandSym); + m_repr = repr_cast(repr); +} + +PdbSymUid::PdbSymUid(const PdbGlobalSymId &gsid) { + GlobalSymIdRepr repr; + ::memset(&repr, 0, sizeof(repr)); + repr.pub = gsid.is_public; + repr.offset = gsid.offset; + repr.tag = static_cast(PdbSymUidKind::GlobalSym); + m_repr = repr_cast(repr); +} + +PdbSymUid::PdbSymUid(const PdbTypeSymId &tsid) { + TypeSymIdRepr repr; + ::memset(&repr, 0, sizeof(repr)); + repr.index = tsid.index.getIndex(); + repr.ipi = tsid.is_ipi; + repr.tag = static_cast(PdbSymUidKind::Type); + m_repr = repr_cast(repr); +} + +PdbSymUid::PdbSymUid(const PdbFieldListMemberId &flmid) { + FieldListMemberIdRepr repr; + ::memset(&repr, 0, sizeof(repr)); + repr.index = flmid.index.getIndex(); + repr.offset = flmid.offset; + repr.tag = static_cast(PdbSymUidKind::FieldListMember); + m_repr = repr_cast(repr); +} + +PdbSymUidKind PdbSymUid::kind() const { + GenericIdRepr generic = repr_cast(m_repr); + return static_cast(generic.tag); +} + +PdbCompilandId PdbSymUid::asCompiland() const { + assert(kind() == PdbSymUidKind::Compiland); + auto repr = repr_cast(m_repr); + PdbCompilandId result; + result.modi = repr.modi; + return result; +} + +PdbCompilandSymId PdbSymUid::asCompilandSym() const { + assert(kind() == PdbSymUidKind::CompilandSym); + auto repr = repr_cast(m_repr); + PdbCompilandSymId result; + result.modi = repr.modi; + result.offset = repr.offset; + return result; +} + +PdbGlobalSymId PdbSymUid::asGlobalSym() const { + assert(kind() == PdbSymUidKind::GlobalSym || + kind() == PdbSymUidKind::PublicSym); + auto repr = repr_cast(m_repr); + PdbGlobalSymId result; + result.is_public = repr.pub; + result.offset = repr.offset; + return result; +} + +PdbTypeSymId PdbSymUid::asTypeSym() const { + assert(kind() == PdbSymUidKind::Type); + auto repr = repr_cast(m_repr); + PdbTypeSymId result; + result.index.setIndex(repr.index); + result.is_ipi = repr.ipi; + return result; +} + +PdbFieldListMemberId PdbSymUid::asFieldListMember() const { + assert(kind() == PdbSymUidKind::FieldListMember); + auto repr = repr_cast(m_repr); + PdbFieldListMemberId result; + result.index.setIndex(repr.index); + result.offset = repr.offset; + return result; +} diff --git a/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h new file mode 100644 index 000000000000..7252d63c1ab4 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h @@ -0,0 +1,125 @@ +//===-- PdbSymUid.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 +// +//===----------------------------------------------------------------------===// +// A unique identification scheme for Pdb records. +// The scheme is to partition a 64-bit integer into an 8-bit tag field, which +// will contain some value from the PDB_SymType enumeration. The format of the +// other 48-bits depend on the tag, but must be sufficient to locate the +// corresponding entry in the underlying PDB file quickly. For example, for +// a compile unit, we use 2 bytes to represent the index, which allows fast +// access to the compile unit's information. +//===----------------------------------------------------------------------===// + +#ifndef LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBSYMUID_H +#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBSYMUID_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/Compiler.h" + +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/lldb-types.h" + +namespace lldb_private { +namespace npdb { + +enum class PdbSymUidKind : uint8_t { + Compiland, + CompilandSym, + PublicSym, + GlobalSym, + Type, + FieldListMember +}; + +struct PdbCompilandId { + // 0-based index of module in PDB + uint16_t modi; +}; + +struct PdbCompilandSymId { + PdbCompilandSymId() = default; + PdbCompilandSymId(uint16_t modi, uint32_t offset) + : modi(modi), offset(offset) {} + // 0-based index of module in PDB + uint16_t modi = 0; + + // Offset of symbol's record in module stream. This is + // offset by 4 from the CVSymbolArray's notion of offset + // due to the debug magic at the beginning of the stream. + uint32_t offset = 0; +}; + +struct PdbGlobalSymId { + PdbGlobalSymId() = default; + PdbGlobalSymId(uint32_t offset, bool is_public) + : offset(offset), is_public(is_public) {} + + // Offset of symbol's record in globals or publics stream. + uint32_t offset = 0; + + // True if this symbol is in the public stream, false if it's in the globals + // stream. + bool is_public = false; +}; + +struct PdbTypeSymId { + PdbTypeSymId() = default; + PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi = false) + : index(index), is_ipi(is_ipi) {} + + // The index of the of the type in the TPI or IPI stream. + llvm::codeview::TypeIndex index; + + // True if this symbol comes from the IPI stream, false if it's from the TPI + // stream. + bool is_ipi = false; +}; + +struct PdbFieldListMemberId { + // The TypeIndex of the LF_FIELDLIST record. + llvm::codeview::TypeIndex index; + + // The offset from the beginning of the LF_FIELDLIST record to this record. + uint16_t offset = 0; +}; + +class PdbSymUid { + uint64_t m_repr = 0; + +public: + PdbSymUid() = default; + PdbSymUid(uint64_t repr) : m_repr(repr) {} + PdbSymUid(const PdbCompilandId &cid); + PdbSymUid(const PdbCompilandSymId &csid); + PdbSymUid(const PdbGlobalSymId &gsid); + PdbSymUid(const PdbTypeSymId &tsid); + PdbSymUid(const PdbFieldListMemberId &flmid); + + uint64_t toOpaqueId() const { return m_repr; } + + PdbSymUidKind kind() const; + + PdbCompilandId asCompiland() const; + PdbCompilandSymId asCompilandSym() const; + PdbGlobalSymId asGlobalSym() const; + PdbTypeSymId asTypeSym() const; + PdbFieldListMemberId asFieldListMember() const; +}; + +template uint64_t toOpaqueUid(const T &cid) { + return PdbSymUid(cid).toOpaqueId(); +} + +struct SymbolAndUid { + llvm::codeview::CVSymbol sym; + PdbSymUid uid; +}; +} // namespace npdb +} // namespace lldb_private + +#endif diff --git a/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp new file mode 100644 index 000000000000..0677554c4cfb --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp @@ -0,0 +1,749 @@ +//===-- PdbUtil.cpp ---------------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "PdbUtil.h" + +#include "DWARFLocationExpression.h" +#include "PdbIndex.h" +#include "PdbSymUid.h" + +#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" + +#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h" +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/lldb-enumerations.h" + +using namespace lldb_private; +using namespace lldb_private::npdb; +using namespace llvm::codeview; +using namespace llvm::pdb; + +static Variable::RangeList +MakeRangeList(const PdbIndex &index, const LocalVariableAddrRange &range, + llvm::ArrayRef gaps) { + lldb::addr_t start = + index.MakeVirtualAddress(range.ISectStart, range.OffsetStart); + lldb::addr_t end = start + range.Range; + + Variable::RangeList result; + while (!gaps.empty()) { + const LocalVariableAddrGap &gap = gaps.front(); + + lldb::addr_t size = gap.GapStartOffset - start; + result.Append(start, size); + start += gap.Range; + gaps = gaps.drop_front(); + } + + result.Append(start, end); + return result; +} + +CVTagRecord CVTagRecord::create(CVType type) { + assert(IsTagRecord(type) && "type is not a tag record!"); + switch (type.kind()) { + case LF_CLASS: + case LF_STRUCTURE: + case LF_INTERFACE: { + ClassRecord cr; + llvm::cantFail(TypeDeserializer::deserializeAs(type, cr)); + return CVTagRecord(std::move(cr)); + } + case LF_UNION: { + UnionRecord ur; + llvm::cantFail(TypeDeserializer::deserializeAs(type, ur)); + return CVTagRecord(std::move(ur)); + } + case LF_ENUM: { + EnumRecord er; + llvm::cantFail(TypeDeserializer::deserializeAs(type, er)); + return CVTagRecord(std::move(er)); + } + default: + llvm_unreachable("Unreachable!"); + } +} + +CVTagRecord::CVTagRecord(ClassRecord &&c) + : cvclass(std::move(c)), + m_kind(cvclass.Kind == TypeRecordKind::Struct ? Struct : Class) {} +CVTagRecord::CVTagRecord(UnionRecord &&u) + : cvunion(std::move(u)), m_kind(Union) {} +CVTagRecord::CVTagRecord(EnumRecord &&e) : cvenum(std::move(e)), m_kind(Enum) {} + +PDB_SymType lldb_private::npdb::CVSymToPDBSym(SymbolKind kind) { + switch (kind) { + case S_COMPILE3: + case S_OBJNAME: + return PDB_SymType::CompilandDetails; + case S_ENVBLOCK: + return PDB_SymType::CompilandEnv; + case S_THUNK32: + case S_TRAMPOLINE: + return PDB_SymType::Thunk; + case S_COFFGROUP: + return PDB_SymType::CoffGroup; + case S_EXPORT: + return PDB_SymType::Export; + case S_LPROC32: + case S_GPROC32: + case S_LPROC32_DPC: + return PDB_SymType::Function; + case S_PUB32: + return PDB_SymType::PublicSymbol; + case S_INLINESITE: + return PDB_SymType::InlineSite; + case S_LOCAL: + case S_BPREL32: + case S_REGREL32: + case S_MANCONSTANT: + case S_CONSTANT: + case S_LDATA32: + case S_GDATA32: + case S_LMANDATA: + case S_GMANDATA: + case S_LTHREAD32: + case S_GTHREAD32: + return PDB_SymType::Data; + case S_BLOCK32: + return PDB_SymType::Block; + case S_LABEL32: + return PDB_SymType::Label; + case S_CALLSITEINFO: + return PDB_SymType::CallSite; + case S_HEAPALLOCSITE: + return PDB_SymType::HeapAllocationSite; + case S_CALLEES: + return PDB_SymType::Callee; + case S_CALLERS: + return PDB_SymType::Caller; + default: + lldbassert(false && "Invalid symbol record kind!"); + } + return PDB_SymType::None; +} + +PDB_SymType lldb_private::npdb::CVTypeToPDBType(TypeLeafKind kind) { + switch (kind) { + case LF_ARRAY: + return PDB_SymType::ArrayType; + case LF_ARGLIST: + return PDB_SymType::FunctionSig; + case LF_BCLASS: + return PDB_SymType::BaseClass; + case LF_BINTERFACE: + return PDB_SymType::BaseInterface; + case LF_CLASS: + case LF_STRUCTURE: + case LF_INTERFACE: + case LF_UNION: + return PDB_SymType::UDT; + case LF_POINTER: + return PDB_SymType::PointerType; + case LF_ENUM: + return PDB_SymType::Enum; + case LF_PROCEDURE: + return PDB_SymType::FunctionSig; + case LF_BITFIELD: + return PDB_SymType::BuiltinType; + default: + lldbassert(false && "Invalid type record kind!"); + } + return PDB_SymType::None; +} + +bool lldb_private::npdb::SymbolHasAddress(const CVSymbol &sym) { + switch (sym.kind()) { + case S_GPROC32: + case S_LPROC32: + case S_GPROC32_ID: + case S_LPROC32_ID: + case S_LPROC32_DPC: + case S_LPROC32_DPC_ID: + case S_THUNK32: + case S_TRAMPOLINE: + case S_COFFGROUP: + case S_BLOCK32: + case S_LABEL32: + case S_CALLSITEINFO: + case S_HEAPALLOCSITE: + case S_LDATA32: + case S_GDATA32: + case S_LMANDATA: + case S_GMANDATA: + case S_LTHREAD32: + case S_GTHREAD32: + return true; + default: + return false; + } +} + +bool lldb_private::npdb::SymbolIsCode(const CVSymbol &sym) { + switch (sym.kind()) { + case S_GPROC32: + case S_LPROC32: + case S_GPROC32_ID: + case S_LPROC32_ID: + case S_LPROC32_DPC: + case S_LPROC32_DPC_ID: + case S_THUNK32: + case S_TRAMPOLINE: + case S_COFFGROUP: + case S_BLOCK32: + return true; + default: + return false; + } +} + +template RecordT createRecord(const CVSymbol &sym) { + RecordT record(static_cast(sym.kind())); + cantFail(SymbolDeserializer::deserializeAs(sym, record)); + return record; +} + +template +static SegmentOffset GetSegmentAndOffset(const CVSymbol &sym) { + RecordT record = createRecord(sym); + return {record.Segment, record.CodeOffset}; +} + +template <> +SegmentOffset GetSegmentAndOffset(const CVSymbol &sym) { + TrampolineSym record = createRecord(sym); + return {record.ThunkSection, record.ThunkOffset}; +} + +template <> SegmentOffset GetSegmentAndOffset(const CVSymbol &sym) { + Thunk32Sym record = createRecord(sym); + return {record.Segment, record.Offset}; +} + +template <> +SegmentOffset GetSegmentAndOffset(const CVSymbol &sym) { + CoffGroupSym record = createRecord(sym); + return {record.Segment, record.Offset}; +} + +template <> SegmentOffset GetSegmentAndOffset(const CVSymbol &sym) { + DataSym record = createRecord(sym); + return {record.Segment, record.DataOffset}; +} + +template <> +SegmentOffset GetSegmentAndOffset(const CVSymbol &sym) { + ThreadLocalDataSym record = createRecord(sym); + return {record.Segment, record.DataOffset}; +} + +SegmentOffset lldb_private::npdb::GetSegmentAndOffset(const CVSymbol &sym) { + switch (sym.kind()) { + case S_GPROC32: + case S_LPROC32: + case S_GPROC32_ID: + case S_LPROC32_ID: + case S_LPROC32_DPC: + case S_LPROC32_DPC_ID: + return ::GetSegmentAndOffset(sym); + case S_THUNK32: + return ::GetSegmentAndOffset(sym); + break; + case S_TRAMPOLINE: + return ::GetSegmentAndOffset(sym); + break; + case S_COFFGROUP: + return ::GetSegmentAndOffset(sym); + break; + case S_BLOCK32: + return ::GetSegmentAndOffset(sym); + break; + case S_LABEL32: + return ::GetSegmentAndOffset(sym); + break; + case S_CALLSITEINFO: + return ::GetSegmentAndOffset(sym); + break; + case S_HEAPALLOCSITE: + return ::GetSegmentAndOffset(sym); + break; + case S_LDATA32: + case S_GDATA32: + case S_LMANDATA: + case S_GMANDATA: + return ::GetSegmentAndOffset(sym); + break; + case S_LTHREAD32: + case S_GTHREAD32: + return ::GetSegmentAndOffset(sym); + break; + default: + lldbassert(false && "Record does not have a segment/offset!"); + } + return {0, 0}; +} + +template +SegmentOffsetLength GetSegmentOffsetAndLength(const CVSymbol &sym) { + RecordT record = createRecord(sym); + return {record.Segment, record.CodeOffset, record.CodeSize}; +} + +template <> +SegmentOffsetLength +GetSegmentOffsetAndLength(const CVSymbol &sym) { + TrampolineSym record = createRecord(sym); + return {record.ThunkSection, record.ThunkOffset, record.Size}; +} + +template <> +SegmentOffsetLength GetSegmentOffsetAndLength(const CVSymbol &sym) { + Thunk32Sym record = createRecord(sym); + return SegmentOffsetLength{record.Segment, record.Offset, record.Length}; +} + +template <> +SegmentOffsetLength +GetSegmentOffsetAndLength(const CVSymbol &sym) { + CoffGroupSym record = createRecord(sym); + return SegmentOffsetLength{record.Segment, record.Offset, record.Size}; +} + +SegmentOffsetLength +lldb_private::npdb::GetSegmentOffsetAndLength(const CVSymbol &sym) { + switch (sym.kind()) { + case S_GPROC32: + case S_LPROC32: + case S_GPROC32_ID: + case S_LPROC32_ID: + case S_LPROC32_DPC: + case S_LPROC32_DPC_ID: + return ::GetSegmentOffsetAndLength(sym); + case S_THUNK32: + return ::GetSegmentOffsetAndLength(sym); + break; + case S_TRAMPOLINE: + return ::GetSegmentOffsetAndLength(sym); + break; + case S_COFFGROUP: + return ::GetSegmentOffsetAndLength(sym); + break; + case S_BLOCK32: + return ::GetSegmentOffsetAndLength(sym); + break; + default: + lldbassert(false && "Record does not have a segment/offset/length triple!"); + } + return {0, 0, 0}; +} + +bool lldb_private::npdb::IsForwardRefUdt(CVType cvt) { + ClassRecord cr; + UnionRecord ur; + EnumRecord er; + switch (cvt.kind()) { + case LF_CLASS: + case LF_STRUCTURE: + case LF_INTERFACE: + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, cr)); + return cr.isForwardRef(); + case LF_UNION: + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, ur)); + return ur.isForwardRef(); + case LF_ENUM: + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, er)); + return er.isForwardRef(); + default: + return false; + } +} + +bool lldb_private::npdb::IsTagRecord(llvm::codeview::CVType cvt) { + switch (cvt.kind()) { + case LF_CLASS: + case LF_STRUCTURE: + case LF_UNION: + case LF_ENUM: + return true; + default: + return false; + } +} + +bool lldb_private::npdb::IsClassStructUnion(llvm::codeview::CVType cvt) { + switch (cvt.kind()) { + case LF_CLASS: + case LF_STRUCTURE: + case LF_UNION: + return true; + default: + return false; + } +} + +bool lldb_private::npdb::IsForwardRefUdt(const PdbTypeSymId &id, + TpiStream &tpi) { + if (id.is_ipi || id.index.isSimple()) + return false; + return IsForwardRefUdt(tpi.getType(id.index)); +} + +bool lldb_private::npdb::IsTagRecord(const PdbTypeSymId &id, TpiStream &tpi) { + if (id.is_ipi || id.index.isSimple()) + return false; + return IsTagRecord(tpi.getType(id.index)); +} + +lldb::AccessType +lldb_private::npdb::TranslateMemberAccess(MemberAccess access) { + switch (access) { + case MemberAccess::Private: + return lldb::eAccessPrivate; + case MemberAccess::Protected: + return lldb::eAccessProtected; + case MemberAccess::Public: + return lldb::eAccessPublic; + case MemberAccess::None: + return lldb::eAccessNone; + } + llvm_unreachable("unreachable"); +} + +TypeIndex lldb_private::npdb::GetFieldListIndex(CVType cvt) { + switch (cvt.kind()) { + case LF_CLASS: + case LF_STRUCTURE: + case LF_INTERFACE: { + ClassRecord cr; + cantFail(TypeDeserializer::deserializeAs(cvt, cr)); + return cr.FieldList; + } + case LF_UNION: { + UnionRecord ur; + cantFail(TypeDeserializer::deserializeAs(cvt, ur)); + return ur.FieldList; + } + case LF_ENUM: { + EnumRecord er; + cantFail(TypeDeserializer::deserializeAs(cvt, er)); + return er.FieldList; + } + default: + llvm_unreachable("Unreachable!"); + } +} + +TypeIndex lldb_private::npdb::LookThroughModifierRecord(CVType modifier) { + lldbassert(modifier.kind() == LF_MODIFIER); + ModifierRecord mr; + llvm::cantFail(TypeDeserializer::deserializeAs(modifier, mr)); + return mr.ModifiedType; +} + +llvm::StringRef lldb_private::npdb::DropNameScope(llvm::StringRef name) { + return MSVCUndecoratedNameParser::DropScope(name); +} + +VariableInfo lldb_private::npdb::GetVariableNameInfo(CVSymbol sym) { + VariableInfo result; + + if (sym.kind() == S_REGREL32) { + RegRelativeSym reg(SymbolRecordKind::RegRelativeSym); + cantFail(SymbolDeserializer::deserializeAs(sym, reg)); + result.type = reg.Type; + result.name = reg.Name; + return result; + } + + if (sym.kind() == S_REGISTER) { + RegisterSym reg(SymbolRecordKind::RegisterSym); + cantFail(SymbolDeserializer::deserializeAs(sym, reg)); + result.type = reg.Index; + result.name = reg.Name; + return result; + } + + if (sym.kind() == S_LOCAL) { + LocalSym local(SymbolRecordKind::LocalSym); + cantFail(SymbolDeserializer::deserializeAs(sym, local)); + result.type = local.Type; + result.name = local.Name; + return result; + } + + if (sym.kind() == S_GDATA32 || sym.kind() == S_LDATA32) { + DataSym data(SymbolRecordKind::DataSym); + cantFail(SymbolDeserializer::deserializeAs(sym, data)); + result.type = data.Type; + result.name = data.Name; + return result; + } + + if (sym.kind() == S_GTHREAD32 || sym.kind() == S_LTHREAD32) { + ThreadLocalDataSym data(SymbolRecordKind::ThreadLocalDataSym); + cantFail(SymbolDeserializer::deserializeAs(sym, data)); + result.type = data.Type; + result.name = data.Name; + return result; + } + + if (sym.kind() == S_CONSTANT) { + ConstantSym constant(SymbolRecordKind::ConstantSym); + cantFail(SymbolDeserializer::deserializeAs(sym, constant)); + result.type = constant.Type; + result.name = constant.Name; + return result; + } + + lldbassert(false && "Invalid variable record kind!"); + return {}; +} + +VariableInfo lldb_private::npdb::GetVariableLocationInfo( + PdbIndex &index, PdbCompilandSymId var_id, lldb::ModuleSP module) { + + CVSymbol sym = index.ReadSymbolRecord(var_id); + + VariableInfo result = GetVariableNameInfo(sym); + + if (sym.kind() == S_REGREL32) { + RegRelativeSym reg(SymbolRecordKind::RegRelativeSym); + cantFail(SymbolDeserializer::deserializeAs(sym, reg)); + result.location = + MakeRegRelLocationExpression(reg.Register, reg.Offset, module); + result.ranges.emplace(); + return result; + } + + if (sym.kind() == S_REGISTER) { + RegisterSym reg(SymbolRecordKind::RegisterSym); + cantFail(SymbolDeserializer::deserializeAs(sym, reg)); + result.location = MakeEnregisteredLocationExpression(reg.Register, module); + result.ranges.emplace(); + return result; + } + + if (sym.kind() == S_LOCAL) { + LocalSym local(SymbolRecordKind::LocalSym); + cantFail(SymbolDeserializer::deserializeAs(sym, local)); + + PdbCompilandSymId loc_specifier_id(var_id.modi, + var_id.offset + sym.RecordData.size()); + CVSymbol loc_specifier_cvs = index.ReadSymbolRecord(loc_specifier_id); + if (loc_specifier_cvs.kind() == S_DEFRANGE_FRAMEPOINTER_REL) { + DefRangeFramePointerRelSym loc( + SymbolRecordKind::DefRangeFramePointerRelSym); + cantFail(SymbolDeserializer::deserializeAs( + loc_specifier_cvs, loc)); + // FIXME: The register needs to come from the S_FRAMEPROC symbol. + result.location = + MakeRegRelLocationExpression(RegisterId::RSP, loc.Offset, module); + result.ranges = MakeRangeList(index, loc.Range, loc.Gaps); + } else { + // FIXME: Handle other kinds + } + return result; + } + llvm_unreachable("Symbol is not a local variable!"); + return result; +} + +lldb::BasicType +lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) { + switch (kind) { + case SimpleTypeKind::Boolean128: + case SimpleTypeKind::Boolean16: + case SimpleTypeKind::Boolean32: + case SimpleTypeKind::Boolean64: + case SimpleTypeKind::Boolean8: + return lldb::eBasicTypeBool; + case SimpleTypeKind::Byte: + case SimpleTypeKind::UnsignedCharacter: + return lldb::eBasicTypeUnsignedChar; + case SimpleTypeKind::NarrowCharacter: + return lldb::eBasicTypeChar; + case SimpleTypeKind::SignedCharacter: + case SimpleTypeKind::SByte: + return lldb::eBasicTypeSignedChar; + case SimpleTypeKind::Character16: + return lldb::eBasicTypeChar16; + case SimpleTypeKind::Character32: + return lldb::eBasicTypeChar32; + case SimpleTypeKind::Complex80: + return lldb::eBasicTypeLongDoubleComplex; + case SimpleTypeKind::Complex64: + return lldb::eBasicTypeDoubleComplex; + case SimpleTypeKind::Complex32: + return lldb::eBasicTypeFloatComplex; + case SimpleTypeKind::Float128: + case SimpleTypeKind::Float80: + return lldb::eBasicTypeLongDouble; + case SimpleTypeKind::Float64: + return lldb::eBasicTypeDouble; + case SimpleTypeKind::Float32: + return lldb::eBasicTypeFloat; + case SimpleTypeKind::Float16: + return lldb::eBasicTypeHalf; + case SimpleTypeKind::Int128: + return lldb::eBasicTypeInt128; + case SimpleTypeKind::Int64: + case SimpleTypeKind::Int64Quad: + return lldb::eBasicTypeLongLong; + case SimpleTypeKind::Int32: + return lldb::eBasicTypeInt; + case SimpleTypeKind::Int16: + case SimpleTypeKind::Int16Short: + return lldb::eBasicTypeShort; + case SimpleTypeKind::UInt128: + return lldb::eBasicTypeUnsignedInt128; + case SimpleTypeKind::UInt64: + case SimpleTypeKind::UInt64Quad: + return lldb::eBasicTypeUnsignedLongLong; + case SimpleTypeKind::HResult: + case SimpleTypeKind::UInt32: + return lldb::eBasicTypeUnsignedInt; + case SimpleTypeKind::UInt16: + case SimpleTypeKind::UInt16Short: + return lldb::eBasicTypeUnsignedShort; + case SimpleTypeKind::Int32Long: + return lldb::eBasicTypeLong; + case SimpleTypeKind::UInt32Long: + return lldb::eBasicTypeUnsignedLong; + case SimpleTypeKind::Void: + return lldb::eBasicTypeVoid; + case SimpleTypeKind::WideCharacter: + return lldb::eBasicTypeWChar; + default: + return lldb::eBasicTypeInvalid; + } +} + +size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) { + switch (kind) { + case SimpleTypeKind::Boolean128: + case SimpleTypeKind::Int128: + case SimpleTypeKind::UInt128: + case SimpleTypeKind::Float128: + return 16; + case SimpleTypeKind::Complex80: + case SimpleTypeKind::Float80: + return 10; + case SimpleTypeKind::Boolean64: + case SimpleTypeKind::Complex64: + case SimpleTypeKind::UInt64: + case SimpleTypeKind::UInt64Quad: + case SimpleTypeKind::Float64: + case SimpleTypeKind::Int64: + case SimpleTypeKind::Int64Quad: + return 8; + case SimpleTypeKind::Boolean32: + case SimpleTypeKind::Character32: + case SimpleTypeKind::Complex32: + case SimpleTypeKind::Float32: + case SimpleTypeKind::Int32: + case SimpleTypeKind::Int32Long: + case SimpleTypeKind::UInt32Long: + case SimpleTypeKind::HResult: + case SimpleTypeKind::UInt32: + return 4; + case SimpleTypeKind::Boolean16: + case SimpleTypeKind::Character16: + case SimpleTypeKind::Float16: + case SimpleTypeKind::Int16: + case SimpleTypeKind::Int16Short: + case SimpleTypeKind::UInt16: + case SimpleTypeKind::UInt16Short: + case SimpleTypeKind::WideCharacter: + return 2; + case SimpleTypeKind::Boolean8: + case SimpleTypeKind::Byte: + case SimpleTypeKind::UnsignedCharacter: + case SimpleTypeKind::NarrowCharacter: + case SimpleTypeKind::SignedCharacter: + case SimpleTypeKind::SByte: + return 1; + case SimpleTypeKind::Void: + default: + return 0; + } +} + +PdbTypeSymId lldb_private::npdb::GetBestPossibleDecl(PdbTypeSymId id, + TpiStream &tpi) { + if (id.index.isSimple()) + return id; + + CVType cvt = tpi.getType(id.index); + + // Only tag records have a best and a worst record. + if (!IsTagRecord(cvt)) + return id; + + // Tag records that are not forward decls are full decls, hence they are the + // best. + if (!IsForwardRefUdt(cvt)) + return id; + + return llvm::cantFail(tpi.findFullDeclForForwardRef(id.index)); +} + +template static size_t GetSizeOfTypeInternal(CVType cvt) { + RecordType record; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, record)); + return record.getSize(); +} + +size_t lldb_private::npdb::GetSizeOfType(PdbTypeSymId id, + llvm::pdb::TpiStream &tpi) { + if (id.index.isSimple()) { + switch (id.index.getSimpleMode()) { + case SimpleTypeMode::Direct: + return GetTypeSizeForSimpleKind(id.index.getSimpleKind()); + case SimpleTypeMode::NearPointer32: + case SimpleTypeMode::FarPointer32: + return 4; + case SimpleTypeMode::NearPointer64: + return 8; + case SimpleTypeMode::NearPointer128: + return 16; + default: + break; + } + return 0; + } + + TypeIndex index = id.index; + if (IsForwardRefUdt(index, tpi)) + index = llvm::cantFail(tpi.findFullDeclForForwardRef(index)); + + CVType cvt = tpi.getType(index); + switch (cvt.kind()) { + case LF_MODIFIER: + return GetSizeOfType({LookThroughModifierRecord(cvt)}, tpi); + case LF_ENUM: { + EnumRecord record; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, record)); + return GetSizeOfType({record.UnderlyingType}, tpi); + } + case LF_POINTER: + return GetSizeOfTypeInternal(cvt); + case LF_ARRAY: + return GetSizeOfTypeInternal(cvt); + case LF_CLASS: + case LF_STRUCTURE: + case LF_INTERFACE: + return GetSizeOfTypeInternal(cvt); + case LF_UNION: + return GetSizeOfTypeInternal(cvt); + default: + break; + } + return 0; +} diff --git a/source/Plugins/SymbolFile/NativePDB/PdbUtil.h b/source/Plugins/SymbolFile/NativePDB/PdbUtil.h new file mode 100644 index 000000000000..46ae4912c1b4 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/PdbUtil.h @@ -0,0 +1,158 @@ +//===-- PdbUtil.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 LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBUTIL_H +#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBUTIL_H + +#include "lldb/Expression/DWARFExpression.h" +#include "lldb/Symbol/Variable.h" +#include "lldb/lldb-enumerations.h" + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +#include "PdbSymUid.h" + +#include +#include + +namespace llvm { +namespace pdb { +class TpiStream; +} +} // namespace llvm + +namespace lldb_private { +namespace npdb { + +class PdbIndex; + +struct CVTagRecord { + enum Kind { Class, Struct, Union, Enum }; + + static CVTagRecord create(llvm::codeview::CVType type); + + Kind kind() const { return m_kind; } + + const llvm::codeview::TagRecord &asTag() const { + if (m_kind == Struct || m_kind == Class) + return cvclass; + if (m_kind == Enum) + return cvenum; + return cvunion; + } + + const llvm::codeview::ClassRecord &asClass() const { + assert(m_kind == Struct || m_kind == Class); + return cvclass; + } + + const llvm::codeview::EnumRecord &asEnum() const { + assert(m_kind == Enum); + return cvenum; + } + + const llvm::codeview::UnionRecord &asUnion() const { + assert(m_kind == Union); + return cvunion; + } + + llvm::StringRef name() const { + if (m_kind == Struct || m_kind == Union) + return cvclass.Name; + if (m_kind == Enum) + return cvenum.Name; + return cvunion.Name; + } + +private: + CVTagRecord(llvm::codeview::ClassRecord &&c); + CVTagRecord(llvm::codeview::UnionRecord &&u); + CVTagRecord(llvm::codeview::EnumRecord &&e); + union { + llvm::codeview::ClassRecord cvclass; + llvm::codeview::EnumRecord cvenum; + llvm::codeview::UnionRecord cvunion; + }; + Kind m_kind; +}; + +struct SegmentOffset { + SegmentOffset() = default; + SegmentOffset(uint16_t s, uint32_t o) : segment(s), offset(o) {} + uint16_t segment = 0; + uint32_t offset = 0; +}; + +struct SegmentOffsetLength { + SegmentOffsetLength() = default; + SegmentOffsetLength(uint16_t s, uint32_t o, uint32_t l) + : so(s, o), length(l) {} + SegmentOffset so; + uint32_t length = 0; +}; + +struct VariableInfo { + llvm::StringRef name; + llvm::codeview::TypeIndex type; + llvm::Optional location; + llvm::Optional ranges; +}; + +llvm::pdb::PDB_SymType CVSymToPDBSym(llvm::codeview::SymbolKind kind); +llvm::pdb::PDB_SymType CVTypeToPDBType(llvm::codeview::TypeLeafKind kind); + +bool SymbolHasAddress(const llvm::codeview::CVSymbol &sym); +bool SymbolIsCode(const llvm::codeview::CVSymbol &sym); + +SegmentOffset GetSegmentAndOffset(const llvm::codeview::CVSymbol &sym); +SegmentOffsetLength +GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym); + +template bool IsValidRecord(const RecordT &sym) { + return true; +} + +inline bool IsValidRecord(const llvm::codeview::ProcRefSym &sym) { + // S_PROCREF symbols have 1-based module indices. + return sym.Module > 0; +} + +bool IsForwardRefUdt(llvm::codeview::CVType cvt); +bool IsTagRecord(llvm::codeview::CVType cvt); +bool IsClassStructUnion(llvm::codeview::CVType cvt); + +bool IsForwardRefUdt(const PdbTypeSymId &id, llvm::pdb::TpiStream &tpi); +bool IsTagRecord(const PdbTypeSymId &id, llvm::pdb::TpiStream &tpi); + +lldb::AccessType TranslateMemberAccess(llvm::codeview::MemberAccess access); +llvm::codeview::TypeIndex GetFieldListIndex(llvm::codeview::CVType cvt); +llvm::codeview::TypeIndex +LookThroughModifierRecord(llvm::codeview::CVType modifier); + +llvm::StringRef DropNameScope(llvm::StringRef name); + +VariableInfo GetVariableNameInfo(llvm::codeview::CVSymbol symbol); +VariableInfo GetVariableLocationInfo(PdbIndex &index, PdbCompilandSymId var_id, + lldb::ModuleSP module); + +size_t GetTypeSizeForSimpleKind(llvm::codeview::SimpleTypeKind kind); +lldb::BasicType +GetCompilerTypeForSimpleKind(llvm::codeview::SimpleTypeKind kind); + +PdbTypeSymId GetBestPossibleDecl(PdbTypeSymId id, llvm::pdb::TpiStream &tpi); + +size_t GetSizeOfType(PdbTypeSymId id, llvm::pdb::TpiStream &tpi); + +} // namespace npdb +} // namespace lldb_private + +#endif diff --git a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 004609f599b0..bdad031e88df 100644 --- a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1315,9 +1315,7 @@ VariableSP SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param) { ModuleSP module = GetObjectFile()->GetModule(); - Block &block = GetOrCreateBlock(scope_id); - VariableInfo var_info = - GetVariableLocationInfo(*m_index, var_id, block, module); + VariableInfo var_info = GetVariableLocationInfo(*m_index, var_id, module); if (!var_info.location || !var_info.ranges) return nullptr; diff --git a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h index 1264244b622f..9c06a929a1e0 100644 --- a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h +++ b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h @@ -96,7 +96,7 @@ class SymbolFileNativePDB : public SymbolFile { bool ParseImportedModules( const SymbolContext &sc, - std::vector &imported_modules) override; + std::vector &imported_modules) override; size_t ParseBlocksRecursive(Function &func) override; diff --git a/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp new file mode 100644 index 000000000000..37be3bc9cdfd --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -0,0 +1,223 @@ +#include "UdtRecordCompleter.h" + +#include "PdbAstBuilder.h" +#include "PdbIndex.h" +#include "PdbSymUid.h" +#include "PdbUtil.h" + +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangASTImporter.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Utility/LLDBAssert.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" + +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/PDB/Native/TpiStream.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +using namespace llvm::codeview; +using namespace llvm::pdb; +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::npdb; + +using Error = llvm::Error; + +UdtRecordCompleter::UdtRecordCompleter(PdbTypeSymId id, + CompilerType &derived_ct, + clang::TagDecl &tag_decl, + PdbAstBuilder &ast_builder, + TpiStream &tpi) + : m_id(id), m_derived_ct(derived_ct), m_tag_decl(tag_decl), + m_ast_builder(ast_builder), m_tpi(tpi) { + CVType cvt = m_tpi.getType(m_id.index); + switch (cvt.kind()) { + case LF_ENUM: + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, m_cvr.er)); + break; + case LF_UNION: + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, m_cvr.ur)); + break; + case LF_CLASS: + case LF_STRUCTURE: + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, m_cvr.cr)); + break; + default: + llvm_unreachable("unreachable!"); + } +} + +clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex( + llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access) { + PdbTypeSymId type_id(ti); + clang::QualType qt = m_ast_builder.GetOrCreateType(type_id); + + CVType udt_cvt = m_tpi.getType(ti); + + std::unique_ptr base_spec = + m_ast_builder.clang().CreateBaseClassSpecifier( + qt.getAsOpaquePtr(), TranslateMemberAccess(access), false, + udt_cvt.kind() == LF_CLASS); + lldbassert(base_spec); + m_bases.push_back(std::move(base_spec)); + return qt; +} + +void UdtRecordCompleter::AddMethod(llvm::StringRef name, TypeIndex type_idx, + MemberAccess access, MethodOptions options, + MemberAttributes attrs) { + clang::QualType method_qt = + m_ast_builder.GetOrCreateType(PdbTypeSymId(type_idx)); + m_ast_builder.CompleteType(method_qt); + + lldb::AccessType access_type = TranslateMemberAccess(access); + bool is_artificial = (options & MethodOptions::CompilerGenerated) == + MethodOptions::CompilerGenerated; + m_ast_builder.clang().AddMethodToCXXRecordType( + m_derived_ct.GetOpaqueQualType(), name.data(), nullptr, + m_ast_builder.ToCompilerType(method_qt), access_type, attrs.isVirtual(), + attrs.isStatic(), false, false, false, is_artificial); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + BaseClassRecord &base) { + clang::QualType base_qt = + AddBaseClassForTypeIndex(base.Type, base.getAccess()); + + auto decl = + m_ast_builder.clang().GetAsCXXRecordDecl(base_qt.getAsOpaquePtr()); + lldbassert(decl); + + auto offset = clang::CharUnits::fromQuantity(base.getBaseOffset()); + m_layout.base_offsets.insert(std::make_pair(decl, offset)); + + return llvm::Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + VirtualBaseClassRecord &base) { + AddBaseClassForTypeIndex(base.BaseType, base.getAccess()); + + // FIXME: Handle virtual base offsets. + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + ListContinuationRecord &cont) { + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + VFPtrRecord &vfptr) { + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember( + CVMemberRecord &cvr, StaticDataMemberRecord &static_data_member) { + clang::QualType member_type = + m_ast_builder.GetOrCreateType(PdbTypeSymId(static_data_member.Type)); + + m_ast_builder.CompleteType(member_type); + + CompilerType member_ct = m_ast_builder.ToCompilerType(member_type); + + lldb::AccessType access = + TranslateMemberAccess(static_data_member.getAccess()); + ClangASTContext::AddVariableToRecordType( + m_derived_ct, static_data_member.Name, member_ct, access); + + // FIXME: Add a PdbSymUid namespace for field list members and update + // the m_uid_to_decl map with this decl. + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + NestedTypeRecord &nested) { + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + DataMemberRecord &data_member) { + + uint64_t offset = data_member.FieldOffset * 8; + uint32_t bitfield_width = 0; + + TypeIndex ti(data_member.Type); + if (!ti.isSimple()) { + CVType cvt = m_tpi.getType(ti); + if (cvt.kind() == LF_BITFIELD) { + BitFieldRecord bfr; + llvm::cantFail(TypeDeserializer::deserializeAs(cvt, bfr)); + offset += bfr.BitOffset; + bitfield_width = bfr.BitSize; + ti = bfr.Type; + } + } + + clang::QualType member_qt = m_ast_builder.GetOrCreateType(PdbTypeSymId(ti)); + m_ast_builder.CompleteType(member_qt); + + lldb::AccessType access = TranslateMemberAccess(data_member.getAccess()); + + clang::FieldDecl *decl = ClangASTContext::AddFieldToRecordType( + m_derived_ct, data_member.Name, m_ast_builder.ToCompilerType(member_qt), + access, bitfield_width); + // FIXME: Add a PdbSymUid namespace for field list members and update + // the m_uid_to_decl map with this decl. + + m_layout.field_offsets.insert(std::make_pair(decl, offset)); + + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + OneMethodRecord &one_method) { + AddMethod(one_method.Name, one_method.Type, one_method.getAccess(), + one_method.getOptions(), one_method.Attrs); + + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + OverloadedMethodRecord &overloaded) { + TypeIndex method_list_idx = overloaded.MethodList; + + CVType method_list_type = m_tpi.getType(method_list_idx); + assert(method_list_type.Type == LF_METHODLIST); + + MethodOverloadListRecord method_list; + llvm::cantFail(TypeDeserializer::deserializeAs( + method_list_type, method_list)); + + for (const OneMethodRecord &method : method_list.Methods) + AddMethod(overloaded.Name, method.Type, method.getAccess(), + method.getOptions(), method.Attrs); + + return Error::success(); +} + +Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr, + EnumeratorRecord &enumerator) { + Declaration decl; + llvm::StringRef name = DropNameScope(enumerator.getName()); + + m_ast_builder.clang().AddEnumerationValueToEnumerationType( + m_derived_ct, decl, name.str().c_str(), enumerator.Value); + return Error::success(); +} + +void UdtRecordCompleter::complete() { + ClangASTContext &clang = m_ast_builder.clang(); + clang.TransferBaseClasses(m_derived_ct.GetOpaqueQualType(), + std::move(m_bases)); + + clang.AddMethodOverridesForCXXRecordType(m_derived_ct.GetOpaqueQualType()); + ClangASTContext::BuildIndirectFields(m_derived_ct); + ClangASTContext::CompleteTagDeclarationDefinition(m_derived_ct); + + if (auto *record_decl = llvm::dyn_cast(&m_tag_decl)) { + m_ast_builder.importer().InsertRecordDecl(record_decl, m_layout); + } +} diff --git a/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h new file mode 100644 index 000000000000..43015f9e25b1 --- /dev/null +++ b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h @@ -0,0 +1,78 @@ +//===-- SymbolFileNativePDB.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 LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H +#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H + +#include "lldb/Symbol/ClangASTImporter.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" + +#include "PdbSymUid.h" + +namespace clang { +class CXXBaseSpecifier; +class QualType; +class TagDecl; +} // namespace clang + +namespace llvm { +namespace pdb { +class TpiStream; +} +} // namespace llvm + +namespace lldb_private { +class Type; +class CompilerType; +namespace npdb { +class PdbAstBuilder; + +class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks { + union UdtTagRecord { + UdtTagRecord() {} + llvm::codeview::UnionRecord ur; + llvm::codeview::ClassRecord cr; + llvm::codeview::EnumRecord er; + } m_cvr; + + PdbTypeSymId m_id; + CompilerType &m_derived_ct; + clang::TagDecl &m_tag_decl; + PdbAstBuilder &m_ast_builder; + llvm::pdb::TpiStream &m_tpi; + std::vector> m_bases; + ClangASTImporter::LayoutInfo m_layout; + +public: + UdtRecordCompleter(PdbTypeSymId id, CompilerType &derived_ct, + clang::TagDecl &tag_decl, PdbAstBuilder &ast_builder, + llvm::pdb::TpiStream &tpi); + +#define MEMBER_RECORD(EnumName, EnumVal, Name) \ + llvm::Error visitKnownMember(llvm::codeview::CVMemberRecord &CVR, \ + llvm::codeview::Name##Record &Record) override; +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" + + void complete(); + +private: + clang::QualType AddBaseClassForTypeIndex(llvm::codeview::TypeIndex ti, + llvm::codeview::MemberAccess access); + void AddMethod(llvm::StringRef name, llvm::codeview::TypeIndex type_idx, + llvm::codeview::MemberAccess access, + llvm::codeview::MethodOptions options, + llvm::codeview::MemberAttributes attrs); +}; + +} // namespace npdb +} // namespace lldb_private + +#endif // LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H diff --git a/source/Plugins/SymbolFile/PDB/CMakeLists.txt b/source/Plugins/SymbolFile/PDB/CMakeLists.txt index 1c176c32224d..19698a7187f7 100644 --- a/source/Plugins/SymbolFile/PDB/CMakeLists.txt +++ b/source/Plugins/SymbolFile/PDB/CMakeLists.txt @@ -9,6 +9,7 @@ add_lldb_library(lldbPluginSymbolFilePDB PLUGIN lldbCore lldbSymbol lldbUtility + lldbPluginSymbolFileNativePDB LINK_COMPONENTS DebugInfoPDB Support diff --git a/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index 6915444b2d57..82cfcfbb040f 100644 --- a/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -1,23 +1,26 @@ //===-- PDBASTParser.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "PDBASTParser.h" +#include "SymbolFilePDB.h" + #include "clang/AST/CharUnits.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" -#include "lldb/Utility/LLDBAssert.h" +#include "lldb/Core/Module.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/ClangUtil.h" #include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/SymbolFile.h" +#include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/TypeSystem.h" #include "llvm/DebugInfo/PDB/IPDBLineNumber.h" @@ -34,12 +37,13 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" +#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h" + using namespace lldb; using namespace lldb_private; using namespace llvm::pdb; -namespace { -int TranslateUdtKind(PDB_UdtType pdb_kind) { +static int TranslateUdtKind(PDB_UdtType pdb_kind) { switch (pdb_kind) { case PDB_UdtType::Class: return clang::TTK_Class; @@ -50,10 +54,10 @@ int TranslateUdtKind(PDB_UdtType pdb_kind) { case PDB_UdtType::Interface: return clang::TTK_Interface; } - return -1; + llvm_unreachable("unsuported PDB UDT type"); } -lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type) { +static lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type) { switch (type) { case PDB_BuiltinType::Float: return lldb::eEncodingIEEE754; @@ -74,7 +78,7 @@ lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type) { } } -lldb::Encoding TranslateEnumEncoding(PDB_VariantType type) { +static lldb::Encoding TranslateEnumEncoding(PDB_VariantType type) { switch (type) { case PDB_VariantType::Int8: case PDB_VariantType::Int16: @@ -95,7 +99,7 @@ lldb::Encoding TranslateEnumEncoding(PDB_VariantType type) { return lldb::eEncodingSint; } -CompilerType +static CompilerType GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast, const PDBSymbolTypeBuiltin &pdb_type, Encoding encoding, uint32_t width) { @@ -110,6 +114,8 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast, return CompilerType(); case PDB_BuiltinType::Void: return clang_ast.GetBasicType(eBasicTypeVoid); + case PDB_BuiltinType::Char: + return clang_ast.GetBasicType(eBasicTypeChar); case PDB_BuiltinType::Bool: return clang_ast.GetBasicType(eBasicTypeBool); case PDB_BuiltinType::Long: @@ -144,8 +150,8 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast, return clang_ast.GetBuiltinTypeForEncodingAndBitSize(encoding, width); } -ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type, - CompilerType &compiler_type) { +static ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type, + CompilerType &compiler_type) { PDB_BuiltinType kind = pdb_type.getBuiltinType(); switch (kind) { default: @@ -176,7 +182,8 @@ ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type, return compiler_type.GetTypeName(); } -bool GetDeclarationForSymbol(const PDBSymbol &symbol, Declaration &decl) { +static bool GetDeclarationForSymbol(const PDBSymbol &symbol, + Declaration &decl) { auto &raw_sym = symbol.getRawSymbol(); auto first_line_up = raw_sym.getSrcLineOnTypeDefn(); @@ -194,13 +201,159 @@ bool GetDeclarationForSymbol(const PDBSymbol &symbol, Declaration &decl) { if (!src_file_up) return false; - FileSpec spec(src_file_up->getFileName(), /*resolve_path*/ false); + FileSpec spec(src_file_up->getFileName()); decl.SetFile(spec); decl.SetColumn(first_line_up->getColumnNumber()); decl.SetLine(first_line_up->getLineNumber()); return true; } -} // namespace + +static AccessType TranslateMemberAccess(PDB_MemberAccess access) { + switch (access) { + case PDB_MemberAccess::Private: + return eAccessPrivate; + case PDB_MemberAccess::Protected: + return eAccessProtected; + case PDB_MemberAccess::Public: + return eAccessPublic; + } + return eAccessNone; +} + +static AccessType GetDefaultAccessibilityForUdtKind(PDB_UdtType udt_kind) { + switch (udt_kind) { + case PDB_UdtType::Struct: + case PDB_UdtType::Union: + return eAccessPublic; + case PDB_UdtType::Class: + case PDB_UdtType::Interface: + return eAccessPrivate; + } + llvm_unreachable("unsupported PDB UDT type"); +} + +static AccessType GetAccessibilityForUdt(const PDBSymbolTypeUDT &udt) { + AccessType access = TranslateMemberAccess(udt.getAccess()); + if (access != lldb::eAccessNone || !udt.isNested()) + return access; + + auto parent = udt.getClassParent(); + if (!parent) + return lldb::eAccessNone; + + auto parent_udt = llvm::dyn_cast(parent.get()); + if (!parent_udt) + return lldb::eAccessNone; + + return GetDefaultAccessibilityForUdtKind(parent_udt->getUdtKind()); +} + +static clang::MSInheritanceAttr::Spelling +GetMSInheritance(const PDBSymbolTypeUDT &udt) { + int base_count = 0; + bool has_virtual = false; + + auto bases_enum = udt.findAllChildren(); + if (bases_enum) { + while (auto base = bases_enum->getNext()) { + base_count++; + has_virtual |= base->isVirtualBaseClass(); + } + } + + if (has_virtual) + return clang::MSInheritanceAttr::Keyword_virtual_inheritance; + if (base_count > 1) + return clang::MSInheritanceAttr::Keyword_multiple_inheritance; + return clang::MSInheritanceAttr::Keyword_single_inheritance; +} + +static std::unique_ptr +GetClassOrFunctionParent(const llvm::pdb::PDBSymbol &symbol) { + const IPDBSession &session = symbol.getSession(); + const IPDBRawSymbol &raw = symbol.getRawSymbol(); + auto tag = symbol.getSymTag(); + + // For items that are nested inside of a class, return the class that it is + // nested inside of. + // Note that only certain items can be nested inside of classes. + switch (tag) { + case PDB_SymType::Function: + case PDB_SymType::Data: + case PDB_SymType::UDT: + case PDB_SymType::Enum: + case PDB_SymType::FunctionSig: + case PDB_SymType::Typedef: + case PDB_SymType::BaseClass: + case PDB_SymType::VTable: { + auto class_parent_id = raw.getClassParentId(); + if (auto class_parent = session.getSymbolById(class_parent_id)) + return class_parent; + break; + } + default: + break; + } + + // Otherwise, if it is nested inside of a function, return the function. + // Note that only certain items can be nested inside of functions. + switch (tag) { + case PDB_SymType::Block: + case PDB_SymType::Data: { + auto lexical_parent_id = raw.getLexicalParentId(); + auto lexical_parent = session.getSymbolById(lexical_parent_id); + if (!lexical_parent) + return nullptr; + + auto lexical_parent_tag = lexical_parent->getSymTag(); + if (lexical_parent_tag == PDB_SymType::Function) + return lexical_parent; + if (lexical_parent_tag == PDB_SymType::Exe) + return nullptr; + + return GetClassOrFunctionParent(*lexical_parent); + } + default: + return nullptr; + } +} + +static clang::NamedDecl * +GetDeclFromContextByName(const clang::ASTContext &ast, + const clang::DeclContext &decl_context, + llvm::StringRef name) { + clang::IdentifierInfo &ident = ast.Idents.get(name); + clang::DeclarationName decl_name = ast.DeclarationNames.getIdentifier(&ident); + clang::DeclContext::lookup_result result = decl_context.lookup(decl_name); + if (result.empty()) + return nullptr; + + return result[0]; +} + +static bool IsAnonymousNamespaceName(llvm::StringRef name) { + return name == "`anonymous namespace'" || name == "`anonymous-namespace'"; +} + +static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc) { + switch (pdb_cc) { + case llvm::codeview::CallingConvention::NearC: + return clang::CC_C; + case llvm::codeview::CallingConvention::NearStdCall: + return clang::CC_X86StdCall; + case llvm::codeview::CallingConvention::NearFast: + return clang::CC_X86FastCall; + case llvm::codeview::CallingConvention::ThisCall: + return clang::CC_X86ThisCall; + case llvm::codeview::CallingConvention::NearVector: + return clang::CC_X86VectorCall; + case llvm::codeview::CallingConvention::NearPascal: + return clang::CC_X86Pascal; + default: + assert(false && "Unknown calling convention"); + return clang::CC_C; + } +} PDBASTParser::PDBASTParser(lldb_private::ClangASTContext &ast) : m_ast(ast) {} @@ -209,76 +362,167 @@ PDBASTParser::~PDBASTParser() {} // DebugInfoASTParser interface lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { - // PDB doesn't maintain enough information to robustly rebuild the entire - // tree, and this is most problematic when it comes to figure out the right - // DeclContext to put a type in. So for now, everything goes in the - // translation unit decl as a fully qualified type. - clang::DeclContext *tu_decl_ctx = m_ast.GetTranslationUnitDecl(); Declaration decl; - switch (type.getSymTag()) { + case PDB_SymType::BaseClass: { + auto symbol_file = m_ast.GetSymbolFile(); + if (!symbol_file) + return nullptr; + + auto ty = symbol_file->ResolveTypeUID(type.getRawSymbol().getTypeId()); + return ty ? ty->shared_from_this() : nullptr; + } break; case PDB_SymType::UDT: { auto udt = llvm::dyn_cast(&type); assert(udt); - AccessType access = lldb::eAccessPublic; - PDB_UdtType udt_kind = udt->getUdtKind(); - auto tag_type_kind = TranslateUdtKind(udt_kind); - if (tag_type_kind == -1) + + // Note that, unnamed UDT being typedef-ed is generated as a UDT symbol + // other than a Typedef symbol in PDB. For example, + // typedef union { short Row; short Col; } Union; + // is generated as a named UDT in PDB: + // union Union { short Row; short Col; } + // Such symbols will be handled here. + + // Some UDT with trival ctor has zero length. Just ignore. + if (udt->getLength() == 0) + return nullptr; + + // Ignore unnamed-tag UDTs. + std::string name = MSVCUndecoratedNameParser::DropScope(udt->getName()); + if (name.empty()) return nullptr; - if (udt_kind == PDB_UdtType::Class) - access = lldb::eAccessPrivate; + auto decl_context = GetDeclContextContainingSymbol(type); - CompilerType clang_type = m_ast.CreateRecordType( - tu_decl_ctx, access, udt->getName().c_str(), tag_type_kind, - lldb::eLanguageTypeC_plus_plus, nullptr); + // Check if such an UDT already exists in the current context. + // This may occur with const or volatile types. There are separate type + // symbols in PDB for types with const or volatile modifiers, but we need + // to create only one declaration for them all. + Type::ResolveStateTag type_resolve_state_tag; + CompilerType clang_type = m_ast.GetTypeForIdentifier( + ConstString(name), decl_context); + if (!clang_type.IsValid()) { + auto access = GetAccessibilityForUdt(*udt); - m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true); + auto tag_type_kind = TranslateUdtKind(udt->getUdtKind()); + ClangASTMetadata metadata; + metadata.SetUserID(type.getSymIndexId()); + metadata.SetIsDynamicCXXType(false); + + clang_type = m_ast.CreateRecordType( + decl_context, access, name.c_str(), tag_type_kind, + lldb::eLanguageTypeC_plus_plus, &metadata); + assert(clang_type.IsValid()); + + auto record_decl = + m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); + assert(record_decl); + m_uid_to_decl[type.getSymIndexId()] = record_decl; + + auto inheritance_attr = clang::MSInheritanceAttr::CreateImplicit( + *m_ast.getASTContext(), GetMSInheritance(*udt)); + record_decl->addAttr(inheritance_attr); + + ClangASTContext::StartTagDeclarationDefinition(clang_type); + + auto children = udt->findAllChildren(); + if (!children || children->getChildCount() == 0) { + // PDB does not have symbol of forwarder. We assume we get an udt w/o + // any fields. Just complete it at this point. + ClangASTContext::CompleteTagDeclarationDefinition(clang_type); + + ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(), + false); + + type_resolve_state_tag = Type::eResolveStateFull; + } else { + // Add the type to the forward declarations. It will help us to avoid + // an endless recursion in CompleteTypeFromUdt function. + m_forward_decl_to_uid[record_decl] = type.getSymIndexId(); + + ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(), + true); + + type_resolve_state_tag = Type::eResolveStateForward; + } + } else + type_resolve_state_tag = Type::eResolveStateForward; + + if (udt->isConstType()) + clang_type = clang_type.AddConstModifier(); + + if (udt->isVolatileType()) + clang_type = clang_type.AddVolatileModifier(); + + GetDeclarationForSymbol(type, decl); return std::make_shared( - type.getSymIndexId(), m_ast.GetSymbolFile(), - ConstString(udt->getName()), udt->getLength(), nullptr, - LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, clang_type, - lldb_private::Type::eResolveStateForward); + type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), + udt->getLength(), nullptr, LLDB_INVALID_UID, + lldb_private::Type::eEncodingIsUID, decl, clang_type, + type_resolve_state_tag); } break; case PDB_SymType::Enum: { auto enum_type = llvm::dyn_cast(&type); assert(enum_type); - auto underlying_type_up = enum_type->getUnderlyingType(); - if (!underlying_type_up) - return nullptr; - lldb::Encoding encoding = - TranslateBuiltinEncoding(underlying_type_up->getBuiltinType()); - // FIXME: Type of underlying builtin is always `Int`. We correct it with - // the very first enumerator's encoding if any. - auto first_child = enum_type->findOneChild(); - if (first_child) { - encoding = TranslateEnumEncoding(first_child->getValue().Type); - } - std::string name = enum_type->getName(); + + std::string name = + MSVCUndecoratedNameParser::DropScope(enum_type->getName()); + auto decl_context = GetDeclContextContainingSymbol(type); uint64_t bytes = enum_type->getLength(); - CompilerType builtin_type; - if (bytes > 0) - builtin_type = GetBuiltinTypeForPDBEncodingAndBitSize( - m_ast, *underlying_type_up, encoding, bytes * 8); - else - builtin_type = m_ast.GetBasicType(eBasicTypeInt); - // FIXME: PDB does not have information about scoped enumeration (Enum - // Class). Set it false for now. - bool isScoped = false; - - CompilerType ast_enum = m_ast.CreateEnumerationType( - name.c_str(), tu_decl_ctx, decl, builtin_type, isScoped); - auto enum_values = enum_type->findAllChildren(); - if (enum_values) { - while (auto enum_value = enum_values->getNext()) { - if (enum_value->getDataKind() != PDB_DataKind::Constant) - continue; - AddEnumValue(ast_enum, *enum_value); + + // Check if such an enum already exists in the current context + CompilerType ast_enum = m_ast.GetTypeForIdentifier( + ConstString(name), decl_context); + if (!ast_enum.IsValid()) { + auto underlying_type_up = enum_type->getUnderlyingType(); + if (!underlying_type_up) + return nullptr; + + lldb::Encoding encoding = + TranslateBuiltinEncoding(underlying_type_up->getBuiltinType()); + // FIXME: Type of underlying builtin is always `Int`. We correct it with + // the very first enumerator's encoding if any. + auto first_child = enum_type->findOneChild(); + if (first_child) + encoding = TranslateEnumEncoding(first_child->getValue().Type); + + CompilerType builtin_type; + if (bytes > 0) + builtin_type = GetBuiltinTypeForPDBEncodingAndBitSize( + m_ast, *underlying_type_up, encoding, bytes * 8); + else + builtin_type = m_ast.GetBasicType(eBasicTypeInt); + + // FIXME: PDB does not have information about scoped enumeration (Enum + // Class). Set it false for now. + bool isScoped = false; + + ast_enum = m_ast.CreateEnumerationType(name.c_str(), decl_context, decl, + builtin_type, isScoped); + + auto enum_decl = ClangASTContext::GetAsEnumDecl(ast_enum); + assert(enum_decl); + m_uid_to_decl[type.getSymIndexId()] = enum_decl; + + auto enum_values = enum_type->findAllChildren(); + if (enum_values) { + while (auto enum_value = enum_values->getNext()) { + if (enum_value->getDataKind() != PDB_DataKind::Constant) + continue; + AddEnumValue(ast_enum, *enum_value); + } } + + if (ClangASTContext::StartTagDeclarationDefinition(ast_enum)) + ClangASTContext::CompleteTagDeclarationDefinition(ast_enum); } - if (ClangASTContext::StartTagDeclarationDefinition(ast_enum)) - ClangASTContext::CompleteTagDeclarationDefinition(ast_enum); + + if (enum_type->isConstType()) + ast_enum = ast_enum.AddConstModifier(); + + if (enum_type->isVolatileType()) + ast_enum = ast_enum.AddVolatileModifier(); GetDeclarationForSymbol(type, decl); return std::make_shared( @@ -289,23 +533,46 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { case PDB_SymType::Typedef: { auto type_def = llvm::dyn_cast(&type); assert(type_def); + lldb_private::Type *target_type = m_ast.GetSymbolFile()->ResolveTypeUID(type_def->getTypeId()); if (!target_type) return nullptr; - std::string name = type_def->getName(); - uint64_t bytes = type_def->getLength(); - CompilerType target_ast_type = target_type->GetFullCompilerType(); - CompilerDeclContext target_decl_ctx = - m_ast.GetSymbolFile()->GetDeclContextForUID(target_type->GetID()); + + std::string name = + MSVCUndecoratedNameParser::DropScope(type_def->getName()); + auto decl_ctx = GetDeclContextContainingSymbol(type); + + // Check if such a typedef already exists in the current context CompilerType ast_typedef = - m_ast.CreateTypedefType(target_ast_type, name.c_str(), target_decl_ctx); - if (!ast_typedef) - return nullptr; + m_ast.GetTypeForIdentifier(ConstString(name), + decl_ctx); + if (!ast_typedef.IsValid()) { + CompilerType target_ast_type = target_type->GetFullCompilerType(); + + ast_typedef = m_ast.CreateTypedefType( + target_ast_type, name.c_str(), CompilerDeclContext(&m_ast, decl_ctx)); + if (!ast_typedef) + return nullptr; + + auto typedef_decl = ClangASTContext::GetAsTypedefDecl(ast_typedef); + assert(typedef_decl); + m_uid_to_decl[type.getSymIndexId()] = typedef_decl; + } + + if (type_def->isConstType()) + ast_typedef = ast_typedef.AddConstModifier(); + + if (type_def->isVolatileType()) + ast_typedef = ast_typedef.AddVolatileModifier(); + GetDeclarationForSymbol(type, decl); + llvm::Optional size; + if (type_def->getLength()) + size = type_def->getLength(); return std::make_shared( type_def->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), - bytes, nullptr, target_type->GetID(), + size, nullptr, target_type->GetID(), lldb_private::Type::eEncodingIsTypedefUID, decl, ast_typedef, lldb_private::Type::eResolveStateFull); } break; @@ -322,7 +589,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { return nullptr; func_sig = sig.release(); // Function type is named. - name = pdb_func->getName(); + name = MSVCUndecoratedNameParser::DropScope(pdb_func->getName()); } else if (auto pdb_func_sig = llvm::dyn_cast(&type)) { func_sig = const_cast(pdb_func_sig); @@ -365,22 +632,26 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { type_quals |= clang::Qualifiers::Const; if (func_sig->isVolatileType()) type_quals |= clang::Qualifiers::Volatile; + auto cc = TranslateCallingConvention(func_sig->getCallingConvention()); CompilerType func_sig_ast_type = m_ast.CreateFunctionType(return_ast_type, arg_list.data(), - arg_list.size(), is_variadic, type_quals); + arg_list.size(), is_variadic, type_quals, cc); GetDeclarationForSymbol(type, decl); return std::make_shared( - type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), 0, - nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, - func_sig_ast_type, lldb_private::Type::eResolveStateFull); + type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), + llvm::None, nullptr, LLDB_INVALID_UID, + lldb_private::Type::eEncodingIsUID, decl, func_sig_ast_type, + lldb_private::Type::eResolveStateFull); } break; case PDB_SymType::ArrayType: { auto array_type = llvm::dyn_cast(&type); assert(array_type); uint32_t num_elements = array_type->getCount(); uint32_t element_uid = array_type->getElementTypeId(); - uint32_t bytes = array_type->getLength(); + llvm::Optional bytes; + if (uint64_t size = array_type->getLength()) + bytes = size; // If array rank > 0, PDB gives the element type at N=0. So element type // will parsed in the order N=0, N=1,..., N=rank sequentially. @@ -392,7 +663,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { CompilerType element_ast_type = element_type->GetForwardCompilerType(); // If element type is UDT, it needs to be complete. if (ClangASTContext::IsCXXClassType(element_ast_type) && - element_ast_type.GetCompleteType() == false) { + !element_ast_type.GetCompleteType()) { if (ClangASTContext::StartTagDeclarationDefinition(element_ast_type)) { ClangASTContext::CompleteTagDeclarationDefinition(element_ast_type); } else { @@ -416,10 +687,12 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { if (builtin_kind == PDB_BuiltinType::None) return nullptr; - uint64_t bytes = builtin_type->getLength(); + llvm::Optional bytes; + if (uint64_t size = builtin_type->getLength()) + bytes = size; Encoding encoding = TranslateBuiltinEncoding(builtin_kind); CompilerType builtin_ast_type = GetBuiltinTypeForPDBEncodingAndBitSize( - m_ast, *builtin_type, encoding, bytes * 8); + m_ast, *builtin_type, encoding, bytes.getValueOr(0) * 8); if (builtin_type->isConstType()) builtin_ast_type = builtin_ast_type.AddConstModifier(); @@ -442,6 +715,26 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { if (!pointee_type) return nullptr; + if (pointer_type->isPointerToDataMember() || + pointer_type->isPointerToMemberFunction()) { + auto class_parent_uid = pointer_type->getRawSymbol().getClassParentId(); + auto class_parent_type = + m_ast.GetSymbolFile()->ResolveTypeUID(class_parent_uid); + assert(class_parent_type); + + CompilerType pointer_ast_type; + pointer_ast_type = ClangASTContext::CreateMemberPointerType( + class_parent_type->GetLayoutCompilerType(), + pointee_type->GetForwardCompilerType()); + assert(pointer_ast_type); + + return std::make_shared( + pointer_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(), + pointer_type->getLength(), nullptr, LLDB_INVALID_UID, + lldb_private::Type::eEncodingIsUID, decl, pointer_ast_type, + lldb_private::Type::eResolveStateForward); + } + CompilerType pointer_ast_type; pointer_ast_type = pointee_type->GetFullCompilerType(); if (pointer_type->isReference()) @@ -472,11 +765,363 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { return nullptr; } +bool PDBASTParser::CompleteTypeFromPDB( + lldb_private::CompilerType &compiler_type) { + if (GetClangASTImporter().CanImport(compiler_type)) + return GetClangASTImporter().CompleteType(compiler_type); + + // Remove the type from the forward declarations to avoid + // an endless recursion for types like a linked list. + clang::CXXRecordDecl *record_decl = + m_ast.GetAsCXXRecordDecl(compiler_type.GetOpaqueQualType()); + auto uid_it = m_forward_decl_to_uid.find(record_decl); + if (uid_it == m_forward_decl_to_uid.end()) + return true; + + auto symbol_file = static_cast(m_ast.GetSymbolFile()); + if (!symbol_file) + return false; + + std::unique_ptr symbol = + symbol_file->GetPDBSession().getSymbolById(uid_it->getSecond()); + if (!symbol) + return false; + + m_forward_decl_to_uid.erase(uid_it); + + ClangASTContext::SetHasExternalStorage(compiler_type.GetOpaqueQualType(), + false); + + switch (symbol->getSymTag()) { + case PDB_SymType::UDT: { + auto udt = llvm::dyn_cast(symbol.get()); + if (!udt) + return false; + + return CompleteTypeFromUDT(*symbol_file, compiler_type, *udt); + } + default: + llvm_unreachable("not a forward clang type decl!"); + } +} + +clang::Decl * +PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) { + uint32_t sym_id = symbol.getSymIndexId(); + auto it = m_uid_to_decl.find(sym_id); + if (it != m_uid_to_decl.end()) + return it->second; + + auto symbol_file = static_cast(m_ast.GetSymbolFile()); + if (!symbol_file) + return nullptr; + + // First of all, check if the symbol is a member of a class. Resolve the full + // class type and return the declaration from the cache if so. + auto tag = symbol.getSymTag(); + if (tag == PDB_SymType::Data || tag == PDB_SymType::Function) { + const IPDBSession &session = symbol.getSession(); + const IPDBRawSymbol &raw = symbol.getRawSymbol(); + + auto class_parent_id = raw.getClassParentId(); + if (std::unique_ptr class_parent = + session.getSymbolById(class_parent_id)) { + auto class_parent_type = symbol_file->ResolveTypeUID(class_parent_id); + if (!class_parent_type) + return nullptr; + + CompilerType class_parent_ct = class_parent_type->GetFullCompilerType(); + + // Look a declaration up in the cache after completing the class + clang::Decl *decl = m_uid_to_decl.lookup(sym_id); + if (decl) + return decl; + + // A declaration was not found in the cache. It means that the symbol + // has the class parent, but the class doesn't have the symbol in its + // children list. + if (auto func = llvm::dyn_cast_or_null(&symbol)) { + // Try to find a class child method with the same RVA and use its + // declaration if found. + if (uint32_t rva = func->getRelativeVirtualAddress()) { + if (std::unique_ptr> + methods_enum = + class_parent->findAllChildren()) { + while (std::unique_ptr method = + methods_enum->getNext()) { + if (method->getRelativeVirtualAddress() == rva) { + decl = m_uid_to_decl.lookup(method->getSymIndexId()); + if (decl) + break; + } + } + } + } + + // If no class methods with the same RVA were found, then create a new + // method. It is possible for template methods. + if (!decl) + decl = AddRecordMethod(*symbol_file, class_parent_ct, *func); + } + + if (decl) + m_uid_to_decl[sym_id] = decl; + + return decl; + } + } + + // If we are here, then the symbol is not belonging to a class and is not + // contained in the cache. So create a declaration for it. + switch (symbol.getSymTag()) { + case PDB_SymType::Data: { + auto data = llvm::dyn_cast(&symbol); + assert(data); + + auto decl_context = GetDeclContextContainingSymbol(symbol); + assert(decl_context); + + // May be the current context is a class really, but we haven't found + // any class parent. This happens e.g. in the case of class static + // variables - they has two symbols, one is a child of the class when + // another is a child of the exe. So always complete the parent and use + // an existing declaration if possible. + if (auto parent_decl = llvm::dyn_cast_or_null(decl_context)) + m_ast.GetCompleteDecl(parent_decl); + + std::string name = MSVCUndecoratedNameParser::DropScope(data->getName()); + + // Check if the current context already contains the symbol with the name. + clang::Decl *decl = + GetDeclFromContextByName(*m_ast.getASTContext(), *decl_context, name); + if (!decl) { + auto type = symbol_file->ResolveTypeUID(data->getTypeId()); + if (!type) + return nullptr; + + decl = m_ast.CreateVariableDeclaration( + decl_context, name.c_str(), + ClangUtil::GetQualType(type->GetLayoutCompilerType())); + } + + m_uid_to_decl[sym_id] = decl; + + return decl; + } + case PDB_SymType::Function: { + auto func = llvm::dyn_cast(&symbol); + assert(func); + + auto decl_context = GetDeclContextContainingSymbol(symbol); + assert(decl_context); + + std::string name = MSVCUndecoratedNameParser::DropScope(func->getName()); + + Type *type = symbol_file->ResolveTypeUID(sym_id); + if (!type) + return nullptr; + + auto storage = func->isStatic() ? clang::StorageClass::SC_Static + : clang::StorageClass::SC_None; + + auto decl = m_ast.CreateFunctionDeclaration( + decl_context, name.c_str(), type->GetForwardCompilerType(), storage, + func->hasInlineAttribute()); + + std::vector params; + if (std::unique_ptr sig = func->getSignature()) { + if (std::unique_ptr> + arg_enum = sig->findAllChildren()) { + while (std::unique_ptr arg = + arg_enum->getNext()) { + Type *arg_type = symbol_file->ResolveTypeUID(arg->getTypeId()); + if (!arg_type) + continue; + + clang::ParmVarDecl *param = m_ast.CreateParameterDeclaration( + decl, nullptr, arg_type->GetForwardCompilerType(), + clang::SC_None); + if (param) + params.push_back(param); + } + } + } + if (params.size()) + m_ast.SetFunctionParameters(decl, params.data(), params.size()); + + m_uid_to_decl[sym_id] = decl; + + return decl; + } + default: { + // It's not a variable and not a function, check if it's a type + Type *type = symbol_file->ResolveTypeUID(sym_id); + if (!type) + return nullptr; + + return m_uid_to_decl.lookup(sym_id); + } + } +} + +clang::DeclContext * +PDBASTParser::GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol) { + if (symbol.getSymTag() == PDB_SymType::Function) { + clang::DeclContext *result = + llvm::dyn_cast_or_null(GetDeclForSymbol(symbol)); + + if (result) + m_decl_context_to_uid[result] = symbol.getSymIndexId(); + + return result; + } + + auto symbol_file = static_cast(m_ast.GetSymbolFile()); + if (!symbol_file) + return nullptr; + + auto type = symbol_file->ResolveTypeUID(symbol.getSymIndexId()); + if (!type) + return nullptr; + + clang::DeclContext *result = + m_ast.GetDeclContextForType(type->GetForwardCompilerType()); + + if (result) + m_decl_context_to_uid[result] = symbol.getSymIndexId(); + + return result; +} + +clang::DeclContext *PDBASTParser::GetDeclContextContainingSymbol( + const llvm::pdb::PDBSymbol &symbol) { + auto parent = GetClassOrFunctionParent(symbol); + while (parent) { + if (auto parent_context = GetDeclContextForSymbol(*parent)) + return parent_context; + + parent = GetClassOrFunctionParent(*parent); + } + + // We can't find any class or function parent of the symbol. So analyze + // the full symbol name. The symbol may be belonging to a namespace + // or function (or even to a class if it's e.g. a static variable symbol). + + // TODO: Make clang to emit full names for variables in namespaces + // (as MSVC does) + + std::string name(symbol.getRawSymbol().getName()); + MSVCUndecoratedNameParser parser(name); + llvm::ArrayRef specs = parser.GetSpecifiers(); + if (specs.empty()) + return m_ast.GetTranslationUnitDecl(); + + auto symbol_file = static_cast(m_ast.GetSymbolFile()); + if (!symbol_file) + return m_ast.GetTranslationUnitDecl(); + + auto global = symbol_file->GetPDBSession().getGlobalScope(); + if (!global) + return m_ast.GetTranslationUnitDecl(); + + bool has_type_or_function_parent = false; + clang::DeclContext *curr_context = m_ast.GetTranslationUnitDecl(); + for (std::size_t i = 0; i < specs.size() - 1; i++) { + // Check if there is a function or a type with the current context's name. + if (std::unique_ptr children_enum = global->findChildren( + PDB_SymType::None, specs[i].GetFullName(), NS_CaseSensitive)) { + while (IPDBEnumChildren::ChildTypePtr child = + children_enum->getNext()) { + if (clang::DeclContext *child_context = + GetDeclContextForSymbol(*child)) { + // Note that `GetDeclContextForSymbol' retrieves + // a declaration context for functions and types only, + // so if we are here then `child_context' is guaranteed + // a function or a type declaration context. + has_type_or_function_parent = true; + curr_context = child_context; + } + } + } + + // If there were no functions or types above then retrieve a namespace with + // the current context's name. There can be no namespaces inside a function + // or a type. We check it to avoid fake namespaces such as `__l2': + // `N0::N1::CClass::PrivateFunc::__l2::InnerFuncStruct' + if (!has_type_or_function_parent) { + std::string namespace_name = specs[i].GetBaseName(); + const char *namespace_name_c_str = + IsAnonymousNamespaceName(namespace_name) ? nullptr + : namespace_name.data(); + clang::NamespaceDecl *namespace_decl = + m_ast.GetUniqueNamespaceDeclaration(namespace_name_c_str, + curr_context); + + m_parent_to_namespaces[curr_context].insert(namespace_decl); + m_namespaces.insert(namespace_decl); + + curr_context = namespace_decl; + } + } + + return curr_context; +} + +void PDBASTParser::ParseDeclsForDeclContext( + const clang::DeclContext *decl_context) { + auto symbol_file = static_cast(m_ast.GetSymbolFile()); + if (!symbol_file) + return; + + IPDBSession &session = symbol_file->GetPDBSession(); + auto symbol_up = + session.getSymbolById(m_decl_context_to_uid.lookup(decl_context)); + auto global_up = session.getGlobalScope(); + + PDBSymbol *symbol; + if (symbol_up) + symbol = symbol_up.get(); + else if (global_up) + symbol = global_up.get(); + else + return; + + if (auto children = symbol->findAllChildren()) + while (auto child = children->getNext()) + GetDeclForSymbol(*child); +} + +clang::NamespaceDecl * +PDBASTParser::FindNamespaceDecl(const clang::DeclContext *parent, + llvm::StringRef name) { + NamespacesSet *set; + if (parent) { + auto pit = m_parent_to_namespaces.find(parent); + if (pit == m_parent_to_namespaces.end()) + return nullptr; + + set = &pit->second; + } else { + set = &m_namespaces; + } + assert(set); + + for (clang::NamespaceDecl *namespace_decl : *set) + if (namespace_decl->getName().equals(name)) + return namespace_decl; + + for (clang::NamespaceDecl *namespace_decl : *set) + if (namespace_decl->isAnonymousNamespace()) + return FindNamespaceDecl(namespace_decl, name); + + return nullptr; +} + bool PDBASTParser::AddEnumValue(CompilerType enum_type, - const PDBSymbolData &enum_value) const { + const PDBSymbolData &enum_value) { Declaration decl; Variant v = enum_value.getValue(); - std::string name = enum_value.getName(); + std::string name = MSVCUndecoratedNameParser::DropScope(enum_value.getName()); int64_t raw_value; switch (v.Type) { case PDB_VariantType::Int8: @@ -510,6 +1155,213 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type, m_ast.GetEnumerationIntegerType(enum_type.GetOpaqueQualType()); uint32_t byte_size = m_ast.getASTContext()->getTypeSize( ClangUtil::GetQualType(underlying_type)); - return m_ast.AddEnumerationValueToEnumerationType( + auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType( enum_type, decl, name.c_str(), raw_value, byte_size * 8); + if (!enum_constant_decl) + return false; + + m_uid_to_decl[enum_value.getSymIndexId()] = enum_constant_decl; + + return true; +} + +bool PDBASTParser::CompleteTypeFromUDT( + lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &compiler_type, + llvm::pdb::PDBSymbolTypeUDT &udt) { + ClangASTImporter::LayoutInfo layout_info; + layout_info.bit_size = udt.getLength() * 8; + + auto nested_enums = udt.findAllChildren(); + if (nested_enums) + while (auto nested = nested_enums->getNext()) + symbol_file.ResolveTypeUID(nested->getSymIndexId()); + + auto bases_enum = udt.findAllChildren(); + if (bases_enum) + AddRecordBases(symbol_file, compiler_type, + TranslateUdtKind(udt.getUdtKind()), *bases_enum, + layout_info); + + auto members_enum = udt.findAllChildren(); + if (members_enum) + AddRecordMembers(symbol_file, compiler_type, *members_enum, layout_info); + + auto methods_enum = udt.findAllChildren(); + if (methods_enum) + AddRecordMethods(symbol_file, compiler_type, *methods_enum); + + m_ast.AddMethodOverridesForCXXRecordType(compiler_type.GetOpaqueQualType()); + ClangASTContext::BuildIndirectFields(compiler_type); + ClangASTContext::CompleteTagDeclarationDefinition(compiler_type); + + clang::CXXRecordDecl *record_decl = + m_ast.GetAsCXXRecordDecl(compiler_type.GetOpaqueQualType()); + if (!record_decl) + return static_cast(compiler_type); + + GetClangASTImporter().InsertRecordDecl(record_decl, layout_info); + + return static_cast(compiler_type); +} + +void PDBASTParser::AddRecordMembers( + lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, + PDBDataSymbolEnumerator &members_enum, + lldb_private::ClangASTImporter::LayoutInfo &layout_info) { + while (auto member = members_enum.getNext()) { + if (member->isCompilerGenerated()) + continue; + + auto member_name = member->getName(); + + auto member_type = symbol_file.ResolveTypeUID(member->getTypeId()); + if (!member_type) + continue; + + auto member_comp_type = member_type->GetLayoutCompilerType(); + if (!member_comp_type.GetCompleteType()) { + symbol_file.GetObjectFile()->GetModule()->ReportError( + ":: Class '%s' has a member '%s' of type '%s' " + "which does not have a complete definition.", + record_type.GetTypeName().GetCString(), member_name.c_str(), + member_comp_type.GetTypeName().GetCString()); + if (ClangASTContext::StartTagDeclarationDefinition(member_comp_type)) + ClangASTContext::CompleteTagDeclarationDefinition(member_comp_type); + } + + auto access = TranslateMemberAccess(member->getAccess()); + + switch (member->getDataKind()) { + case PDB_DataKind::Member: { + auto location_type = member->getLocationType(); + + auto bit_size = member->getLength(); + if (location_type == PDB_LocType::ThisRel) + bit_size *= 8; + + auto decl = ClangASTContext::AddFieldToRecordType( + record_type, member_name.c_str(), member_comp_type, access, bit_size); + if (!decl) + continue; + + m_uid_to_decl[member->getSymIndexId()] = decl; + + auto offset = member->getOffset() * 8; + if (location_type == PDB_LocType::BitField) + offset += member->getBitPosition(); + + layout_info.field_offsets.insert(std::make_pair(decl, offset)); + + break; + } + case PDB_DataKind::StaticMember: { + auto decl = ClangASTContext::AddVariableToRecordType( + record_type, member_name.c_str(), member_comp_type, access); + if (!decl) + continue; + + m_uid_to_decl[member->getSymIndexId()] = decl; + + break; + } + default: + llvm_unreachable("unsupported PDB data kind"); + } + } +} + +void PDBASTParser::AddRecordBases( + lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, int record_kind, + PDBBaseClassSymbolEnumerator &bases_enum, + lldb_private::ClangASTImporter::LayoutInfo &layout_info) const { + std::vector> base_classes; + + while (auto base = bases_enum.getNext()) { + auto base_type = symbol_file.ResolveTypeUID(base->getTypeId()); + if (!base_type) + continue; + + auto base_comp_type = base_type->GetFullCompilerType(); + if (!base_comp_type.GetCompleteType()) { + symbol_file.GetObjectFile()->GetModule()->ReportError( + ":: Class '%s' has a base class '%s' " + "which does not have a complete definition.", + record_type.GetTypeName().GetCString(), + base_comp_type.GetTypeName().GetCString()); + if (ClangASTContext::StartTagDeclarationDefinition(base_comp_type)) + ClangASTContext::CompleteTagDeclarationDefinition(base_comp_type); + } + + auto access = TranslateMemberAccess(base->getAccess()); + + auto is_virtual = base->isVirtualBaseClass(); + + std::unique_ptr base_spec = + m_ast.CreateBaseClassSpecifier(base_comp_type.GetOpaqueQualType(), + access, is_virtual, + record_kind == clang::TTK_Class); + lldbassert(base_spec); + + base_classes.push_back(std::move(base_spec)); + + if (is_virtual) + continue; + + auto decl = m_ast.GetAsCXXRecordDecl(base_comp_type.GetOpaqueQualType()); + if (!decl) + continue; + + auto offset = clang::CharUnits::fromQuantity(base->getOffset()); + layout_info.base_offsets.insert(std::make_pair(decl, offset)); + } + + m_ast.TransferBaseClasses(record_type.GetOpaqueQualType(), + std::move(base_classes)); +} + +void PDBASTParser::AddRecordMethods(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, + PDBFuncSymbolEnumerator &methods_enum) { + while (std::unique_ptr method = methods_enum.getNext()) + if (clang::CXXMethodDecl *decl = + AddRecordMethod(symbol_file, record_type, *method)) + m_uid_to_decl[method->getSymIndexId()] = decl; +} + +clang::CXXMethodDecl * +PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, + const llvm::pdb::PDBSymbolFunc &method) const { + std::string name = MSVCUndecoratedNameParser::DropScope(method.getName()); + + Type *method_type = symbol_file.ResolveTypeUID(method.getSymIndexId()); + // MSVC specific __vecDelDtor. + if (!method_type) + return nullptr; + + CompilerType method_comp_type = method_type->GetFullCompilerType(); + if (!method_comp_type.GetCompleteType()) { + symbol_file.GetObjectFile()->GetModule()->ReportError( + ":: Class '%s' has a method '%s' whose type cannot be completed.", + record_type.GetTypeName().GetCString(), + method_comp_type.GetTypeName().GetCString()); + if (ClangASTContext::StartTagDeclarationDefinition(method_comp_type)) + ClangASTContext::CompleteTagDeclarationDefinition(method_comp_type); + } + + AccessType access = TranslateMemberAccess(method.getAccess()); + if (access == eAccessNone) + access = eAccessPublic; + + // TODO: get mangled name for the method. + return m_ast.AddMethodToCXXRecordType( + record_type.GetOpaqueQualType(), name.c_str(), + /*mangled_name*/ nullptr, method_comp_type, access, method.isVirtual(), + method.isStatic(), method.hasInlineAttribute(), + /*is_explicit*/ false, // FIXME: Need this field in CodeView. + /*is_attr_used*/ false, + /*is_artificial*/ method.isCompilerGenerated()); } diff --git a/source/Plugins/SymbolFile/PDB/PDBASTParser.h b/source/Plugins/SymbolFile/PDB/PDBASTParser.h index d1ac138b8115..9221d42b2020 100644 --- a/source/Plugins/SymbolFile/PDB/PDBASTParser.h +++ b/source/Plugins/SymbolFile/PDB/PDBASTParser.h @@ -1,9 +1,8 @@ //===-- PDBASTParser.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,6 +13,8 @@ #include "lldb/Symbol/ClangASTImporter.h" +class SymbolFilePDB; + namespace clang { class CharUnits; class CXXRecordDecl; @@ -28,9 +29,14 @@ class CompilerType; namespace llvm { namespace pdb { +template class ConcreteSymbolEnumerator; + class PDBSymbol; class PDBSymbolData; +class PDBSymbolFunc; +class PDBSymbolTypeBaseClass; class PDBSymbolTypeBuiltin; +class PDBSymbolTypeUDT; } // namespace pdb } // namespace llvm @@ -40,13 +46,71 @@ class PDBASTParser { ~PDBASTParser(); lldb::TypeSP CreateLLDBTypeFromPDBType(const llvm::pdb::PDBSymbol &type); + bool CompleteTypeFromPDB(lldb_private::CompilerType &compiler_type); + + clang::Decl *GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol); + + clang::DeclContext * + GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol); + clang::DeclContext * + GetDeclContextContainingSymbol(const llvm::pdb::PDBSymbol &symbol); + + void ParseDeclsForDeclContext(const clang::DeclContext *decl_context); + + clang::NamespaceDecl *FindNamespaceDecl(const clang::DeclContext *parent, + llvm::StringRef name); + + lldb_private::ClangASTImporter &GetClangASTImporter() { + return m_ast_importer; + } private: + typedef llvm::DenseMap + CXXRecordDeclToUidMap; + typedef llvm::DenseMap UidToDeclMap; + typedef std::set NamespacesSet; + typedef llvm::DenseMap + ParentToNamespacesMap; + typedef llvm::DenseMap + DeclContextToUidMap; + typedef llvm::pdb::ConcreteSymbolEnumerator + PDBDataSymbolEnumerator; + typedef llvm::pdb::ConcreteSymbolEnumerator + PDBBaseClassSymbolEnumerator; + typedef llvm::pdb::ConcreteSymbolEnumerator + PDBFuncSymbolEnumerator; + bool AddEnumValue(lldb_private::CompilerType enum_type, - const llvm::pdb::PDBSymbolData &data) const; + const llvm::pdb::PDBSymbolData &data); + bool CompleteTypeFromUDT(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &compiler_type, + llvm::pdb::PDBSymbolTypeUDT &udt); + void + AddRecordMembers(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, + PDBDataSymbolEnumerator &members_enum, + lldb_private::ClangASTImporter::LayoutInfo &layout_info); + void + AddRecordBases(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, int record_kind, + PDBBaseClassSymbolEnumerator &bases_enum, + lldb_private::ClangASTImporter::LayoutInfo &layout_info) const; + void AddRecordMethods(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, + PDBFuncSymbolEnumerator &methods_enum); + clang::CXXMethodDecl * + AddRecordMethod(lldb_private::SymbolFile &symbol_file, + lldb_private::CompilerType &record_type, + const llvm::pdb::PDBSymbolFunc &method) const; lldb_private::ClangASTContext &m_ast; lldb_private::ClangASTImporter m_ast_importer; + + CXXRecordDeclToUidMap m_forward_decl_to_uid; + UidToDeclMap m_uid_to_decl; + ParentToNamespacesMap m_parent_to_namespaces; + NamespacesSet m_namespaces; + DeclContextToUidMap m_decl_context_to_uid; }; #endif // LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H diff --git a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp index 69ef70cc508c..f57c3b6cb8ea 100644 --- a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp +++ b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp @@ -1,9 +1,8 @@ //===-- PDBLocationToDWARFExpression.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -26,51 +25,51 @@ using namespace llvm::pdb; namespace { const uint32_t g_code_view_to_lldb_registers_x86[] = { - LLDB_INVALID_REGNUM, // CVRegNONE - lldb_al_i386, // CVRegAL - lldb_cl_i386, // CVRegCL - lldb_dl_i386, // CVRegDL - lldb_bl_i386, // CVRegBL - lldb_ah_i386, // CVRegAH - lldb_ch_i386, // CVRegCH - lldb_dh_i386, // CVRegDH - lldb_bh_i386, // CVRegBH - lldb_ax_i386, // CVRegAX - lldb_cx_i386, // CVRegCX - lldb_dx_i386, // CVRegDX - lldb_bx_i386, // CVRegBX - lldb_sp_i386, // CVRegSP - lldb_bp_i386, // CVRegBP - lldb_si_i386, // CVRegSI - lldb_di_i386, // CVRegDI - lldb_eax_i386, // CVRegEAX - lldb_ecx_i386, // CVRegECX - lldb_edx_i386, // CVRegEDX - lldb_ebx_i386, // CVRegEBX - lldb_esp_i386, // CVRegESP - lldb_ebp_i386, // CVRegEBP - lldb_esi_i386, // CVRegESI - lldb_edi_i386, // CVRegEDI - lldb_es_i386, // CVRegES - lldb_cs_i386, // CVRegCS - lldb_ss_i386, // CVRegSS - lldb_ds_i386, // CVRegDS - lldb_fs_i386, // CVRegFS - lldb_gs_i386, // CVRegGS - LLDB_INVALID_REGNUM, // CVRegIP - LLDB_INVALID_REGNUM, // CVRegFLAGS - lldb_eip_i386, // CVRegEIP - lldb_eflags_i386, // CVRegEFLAGS + LLDB_INVALID_REGNUM, // NONE + lldb_al_i386, // AL + lldb_cl_i386, // CL + lldb_dl_i386, // DL + lldb_bl_i386, // BL + lldb_ah_i386, // AH + lldb_ch_i386, // CH + lldb_dh_i386, // DH + lldb_bh_i386, // BH + lldb_ax_i386, // AX + lldb_cx_i386, // CX + lldb_dx_i386, // DX + lldb_bx_i386, // BX + lldb_sp_i386, // SP + lldb_bp_i386, // BP + lldb_si_i386, // SI + lldb_di_i386, // DI + lldb_eax_i386, // EAX + lldb_ecx_i386, // ECX + lldb_edx_i386, // EDX + lldb_ebx_i386, // EBX + lldb_esp_i386, // ESP + lldb_ebp_i386, // EBP + lldb_esi_i386, // ESI + lldb_edi_i386, // EDI + lldb_es_i386, // ES + lldb_cs_i386, // CS + lldb_ss_i386, // SS + lldb_ds_i386, // DS + lldb_fs_i386, // FS + lldb_gs_i386, // GS + LLDB_INVALID_REGNUM, // IP + LLDB_INVALID_REGNUM, // FLAGS + lldb_eip_i386, // EIP + lldb_eflags_i386, // EFLAGS LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegTEMP - LLDB_INVALID_REGNUM, // CVRegTEMPH - LLDB_INVALID_REGNUM, // CVRegQUOTE - LLDB_INVALID_REGNUM, // CVRegPCDR3 - LLDB_INVALID_REGNUM, // CVRegPCDR4 - LLDB_INVALID_REGNUM, // CVRegPCDR5 - LLDB_INVALID_REGNUM, // CVRegPCDR6 - LLDB_INVALID_REGNUM, // CVRegPCDR7 + LLDB_INVALID_REGNUM, // TEMP + LLDB_INVALID_REGNUM, // TEMPH + LLDB_INVALID_REGNUM, // QUOTE + LLDB_INVALID_REGNUM, // PCDR3 + LLDB_INVALID_REGNUM, // PCDR4 + LLDB_INVALID_REGNUM, // PCDR5 + LLDB_INVALID_REGNUM, // PCDR6 + LLDB_INVALID_REGNUM, // PCDR7 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -82,123 +81,123 @@ const uint32_t g_code_view_to_lldb_registers_x86[] = { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegCR0 - LLDB_INVALID_REGNUM, // CVRegCR1 - LLDB_INVALID_REGNUM, // CVRegCR2 - LLDB_INVALID_REGNUM, // CVRegCR3 - LLDB_INVALID_REGNUM, // CVRegCR4 + LLDB_INVALID_REGNUM, // CR0 + LLDB_INVALID_REGNUM, // CR1 + LLDB_INVALID_REGNUM, // CR2 + LLDB_INVALID_REGNUM, // CR3 + LLDB_INVALID_REGNUM, // CR4 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_dr0_i386, // CVRegDR0 - lldb_dr1_i386, // CVRegDR1 - lldb_dr2_i386, // CVRegDR2 - lldb_dr3_i386, // CVRegDR3 - lldb_dr4_i386, // CVRegDR4 - lldb_dr5_i386, // CVRegDR5 - lldb_dr6_i386, // CVRegDR6 - lldb_dr7_i386, // CVRegDR7 - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegGDTR - LLDB_INVALID_REGNUM, // CVRegGDTL - LLDB_INVALID_REGNUM, // CVRegIDTR - LLDB_INVALID_REGNUM, // CVRegIDTL - LLDB_INVALID_REGNUM, // CVRegLDTR - LLDB_INVALID_REGNUM, // CVRegTR - LLDB_INVALID_REGNUM, // CVRegPSEUDO1 - LLDB_INVALID_REGNUM, // CVRegPSEUDO2 - LLDB_INVALID_REGNUM, // CVRegPSEUDO3 - LLDB_INVALID_REGNUM, // CVRegPSEUDO4 - LLDB_INVALID_REGNUM, // CVRegPSEUDO5 - LLDB_INVALID_REGNUM, // CVRegPSEUDO6 - LLDB_INVALID_REGNUM, // CVRegPSEUDO7 - LLDB_INVALID_REGNUM, // CVRegPSEUDO8 - LLDB_INVALID_REGNUM, // CVRegPSEUDO9 - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_st0_i386, // CVRegST0 - lldb_st1_i386, // CVRegST1 - lldb_st2_i386, // CVRegST2 - lldb_st3_i386, // CVRegST3 - lldb_st4_i386, // CVRegST4 - lldb_st5_i386, // CVRegST5 - lldb_st6_i386, // CVRegST6 - lldb_st7_i386, // CVRegST7 - LLDB_INVALID_REGNUM, // CVRegCTRL - LLDB_INVALID_REGNUM, // CVRegSTAT - LLDB_INVALID_REGNUM, // CVRegTAG - LLDB_INVALID_REGNUM, // CVRegFPIP - LLDB_INVALID_REGNUM, // CVRegFPCS - LLDB_INVALID_REGNUM, // CVRegFPDO - LLDB_INVALID_REGNUM, // CVRegFPDS - LLDB_INVALID_REGNUM, // CVRegISEM - LLDB_INVALID_REGNUM, // CVRegFPEIP - LLDB_INVALID_REGNUM, // CVRegFPEDO - lldb_mm0_i386, // CVRegMM0 - lldb_mm1_i386, // CVRegMM1 - lldb_mm2_i386, // CVRegMM2 - lldb_mm3_i386, // CVRegMM3 - lldb_mm4_i386, // CVRegMM4 - lldb_mm5_i386, // CVRegMM5 - lldb_mm6_i386, // CVRegMM6 - lldb_mm7_i386, // CVRegMM7 - lldb_xmm0_i386, // CVRegXMM0 - lldb_xmm1_i386, // CVRegXMM1 - lldb_xmm2_i386, // CVRegXMM2 - lldb_xmm3_i386, // CVRegXMM3 - lldb_xmm4_i386, // CVRegXMM4 - lldb_xmm5_i386, // CVRegXMM5 - lldb_xmm6_i386, // CVRegXMM6 - lldb_xmm7_i386 // CVRegXMM7 + lldb_dr0_i386, // DR0 + lldb_dr1_i386, // DR1 + lldb_dr2_i386, // DR2 + lldb_dr3_i386, // DR3 + lldb_dr4_i386, // DR4 + lldb_dr5_i386, // DR5 + lldb_dr6_i386, // DR6 + lldb_dr7_i386, // DR7 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, // GDTR + LLDB_INVALID_REGNUM, // GDTL + LLDB_INVALID_REGNUM, // IDTR + LLDB_INVALID_REGNUM, // IDTL + LLDB_INVALID_REGNUM, // LDTR + LLDB_INVALID_REGNUM, // TR + LLDB_INVALID_REGNUM, // PSEUDO1 + LLDB_INVALID_REGNUM, // PSEUDO2 + LLDB_INVALID_REGNUM, // PSEUDO3 + LLDB_INVALID_REGNUM, // PSEUDO4 + LLDB_INVALID_REGNUM, // PSEUDO5 + LLDB_INVALID_REGNUM, // PSEUDO6 + LLDB_INVALID_REGNUM, // PSEUDO7 + LLDB_INVALID_REGNUM, // PSEUDO8 + LLDB_INVALID_REGNUM, // PSEUDO9 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_st0_i386, // ST0 + lldb_st1_i386, // ST1 + lldb_st2_i386, // ST2 + lldb_st3_i386, // ST3 + lldb_st4_i386, // ST4 + lldb_st5_i386, // ST5 + lldb_st6_i386, // ST6 + lldb_st7_i386, // ST7 + LLDB_INVALID_REGNUM, // CTRL + LLDB_INVALID_REGNUM, // STAT + LLDB_INVALID_REGNUM, // TAG + LLDB_INVALID_REGNUM, // FPIP + LLDB_INVALID_REGNUM, // FPCS + LLDB_INVALID_REGNUM, // FPDO + LLDB_INVALID_REGNUM, // FPDS + LLDB_INVALID_REGNUM, // ISEM + LLDB_INVALID_REGNUM, // FPEIP + LLDB_INVALID_REGNUM, // FPEDO + lldb_mm0_i386, // MM0 + lldb_mm1_i386, // MM1 + lldb_mm2_i386, // MM2 + lldb_mm3_i386, // MM3 + lldb_mm4_i386, // MM4 + lldb_mm5_i386, // MM5 + lldb_mm6_i386, // MM6 + lldb_mm7_i386, // MM7 + lldb_xmm0_i386, // XMM0 + lldb_xmm1_i386, // XMM1 + lldb_xmm2_i386, // XMM2 + lldb_xmm3_i386, // XMM3 + lldb_xmm4_i386, // XMM4 + lldb_xmm5_i386, // XMM5 + lldb_xmm6_i386, // XMM6 + lldb_xmm7_i386 // XMM7 }; const uint32_t g_code_view_to_lldb_registers_x86_64[] = { - LLDB_INVALID_REGNUM, // CVRegNONE - lldb_al_x86_64, // CVRegAL - lldb_cl_x86_64, // CVRegCL - lldb_dl_x86_64, // CVRegDL - lldb_bl_x86_64, // CVRegBL - lldb_ah_x86_64, // CVRegAH - lldb_ch_x86_64, // CVRegCH - lldb_dh_x86_64, // CVRegDH - lldb_bh_x86_64, // CVRegBH - lldb_ax_x86_64, // CVRegAX - lldb_cx_x86_64, // CVRegCX - lldb_dx_x86_64, // CVRegDX - lldb_bx_x86_64, // CVRegBX - lldb_sp_x86_64, // CVRegSP - lldb_bp_x86_64, // CVRegBP - lldb_si_x86_64, // CVRegSI - lldb_di_x86_64, // CVRegDI - lldb_eax_x86_64, // CVRegEAX - lldb_ecx_x86_64, // CVRegECX - lldb_edx_x86_64, // CVRegEDX - lldb_ebx_x86_64, // CVRegEBX - lldb_esp_x86_64, // CVRegESP - lldb_ebp_x86_64, // CVRegEBP - lldb_esi_x86_64, // CVRegESI - lldb_edi_x86_64, // CVRegEDI - lldb_es_x86_64, // CVRegES - lldb_cs_x86_64, // CVRegCS - lldb_ss_x86_64, // CVRegSS - lldb_ds_x86_64, // CVRegDS - lldb_fs_x86_64, // CVRegFS - lldb_gs_x86_64, // CVRegGS - LLDB_INVALID_REGNUM, // CVRegIP - LLDB_INVALID_REGNUM, // CVRegFLAGS - LLDB_INVALID_REGNUM, // CVRegEIP - LLDB_INVALID_REGNUM, // CVRegEFLAGS + LLDB_INVALID_REGNUM, // NONE + lldb_al_x86_64, // AL + lldb_cl_x86_64, // CL + lldb_dl_x86_64, // DL + lldb_bl_x86_64, // BL + lldb_ah_x86_64, // AH + lldb_ch_x86_64, // CH + lldb_dh_x86_64, // DH + lldb_bh_x86_64, // BH + lldb_ax_x86_64, // AX + lldb_cx_x86_64, // CX + lldb_dx_x86_64, // DX + lldb_bx_x86_64, // BX + lldb_sp_x86_64, // SP + lldb_bp_x86_64, // BP + lldb_si_x86_64, // SI + lldb_di_x86_64, // DI + lldb_eax_x86_64, // EAX + lldb_ecx_x86_64, // ECX + lldb_edx_x86_64, // EDX + lldb_ebx_x86_64, // EBX + lldb_esp_x86_64, // ESP + lldb_ebp_x86_64, // EBP + lldb_esi_x86_64, // ESI + lldb_edi_x86_64, // EDI + lldb_es_x86_64, // ES + lldb_cs_x86_64, // CS + lldb_ss_x86_64, // SS + lldb_ds_x86_64, // DS + lldb_fs_x86_64, // FS + lldb_gs_x86_64, // GS + LLDB_INVALID_REGNUM, // IP + LLDB_INVALID_REGNUM, // FLAGS + LLDB_INVALID_REGNUM, // EIP + LLDB_INVALID_REGNUM, // EFLAGS LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegTEMP - LLDB_INVALID_REGNUM, // CVRegTEMPH - LLDB_INVALID_REGNUM, // CVRegQUOTE - LLDB_INVALID_REGNUM, // CVRegPCDR3 - LLDB_INVALID_REGNUM, // CVRegPCDR4 - LLDB_INVALID_REGNUM, // CVRegPCDR5 - LLDB_INVALID_REGNUM, // CVRegPCDR6 - LLDB_INVALID_REGNUM, // CVRegPCDR7 + LLDB_INVALID_REGNUM, // TEMP + LLDB_INVALID_REGNUM, // TEMPH + LLDB_INVALID_REGNUM, // QUOTE + LLDB_INVALID_REGNUM, // PCDR3 + LLDB_INVALID_REGNUM, // PCDR4 + LLDB_INVALID_REGNUM, // PCDR5 + LLDB_INVALID_REGNUM, // PCDR6 + LLDB_INVALID_REGNUM, // PCDR7 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -210,75 +209,75 @@ const uint32_t g_code_view_to_lldb_registers_x86_64[] = { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegCR0 - LLDB_INVALID_REGNUM, // CVRegCR1 - LLDB_INVALID_REGNUM, // CVRegCR2 - LLDB_INVALID_REGNUM, // CVRegCR3 - LLDB_INVALID_REGNUM, // CVRegCR4 + LLDB_INVALID_REGNUM, // CR0 + LLDB_INVALID_REGNUM, // CR1 + LLDB_INVALID_REGNUM, // CR2 + LLDB_INVALID_REGNUM, // CR3 + LLDB_INVALID_REGNUM, // CR4 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_dr0_x86_64, // CVRegDR0 - lldb_dr1_x86_64, // CVRegDR1 - lldb_dr2_x86_64, // CVRegDR2 - lldb_dr3_x86_64, // CVRegDR3 - lldb_dr4_x86_64, // CVRegDR4 - lldb_dr5_x86_64, // CVRegDR5 - lldb_dr6_x86_64, // CVRegDR6 - lldb_dr7_x86_64, // CVRegDR7 + lldb_dr0_x86_64, // DR0 + lldb_dr1_x86_64, // DR1 + lldb_dr2_x86_64, // DR2 + lldb_dr3_x86_64, // DR3 + lldb_dr4_x86_64, // DR4 + lldb_dr5_x86_64, // DR5 + lldb_dr6_x86_64, // DR6 + lldb_dr7_x86_64, // DR7 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegGDTR - LLDB_INVALID_REGNUM, // CVRegGDTL - LLDB_INVALID_REGNUM, // CVRegIDTR - LLDB_INVALID_REGNUM, // CVRegIDTL - LLDB_INVALID_REGNUM, // CVRegLDTR - LLDB_INVALID_REGNUM, // CVRegTR - LLDB_INVALID_REGNUM, // CVRegPSEUDO1 - LLDB_INVALID_REGNUM, // CVRegPSEUDO2 - LLDB_INVALID_REGNUM, // CVRegPSEUDO3 - LLDB_INVALID_REGNUM, // CVRegPSEUDO4 - LLDB_INVALID_REGNUM, // CVRegPSEUDO5 - LLDB_INVALID_REGNUM, // CVRegPSEUDO6 - LLDB_INVALID_REGNUM, // CVRegPSEUDO7 - LLDB_INVALID_REGNUM, // CVRegPSEUDO8 - LLDB_INVALID_REGNUM, // CVRegPSEUDO9 + LLDB_INVALID_REGNUM, // GDTR + LLDB_INVALID_REGNUM, // GDTL + LLDB_INVALID_REGNUM, // IDTR + LLDB_INVALID_REGNUM, // IDTL + LLDB_INVALID_REGNUM, // LDTR + LLDB_INVALID_REGNUM, // TR + LLDB_INVALID_REGNUM, // PSEUDO1 + LLDB_INVALID_REGNUM, // PSEUDO2 + LLDB_INVALID_REGNUM, // PSEUDO3 + LLDB_INVALID_REGNUM, // PSEUDO4 + LLDB_INVALID_REGNUM, // PSEUDO5 + LLDB_INVALID_REGNUM, // PSEUDO6 + LLDB_INVALID_REGNUM, // PSEUDO7 + LLDB_INVALID_REGNUM, // PSEUDO8 + LLDB_INVALID_REGNUM, // PSEUDO9 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_st0_x86_64, // CVRegST0 - lldb_st1_x86_64, // CVRegST1 - lldb_st2_x86_64, // CVRegST2 - lldb_st3_x86_64, // CVRegST3 - lldb_st4_x86_64, // CVRegST4 - lldb_st5_x86_64, // CVRegST5 - lldb_st6_x86_64, // CVRegST6 - lldb_st7_x86_64, // CVRegST7 - LLDB_INVALID_REGNUM, // CVRegCTRL - LLDB_INVALID_REGNUM, // CVRegSTAT - LLDB_INVALID_REGNUM, // CVRegTAG - LLDB_INVALID_REGNUM, // CVRegFPIP - LLDB_INVALID_REGNUM, // CVRegFPCS - LLDB_INVALID_REGNUM, // CVRegFPDO - LLDB_INVALID_REGNUM, // CVRegFPDS - LLDB_INVALID_REGNUM, // CVRegISEM - LLDB_INVALID_REGNUM, // CVRegFPEIP - LLDB_INVALID_REGNUM, // CVRegFPEDO - lldb_mm0_x86_64, // CVRegMM0 - lldb_mm1_x86_64, // CVRegMM1 - lldb_mm2_x86_64, // CVRegMM2 - lldb_mm3_x86_64, // CVRegMM3 - lldb_mm4_x86_64, // CVRegMM4 - lldb_mm5_x86_64, // CVRegMM5 - lldb_mm6_x86_64, // CVRegMM6 - lldb_mm7_x86_64, // CVRegMM7 - lldb_xmm0_x86_64, // CVRegXMM0 - lldb_xmm1_x86_64, // CVRegXMM1 - lldb_xmm2_x86_64, // CVRegXMM2 - lldb_xmm3_x86_64, // CVRegXMM3 - lldb_xmm4_x86_64, // CVRegXMM4 - lldb_xmm5_x86_64, // CVRegXMM5 - lldb_xmm6_x86_64, // CVRegXMM6 - lldb_xmm7_x86_64, // CVRegXMM7 + lldb_st0_x86_64, // ST0 + lldb_st1_x86_64, // ST1 + lldb_st2_x86_64, // ST2 + lldb_st3_x86_64, // ST3 + lldb_st4_x86_64, // ST4 + lldb_st5_x86_64, // ST5 + lldb_st6_x86_64, // ST6 + lldb_st7_x86_64, // ST7 + LLDB_INVALID_REGNUM, // CTRL + LLDB_INVALID_REGNUM, // STAT + LLDB_INVALID_REGNUM, // TAG + LLDB_INVALID_REGNUM, // FPIP + LLDB_INVALID_REGNUM, // FPCS + LLDB_INVALID_REGNUM, // FPDO + LLDB_INVALID_REGNUM, // FPDS + LLDB_INVALID_REGNUM, // ISEM + LLDB_INVALID_REGNUM, // FPEIP + LLDB_INVALID_REGNUM, // FPEDO + lldb_mm0_x86_64, // MM0 + lldb_mm1_x86_64, // MM1 + lldb_mm2_x86_64, // MM2 + lldb_mm3_x86_64, // MM3 + lldb_mm4_x86_64, // MM4 + lldb_mm5_x86_64, // MM5 + lldb_mm6_x86_64, // MM6 + lldb_mm7_x86_64, // MM7 + lldb_xmm0_x86_64, // XMM0 + lldb_xmm1_x86_64, // XMM1 + lldb_xmm2_x86_64, // XMM2 + lldb_xmm3_x86_64, // XMM3 + lldb_xmm4_x86_64, // XMM4 + lldb_xmm5_x86_64, // XMM5 + lldb_xmm6_x86_64, // XMM6 + lldb_xmm7_x86_64, // XMM7 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -296,51 +295,51 @@ const uint32_t g_code_view_to_lldb_registers_x86_64[] = { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_mxcsr_x86_64, // CVRegMXCSR - LLDB_INVALID_REGNUM, // CVRegEDXEAX + lldb_mxcsr_x86_64, // MXCSR + LLDB_INVALID_REGNUM, // EDXEAX LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, // CVRegEMM0L - LLDB_INVALID_REGNUM, // CVRegEMM1L - LLDB_INVALID_REGNUM, // CVRegEMM2L - LLDB_INVALID_REGNUM, // CVRegEMM3L - LLDB_INVALID_REGNUM, // CVRegEMM4L - LLDB_INVALID_REGNUM, // CVRegEMM5L - LLDB_INVALID_REGNUM, // CVRegEMM6L - LLDB_INVALID_REGNUM, // CVRegEMM7L - LLDB_INVALID_REGNUM, // CVRegEMM0H - LLDB_INVALID_REGNUM, // CVRegEMM1H - LLDB_INVALID_REGNUM, // CVRegEMM2H - LLDB_INVALID_REGNUM, // CVRegEMM3H - LLDB_INVALID_REGNUM, // CVRegEMM4H - LLDB_INVALID_REGNUM, // CVRegEMM5H - LLDB_INVALID_REGNUM, // CVRegEMM6H - LLDB_INVALID_REGNUM, // CVRegEMM7H - LLDB_INVALID_REGNUM, // CVRegMM00 - LLDB_INVALID_REGNUM, // CVRegMM01 - LLDB_INVALID_REGNUM, // CVRegMM10 - LLDB_INVALID_REGNUM, // CVRegMM11 - LLDB_INVALID_REGNUM, // CVRegMM20 - LLDB_INVALID_REGNUM, // CVRegMM21 - LLDB_INVALID_REGNUM, // CVRegMM30 - LLDB_INVALID_REGNUM, // CVRegMM31 - LLDB_INVALID_REGNUM, // CVRegMM40 - LLDB_INVALID_REGNUM, // CVRegMM41 - LLDB_INVALID_REGNUM, // CVRegMM50 - LLDB_INVALID_REGNUM, // CVRegMM51 - LLDB_INVALID_REGNUM, // CVRegMM60 - LLDB_INVALID_REGNUM, // CVRegMM61 - LLDB_INVALID_REGNUM, // CVRegMM70 - LLDB_INVALID_REGNUM, // CVRegMM71 - lldb_xmm8_x86_64, // CVRegXMM8 - lldb_xmm9_x86_64, // CVRegXMM9 - lldb_xmm10_x86_64, // CVRegXMM10 - lldb_xmm11_x86_64, // CVRegXMM11 - lldb_xmm12_x86_64, // CVRegXMM12 - lldb_xmm13_x86_64, // CVRegXMM13 - lldb_xmm14_x86_64, // CVRegXMM14 - lldb_xmm15_x86_64, // CVRegXMM15 + LLDB_INVALID_REGNUM, // EMM0L + LLDB_INVALID_REGNUM, // EMM1L + LLDB_INVALID_REGNUM, // EMM2L + LLDB_INVALID_REGNUM, // EMM3L + LLDB_INVALID_REGNUM, // EMM4L + LLDB_INVALID_REGNUM, // EMM5L + LLDB_INVALID_REGNUM, // EMM6L + LLDB_INVALID_REGNUM, // EMM7L + LLDB_INVALID_REGNUM, // EMM0H + LLDB_INVALID_REGNUM, // EMM1H + LLDB_INVALID_REGNUM, // EMM2H + LLDB_INVALID_REGNUM, // EMM3H + LLDB_INVALID_REGNUM, // EMM4H + LLDB_INVALID_REGNUM, // EMM5H + LLDB_INVALID_REGNUM, // EMM6H + LLDB_INVALID_REGNUM, // EMM7H + LLDB_INVALID_REGNUM, // MM00 + LLDB_INVALID_REGNUM, // MM01 + LLDB_INVALID_REGNUM, // MM10 + LLDB_INVALID_REGNUM, // MM11 + LLDB_INVALID_REGNUM, // MM20 + LLDB_INVALID_REGNUM, // MM21 + LLDB_INVALID_REGNUM, // MM30 + LLDB_INVALID_REGNUM, // MM31 + LLDB_INVALID_REGNUM, // MM40 + LLDB_INVALID_REGNUM, // MM41 + LLDB_INVALID_REGNUM, // MM50 + LLDB_INVALID_REGNUM, // MM51 + LLDB_INVALID_REGNUM, // MM60 + LLDB_INVALID_REGNUM, // MM61 + LLDB_INVALID_REGNUM, // MM70 + LLDB_INVALID_REGNUM, // MM71 + lldb_xmm8_x86_64, // XMM8 + lldb_xmm9_x86_64, // XMM9 + lldb_xmm10_x86_64, // XMM10 + lldb_xmm11_x86_64, // XMM11 + lldb_xmm12_x86_64, // XMM12 + lldb_xmm13_x86_64, // XMM13 + lldb_xmm14_x86_64, // XMM14 + lldb_xmm15_x86_64, // XMM15 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -363,73 +362,73 @@ const uint32_t g_code_view_to_lldb_registers_x86_64[] = { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_sil_x86_64, // CVRegSIL - lldb_dil_x86_64, // CVRegDIL - lldb_bpl_x86_64, // CVRegBPL - lldb_spl_x86_64, // CVRegSPL - lldb_rax_x86_64, // CVRegRAX - lldb_rbx_x86_64, // CVRegRBX - lldb_rcx_x86_64, // CVRegRCX - lldb_rdx_x86_64, // CVRegRDX - lldb_rsi_x86_64, // CVRegRSI - lldb_rdi_x86_64, // CVRegRDI - lldb_rbp_x86_64, // CVRegRBP - lldb_rsp_x86_64, // CVRegRSP - lldb_r8_x86_64, // CVRegR8 - lldb_r9_x86_64, // CVRegR9 - lldb_r10_x86_64, // CVRegR10 - lldb_r11_x86_64, // CVRegR11 - lldb_r12_x86_64, // CVRegR12 - lldb_r13_x86_64, // CVRegR13 - lldb_r14_x86_64, // CVRegR14 - lldb_r15_x86_64, // CVRegR15 - lldb_r8l_x86_64, // CVRegR8B - lldb_r9l_x86_64, // CVRegR9B - lldb_r10l_x86_64, // CVRegR10B - lldb_r11l_x86_64, // CVRegR11B - lldb_r12l_x86_64, // CVRegR12B - lldb_r13l_x86_64, // CVRegR13B - lldb_r14l_x86_64, // CVRegR14B - lldb_r15l_x86_64, // CVRegR15B - lldb_r8w_x86_64, // CVRegR8W - lldb_r9w_x86_64, // CVRegR9W - lldb_r10w_x86_64, // CVRegR10W - lldb_r11w_x86_64, // CVRegR11W - lldb_r12w_x86_64, // CVRegR12W - lldb_r13w_x86_64, // CVRegR13W - lldb_r14w_x86_64, // CVRegR14W - lldb_r15w_x86_64, // CVRegR15W - lldb_r8d_x86_64, // CVRegR8D - lldb_r9d_x86_64, // CVRegR9D - lldb_r10d_x86_64, // CVRegR10D - lldb_r11d_x86_64, // CVRegR11D - lldb_r12d_x86_64, // CVRegR12D - lldb_r13d_x86_64, // CVRegR13D - lldb_r14d_x86_64, // CVRegR14D - lldb_r15d_x86_64, // CVRegR15D - lldb_ymm0_x86_64, // CVRegAMD64_YMM0 - lldb_ymm1_x86_64, // CVRegAMD64_YMM1 - lldb_ymm2_x86_64, // CVRegAMD64_YMM2 - lldb_ymm3_x86_64, // CVRegAMD64_YMM3 - lldb_ymm4_x86_64, // CVRegAMD64_YMM4 - lldb_ymm5_x86_64, // CVRegAMD64_YMM5 - lldb_ymm6_x86_64, // CVRegAMD64_YMM6 - lldb_ymm7_x86_64, // CVRegAMD64_YMM7 - lldb_ymm8_x86_64, // CVRegAMD64_YMM8 - lldb_ymm9_x86_64, // CVRegAMD64_YMM9 - lldb_ymm10_x86_64, // CVRegAMD64_YMM10 - lldb_ymm11_x86_64, // CVRegAMD64_YMM11 - lldb_ymm12_x86_64, // CVRegAMD64_YMM12 - lldb_ymm13_x86_64, // CVRegAMD64_YMM13 - lldb_ymm14_x86_64, // CVRegAMD64_YMM14 - lldb_ymm15_x86_64, // CVRegAMD64_YMM15 - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_bnd0_x86_64, // CVRegBND0 - lldb_bnd1_x86_64, // CVRegBND1 - lldb_bnd2_x86_64 // CVRegBND2 + lldb_sil_x86_64, // SIL + lldb_dil_x86_64, // DIL + lldb_bpl_x86_64, // BPL + lldb_spl_x86_64, // SPL + lldb_rax_x86_64, // RAX + lldb_rbx_x86_64, // RBX + lldb_rcx_x86_64, // RCX + lldb_rdx_x86_64, // RDX + lldb_rsi_x86_64, // RSI + lldb_rdi_x86_64, // RDI + lldb_rbp_x86_64, // RBP + lldb_rsp_x86_64, // RSP + lldb_r8_x86_64, // R8 + lldb_r9_x86_64, // R9 + lldb_r10_x86_64, // R10 + lldb_r11_x86_64, // R11 + lldb_r12_x86_64, // R12 + lldb_r13_x86_64, // R13 + lldb_r14_x86_64, // R14 + lldb_r15_x86_64, // R15 + lldb_r8l_x86_64, // R8B + lldb_r9l_x86_64, // R9B + lldb_r10l_x86_64, // R10B + lldb_r11l_x86_64, // R11B + lldb_r12l_x86_64, // R12B + lldb_r13l_x86_64, // R13B + lldb_r14l_x86_64, // R14B + lldb_r15l_x86_64, // R15B + lldb_r8w_x86_64, // R8W + lldb_r9w_x86_64, // R9W + lldb_r10w_x86_64, // R10W + lldb_r11w_x86_64, // R11W + lldb_r12w_x86_64, // R12W + lldb_r13w_x86_64, // R13W + lldb_r14w_x86_64, // R14W + lldb_r15w_x86_64, // R15W + lldb_r8d_x86_64, // R8D + lldb_r9d_x86_64, // R9D + lldb_r10d_x86_64, // R10D + lldb_r11d_x86_64, // R11D + lldb_r12d_x86_64, // R12D + lldb_r13d_x86_64, // R13D + lldb_r14d_x86_64, // R14D + lldb_r15d_x86_64, // R15D + lldb_ymm0_x86_64, // AMD64_YMM0 + lldb_ymm1_x86_64, // AMD64_YMM1 + lldb_ymm2_x86_64, // AMD64_YMM2 + lldb_ymm3_x86_64, // AMD64_YMM3 + lldb_ymm4_x86_64, // AMD64_YMM4 + lldb_ymm5_x86_64, // AMD64_YMM5 + lldb_ymm6_x86_64, // AMD64_YMM6 + lldb_ymm7_x86_64, // AMD64_YMM7 + lldb_ymm8_x86_64, // AMD64_YMM8 + lldb_ymm9_x86_64, // AMD64_YMM9 + lldb_ymm10_x86_64, // AMD64_YMM10 + lldb_ymm11_x86_64, // AMD64_YMM11 + lldb_ymm12_x86_64, // AMD64_YMM12 + lldb_ymm13_x86_64, // AMD64_YMM13 + lldb_ymm14_x86_64, // AMD64_YMM14 + lldb_ymm15_x86_64, // AMD64_YMM15 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + lldb_bnd0_x86_64, // BND0 + lldb_bnd1_x86_64, // BND1 + lldb_bnd2_x86_64 // BND2 }; uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type, @@ -443,13 +442,13 @@ uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type, register_id)]; switch (register_id) { - case llvm::codeview::RegisterId::CVRegMXCSR: + case llvm::codeview::RegisterId::MXCSR: return lldb_mxcsr_i386; - case llvm::codeview::RegisterId::CVRegBND0: + case llvm::codeview::RegisterId::BND0: return lldb_bnd0_i386; - case llvm::codeview::RegisterId::CVRegBND1: + case llvm::codeview::RegisterId::BND1: return lldb_bnd1_i386; - case llvm::codeview::RegisterId::CVRegBND2: + case llvm::codeview::RegisterId::BND2: return lldb_bnd2_i386; default: return LLDB_INVALID_REGNUM; @@ -468,7 +467,7 @@ uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type, } uint32_t GetGenericRegisterNumber(llvm::codeview::RegisterId register_id) { - if (register_id == llvm::codeview::RegisterId::CVRegVFRAME) + if (register_id == llvm::codeview::RegisterId::VFRAME) return LLDB_REGNUM_GENERIC_FP; return LLDB_INVALID_REGNUM; diff --git a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h index 37b80dfccb84..7c34512e5f31 100644 --- a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h +++ b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h @@ -1,9 +1,8 @@ //===-- PDBLocationToDWARFExpression.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index bed7f557c58c..287c831e7f98 100644 --- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1,14 +1,16 @@ //===-- SymbolFilePDB.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "SymbolFilePDB.h" +#include "PDBASTParser.h" +#include "PDBLocationToDWARFExpression.h" + #include "clang/Lex/Lexer.h" #include "lldb/Core/Module.h" @@ -46,8 +48,8 @@ #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" -#include "Plugins/SymbolFile/PDB/PDBASTParser.h" -#include "Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h" +#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h" +#include "Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h" #include @@ -74,14 +76,32 @@ bool ShouldAddLine(uint32_t requested_line, uint32_t actual_line, } } // namespace +static bool ShouldUseNativeReader() { +#if defined(_WIN32) + llvm::StringRef use_native = ::getenv("LLDB_USE_NATIVE_PDB_READER"); + return use_native.equals_lower("on") || use_native.equals_lower("yes") || + use_native.equals_lower("1") || use_native.equals_lower("true"); +#else + return true; +#endif +} + void SymbolFilePDB::Initialize() { - PluginManager::RegisterPlugin(GetPluginNameStatic(), - GetPluginDescriptionStatic(), CreateInstance, - DebuggerInitialize); + if (ShouldUseNativeReader()) { + npdb::SymbolFileNativePDB::Initialize(); + } else { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + } } void SymbolFilePDB::Terminate() { - PluginManager::UnregisterPlugin(CreateInstance); + if (ShouldUseNativeReader()) { + npdb::SymbolFileNativePDB::Terminate(); + } else { + PluginManager::UnregisterPlugin(CreateInstance); + } } void SymbolFilePDB::DebuggerInitialize(lldb_private::Debugger &debugger) {} @@ -246,14 +266,8 @@ lldb::CompUnitSP SymbolFilePDB::ParseCompileUnitAtIndex(uint32_t index) { return ParseCompileUnitForUID(compiland_up->getSymIndexId(), index); } -lldb::LanguageType -SymbolFilePDB::ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) { - // What fields should I expect to be filled out on the SymbolContext? Is it - // safe to assume that `sc.comp_unit` is valid? - if (!sc.comp_unit) - return lldb::eLanguageTypeUnknown; - - auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID()); +lldb::LanguageType SymbolFilePDB::ParseLanguage(CompileUnit &comp_unit) { + auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) return lldb::eLanguageTypeUnknown; auto details = compiland_up->findOneChild(); @@ -262,9 +276,11 @@ SymbolFilePDB::ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) { return TranslateLanguage(details->getLanguage()); } -lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc( - const PDBSymbolFunc &pdb_func, const lldb_private::SymbolContext &sc) { - lldbassert(sc.comp_unit && sc.module_sp.get()); +lldb_private::Function * +SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func, + CompileUnit &comp_unit) { + if (FunctionSP result = comp_unit.FindFunctionByUID(pdb_func.getSymIndexId())) + return result.get(); auto file_vm_addr = pdb_func.getVirtualAddress(); if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0) @@ -272,7 +288,8 @@ lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc( auto func_length = pdb_func.getLength(); AddressRange func_range = - AddressRange(file_vm_addr, func_length, sc.module_sp->GetSectionList()); + AddressRange(file_vm_addr, func_length, + GetObjectFile()->GetModule()->GetSectionList()); if (!func_range.GetBaseAddress().IsValid()) return nullptr; @@ -285,59 +302,61 @@ lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc( Mangled mangled = GetMangledForPDBFunc(pdb_func); FunctionSP func_sp = - std::make_shared(sc.comp_unit, pdb_func.getSymIndexId(), + std::make_shared(&comp_unit, pdb_func.getSymIndexId(), func_type_uid, mangled, func_type, func_range); - sc.comp_unit->AddFunction(func_sp); + comp_unit.AddFunction(func_sp); + + TypeSystem *type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + if (!type_system) + return nullptr; + ClangASTContext *clang_type_system = + llvm::dyn_cast_or_null(type_system); + if (!clang_type_system) + return nullptr; + clang_type_system->GetPDBParser()->GetDeclForSymbol(pdb_func); + return func_sp.get(); } -size_t SymbolFilePDB::ParseCompileUnitFunctions( - const lldb_private::SymbolContext &sc) { - lldbassert(sc.comp_unit); +size_t SymbolFilePDB::ParseFunctions(CompileUnit &comp_unit) { size_t func_added = 0; - auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID()); + auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) return 0; auto results_up = compiland_up->findAllChildren(); if (!results_up) return 0; while (auto pdb_func_up = results_up->getNext()) { - auto func_sp = - sc.comp_unit->FindFunctionByUID(pdb_func_up->getSymIndexId()); + auto func_sp = comp_unit.FindFunctionByUID(pdb_func_up->getSymIndexId()); if (!func_sp) { - if (ParseCompileUnitFunctionForPDBFunc(*pdb_func_up, sc)) + if (ParseCompileUnitFunctionForPDBFunc(*pdb_func_up, comp_unit)) ++func_added; } } return func_added; } -bool SymbolFilePDB::ParseCompileUnitLineTable( - const lldb_private::SymbolContext &sc) { - lldbassert(sc.comp_unit); - if (sc.comp_unit->GetLineTable()) +bool SymbolFilePDB::ParseLineTable(CompileUnit &comp_unit) { + if (comp_unit.GetLineTable()) return true; - return ParseCompileUnitLineTable(sc, 0); + return ParseCompileUnitLineTable(comp_unit, 0); } -bool SymbolFilePDB::ParseCompileUnitDebugMacros( - const lldb_private::SymbolContext &sc) { +bool SymbolFilePDB::ParseDebugMacros(CompileUnit &comp_unit) { // PDB doesn't contain information about macros return false; } -bool SymbolFilePDB::ParseCompileUnitSupportFiles( - const lldb_private::SymbolContext &sc, - lldb_private::FileSpecList &support_files) { - lldbassert(sc.comp_unit); +bool SymbolFilePDB::ParseSupportFiles( + CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) { // In theory this is unnecessary work for us, because all of this information // is easily (and quickly) accessible from DebugInfoPDB, so caching it a // second time seems like a waste. Unfortunately, there's no good way around // this short of a moderate refactor since SymbolVendor depends on being able // to cache this list. - auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID()); + auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) return false; auto files = m_session_up->getSourceFilesForCompiland(*compiland_up); @@ -345,28 +364,27 @@ bool SymbolFilePDB::ParseCompileUnitSupportFiles( return false; while (auto file = files->getNext()) { - FileSpec spec(file->getFileName(), false, FileSpec::Style::windows); + FileSpec spec(file->getFileName(), FileSpec::Style::windows); support_files.AppendIfUnique(spec); } // LLDB uses the DWARF-like file numeration (one based), // the zeroth file is the compile unit itself - support_files.Insert(0, *sc.comp_unit); + support_files.Insert(0, comp_unit); return true; } bool SymbolFilePDB::ParseImportedModules( const lldb_private::SymbolContext &sc, - std::vector &imported_modules) { + std::vector &imported_modules) { // PDB does not yet support module debug info return false; } static size_t ParseFunctionBlocksForPDBSymbol( - const lldb_private::SymbolContext &sc, uint64_t func_file_vm_addr, - const llvm::pdb::PDBSymbol *pdb_symbol, lldb_private::Block *parent_block, - bool is_top_parent) { + uint64_t func_file_vm_addr, const llvm::pdb::PDBSymbol *pdb_symbol, + lldb_private::Block *parent_block, bool is_top_parent) { assert(pdb_symbol && parent_block); size_t num_added = 0; @@ -405,7 +423,7 @@ static size_t ParseFunctionBlocksForPDBSymbol( break; while (auto symbol_up = results_up->getNext()) { num_added += ParseFunctionBlocksForPDBSymbol( - sc, func_file_vm_addr, symbol_up.get(), block, false); + func_file_vm_addr, symbol_up.get(), block, false); } } break; default: @@ -414,28 +432,22 @@ static size_t ParseFunctionBlocksForPDBSymbol( return num_added; } -size_t -SymbolFilePDB::ParseFunctionBlocks(const lldb_private::SymbolContext &sc) { - lldbassert(sc.comp_unit && sc.function); +size_t SymbolFilePDB::ParseBlocksRecursive(Function &func) { size_t num_added = 0; - auto uid = sc.function->GetID(); + auto uid = func.GetID(); auto pdb_func_up = m_session_up->getConcreteSymbolById(uid); if (!pdb_func_up) return 0; - Block &parent_block = sc.function->GetBlock(false); - num_added = - ParseFunctionBlocksForPDBSymbol(sc, pdb_func_up->getVirtualAddress(), - pdb_func_up.get(), &parent_block, true); + Block &parent_block = func.GetBlock(false); + num_added = ParseFunctionBlocksForPDBSymbol( + pdb_func_up->getVirtualAddress(), pdb_func_up.get(), &parent_block, true); return num_added; } -size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) { - lldbassert(sc.module_sp.get()); - if (!sc.comp_unit) - return 0; +size_t SymbolFilePDB::ParseTypes(CompileUnit &comp_unit) { size_t num_added = 0; - auto compiland = GetPDBCompilandByUID(sc.comp_unit->GetID()); + auto compiland = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland) return 0; @@ -459,31 +471,26 @@ size_t SymbolFilePDB::ParseTypes(const lldb_private::SymbolContext &sc) { // This should cause the type to get cached and stored in the `m_types` // lookup. - if (!ResolveTypeUID(symbol->getSymIndexId())) - continue; - - ++num_added; + if (auto type = ResolveTypeUID(symbol->getSymIndexId())) { + // Resolve the type completely to avoid a completion + // (and so a list change, which causes an iterators invalidation) + // during a TypeList dumping + type->GetFullCompilerType(); + ++num_added; + } } } }; - if (sc.function) { - auto pdb_func = m_session_up->getConcreteSymbolById( - sc.function->GetID()); - if (!pdb_func) - return 0; - ParseTypesByTagFn(*pdb_func); - } else { - ParseTypesByTagFn(*compiland); - - // Also parse global types particularly coming from this compiland. - // Unfortunately, PDB has no compiland information for each global type. We - // have to parse them all. But ensure we only do this once. - static bool parse_all_global_types = false; - if (!parse_all_global_types) { - ParseTypesByTagFn(*m_global_scope_up); - parse_all_global_types = true; - } + ParseTypesByTagFn(*compiland); + + // Also parse global types particularly coming from this compiland. + // Unfortunately, PDB has no compiland information for each global type. We + // have to parse them all. But ensure we only do this once. + static bool parse_all_global_types = false; + if (!parse_all_global_types) { + ParseTypesByTagFn(*m_global_scope_up); + parse_all_global_types = true; } return num_added; } @@ -513,7 +520,7 @@ SymbolFilePDB::ParseVariablesForContext(const lldb_private::SymbolContext &sc) { auto results = m_global_scope_up->findAllChildren(); if (results && results->getChildCount()) { while (auto result = results->getNext()) { - auto cu_id = result->getCompilandId(); + auto cu_id = GetCompilandId(*result); // FIXME: We are not able to determine variable's compile unit. if (cu_id == 0) continue; @@ -548,8 +555,7 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) { llvm::dyn_cast_or_null(type_system); if (!clang_type_system) return nullptr; - PDBASTParser *pdb = - llvm::dyn_cast(clang_type_system->GetPDBParser()); + PDBASTParser *pdb = clang_type_system->GetPDBParser(); if (!pdb) return nullptr; @@ -573,33 +579,103 @@ llvm::Optional SymbolFilePDB::GetDynamicArrayInfoForUID( } bool SymbolFilePDB::CompleteType(lldb_private::CompilerType &compiler_type) { - // TODO: Implement this - return false; + std::lock_guard guard( + GetObjectFile()->GetModule()->GetMutex()); + + ClangASTContext *clang_ast_ctx = llvm::dyn_cast_or_null( + GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + if (!clang_ast_ctx) + return false; + + PDBASTParser *pdb = clang_ast_ctx->GetPDBParser(); + if (!pdb) + return false; + + return pdb->CompleteTypeFromPDB(compiler_type); } lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) { - return lldb_private::CompilerDecl(); + ClangASTContext *clang_ast_ctx = llvm::dyn_cast_or_null( + GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + if (!clang_ast_ctx) + return CompilerDecl(); + + PDBASTParser *pdb = clang_ast_ctx->GetPDBParser(); + if (!pdb) + return CompilerDecl(); + + auto symbol = m_session_up->getSymbolById(uid); + if (!symbol) + return CompilerDecl(); + + auto decl = pdb->GetDeclForSymbol(*symbol); + if (!decl) + return CompilerDecl(); + + return CompilerDecl(clang_ast_ctx, decl); } lldb_private::CompilerDeclContext SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) { - // PDB always uses the translation unit decl context for everything. We can - // improve this later but it's not easy because PDB doesn't provide a high - // enough level of type fidelity in this area. - return *m_tu_decl_ctx_up; + ClangASTContext *clang_ast_ctx = llvm::dyn_cast_or_null( + GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + if (!clang_ast_ctx) + return CompilerDeclContext(); + + PDBASTParser *pdb = clang_ast_ctx->GetPDBParser(); + if (!pdb) + return CompilerDeclContext(); + + auto symbol = m_session_up->getSymbolById(uid); + if (!symbol) + return CompilerDeclContext(); + + auto decl_context = pdb->GetDeclContextForSymbol(*symbol); + if (!decl_context) + return GetDeclContextContainingUID(uid); + + return CompilerDeclContext(clang_ast_ctx, decl_context); } lldb_private::CompilerDeclContext SymbolFilePDB::GetDeclContextContainingUID(lldb::user_id_t uid) { - return *m_tu_decl_ctx_up; + ClangASTContext *clang_ast_ctx = llvm::dyn_cast_or_null( + GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + if (!clang_ast_ctx) + return CompilerDeclContext(); + + PDBASTParser *pdb = clang_ast_ctx->GetPDBParser(); + if (!pdb) + return CompilerDeclContext(); + + auto symbol = m_session_up->getSymbolById(uid); + if (!symbol) + return CompilerDeclContext(); + + auto decl_context = pdb->GetDeclContextContainingSymbol(*symbol); + assert(decl_context); + + return CompilerDeclContext(clang_ast_ctx, decl_context); } void SymbolFilePDB::ParseDeclsForContext( - lldb_private::CompilerDeclContext decl_ctx) {} + lldb_private::CompilerDeclContext decl_ctx) { + ClangASTContext *clang_ast_ctx = llvm::dyn_cast_or_null( + GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus)); + if (!clang_ast_ctx) + return; + + PDBASTParser *pdb = clang_ast_ctx->GetPDBParser(); + if (!pdb) + return; + + pdb->ParseDeclsForDeclContext( + static_cast(decl_ctx.GetOpaqueDeclContext())); +} uint32_t SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr, - uint32_t resolve_scope, + SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) { uint32_t resolved_flags = 0; if (resolve_scope & eSymbolContextCompUnit || @@ -619,7 +695,8 @@ SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr, lldbassert(sc.module_sp == cu_sp->GetModule()); } - if (resolve_scope & eSymbolContextFunction) { + if (resolve_scope & eSymbolContextFunction || + resolve_scope & eSymbolContextBlock) { addr_t file_vm_addr = so_addr.GetFileAddress(); auto symbol_up = m_session_up->findSymbolByAddress(file_vm_addr, PDB_SymType::Function); @@ -629,12 +706,16 @@ SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr, auto func_uid = pdb_func->getSymIndexId(); sc.function = sc.comp_unit->FindFunctionByUID(func_uid).get(); if (sc.function == nullptr) - sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, sc); + sc.function = + ParseCompileUnitFunctionForPDBFunc(*pdb_func, *sc.comp_unit); if (sc.function) { resolved_flags |= eSymbolContextFunction; if (resolve_scope & eSymbolContextBlock) { - Block &block = sc.function->GetBlock(true); - sc.block = block.FindBlockByID(sc.function->GetID()); + auto block_symbol = m_session_up->findSymbolByAddress( + file_vm_addr, PDB_SymType::Block); + auto block_id = block_symbol ? block_symbol->getSymIndexId() + : sc.function->GetID(); + sc.block = sc.function->GetBlock(true).FindBlockByID(block_id); if (sc.block) resolved_flags |= eSymbolContextBlock; } @@ -655,7 +736,7 @@ SymbolFilePDB::ResolveSymbolContext(const lldb_private::Address &so_addr, uint32_t SymbolFilePDB::ResolveSymbolContext( const lldb_private::FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, lldb_private::SymbolContextList &sc_list) { + SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) { const size_t old_size = sc_list.GetSize(); if (resolve_scope & lldb::eSymbolContextCompUnit) { // Locate all compilation units with line numbers referencing the specified @@ -679,7 +760,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( std::string source_file = compiland->getSourceFileFullPath(); if (source_file.empty()) continue; - FileSpec this_spec(source_file, false, FileSpec::Style::windows); + FileSpec this_spec(source_file, FileSpec::Style::windows); bool need_full_match = !file_spec.GetDirectory().IsEmpty(); if (FileSpec::Compare(file_spec, this_spec, need_full_match) != 0) continue; @@ -696,7 +777,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( // table that match the requested line (or all lines if `line` == 0). if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock | eSymbolContextLineEntry)) { - bool has_line_table = ParseCompileUnitLineTable(sc, line); + bool has_line_table = ParseCompileUnitLineTable(*sc.comp_unit, line); if ((resolve_scope & eSymbolContextLineEntry) && !has_line_table) { // The query asks for line entries, but we can't get them for the @@ -739,7 +820,8 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( if (sc.function == nullptr) { auto pdb_func = llvm::dyn_cast(symbol_up.get()); assert(pdb_func); - sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, sc); + sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, + *sc.comp_unit); } if (sc.function && (resolve_scope & eSymbolContextBlock)) { Block &block = sc.function->GetBlock(true); @@ -764,24 +846,16 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( } std::string SymbolFilePDB::GetMangledForPDBData(const PDBSymbolData &pdb_data) { - std::string decorated_name; - auto vm_addr = pdb_data.getVirtualAddress(); - if (vm_addr != LLDB_INVALID_ADDRESS && vm_addr) { - auto result_up = - m_global_scope_up->findAllChildren(PDB_SymType::PublicSymbol); - if (result_up) { - while (auto symbol_up = result_up->getNext()) { - if (symbol_up->getRawSymbol().getVirtualAddress() == vm_addr) { - decorated_name = symbol_up->getRawSymbol().getName(); - break; - } - } - } - } - if (!decorated_name.empty()) - return decorated_name; - - return std::string(); + // Cache public names at first + if (m_public_names.empty()) + if (auto result_up = + m_global_scope_up->findAllChildren(PDB_SymType::PublicSymbol)) + while (auto symbol_up = result_up->getNext()) + if (auto addr = symbol_up->getRawSymbol().getVirtualAddress()) + m_public_names[addr] = symbol_up->getRawSymbol().getName(); + + // Look up the name in the cache + return m_public_names.lookup(pdb_data.getVirtualAddress()); } VariableSP SymbolFilePDB::ParseVariableForPDBData( @@ -848,7 +922,7 @@ VariableSP SymbolFilePDB::ParseVariableForPDBData( uint32_t src_file_id = first_line->getSourceFileId(); auto src_file = m_session_up->getSourceFileById(src_file_id); if (src_file) { - FileSpec spec(src_file->getFileName(), /*resolve_path*/ false); + FileSpec spec(src_file->getFileName()); decl.SetFile(spec); decl.SetColumn(first_line->getColumnNumber()); decl.SetLine(first_line->getLineNumber()); @@ -862,7 +936,7 @@ VariableSP SymbolFilePDB::ParseVariableForPDBData( if (scope == eValueTypeVariableLocal) { if (sc.function) { context_scope = sc.function->GetBlock(true).FindBlockByID( - pdb_data.getClassParentId()); + pdb_data.getLexicalParentId()); if (context_scope == nullptr) context_scope = sc.function; } @@ -942,6 +1016,9 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc, if (variable_list) variable_list->AddVariableIfUnique(var_sp); ++num_added; + PDBASTParser *ast = GetPDBAstParser(); + if (ast) + ast->GetDeclForSymbol(*pdb_data); } } } @@ -964,9 +1041,7 @@ uint32_t SymbolFilePDB::FindGlobalVariables( if (name.IsEmpty()) return 0; - auto results = - m_global_scope_up->findChildren(PDB_SymType::Data, name.GetStringRef(), - PDB_NameSearchFlags::NS_CaseSensitive); + auto results = m_global_scope_up->findAllChildren(); if (!results) return 0; @@ -981,11 +1056,19 @@ uint32_t SymbolFilePDB::FindGlobalVariables( sc.module_sp = m_obj_file->GetModule(); lldbassert(sc.module_sp.get()); - sc.comp_unit = ParseCompileUnitForUID(pdb_data->getCompilandId()).get(); + if (!name.GetStringRef().equals( + MSVCUndecoratedNameParser::DropScope(pdb_data->getName()))) + continue; + + sc.comp_unit = ParseCompileUnitForUID(GetCompilandId(*pdb_data)).get(); // FIXME: We are not able to determine the compile unit. if (sc.comp_unit == nullptr) continue; + if (parent_decl_ctx && GetDeclContextContainingUID( + result->getSymIndexId()) != *parent_decl_ctx) + continue; + ParseVariables(sc, *pdb_data, &variables); matches = variables.GetSize() - old_size; } @@ -1018,7 +1101,7 @@ SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression ®ex, sc.module_sp = m_obj_file->GetModule(); lldbassert(sc.module_sp.get()); - sc.comp_unit = ParseCompileUnitForUID(pdb_data->getCompilandId()).get(); + sc.comp_unit = ParseCompileUnitForUID(GetCompilandId(*pdb_data)).get(); // FIXME: We are not able to determine the compile unit. if (sc.comp_unit == nullptr) continue; @@ -1038,7 +1121,7 @@ bool SymbolFilePDB::ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func, if (!sc.comp_unit) return false; sc.module_sp = sc.comp_unit->GetModule(); - sc.function = ParseCompileUnitFunctionForPDBFunc(pdb_func, sc); + sc.function = ParseCompileUnitFunctionForPDBFunc(pdb_func, *sc.comp_unit); if (!sc.function) return false; @@ -1080,22 +1163,11 @@ void SymbolFilePDB::CacheFunctionNames() { // Class. We won't bother to check if the parent is UDT or Enum here. m_func_method_names.Append(ConstString(name), uid); - ConstString cstr_name(name); - // To search a method name, like NS::Class:MemberFunc, LLDB searches // its base name, i.e. MemberFunc by default. Since PDBSymbolFunc does // not have inforamtion of this, we extract base names and cache them // by our own effort. - llvm::StringRef basename; - CPlusPlusLanguage::MethodName cpp_method(cstr_name); - if (cpp_method.IsValid()) { - llvm::StringRef context; - basename = cpp_method.GetBasename(); - if (basename.empty()) - CPlusPlusLanguage::ExtractContextAndIdentifier(name.c_str(), - context, basename); - } - + llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name); if (!basename.empty()) m_func_base_names.Append(ConstString(basename), uid); else { @@ -1108,11 +1180,12 @@ void SymbolFilePDB::CacheFunctionNames() { } else { // Handle not-method symbols. - // The function name might contain namespace, or its lexical scope. It - // is not safe to get its base name by applying same scheme as we deal - // with the method names. - // FIXME: Remove namespace if function is static in a scope. - m_func_base_names.Append(ConstString(name), uid); + // The function name might contain namespace, or its lexical scope. + llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name); + if (!basename.empty()) + m_func_base_names.Append(ConstString(basename), uid); + else + m_func_base_names.Append(ConstString(name), uid); if (name == "main") { m_func_full_names.Append(ConstString(name), uid); @@ -1162,7 +1235,7 @@ void SymbolFilePDB::CacheFunctionNames() { uint32_t SymbolFilePDB::FindFunctions( const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) { if (!append) sc_list.Clear(); @@ -1182,20 +1255,28 @@ uint32_t SymbolFilePDB::FindFunctions( CacheFunctionNames(); std::set resolved_ids; - auto ResolveFn = [include_inlines, &name, &sc_list, &resolved_ids, - this](UniqueCStringMap &Names) { + auto ResolveFn = [this, &name, parent_decl_ctx, include_inlines, &sc_list, + &resolved_ids](UniqueCStringMap &Names) { std::vector ids; - if (Names.GetValues(name, ids)) { - for (auto id : ids) { - if (resolved_ids.find(id) == resolved_ids.end()) { - if (ResolveFunction(id, include_inlines, sc_list)) - resolved_ids.insert(id); - } - } + if (!Names.GetValues(name, ids)) + return; + + for (uint32_t id : ids) { + if (resolved_ids.find(id) != resolved_ids.end()) + continue; + + if (parent_decl_ctx && + GetDeclContextContainingUID(id) != *parent_decl_ctx) + continue; + + if (ResolveFunction(id, include_inlines, sc_list)) + resolved_ids.insert(id); } }; if (name_type_mask & eFunctionNameTypeFull) { ResolveFn(m_func_full_names); + ResolveFn(m_func_base_names); + ResolveFn(m_func_method_names); } if (name_type_mask & eFunctionNameTypeBase) { ResolveFn(m_func_base_names); @@ -1241,8 +1322,59 @@ void SymbolFilePDB::GetMangledNamesForFunction( const std::string &scope_qualified_name, std::vector &mangled_names) {} +void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) { + std::set sym_addresses; + for (size_t i = 0; i < symtab.GetNumSymbols(); i++) + sym_addresses.insert(symtab.SymbolAtIndex(i)->GetFileAddress()); + + auto results = m_global_scope_up->findAllChildren(); + if (!results) + return; + + auto section_list = m_obj_file->GetSectionList(); + if (!section_list) + return; + + while (auto pub_symbol = results->getNext()) { + auto section_idx = pub_symbol->getAddressSection() - 1; + if (section_idx >= section_list->GetSize()) + continue; + + auto section = section_list->GetSectionAtIndex(section_idx); + if (!section) + continue; + + auto offset = pub_symbol->getAddressOffset(); + + auto file_addr = section->GetFileAddress() + offset; + if (sym_addresses.find(file_addr) != sym_addresses.end()) + continue; + sym_addresses.insert(file_addr); + + auto size = pub_symbol->getLength(); + symtab.AddSymbol( + Symbol(pub_symbol->getSymIndexId(), // symID + pub_symbol->getName().c_str(), // name + true, // name_is_mangled + pub_symbol->isCode() ? eSymbolTypeCode : eSymbolTypeData, // type + true, // external + false, // is_debug + false, // is_trampoline + false, // is_artificial + section, // section_sp + offset, // value + size, // size + size != 0, // size_is_valid + false, // contains_linker_annotations + 0 // flags + )); + } + + symtab.CalculateSymbolSizes(); + symtab.Finalize(); +} + uint32_t SymbolFilePDB::FindTypes( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, @@ -1258,14 +1390,20 @@ uint32_t SymbolFilePDB::FindTypes( searched_symbol_files.clear(); searched_symbol_files.insert(this); - std::string name_str = name.AsCString(); - // There is an assumption 'name' is not a regex - FindTypesByName(name_str, max_matches, types); + FindTypesByName(name.GetStringRef(), parent_decl_ctx, max_matches, types); return types.GetSize(); } +void SymbolFilePDB::DumpClangAST(Stream &s) { + auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + auto clang = llvm::dyn_cast_or_null(type_system); + if (!clang) + return; + clang->Dump(s); +} + void SymbolFilePDB::FindTypesByRegex( const lldb_private::RegularExpression ®ex, uint32_t max_matches, lldb_private::TypeMap &types) { @@ -1321,14 +1459,14 @@ void SymbolFilePDB::FindTypesByRegex( } } -void SymbolFilePDB::FindTypesByName(const std::string &name, - uint32_t max_matches, - lldb_private::TypeMap &types) { +void SymbolFilePDB::FindTypesByName( + llvm::StringRef name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + uint32_t max_matches, lldb_private::TypeMap &types) { std::unique_ptr results; if (name.empty()) return; - results = m_global_scope_up->findChildren(PDB_SymType::None, name, - PDB_NameSearchFlags::NS_Default); + results = m_global_scope_up->findAllChildren(PDB_SymType::None); if (!results) return; @@ -1337,6 +1475,11 @@ void SymbolFilePDB::FindTypesByName(const std::string &name, while (auto result = results->getNext()) { if (max_matches > 0 && matches >= max_matches) break; + + if (MSVCUndecoratedNameParser::DropScope( + result->getRawSymbol().getName()) != name) + continue; + switch (result->getSymTag()) { case PDB_SymType::Enum: case PDB_SymType::UDT: @@ -1353,6 +1496,10 @@ void SymbolFilePDB::FindTypesByName(const std::string &name, if (!ResolveTypeUID(result->getSymIndexId())) continue; + if (parent_decl_ctx && GetDeclContextContainingUID( + result->getSymIndexId()) != *parent_decl_ctx) + continue; + auto iter = m_types.find(result->getSymIndexId()); if (iter == m_types.end()) continue; @@ -1422,7 +1569,7 @@ void SymbolFilePDB::GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol, } size_t SymbolFilePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + TypeClass type_mask, lldb_private::TypeList &type_list) { TypeCollection type_collection; uint32_t old_size = type_list.GetSize(); @@ -1459,11 +1606,40 @@ SymbolFilePDB::GetTypeSystemForLanguage(lldb::LanguageType language) { return type_system; } +PDBASTParser *SymbolFilePDB::GetPDBAstParser() { + auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + auto clang_type_system = llvm::dyn_cast_or_null(type_system); + if (!clang_type_system) + return nullptr; + + return clang_type_system->GetPDBParser(); +} + + lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx) { - return lldb_private::CompilerDeclContext(); + auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + auto clang_type_system = llvm::dyn_cast_or_null(type_system); + if (!clang_type_system) + return CompilerDeclContext(); + + PDBASTParser *pdb = clang_type_system->GetPDBParser(); + if (!pdb) + return CompilerDeclContext(); + + clang::DeclContext *decl_context = nullptr; + if (parent_decl_ctx) + decl_context = static_cast( + parent_decl_ctx->GetOpaqueDeclContext()); + + auto namespace_decl = + pdb->FindNamespaceDecl(decl_context, name.GetStringRef()); + if (!namespace_decl) + return CompilerDeclContext(); + + return CompilerDeclContext(type_system, + static_cast(namespace_decl)); } lldb_private::ConstString SymbolFilePDB::GetPluginName() { @@ -1521,11 +1697,9 @@ lldb::CompUnitSP SymbolFilePDB::ParseCompileUnitForUID(uint32_t id, return cu_sp; } -bool SymbolFilePDB::ParseCompileUnitLineTable( - const lldb_private::SymbolContext &sc, uint32_t match_line) { - lldbassert(sc.comp_unit); - - auto compiland_up = GetPDBCompilandByUID(sc.comp_unit->GetID()); +bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit, + uint32_t match_line) { + auto compiland_up = GetPDBCompilandByUID(comp_unit.GetID()); if (!compiland_up) return false; @@ -1535,10 +1709,10 @@ bool SymbolFilePDB::ParseCompileUnitLineTable( // to do a mapping so that we can hand out indices. llvm::DenseMap index_map; BuildSupportFileIdToSupportFileIndexMap(*compiland_up, index_map); - auto line_table = llvm::make_unique(sc.comp_unit); + auto line_table = llvm::make_unique(&comp_unit); // Find contributions to `compiland` from all source and header files. - std::string path = sc.comp_unit->GetPath(); + std::string path = comp_unit.GetPath(); auto files = m_session_up->getSourceFilesForCompiland(*compiland_up); if (!files) return false; @@ -1622,7 +1796,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable( } if (line_table->GetSize()) { - sc.comp_unit->SetLineTable(line_table.release()); + comp_unit.SetLineTable(line_table.release()); return true; } return false; @@ -1752,3 +1926,68 @@ bool SymbolFilePDB::DeclContextMatchesThisSymbolFile( return false; } + +uint32_t SymbolFilePDB::GetCompilandId(const llvm::pdb::PDBSymbolData &data) { + static const auto pred_upper = [](uint32_t lhs, SecContribInfo rhs) { + return lhs < rhs.Offset; + }; + + // Cache section contributions + if (m_sec_contribs.empty()) { + if (auto SecContribs = m_session_up->getSectionContribs()) { + while (auto SectionContrib = SecContribs->getNext()) { + auto comp_id = SectionContrib->getCompilandId(); + if (!comp_id) + continue; + + auto sec = SectionContrib->getAddressSection(); + auto &sec_cs = m_sec_contribs[sec]; + + auto offset = SectionContrib->getAddressOffset(); + auto it = + std::upper_bound(sec_cs.begin(), sec_cs.end(), offset, pred_upper); + + auto size = SectionContrib->getLength(); + sec_cs.insert(it, {offset, size, comp_id}); + } + } + } + + // Check by line number + if (auto Lines = data.getLineNumbers()) { + if (auto FirstLine = Lines->getNext()) + return FirstLine->getCompilandId(); + } + + // Retrieve section + offset + uint32_t DataSection = data.getAddressSection(); + uint32_t DataOffset = data.getAddressOffset(); + if (DataSection == 0) { + if (auto RVA = data.getRelativeVirtualAddress()) + m_session_up->addressForRVA(RVA, DataSection, DataOffset); + } + + if (DataSection) { + // Search by section contributions + auto &sec_cs = m_sec_contribs[DataSection]; + auto it = + std::upper_bound(sec_cs.begin(), sec_cs.end(), DataOffset, pred_upper); + if (it != sec_cs.begin()) { + --it; + if (DataOffset < it->Offset + it->Size) + return it->CompilandId; + } + } else { + // Search in lexical tree + auto LexParentId = data.getLexicalParentId(); + while (auto LexParent = m_session_up->getSymbolById(LexParentId)) { + if (LexParent->getSymTag() == PDB_SymType::Exe) + break; + if (LexParent->getSymTag() == PDB_SymType::Compiland) + return LexParentId; + LexParentId = LexParent->getRawSymbol().getLexicalParentId(); + } + } + + return 0; +} diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h index 66c9d329e502..e3b093175071 100644 --- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -1,9 +1,8 @@ //===-- SymbolFilePDB.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,6 +19,8 @@ #include "llvm/DebugInfo/PDB/PDB.h" #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" +class PDBASTParser; + class SymbolFilePDB : public lldb_private::SymbolFile { public: //------------------------------------------------------------------ @@ -58,28 +59,24 @@ class SymbolFilePDB : public lldb_private::SymbolFile { lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; lldb::LanguageType - ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override; + ParseLanguage(lldb_private::CompileUnit &comp_unit) override; - size_t - ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override; + size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; - bool - ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override; + bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; - bool - ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override; + bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; - bool ParseCompileUnitSupportFiles( - const lldb_private::SymbolContext &sc, - lldb_private::FileSpecList &support_files) override; + bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, + lldb_private::FileSpecList &support_files) override; + + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; bool ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) override; - size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t ParseBlocksRecursive(lldb_private::Function &func) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; @@ -103,12 +100,13 @@ class SymbolFilePDB : public lldb_private::SymbolFile { ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override; uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override; uint32_t ResolveSymbolContext(const lldb_private::FileSpec &file_spec, uint32_t line, - bool check_inlines, uint32_t resolve_scope, + bool check_inlines, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override; uint32_t @@ -124,8 +122,8 @@ class SymbolFilePDB : public lldb_private::SymbolFile { uint32_t FindFunctions(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, bool append, - lldb_private::SymbolContextList &sc_list) override; + lldb::FunctionNameType name_type_mask, bool include_inlines, + bool append, lldb_private::SymbolContextList &sc_list) override; uint32_t FindFunctions(const lldb_private::RegularExpression ®ex, bool include_inlines, bool append, @@ -135,9 +133,10 @@ class SymbolFilePDB : public lldb_private::SymbolFile { const std::string &scope_qualified_name, std::vector &mangled_names) override; + void AddSymbols(lldb_private::Symtab &symtab) override; + uint32_t - FindTypes(const lldb_private::SymbolContext &sc, - const lldb_private::ConstString &name, + FindTypes(const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, @@ -152,14 +151,13 @@ class SymbolFilePDB : public lldb_private::SymbolFile { lldb_private::TypeList *GetTypeList() override; size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override; lldb_private::TypeSystem * GetTypeSystemForLanguage(lldb::LanguageType language) override; lldb_private::CompilerDeclContext FindNamespace( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const lldb_private::CompilerDeclContext *parent_decl_ctx) override; @@ -171,19 +169,29 @@ class SymbolFilePDB : public lldb_private::SymbolFile { const llvm::pdb::IPDBSession &GetPDBSession() const; + void DumpClangAST(lldb_private::Stream &s) override; + private: + struct SecContribInfo { + uint32_t Offset; + uint32_t Size; + uint32_t CompilandId; + }; + using SecContribsMap = std::map>; + lldb::CompUnitSP ParseCompileUnitForUID(uint32_t id, uint32_t index = UINT32_MAX); - bool ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc, + bool ParseCompileUnitLineTable(lldb_private::CompileUnit &comp_unit, uint32_t match_line); void BuildSupportFileIdToSupportFileIndexMap( const llvm::pdb::PDBSymbolCompiland &pdb_compiland, llvm::DenseMap &index_map) const; - void FindTypesByName(const std::string &name, uint32_t max_matches, - lldb_private::TypeMap &types); + void FindTypesByName(llvm::StringRef name, + const lldb_private::CompilerDeclContext *parent_decl_ctx, + uint32_t max_matches, lldb_private::TypeMap &types); std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data); @@ -206,11 +214,13 @@ class SymbolFilePDB : public lldb_private::SymbolFile { lldb_private::Function * ParseCompileUnitFunctionForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func, - const lldb_private::SymbolContext &sc); + lldb_private::CompileUnit &comp_unit); void GetCompileUnitIndex(const llvm::pdb::PDBSymbolCompiland &pdb_compiland, uint32_t &index); + PDBASTParser *GetPDBAstParser(); + std::unique_ptr GetPDBCompilandByUID(uint32_t uid); @@ -229,9 +239,14 @@ class SymbolFilePDB : public lldb_private::SymbolFile { bool DeclContextMatchesThisSymbolFile( const lldb_private::CompilerDeclContext *decl_ctx); + uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data); + llvm::DenseMap m_comp_units; llvm::DenseMap m_types; llvm::DenseMap m_variables; + llvm::DenseMap m_public_names; + + SecContribsMap m_sec_contribs; std::vector m_builtin_types; std::unique_ptr m_session_up; diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 4c7b60c65e56..3d2e7a2f3eab 100644 --- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -1,9 +1,8 @@ //===-- SymbolFileSymtab.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -46,7 +45,7 @@ SymbolFile *SymbolFileSymtab::CreateInstance(ObjectFile *obj_file) { } size_t SymbolFileSymtab::GetTypes(SymbolContextScope *sc_scope, - uint32_t type_mask, + TypeClass type_mask, lldb_private::TypeList &type_list) { return 0; } @@ -131,15 +130,13 @@ CompUnitSP SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx) { return cu_sp; } -lldb::LanguageType -SymbolFileSymtab::ParseCompileUnitLanguage(const SymbolContext &sc) { +lldb::LanguageType SymbolFileSymtab::ParseLanguage(CompileUnit &comp_unit) { return eLanguageTypeUnknown; } -size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { +size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) { size_t num_added = 0; // We must at least have a valid compile unit - assert(sc.comp_unit != NULL); const Symtab *symtab = m_obj_file->GetSymtab(); const Symbol *curr_symbol = NULL; const Symbol *next_symbol = NULL; @@ -185,7 +182,7 @@ size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { } FunctionSP func_sp( - new Function(sc.comp_unit, + new Function(&comp_unit, symbol_idx, // UserID is the DIE offset LLDB_INVALID_UID, // We don't have any type info // for this function @@ -194,7 +191,7 @@ size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { func_range)); // first address range if (func_sp.get() != NULL) { - sc.comp_unit->AddFunction(func_sp); + comp_unit.AddFunction(func_sp); ++num_added; } } @@ -207,16 +204,16 @@ size_t SymbolFileSymtab::ParseCompileUnitFunctions(const SymbolContext &sc) { return num_added; } -bool SymbolFileSymtab::ParseCompileUnitLineTable(const SymbolContext &sc) { - return false; -} +size_t SymbolFileSymtab::ParseTypes(CompileUnit &comp_unit) { return 0; } + +bool SymbolFileSymtab::ParseLineTable(CompileUnit &comp_unit) { return false; } -bool SymbolFileSymtab::ParseCompileUnitDebugMacros(const SymbolContext &sc) { +bool SymbolFileSymtab::ParseDebugMacros(CompileUnit &comp_unit) { return false; } -bool SymbolFileSymtab::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { +bool SymbolFileSymtab::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { return false; } @@ -225,11 +222,7 @@ bool SymbolFileSymtab::ParseImportedModules( return false; } -size_t SymbolFileSymtab::ParseFunctionBlocks(const SymbolContext &sc) { - return 0; -} - -size_t SymbolFileSymtab::ParseTypes(const SymbolContext &sc) { return 0; } +size_t SymbolFileSymtab::ParseBlocksRecursive(Function &func) { return 0; } size_t SymbolFileSymtab::ParseVariablesForContext(const SymbolContext &sc) { return 0; @@ -250,7 +243,7 @@ bool SymbolFileSymtab::CompleteType(lldb_private::CompilerType &compiler_type) { } uint32_t SymbolFileSymtab::ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + SymbolContextItem resolve_scope, SymbolContext &sc) { if (m_obj_file->GetSymtab() == NULL) return 0; diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h index 489a7dbc9873..f2e90c954512 100644 --- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h +++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h @@ -1,22 +1,17 @@ //===-- SymbolFileSymtab.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SymbolFileSymtab_h_ #define liblldb_SymbolFileSymtab_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/Symtab.h" @@ -53,28 +48,24 @@ class SymbolFileSymtab : public lldb_private::SymbolFile { lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override; lldb::LanguageType - ParseCompileUnitLanguage(const lldb_private::SymbolContext &sc) override; + ParseLanguage(lldb_private::CompileUnit &comp_unit) override; - size_t - ParseCompileUnitFunctions(const lldb_private::SymbolContext &sc) override; + size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override; - bool - ParseCompileUnitLineTable(const lldb_private::SymbolContext &sc) override; + bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override; - bool - ParseCompileUnitDebugMacros(const lldb_private::SymbolContext &sc) override; + bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override; - bool ParseCompileUnitSupportFiles( - const lldb_private::SymbolContext &sc, - lldb_private::FileSpecList &support_files) override; + bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, + lldb_private::FileSpecList &support_files) override; + + size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override; bool ParseImportedModules( const lldb_private::SymbolContext &sc, std::vector &imported_modules) override; - size_t ParseFunctionBlocks(const lldb_private::SymbolContext &sc) override; - - size_t ParseTypes(const lldb_private::SymbolContext &sc) override; + size_t ParseBlocksRecursive(lldb_private::Function &func) override; size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override; @@ -87,11 +78,11 @@ class SymbolFileSymtab : public lldb_private::SymbolFile { bool CompleteType(lldb_private::CompilerType &compiler_type) override; uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override; size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override; //------------------------------------------------------------------ diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp index d24510966878..4040f20d08b3 100644 --- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -1,9 +1,8 @@ //===-- SymbolVendorELF.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -101,16 +100,17 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp, const FileSpec fspec = file_spec_list.GetFileSpecAtIndex(idx); module_spec.GetFileSpec() = obj_file->GetFileSpec(); - module_spec.GetFileSpec().ResolvePath(); + FileSystem::Instance().Resolve(module_spec.GetFileSpec()); module_spec.GetSymbolFileSpec() = fspec; module_spec.GetUUID() = uuid; FileSpec dsym_fspec = Symbols::LocateExecutableSymbolFile(module_spec); if (dsym_fspec) { DataBufferSP dsym_file_data_sp; lldb::offset_t dsym_file_data_offset = 0; - ObjectFileSP dsym_objfile_sp = ObjectFile::FindPlugin( - module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(), - dsym_file_data_sp, dsym_file_data_offset); + ObjectFileSP dsym_objfile_sp = + ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0, + FileSystem::Instance().GetByteSize(dsym_fspec), + dsym_file_data_sp, dsym_file_data_offset); if (dsym_objfile_sp) { // This objfile is for debugging purposes. Sadly, ObjectFileELF won't // be able to figure this out consistently as the symbol file may not diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h index e7aeebc96b94..60d30218bc59 100644 --- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h +++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h @@ -1,19 +1,14 @@ //===-- SymbolVendorELF.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SymbolVendorELF_h_ #define liblldb_SymbolVendorELF_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/SymbolVendor.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index c69eb7fd51c7..4451bfa9e0f8 100644 --- a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -1,9 +1,8 @@ //===-- SymbolVendorMacOSX.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -153,9 +152,10 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp, if (dsym_fspec) { DataBufferSP dsym_file_data_sp; lldb::offset_t dsym_file_data_offset = 0; - dsym_objfile_sp = ObjectFile::FindPlugin( - module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(), - dsym_file_data_sp, dsym_file_data_offset); + dsym_objfile_sp = + ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0, + FileSystem::Instance().GetByteSize(dsym_fspec), + dsym_file_data_sp, dsym_file_data_offset); if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get(), feedback_strm)) { // We need a XML parser if we hope to parse a plist... if (XMLDocument::XMLEnabled()) { @@ -172,8 +172,8 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp, resources[strlen("/Contents/Resources/")] = '\0'; snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path), "%s%s.plist", dsym_path, uuid_str.c_str()); - FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path, false); - if (dsym_uuid_plist_spec.Exists()) { + FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path); + if (FileSystem::Instance().Exists(dsym_uuid_plist_spec)) { ApplePropertyList plist(dsym_uuid_plist_path); if (plist) { std::string DBGBuildSourcePath; @@ -236,14 +236,15 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp, // object is DBGSourcePath std::string DBGSourcePath = object->GetStringValue(); - if (new_style_source_remapping_dictionary == - false && + if (!new_style_source_remapping_dictionary && !original_DBGSourcePath_value.empty()) { DBGSourcePath = original_DBGSourcePath_value; } if (DBGSourcePath[0] == '~') { FileSpec resolved_source_path( - DBGSourcePath.c_str(), true); + DBGSourcePath.c_str()); + FileSystem::Instance().Resolve( + resolved_source_path); DBGSourcePath = resolved_source_path.GetPath(); } @@ -256,8 +257,8 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp, // Add this as another option in addition to // the full source path remap. if (do_truncate_remapping_names) { - FileSpec build_path(key.AsCString(), false); - FileSpec source_path(DBGSourcePath.c_str(), false); + FileSpec build_path(key.AsCString()); + FileSpec source_path(DBGSourcePath.c_str()); build_path.RemoveLastPathComponent(); build_path.RemoveLastPathComponent(); source_path.RemoveLastPathComponent(); @@ -280,8 +281,8 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp, if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) { if (DBGSourcePath[0] == '~') { - FileSpec resolved_source_path(DBGSourcePath.c_str(), - true); + FileSpec resolved_source_path(DBGSourcePath.c_str()); + FileSystem::Instance().Resolve(resolved_source_path); DBGSourcePath = resolved_source_path.GetPath(); } module_sp->GetSourceMappingList().Append( diff --git a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h index 53b5291af031..100086bf3e82 100644 --- a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h +++ b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h @@ -1,9 +1,8 @@ //===-- SymbolVendorMacOSX.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index 91187ae7f42f..92e2b24d8484 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -1,19 +1,14 @@ //===-- AppleGetItemInfoHandler.cpp -------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "AppleGetItemInfoHandler.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" @@ -242,7 +237,7 @@ AppleGetItemInfoHandler::GetItemInfo(Thread &thread, uint64_t item, error.Clear(); - if (thread.SafeToCallFunctions() == false) { + if (!thread.SafeToCallFunctions()) { if (log) log->Printf("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h index 373808e0f7e8..d0e79fb1ed89 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h @@ -1,23 +1,18 @@ //===-- AppleGetItemInfoHandler.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_AppleGetItemInfoHandler_h_ #define lldb_AppleGetItemInfoHandler_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Expression/UtilityFunction.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/Status.h" diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index 67436385cbd8..dfafea3f7ef5 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -1,19 +1,14 @@ //===-- AppleGetPendingItemsHandler.cpp -------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "AppleGetPendingItemsHandler.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" @@ -245,7 +240,7 @@ AppleGetPendingItemsHandler::GetPendingItems(Thread &thread, addr_t queue, error.Clear(); - if (thread.SafeToCallFunctions() == false) { + if (!thread.SafeToCallFunctions()) { if (log) log->Printf("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h index 139e05b1b6c9..742e09d92a5b 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h @@ -1,24 +1,19 @@ //===-- AppleGetPendingItemsHandler.h ----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_AppleGetPendingItemsHandler_h_ #define lldb_AppleGetPendingItemsHandler_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-public.h" diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index 038e6635823c..8f896b62f579 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -1,18 +1,13 @@ //===-- AppleGetQueuesHandler.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "AppleGetQueuesHandler.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DiagnosticManager.h" @@ -247,7 +242,7 @@ AppleGetQueuesHandler::GetCurrentQueues(Thread &thread, addr_t page_to_free, error.Clear(); - if (thread.SafeToCallFunctions() == false) { + if (!thread.SafeToCallFunctions()) { if (log) log->Printf("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h index f1c79044496f..d361ef1c682b 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h @@ -1,23 +1,18 @@ //===-- AppleGetQueuesHandler.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_AppleGetQueuesHandler_h_ #define lldb_AppleGetQueuesHandler_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-public.h" diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index f38ab086dd4d..5bbbffaf0398 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -1,19 +1,14 @@ //===-- AppleGetThreadItemInfoHandler.cpp -------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "AppleGetThreadItemInfoHandler.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" @@ -252,7 +247,7 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo(Thread &thread, error.Clear(); - if (thread.SafeToCallFunctions() == false) { + if (!thread.SafeToCallFunctions()) { if (log) log->Printf("Not safe to call functions on thread 0x%" PRIx64, thread.GetID()); diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h index 62730809e0d1..381f0f5d57a5 100644 --- a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h +++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h @@ -1,24 +1,19 @@ //===-- AppleGetThreadItemInfoHandler.h ----------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 lldb_AppleGetThreadItemInfoHandler_h_ #define lldb_AppleGetThreadItemInfoHandler_h_ -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes -// Project includes #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-public.h" diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 24b6de2167a5..6dca6b650f56 100644 --- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -1,9 +1,8 @@ //===-- SystemRuntimeMacOSX.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -277,7 +276,7 @@ void SystemRuntimeMacOSX::ReadLibdispatchOffsetsAddress() { // libdispatch symbols were in libSystem.B.dylib up through Mac OS X 10.6 // ("Snow Leopard") - ModuleSpec libSystem_module_spec(FileSpec("libSystem.B.dylib", false)); + ModuleSpec libSystem_module_spec(FileSpec("libSystem.B.dylib")); ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule( libSystem_module_spec)); if (module_sp) @@ -287,7 +286,7 @@ void SystemRuntimeMacOSX::ReadLibdispatchOffsetsAddress() { // libdispatch symbols are in their own dylib as of Mac OS X 10.7 ("Lion") // and later if (dispatch_queue_offsets_symbol == NULL) { - ModuleSpec libdispatch_module_spec(FileSpec("libdispatch.dylib", false)); + ModuleSpec libdispatch_module_spec(FileSpec("libdispatch.dylib")); module_sp = m_process->GetTarget().GetImages().FindFirstModule( libdispatch_module_spec); if (module_sp) @@ -331,7 +330,7 @@ void SystemRuntimeMacOSX::ReadLibpthreadOffsetsAddress() { "pthread_layout_offsets"); const Symbol *libpthread_layout_offsets_symbol = NULL; - ModuleSpec libpthread_module_spec(FileSpec("libsystem_pthread.dylib", false)); + ModuleSpec libpthread_module_spec(FileSpec("libsystem_pthread.dylib")); ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule( libpthread_module_spec)); if (module_sp) { @@ -379,7 +378,7 @@ void SystemRuntimeMacOSX::ReadLibdispatchTSDIndexesAddress() { "dispatch_tsd_indexes"); const Symbol *libdispatch_tsd_indexes_symbol = NULL; - ModuleSpec libpthread_module_spec(FileSpec("libdispatch.dylib", false)); + ModuleSpec libpthread_module_spec(FileSpec("libdispatch.dylib")); ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule( libpthread_module_spec)); if (module_sp) { diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h index 2dc5740da9b6..c571bad42dd3 100644 --- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -1,23 +1,19 @@ //===-- SystemRuntimeMacOSX.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_SystemRuntimeMacOSX_h_ #define liblldb_SystemRuntimeMacOSX_h_ -// C Includes -// C++ Includes #include #include #include // Other libraries and framework include -// Project includes #include "lldb/Core/ModuleList.h" #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp index 54e182b30b6f..dc16e0c9123a 100644 --- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp +++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp @@ -1,9 +1,8 @@ //===-- UnwindAssemblyInstEmulation.cpp --------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -606,7 +605,7 @@ bool UnwindAssemblyInstEmulation::WriteRegister( assert( (generic_regnum == LLDB_REGNUM_GENERIC_PC || generic_regnum == LLDB_REGNUM_GENERIC_FLAGS) && - "eInfoTypeISA used for poping a register other the the PC/FLAGS"); + "eInfoTypeISA used for popping a register other the PC/FLAGS"); if (generic_regnum != LLDB_REGNUM_GENERIC_FLAGS) { m_curr_row->SetRegisterLocationToSame(reg_num, false /*must_replace*/); diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h index e587c93b427c..3bbccc01eb02 100644 --- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h +++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h @@ -1,23 +1,18 @@ //===-- UnwindAssemblyInstEmulation.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UnwindAssemblyInstEmulation_h_ #define liblldb_UnwindAssemblyInstEmulation_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/UnwindAssembly.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly { diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp index 327d0b0e4f71..d8a820ca6fc2 100644 --- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp +++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp @@ -1,9 +1,8 @@ //===-- UnwindAssembly-x86.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -92,7 +91,7 @@ bool UnwindAssembly_x86::AugmentUnwindPlanFromCallSite( // assembly parsing instead. if (first_row->GetCFAValue().GetValueType() != - UnwindPlan::Row::CFAValue::isRegisterPlusOffset || + UnwindPlan::Row::FAValue::isRegisterPlusOffset || RegisterNumber(thread, unwind_plan.GetRegisterKind(), first_row->GetCFAValue().GetRegisterNumber()) != sp_regnum || @@ -100,10 +99,10 @@ bool UnwindAssembly_x86::AugmentUnwindPlanFromCallSite( return false; } UnwindPlan::Row::RegisterLocation first_row_pc_loc; - if (first_row->GetRegisterInfo( + if (!first_row->GetRegisterInfo( pc_regnum.GetAsKind(unwind_plan.GetRegisterKind()), - first_row_pc_loc) == false || - first_row_pc_loc.IsAtCFAPlusOffset() == false || + first_row_pc_loc) || + !first_row_pc_loc.IsAtCFAPlusOffset() || first_row_pc_loc.GetOffset() != -wordsize) { return false; } diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h index 2beaa4a6510a..ffc8aa63b1b9 100644 --- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h +++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h @@ -1,21 +1,16 @@ //===-- UnwindAssembly-x86.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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_UnwindAssembly_x86_h_ #define liblldb_UnwindAssembly_x86_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "x86AssemblyInspectionEngine.h" -// Project includes #include "lldb/Target/UnwindAssembly.h" #include "lldb/lldb-private.h" diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp index 10a56980594f..8037095a825b 100644 --- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp +++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp @@ -1,9 +1,8 @@ //===-- x86AssemblyInspectionEngine.cpp -------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -59,6 +58,7 @@ void x86AssemblyInspectionEngine::Initialize(RegisterContextSP ®_ctx) { m_machine_ip_regnum = k_machine_eip; m_machine_sp_regnum = k_machine_esp; m_machine_fp_regnum = k_machine_ebp; + m_machine_alt_fp_regnum = k_machine_ebx; m_wordsize = 4; struct lldb_reg_info reginfo; @@ -84,6 +84,7 @@ void x86AssemblyInspectionEngine::Initialize(RegisterContextSP ®_ctx) { m_machine_ip_regnum = k_machine_rip; m_machine_sp_regnum = k_machine_rsp; m_machine_fp_regnum = k_machine_rbp; + m_machine_alt_fp_regnum = k_machine_rbx; m_wordsize = 8; struct lldb_reg_info reginfo; @@ -135,6 +136,8 @@ void x86AssemblyInspectionEngine::Initialize(RegisterContextSP ®_ctx) { m_lldb_sp_regnum = lldb_regno; if (machine_regno_to_lldb_regno(m_machine_fp_regnum, lldb_regno)) m_lldb_fp_regnum = lldb_regno; + if (machine_regno_to_lldb_regno(m_machine_alt_fp_regnum, lldb_regno)) + m_lldb_alt_fp_regnum = lldb_regno; if (machine_regno_to_lldb_regno(m_machine_ip_regnum, lldb_regno)) m_lldb_ip_regnum = lldb_regno; @@ -160,6 +163,7 @@ void x86AssemblyInspectionEngine::Initialize( m_machine_ip_regnum = k_machine_eip; m_machine_sp_regnum = k_machine_esp; m_machine_fp_regnum = k_machine_ebp; + m_machine_alt_fp_regnum = k_machine_ebx; m_wordsize = 4; struct lldb_reg_info reginfo; @@ -185,6 +189,7 @@ void x86AssemblyInspectionEngine::Initialize( m_machine_ip_regnum = k_machine_rip; m_machine_sp_regnum = k_machine_rsp; m_machine_fp_regnum = k_machine_rbp; + m_machine_alt_fp_regnum = k_machine_rbx; m_wordsize = 8; struct lldb_reg_info reginfo; @@ -239,6 +244,8 @@ void x86AssemblyInspectionEngine::Initialize( m_lldb_sp_regnum = lldb_regno; if (machine_regno_to_lldb_regno(m_machine_fp_regnum, lldb_regno)) m_lldb_fp_regnum = lldb_regno; + if (machine_regno_to_lldb_regno(m_machine_alt_fp_regnum, lldb_regno)) + m_lldb_alt_fp_regnum = lldb_regno; if (machine_regno_to_lldb_regno(m_machine_ip_regnum, lldb_regno)) m_lldb_ip_regnum = lldb_regno; @@ -296,26 +303,20 @@ bool x86AssemblyInspectionEngine::nonvolatile_reg_p(int machine_regno) { // pushq %rbp [0x55] bool x86AssemblyInspectionEngine::push_rbp_pattern_p() { uint8_t *p = m_cur_insn; - if (*p == 0x55) - return true; - return false; + return *p == 0x55; } // pushq $0 ; the first instruction in start() [0x6a 0x00] bool x86AssemblyInspectionEngine::push_0_pattern_p() { uint8_t *p = m_cur_insn; - if (*p == 0x6a && *(p + 1) == 0x0) - return true; - return false; + return *p == 0x6a && *(p + 1) == 0x0; } // pushq $0 // pushl $0 bool x86AssemblyInspectionEngine::push_imm_pattern_p() { uint8_t *p = m_cur_insn; - if (*p == 0x68 || *p == 0x6a) - return true; - return false; + return *p == 0x68 || *p == 0x6a; } // pushl imm8(%esp) @@ -387,6 +388,45 @@ bool x86AssemblyInspectionEngine::mov_rsp_rbp_pattern_p() { return false; } +// movq %rsp, %rbx [0x48 0x8b 0xdc] or [0x48 0x89 0xe3] +// movl %esp, %ebx [0x8b 0xdc] or [0x89 0xe3] +bool x86AssemblyInspectionEngine::mov_rsp_rbx_pattern_p() { + uint8_t *p = m_cur_insn; + if (m_wordsize == 8 && *p == 0x48) + p++; + if (*(p) == 0x8b && *(p + 1) == 0xdc) + return true; + if (*(p) == 0x89 && *(p + 1) == 0xe3) + return true; + return false; +} + +// movq %rbp, %rsp [0x48 0x8b 0xe5] or [0x48 0x89 0xec] +// movl %ebp, %esp [0x8b 0xe5] or [0x89 0xec] +bool x86AssemblyInspectionEngine::mov_rbp_rsp_pattern_p() { + uint8_t *p = m_cur_insn; + if (m_wordsize == 8 && *p == 0x48) + p++; + if (*(p) == 0x8b && *(p + 1) == 0xe5) + return true; + if (*(p) == 0x89 && *(p + 1) == 0xec) + return true; + return false; +} + +// movq %rbx, %rsp [0x48 0x8b 0xe3] or [0x48 0x89 0xdc] +// movl %ebx, %esp [0x8b 0xe3] or [0x89 0xdc] +bool x86AssemblyInspectionEngine::mov_rbx_rsp_pattern_p() { + uint8_t *p = m_cur_insn; + if (m_wordsize == 8 && *p == 0x48) + p++; + if (*(p) == 0x8b && *(p + 1) == 0xe3) + return true; + if (*(p) == 0x89 && *(p + 1) == 0xdc) + return true; + return false; +} + // subq $0x20, %rsp bool x86AssemblyInspectionEngine::sub_rsp_pattern_p(int &amount) { uint8_t *p = m_cur_insn; @@ -476,6 +516,46 @@ bool x86AssemblyInspectionEngine::lea_rbp_rsp_pattern_p(int &amount) { return false; } +// lea -0x28(%ebx), %esp +// (32-bit and 64-bit variants, 8-bit and 32-bit displacement) +bool x86AssemblyInspectionEngine::lea_rbx_rsp_pattern_p(int &amount) { + uint8_t *p = m_cur_insn; + if (m_wordsize == 8 && *p == 0x48) + p++; + + // Check opcode + if (*p != 0x8d) + return false; + ++p; + + // 8 bit displacement + if (*p == 0x63) { + amount = (int8_t)p[1]; + return true; + } + + // 32 bit displacement + if (*p == 0xa3) { + amount = (int32_t)extract_4(p + 1); + return true; + } + + return false; +} + +// and -0xfffffff0, %esp +// (32-bit and 64-bit variants, 8-bit and 32-bit displacement) +bool x86AssemblyInspectionEngine::and_rsp_pattern_p() { + uint8_t *p = m_cur_insn; + if (m_wordsize == 8 && *p == 0x48) + p++; + + if (*p != 0x81 && *p != 0x83) + return false; + + return *++p == 0xe4; +} + // popq %rbx // popl %ebx bool x86AssemblyInspectionEngine::pop_reg_p(int ®no) { @@ -588,9 +668,7 @@ bool x86AssemblyInspectionEngine::mov_reg_to_local_stack_frame_p( // ret [0xc9] or [0xc2 imm8] or [0xca imm8] bool x86AssemblyInspectionEngine::ret_pattern_p() { uint8_t *p = m_cur_insn; - if (*p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3) - return true; - return false; + return *p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3; } uint32_t x86AssemblyInspectionEngine::extract_4(uint8_t *b) { @@ -636,11 +714,12 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( if (data == nullptr || size == 0) return false; - if (m_register_map_initialized == false) + if (!m_register_map_initialized) return false; addr_t current_func_text_offset = 0; - int current_sp_bytes_offset_from_cfa = 0; + int current_sp_bytes_offset_from_fa = 0; + bool is_aligned = false; UnwindPlan::Row::RegisterLocation initial_regloc; UnwindPlan::RowSP row(new UnwindPlan::Row); @@ -657,8 +736,8 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( row->SetRegisterInfo(m_lldb_sp_regnum, initial_regloc); // saved instruction pointer can be found at CFA - wordsize. - current_sp_bytes_offset_from_cfa = m_wordsize; - initial_regloc.SetAtCFAPlusOffset(-current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa = m_wordsize; + initial_regloc.SetAtCFAPlusOffset(-current_sp_bytes_offset_from_fa); row->SetRegisterInfo(m_lldb_ip_regnum, initial_regloc); unwind_plan.AppendRow(row); @@ -682,6 +761,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( UnwindPlan::RowSP prologue_completed_row; // copy of prologue row of CFI int prologue_completed_sp_bytes_offset_from_cfa; // The sp value before the // epilogue started executed + bool prologue_completed_is_aligned; std::vector prologue_completed_saved_registers; while (current_func_text_offset < size) { @@ -701,22 +781,59 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( break; } - if (push_rbp_pattern_p()) { - current_sp_bytes_offset_from_cfa += m_wordsize; - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); - UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset(-row->GetCFAValue().GetOffset()); - row->SetRegisterInfo(m_lldb_fp_regnum, regloc); - saved_registers[m_machine_fp_regnum] = true; - row_updated = true; + auto &cfa_value = row->GetCFAValue(); + auto &afa_value = row->GetAFAValue(); + auto fa_value_ptr = is_aligned ? &afa_value : &cfa_value; + + if (mov_rsp_rbp_pattern_p()) { + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_fp_regnum, fa_value_ptr->GetOffset()); + row_updated = true; + } + } + + else if (mov_rsp_rbx_pattern_p()) { + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_alt_fp_regnum, fa_value_ptr->GetOffset()); + row_updated = true; + } } - else if (mov_rsp_rbp_pattern_p()) { - row->GetCFAValue().SetIsRegisterPlusOffset( - m_lldb_fp_regnum, row->GetCFAValue().GetOffset()); + else if (and_rsp_pattern_p()) { + current_sp_bytes_offset_from_fa = 0; + afa_value.SetIsRegisterPlusOffset( + m_lldb_sp_regnum, current_sp_bytes_offset_from_fa); + fa_value_ptr = &afa_value; + is_aligned = true; row_updated = true; } + else if (mov_rbp_rsp_pattern_p()) { + if (is_aligned && cfa_value.GetRegisterNumber() == m_lldb_fp_regnum) + { + is_aligned = false; + fa_value_ptr = &cfa_value; + afa_value.SetUnspecified(); + row_updated = true; + } + if (fa_value_ptr->GetRegisterNumber() == m_lldb_fp_regnum) + current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset(); + } + + else if (mov_rbx_rsp_pattern_p()) { + if (is_aligned && cfa_value.GetRegisterNumber() == m_lldb_alt_fp_regnum) + { + is_aligned = false; + fa_value_ptr = &cfa_value; + afa_value.SetUnspecified(); + row_updated = true; + } + if (fa_value_ptr->GetRegisterNumber() == m_lldb_alt_fp_regnum) + current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset(); + } + // This is the start() function (or a pthread equivalent), it starts with a // pushl $0x0 which puts the saved pc value of 0 on the stack. In this // case we want to pretend we didn't see a stack movement at all -- @@ -726,21 +843,24 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( } else if (push_reg_p(machine_regno)) { - current_sp_bytes_offset_from_cfa += m_wordsize; - // the PUSH instruction has moved the stack pointer - if the CFA is set + current_sp_bytes_offset_from_fa += m_wordsize; + // the PUSH instruction has moved the stack pointer - if the FA is set // in terms of the stack pointer, we need to add a new row of // instructions. - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetOffset(current_sp_bytes_offset_from_fa); row_updated = true; } // record where non-volatile (callee-saved, spilled) registers are saved // on the stack if (nonvolatile_reg_p(machine_regno) && machine_regno_to_lldb_regno(machine_regno, lldb_regno) && - saved_registers[machine_regno] == false) { + !saved_registers[machine_regno]) { UnwindPlan::Row::RegisterLocation regloc; - regloc.SetAtCFAPlusOffset(-current_sp_bytes_offset_from_cfa); + if (is_aligned) + regloc.SetAtAFAPlusOffset(-current_sp_bytes_offset_from_fa); + else + regloc.SetAtCFAPlusOffset(-current_sp_bytes_offset_from_fa); row->SetRegisterInfo(lldb_regno, regloc); saved_registers[machine_regno] = true; row_updated = true; @@ -748,37 +868,37 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( } else if (pop_reg_p(machine_regno)) { - current_sp_bytes_offset_from_cfa -= m_wordsize; + current_sp_bytes_offset_from_fa -= m_wordsize; if (nonvolatile_reg_p(machine_regno) && machine_regno_to_lldb_regno(machine_regno, lldb_regno) && - saved_registers[machine_regno] == true) { + saved_registers[machine_regno]) { saved_registers[machine_regno] = false; row->RemoveRegisterInfo(lldb_regno); - if (machine_regno == (int)m_machine_fp_regnum) { - row->GetCFAValue().SetIsRegisterPlusOffset( - m_lldb_sp_regnum, row->GetCFAValue().GetOffset()); + if (lldb_regno == fa_value_ptr->GetRegisterNumber()) { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_sp_regnum, fa_value_ptr->GetOffset()); } in_epilogue = true; row_updated = true; } - // the POP instruction has moved the stack pointer - if the CFA is set in + // the POP instruction has moved the stack pointer - if the FA is set in // terms of the stack pointer, we need to add a new row of instructions. - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetIsRegisterPlusOffset( - m_lldb_sp_regnum, current_sp_bytes_offset_from_cfa); + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_sp_regnum, current_sp_bytes_offset_from_fa); row_updated = true; } } else if (pop_misc_reg_p()) { - current_sp_bytes_offset_from_cfa -= m_wordsize; - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetIsRegisterPlusOffset( - m_lldb_sp_regnum, current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa -= m_wordsize; + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_sp_regnum, current_sp_bytes_offset_from_fa); row_updated = true; } } @@ -787,41 +907,57 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( // off the stack into rbp (restoring the caller's rbp value). It is the // opposite of ENTER, or 'push rbp, mov rsp rbp'. else if (leave_pattern_p()) { - // We're going to copy the value in rbp into rsp, so re-set the sp offset - // based on the CFAValue. Also, adjust it to recognize that we're - // popping the saved rbp value off the stack. - current_sp_bytes_offset_from_cfa = row->GetCFAValue().GetOffset(); - current_sp_bytes_offset_from_cfa -= m_wordsize; - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); - - // rbp is restored to the caller's value - saved_registers[m_machine_fp_regnum] = false; - row->RemoveRegisterInfo(m_lldb_fp_regnum); - - // cfa is now in terms of rsp again. - row->GetCFAValue().SetIsRegisterPlusOffset( - m_lldb_sp_regnum, row->GetCFAValue().GetOffset()); - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + if (saved_registers[m_machine_fp_regnum]) { + saved_registers[m_machine_fp_regnum] = false; + row->RemoveRegisterInfo(m_lldb_fp_regnum); + + row_updated = true; + } + + if (is_aligned && cfa_value.GetRegisterNumber() == m_lldb_fp_regnum) + { + is_aligned = false; + fa_value_ptr = &cfa_value; + afa_value.SetUnspecified(); + row_updated = true; + } + + if (fa_value_ptr->GetRegisterNumber() == m_lldb_fp_regnum) + { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_sp_regnum, fa_value_ptr->GetOffset()); + + current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset(); + } + + current_sp_bytes_offset_from_fa -= m_wordsize; + + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetIsRegisterPlusOffset( + m_lldb_sp_regnum, current_sp_bytes_offset_from_fa); + row_updated = true; + } in_epilogue = true; - row_updated = true; } else if (mov_reg_to_local_stack_frame_p(machine_regno, stack_offset) && nonvolatile_reg_p(machine_regno) && machine_regno_to_lldb_regno(machine_regno, lldb_regno) && - saved_registers[machine_regno] == false) { + !saved_registers[machine_regno]) { saved_registers[machine_regno] = true; UnwindPlan::Row::RegisterLocation regloc; // stack_offset for 'movq %r15, -80(%rbp)' will be 80. In the Row, we - // want to express this as the offset from the CFA. If the frame base is - // rbp (like the above instruction), the CFA offset for rbp is probably - // 16. So we want to say that the value is stored at the CFA address - + // want to express this as the offset from the FA. If the frame base is + // rbp (like the above instruction), the FA offset for rbp is probably + // 16. So we want to say that the value is stored at the FA address - // 96. - regloc.SetAtCFAPlusOffset( - -(stack_offset + row->GetCFAValue().GetOffset())); + if (is_aligned) + regloc.SetAtAFAPlusOffset(-(stack_offset + fa_value_ptr->GetOffset())); + else + regloc.SetAtCFAPlusOffset(-(stack_offset + fa_value_ptr->GetOffset())); row->SetRegisterInfo(lldb_regno, regloc); @@ -829,17 +965,17 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( } else if (sub_rsp_pattern_p(stack_offset)) { - current_sp_bytes_offset_from_cfa += stack_offset; - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa += stack_offset; + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetOffset(current_sp_bytes_offset_from_fa); row_updated = true; } } else if (add_rsp_pattern_p(stack_offset)) { - current_sp_bytes_offset_from_cfa -= stack_offset; - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa -= stack_offset; + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetOffset(current_sp_bytes_offset_from_fa); row_updated = true; } in_epilogue = true; @@ -847,27 +983,48 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( else if (push_extended_pattern_p() || push_imm_pattern_p() || push_misc_reg_p()) { - current_sp_bytes_offset_from_cfa += m_wordsize; - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa += m_wordsize; + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetOffset(current_sp_bytes_offset_from_fa); row_updated = true; } } else if (lea_rsp_pattern_p(stack_offset)) { - current_sp_bytes_offset_from_cfa -= stack_offset; - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa -= stack_offset; + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetOffset(current_sp_bytes_offset_from_fa); row_updated = true; } if (stack_offset > 0) in_epilogue = true; } - else if (lea_rbp_rsp_pattern_p(stack_offset) && - row->GetCFAValue().GetRegisterNumber() == m_lldb_fp_regnum) { - current_sp_bytes_offset_from_cfa = - row->GetCFAValue().GetOffset() - stack_offset; + else if (lea_rbp_rsp_pattern_p(stack_offset)) { + if (is_aligned && + cfa_value.GetRegisterNumber() == m_lldb_fp_regnum) { + is_aligned = false; + fa_value_ptr = &cfa_value; + afa_value.SetUnspecified(); + row_updated = true; + } + if (fa_value_ptr->GetRegisterNumber() == m_lldb_fp_regnum) { + current_sp_bytes_offset_from_fa = + fa_value_ptr->GetOffset() - stack_offset; + } + } + + else if (lea_rbx_rsp_pattern_p(stack_offset)) { + if (is_aligned && + cfa_value.GetRegisterNumber() == m_lldb_alt_fp_regnum) { + is_aligned = false; + fa_value_ptr = &cfa_value; + afa_value.SetUnspecified(); + row_updated = true; + } + if (fa_value_ptr->GetRegisterNumber() == m_lldb_alt_fp_regnum) { + current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset() - stack_offset; + } } else if (ret_pattern_p() && prologue_completed_row.get()) { @@ -877,8 +1034,9 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( UnwindPlan::Row *newrow = new UnwindPlan::Row; *newrow = *prologue_completed_row.get(); row.reset(newrow); - current_sp_bytes_offset_from_cfa = + current_sp_bytes_offset_from_fa = prologue_completed_sp_bytes_offset_from_cfa; + is_aligned = prologue_completed_is_aligned; saved_registers.clear(); saved_registers.resize(prologue_completed_saved_registers.size(), false); @@ -896,9 +1054,9 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( // This is used in i386 programs to get the PIC base address for finding // global data else if (call_next_insn_pattern_p()) { - current_sp_bytes_offset_from_cfa += m_wordsize; - if (row->GetCFAValue().GetRegisterNumber() == m_lldb_sp_regnum) { - row->GetCFAValue().SetOffset(current_sp_bytes_offset_from_cfa); + current_sp_bytes_offset_from_fa += m_wordsize; + if (fa_value_ptr->GetRegisterNumber() == m_lldb_sp_regnum) { + fa_value_ptr->SetOffset(current_sp_bytes_offset_from_fa); row_updated = true; } } @@ -914,7 +1072,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( } } - if (in_epilogue == false && row_updated) { + if (!in_epilogue && row_updated) { // If we're not in an epilogue sequence, save the updated Row UnwindPlan::Row *newrow = new UnwindPlan::Row; *newrow = *row.get(); @@ -929,9 +1087,10 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( // We may change the sp value without adding a new Row necessarily -- keep // track of it either way. - if (in_epilogue == false) { + if (!in_epilogue) { prologue_completed_sp_bytes_offset_from_cfa = - current_sp_bytes_offset_from_cfa; + current_sp_bytes_offset_from_fa; + prologue_completed_is_aligned = is_aligned; } m_cur_insn = m_cur_insn + insn_len; @@ -1194,7 +1353,7 @@ bool x86AssemblyInspectionEngine::FindFirstNonPrologueInstruction( uint8_t *data, size_t size, size_t &offset) { offset = 0; - if (m_register_map_initialized == false) + if (!m_register_map_initialized) return false; while (offset < size) { diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h index cec9803c8a49..9a8f71f4ee1c 100644 --- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h +++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h @@ -1,9 +1,8 @@ //===-- x86AssemblyInspectionEngine.h ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -98,10 +97,15 @@ class x86AssemblyInspectionEngine { bool push_extended_pattern_p(); bool push_misc_reg_p(); bool mov_rsp_rbp_pattern_p(); + bool mov_rsp_rbx_pattern_p(); + bool mov_rbp_rsp_pattern_p(); + bool mov_rbx_rsp_pattern_p(); bool sub_rsp_pattern_p(int &amount); bool add_rsp_pattern_p(int &amount); bool lea_rsp_pattern_p(int &amount); bool lea_rbp_rsp_pattern_p(int &amount); + bool lea_rbx_rsp_pattern_p(int &amount); + bool and_rsp_pattern_p(); bool push_reg_p(int ®no); bool pop_reg_p(int ®no); bool pop_rbp_pattern_p(); @@ -157,9 +161,11 @@ class x86AssemblyInspectionEngine { uint32_t m_machine_ip_regnum; uint32_t m_machine_sp_regnum; uint32_t m_machine_fp_regnum; + uint32_t m_machine_alt_fp_regnum; uint32_t m_lldb_ip_regnum; uint32_t m_lldb_sp_regnum; uint32_t m_lldb_fp_regnum; + uint32_t m_lldb_alt_fp_regnum; typedef std::map MachineRegnumToNameAndLLDBRegnum; diff --git a/source/Symbol/ArmUnwindInfo.cpp b/source/Symbol/ArmUnwindInfo.cpp index 6dcad62f2f9d..3ab1bbabbe07 100644 --- a/source/Symbol/ArmUnwindInfo.cpp +++ b/source/Symbol/ArmUnwindInfo.cpp @@ -1,9 +1,8 @@ //===-- ArmUnwindInfo.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -66,7 +65,7 @@ ArmUnwindInfo::ArmUnwindInfo(ObjectFile &objfile, SectionSP &arm_exidx, // Sort the entries in the exidx section. The entries should be sorted inside // the section but some old compiler isn't sorted them. - std::sort(m_exidx_entries.begin(), m_exidx_entries.end()); + llvm::sort(m_exidx_entries.begin(), m_exidx_entries.end()); } ArmUnwindInfo::~ArmUnwindInfo() {} diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp index acc284de75e5..0d317c53935d 100644 --- a/source/Symbol/Block.cpp +++ b/source/Symbol/Block.cpp @@ -1,9 +1,8 @@ //===-- Block.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -83,7 +82,7 @@ void Block::Dump(Stream *s, addr_t base_addr, int32_t depth, size_t num_ranges = m_ranges.GetSize(); for (size_t i = 0; i < num_ranges; ++i) { const Range &range = m_ranges.GetEntryRef(i); - if (parent_block != nullptr && parent_block->Contains(range) == false) + if (parent_block != nullptr && !parent_block->Contains(range)) *s << '!'; else *s << ' '; @@ -369,7 +368,7 @@ void Block::SetInlinedFunctionInfo(const char *name, const char *mangled, } VariableListSP Block::GetBlockVariableList(bool can_create) { - if (m_parsed_block_variables == false) { + if (!m_parsed_block_variables) { if (m_variable_list_sp.get() == nullptr && can_create) { m_parsed_block_variables = true; SymbolContext sc; @@ -402,7 +401,7 @@ Block::AppendBlockVariables(bool can_create, bool get_child_block_variables, collection::const_iterator pos, end = m_children.end(); for (pos = m_children.begin(); pos != end; ++pos) { Block *child_block = pos->get(); - if (stop_if_child_block_is_inlined_function == false || + if (!stop_if_child_block_is_inlined_function || child_block->GetInlinedFunctionInfo() == nullptr) { num_variables_added += child_block->AppendBlockVariables( can_create, get_child_block_variables, diff --git a/source/Symbol/CMakeLists.txt b/source/Symbol/CMakeLists.txt index 68ff187374e2..2e90c3eea3b3 100644 --- a/source/Symbol/CMakeLists.txt +++ b/source/Symbol/CMakeLists.txt @@ -64,3 +64,6 @@ add_lldb_library(lldbSymbol LINK_COMPONENTS Support ) +if(CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT SWIFT_COMPILER_IS_MSVC_LIKE) + target_compile_options(lldbSymbol PRIVATE -Wno-dollar-in-identifier-extension) +endif() diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp index 6f163132c917..bc7c6d6d13a9 100644 --- a/source/Symbol/ClangASTContext.cpp +++ b/source/Symbol/ClangASTContext.cpp @@ -1,9 +1,8 @@ //===-- ClangASTContext.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,13 +11,10 @@ #include "llvm/Support/FormatAdapters.h" #include "llvm/Support/FormatVariadic.h" -// C Includes -// C++ Includes #include #include #include -// Other libraries and framework includes // Clang headers like to use NDEBUG inside of them to enable/disable debug // related features using "#ifndef NDEBUG" preprocessor blocks to do one thing @@ -77,7 +73,6 @@ #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ThreadSafeDenseMap.h" #include "lldb/Core/UniqueCStringMap.h" @@ -98,6 +93,7 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Scalar.h" #include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h" #include "Plugins/SymbolFile/PDB/PDBASTParser.h" @@ -123,8 +119,204 @@ ClangASTContextSupportsLanguage(lldb::LanguageType language) { language == eLanguageTypeRust || language == eLanguageTypeExtRenderScript || // Use Clang for D until there is a proper language plugin for it - language == eLanguageTypeD; -} + language == eLanguageTypeD || + // Open Dylan compiler debug info is designed to be Clang-compatible + language == eLanguageTypeDylan; +} + +// Checks whether m1 is an overload of m2 (as opposed to an override). This is +// called by addOverridesForMethod to distinguish overrides (which share a +// vtable entry) from overloads (which require distinct entries). +bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) { + // FIXME: This should detect covariant return types, but currently doesn't. + lldbassert(&m1->getASTContext() == &m2->getASTContext() && + "Methods should have the same AST context"); + clang::ASTContext &context = m1->getASTContext(); + + const auto *m1Type = llvm::cast( + context.getCanonicalType(m1->getType())); + + const auto *m2Type = llvm::cast( + context.getCanonicalType(m2->getType())); + + auto compareArgTypes = [&context](const clang::QualType &m1p, + const clang::QualType &m2p) { + return context.hasSameType(m1p.getUnqualifiedType(), + m2p.getUnqualifiedType()); + }; + + // FIXME: In C++14 and later, we can just pass m2Type->param_type_end() + // as a fourth parameter to std::equal(). + return (m1->getNumParams() != m2->getNumParams()) || + !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(), + m2Type->param_type_begin(), compareArgTypes); +} + +// If decl is a virtual method, walk the base classes looking for methods that +// decl overrides. This table of overridden methods is used by IRGen to +// determine the vtable layout for decl's parent class. +void addOverridesForMethod(clang::CXXMethodDecl *decl) { + if (!decl->isVirtual()) + return; + + clang::CXXBasePaths paths; + + auto find_overridden_methods = + [decl](const clang::CXXBaseSpecifier *specifier, + clang::CXXBasePath &path) { + if (auto *base_record = llvm::dyn_cast( + specifier->getType()->getAs()->getDecl())) { + + clang::DeclarationName name = decl->getDeclName(); + + // If this is a destructor, check whether the base class destructor is + // virtual. + if (name.getNameKind() == clang::DeclarationName::CXXDestructorName) + if (auto *baseDtorDecl = base_record->getDestructor()) { + if (baseDtorDecl->isVirtual()) { + path.Decls = baseDtorDecl; + return true; + } else + return false; + } + + // Otherwise, search for name in the base class. + for (path.Decls = base_record->lookup(name); !path.Decls.empty(); + path.Decls = path.Decls.slice(1)) { + if (auto *method_decl = + llvm::dyn_cast(path.Decls.front())) + if (method_decl->isVirtual() && !isOverload(decl, method_decl)) { + path.Decls = method_decl; + return true; + } + } + } + + return false; + }; + + if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) { + for (auto *overridden_decl : paths.found_decls()) + decl->addOverriddenMethod( + llvm::cast(overridden_decl)); + } +} +} + +static lldb::addr_t GetVTableAddress(Process &process, + VTableContextBase &vtable_ctx, + ValueObject &valobj, + const ASTRecordLayout &record_layout) { + // Retrieve type info + CompilerType pointee_type; + CompilerType this_type(valobj.GetCompilerType()); + uint32_t type_info = this_type.GetTypeInfo(&pointee_type); + if (!type_info) + return LLDB_INVALID_ADDRESS; + + // Check if it's a pointer or reference + bool ptr_or_ref = false; + if (type_info & (eTypeIsPointer | eTypeIsReference)) { + ptr_or_ref = true; + type_info = pointee_type.GetTypeInfo(); + } + + // We process only C++ classes + const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus; + if ((type_info & cpp_class) != cpp_class) + return LLDB_INVALID_ADDRESS; + + // Calculate offset to VTable pointer + lldb::offset_t vbtable_ptr_offset = + vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity() + : 0; + + if (ptr_or_ref) { + // We have a pointer / ref to object, so read + // VTable pointer from process memory + + if (valobj.GetAddressTypeOfChildren() != eAddressTypeLoad) + return LLDB_INVALID_ADDRESS; + + auto vbtable_ptr_addr = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + if (vbtable_ptr_addr == LLDB_INVALID_ADDRESS) + return LLDB_INVALID_ADDRESS; + + vbtable_ptr_addr += vbtable_ptr_offset; + + Status err; + return process.ReadPointerFromMemory(vbtable_ptr_addr, err); + } + + // We have an object already read from process memory, + // so just extract VTable pointer from it + + DataExtractor data; + Status err; + auto size = valobj.GetData(data, err); + if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size) + return LLDB_INVALID_ADDRESS; + + return data.GetPointer(&vbtable_ptr_offset); +} + +static int64_t ReadVBaseOffsetFromVTable(Process &process, + VTableContextBase &vtable_ctx, + lldb::addr_t vtable_ptr, + const CXXRecordDecl *cxx_record_decl, + const CXXRecordDecl *base_class_decl) { + if (vtable_ctx.isMicrosoft()) { + clang::MicrosoftVTableContext &msoft_vtable_ctx = + static_cast(vtable_ctx); + + // Get the index into the virtual base table. The + // index is the index in uint32_t from vbtable_ptr + const unsigned vbtable_index = + msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl); + const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4; + Status err; + return process.ReadSignedIntegerFromMemory(base_offset_addr, 4, INT64_MAX, + err); + } + + clang::ItaniumVTableContext &itanium_vtable_ctx = + static_cast(vtable_ctx); + + clang::CharUnits base_offset_offset = + itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl, + base_class_decl); + const lldb::addr_t base_offset_addr = + vtable_ptr + base_offset_offset.getQuantity(); + const uint32_t base_offset_size = process.GetAddressByteSize(); + Status err; + return process.ReadSignedIntegerFromMemory(base_offset_addr, base_offset_size, + INT64_MAX, err); +} + +static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, + ValueObject &valobj, + const ASTRecordLayout &record_layout, + const CXXRecordDecl *cxx_record_decl, + const CXXRecordDecl *base_class_decl, + int32_t &bit_offset) { + ExecutionContext exe_ctx(valobj.GetExecutionContextRef()); + Process *process = exe_ctx.GetProcessPtr(); + if (!process) + return false; + + lldb::addr_t vtable_ptr = + GetVTableAddress(*process, vtable_ctx, valobj, record_layout); + if (vtable_ptr == LLDB_INVALID_ADDRESS) + return false; + + auto base_offset = ReadVBaseOffsetFromVTable( + *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl); + if (base_offset == INT64_MAX) + return false; + + bit_offset = base_offset * 8; + + return true; } typedef lldb_private::ThreadSafeDenseMap @@ -382,7 +574,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { if (IK.getLanguage() == InputKind::Asm) { Opts.AsmPreprocessor = 1; } else if (IK.isObjectiveC()) { - Opts.ObjC1 = Opts.ObjC2 = 1; + Opts.ObjC = 1; } LangStandard::Kind LangStd = LangStandard::lang_unspecified; @@ -811,9 +1003,7 @@ TargetInfo *ClangASTContext::getTargetInfo() { static inline bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext *ast, QualType qual_type) { uint64_t qual_type_bit_size = ast->getTypeSize(qual_type); - if (qual_type_bit_size == bit_size) - return true; - return false; + return qual_type_bit_size == bit_size; } CompilerType @@ -1395,25 +1585,24 @@ static TemplateParameterList *CreateTemplateParameterList( } } - if (template_param_infos.packed_args && - template_param_infos.packed_args->args.size()) { + if (template_param_infos.packed_args) { IdentifierInfo *identifier_info = nullptr; if (template_param_infos.pack_name && template_param_infos.pack_name[0]) identifier_info = &ast->Idents.get(template_param_infos.pack_name); const bool parameter_pack_true = true; - if (IsValueParam(template_param_infos.packed_args->args[0])) { + + if (!template_param_infos.packed_args->args.empty() && + IsValueParam(template_param_infos.packed_args->args[0])) { template_param_decls.push_back(NonTypeTemplateParmDecl::Create( - *ast, decl_context, - SourceLocation(), SourceLocation(), depth, num_template_params, - identifier_info, + *ast, decl_context, SourceLocation(), SourceLocation(), depth, + num_template_params, identifier_info, template_param_infos.packed_args->args[0].getIntegralType(), parameter_pack_true, nullptr)); } else { template_param_decls.push_back(TemplateTypeParmDecl::Create( - *ast, decl_context, - SourceLocation(), SourceLocation(), depth, num_template_params, - identifier_info, - is_typename, parameter_pack_true)); + *ast, decl_context, SourceLocation(), SourceLocation(), depth, + num_template_params, identifier_info, is_typename, + parameter_pack_true)); } } clang::Expr *const requires_clause = nullptr; // TODO: Concepts @@ -1710,8 +1899,7 @@ CompilerType ClangASTContext::CreateObjCClass(const char *name, } static inline bool BaseSpecifierIsEmpty(const CXXBaseSpecifier *b) { - return ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()) == - false; + return !ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl()); } uint32_t @@ -2017,7 +2205,8 @@ FunctionDecl *ClangASTContext::CreateFunctionDeclaration( CompilerType ClangASTContext::CreateFunctionType( ASTContext *ast, const CompilerType &result_type, const CompilerType *args, - unsigned num_args, bool is_variadic, unsigned type_quals) { + unsigned num_args, bool is_variadic, unsigned type_quals, + clang::CallingConv cc) { if (ast == nullptr) return CompilerType(); // invalid AST @@ -2045,9 +2234,10 @@ CompilerType ClangASTContext::CreateFunctionType( // TODO: Detect calling convention in DWARF? FunctionProtoType::ExtProtoInfo proto_info; + proto_info.ExtInfo = cc; proto_info.Variadic = is_variadic; proto_info.ExceptionSpec = EST_None; - proto_info.TypeQuals = type_quals; + proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals); proto_info.RefQualifier = RQ_None; return CompilerType(ast, @@ -2056,14 +2246,17 @@ CompilerType ClangASTContext::CreateFunctionType( } ParmVarDecl *ClangASTContext::CreateParameterDeclaration( - const char *name, const CompilerType ¶m_type, int storage) { + clang::DeclContext *decl_ctx, const char *name, + const CompilerType ¶m_type, int storage) { ASTContext *ast = getASTContext(); assert(ast != nullptr); - return ParmVarDecl::Create(*ast, ast->getTranslationUnitDecl(), - SourceLocation(), SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : nullptr, - ClangUtil::GetQualType(param_type), nullptr, - (clang::StorageClass)storage, nullptr); + auto *decl = + ParmVarDecl::Create(*ast, decl_ctx, SourceLocation(), SourceLocation(), + name && name[0] ? &ast->Idents.get(name) : nullptr, + ClangUtil::GetQualType(param_type), nullptr, + (clang::StorageClass)storage, nullptr); + decl_ctx->addDecl(decl); + return decl; } void ClangASTContext::SetFunctionParameters(FunctionDecl *function_decl, @@ -2171,6 +2364,9 @@ ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx, false); // IsFixed if (enum_decl) { + if (decl_ctx) + decl_ctx->addDecl(enum_decl); + // TODO: check if we should be setting the promotion type too? enum_decl->setIntegerType(ClangUtil::GetQualType(integer_clang_type)); @@ -3772,9 +3968,7 @@ bool ClangASTContext::IsCXXClassType(const CompilerType &type) { return false; clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type)); - if (!qual_type.isNull() && qual_type->getAsCXXRecordDecl() != nullptr) - return true; - return false; + return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() != nullptr; } bool ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) { @@ -4346,7 +4540,7 @@ ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type, // TODO: the real stride will be >= this value.. find the real one! if (stride) - if (auto size = element_type.GetByteSize(nullptr)) + if (Optional size = element_type.GetByteSize(nullptr)) *stride = *size; return element_type; @@ -4727,6 +4921,8 @@ CompilerType ClangASTContext::CreateTypedefType( decl->setAccess(clang::AS_public); // TODO respect proper access specifier + decl_ctx->addDecl(decl); + // Get a uniqued clang::QualType for the typedef decl type return CompilerType(clang_ast, clang_ast->getTypedefType(decl)); } @@ -5117,6 +5313,20 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type, case clang::BuiltinType::Kind::PseudoObject: case clang::BuiltinType::Kind::UnknownAny: break; + + case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload: + case clang::BuiltinType::OCLIntelSubgroupAVCImePayload: + case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload: + case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload: + case clang::BuiltinType::OCLIntelSubgroupAVCMceResult: + case clang::BuiltinType::OCLIntelSubgroupAVCImeResult: + case clang::BuiltinType::OCLIntelSubgroupAVCRefResult: + case clang::BuiltinType::OCLIntelSubgroupAVCSicResult: + case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleRefStreamout: + case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualRefStreamout: + case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleRefStreamin: + case clang::BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin: + break; } break; // All pointer types are represented as unsigned integer encodings. We may @@ -5404,15 +5614,14 @@ static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl, return false; } -static llvm::Optional +static Optional GetDynamicArrayInfo(ClangASTContext &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx) { if (qual_type->isIncompleteArrayType()) if (auto *metadata = ast.GetMetadata(qual_type.getAsOpaquePtr())) - if (auto *dwarf_parser = ast.GetDWARFParser()) - return sym_file->GetDynamicArrayInfoForUID(metadata->GetUserID(), - exe_ctx); + return sym_file->GetDynamicArrayInfoForUID(metadata->GetUserID(), + exe_ctx); return llvm::None; } @@ -5465,7 +5674,7 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type, ->getDecl()); // Skip empty base classes - if (ClangASTContext::RecordHasFields(base_class_decl) == false) + if (!ClangASTContext::RecordHasFields(base_class_decl)) continue; num_children++; @@ -5840,10 +6049,10 @@ GetObjCFieldAtIndex(clang::ASTContext *ast, if (is_bitfield && ast) { clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth(); - llvm::APSInt bitfield_apsint; + clang::Expr::EvalResult result; if (bitfield_bit_size_expr && - bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, - *ast)) { + bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) { + llvm::APSInt bitfield_apsint = result.Val.getInt(); *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue(); } } @@ -5900,10 +6109,11 @@ CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type, if (is_bitfield) { clang::Expr *bitfield_bit_size_expr = field->getBitWidth(); - llvm::APSInt bitfield_apsint; + clang::Expr::EvalResult result; if (bitfield_bit_size_expr && - bitfield_bit_size_expr->EvaluateAsInt(bitfield_apsint, + bitfield_bit_size_expr->EvaluateAsInt(result, *getASTContext())) { + llvm::APSInt bitfield_apsint = result.Val.getInt(); *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue(); } } @@ -6471,6 +6681,10 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( if (!type) return CompilerType(); + auto get_exe_scope = [&exe_ctx]() { + return exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; + }; + clang::QualType parent_qual_type(GetCanonicalQualType(type)); const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass(); @@ -6481,7 +6695,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( const bool idx_is_valid = idx < GetNumChildren(type, omit_empty_base_classes, exe_ctx); - uint32_t bit_offset; + int32_t bit_offset; switch (parent_type_class) { case clang::Type::Builtin: if (idx_is_valid) { @@ -6526,7 +6740,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( if (omit_empty_base_classes) { base_class_decl = llvm::cast( base_class->getType()->getAs()->getDecl()); - if (ClangASTContext::RecordHasFields(base_class_decl) == false) + if (!ClangASTContext::RecordHasFields(base_class_decl)) continue; } @@ -6538,80 +6752,12 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( if (base_class->isVirtual()) { bool handled = false; if (valobj) { - Status err; - AddressType addr_type = eAddressTypeInvalid; - lldb::addr_t vtable_ptr_addr = - valobj->GetCPPVTableAddress(addr_type); - - if (vtable_ptr_addr != LLDB_INVALID_ADDRESS && - addr_type == eAddressTypeLoad) { - - ExecutionContext exe_ctx(valobj->GetExecutionContextRef()); - Process *process = exe_ctx.GetProcessPtr(); - if (process) { - clang::VTableContextBase *vtable_ctx = - getASTContext()->getVTableContext(); - if (vtable_ctx) { - if (vtable_ctx->isMicrosoft()) { - clang::MicrosoftVTableContext *msoft_vtable_ctx = - static_cast( - vtable_ctx); - - if (vtable_ptr_addr) { - const lldb::addr_t vbtable_ptr_addr = - vtable_ptr_addr + - record_layout.getVBPtrOffset().getQuantity(); - - const lldb::addr_t vbtable_ptr = - process->ReadPointerFromMemory(vbtable_ptr_addr, - err); - if (vbtable_ptr != LLDB_INVALID_ADDRESS) { - // Get the index into the virtual base table. The - // index is the index in uint32_t from vbtable_ptr - const unsigned vbtable_index = - msoft_vtable_ctx->getVBTableIndex( - cxx_record_decl, base_class_decl); - const lldb::addr_t base_offset_addr = - vbtable_ptr + vbtable_index * 4; - const uint32_t base_offset = - process->ReadUnsignedIntegerFromMemory( - base_offset_addr, 4, UINT32_MAX, err); - if (base_offset != UINT32_MAX) { - handled = true; - bit_offset = base_offset * 8; - } - } - } - } else { - clang::ItaniumVTableContext *itanium_vtable_ctx = - static_cast( - vtable_ctx); - if (vtable_ptr_addr) { - const lldb::addr_t vtable_ptr = - process->ReadPointerFromMemory(vtable_ptr_addr, - err); - if (vtable_ptr != LLDB_INVALID_ADDRESS) { - clang::CharUnits base_offset_offset = - itanium_vtable_ctx->getVirtualBaseOffsetOffset( - cxx_record_decl, base_class_decl); - const lldb::addr_t base_offset_addr = - vtable_ptr + base_offset_offset.getQuantity(); - const uint32_t base_offset_size = - process->GetAddressByteSize(); - const uint64_t base_offset = - process->ReadUnsignedIntegerFromMemory( - base_offset_addr, base_offset_size, - UINT32_MAX, err); - if (base_offset < UINT32_MAX) { - handled = true; - bit_offset = base_offset * 8; - } - } - } - } - } - } - } + clang::VTableContextBase *vtable_ctx = + getASTContext()->getVTableContext(); + if (vtable_ctx) + handled = GetVBaseBitOffset(*vtable_ctx, *valobj, + record_layout, cxx_record_decl, + base_class_decl, bit_offset); } if (!handled) bit_offset = record_layout.getVBaseClassOffset(base_class_decl) @@ -6627,8 +6773,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( CompilerType base_class_clang_type(getASTContext(), base_class->getType()); child_name = base_class_clang_type.GetTypeName().AsCString(""); - auto size = base_class_clang_type.GetBitSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL); + Optional size = + base_class_clang_type.GetBitSize(get_exe_scope()); if (!size) return {}; uint64_t base_class_clang_type_bit_size = *size; @@ -6659,8 +6805,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( // alignment (field_type_info.second) from the AST context. CompilerType field_clang_type(getASTContext(), field->getType()); assert(field_idx < record_layout.getFieldCount()); - auto size = field_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL); + Optional size = + field_clang_type.GetByteSize(get_exe_scope()); if (!size) return {}; child_byte_size = *size; @@ -6775,9 +6921,9 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( } } - // Setting this to UINT32_MAX to make sure we don't compute it + // Setting this to INT32_MAX to make sure we don't compute it // twice... - bit_offset = UINT32_MAX; + bit_offset = INT32_MAX; if (child_byte_offset == static_cast(LLDB_INVALID_IVAR_OFFSET)) { @@ -6794,7 +6940,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( if (ClangASTContext::FieldIsBitfield(getASTContext(), ivar_decl, child_bitfield_bit_size)) { - if (bit_offset == UINT32_MAX) + if (bit_offset == INT32_MAX) bit_offset = interface_layout.getFieldOffset( child_idx - superclass_idx); @@ -6834,8 +6980,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( // We have a pointer to an simple type if (idx == 0 && pointee_clang_type.GetCompleteType()) { - if (auto size = pointee_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional size = + pointee_clang_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = 0; return pointee_clang_type; @@ -6857,8 +7003,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( ::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]", static_cast(idx)); child_name.assign(element_name); - if (auto size = element_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional size = + element_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = (int32_t)idx * (int32_t)child_byte_size; return element_type; @@ -6876,8 +7022,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( CompilerType element_type(getASTContext(), array->getElementType()); if (element_type.GetCompleteType()) { child_name = llvm::formatv("[{0}]", idx); - if (auto size = element_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional size = + element_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = (int32_t)idx * (int32_t)child_byte_size; return element_type; @@ -6915,8 +7061,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( // We have a pointer to an simple type if (idx == 0) { - if (auto size = pointee_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional size = + pointee_clang_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = 0; return pointee_clang_type; @@ -6952,8 +7098,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( // We have a pointer to an simple type if (idx == 0) { - if (auto size = pointee_clang_type.GetByteSize( - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) { + if (Optional size = + pointee_clang_type.GetByteSize(get_exe_scope())) { child_byte_size = *size; child_byte_offset = 0; return pointee_clang_type; @@ -7405,14 +7551,14 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, ->getAs() ->getDecl()); if (omit_empty_base_classes && - ClangASTContext::RecordHasFields(base_class_decl) == false) + !ClangASTContext::RecordHasFields(base_class_decl)) continue; CompilerType base_class_clang_type(getASTContext(), base_class->getType()); std::string base_class_type_name( base_class_clang_type.GetTypeName().AsCString("")); - if (base_class_type_name.compare(name) == 0) + if (base_class_type_name == name) return child_idx; ++child_idx; } @@ -7747,7 +7893,7 @@ ClangASTContext::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, return CompilerType(getASTContext(), template_arg.getAsType()); } -llvm::Optional +Optional ClangASTContext::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx) { const clang::ClassTemplateSpecializationDecl *template_decl = @@ -7787,11 +7933,16 @@ clang::RecordDecl *ClangASTContext::GetAsRecordDecl(const CompilerType &type) { } clang::TagDecl *ClangASTContext::GetAsTagDecl(const CompilerType &type) { - clang::QualType qual_type = ClangUtil::GetCanonicalQualType(type); - if (qual_type.isNull()) - return nullptr; - else - return qual_type->getAsTagDecl(); + return ClangUtil::GetAsTagDecl(type); +} + +clang::TypedefNameDecl * +ClangASTContext::GetAsTypedefDecl(const CompilerType &type) { + const clang::TypedefType *typedef_type = + llvm::dyn_cast(ClangUtil::GetQualType(type)); + if (typedef_type) + return typedef_type->getDecl(); + return nullptr; } clang::CXXRecordDecl * @@ -7810,7 +7961,7 @@ ClangASTContext::GetAsObjCInterfaceDecl(const CompilerType &type) { } clang::FieldDecl *ClangASTContext::AddFieldToRecordType( - const CompilerType &type, const char *name, + const CompilerType &type, llvm::StringRef name, const CompilerType &field_clang_type, AccessType access, uint32_t bitfield_bit_size) { if (!type.IsValid() || !field_clang_type.IsValid()) @@ -7820,6 +7971,9 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType( if (!ast) return nullptr; clang::ASTContext *clang_ast = ast->getASTContext(); + clang::IdentifierInfo *ident = nullptr; + if (!name.empty()) + ident = &clang_ast->Idents.get(name); clang::FieldDecl *field = nullptr; @@ -7837,14 +7991,14 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType( field = clang::FieldDecl::Create( *clang_ast, record_decl, clang::SourceLocation(), clang::SourceLocation(), - name ? &clang_ast->Idents.get(name) : nullptr, // Identifier - ClangUtil::GetQualType(field_clang_type), // Field type - nullptr, // TInfo * - bit_width, // BitWidth - false, // Mutable - clang::ICIS_NoInit); // HasInit - - if (!name) { + ident, // Identifier + ClangUtil::GetQualType(field_clang_type), // Field type + nullptr, // TInfo * + bit_width, // BitWidth + false, // Mutable + clang::ICIS_NoInit); // HasInit + + if (name.empty()) { // Determine whether this field corresponds to an anonymous struct or // union. if (const clang::TagType *TagT = @@ -7880,9 +8034,9 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType( field = clang::ObjCIvarDecl::Create( *clang_ast, class_interface_decl, clang::SourceLocation(), clang::SourceLocation(), - name ? &clang_ast->Idents.get(name) : nullptr, // Identifier - ClangUtil::GetQualType(field_clang_type), // Field type - nullptr, // TypeSourceInfo * + ident, // Identifier + ClangUtil::GetQualType(field_clang_type), // Field type + nullptr, // TypeSourceInfo * ConvertAccessTypeToObjCIvarAccessControl(access), bit_width, is_synthesized); @@ -8021,38 +8175,44 @@ void ClangASTContext::SetIsPacked(const CompilerType &type) { } clang::VarDecl *ClangASTContext::AddVariableToRecordType( - const CompilerType &type, const char *name, const CompilerType &var_type, - AccessType access) { - clang::VarDecl *var_decl = nullptr; - + const CompilerType &type, llvm::StringRef name, + const CompilerType &var_type, AccessType access) { if (!type.IsValid() || !var_type.IsValid()) return nullptr; + ClangASTContext *ast = llvm::dyn_cast(type.GetTypeSystem()); if (!ast) return nullptr; clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type); - if (record_decl) { - var_decl = clang::VarDecl::Create( - *ast->getASTContext(), // ASTContext & - record_decl, // DeclContext * - clang::SourceLocation(), // clang::SourceLocation StartLoc - clang::SourceLocation(), // clang::SourceLocation IdLoc - name ? &ast->getASTContext()->Idents.get(name) - : nullptr, // clang::IdentifierInfo * - ClangUtil::GetQualType(var_type), // Variable clang::QualType - nullptr, // TypeSourceInfo * - clang::SC_Static); // StorageClass - if (var_decl) { - var_decl->setAccess( - ClangASTContext::ConvertAccessTypeToAccessSpecifier(access)); - record_decl->addDecl(var_decl); + if (!record_decl) + return nullptr; + + clang::VarDecl *var_decl = nullptr; + clang::IdentifierInfo *ident = nullptr; + if (!name.empty()) + ident = &ast->getASTContext()->Idents.get(name); + + var_decl = clang::VarDecl::Create( + *ast->getASTContext(), // ASTContext & + record_decl, // DeclContext * + clang::SourceLocation(), // clang::SourceLocation StartLoc + clang::SourceLocation(), // clang::SourceLocation IdLoc + ident, // clang::IdentifierInfo * + ClangUtil::GetQualType(var_type), // Variable clang::QualType + nullptr, // TypeSourceInfo * + clang::SC_Static); // StorageClass + if (!var_decl) + return nullptr; + + var_decl->setAccess( + ClangASTContext::ConvertAccessTypeToAccessSpecifier(access)); + record_decl->addDecl(var_decl); #ifdef LLDB_CONFIGURATION_DEBUG - VerifyDecl(var_decl); + VerifyDecl(var_decl); #endif - } - } + return var_decl; } @@ -8253,41 +8413,46 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType( return cxx_method_decl; } +void ClangASTContext::AddMethodOverridesForCXXRecordType( + lldb::opaque_compiler_type_t type) { + if (auto *record = GetAsCXXRecordDecl(type)) + for (auto *method : record->methods()) + addOverridesForMethod(method); +} + #pragma mark C++ Base Classes -clang::CXXBaseSpecifier * +std::unique_ptr ClangASTContext::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, AccessType access, bool is_virtual, bool base_of_class) { - if (type) - return new clang::CXXBaseSpecifier( - clang::SourceRange(), is_virtual, base_of_class, - ClangASTContext::ConvertAccessTypeToAccessSpecifier(access), - getASTContext()->getTrivialTypeSourceInfo(GetQualType(type)), - clang::SourceLocation()); - return nullptr; -} + if (!type) + return nullptr; -void ClangASTContext::DeleteBaseClassSpecifiers( - clang::CXXBaseSpecifier **base_classes, unsigned num_base_classes) { - for (unsigned i = 0; i < num_base_classes; ++i) { - delete base_classes[i]; - base_classes[i] = nullptr; - } + return llvm::make_unique( + clang::SourceRange(), is_virtual, base_of_class, + ClangASTContext::ConvertAccessTypeToAccessSpecifier(access), + getASTContext()->getTrivialTypeSourceInfo(GetQualType(type)), + clang::SourceLocation()); } -bool ClangASTContext::SetBaseClassesForClassType( +bool ClangASTContext::TransferBaseClasses( lldb::opaque_compiler_type_t type, - clang::CXXBaseSpecifier const *const *base_classes, - unsigned num_base_classes) { - if (type) { - clang::CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl(type); - if (cxx_record_decl) { - cxx_record_decl->setBases(base_classes, num_base_classes); - return true; - } - } - return false; + std::vector> bases) { + if (!type) + return false; + clang::CXXRecordDecl *cxx_record_decl = GetAsCXXRecordDecl(type); + if (!cxx_record_decl) + return false; + std::vector raw_bases; + raw_bases.reserve(bases.size()); + + // Clang will make a copy of them, so it's ok that we pass pointers that we're + // about to destroy. + for (auto &b : bases) + raw_bases.push_back(b.get()); + cxx_record_decl->setBases(raw_bases.data(), raw_bases.size()); + return true; } bool ClangASTContext::SetObjCSuperClass( @@ -8872,9 +9037,9 @@ bool ClangASTContext::CompleteTagDeclarationDefinition( return false; } -bool ClangASTContext::AddEnumerationValueToEnumerationType( +clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType( const CompilerType &enum_type, const Declaration &decl, const char *name, - int64_t enum_value, uint32_t enum_value_bit_size) { + const llvm::APSInt &value) { if (!enum_type || ConstString(name).IsEmpty()) return nullptr; @@ -8887,33 +9052,26 @@ bool ClangASTContext::AddEnumerationValueToEnumerationType( if (!enum_opaque_compiler_type) return nullptr; - CompilerType underlying_type = - GetEnumerationIntegerType(enum_type.GetOpaqueQualType()); - clang::QualType enum_qual_type( GetCanonicalQualType(enum_opaque_compiler_type)); - bool is_signed = false; - underlying_type.IsIntegerType(is_signed); const clang::Type *clang_type = enum_qual_type.getTypePtr(); if (!clang_type) - return false; + return nullptr; const clang::EnumType *enutype = llvm::dyn_cast(clang_type); if (!enutype) - return false; + return nullptr; - llvm::APSInt enum_llvm_apsint(enum_value_bit_size, is_signed); - enum_llvm_apsint = enum_value; clang::EnumConstantDecl *enumerator_decl = clang::EnumConstantDecl::Create( *getASTContext(), enutype->getDecl(), clang::SourceLocation(), name ? &getASTContext()->Idents.get(name) : nullptr, // Identifier - clang::QualType(enutype, 0), nullptr, enum_llvm_apsint); + clang::QualType(enutype, 0), nullptr, value); if (!enumerator_decl) - return false; + return nullptr; enutype->getDecl()->addDecl(enumerator_decl); @@ -8921,7 +9079,21 @@ bool ClangASTContext::AddEnumerationValueToEnumerationType( VerifyDecl(enumerator_decl); #endif - return true; + return enumerator_decl; +} + +clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType( + const CompilerType &enum_type, const Declaration &decl, const char *name, + int64_t enum_value, uint32_t enum_value_bit_size) { + CompilerType underlying_type = + GetEnumerationIntegerType(enum_type.GetOpaqueQualType()); + bool is_signed = false; + underlying_type.IsIntegerType(is_signed); + + llvm::APSInt value(enum_value_bit_size, is_signed); + value = enum_value; + + return AddEnumerationValueToEnumerationType(enum_type, decl, name, value); } CompilerType @@ -8995,6 +9167,11 @@ ClangASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, //---------------------------------------------------------------------- #define DEPTH_INCREMENT 2 +void ClangASTContext::Dump(Stream &s) { + Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl()); + tu->dump(s.AsRawOstream()); +} + void ClangASTContext::DumpValue( lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, @@ -9032,8 +9209,7 @@ void ClangASTContext::DumpValue( base_class->getType()->getAs()->getDecl()); // Skip empty base classes - if (verbose == false && - ClangASTContext::RecordHasFields(base_class_decl) == false) + if (!verbose && !ClangASTContext::RecordHasFields(base_class_decl)) continue; if (base_class->isVirtual()) @@ -9805,11 +9981,16 @@ bool ClangASTContext::LayoutRecordType( llvm::DenseMap &vbase_offsets) { ClangASTContext *ast = (ClangASTContext *)baton; - DWARFASTParserClang *dwarf_ast_parser = - (DWARFASTParserClang *)ast->GetDWARFParser(); - return dwarf_ast_parser->GetClangASTImporter().LayoutRecordType( - record_decl, bit_size, alignment, field_offsets, base_offsets, - vbase_offsets); + lldb_private::ClangASTImporter *importer = nullptr; + if (ast->m_dwarf_ast_parser_ap) + importer = &ast->m_dwarf_ast_parser_ap->GetClangASTImporter(); + if (!importer && ast->m_pdb_ast_parser_ap) + importer = &ast->m_pdb_ast_parser_ap->GetClangASTImporter(); + if (!importer) + return false; + + return importer->LayoutRecordType(record_decl, bit_size, alignment, + field_offsets, base_offsets, vbase_offsets); } //---------------------------------------------------------------------- diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp index ea3b141c9e74..a1c6408fdec3 100644 --- a/source/Symbol/ClangASTImporter.cpp +++ b/source/Symbol/ClangASTImporter.cpp @@ -1,9 +1,8 @@ //===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -1002,7 +1001,7 @@ clang::Decl *ClangASTImporter::Minion::Imported(clang::Decl *from, if (isa(to) || isa(to)) { RecordDecl *from_record_decl = dyn_cast(from); if (from_record_decl == nullptr || - from_record_decl->isInjectedClassName() == false) { + !from_record_decl->isInjectedClassName()) { NamedDecl *to_named_decl = dyn_cast(to); if (!m_decls_already_deported->count(to_named_decl)) @@ -1050,7 +1049,7 @@ clang::Decl *ClangASTImporter::Minion::Imported(clang::Decl *from, TagDecl *to_tag_decl = dyn_cast(to); to_tag_decl->setHasExternalLexicalStorage(); - to_tag_decl->setMustBuildLookupTable(); + to_tag_decl->getPrimaryContext()->setMustBuildLookupTable(); if (log) log->Printf( diff --git a/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/source/Symbol/ClangExternalASTSourceCallbacks.cpp index c88119bc9a4c..c35fc585bfa5 100644 --- a/source/Symbol/ClangExternalASTSourceCallbacks.cpp +++ b/source/Symbol/ClangExternalASTSourceCallbacks.cpp @@ -1,17 +1,13 @@ //===-- ClangExternalASTSourceCallbacks.cpp ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Symbol/ClangExternalASTSourceCallbacks.h" -// C Includes -// C++ Includes -// Other libraries and framework includes // Clang headers like to use NDEBUG inside of them to enable/disable debug // related features using "#ifndef NDEBUG" preprocessor blocks to do one thing diff --git a/source/Symbol/ClangExternalASTSourceCommon.cpp b/source/Symbol/ClangExternalASTSourceCommon.cpp index 992a76352d92..3dcf9051d0a4 100644 --- a/source/Symbol/ClangExternalASTSourceCommon.cpp +++ b/source/Symbol/ClangExternalASTSourceCommon.cpp @@ -1,9 +1,8 @@ //===-- ClangExternalASTSourceCommon.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/ClangUtil.cpp b/source/Symbol/ClangUtil.cpp index 7a67df48ee6a..86be895fadcb 100644 --- a/source/Symbol/ClangUtil.cpp +++ b/source/Symbol/ClangUtil.cpp @@ -1,9 +1,8 @@ //===-- ClangUtil.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // // A collection of helper methods and data structures for manipulating clang // types and decls. @@ -48,3 +47,11 @@ CompilerType ClangUtil::RemoveFastQualifiers(const CompilerType &ct) { qual_type.removeLocalFastQualifiers(); return CompilerType(ct.GetTypeSystem(), qual_type.getAsOpaquePtr()); } + +clang::TagDecl *ClangUtil::GetAsTagDecl(const CompilerType &type) { + clang::QualType qual_type = ClangUtil::GetCanonicalQualType(type); + if (qual_type.isNull()) + return nullptr; + + return qual_type->getAsTagDecl(); +} diff --git a/source/Symbol/CompactUnwindInfo.cpp b/source/Symbol/CompactUnwindInfo.cpp index 7dda877582cc..20987a0a2ba2 100644 --- a/source/Symbol/CompactUnwindInfo.cpp +++ b/source/Symbol/CompactUnwindInfo.cpp @@ -1,9 +1,8 @@ //===-- CompactUnwindInfo.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -183,8 +182,7 @@ bool CompactUnwindInfo::GetUnwindPlan(Target &target, Address addr, if (function_info.encoding == 0) return false; - ArchSpec arch; - if (m_objfile.GetArchitecture(arch)) { + if (ArchSpec arch = m_objfile.GetArchitecture()) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); if (log && log->GetVerbose()) { @@ -204,7 +202,7 @@ bool CompactUnwindInfo::GetUnwindPlan(Target &target, Address addr, if (sl) { addr_t func_range_start_file_addr = function_info.valid_range_offset_start + - m_objfile.GetHeaderAddress().GetFileAddress(); + m_objfile.GetBaseAddress().GetFileAddress(); AddressRange func_range(func_range_start_file_addr, function_info.valid_range_offset_end - function_info.valid_range_offset_start, @@ -259,7 +257,7 @@ void CompactUnwindInfo::ScanIndex(const ProcessSP &process_sp) { m_objfile.GetModule()->LogMessage( log, "Reading compact unwind first-level indexes"); - if (m_unwindinfo_data_computed == false) { + if (!m_unwindinfo_data_computed) { if (m_section_sp->IsEncrypted()) { // Can't get section contents of a protected/encrypted section until we // have a live process and can read them out of memory. @@ -338,8 +336,7 @@ void CompactUnwindInfo::ScanIndex(const ProcessSP &process_sp) { // }; bool clear_address_zeroth_bit = false; - ArchSpec arch; - if (m_objfile.GetArchitecture(arch)) { + if (ArchSpec arch = m_objfile.GetArchitecture()) { if (arch.GetTriple().getArch() == llvm::Triple::arm || arch.GetTriple().getArch() == llvm::Triple::thumb) clear_address_zeroth_bit = true; @@ -513,7 +510,7 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction( return false; addr_t function_offset = - address.GetFileAddress() - m_objfile.GetHeaderAddress().GetFileAddress(); + address.GetFileAddress() - m_objfile.GetBaseAddress().GetFileAddress(); UnwindIndex key; key.function_offset = function_offset; @@ -529,7 +526,7 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction( --it; } - if (it->sentinal_entry == true) { + if (it->sentinal_entry) { return false; } @@ -578,10 +575,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction( if (sl) { uint32_t lsda_offset = GetLSDAForFunctionOffset( lsda_array_start, lsda_array_count, function_offset); - addr_t objfile_header_file_address = - m_objfile.GetHeaderAddress().GetFileAddress(); + addr_t objfile_base_address = + m_objfile.GetBaseAddress().GetFileAddress(); unwind_info.lsda_address.ResolveAddressUsingFileSections( - objfile_header_file_address + lsda_offset, sl); + objfile_base_address + lsda_offset, sl); } } if (unwind_info.encoding & UNWIND_PERSONALITY_MASK) { @@ -596,10 +593,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction( SectionList *sl = m_objfile.GetSectionList(); if (sl) { uint32_t personality_offset = m_unwindinfo_data.GetU32(&offset); - addr_t objfile_header_file_address = - m_objfile.GetHeaderAddress().GetFileAddress(); + addr_t objfile_base_address = + m_objfile.GetBaseAddress().GetFileAddress(); unwind_info.personality_ptr_address.ResolveAddressUsingFileSections( - objfile_header_file_address + personality_offset, sl); + objfile_base_address + personality_offset, sl); } } } @@ -662,10 +659,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction( if (sl) { uint32_t lsda_offset = GetLSDAForFunctionOffset( lsda_array_start, lsda_array_count, function_offset); - addr_t objfile_header_file_address = - m_objfile.GetHeaderAddress().GetFileAddress(); + addr_t objfile_base_address = + m_objfile.GetBaseAddress().GetFileAddress(); unwind_info.lsda_address.ResolveAddressUsingFileSections( - objfile_header_file_address + lsda_offset, sl); + objfile_base_address + lsda_offset, sl); } } if (unwind_info.encoding & UNWIND_PERSONALITY_MASK) { @@ -680,10 +677,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction( SectionList *sl = m_objfile.GetSectionList(); if (sl) { uint32_t personality_offset = m_unwindinfo_data.GetU32(&offset); - addr_t objfile_header_file_address = - m_objfile.GetHeaderAddress().GetFileAddress(); + addr_t objfile_base_address = + m_objfile.GetBaseAddress().GetFileAddress(); unwind_info.personality_ptr_address.ResolveAddressUsingFileSections( - objfile_header_file_address + personality_offset, sl); + objfile_base_address + personality_offset, sl); } } } @@ -925,7 +922,7 @@ bool CompactUnwindInfo::CreateUnwindPlan_x86_64(Target &target, for (uint32_t i = 0; i < register_count; i++) { int renum = 0; for (int j = 1; j < 7; j++) { - if (used[j] == false) { + if (!used[j]) { if (renum == permunreg[i]) { registers[i] = j; used[j] = true; @@ -1187,7 +1184,7 @@ bool CompactUnwindInfo::CreateUnwindPlan_i386(Target &target, for (uint32_t i = 0; i < register_count; i++) { int renum = 0; for (int j = 1; j < 7; j++) { - if (used[j] == false) { + if (!used[j]) { if (renum == permunreg[i]) { registers[i] = j; used[j] = true; diff --git a/source/Symbol/CompileUnit.cpp b/source/Symbol/CompileUnit.cpp index 0f56aabcfd99..09f02e18a77c 100644 --- a/source/Symbol/CompileUnit.cpp +++ b/source/Symbol/CompileUnit.cpp @@ -1,9 +1,8 @@ //===-- CompileUnit.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -21,7 +20,7 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, lldb_private::LazyBool is_optimized) - : ModuleChild(module_sp), FileSpec(pathname, false), UserID(cu_sym_id), + : ModuleChild(module_sp), FileSpec(pathname), UserID(cu_sym_id), m_user_data(user_data), m_language(language), m_flags(0), m_support_files(), m_line_table_ap(), m_variables(), m_is_optimized(is_optimized) { @@ -72,10 +71,10 @@ void CompileUnit::ForeachFunction( sorted_functions.reserve(m_functions_by_uid.size()); for (auto &p : m_functions_by_uid) sorted_functions.push_back(p.second); - std::sort(sorted_functions.begin(), sorted_functions.end(), - [](const lldb::FunctionSP &a, const lldb::FunctionSP &b) { - return a->GetID() < b->GetID(); - }); + llvm::sort(sorted_functions.begin(), sorted_functions.end(), + [](const lldb::FunctionSP &a, const lldb::FunctionSP &b) { + return a->GetID() < b->GetID(); + }); for (auto &f : sorted_functions) if (lambda(f)) @@ -182,9 +181,7 @@ lldb::LanguageType CompileUnit::GetLanguage() { m_flags.Set(flagsParsedLanguage); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - m_language = symbol_vendor->ParseCompileUnitLanguage(sc); + m_language = symbol_vendor->ParseLanguage(*this); } } } @@ -196,11 +193,8 @@ LineTable *CompileUnit::GetLineTable() { if (m_flags.IsClear(flagsParsedLineTable)) { m_flags.Set(flagsParsedLineTable); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); - if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - symbol_vendor->ParseCompileUnitLineTable(sc); - } + if (symbol_vendor) + symbol_vendor->ParseLineTable(*this); } } return m_line_table_ap.get(); @@ -220,9 +214,7 @@ DebugMacros *CompileUnit::GetDebugMacros() { m_flags.Set(flagsParsedDebugMacros); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - symbol_vendor->ParseCompileUnitDebugMacros(sc); + symbol_vendor->ParseDebugMacros(*this); } } } @@ -278,7 +270,8 @@ uint32_t CompileUnit::FindLineEntry(uint32_t start_idx, uint32_t line, uint32_t CompileUnit::ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - bool exact, uint32_t resolve_scope, + bool exact, + SymbolContextItem resolve_scope, SymbolContextList &sc_list) { // First find all of the file indexes that match our "file_spec". If // "file_spec" has an empty directory, then only compare the basenames when @@ -290,7 +283,7 @@ uint32_t CompileUnit::ResolveSymbolContext(const FileSpec &file_spec, // If we are not looking for inlined functions and our file spec doesn't // match then we are done... - if (file_spec_matches_cu_file_spec == false && check_inlines == false) + if (!file_spec_matches_cu_file_spec && !check_inlines) return 0; uint32_t file_idx = @@ -386,9 +379,7 @@ bool CompileUnit::GetIsOptimized() { if (m_is_optimized == eLazyBoolCalculate) { m_is_optimized = eLazyBoolNo; if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (symbol_vendor->ParseCompileUnitIsOptimized(sc)) + if (symbol_vendor->ParseIsOptimized(*this)) m_is_optimized = eLazyBoolYes; } } @@ -418,9 +409,7 @@ FileSpecList &CompileUnit::GetSupportFiles() { m_flags.Set(flagsParsedSupportFiles); SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor(); if (symbol_vendor) { - SymbolContext sc; - CalculateSymbolContext(&sc); - symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files); + symbol_vendor->ParseSupportFiles(*this, m_support_files); } } } diff --git a/source/Symbol/CompilerDecl.cpp b/source/Symbol/CompilerDecl.cpp index 2b632c5eb5d0..2c64113a2bbe 100644 --- a/source/Symbol/CompilerDecl.cpp +++ b/source/Symbol/CompilerDecl.cpp @@ -1,9 +1,8 @@ //===-- CompilerDecl.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/CompilerDeclContext.cpp b/source/Symbol/CompilerDeclContext.cpp index 43a83bbca77b..a8fa7e2d339f 100644 --- a/source/Symbol/CompilerDeclContext.cpp +++ b/source/Symbol/CompilerDeclContext.cpp @@ -1,9 +1,8 @@ //===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/CompilerType.cpp b/source/Symbol/CompilerType.cpp index fb214c3a03dd..a5823c7f7b11 100644 --- a/source/Symbol/CompilerType.cpp +++ b/source/Symbol/CompilerType.cpp @@ -1,16 +1,14 @@ //===-- CompilerType.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Symbol/CompilerType.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/StreamFile.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangExternalASTSourceCommon.h" @@ -21,6 +19,7 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -561,7 +560,7 @@ CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const { llvm::Optional CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const { - if (auto bit_size = GetBitSize(exe_scope)) + if (llvm::Optional bit_size = GetBitSize(exe_scope)) return (*bit_size + 7) / 8; return {}; } @@ -889,7 +888,7 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data, if (encoding == lldb::eEncodingInvalid || count != 1) return false; - auto byte_size = GetByteSize(nullptr); + llvm::Optional byte_size = GetByteSize(nullptr); if (!byte_size) return false; lldb::offset_t offset = data_byte_offset; @@ -987,7 +986,7 @@ bool CompilerType::SetValueFromScalar(const Scalar &value, Stream &strm) { if (encoding == lldb::eEncodingInvalid || count != 1) return false; - auto bit_width = GetBitSize(nullptr); + llvm::Optional bit_width = GetBitSize(nullptr); if (!bit_width) return false; @@ -1141,16 +1140,6 @@ bool CompilerType::WriteToMemory(lldb_private::ExecutionContext *exe_ctx, return false; } -// clang::CXXRecordDecl * -// CompilerType::GetAsCXXRecordDecl (lldb::opaque_compiler_type_t -// opaque_compiler_qual_type) -//{ -// if (opaque_compiler_qual_type) -// return -// clang::QualType::getFromOpaquePtr(opaque_compiler_qual_type)->getAsCXXRecordDecl(); -// return NULL; -//} - bool lldb_private::operator==(const lldb_private::CompilerType &lhs, const lldb_private::CompilerType &rhs) { return lhs.GetTypeSystem() == rhs.GetTypeSystem() && @@ -1159,6 +1148,5 @@ bool lldb_private::operator==(const lldb_private::CompilerType &lhs, bool lldb_private::operator!=(const lldb_private::CompilerType &lhs, const lldb_private::CompilerType &rhs) { - return lhs.GetTypeSystem() != rhs.GetTypeSystem() || - lhs.GetOpaqueQualType() != rhs.GetOpaqueQualType(); + return !(lhs == rhs); } diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp index 1bf9ff99e015..c5b02e2ff226 100644 --- a/source/Symbol/DWARFCallFrameInfo.cpp +++ b/source/Symbol/DWARFCallFrameInfo.cpp @@ -1,9 +1,8 @@ //===-- DWARFCallFrameInfo.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -161,7 +160,7 @@ bool DWARFCallFrameInfo::GetUnwindPlan(Address addr, UnwindPlan &unwind_plan) { module_sp->GetObjectFile() != &m_objfile) return false; - if (GetFDEEntryByFileAddress(addr.GetFileAddress(), fde_entry) == false) + if (!GetFDEEntryByFileAddress(addr.GetFileAddress(), fde_entry)) return false; return FDEToUnwindPlan(fde_entry.data, addr, unwind_plan); } @@ -243,7 +242,7 @@ DWARFCallFrameInfo::CIESP DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { CIESP cie_sp(new CIE(cie_offset)); lldb::offset_t offset = cie_offset; - if (m_cfi_data_initialized == false) + if (!m_cfi_data_initialized) GetCFIData(); uint32_t length = m_cfi_data.GetU32(&offset); dw_offset_t cie_id, end_offset; @@ -394,7 +393,7 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { } void DWARFCallFrameInfo::GetCFIData() { - if (m_cfi_data_initialized == false) { + if (!m_cfi_data_initialized) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); if (log) m_objfile.GetModule()->LogMessage(log, "Reading EH frame info"); @@ -423,15 +422,14 @@ void DWARFCallFrameInfo::GetFDEIndex() { m_objfile.GetFileSpec().GetFilename().AsCString("")); bool clear_address_zeroth_bit = false; - ArchSpec arch; - if (m_objfile.GetArchitecture(arch)) { + if (ArchSpec arch = m_objfile.GetArchitecture()) { if (arch.GetTriple().getArch() == llvm::Triple::arm || arch.GetTriple().getArch() == llvm::Triple::thumb) clear_address_zeroth_bit = true; } lldb::offset_t offset = 0; - if (m_cfi_data_initialized == false) + if (!m_cfi_data_initialized) GetCFIData(); while (m_cfi_data.ValidOffsetForDataOfSize(offset, 8)) { const dw_offset_t current_entry = offset; @@ -533,7 +531,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset, if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted()) return false; - if (m_cfi_data_initialized == false) + if (!m_cfi_data_initialized) GetCFIData(); uint32_t length = m_cfi_data.GetU32(&offset); diff --git a/source/Symbol/DebugMacros.cpp b/source/Symbol/DebugMacros.cpp index 22576ee1ce26..d119a78868a4 100644 --- a/source/Symbol/DebugMacros.cpp +++ b/source/Symbol/DebugMacros.cpp @@ -1,9 +1,8 @@ //===-- DebugMacros.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/Declaration.cpp b/source/Symbol/Declaration.cpp index 83df578da2e3..a1c6068e90b4 100644 --- a/source/Symbol/Declaration.cpp +++ b/source/Symbol/Declaration.cpp @@ -1,9 +1,8 @@ //===-- Declaration.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp index 2384d35e3d36..ee7bf608c45e 100644 --- a/source/Symbol/FuncUnwinders.cpp +++ b/source/Symbol/FuncUnwinders.cpp @@ -1,9 +1,8 @@ //===-- FuncUnwinders.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -255,7 +254,7 @@ UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target &target, int current_offset) { std::lock_guard guard(m_mutex); if (m_unwind_plan_assembly_sp.get() || m_tried_unwind_plan_assembly || - m_unwind_table.GetAllowAssemblyEmulationUnwindPlans() == false) { + !m_unwind_table.GetAllowAssemblyEmulationUnwindPlans()) { return m_unwind_plan_assembly_sp; } @@ -443,8 +442,7 @@ const Address &FuncUnwinders::GetFunctionStartAddress() const { lldb::UnwindAssemblySP FuncUnwinders::GetUnwindAssemblyProfiler(Target &target) { UnwindAssemblySP assembly_profiler_sp; - ArchSpec arch; - if (m_unwind_table.GetArchitecture(arch)) { + if (ArchSpec arch = m_unwind_table.GetArchitecture()) { arch.MergeFrom(target.GetArchitecture()); assembly_profiler_sp = UnwindAssembly::FindPlugin(arch); } diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp index c200915bec6b..5b8d804fd85e 100644 --- a/source/Symbol/Function.cpp +++ b/source/Symbol/Function.cpp @@ -1,9 +1,8 @@ //===-- Function.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -201,21 +200,6 @@ Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, assert(comp_unit != nullptr); } -Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, - lldb::user_id_t type_uid, const char *mangled, Type *type, - const AddressRange &range, bool canThrow) - : UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid), - m_type(type), m_mangled(ConstString(mangled), true), m_block(func_uid), - m_range(range), m_frame_base(nullptr), m_flags(), - m_prologue_byte_size(0) { - m_block.SetParentScope(this); - - if (canThrow) - m_flags.Set(flagsFunctionCanThrow); - - assert(comp_unit != nullptr); -} - Function::~Function() {} void Function::GetStartLineSourceInfo(FileSpec &source_file, @@ -287,11 +271,11 @@ llvm::MutableArrayRef Function::GetCallEdges() { m_call_edges = sym_file->ParseCallEdgesInFunction(GetID()); // Sort the call edges to speed up return_pc lookups. - std::sort(m_call_edges.begin(), m_call_edges.end(), - [](const CallEdge &LHS, const CallEdge &RHS) { - return LHS.GetUnresolvedReturnPCAddress() < - RHS.GetUnresolvedReturnPCAddress(); - }); + llvm::sort(m_call_edges.begin(), m_call_edges.end(), + [](const CallEdge &LHS, const CallEdge &RHS) { + return LHS.GetUnresolvedReturnPCAddress() < + RHS.GetUnresolvedReturnPCAddress(); + }); return m_call_edges; } @@ -306,14 +290,14 @@ llvm::MutableArrayRef Function::GetTailCallingEdges() { Block &Function::GetBlock(bool can_create) { if (!m_block.BlockInfoHasBeenParsed() && can_create) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.module_sp) { - sc.module_sp->GetSymbolVendor()->ParseFunctionBlocks(sc); + ModuleSP module_sp = CalculateSymbolContextModule(); + if (module_sp) { + module_sp->GetSymbolVendor()->ParseBlocksRecursive(*this); } else { - Host::SystemLog(Host::eSystemLogError, "error: unable to find module " - "shared pointer for function '%s' " - "in %s\n", + Host::SystemLog(Host::eSystemLogError, + "error: unable to find module " + "shared pointer for function '%s' " + "in %s\n", GetName().GetCString(), m_comp_unit->GetPath().c_str()); } m_block.SetBlockInfoHasBeenParsed(true, true); diff --git a/source/Symbol/LineEntry.cpp b/source/Symbol/LineEntry.cpp index bffcc5321b11..94887a0f7858 100644 --- a/source/Symbol/LineEntry.cpp +++ b/source/Symbol/LineEntry.cpp @@ -1,9 +1,8 @@ //===-- LineEntry.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp index 06e30219f09a..91fc94fb4926 100644 --- a/source/Symbol/LineTable.cpp +++ b/source/Symbol/LineTable.cpp @@ -1,9 +1,8 @@ //===-- LineTable.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp index 22936381fd4c..a91050466629 100644 --- a/source/Symbol/ObjectFile.cpp +++ b/source/Symbol/ObjectFile.cpp @@ -1,9 +1,8 @@ //===-- ObjectFile.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,7 +19,6 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Timer.h" @@ -48,7 +46,7 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file, FileSpec archive_file; ObjectContainerCreateInstance create_object_container_callback; - const bool file_exists = file->Exists(); + const bool file_exists = FileSystem::Instance().Exists(*file); if (!data_sp) { // We have an object name which most likely means we have a .o file in // a static archive (.a file). Try and see if we have a cached archive @@ -76,8 +74,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file, // container plug-ins can use these bytes to see if they can parse this // file. if (file_size > 0) { - data_sp = - DataBufferLLVM::CreateSliceFromPath(file->GetPath(), 512, file_offset); + data_sp = FileSystem::Instance().CreateDataBuffer(file->GetPath(), + 512, file_offset); data_offset = 0; } } @@ -92,7 +90,7 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file, const bool must_exist = true; if (ObjectFile::SplitArchivePathWithObject( path_with_object, archive_file, archive_object, must_exist)) { - file_size = archive_file.GetByteSize(); + file_size = FileSystem::Instance().GetByteSize(archive_file); if (file_size > 0) { file = &archive_file; module_sp->SetFileSpecAndObjectName(archive_file, archive_object); @@ -121,8 +119,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file, } // We failed to find any cached object files in the container plug- // ins, so lets read the first 512 bytes and try again below... - data_sp = DataBufferLLVM::CreateSliceFromPath(archive_file.GetPath(), - 512, file_offset); + data_sp = FileSystem::Instance().CreateDataBuffer( + archive_file.GetPath(), 512, file_offset); } } } @@ -210,10 +208,12 @@ size_t ObjectFile::GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs) { - DataBufferSP data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), 512, file_offset); + DataBufferSP data_sp = + FileSystem::Instance().CreateDataBuffer(file.GetPath(), 512, file_offset); if (data_sp) { if (file_size == 0) { - const lldb::offset_t actual_file_size = file.GetByteSize(); + const lldb::offset_t actual_file_size = + FileSystem::Instance().GetByteSize(file); if (actual_file_size > file_offset) file_size = actual_file_size - file_offset; } @@ -345,21 +345,28 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) { return AddressClass::eData; case eSectionTypeDebug: case eSectionTypeDWARFDebugAbbrev: + case eSectionTypeDWARFDebugAbbrevDwo: case eSectionTypeDWARFDebugAddr: case eSectionTypeDWARFDebugAranges: case eSectionTypeDWARFDebugCuIndex: case eSectionTypeDWARFDebugFrame: case eSectionTypeDWARFDebugInfo: + case eSectionTypeDWARFDebugInfoDwo: case eSectionTypeDWARFDebugLine: + case eSectionTypeDWARFDebugLineStr: case eSectionTypeDWARFDebugLoc: + case eSectionTypeDWARFDebugLocLists: case eSectionTypeDWARFDebugMacInfo: case eSectionTypeDWARFDebugMacro: case eSectionTypeDWARFDebugNames: case eSectionTypeDWARFDebugPubNames: case eSectionTypeDWARFDebugPubTypes: case eSectionTypeDWARFDebugRanges: + case eSectionTypeDWARFDebugRngLists: case eSectionTypeDWARFDebugStr: + case eSectionTypeDWARFDebugStrDwo: case eSectionTypeDWARFDebugStrOffsets: + case eSectionTypeDWARFDebugStrOffsetsDwo: case eSectionTypeDWARFDebugTypes: case eSectionTypeDWARFAppleNames: case eSectionTypeDWARFAppleTypes: @@ -451,6 +458,9 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) { return AddressClass::eRuntime; case eSymbolTypeASTFile: return AddressClass::eDebug; + + case eSymbolTypeIVarOffset: + break; } } } @@ -583,11 +593,9 @@ bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object, std::string obj; if (regex_match.GetMatchAtIndex(path_with_object, 1, path) && regex_match.GetMatchAtIndex(path_with_object, 2, obj)) { - archive_file.SetFile(path, false, FileSpec::Style::native); + archive_file.SetFile(path, FileSpec::Style::native); archive_object.SetCString(obj.c_str()); - if (must_exist && !archive_file.Exists()) - return false; - return true; + return !(must_exist && !FileSystem::Instance().Exists(archive_file)); } } return false; @@ -683,5 +691,65 @@ void ObjectFile::RelocateSection(lldb_private::Section *section) DataBufferSP ObjectFile::MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset) { - return DataBufferLLVM::CreateSliceFromPath(file.GetPath(), Size, Offset); + return FileSystem::Instance().CreateDataBuffer(file.GetPath(), Size, Offset); +} + +void llvm::format_provider::format( + const ObjectFile::Type &type, raw_ostream &OS, StringRef Style) { + switch (type) { + case ObjectFile::eTypeInvalid: + OS << "invalid"; + break; + case ObjectFile::eTypeCoreFile: + OS << "core file"; + break; + case ObjectFile::eTypeExecutable: + OS << "executable"; + break; + case ObjectFile::eTypeDebugInfo: + OS << "debug info"; + break; + case ObjectFile::eTypeDynamicLinker: + OS << "dynamic linker"; + break; + case ObjectFile::eTypeObjectFile: + OS << "object file"; + break; + case ObjectFile::eTypeSharedLibrary: + OS << "shared library"; + break; + case ObjectFile::eTypeStubLibrary: + OS << "stub library"; + break; + case ObjectFile::eTypeJIT: + OS << "jit"; + break; + case ObjectFile::eTypeUnknown: + OS << "unknown"; + break; + } +} + +void llvm::format_provider::format( + const ObjectFile::Strata &strata, raw_ostream &OS, StringRef Style) { + switch (strata) { + case ObjectFile::eStrataInvalid: + OS << "invalid"; + break; + case ObjectFile::eStrataUnknown: + OS << "unknown"; + break; + case ObjectFile::eStrataUser: + OS << "user"; + break; + case ObjectFile::eStrataKernel: + OS << "kernel"; + break; + case ObjectFile::eStrataRawImage: + OS << "raw image"; + break; + case ObjectFile::eStrataJIT: + OS << "jit"; + break; + } } diff --git a/source/Symbol/SwiftASTContext.cpp b/source/Symbol/SwiftASTContext.cpp index 809368f541d1..8f6ff5839965 100644 --- a/source/Symbol/SwiftASTContext.cpp +++ b/source/Symbol/SwiftASTContext.cpp @@ -518,7 +518,7 @@ class SwiftAllPayloadEnumDescriptor : public SwiftEnumDescriptor { .getPointer()}; } - const bool is_indirect = case_decl->isIndirect() + const bool is_indirect = case_decl->isIndirect() || case_decl->getParentEnum()->isIndirect(); if (log) @@ -1043,7 +1043,7 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, // First, check if there's something in our bundle. { - FileSpec swift_dir_spec(swift_dir, false); + FileSpec swift_dir_spec(swift_dir); if (swift_dir_spec) { if (log) log->Printf("%s: trying ePathTypeSwiftDir: %s", fn, @@ -1077,7 +1077,7 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, log->Printf("%s: trying toolchain-based lib path: %s", fn, path.c_str()); - if (IsDirectory(FileSpec(path, false))) { + if (IsDirectory(FileSpec(path))) { if (log) log->Printf("%s: found Swift resource dir via " "toolchain path + 'usr/lib/swift': %s", @@ -1101,11 +1101,11 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, if (log) log->Printf("%s: trying Xcode-based lib path: %s", fn, path.c_str()); - if (IsDirectory(FileSpec(path, false))) { + if (IsDirectory(FileSpec(path))) { StringRef resource_dir = path; llvm::sys::path::append(path, swift_stdlib_os_dir); std::string s = path.str(); - if (IsDirectory(FileSpec(path, false))) { + if (IsDirectory(FileSpec(path))) { if (log) log->Printf("%s: found Swift resource dir via " "Xcode contents path + default toolchain " @@ -1118,7 +1118,7 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, llvm::sys::path::append(path, "usr/lib/swift"); StringRef resource_dir = path; llvm::sys::path::append(path, swift_stdlib_os_dir); - if (IsDirectory(FileSpec(path, false))) { + if (IsDirectory(FileSpec(path))) { if (log) log->Printf("%s: found Swift resource dir via " "Xcode contents path + cross-compilation SDK " @@ -1145,7 +1145,7 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, log->Printf("%s: trying command-line tools-based lib path: %s", fn, path.c_str()); - if (IsDirectory(FileSpec(path, false))) { + if (IsDirectory(FileSpec(path))) { if (log) log->Printf("%s: found Swift resource dir via command-line tools " "path + usr/lib/swift: %s", @@ -1161,7 +1161,7 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, // different than the install- dir layout that the previous checks // would try. { - FileSpec faux_swift_dir_spec(swift_dir, false); + FileSpec faux_swift_dir_spec(swift_dir); if (faux_swift_dir_spec) { // We can't use a C++11 stdlib regex feature here because it doesn't // work on Ubuntu 14.04 x86_64. Once we don't care about supporting @@ -1214,8 +1214,7 @@ std::string SwiftASTContext::GetResourceDir(StringRef platform_sdk_path, log->Printf("%s: trying ePathTypeSwiftDir regex-based " "build dir: %s", fn, build_tree_resource_dir.c_str()); - FileSpec swift_resource_dir_spec(build_tree_resource_dir.c_str(), - false); + FileSpec swift_resource_dir_spec(build_tree_resource_dir.c_str()); if (IsDirectory(swift_resource_dir_spec)) { if (log) log->Printf("%s: found Swift resource dir via " @@ -1305,6 +1304,9 @@ static bool DeserializeCompilerFlags(swift::CompilerInvocation &invocation, error << "the swift module file was built for a target newer than the " "current target\n"; break; + + case swift::serialization::Status::CircularDependency: + break; } return false; } @@ -1400,6 +1402,30 @@ bool HasSwiftModules(Module &module) { } namespace { + +/// Calls arg.consume_front() and returns true on success. +/// \param prefix contains the consumed prefix. +bool ConsumeIncludeOption(StringRef &arg, StringRef &prefix) { + static StringRef options[] = {"-I", + "-F", + "-iquote", + "-idirafter", + "-iframeworkwithsysroot", + "-iframework", + "-iprefix", + "-iwithprefixbefore", + "-iwithprefix", + "-isystemafter", + "-isystem", + "-isysroot"}; + for (StringRef &option : options) + if (arg.consume_front(option)) { + prefix = option; + return true; + } + return false; +} + /// Turn relative paths in clang options into absolute paths based on /// \c cur_working_dir. template @@ -1407,16 +1433,14 @@ void ApplyWorkingDir(SmallString &clang_argument, StringRef cur_working_dir) { StringRef arg = clang_argument.str(); StringRef prefix; - // Ignore the option part of a double-arg include option. - if (arg == "-I" || arg == "-F") - return; - if (arg.consume_front("-I")) - prefix = "-I"; - else if (arg.consume_front("-F")) - prefix = "-F"; - else if (arg.startswith("-")) + if (ConsumeIncludeOption(arg, prefix)) { + // Ignore the option part of a double-arg include option. + if (arg.empty()) + return; + } else if (arg.startswith("-")) { // Assume this is a compiler arg and not a path starting with "-". return; + } // There is most probably a path in arg now. if (!llvm::sys::path::is_relative(arg)) return; @@ -1467,18 +1491,32 @@ void SwiftASTContext::RemapClangImporterOptions( remapped.c_str()); options.BridgingHeader = remapped; } + + // Previous argument was the dash-option of an option pair. + bool remap_next = false; for (auto &arg_string : options.ExtraArgs) { StringRef prefix; StringRef arg = arg_string; - if (arg.consume_front("-I")) - prefix = "-I"; - else if (arg.consume_front("-F")) - prefix = "-F"; + + if (remap_next) + remap_next = false; + else if (ConsumeIncludeOption(arg, prefix)) { + if (arg.empty()) { + // Option pair. + remap_next = true; + continue; + } + // Single-arg include option with prefix. + } else { + // Not a recognized option. + continue; + } + if (path_map.RemapPath(arg, remapped)) { if (log) log->Printf("remapped %s -> %s%s", arg.str().c_str(), prefix.str().c_str(), remapped.c_str()); - arg_string = prefix.str()+remapped; + arg_string = prefix.str() + remapped; } } } @@ -1492,10 +1530,12 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, ArchSpec arch = module.GetArchitecture(); ObjectFile *objfile = module.GetObjectFile(); - ArchSpec object_arch; + if (!objfile) + return {}; - if (!objfile || !objfile->GetArchitecture(object_arch)) - return TypeSystemSP(); + ArchSpec object_arch = objfile->GetArchitecture(); + if (!object_arch.IsValid()) + return {}; lldb::CompUnitSP main_compile_unit_sp = module.GetCompileUnitAtIndex(0); @@ -1505,7 +1545,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, StreamString ss; module.GetDescription(&ss); log->Printf("SwiftASTContext::CreateInstance(Module=%s)", ss.GetData()); - if (main_compile_unit_sp && !main_compile_unit_sp->Exists()) + if (main_compile_unit_sp && !FileSystem::Instance().Exists(*main_compile_unit_sp)) log->Printf("Corresponding source not found for %s, loading module " "is unlikely to succeed", main_compile_unit_sp->GetCString()); @@ -1594,8 +1634,8 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, if (log) log->Printf("\tGot serialized SDK path %s.", serialized_sdk_path.data()); - FileSpec sdk_spec(serialized_sdk_path.data(), false); - if (sdk_spec.Exists()) { + FileSpec sdk_spec(serialized_sdk_path.data()); + if (FileSystem::Instance().Exists(sdk_spec)) { swift_ast_sp->SetPlatformSDKPath(serialized_sdk_path.data()); } } @@ -1603,8 +1643,8 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, if (!got_serialized_options || !swift_ast_sp->GetPlatformSDKPath()) { std::string platform_sdk_path; if (sym_vendor->GetCompileOption("-sdk", platform_sdk_path)) { - FileSpec sdk_spec(platform_sdk_path.c_str(), false); - if (sdk_spec.Exists()) { + FileSpec sdk_spec(platform_sdk_path.c_str()); + if (FileSystem::Instance().Exists(sdk_spec)) { swift_ast_sp->SetPlatformSDKPath(platform_sdk_path.c_str()); } @@ -1631,9 +1671,9 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, if (sym_vendor->GetCompileOptions("-I", include_paths)) { for (std::string &search_path : include_paths) { - const FileSpec path_spec(search_path.c_str(), false); + const FileSpec path_spec(search_path.c_str()); - if (path_spec.Exists()) { + if (FileSystem::Instance().Exists(path_spec)) { static const ConstString s_hmap_extension("hmap"); if (IsDirectory(path_spec)) { @@ -1651,7 +1691,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, std::vector cc_options; if (sym_vendor->GetCompileOptions("-Xcc", cc_options)) { - for (int i = 0; i < cc_options.size(); ++i) { + for (size_t i = 0; i < cc_options.size(); ++i) { if (!cc_options[i].compare("-iquote") && i + 1 < cc_options.size()) { swift_ast_sp->AddClangArgumentPair("-iquote", cc_options[i + 1].c_str()); @@ -1680,7 +1720,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, StringRef resource_dir = swift_ast_sp->GetResourceDir(triple); ConfigureResourceDirs(swift_ast_sp->GetCompilerInvocation(), - FileSpec(resource_dir, false), triple); + FileSpec(resource_dir), triple); // Apply the working directory to all relative paths. std::vector DeserializedArgs = swift_ast_sp->GetClangArguments(); @@ -1688,12 +1728,12 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, swift_ast_sp->AddExtraClangArgs(DeserializedArgs); // Apply source path remappings found in the module's dSYM. swift_ast_sp->RemapClangImporterOptions(module.GetSourceMappingList()); - + if (!swift_ast_sp->GetClangImporter()) { if (log) { log->Printf("((Module*)%p) [%s]->GetSwiftASTContext() returning NULL " "- couldn't create a ClangImporter", - &module, + static_cast(&module), module.GetFileSpec().GetFilename().AsCString("")); } @@ -1705,9 +1745,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, swift_ast_sp->ValidateSectionModules(module, module_names); if (log) { - log->Printf("((Module*)%p) [%s]->GetSwiftASTContext() = %p", &module, + log->Printf("((Module*)%p) [%s]->GetSwiftASTContext() = %p", + static_cast(&module), module.GetFileSpec().GetFilename().AsCString(""), - swift_ast_sp.get()); + static_cast(swift_ast_sp.get())); swift_ast_sp->DumpConfiguration(log); } return swift_ast_sp; @@ -1733,7 +1774,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, auto logError = [&](const char *message) { if (log) log->Printf("((Target*)%p)->GetSwiftASTContext() returning NULL - %s", - &target, message); + static_cast(&target), message); }; if (!arch.IsValid()) { @@ -1749,7 +1790,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, // Set the SDK path prior to doing search paths. Otherwise when we // create search path options we put in the wrong SDK path. FileSpec &target_sdk_spec = target.GetSDKPath(); - if (target_sdk_spec && target_sdk_spec.Exists()) { + if (target_sdk_spec && FileSystem::Instance().Exists(target_sdk_spec)) { std::string platform_sdk_path(target_sdk_spec.GetPath()); swift_ast_sp->SetPlatformSDKPath(std::move(platform_sdk_path)); handled_sdk_path = true; @@ -1890,7 +1931,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, llvm::Triple triple(swift_ast_sp->GetTriple()); StringRef resource_dir = swift_ast_sp->GetResourceDir(triple); ConfigureResourceDirs(swift_ast_sp->GetCompilerInvocation(), - FileSpec(resource_dir, false), triple); + FileSpec(resource_dir), triple); const bool use_all_compiler_flags = !got_serialized_options || target.GetUseAllCompilerFlags(); @@ -1916,16 +1957,17 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, std::string framework_path = module_path.substr(0, framework_offset); framework_path.append(".framework"); - FileSpec path_spec(framework_path, true); + FileSpec path_spec(framework_path); + FileSystem::Instance().Resolve(path_spec); FileSpec headers_spec = path_spec.CopyByAppendingPathComponent("Headers"); bool add_it = false; - if (headers_spec.Exists()) + if (FileSystem::Instance().Exists(headers_spec)) add_it = true; if (!add_it) { FileSpec module_spec = path_spec.CopyByAppendingPathComponent("Modules"); - if (module_spec.Exists()) + if (FileSystem::Instance().Exists(module_spec)) add_it = true; } @@ -2040,8 +2082,9 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language, } if (log) { - log->Printf("((Target*)%p)->GetSwiftASTContext() = %p", &target, - swift_ast_sp.get()); + log->Printf("((Target*)%p)->GetSwiftASTContext() = %p", + static_cast(&target), + static_cast(swift_ast_sp.get())); swift_ast_sp->DumpConfiguration(log); } @@ -2091,6 +2134,7 @@ static lldb::TypeSystemSP CreateTypeSystemInstance(lldb::LanguageType language, assert(!module); return SwiftASTContext::CreateInstance(language, *target, extra_options); } + llvm_unreachable("Neither type nor module given to CreateTypeSystemInstance"); } void SwiftASTContext::Initialize() { @@ -2184,7 +2228,6 @@ bool SwiftASTContext::SetTriple(const char *triple_cstr, Module *module) { if (module) { ObjectFile *objfile = module->GetObjectFile(); - uint32_t versions[3]; if (objfile) { StreamString strm; if (llvm::VersionTuple version = objfile->GetMinimumOSVersion()) { @@ -2198,7 +2241,7 @@ bool SwiftASTContext::SetTriple(const char *triple_cstr, Module *module) { } if (log) log->Printf("%p: SwiftASTContext::SetTriple('%s') setting to '%s'%s", - this, triple_cstr, triple.c_str(), + static_cast(this), triple_cstr, triple.c_str(), m_target_wp.lock() ? " (target)" : ""); if (llvm::Triple(triple).getOS() == llvm::Triple::UnknownOS) { @@ -2219,7 +2262,7 @@ bool SwiftASTContext::SetTriple(const char *triple_cstr, Module *module) { if (log) log->Printf("%p: SwiftASTContext::SetTriple('%s') ignoring triple " "since the IRGenModule has already been created", - this, triple_cstr); + static_cast(this), triple_cstr); } } return false; @@ -2235,7 +2278,7 @@ struct SDKEnumeratorInfo { }; } // anonymous namespace - + static bool SDKSupportsSwift(const FileSpec &sdk_path, SDKType desired_type) { ConstString last_path_component = sdk_path.GetLastPathComponent(); @@ -2324,17 +2367,17 @@ static bool SDKSupportsSwift(const FileSpec &sdk_path, SDKType desired_type) { return false; } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, - const FileSpec &spec) { + StringRef path) { SDKEnumeratorInfo *enumerator_info = static_cast(baton); - + const FileSpec spec(path); if (SDKSupportsSwift(spec, enumerator_info->sdk_type)) { enumerator_info->found_path = spec; - return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; + return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; } - return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; + return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; }; static ConstString EnumerateSDKsForVersion(FileSpec sdks_spec, SDKType sdk_type, @@ -2353,9 +2396,11 @@ static ConstString EnumerateSDKsForVersion(FileSpec sdks_spec, SDKType sdk_type, enumerator_info.least_major = least_major; enumerator_info.least_minor = least_minor; - FileSpec::EnumerateDirectory(sdks_spec.GetPath().c_str(), find_directories, - find_files, find_other, DirectoryEnumerator, - &enumerator_info); + FileSystem::Instance().EnumerateDirectory(sdks_spec.GetPath().c_str(), + find_directories, + find_files, find_other, + DirectoryEnumerator, + &enumerator_info); if (IsDirectory(enumerator_info.found_path)) return ConstString(enumerator_info.found_path.GetPath()); @@ -2382,11 +2427,11 @@ static ConstString GetSDKDirectory(SDKType sdk_type, uint32_t least_major, // For now, we need to be prepared to handle either capitalization of this // path. std::string WatchOS_candidate_path = sdks_path + "/WatchOS.platform/"; - if (IsDirectory(FileSpec(WatchOS_candidate_path.c_str(), false))) { + if (IsDirectory(FileSpec(WatchOS_candidate_path.c_str()))) { sdks_path = WatchOS_candidate_path; } else { std::string watchOS_candidate_path = sdks_path + "/watchOS.platform/"; - if (IsDirectory(FileSpec(watchOS_candidate_path.c_str(), false))) { + if (IsDirectory(FileSpec(watchOS_candidate_path.c_str()))) { sdks_path = watchOS_candidate_path; } else { return ConstString(); @@ -2398,7 +2443,7 @@ static ConstString GetSDKDirectory(SDKType sdk_type, uint32_t least_major, sdks_path.append("Developer/SDKs/"); - FileSpec sdks_spec(sdks_path.c_str(), false); + FileSpec sdks_spec(sdks_path.c_str()); return EnumerateSDKsForVersion(sdks_spec, sdk_type, least_major, least_major); @@ -2412,7 +2457,6 @@ static ConstString GetSDKDirectory(SDKType sdk_type, uint32_t least_major, uint32_t major = version.getMajor(); uint32_t minor = version.getMinor().getValueOr(0); - uint32_t update = version.getSubminor().getValueOr(0); // If there are minimum requirements that exceed the current OS, // apply those. @@ -2444,8 +2488,8 @@ static ConstString GetSDKDirectory(SDKType sdk_type, uint32_t least_major, sdk_path.Printf( "%sDeveloper/Platforms/MacOSX.platform/Developer/SDKs/MacOSX%u.%u.sdk", xcode_contents_path.c_str(), major, minor); - fspec.SetFile(sdk_path.GetString(), false, FileSpec::Style::native); - if (fspec.Exists()) { + fspec.SetFile(sdk_path.GetString(), FileSpec::Style::native); + if (FileSystem::Instance().Exists(fspec)) { ConstString path(sdk_path.GetString()); // Cache results. g_sdk_cache[major_minor] = path; @@ -2456,8 +2500,8 @@ static ConstString GetSDKDirectory(SDKType sdk_type, uint32_t least_major, sdk_path.Printf("%sDeveloper/Platforms/MacOSX.platform/Developer/SDKs/" "MacOSX%u.%u.sdk", xcode_contents_path.c_str(), least_major, least_minor); - fspec.SetFile(sdk_path.GetString(), false, FileSpec::Style::native); - if (fspec.Exists()) { + fspec.SetFile(sdk_path.GetString(), FileSpec::Style::native); + if (FileSystem::Instance().Exists(fspec)) { ConstString path(sdk_path.GetString()); // Cache results. g_sdk_cache[major_minor] = path; @@ -2468,7 +2512,7 @@ static ConstString GetSDKDirectory(SDKType sdk_type, uint32_t least_major, std::string sdks_path = xcode_contents_path; sdks_path.append("Developer/Platforms/MacOSX.platform/Developer/SDKs"); - FileSpec sdks_spec(sdks_path.c_str(), false); + FileSpec sdks_spec(sdks_path.c_str()); ConstString sdk_path = EnumerateSDKsForVersion( sdks_spec, sdk_type, least_major, least_major); @@ -2538,9 +2582,8 @@ swift::ClangImporterOptions &SwiftASTContext::GetClangImporterOptions() { FileSpec clang_dir_spec; clang_dir_spec = GetClangResourceDir(); - if (clang_dir_spec.Exists()) - clang_importer_options.OverrideResourceDir = - std::move(clang_dir_spec.GetPath()); + if (FileSystem::Instance().Exists(clang_dir_spec)) + clang_importer_options.OverrideResourceDir = clang_dir_spec.GetPath(); clang_importer_options.DebuggerSupport = true; } return clang_importer_options; @@ -2555,18 +2598,18 @@ swift::SearchPathOptions &SwiftASTContext::GetSearchPathOptions() { bool set_sdk = false; if (!search_path_opts.SDKPath.empty()) { - FileSpec provided_sdk_path(search_path_opts.SDKPath, false); - if (provided_sdk_path.Exists()) { - // We don't check whether the SDK supports swift because we - // figure if someone is passing this to us on the command line - // (e.g., for the REPL), they probably know what they're - // doing. + FileSpec provided_sdk_path(search_path_opts.SDKPath); + if (FileSystem::Instance().Exists(provided_sdk_path)) { + // We don't check whether the SDK supports swift because we figure if + // someone is passing this to us on the command line (e.g., for the + // REPL), they probably know what they're doing. + set_sdk = true; } } else if (!m_platform_sdk_path.empty()) { - FileSpec platform_sdk(m_platform_sdk_path.c_str(), false); + FileSpec platform_sdk(m_platform_sdk_path.c_str()); - if (platform_sdk.Exists() && + if (FileSystem::Instance().Exists(platform_sdk) && SDKSupportsSwift(platform_sdk, SDKType::unknown)) { search_path_opts.SDKPath = m_platform_sdk_path.c_str(); set_sdk = true; @@ -2576,7 +2619,7 @@ swift::SearchPathOptions &SwiftASTContext::GetSearchPathOptions() { llvm::Triple triple(GetTriple()); StringRef resource_dir = GetResourceDir(triple); ConfigureResourceDirs(GetCompilerInvocation(), - FileSpec(resource_dir, false), triple); + FileSpec(resource_dir), triple); auto is_simulator = [&]() -> bool { return triple.getEnvironment() == llvm::Triple::Simulator || @@ -2693,8 +2736,8 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer { llvm::SmallString<256> text; { llvm::raw_svector_ostream out(text); - swift::DiagnosticEngine::formatDiagnosticText(out, - formatString, + swift::DiagnosticEngine::formatDiagnosticText(out, + formatString, formatArgs); } @@ -2791,6 +2834,8 @@ class StoringDiagnosticConsumer : public swift::DiagnosticConsumer { return eDiagnosticSeverityWarning; case swift::DiagnosticKind::Note: return eDiagnosticSeverityRemark; + case swift::DiagnosticKind::Remark: + break; } llvm_unreachable("Unhandled DiagnosticKind in switch."); @@ -3294,8 +3339,8 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES)); if (log) - log->Printf("((SwiftASTContext*)%p)->GetModule((FileSpec)'%s')", this, - module_spec.GetPath().c_str()); + log->Printf("((SwiftASTContext*)%p)->GetModule((FileSpec)'%s')", + static_cast(this), module_spec.GetPath().c_str()); if (module_basename) { SwiftModuleMap::const_iterator iter = @@ -3304,13 +3349,13 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec, if (iter != m_swift_module_cache.end()) return iter->second; - if (module_spec.Exists()) { + if (FileSystem::Instance().Exists(module_spec)) { swift::ASTContext *ast = GetASTContext(); if (!GetClangImporter()) { if (log) log->Printf("((SwiftASTContext*)%p)->GetModule((FileSpec)'%s') -- no " "ClangImporter so giving up", - this, module_spec.GetPath().c_str()); + static_cast(this), module_spec.GetPath().c_str()); error.SetErrorStringWithFormat("couldn't get a ClangImporter"); return nullptr; } @@ -3338,7 +3383,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec, if (log) log->Printf( "((SwiftASTContext*)%p)->GetModule((FileSpec)'%s') -- found %s", - this, module_spec.GetPath().c_str(), + static_cast(this), module_spec.GetPath().c_str(), module->getName().str().str().c_str()); m_swift_module_cache[module_basename.GetCString()] = module; @@ -3347,7 +3392,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec, if (log) log->Printf("((SwiftASTContext*)%p)->GetModule((FileSpec)'%s') -- " "couldn't get from AST context", - this, module_spec.GetPath().c_str()); + static_cast(this), module_spec.GetPath().c_str()); error.SetErrorStringWithFormat( "failed to get module '%s' from AST context", @@ -3357,7 +3402,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec, if (log) log->Printf("((SwiftASTContext*)%p)->GetModule((FileSpec)'%s') -- " "doesn't exist", - this, module_spec.GetPath().c_str()); + static_cast(this), module_spec.GetPath().c_str()); error.SetErrorStringWithFormat("module '%s' doesn't exist", module_spec.GetPath().c_str()); @@ -3366,7 +3411,7 @@ swift::ModuleDecl *SwiftASTContext::GetModule(const FileSpec &module_spec, if (log) log->Printf( "((SwiftASTContext*)%p)->GetModule((FileSpec)'%s') -- no basename", - this, module_spec.GetPath().c_str()); + static_cast(this), module_spec.GetPath().c_str()); error.SetErrorStringWithFormat("no module basename in '%s'", module_spec.GetPath().c_str()); @@ -3507,7 +3552,7 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module, framework_path.append(library_name); framework_path.append(".framework/"); framework_path.append(library_name); - FileSpec framework_spec(framework_path.c_str(), false); + FileSpec framework_spec(framework_path.c_str()); if (LoadOneImage(process, framework_spec, load_image_error)) { if (log) @@ -3522,7 +3567,7 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module, // And then in the various framework search paths. std::unordered_set seen_paths; std::vector uniqued_paths; - + for (const auto &framework_search_dir : swift_module->getASTContext().SearchPathOpts.FrameworkSearchPaths) { // The framework search dir as it comes from the AST context @@ -3539,19 +3584,19 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module, uniqued_paths.push_back(framework_path); } } - + uint32_t token = LLDB_INVALID_IMAGE_TOKEN; PlatformSP platform_sp = process.GetTarget().GetPlatform(); - + Status error; - FileSpec library_spec(library_name, false); + FileSpec library_spec(library_name); FileSpec found_path; - + if (platform_sp) token = platform_sp->LoadImageUsingPaths(&process, library_spec, uniqued_paths, error, &found_path); - + if (token != LLDB_INVALID_IMAGE_TOKEN) { if (log) log->Printf("Found framework at: %s.", framework_path.c_str()); @@ -3575,7 +3620,7 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module, system_path.append(library_name); system_path.append(".framework/"); system_path.append(library_name); - framework_spec.SetFile(system_path.c_str(), true, FileSpec::Style::native); + framework_spec.SetFile(system_path.c_str(), FileSpec::Style::native); if (LoadOneImage(process, framework_spec, load_image_error)) return; else @@ -3675,7 +3720,7 @@ bool SwiftASTContext::LoadLibraryUsingPaths( std::unordered_set seen_paths; Status load_image_error; std::vector uniqued_paths; - + for (const std::string &library_search_dir : search_paths) { // The library search dir as it comes from the AST context often // has duplicate entries, so lets unique the path list before we @@ -3686,12 +3731,12 @@ bool SwiftASTContext::LoadLibraryUsingPaths( uniqued_paths.push_back(library_search_dir); } - FileSpec library_spec(library_fullname, false); + FileSpec library_spec(library_fullname); FileSpec found_library; uint32_t token = LLDB_INVALID_IMAGE_TOKEN; Status error; if (platform_sp) - token = platform_sp->LoadImageUsingPaths(&process, library_spec, + token = platform_sp->LoadImageUsingPaths(&process, library_spec, uniqued_paths, error, &found_library); @@ -3711,7 +3756,7 @@ bool SwiftASTContext::LoadLibraryUsingPaths( library_path = "@rpath/"; library_path += library_fullname; - FileSpec link_lib_spec(library_path.c_str(), false); + FileSpec link_lib_spec(library_path.c_str()); if (LoadOneImage(process, link_lib_spec, load_image_error)) { if (log) @@ -3933,14 +3978,14 @@ SwiftASTContext::GetTypeFromMangledTypename(const char *mangled_typename, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES)); if (log) log->Printf("((SwiftASTContext*)%p)->GetTypeFromMangledTypename('%s')", - this, mangled_typename); + static_cast(this), mangled_typename); swift::ASTContext *ast_ctx = GetASTContext(); if (!ast_ctx) { if (log) log->Printf("((SwiftASTContext*)%p)->GetTypeFromMangledTypename('%s') " "-- null Swift AST Context", - this, mangled_typename); + static_cast(this), mangled_typename); error.SetErrorString("null Swift AST Context"); return {}; } @@ -3957,7 +4002,7 @@ SwiftASTContext::GetTypeFromMangledTypename(const char *mangled_typename, if (log) log->Printf("((SwiftASTContext*)%p)->GetTypeFromMangledTypename('%s') " "-- found in the positive cache", - this, mangled_typename); + static_cast(this), mangled_typename); assert(&found_type->getASTContext() == ast_ctx); return {found_type}; } @@ -3966,14 +4011,14 @@ SwiftASTContext::GetTypeFromMangledTypename(const char *mangled_typename, if (log) log->Printf("((SwiftASTContext*)%p)->GetTypeFromMangledTypename('%s') " "-- found in the negative cache", - this, mangled_typename); + static_cast(this), mangled_typename); return {}; } if (log) log->Printf("((SwiftASTContext*)%p)->GetTypeFromMangledTypename('%s') -- " "not cached, searching", - this, mangled_typename); + static_cast(this), mangled_typename); found_type = swift::Demangle::getTypeForMangling(*ast_ctx, mangled_typename) .getPointer(); @@ -3987,7 +4032,7 @@ SwiftASTContext::GetTypeFromMangledTypename(const char *mangled_typename, if (log) log->Printf("((SwiftASTContext*)%p)->GetTypeFromMangledTypename('%s') " "-- found %s", - this, mangled_typename, + static_cast(this), mangled_typename, result_type.GetTypeName().GetCString()); return result_type; } @@ -4142,6 +4187,10 @@ static SwiftASTContext::TypeOrDecl DeclToTypeOrDecl(swift::ASTContext *ast, case swift::DeclKind::Constructor: case swift::DeclKind::Destructor: break; + + case swift::DeclKind::Accessor: + case swift::DeclKind::PoundDiagnostic: + break; } } return CompilerType(); @@ -4623,7 +4672,7 @@ void SwiftASTContext::PrintDiagnostics(DiagnosticManager &diagnostic_manager, if (!m_ast_context_ap.get()) { SymbolFile *sym_file = GetSymbolFile(); if (sym_file) { - ConstString name + ConstString name = sym_file->GetObjectFile()->GetModule()->GetObjectName(); m_fatal_errors.SetErrorStringWithFormat( "Null context for %s.", name.AsCString()); @@ -4679,7 +4728,7 @@ void SwiftASTContext::DumpConfiguration(Log *log) { if (!log) return; - log->Printf("(SwiftASTContext*)%p:", this); + log->Printf("(SwiftASTContext*)%p:", static_cast(this)); if (!m_ast_context_ap) log->Printf(" (no AST context)"); @@ -5234,8 +5283,6 @@ SwiftASTContext::GetAllocationStrategy(const CompilerType &type) { return TypeAllocationStrategy::ePointer; case swift::irgen::FixedPacking::Dynamic: return TypeAllocationStrategy::eDynamic; - default: - break; } } @@ -5345,6 +5392,7 @@ SwiftASTContext::GetTypeInfo(void *type, case swift::TypeKind::GenericFunction: swift_flags |= eTypeIsGeneric; + LLVM_FALLTHROUGH; case swift::TypeKind::Function: swift_flags |= eTypeIsPointer | eTypeHasValue; break; @@ -5392,6 +5440,7 @@ SwiftASTContext::GetTypeInfo(void *type, break; case swift::TypeKind::BoundGenericEnum: swift_flags |= eTypeIsGeneric | eTypeIsBound; + LLVM_FALLTHROUGH; case swift::TypeKind::Enum: { SwiftEnumDescriptor *cached_enum_info = GetCachedEnumInfo(type); if (cached_enum_info) { @@ -5405,12 +5454,14 @@ SwiftASTContext::GetTypeInfo(void *type, case swift::TypeKind::BoundGenericStruct: swift_flags |= eTypeIsGeneric | eTypeIsBound; + LLVM_FALLTHROUGH; case swift::TypeKind::Struct: swift_flags |= eTypeHasChildren | eTypeIsStructUnion; break; case swift::TypeKind::BoundGenericClass: swift_flags |= eTypeIsGeneric | eTypeIsBound; + LLVM_FALLTHROUGH; case swift::TypeKind::Class: swift_flags |= eTypeHasChildren | eTypeIsClass | eTypeHasValue | eTypeInstanceIsPointer; @@ -5450,6 +5501,9 @@ SwiftASTContext::GetTypeInfo(void *type, case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return swift_flags; } @@ -5553,6 +5607,9 @@ lldb::TypeClass SwiftASTContext::GetTypeClass(void *type) { case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return lldb::eTypeClassOther; @@ -6028,6 +6085,9 @@ lldb::Encoding SwiftASTContext::GetEncoding(void *type, uint64_t &count) { case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } count = 0; return lldb::eEncodingInvalid; @@ -6112,6 +6172,9 @@ lldb::Format SwiftASTContext::GetFormat(void *type) { case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } // We don't know hot to display this type. return lldb::eFormatBytes; @@ -6222,6 +6285,9 @@ uint32_t SwiftASTContext::GetNumChildren(void *type, case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return num_children; @@ -6331,6 +6397,9 @@ uint32_t SwiftASTContext::GetNumFields(void *type) { case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return count; @@ -6462,7 +6531,7 @@ CompilerType SwiftASTContext::GetFieldAtIndex(void *type, size_t idx, return {}; swift::CanType swift_can_type(GetCanonicalSwiftType(type)); - + const swift::TypeKind type_kind = swift_can_type->getKind(); switch (type_kind) { @@ -6629,6 +6698,9 @@ CompilerType SwiftASTContext::GetFieldAtIndex(void *type, size_t idx, case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return CompilerType(); @@ -6732,6 +6804,9 @@ uint32_t SwiftASTContext::GetNumPointeeChildren(void *type) { case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return 0; @@ -6754,7 +6829,7 @@ static int64_t GetInstanceVariableOffset_Metadata( if (auto offset = runtime->GetMemberVariableOffset(type, valobj, ivar_name, &error)) { if (log) - log->Printf("[GetInstanceVariableOffset_Metadata] for %s: %llu", + log->Printf("[GetInstanceVariableOffset_Metadata] for %s: %lu", ivar_name.AsCString(), *offset); return *offset; } @@ -7077,6 +7152,9 @@ CompilerType SwiftASTContext::GetChildCompilerTypeAtIndex( case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return CompilerType(); } @@ -7290,6 +7368,9 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName( assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } } return 0; @@ -7522,7 +7603,7 @@ bool SwiftASTContext::DumpTypeValue( // else if it is a base class, it has no value. if (is_base_class) break; - // Fall through to case below. + LLVM_FALLTHROUGH; case swift::TypeKind::BuiltinInteger: case swift::TypeKind::BuiltinFloat: case swift::TypeKind::BuiltinRawPointer: @@ -7664,6 +7745,9 @@ bool SwiftASTContext::DumpTypeValue( case swift::TypeKind::ArraySlice: assert(false && "Not a canonical type"); break; + + case swift::TypeKind::SILToken: + break; } return 0; diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp index 3b91582a2265..4319b58c5e6b 100644 --- a/source/Symbol/Symbol.cpp +++ b/source/Symbol/Symbol.cpp @@ -1,9 +1,8 @@ //===-- Symbol.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -143,7 +142,7 @@ FileSpec Symbol::GetReExportedSymbolSharedLibrary() const { // back into a string that is the re-exported name. intptr_t str_ptr = m_addr_range.GetByteSize(); if (str_ptr != 0) - return FileSpec((const char *)str_ptr, false); + return FileSpec((const char *)str_ptr); } return FileSpec(); } diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp index 8716f50a384d..e26ad73a7605 100644 --- a/source/Symbol/SymbolContext.cpp +++ b/source/Symbol/SymbolContext.cpp @@ -1,9 +1,8 @@ //===-- SymbolContext.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -105,12 +104,12 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, if (function != nullptr) { SymbolContext inline_parent_sc; Address inline_parent_addr; - if (show_function_name == false) { + if (!show_function_name) { s->Printf("<"); dumped_something = true; } else { ConstString name; - if (show_function_arguments == false) + if (!show_function_arguments) name = function->GetNameNoArguments(); if (!name) name = function->GetName(); @@ -122,7 +121,7 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); - if (show_function_name == false) { + if (!show_function_name) { // Print +offset even if offset is 0 dumped_something = true; s->Printf("+%" PRIu64 ">", function_offset); @@ -171,7 +170,7 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, } } } else if (symbol != nullptr) { - if (show_function_name == false) { + if (!show_function_name) { s->Printf("<"); dumped_something = true; } else if (symbol->GetName()) { @@ -184,7 +183,7 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, if (addr.IsValid() && symbol->ValueIsAddress()) { const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRef().GetOffset(); - if (show_function_name == false) { + if (!show_function_name) { // Print +offset even if offset is 0 dumped_something = true; s->Printf("+%" PRIu64 ">", symbol_offset); @@ -393,12 +392,7 @@ bool lldb_private::operator==(const SymbolContext &lhs, bool lldb_private::operator!=(const SymbolContext &lhs, const SymbolContext &rhs) { - return lhs.function != rhs.function || lhs.symbol != rhs.symbol || - lhs.module_sp.get() != rhs.module_sp.get() || - lhs.comp_unit != rhs.comp_unit || - lhs.target_sp.get() != rhs.target_sp.get() || - LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0 || - lhs.variable != rhs.variable; + return !(lhs == rhs); } bool SymbolContext::GetAddressRange(uint32_t scope, uint32_t range_idx, @@ -801,14 +795,14 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line, const Symbol * SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) { error.Clear(); - + if (!target_sp) { return nullptr; } - + Target &target = *target_sp; Module *module = module_sp.get(); - + auto ProcessMatches = [this, &name, &target, module] (SymbolContextList &sc_list, Status &error) -> const Symbol* { llvm::SmallVector external_symbols; @@ -820,7 +814,7 @@ SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) if (sym_ctx.symbol) { const Symbol *symbol = sym_ctx.symbol; const Address sym_address = symbol->GetAddress(); - + if (sym_address.IsValid()) { switch (symbol->GetType()) { case eSymbolTypeData: @@ -865,12 +859,12 @@ SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) if (name == symbol->GetReExportedSymbolName() && module == reexport_module_sp.get()) return nullptr; - + return FindBestGlobalDataSymbol( symbol->GetReExportedSymbolName(), error); } } break; - + case eSymbolTypeCode: // We already lookup functions elsewhere case eSymbolTypeVariable: case eSymbolTypeLocal: @@ -894,11 +888,17 @@ SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) case eSymbolTypeUndefined: case eSymbolTypeResolver: break; + + case eSymbolTypeASTFile: + break; + + case eSymbolTypeIVarOffset: + break; } } } } - + if (external_symbols.size() > 1) { StreamString ss; ss.Printf("Multiple external symbols found for '%s'\n", name.AsCString()); @@ -925,32 +925,32 @@ SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) return nullptr; } }; - + if (module) { SymbolContextList sc_list; module->FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list); const Symbol *const module_symbol = ProcessMatches(sc_list, error); - + if (!error.Success()) { return nullptr; } else if (module_symbol) { return module_symbol; } } - + { SymbolContextList sc_list; target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list); const Symbol *const target_symbol = ProcessMatches(sc_list, error); - + if (!error.Success()) { return nullptr; } else if (target_symbol) { return target_symbol; } } - + return nullptr; // no error; we just didn't find anything } @@ -999,7 +999,7 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string, break; case eModuleSpecified: { // See if we can find the Module, if so stick it in the SymbolContext. - FileSpec module_file_spec(spec_string, false); + FileSpec module_file_spec(spec_string); ModuleSpec module_spec(module_file_spec); lldb::ModuleSP module_sp( m_target_sp->GetImages().FindFirstModule(module_spec)); @@ -1013,7 +1013,7 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string, // CompUnits can't necessarily be resolved here, since an inlined function // might show up in a number of CompUnits. Instead we just convert to a // FileSpec and store it away. - m_file_spec_ap.reset(new FileSpec(spec_string, false)); + m_file_spec_ap.reset(new FileSpec(spec_string)); m_type |= eFileSpecified; break; case eLineStartSpecified: @@ -1068,7 +1068,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) { if (m_module_sp.get() != sc.module_sp.get()) return false; } else { - FileSpec module_file_spec(m_module_spec, false); + FileSpec module_file_spec(m_module_spec); if (!FileSpec::Equal(module_file_spec, sc.module_sp->GetFileSpec(), false)) return false; @@ -1259,7 +1259,7 @@ bool SymbolContextList::AppendIfUnique(const SymbolContext &sc, } if (merge_symbol_into_function && sc.symbol != nullptr && sc.comp_unit == nullptr && sc.function == nullptr && - sc.block == nullptr && sc.line_entry.IsValid() == false) { + sc.block == nullptr && !sc.line_entry.IsValid()) { if (sc.symbol->ValueIsAddress()) { for (pos = m_symbol_contexts.begin(); pos != end; ++pos) { // Don't merge symbols into inlined function symbol contexts @@ -1285,41 +1285,6 @@ bool SymbolContextList::AppendIfUnique(const SymbolContext &sc, return true; } -bool SymbolContextList::MergeSymbolContextIntoFunctionContext( - const SymbolContext &symbol_sc, uint32_t start_idx, uint32_t stop_idx) { - if (symbol_sc.symbol != nullptr && symbol_sc.comp_unit == nullptr && - symbol_sc.function == nullptr && symbol_sc.block == nullptr && - symbol_sc.line_entry.IsValid() == false) { - if (symbol_sc.symbol->ValueIsAddress()) { - const size_t end = std::min(m_symbol_contexts.size(), stop_idx); - for (size_t i = start_idx; i < end; ++i) { - const SymbolContext &function_sc = m_symbol_contexts[i]; - // Don't merge symbols into inlined function symbol contexts - if (function_sc.block && function_sc.block->GetContainingInlinedBlock()) - continue; - - if (function_sc.function) { - if (function_sc.function->GetAddressRange().GetBaseAddress() == - symbol_sc.symbol->GetAddressRef()) { - // Do we already have a function with this symbol? - if (function_sc.symbol == symbol_sc.symbol) - return true; // Already have a symbol context with this symbol, - // return true - - if (function_sc.symbol == nullptr) { - // We successfully merged this symbol into an existing symbol - // context - m_symbol_contexts[i].symbol = symbol_sc.symbol; - return true; - } - } - } - } - } - } - return false; -} - void SymbolContextList::Clear() { m_symbol_contexts.clear(); } void SymbolContextList::Dump(Stream *s, Target *target) const { @@ -1346,14 +1311,6 @@ bool SymbolContextList::GetContextAtIndex(size_t idx, SymbolContext &sc) const { return false; } -bool SymbolContextList::GetLastContext(SymbolContext &sc) const { - if (!m_symbol_contexts.empty()) { - sc = m_symbol_contexts.back(); - return true; - } - return false; -} - bool SymbolContextList::RemoveContextAtIndex(size_t idx) { if (idx < m_symbol_contexts.size()) { m_symbol_contexts.erase(m_symbol_contexts.begin() + idx); diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp index 1bc6848a362a..80c63bf3d97d 100644 --- a/source/Symbol/SymbolFile.cpp +++ b/source/Symbol/SymbolFile.cpp @@ -1,9 +1,8 @@ //===-- SymbolFile.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -146,7 +145,7 @@ SymbolFile::GetASTData(lldb::LanguageType language) { uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { return 0; } @@ -166,7 +165,7 @@ uint32_t SymbolFile::FindGlobalVariables(const RegularExpression ®ex, uint32_t SymbolFile::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, + lldb::FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { if (!append) @@ -189,9 +188,8 @@ void SymbolFile::GetMangledNamesForFunction( } uint32_t SymbolFile::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { if (!append) diff --git a/source/Symbol/SymbolVendor.cpp b/source/Symbol/SymbolVendor.cpp index 8b9862736ea4..4a3b26b75327 100644 --- a/source/Symbol/SymbolVendor.cpp +++ b/source/Symbol/SymbolVendor.cpp @@ -1,18 +1,13 @@ //===-- SymbolVendor.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Symbol/SymbolVendor.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" @@ -49,12 +44,19 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp, } // The default implementation just tries to create debug information using // the file representation for the module. + ObjectFileSP sym_objfile_sp; + FileSpec sym_spec = module_sp->GetSymbolFileFileSpec(); + if (sym_spec && sym_spec != module_sp->GetObjectFile()->GetFileSpec()) { + DataBufferSP data_sp; + offset_t data_offset = 0; + sym_objfile_sp = ObjectFile::FindPlugin( + module_sp, &sym_spec, 0, FileSystem::Instance().GetByteSize(sym_spec), + data_sp, data_offset); + } + if (!sym_objfile_sp) + sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this(); instance_ap.reset(new SymbolVendor(module_sp)); - if (instance_ap.get()) { - ObjectFile *objfile = module_sp->GetObjectFile(); - if (objfile) - instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this()); - } + instance_ap->AddSymbolFileRepresentation(sym_objfile_sp); return instance_ap.release(); } @@ -63,7 +65,7 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp, //---------------------------------------------------------------------- SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) : ModuleChild(module_sp), m_type_list(), m_compile_units(), - m_sym_file_ap() {} + m_sym_file_ap(), m_symtab() {} //---------------------------------------------------------------------- // Destructor @@ -124,63 +126,62 @@ size_t SymbolVendor::GetNumCompileUnits() { return m_compile_units.size(); } -lldb::LanguageType -SymbolVendor::ParseCompileUnitLanguage(const SymbolContext &sc) { +lldb::LanguageType SymbolVendor::ParseLanguage(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitLanguage(sc); + return m_sym_file_ap->ParseLanguage(comp_unit); } return eLanguageTypeUnknown; } -size_t SymbolVendor::ParseCompileUnitFunctions(const SymbolContext &sc) { +size_t SymbolVendor::ParseFunctions(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitFunctions(sc); + return m_sym_file_ap->ParseFunctions(comp_unit); } return 0; } -bool SymbolVendor::ParseCompileUnitLineTable(const SymbolContext &sc) { +bool SymbolVendor::ParseLineTable(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitLineTable(sc); + return m_sym_file_ap->ParseLineTable(comp_unit); } return false; } -bool SymbolVendor::ParseCompileUnitDebugMacros(const SymbolContext &sc) { +bool SymbolVendor::ParseDebugMacros(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitDebugMacros(sc); + return m_sym_file_ap->ParseDebugMacros(comp_unit); } return false; } -bool SymbolVendor::ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files) { +bool SymbolVendor::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files); + return m_sym_file_ap->ParseSupportFiles(comp_unit, support_files); } return false; } -bool SymbolVendor::ParseCompileUnitIsOptimized(const SymbolContext &sc) { +bool SymbolVendor::ParseIsOptimized(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseCompileUnitIsOptimized(sc); + return m_sym_file_ap->ParseIsOptimized(comp_unit); } return false; } @@ -196,22 +197,22 @@ bool SymbolVendor::ParseImportedModules( return false; } -size_t SymbolVendor::ParseFunctionBlocks(const SymbolContext &sc) { +size_t SymbolVendor::ParseBlocksRecursive(Function &func) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseFunctionBlocks(sc); + return m_sym_file_ap->ParseBlocksRecursive(func); } return 0; } -size_t SymbolVendor::ParseTypes(const SymbolContext &sc) { +size_t SymbolVendor::ParseTypes(CompileUnit &comp_unit) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->ParseTypes(sc); + return m_sym_file_ap->ParseTypes(comp_unit); } return 0; } @@ -237,7 +238,7 @@ Type *SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) { } uint32_t SymbolVendor::ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + SymbolContextItem resolve_scope, SymbolContext &sc) { ModuleSP module_sp(GetModule()); if (module_sp) { @@ -250,7 +251,7 @@ uint32_t SymbolVendor::ResolveSymbolContext(const Address &so_addr, uint32_t SymbolVendor::ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + SymbolContextItem resolve_scope, SymbolContextList &sc_list) { ModuleSP module_sp(GetModule()); if (module_sp) { @@ -290,7 +291,7 @@ size_t SymbolVendor::FindGlobalVariables(const RegularExpression ®ex, size_t SymbolVendor::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, + FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { ModuleSP module_sp(GetModule()); @@ -317,15 +318,15 @@ size_t SymbolVendor::FindFunctions(const RegularExpression ®ex, } size_t SymbolVendor::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeMap &types) { ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, + return m_sym_file_ap->FindTypes(name, parent_decl_ctx, append, max_matches, searched_symbol_files, types); } @@ -347,7 +348,7 @@ size_t SymbolVendor::FindTypes(const std::vector &context, return 0; } -size_t SymbolVendor::GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask, +size_t SymbolVendor::GetTypes(SymbolContextScope *sc_scope, TypeClass type_mask, lldb_private::TypeList &type_list) { ModuleSP module_sp(GetModule()); if (module_sp) { @@ -359,15 +360,14 @@ size_t SymbolVendor::GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask, } CompilerDeclContext -SymbolVendor::FindNamespace(const SymbolContext &sc, const ConstString &name, +SymbolVendor::FindNamespace(const ConstString &name, const CompilerDeclContext *parent_decl_ctx) { CompilerDeclContext namespace_decl_ctx; ModuleSP module_sp(GetModule()); if (module_sp) { std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) - namespace_decl_ctx = - m_sym_file_ap->FindNamespace(sc, name, parent_decl_ctx); + namespace_decl_ctx = m_sym_file_ap->FindNamespace(name, parent_decl_ctx); } return namespace_decl_ctx; } @@ -383,6 +383,7 @@ void SymbolVendor::Dump(Stream *s) { s->Indent(); s->PutCString("SymbolVendor"); if (m_sym_file_ap.get()) { + *s << " " << m_sym_file_ap->GetPluginName(); ObjectFile *objfile = m_sym_file_ap->GetObjectFile(); if (objfile) { const FileSpec &objfile_file_spec = objfile->GetFileSpec(); @@ -407,6 +408,9 @@ void SymbolVendor::Dump(Stream *s) { (*cu_pos)->Dump(s, show_context); } + if (Symtab *symtab = GetSymtab()) + symtab->Dump(s, nullptr, eSortOrderNone); + s->IndentLess(); } } @@ -440,14 +444,23 @@ FileSpec SymbolVendor::GetMainFileSpec() const { Symtab *SymbolVendor::GetSymtab() { ModuleSP module_sp(GetModule()); - if (module_sp) { - ObjectFile *objfile = module_sp->GetObjectFile(); - if (objfile) { - // Get symbol table from unified section list. - return objfile->GetSymtab(); - } - } - return nullptr; + if (!module_sp) + return nullptr; + + std::lock_guard guard(module_sp->GetMutex()); + + if (m_symtab) + return m_symtab; + + ObjectFile *objfile = module_sp->GetObjectFile(); + if (!objfile) + return nullptr; + + m_symtab = objfile->GetSymtab(); + if (m_symtab && m_sym_file_ap) + m_sym_file_ap->AddSymbols(*m_symtab); + + return m_symtab; } void SymbolVendor::ClearSymtab() { diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp index d8a08a1a74b6..8a69d9cf2934 100644 --- a/source/Symbol/Symtab.cpp +++ b/source/Symbol/Symtab.cpp @@ -1,9 +1,8 @@ //===-- Symtab.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -24,10 +23,10 @@ #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" -#include "lldb/Target/SwiftLanguageRuntime.h" - #include "llvm/ADT/StringRef.h" +#include "lldb/Target/SwiftLanguageRuntime.h" + using namespace lldb; using namespace lldb_private; @@ -143,6 +142,8 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, } break; } + } else { + s->PutCString("\n"); } } @@ -253,6 +254,7 @@ static bool lldb_skip_name(llvm::StringRef mangled, case Mangled::eManglingSchemeNone: return true; } + llvm_unreachable("unknown scheme!"); } void Symtab::InitNameIndexes() { @@ -325,16 +327,9 @@ void Symtab::InitNameIndexes() { const SymbolType type = symbol->GetType(); if (type == eSymbolTypeCode || type == eSymbolTypeResolver) { - // Other schemes are not relevant in the Swift use case. - bool is_relevant_itanium = - !lldb_skip_name(entry.cstring.GetStringRef(), - Mangled::eManglingSchemeItanium); - - if (is_relevant_itanium) { - if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name)) { - RegisterMangledNameEntry(entry, class_contexts, backlog, rmc); - } - } else if (SwiftLanguageRuntime::IsSwiftMangledName(name.str().c_str())) { + if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name)) + RegisterMangledNameEntry(entry, class_contexts, backlog, rmc); + else if (SwiftLanguageRuntime::IsSwiftMangledName(name.str().c_str())) { lldb_private::ConstString basename; bool is_method = false; ConstString mangled_name = mangled.GetMangledName(); @@ -638,10 +633,9 @@ void Symtab::SortSymbolIndexesByValue(std::vector &indexes, return; // Sort the indexes in place using std::stable_sort. - // NOTE: The use of std::stable_sort instead of std::sort here is strictly for - // performance, - // not correctness. The indexes vector tends to be "close" to sorted, which - // the stable sort handles better. + // NOTE: The use of std::stable_sort instead of llvm::sort here is strictly + // for performance, not correctness. The indexes vector tends to be "close" + // to sorted, which the stable sort handles better. std::vector addr_cache(m_symbols.size(), LLDB_INVALID_ADDRESS); @@ -768,7 +762,7 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType( for (uint32_t i = 0; i < sym_end; i++) { if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type) { - if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility) == false) + if (!CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility)) continue; const char *name = m_symbols[i].GetName().AsCString(); @@ -1004,32 +998,8 @@ void Symtab::InitAddressIndexes() { void Symtab::CalculateSymbolSizes() { std::lock_guard guard(m_mutex); - - if (!m_symbols.empty()) { - if (!m_file_addr_to_index_computed) - InitAddressIndexes(); - - const size_t num_entries = m_file_addr_to_index.GetSize(); - - for (size_t i = 0; i < num_entries; ++i) { - // The entries in the m_file_addr_to_index have calculated the sizes - // already so we will use this size if we need to. - const FileRangeToIndexMap::Entry &entry = - m_file_addr_to_index.GetEntryRef(i); - - Symbol &symbol = m_symbols[entry.data]; - - // If the symbol size is already valid, no need to do anything - if (symbol.GetByteSizeIsValid()) - continue; - - const addr_t range_size = entry.GetByteSize(); - if (range_size > 0) { - symbol.SetByteSize(range_size); - symbol.SetSizeIsSynthesized(true); - } - } - } + // Size computation happens inside InitAddressIndexes. + InitAddressIndexes(); } Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) { @@ -1184,7 +1154,7 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name, } if (!symbol_indexes.empty()) { - std::sort(symbol_indexes.begin(), symbol_indexes.end()); + llvm::sort(symbol_indexes.begin(), symbol_indexes.end()); symbol_indexes.erase( std::unique(symbol_indexes.begin(), symbol_indexes.end()), symbol_indexes.end()); diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp index 0b1487dc8e0c..43d039bfcaa8 100644 --- a/source/Symbol/Type.cpp +++ b/source/Symbol/Type.cpp @@ -1,22 +1,17 @@ //===-- Type.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" #include "lldb/Symbol/CompilerType.h" @@ -112,7 +107,7 @@ Type *SymbolFileType::GetType() { } Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file, - const ConstString &name, uint64_t byte_size, + const ConstString &name, llvm::Optional byte_size, SymbolContextScope *context, user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_type, @@ -120,7 +115,14 @@ Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file, : std::enable_shared_from_this(), UserID(uid), m_name(name), m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr), m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type), - m_byte_size(byte_size), m_decl(decl), m_compiler_type(compiler_type) { + m_decl(decl), m_compiler_type(compiler_type) { + if (byte_size) { + m_byte_size = *byte_size; + m_byte_size_has_value = true; + } else { + m_byte_size = 0; + m_byte_size_has_value = false; + } m_flags.compiler_type_resolve_state = (compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved); m_flags.is_complete_objc_class = false; @@ -130,7 +132,8 @@ Type::Type() : std::enable_shared_from_this(), UserID(0), m_name(""), m_symbol_file(nullptr), m_context(nullptr), m_encoding_type(nullptr), m_encoding_uid(LLDB_INVALID_UID), m_encoding_uid_type(eEncodingInvalid), - m_byte_size(0), m_decl(), m_compiler_type() { + m_byte_size(0), m_byte_size_has_value(false), m_decl(), + m_compiler_type() { m_flags.compiler_type_resolve_state = eResolveStateUnresolved; m_flags.is_complete_objc_class = false; } @@ -140,15 +143,10 @@ Type::Type(const Type &rhs) m_symbol_file(rhs.m_symbol_file), m_context(rhs.m_context), m_encoding_type(rhs.m_encoding_type), m_encoding_uid(rhs.m_encoding_uid), m_encoding_uid_type(rhs.m_encoding_uid_type), - m_byte_size(rhs.m_byte_size), m_decl(rhs.m_decl), + m_byte_size(rhs.m_byte_size), + m_byte_size_has_value(rhs.m_byte_size_has_value), m_decl(rhs.m_decl), m_compiler_type(rhs.m_compiler_type), m_flags(rhs.m_flags) {} -const Type &Type::operator=(const Type &rhs) { - if (this != &rhs) { - } - return *this; -} - void Type::GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name) { *s << "id = " << (const UserID &)*this; @@ -218,7 +216,7 @@ void Type::Dump(Stream *s, bool show_context) { if (m_name) *s << ", name = \"" << m_name << "\""; - if (m_byte_size != 0) + if (m_byte_size_has_value) s->Printf(", size = %" PRIu64, m_byte_size); if (show_context && m_context != nullptr) { @@ -297,7 +295,7 @@ void Type::DumpValue(ExecutionContext *exe_ctx, Stream *s, GetForwardCompilerType().DumpValue( exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data, - data_byte_offset, GetByteSize(), + data_byte_offset, GetByteSize().getValueOr(0), 0, // Bitfield bit size 0, // Bitfield bit offset show_types, show_summary, verbose, 0); @@ -310,36 +308,46 @@ Type *Type::GetEncodingType() { return m_encoding_type; } -uint64_t Type::GetByteSize() { - if (m_byte_size == 0) { - switch (m_encoding_uid_type) { - case eEncodingInvalid: - case eEncodingIsSyntheticUID: - break; - case eEncodingIsUID: - case eEncodingIsConstUID: - case eEncodingIsRestrictUID: - case eEncodingIsVolatileUID: - case eEncodingIsTypedefUID: { - Type *encoding_type = GetEncodingType(); - if (encoding_type) - m_byte_size = encoding_type->GetByteSize(); - if (m_byte_size == 0) - if (auto size = GetLayoutCompilerType().GetByteSize(nullptr)) - m_byte_size = *size; - } break; +llvm::Optional Type::GetByteSize() { + if (m_byte_size_has_value) + return m_byte_size; + + switch (m_encoding_uid_type) { + case eEncodingInvalid: + case eEncodingIsSyntheticUID: + break; + case eEncodingIsUID: + case eEncodingIsConstUID: + case eEncodingIsRestrictUID: + case eEncodingIsVolatileUID: + case eEncodingIsTypedefUID: { + Type *encoding_type = GetEncodingType(); + if (encoding_type) + if (llvm::Optional size = encoding_type->GetByteSize()) { + m_byte_size = *size; + m_byte_size_has_value = true; + return m_byte_size; + } + + if (llvm::Optional size = + GetLayoutCompilerType().GetByteSize(nullptr)) { + m_byte_size = *size; + m_byte_size_has_value = true; + return m_byte_size; + } + } break; // If we are a pointer or reference, then this is just a pointer size; case eEncodingIsPointerUID: case eEncodingIsLValueReferenceUID: case eEncodingIsRValueReferenceUID: { - ArchSpec arch; - if (m_symbol_file->GetObjectFile()->GetArchitecture(arch)) + if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) { m_byte_size = arch.GetAddressByteSize(); + m_byte_size_has_value = true; + } } break; - } } - return m_byte_size; + return {}; } uint32_t Type::GetNumChildren(bool omit_empty_base_classes) { @@ -393,7 +401,7 @@ bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr, return false; } - const uint64_t byte_size = GetByteSize(); + const uint64_t byte_size = GetByteSize().getValueOr(0); if (data.GetByteSize() < byte_size) { lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0')); data.SetData(data_sp); @@ -715,11 +723,7 @@ bool TypeAndOrName::operator==(const TypeAndOrName &other) const { } bool TypeAndOrName::operator!=(const TypeAndOrName &other) const { - if (m_type_pair != other.m_type_pair) - return true; - if (m_type_name != other.m_type_name) - return true; - return false; + return !(*this == other); } ConstString TypeAndOrName::GetName() const { @@ -751,10 +755,7 @@ void TypeAndOrName::SetCompilerType(CompilerType compiler_type) { } bool TypeAndOrName::IsEmpty() const { - if ((bool)m_type_name || (bool)m_type_pair) - return false; - else - return true; + return !((bool)m_type_name || (bool)m_type_pair); } void TypeAndOrName::Clear() { @@ -879,8 +880,7 @@ bool TypeImpl::operator==(const TypeImpl &rhs) const { } bool TypeImpl::operator!=(const TypeImpl &rhs) const { - return m_static_type != rhs.m_static_type || - m_dynamic_type != rhs.m_dynamic_type; + return !(*this == rhs); } bool TypeImpl::IsValid() const { diff --git a/source/Symbol/TypeList.cpp b/source/Symbol/TypeList.cpp index 4a0a06f3e8e3..7cc604b13ce1 100644 --- a/source/Symbol/TypeList.cpp +++ b/source/Symbol/TypeList.cpp @@ -1,21 +1,16 @@ //===-- TypeList.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h" -// Project includes #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/Type.h" @@ -184,8 +179,7 @@ void TypeList::RemoveMismatchedTypes(const std::string &type_scope, } else { // The type we are currently looking at doesn't exists in a namespace // or class, so it only matches if there is no type scope... - keep_match = - type_scope.empty() && type_basename.compare(match_type_name) == 0; + keep_match = type_scope.empty() && type_basename == match_type_name; } } diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp index 2838039ad603..641bc95a4517 100644 --- a/source/Symbol/TypeMap.cpp +++ b/source/Symbol/TypeMap.cpp @@ -1,17 +1,13 @@ //===-- TypeMap.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" @@ -27,7 +23,6 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Support/raw_ostream.h" -// Project includes #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/Type.h" @@ -227,8 +222,7 @@ void TypeMap::RemoveMismatchedTypes(const std::string &type_scope, } else { // The type we are currently looking at doesn't exists in a namespace // or class, so it only matches if there is no type scope... - keep_match = - type_scope.empty() && type_basename.compare(match_type_name) == 0; + keep_match = type_scope.empty() && type_basename == match_type_name; } } diff --git a/source/Symbol/TypeSystem.cpp b/source/Symbol/TypeSystem.cpp index 2c3c100f08d3..44ef35d91463 100644 --- a/source/Symbol/TypeSystem.cpp +++ b/source/Symbol/TypeSystem.cpp @@ -1,9 +1,8 @@ //===-- TypeSystem.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -109,6 +108,10 @@ CompilerType TypeSystem::GetTypeForFormatters(void *type) { return CompilerType(this, type); } +size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) { + return 0; +} + TemplateArgumentKind TypeSystem::GetTemplateArgumentKind(opaque_compiler_type_t type, size_t idx) { return eTemplateArgumentKindNull; @@ -225,7 +228,7 @@ void TypeSystemMap::ForEach(std::function const &callback) { TypeSystem *type_system = pair.second.get(); if (type_system && !visited.count(type_system)) { visited.insert(type_system); - if (callback(type_system) == false) + if (!callback(type_system)) break; } } diff --git a/source/Symbol/UnwindPlan.cpp b/source/Symbol/UnwindPlan.cpp index 23ca1324ab06..0e084cda98c9 100644 --- a/source/Symbol/UnwindPlan.cpp +++ b/source/Symbol/UnwindPlan.cpp @@ -1,9 +1,8 @@ //===-- UnwindPlan.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -29,6 +28,8 @@ operator==(const UnwindPlan::Row::RegisterLocation &rhs) const { case atCFAPlusOffset: case isCFAPlusOffset: + case atAFAPlusOffset: + case isAFAPlusOffset: return m_location.offset == rhs.m_location.offset; case inOtherRegister: @@ -95,6 +96,16 @@ void UnwindPlan::Row::RegisterLocation::Dump(Stream &s, s.PutChar(']'); } break; + case atAFAPlusOffset: + case isAFAPlusOffset: { + s.PutChar('='); + if (m_type == atAFAPlusOffset) + s.PutChar('['); + s.Printf("AFA%+d", m_location.offset); + if (m_type == atAFAPlusOffset) + s.PutChar(']'); + } break; + case inOtherRegister: { const RegisterInfo *other_reg_info = nullptr; if (unwind_plan) @@ -125,8 +136,8 @@ static void DumpRegisterName(Stream &s, const UnwindPlan *unwind_plan, s.Printf("reg(%u)", reg_num); } -bool UnwindPlan::Row::CFAValue:: -operator==(const UnwindPlan::Row::CFAValue &rhs) const { +bool UnwindPlan::Row::FAValue:: +operator==(const UnwindPlan::Row::FAValue &rhs) const { if (m_type == rhs.m_type) { switch (m_type) { case unspecified: @@ -148,7 +159,7 @@ operator==(const UnwindPlan::Row::CFAValue &rhs) const { return false; } -void UnwindPlan::Row::CFAValue::Dump(Stream &s, const UnwindPlan *unwind_plan, +void UnwindPlan::Row::FAValue::Dump(Stream &s, const UnwindPlan *unwind_plan, Thread *thread) const { switch (m_type) { case isRegisterPlusOffset: @@ -171,6 +182,7 @@ void UnwindPlan::Row::CFAValue::Dump(Stream &s, const UnwindPlan *unwind_plan, void UnwindPlan::Row::Clear() { m_cfa_value.SetUnspecified(); + m_afa_value.SetUnspecified(); m_offset = 0; m_register_locations.clear(); } @@ -183,6 +195,12 @@ void UnwindPlan::Row::Dump(Stream &s, const UnwindPlan *unwind_plan, s.Printf("%4" PRId64 ": CFA=", GetOffset()); m_cfa_value.Dump(s, unwind_plan, thread); + + if (!m_afa_value.IsUnspecified()) { + s.Printf(" AFA="); + m_afa_value.Dump(s, unwind_plan, thread); + } + s.Printf(" => "); for (collection::const_iterator idx = m_register_locations.begin(); idx != m_register_locations.end(); ++idx) { @@ -194,7 +212,8 @@ void UnwindPlan::Row::Dump(Stream &s, const UnwindPlan *unwind_plan, s.EOL(); } -UnwindPlan::Row::Row() : m_offset(0), m_cfa_value(), m_register_locations() {} +UnwindPlan::Row::Row() + : m_offset(0), m_cfa_value(), m_afa_value(), m_register_locations() {} bool UnwindPlan::Row::GetRegisterInfo( uint32_t reg_num, @@ -296,8 +315,10 @@ bool UnwindPlan::Row::SetRegisterLocationToSame(uint32_t reg_num, } bool UnwindPlan::Row::operator==(const UnwindPlan::Row &rhs) const { - return m_offset == rhs.m_offset && m_cfa_value == rhs.m_cfa_value && - m_register_locations == rhs.m_register_locations; + return m_offset == rhs.m_offset && + m_cfa_value == rhs.m_cfa_value && + m_afa_value == rhs.m_afa_value && + m_register_locations == rhs.m_register_locations; } void UnwindPlan::AppendRow(const UnwindPlan::RowSP &row_sp) { @@ -399,7 +420,7 @@ bool UnwindPlan::PlanValidAtAddress(Address addr) { // UnwindPlan. if (GetRowAtIndex(0).get() == nullptr || GetRowAtIndex(0)->GetCFAValue().GetValueType() == - Row::CFAValue::unspecified) { + Row::FAValue::unspecified) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); if (log) { StreamString s; diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp index 7f98eaca2521..cacbdb1735b1 100644 --- a/source/Symbol/UnwindTable.cpp +++ b/source/Symbol/UnwindTable.cpp @@ -1,9 +1,8 @@ //===-- UnwindTable.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -180,8 +179,8 @@ ArmUnwindInfo *UnwindTable::GetArmUnwindInfo() { return m_arm_unwind_up.get(); } -bool UnwindTable::GetArchitecture(lldb_private::ArchSpec &arch) { - return m_object_file.GetArchitecture(arch); +ArchSpec UnwindTable::GetArchitecture() { + return m_object_file.GetArchitecture(); } bool UnwindTable::GetAllowAssemblyEmulationUnwindPlans() { diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp index 6924c4dfb9a9..883fd9c77b00 100644 --- a/source/Symbol/Variable.cpp +++ b/source/Symbol/Variable.cpp @@ -1,9 +1,8 @@ //===-- Variable.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -50,7 +49,8 @@ Variable::Variable( m_symfile_type_sp(symfile_type_sp), m_scope(scope), m_owner_scope(context), m_scope_range(scope_range), m_declaration(decl_ptr), m_location(location), m_external(external), - m_artificial(artificial), m_static_member(static_member) {} + m_artificial(artificial), m_loc_is_const_data(false), + m_static_member(static_member) {} //---------------------------------------------------------------------- // Destructor diff --git a/source/Symbol/VariableList.cpp b/source/Symbol/VariableList.cpp index e7a482e158b1..5dce9a0b8f51 100644 --- a/source/Symbol/VariableList.cpp +++ b/source/Symbol/VariableList.cpp @@ -1,9 +1,8 @@ //===-- VariableList.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Symbol/VerifyDecl.cpp b/source/Symbol/VerifyDecl.cpp index 96ed47a527a8..88c7494e557b 100644 --- a/source/Symbol/VerifyDecl.cpp +++ b/source/Symbol/VerifyDecl.cpp @@ -1,9 +1,8 @@ //===-- VerifyDecl.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp index cb77c0f32f38..3d56fddf8da5 100644 --- a/source/Target/ABI.cpp +++ b/source/Target/ABI.cpp @@ -1,16 +1,11 @@ //===-- ABI.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/PluginManager.h" diff --git a/source/Target/CMakeLists.txt b/source/Target/CMakeLists.txt index bac68a33c04d..8da30c17911d 100644 --- a/source/Target/CMakeLists.txt +++ b/source/Target/CMakeLists.txt @@ -85,3 +85,6 @@ add_lldb_library(lldbTarget LINK_COMPONENTS Support ) +if(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + target_compile_options(lldbTarget PRIVATE -Wno-dollar-in-identifier-extension) +endif() diff --git a/source/Target/CPPLanguageRuntime.cpp b/source/Target/CPPLanguageRuntime.cpp index 9c6a8a3fbd6b..f3d3ad5a5045 100644 --- a/source/Target/CPPLanguageRuntime.cpp +++ b/source/Target/CPPLanguageRuntime.cpp @@ -1,10 +1,9 @@ //===-- CPPLanguageRuntime.cpp //-------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,11 +13,9 @@ #include "llvm/ADT/StringRef.h" -#include "lldb/API/SBValue.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/VariableList.h" -#include "lldb/API/SBFrame.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Symbol/ClangASTContext.h" @@ -95,6 +92,15 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo( // we will obtain the name from this pointer. ValueObjectSP member__f_( valobj_sp->GetChildMemberWithName(ConstString("__f_"), true)); + + if (member__f_) { + ValueObjectSP sub_member__f_( + member__f_->GetChildMemberWithName(ConstString("__f_"), true)); + + if (sub_member__f_) + member__f_ = sub_member__f_; + } + lldb::addr_t member__f_pointer_value = member__f_->GetValueAsUnsigned(0); optional_info.member__f_pointer_value = member__f_pointer_value; diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp index 73c64916cf1f..0aa4a54ee24a 100644 --- a/source/Target/ExecutionContext.cpp +++ b/source/Target/ExecutionContext.cpp @@ -1,23 +1,18 @@ //===-- ExecutionContext.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ExecutionContext.h" -#include "lldb/Core/State.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/State.h" using namespace lldb_private; diff --git a/source/Target/FileAction.cpp b/source/Target/FileAction.cpp index c9cc325b5a53..c8c0af0ac382 100644 --- a/source/Target/FileAction.cpp +++ b/source/Target/FileAction.cpp @@ -1,9 +1,8 @@ //===-- FileAction.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/InstrumentationRuntime.cpp b/source/Target/InstrumentationRuntime.cpp index ac8b5dfe4599..4c2eb064fbb0 100644 --- a/source/Target/InstrumentationRuntime.cpp +++ b/source/Target/InstrumentationRuntime.cpp @@ -1,16 +1,11 @@ //===-- InstrumentationRuntime.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===---------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" diff --git a/source/Target/InstrumentationRuntimeStopInfo.cpp b/source/Target/InstrumentationRuntimeStopInfo.cpp index dbbd4f4fc1d8..f2767ffbff0d 100644 --- a/source/Target/InstrumentationRuntimeStopInfo.cpp +++ b/source/Target/InstrumentationRuntimeStopInfo.cpp @@ -1,9 +1,8 @@ //===-- InstrumentationRuntimeStopInfo.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/JITLoader.cpp b/source/Target/JITLoader.cpp index 77ce4add486f..e7c13bddcb36 100644 --- a/source/Target/JITLoader.cpp +++ b/source/Target/JITLoader.cpp @@ -1,16 +1,11 @@ //===-- JITLoader.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/JITLoader.h" #include "lldb/Core/PluginManager.h" #include "lldb/Target/JITLoaderList.h" diff --git a/source/Target/JITLoaderList.cpp b/source/Target/JITLoaderList.cpp index 326dd731426c..d5f6144b4f86 100644 --- a/source/Target/JITLoaderList.cpp +++ b/source/Target/JITLoaderList.cpp @@ -1,9 +1,8 @@ //===-- JITLoaderList.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp index 9870ff4673e3..45b60ea5e5cb 100644 --- a/source/Target/Language.cpp +++ b/source/Target/Language.cpp @@ -1,10 +1,9 @@ //===-- Language.cpp -------------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -385,11 +384,10 @@ bool Language::ImageListTypeScavenger::Find_Impl( Target *target = exe_scope->CalculateTarget().get(); if (target) { const auto &images(target->GetImages()); - SymbolContext null_sc; ConstString cs_key(key); llvm::DenseSet searched_sym_files; TypeList matches; - images.FindTypes(null_sc, cs_key, false, UINT32_MAX, searched_sym_files, + images.FindTypes(nullptr, cs_key, false, UINT32_MAX, searched_sym_files, matches); for (const auto &match : matches.Types()) { if (match.get()) { diff --git a/source/Target/LanguageRuntime.cpp b/source/Target/LanguageRuntime.cpp index 145a7bb47b6d..c4f8a4a40edf 100644 --- a/source/Target/LanguageRuntime.cpp +++ b/source/Target/LanguageRuntime.cpp @@ -1,16 +1,11 @@ //===-- LanguageRuntime.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/LanguageRuntime.h" #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp index ad1b4093155d..b3540a4fc71b 100644 --- a/source/Target/Memory.cpp +++ b/source/Target/Memory.cpp @@ -1,23 +1,18 @@ //===-- Memory.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/Memory.h" -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/RangeMap.h" -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/MemoryHistory.cpp b/source/Target/MemoryHistory.cpp index 627942796507..37148e1e72e9 100644 --- a/source/Target/MemoryHistory.cpp +++ b/source/Target/MemoryHistory.cpp @@ -1,16 +1,11 @@ //===-- MemoryHistory.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/MemoryHistory.h" #include "lldb/Core/PluginManager.h" diff --git a/source/Target/ModuleCache.cpp b/source/Target/ModuleCache.cpp index 19adfbabe277..444c9806f98b 100644 --- a/source/Target/ModuleCache.cpp +++ b/source/Target/ModuleCache.cpp @@ -1,9 +1,8 @@ //===--------------------- ModuleCache.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -76,7 +75,7 @@ FileSpec GetModuleDirectory(const FileSpec &root_dir_spec, const UUID &uuid) { } FileSpec GetSymbolFileSpec(const FileSpec &module_file_spec) { - return FileSpec(module_file_spec.GetPath() + kSymFileExtension, false); + return FileSpec(module_file_spec.GetPath() + kSymFileExtension); } void DeleteExistingModule(const FileSpec &root_dir_spec, @@ -133,7 +132,7 @@ Status CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, const auto sysroot_module_path_spec = JoinPath(JoinPath(root_dir_spec, hostname), platform_module_spec.GetPath().c_str()); - if (sysroot_module_path_spec.Exists()) { + if (FileSystem::Instance().Exists(sysroot_module_path_spec)) { if (!delete_existing) return Status(); @@ -141,7 +140,7 @@ Status CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, } const auto error = MakeDirectory( - FileSpec(sysroot_module_path_spec.GetDirectory().AsCString(), false)); + FileSpec(sysroot_module_path_spec.GetDirectory().AsCString())); if (error.Fail()) return error; @@ -159,9 +158,10 @@ ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid, return; m_file_spec = JoinPath(lock_dir_spec, uuid.GetAsString().c_str()); - m_file.Open(m_file_spec.GetCString(), File::eOpenOptionWrite | - File::eOpenOptionCanCreate | - File::eOpenOptionCloseOnExec); + FileSystem::Instance().Open(m_file, m_file_spec, + File::eOpenOptionWrite | + File::eOpenOptionCanCreate | + File::eOpenOptionCloseOnExec); if (!m_file) { error.SetErrorToErrno(); return; @@ -225,9 +225,10 @@ Status ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname, const auto module_file_path = JoinPath( module_spec_dir, module_spec.GetFileSpec().GetFilename().AsCString()); - if (!module_file_path.Exists()) + if (!FileSystem::Instance().Exists(module_file_path)) return Status("Module %s not found", module_file_path.GetPath().c_str()); - if (module_file_path.GetByteSize() != module_spec.GetObjectSize()) + if (FileSystem::Instance().GetByteSize(module_file_path) != + module_spec.GetObjectSize()) return Status("Module %s has invalid file size", module_file_path.GetPath().c_str()); @@ -252,7 +253,7 @@ Status ModuleCache::Get(const FileSpec &root_dir_spec, const char *hostname, return error; FileSpec symfile_spec = GetSymbolFileSpec(cached_module_sp->GetFileSpec()); - if (symfile_spec.Exists()) + if (FileSystem::Instance().Exists(symfile_spec)) cached_module_sp->SetSymbolFileFileSpec(symfile_spec); m_loaded_modules.insert( diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp index b1fcee6db63b..7e0838e2de8c 100644 --- a/source/Target/ObjCLanguageRuntime.cpp +++ b/source/Target/ObjCLanguageRuntime.cpp @@ -1,9 +1,8 @@ //===-- ObjCLanguageRuntime.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "clang/AST/Type.h" @@ -108,14 +107,13 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) { if (!module_sp) return TypeSP(); - const SymbolContext null_sc; const bool exact_match = true; const uint32_t max_matches = UINT32_MAX; TypeList types; llvm::DenseSet searched_symbol_files; const uint32_t num_types = module_sp->FindTypes( - null_sc, name, exact_match, max_matches, searched_symbol_files, types); + name, exact_match, max_matches, searched_symbol_files, types); if (num_types) { uint32_t i; diff --git a/source/Target/OperatingSystem.cpp b/source/Target/OperatingSystem.cpp index 7a1d9d619879..a950f5e32a73 100644 --- a/source/Target/OperatingSystem.cpp +++ b/source/Target/OperatingSystem.cpp @@ -1,16 +1,11 @@ //===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/OperatingSystem.h" #include "lldb/Core/PluginManager.h" #include "lldb/Target/Thread.h" diff --git a/source/Target/PathMappingList.cpp b/source/Target/PathMappingList.cpp index 39a4e2c2af65..c59c842c19cc 100644 --- a/source/Target/PathMappingList.cpp +++ b/source/Target/PathMappingList.cpp @@ -1,25 +1,21 @@ //===-- PathMappingList.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes -#include "lldb/lldb-private-enumerations.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/PosixApi.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" +#include "lldb/lldb-private-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -37,7 +33,7 @@ namespace { ConstString NormalizePath(const ConstString &path) { // If we use "path" to construct a FileSpec, it will normalize the path for // us. We then grab the string and turn it back into a ConstString. - return ConstString(FileSpec(path.GetStringRef(), false).GetPath()); + return ConstString(FileSpec(path.GetStringRef()).GetPath()); } } //---------------------------------------------------------------------- @@ -176,13 +172,13 @@ bool PathMappingList::RemapPath(llvm::StringRef path, // We need to figure out if the "path" argument is relative. If it is, // then we should remap, else skip this entry. if (path_is_relative == eLazyBoolCalculate) { - path_is_relative = FileSpec(path, false).IsRelative() ? eLazyBoolYes : - eLazyBoolNo; + path_is_relative = + FileSpec(path).IsRelative() ? eLazyBoolYes : eLazyBoolNo; } if (!path_is_relative) continue; } - FileSpec remapped(it.second.GetStringRef(), false); + FileSpec remapped(it.second.GetStringRef()); remapped.AppendPathComponent(path); new_path = remapped.GetPath(); return true; @@ -196,7 +192,7 @@ bool PathMappingList::ReverseRemapPath(const FileSpec &file, FileSpec &fixed) co for (const auto &it : m_pairs) { if (!path_ref.consume_front(it.second.GetStringRef())) continue; - fixed.SetFile(it.first.GetStringRef(), false, FileSpec::Style::native); + fixed.SetFile(it.first.GetStringRef(), FileSpec::Style::native); fixed.AppendPathComponent(path_ref); return true; } @@ -230,16 +226,16 @@ bool PathMappingList::FindFile(const FileSpec &orig_spec, // FileSpec paths already. prefix_ref = prefix_ref.drop_front(); } else { - FileSpec prefix_spec(prefix_ref, false, FileSpec::Style::native); + FileSpec prefix_spec(prefix_ref, FileSpec::Style::native); prefix_is_relative = prefix_spec.IsRelative(); } if (prefix_is_relative != orig_is_relative) continue; if (orig_ref.consume_front(prefix_ref)) { - new_spec.SetFile(pos->second.GetCString(), false, FileSpec::Style::native); + new_spec.SetFile(pos->second.GetCString(), FileSpec::Style::native); new_spec.AppendPathComponent(orig_ref); - if (new_spec.Exists()) + if (FileSystem::Instance().Exists(new_spec)) return true; } } diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp index 7b4816fb5328..61484834b51d 100644 --- a/source/Target/Platform.cpp +++ b/source/Target/Platform.cpp @@ -1,24 +1,19 @@ //===-- Platform.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include #include #include -// Other libraries and framework includes #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -// Project includes #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" @@ -94,7 +89,7 @@ PlatformProperties::PlatformProperties() { if (!llvm::sys::path::home_directory(user_home_dir)) return; - module_cache_dir = FileSpec(user_home_dir.c_str(), false); + module_cache_dir = FileSpec(user_home_dir.c_str()); module_cache_dir.AppendPathComponent(".lldb"); module_cache_dir.AppendPathComponent("module_cache"); SetModuleCacheDirectory(module_cache_dir); @@ -227,16 +222,35 @@ Status Platform::GetSharedModule(const ModuleSpec &module_spec, module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr, false); - return GetRemoteSharedModule(module_spec, process, module_sp, - [&](const ModuleSpec &spec) { - Status error = ModuleList::GetSharedModule( - spec, module_sp, module_search_paths_ptr, - old_module_sp_ptr, did_create_ptr, false); - if (error.Success() && module_sp) - module_sp->SetPlatformFileSpec( - spec.GetFileSpec()); - return error; - }, + // Module resolver lambda. + auto resolver = [&](const ModuleSpec &spec) { + Status error(eErrorTypeGeneric); + ModuleSpec resolved_spec; + // Check if we have sysroot set. + if (m_sdk_sysroot) { + // Prepend sysroot to module spec. + resolved_spec = spec; + resolved_spec.GetFileSpec().PrependPathComponent( + m_sdk_sysroot.GetStringRef()); + // Try to get shared module with resolved spec. + error = ModuleList::GetSharedModule( + resolved_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, + did_create_ptr, false); + } + // If we don't have sysroot or it didn't work then + // try original module spec. + if (!error.Success()) { + resolved_spec = spec; + error = ModuleList::GetSharedModule( + resolved_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, + did_create_ptr, false); + } + if (error.Success() && module_sp) + module_sp->SetPlatformFileSpec(resolved_spec.GetFileSpec()); + return error; + }; + + return GetRemoteSharedModule(module_spec, process, module_sp, resolver, did_create_ptr); } @@ -517,9 +531,12 @@ FileSpec Platform::GetWorkingDirectory() { if (IsHost()) { llvm::SmallString<64> cwd; if (llvm::sys::fs::current_path(cwd)) - return FileSpec{}; - else - return FileSpec(cwd, true); + return {}; + else { + FileSpec file_spec(cwd); + FileSystem::Instance().Resolve(file_spec); + return file_spec; + } } else { if (!m_working_dir) m_working_dir = GetRemoteWorkingDirectory(); @@ -533,16 +550,17 @@ struct RecurseCopyBaton { Status error; }; -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &src) { + llvm::StringRef path) { RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton; + FileSpec src(path); namespace fs = llvm::sys::fs; switch (ft) { case fs::file_type::fifo_file: case fs::file_type::socket_file: // we have no way to copy pipes and sockets - ignore them and continue - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; break; case fs::file_type::directory_file: { @@ -555,7 +573,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft, if (error.Fail()) { rc_baton->error.SetErrorStringWithFormat( "unable to setup directory %s on remote end", dst_dir.GetCString()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out } // now recurse @@ -567,13 +585,13 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft, recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str()); RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr, Status()}; - FileSpec::EnumerateDirectory(src_dir_path, true, true, true, - RecurseCopy_Callback, &rc_baton2); + FileSystem::Instance().EnumerateDirectory(src_dir_path, true, true, true, + RecurseCopy_Callback, &rc_baton2); if (rc_baton2.error.Fail()) { rc_baton->error.SetErrorString(rc_baton2.error.AsCString()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } break; case fs::file_type::symlink_file: { @@ -584,18 +602,18 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft, FileSpec src_resolved; - rc_baton->error = FileSystem::Readlink(src, src_resolved); + rc_baton->error = FileSystem::Instance().Readlink(src, src_resolved); if (rc_baton->error.Fail()) - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out rc_baton->error = rc_baton->platform_ptr->CreateSymlink(dst_file, src_resolved); if (rc_baton->error.Fail()) - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } break; case fs::file_type::regular_file: { @@ -606,15 +624,15 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft, Status err = rc_baton->platform_ptr->PutFile(src, dst_file); if (err.Fail()) { rc_baton->error.SetErrorString(err.AsCString()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } break; default: rc_baton->error.SetErrorStringWithFormat( "invalid file detected during copy: %s", src.GetPath().c_str()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out break; } llvm_unreachable("Unhandled file_type!"); @@ -689,7 +707,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) { switch (fs::get_file_type(src.GetPath(), false)) { case fs::file_type::directory_file: { llvm::sys::fs::remove(fixed_dst.GetPath()); - uint32_t permissions = src.GetPermissions(); + uint32_t permissions = FileSystem::Instance().GetPermissions(src); if (permissions == 0) permissions = eFilePermissionsDirectoryDefault; error = MakeDirectory(fixed_dst, permissions); @@ -700,8 +718,8 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) { recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString()); std::string src_dir_path(src.GetPath()); RecurseCopyBaton baton = {recurse_dst, this, Status()}; - FileSpec::EnumerateDirectory(src_dir_path, true, true, true, - RecurseCopy_Callback, &baton); + FileSystem::Instance().EnumerateDirectory( + src_dir_path, true, true, true, RecurseCopy_Callback, &baton); return baton.error; } } break; @@ -714,7 +732,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) { case fs::file_type::symlink_file: { llvm::sys::fs::remove(fixed_dst.GetPath()); FileSpec src_resolved; - error = FileSystem::Readlink(src, src_resolved); + error = FileSystem::Instance().Readlink(src, src_resolved); if (error.Success()) error = CreateSymlink(dst, src_resolved); } break; @@ -870,7 +888,7 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) { Status error; - if (module_spec.GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) { if (module_spec.GetArchitecture().IsValid()) { error = ModuleList::GetSharedModule(module_spec, exe_module_sp, module_search_paths_ptr, nullptr, @@ -901,7 +919,7 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec, Status Platform::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, FileSpec &sym_file) { Status error; - if (sym_spec.GetSymbolFileSpec().Exists()) + if (FileSystem::Instance().Exists(sym_spec.GetSymbolFileSpec())) sym_file = sym_spec.GetSymbolFileSpec(); else error.SetErrorString("unable to resolve symbol file"); @@ -911,7 +929,8 @@ Status Platform::ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, bool Platform::ResolveRemotePath(const FileSpec &platform_path, FileSpec &resolved_platform_path) { resolved_platform_path = platform_path; - return resolved_platform_path.ResolvePath(); + FileSystem::Instance().Resolve(resolved_platform_path); + return true; } const ArchSpec &Platform::GetSystemArchitecture() { @@ -1256,8 +1275,9 @@ Status Platform::PutFile(const FileSpec &source, const FileSpec &destination, if (fs::is_symlink_file(source.GetPath())) source_open_options |= File::eOpenOptionDontFollowSymlinks; - File source_file(source, source_open_options, lldb::eFilePermissionsUserRW); - Status error; + File source_file; + Status error = FileSystem::Instance().Open( + source_file, source, source_open_options, lldb::eFilePermissionsUserRW); uint32_t permissions = source_file.GetPermissions(error); if (permissions == 0) permissions = lldb::eFilePermissionsFileDefault; @@ -1275,7 +1295,7 @@ Status Platform::PutFile(const FileSpec &source, const FileSpec &destination, return error; if (dest_file == UINT64_MAX) return Status("unable to open target file"); - lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024, 0)); + lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024 * 16, 0)); uint64_t offset = 0; for (;;) { size_t bytes_read = buffer_sp->GetByteSize(); @@ -1565,14 +1585,14 @@ Status Platform::GetRemoteSharedModule(const ModuleSpec &module_spec, if (process->GetModuleSpec(module_spec.GetFileSpec(), module_spec.GetArchitecture(), resolved_module_spec)) { - if (module_spec.GetUUID().IsValid() == false || + if (!module_spec.GetUUID().IsValid() || module_spec.GetUUID() == resolved_module_spec.GetUUID()) { got_module_spec = true; } } } - if (module_spec.GetArchitecture().IsValid() == false) { + if (!module_spec.GetArchitecture().IsValid()) { Status error; // No valid architecture was specified, ask the platform for the // architectures that we should be using (in the correct order) and see if @@ -1595,7 +1615,7 @@ Status Platform::GetRemoteSharedModule(const ModuleSpec &module_spec, // Get module information from a target. if (!GetModuleSpec(module_spec.GetFileSpec(), module_spec.GetArchitecture(), resolved_module_spec)) { - if (module_spec.GetUUID().IsValid() == false || + if (!module_spec.GetUUID().IsValid() || module_spec.GetUUID() == resolved_module_spec.GetUUID()) { return module_resolver(module_spec); } @@ -1779,9 +1799,9 @@ uint32_t Platform::LoadImageUsingPaths(lldb_private::Process *process, { FileSpec file_to_use; if (remote_filename.IsAbsolute()) - file_to_use = FileSpec(remote_filename.GetFilename().GetStringRef(), - false, - remote_filename.GetPathStyle()); + file_to_use = FileSpec(remote_filename.GetFilename().GetStringRef(), + + remote_filename.GetPathStyle()); else file_to_use = remote_filename; diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp index a1f6d78529d1..5223a6f32618 100644 --- a/source/Target/Process.cpp +++ b/source/Target/Process.cpp @@ -1,31 +1,24 @@ //===-- Process.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/Threading.h" -// Project includes #include "Plugins/Process/Utility/InferiorCallPOSIX.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Event.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/IRDynamicChecks.h" @@ -68,9 +61,11 @@ #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanBase.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/SelectHelper.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; @@ -431,7 +426,7 @@ Status ProcessLaunchCommandOptions::SetOptionValue( case 'i': // STDIN for read only { FileAction action; - if (action.Open(STDIN_FILENO, FileSpec{option_arg, false}, true, false)) + if (action.Open(STDIN_FILENO, FileSpec(option_arg), true, false)) launch_info.AppendFileAction(action); break; } @@ -439,7 +434,7 @@ Status ProcessLaunchCommandOptions::SetOptionValue( case 'o': // Open STDOUT for write only { FileAction action; - if (action.Open(STDOUT_FILENO, FileSpec{option_arg, false}, false, true)) + if (action.Open(STDOUT_FILENO, FileSpec(option_arg), false, true)) launch_info.AppendFileAction(action); break; } @@ -447,7 +442,7 @@ Status ProcessLaunchCommandOptions::SetOptionValue( case 'e': // STDERR for write only { FileAction action; - if (action.Open(STDERR_FILENO, FileSpec{option_arg, false}, false, true)) + if (action.Open(STDERR_FILENO, FileSpec(option_arg), false, true)) launch_info.AppendFileAction(action); break; } @@ -459,7 +454,7 @@ Status ProcessLaunchCommandOptions::SetOptionValue( case 'n': // Disable STDIO { FileAction action; - const FileSpec dev_null{FileSystem::DEV_NULL, false}; + const FileSpec dev_null(FileSystem::DEV_NULL); if (action.Open(STDIN_FILENO, dev_null, true, false)) launch_info.AppendFileAction(action); if (action.Open(STDOUT_FILENO, dev_null, false, true)) @@ -470,7 +465,7 @@ Status ProcessLaunchCommandOptions::SetOptionValue( } case 'w': - launch_info.SetWorkingDirectory(FileSpec{option_arg, false}); + launch_info.SetWorkingDirectory(FileSpec(option_arg)); break; case 't': // Open process in new terminal window @@ -516,7 +511,7 @@ Status ProcessLaunchCommandOptions::SetOptionValue( case 'c': if (!option_arg.empty()) - launch_info.SetShell(FileSpec(option_arg, false)); + launch_info.SetShell(FileSpec(option_arg)); else launch_info.SetShell(HostInfo::GetDefaultShell()); break; @@ -1500,8 +1495,6 @@ bool Process::IsAlive() { case eStateCrashed: case eStateSuspended: return true; - default: - return false; } } @@ -2864,7 +2857,7 @@ Status Process::Launch(ProcessLaunchInfo &launch_info) { sizeof(local_exec_file_path)); exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path, sizeof(platform_exec_file_path)); - if (exe_module->GetFileSpec().Exists()) { + if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) { // Install anything that might need to be installed prior to launching. // For host systems, this will do nothing, but if we are connected to a // remote platform it will install any needed binaries @@ -3425,6 +3418,11 @@ Status Process::PrivateResume() { m_thread_list.DidResume(); if (log) log->Printf("Process thinks the process has resumed."); + } else { + if (log) + log->Printf( + "Process::PrivateResume() DoResume failed."); + return error; } } } else { @@ -6007,7 +6005,7 @@ void Process::ModulesDidLoad(ModuleList &module_list) { // that loaded. // Iterate over a copy of this language runtime list in case the language - // runtime ModulesDidLoad somehow causes the language riuntime to be + // runtime ModulesDidLoad somehow causes the language runtime to be // unloaded. LanguageRuntimeCollection language_runtimes(m_language_runtimes); for (const auto &pair : language_runtimes) { @@ -6192,7 +6190,7 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr, } Status -Process::GetMemoryRegions(std::vector ®ion_list) { +Process::GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) { Status error; @@ -6200,17 +6198,17 @@ Process::GetMemoryRegions(std::vector ®ion_list) { region_list.clear(); do { - lldb::MemoryRegionInfoSP region_info(new lldb_private::MemoryRegionInfo()); - error = GetMemoryRegionInfo(range_end, *region_info); + lldb_private::MemoryRegionInfo region_info; + error = GetMemoryRegionInfo(range_end, region_info); // GetMemoryRegionInfo should only return an error if it is unimplemented. if (error.Fail()) { region_list.clear(); break; } - range_end = region_info->GetRange().GetRangeEnd(); - if (region_info->GetMapped() == MemoryRegionInfo::eYes) { - region_list.push_back(region_info); + range_end = region_info.GetRange().GetRangeEnd(); + if (region_info.GetMapped() == MemoryRegionInfo::eYes) { + region_list.push_back(std::move(region_info)); } } while (range_end != LLDB_INVALID_ADDRESS); @@ -6267,7 +6265,7 @@ void Process::MapSupportedStructuredDataPlugins( // For each StructuredDataPlugin, if the plugin handles any of the types in // the supported_type_names, map that type name to that plugin. Stop when // we've consumed all the type names. - // FIXME: should we return an error if there are type names nobody + // FIXME: should we return an error if there are type names nobody // supports? for (uint32_t plugin_index = 0; !const_type_names.empty(); plugin_index++) { auto create_instance = @@ -6275,7 +6273,7 @@ void Process::MapSupportedStructuredDataPlugins( plugin_index); if (!create_instance) break; - + // Create the plugin. StructuredDataPluginSP plugin_sp = (*create_instance)(*this); if (!plugin_sp) { diff --git a/source/Target/ProcessInfo.cpp b/source/Target/ProcessInfo.cpp index ac0350686706..65aec34d0b4b 100644 --- a/source/Target/ProcessInfo.cpp +++ b/source/Target/ProcessInfo.cpp @@ -1,20 +1,15 @@ //===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/ProcessInfo.h" -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Host/PosixApi.h" #include "lldb/Utility/Stream.h" @@ -29,8 +24,8 @@ ProcessInfo::ProcessInfo() ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid) - : m_executable(name, false), m_arguments(), m_environment(), - m_uid(UINT32_MAX), m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {} + : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX), + m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {} void ProcessInfo::Clear() { m_executable.Clear(); @@ -67,7 +62,7 @@ void ProcessInfo::SetExecutableFile(const FileSpec &exe_file, if (exe_file) { m_executable = exe_file; if (add_exe_file_as_first_arg) { - llvm::SmallString filename; + llvm::SmallString<128> filename; exe_file.GetPath(filename); if (!filename.empty()) m_arguments.InsertArgumentAtIndex(0, filename); @@ -96,8 +91,7 @@ void ProcessInfo::SetArguments(char const **argv, // Yes the first argument is an executable, set it as the executable in // the launch options. Don't resolve the file path as the path could be a // remote platform path - const bool resolve = false; - m_executable.SetFile(first_arg, resolve, FileSpec::Style::native); + m_executable.SetFile(first_arg, FileSpec::Style::native); } } } @@ -113,8 +107,7 @@ void ProcessInfo::SetArguments(const Args &args, bool first_arg_is_executable) { // Yes the first argument is an executable, set it as the executable in // the launch options. Don't resolve the file path as the path could be a // remote platform path - const bool resolve = false; - m_executable.SetFile(first_arg, resolve, FileSpec::Style::native); + m_executable.SetFile(first_arg, FileSpec::Style::native); } } } diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp index 9569750bc5fd..f9d0b78caccc 100644 --- a/source/Target/ProcessLaunchInfo.cpp +++ b/source/Target/ProcessLaunchInfo.cpp @@ -1,25 +1,18 @@ //===-- ProcessLaunchInfo.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Debugger.h" #include "lldb/Host/Config.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/FileAction.h" #include "lldb/Target/ProcessLaunchInfo.h" -#include "lldb/Target/Target.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" @@ -108,8 +101,7 @@ bool ProcessLaunchInfo::AppendOpenFileAction(int fd, const FileSpec &file_spec, bool ProcessLaunchInfo::AppendSuppressFileAction(int fd, bool read, bool write) { FileAction file_action; - if (file_action.Open(fd, FileSpec{FileSystem::DEV_NULL, false}, read, - write)) { + if (file_action.Open(fd, FileSpec(FileSystem::DEV_NULL), read, write)) { AppendFileAction(file_action); return true; } @@ -151,7 +143,7 @@ const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; } void ProcessLaunchInfo::SetShell(const FileSpec &shell) { m_shell = shell; if (m_shell) { - m_shell.ResolveExecutableLocation(); + FileSystem::Instance().ResolveExecutableLocation(m_shell); m_flags.Set(lldb::eLaunchFlagLaunchInShell); } else m_flags.Clear(lldb::eLaunchFlagLaunchInShell); @@ -212,124 +204,38 @@ void ProcessLaunchInfo::SetDetachOnError(bool enable) { m_flags.Clear(lldb::eLaunchFlagDetachOnError); } -void ProcessLaunchInfo::FinalizeFileActions(Target *target, - bool default_to_use_pty) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); - - // If nothing for stdin or stdout or stderr was specified, then check the - // process for any default settings that were set with "settings set" - if (GetFileActionForFD(STDIN_FILENO) == nullptr || - GetFileActionForFD(STDOUT_FILENO) == nullptr || - GetFileActionForFD(STDERR_FILENO) == nullptr) { - if (log) - log->Printf("ProcessLaunchInfo::%s at least one of stdin/stdout/stderr " - "was not set, evaluating default handling", - __FUNCTION__); - - if (m_flags.Test(eLaunchFlagLaunchInTTY)) { - // Do nothing, if we are launching in a remote terminal no file actions - // should be done at all. - return; - } - - if (m_flags.Test(eLaunchFlagDisableSTDIO)) { - if (log) - log->Printf("ProcessLaunchInfo::%s eLaunchFlagDisableSTDIO set, adding " - "suppression action for stdin, stdout and stderr", - __FUNCTION__); - AppendSuppressFileAction(STDIN_FILENO, true, false); - AppendSuppressFileAction(STDOUT_FILENO, false, true); - AppendSuppressFileAction(STDERR_FILENO, false, true); - } else { - // Check for any values that might have gotten set with any of: (lldb) - // settings set target.input-path (lldb) settings set target.output-path - // (lldb) settings set target.error-path - FileSpec in_file_spec; - FileSpec out_file_spec; - FileSpec err_file_spec; - if (target) { - // Only override with the target settings if we don't already have an - // action for in, out or error - if (GetFileActionForFD(STDIN_FILENO) == nullptr) - in_file_spec = target->GetStandardInputPath(); - if (GetFileActionForFD(STDOUT_FILENO) == nullptr) - out_file_spec = target->GetStandardOutputPath(); - if (GetFileActionForFD(STDERR_FILENO) == nullptr) - err_file_spec = target->GetStandardErrorPath(); - } - - if (log) - log->Printf("ProcessLaunchInfo::%s target stdin='%s', target " - "stdout='%s', stderr='%s'", - __FUNCTION__, - in_file_spec ? in_file_spec.GetCString() : "", - out_file_spec ? out_file_spec.GetCString() : "", - err_file_spec ? err_file_spec.GetCString() : ""); - - if (in_file_spec) { - AppendOpenFileAction(STDIN_FILENO, in_file_spec, true, false); - if (log) - log->Printf( - "ProcessLaunchInfo::%s appended stdin open file action for %s", - __FUNCTION__, in_file_spec.GetCString()); - } - - if (out_file_spec) { - AppendOpenFileAction(STDOUT_FILENO, out_file_spec, false, true); - if (log) - log->Printf( - "ProcessLaunchInfo::%s appended stdout open file action for %s", - __FUNCTION__, out_file_spec.GetCString()); - } - - if (err_file_spec) { - AppendOpenFileAction(STDERR_FILENO, err_file_spec, false, true); - if (log) - log->Printf( - "ProcessLaunchInfo::%s appended stderr open file action for %s", - __FUNCTION__, err_file_spec.GetCString()); - } - - if (default_to_use_pty && - (!in_file_spec || !out_file_spec || !err_file_spec)) { - if (log) - log->Printf("ProcessLaunchInfo::%s default_to_use_pty is set, and at " - "least one stdin/stderr/stdout is unset, so generating a " - "pty to use for it", - __FUNCTION__); +llvm::Error ProcessLaunchInfo::SetUpPtyRedirection() { + Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS); + LLDB_LOG(log, "Generating a pty to use for stdin/out/err"); - int open_flags = O_RDWR | O_NOCTTY; + int open_flags = O_RDWR | O_NOCTTY; #if !defined(_WIN32) - // We really shouldn't be specifying platform specific flags that are - // intended for a system call in generic code. But this will have to - // do for now. - open_flags |= O_CLOEXEC; + // We really shouldn't be specifying platform specific flags that are + // intended for a system call in generic code. But this will have to + // do for now. + open_flags |= O_CLOEXEC; #endif - if (m_pty->OpenFirstAvailableMaster(open_flags, nullptr, 0)) { - const FileSpec slave_file_spec{m_pty->GetSlaveName(nullptr, 0), - false}; - - // Only use the slave tty if we don't have anything specified for - // input and don't have an action for stdin - if (!in_file_spec && GetFileActionForFD(STDIN_FILENO) == nullptr) { - AppendOpenFileAction(STDIN_FILENO, slave_file_spec, true, false); - } - - // Only use the slave tty if we don't have anything specified for - // output and don't have an action for stdout - if (!out_file_spec && GetFileActionForFD(STDOUT_FILENO) == nullptr) { - AppendOpenFileAction(STDOUT_FILENO, slave_file_spec, false, true); - } - - // Only use the slave tty if we don't have anything specified for - // error and don't have an action for stderr - if (!err_file_spec && GetFileActionForFD(STDERR_FILENO) == nullptr) { - AppendOpenFileAction(STDERR_FILENO, slave_file_spec, false, true); - } - } - } - } + if (!m_pty->OpenFirstAvailableMaster(open_flags, nullptr, 0)) { + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "PTY::OpenFirstAvailableMaster failed"); } + const FileSpec slave_file_spec(m_pty->GetSlaveName(nullptr, 0)); + + // Only use the slave tty if we don't have anything specified for + // input and don't have an action for stdin + if (GetFileActionForFD(STDIN_FILENO) == nullptr) + AppendOpenFileAction(STDIN_FILENO, slave_file_spec, true, false); + + // Only use the slave tty if we don't have anything specified for + // output and don't have an action for stdout + if (GetFileActionForFD(STDOUT_FILENO) == nullptr) + AppendOpenFileAction(STDOUT_FILENO, slave_file_spec, false, true); + + // Only use the slave tty if we don't have anything specified for + // error and don't have an action for stderr + if (GetFileActionForFD(STDERR_FILENO) == nullptr) + AppendOpenFileAction(STDERR_FILENO, slave_file_spec, false, true); + return llvm::Error::success(); } bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell( @@ -359,7 +265,7 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell( // Add a modified PATH environment variable in case argv[0] is a // relative path. const char *argv0 = argv[0]; - FileSpec arg_spec(argv0, false); + FileSpec arg_spec(argv0); if (arg_spec.IsRelative()) { // We have a relative path to our executable which may not work if we // just try to run "a.out" (without it being converted to "./a.out") @@ -439,10 +345,3 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell( } return false; } - -ListenerSP ProcessLaunchInfo::GetListenerForProcess(Debugger &debugger) { - if (m_listener_sp) - return m_listener_sp; - else - return debugger.GetListener(); -} diff --git a/source/Target/Queue.cpp b/source/Target/Queue.cpp index 45fdbea13db5..fc2a93dbe899 100644 --- a/source/Target/Queue.cpp +++ b/source/Target/Queue.cpp @@ -1,16 +1,11 @@ //===-- Queue.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Queue.h" #include "lldb/Target/Process.h" #include "lldb/Target/QueueList.h" diff --git a/source/Target/QueueItem.cpp b/source/Target/QueueItem.cpp index c929a0529d94..22e51755bc35 100644 --- a/source/Target/QueueItem.cpp +++ b/source/Target/QueueItem.cpp @@ -1,9 +1,8 @@ //===-- QueueItem.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -94,7 +93,7 @@ std::string QueueItem::GetQueueLabel() { ProcessSP QueueItem::GetProcessSP() { return m_process_wp.lock(); } void QueueItem::FetchEntireItem() { - if (m_have_fetched_entire_item == true) + if (m_have_fetched_entire_item) return; ProcessSP process_sp = m_process_wp.lock(); if (process_sp) { diff --git a/source/Target/QueueList.cpp b/source/Target/QueueList.cpp index fbbfcb6c29e0..c2fcb2034d0e 100644 --- a/source/Target/QueueList.cpp +++ b/source/Target/QueueList.cpp @@ -1,9 +1,8 @@ //===-- QueueList.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp index eaec03d9b595..c960260f30c8 100644 --- a/source/Target/RegisterContext.cpp +++ b/source/Target/RegisterContext.cpp @@ -1,20 +1,13 @@ //===-- RegisterContext.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/RegisterContext.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Target/ExecutionContext.h" @@ -24,6 +17,8 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Scalar.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/RegisterNumber.cpp b/source/Target/RegisterNumber.cpp index d1bb8adf56e1..63b58d3582fd 100644 --- a/source/Target/RegisterNumber.cpp +++ b/source/Target/RegisterNumber.cpp @@ -1,9 +1,8 @@ //===--------------------- RegisterNumber.cpp -------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -61,26 +60,15 @@ bool RegisterNumber::operator==(RegisterNumber &rhs) { return false; if (m_kind == rhs.m_kind) { - if (m_regnum == rhs.m_regnum) - return true; - else - return false; + return m_regnum == rhs.m_regnum; } uint32_t rhs_regnum = rhs.GetAsKind(m_kind); if (rhs_regnum != LLDB_INVALID_REGNUM) { - if (m_regnum == rhs_regnum) - return true; - else - return false; + return m_regnum == rhs_regnum; } uint32_t lhs_regnum = GetAsKind(rhs.m_kind); - { - if (lhs_regnum == rhs.m_regnum) - return true; - else - return false; - } + { return lhs_regnum == rhs.m_regnum; } return false; } diff --git a/source/Target/SectionLoadHistory.cpp b/source/Target/SectionLoadHistory.cpp index 5844da5d41e9..46e1c690e5d8 100644 --- a/source/Target/SectionLoadHistory.cpp +++ b/source/Target/SectionLoadHistory.cpp @@ -1,18 +1,13 @@ //===-- SectionLoadHistory.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/SectionLoadHistory.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/SectionLoadList.h" #include "lldb/Utility/Stream.h" diff --git a/source/Target/SectionLoadList.cpp b/source/Target/SectionLoadList.cpp index 6839aaccaa52..45b6b52e184a 100644 --- a/source/Target/SectionLoadList.cpp +++ b/source/Target/SectionLoadList.cpp @@ -1,18 +1,13 @@ //===-- SectionLoadList.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/SectionLoadList.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/Block.h" diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp index 532a341d47c4..d0f7835efef8 100644 --- a/source/Target/StackFrame.cpp +++ b/source/Target/StackFrame.cpp @@ -1,23 +1,17 @@ //===-- StackFrame.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/StackFrame.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectMemory.h" @@ -35,6 +29,9 @@ #include "lldb/Target/StackFrameRecognizer.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" + +#include "lldb/lldb-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -266,7 +263,8 @@ Block *StackFrame::GetFrameBlock() { // StackFrame object, everyone will have as much information as possible and no // one will ever have to look things up manually. //---------------------------------------------------------------------- -const SymbolContext &StackFrame::GetSymbolContext(uint32_t resolve_scope) { +const SymbolContext & +StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) { std::lock_guard guard(m_mutex); // Copy our internal symbol context into "sc". if ((m_flags.Get() & resolve_scope) != resolve_scope) { @@ -318,7 +316,7 @@ const SymbolContext &StackFrame::GetSymbolContext(uint32_t resolve_scope) { // haven't already tried to lookup one of those things. If we haven't // then we will do the query. - uint32_t actual_resolve_scope = 0; + SymbolContextItem actual_resolve_scope = SymbolContextItem(0); if (resolve_scope & eSymbolContextCompUnit) { if (m_flags.IsClear(eSymbolContextCompUnit)) { @@ -1080,9 +1078,9 @@ bool StackFrame::GetFrameBaseValue(Scalar &frame_base, Status *error_ptr) { m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress( exe_ctx.GetTargetPtr()); - if (m_sc.function->GetFrameBaseExpression().Evaluate( + if (!m_sc.function->GetFrameBaseExpression().Evaluate( &exe_ctx, nullptr, loclist_base_addr, nullptr, nullptr, - expr_value, &m_frame_base_error) == false) { + expr_value, &m_frame_base_error)) { // We should really have an error if evaluate returns, but in case we // don't, lets set the error to something at least. if (m_frame_base_error.Success()) diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp index a01de7a36d9e..3a97c1375a02 100644 --- a/source/Target/StackFrameList.cpp +++ b/source/Target/StackFrameList.cpp @@ -1,16 +1,11 @@ //===-- StackFrameList.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/StackFrameList.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" diff --git a/source/Target/StackFrameRecognizer.cpp b/source/Target/StackFrameRecognizer.cpp index 350d70b396bc..23b45f6b61e6 100644 --- a/source/Target/StackFrameRecognizer.cpp +++ b/source/Target/StackFrameRecognizer.cpp @@ -1,17 +1,12 @@ //===-- StackFrameRecognizer.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Core/Module.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Symbol/Symbol.h" @@ -53,8 +48,9 @@ ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) { class StackFrameRecognizerManagerImpl { public: - void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module, - ConstString &symbol, bool first_instruction_only) { + void AddRecognizer(StackFrameRecognizerSP recognizer, + const ConstString &module, const ConstString &symbol, + bool first_instruction_only) { m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(), symbol, RegularExpressionSP(), first_instruction_only}); @@ -156,8 +152,8 @@ StackFrameRecognizerManagerImpl &GetStackFrameRecognizerManagerImpl() { } void StackFrameRecognizerManager::AddRecognizer( - StackFrameRecognizerSP recognizer, ConstString &module, ConstString &symbol, - bool first_instruction_only) { + StackFrameRecognizerSP recognizer, const ConstString &module, + const ConstString &symbol, bool first_instruction_only) { GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol, first_instruction_only); } diff --git a/source/Target/StackID.cpp b/source/Target/StackID.cpp index 341c902af995..a8f6b787f4b4 100644 --- a/source/Target/StackID.cpp +++ b/source/Target/StackID.cpp @@ -1,16 +1,11 @@ //===-- StackID.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/StackID.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Symbol.h" diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp index 3467f8930cbc..e28890866ea0 100644 --- a/source/Target/StopInfo.cpp +++ b/source/Target/StopInfo.cpp @@ -1,18 +1,13 @@ //===-- StopInfo.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -333,6 +328,19 @@ class StopInfoBreakpoint : public StopInfo { // commands when we see the same breakpoint hit a second time. m_should_stop_is_valid = true; + + // It is possible that the user has a breakpoint at the same site + // as the completed plan had (e.g. user has a breakpoint + // on a module entry point, and `ThreadPlanCallFunction` ends + // also there). We can't find an internal breakpoint in the loop + // later because it was already removed on the plan completion. + // So check if the plan was completed, and stop if so. + if (thread_sp->CompletedPlanOverridesBreakpoint()) { + m_should_stop = true; + thread_sp->ResetStopInfo(); + return; + } + if (log) log->Printf("StopInfoBreakpoint::PerformAction - Hit a " "breakpoint while running an expression," @@ -533,9 +541,9 @@ class StopInfoBreakpoint : public StopInfo { __FUNCTION__, m_value); } - if ((m_should_stop == false || internal_breakpoint) - && thread_sp->CompletedPlanOverridesBreakpoint()) { - + if ((!m_should_stop || internal_breakpoint) && + thread_sp->CompletedPlanOverridesBreakpoint()) { + // Override should_stop decision when we have completed step plan // additionally to the breakpoint m_should_stop = true; diff --git a/source/Target/StructuredDataPlugin.cpp b/source/Target/StructuredDataPlugin.cpp index fe267e5e45a0..d8fbb54e316e 100644 --- a/source/Target/StructuredDataPlugin.cpp +++ b/source/Target/StructuredDataPlugin.cpp @@ -1,9 +1,8 @@ //===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/SwiftLanguageRuntime.cpp b/source/Target/SwiftLanguageRuntime.cpp index 12d28383dcad..2e57df336ff7 100644 --- a/source/Target/SwiftLanguageRuntime.cpp +++ b/source/Target/SwiftLanguageRuntime.cpp @@ -134,7 +134,10 @@ void SwiftLanguageRuntime::SetupReflection() { auto *obj_file = M->GetObjectFile(); if (!obj_file) return; - Address start_address = obj_file->GetHeaderAddress(); + ConstString g_name("elf"); + if (g_name == obj_file->GetPluginName()) + return; + Address start_address = obj_file->GetBaseAddress(); auto load_ptr = static_cast(start_address.GetLoadAddress(&target)); // Bail out if we can't read the executable instead of crashing. @@ -149,7 +152,10 @@ void SwiftLanguageRuntime::SetupReflection() { auto *obj_file = module_sp->GetObjectFile(); if (!obj_file) return false; - Address start_address = obj_file->GetHeaderAddress(); + ConstString g_name("elf"); + if (g_name == obj_file->GetPluginName()) + return true; + Address start_address = obj_file->GetBaseAddress(); auto load_ptr = static_cast( start_address.GetLoadAddress(&(m_process->GetTarget()))); if (load_ptr == 0 || load_ptr == LLDB_INVALID_ADDRESS) @@ -224,7 +230,7 @@ void SwiftLanguageRuntime::SetupExclusivity() { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); if (log) - log->Printf("SwiftLanguageRuntime: _swift_disableExclusivityChecking = %llu", + log->Printf("SwiftLanguageRuntime: _swift_disableExclusivityChecking = %lu", m_dynamic_exclusivity_flag_addr ? *m_dynamic_exclusivity_flag_addr : 0); } @@ -234,7 +240,7 @@ void SwiftLanguageRuntime::ModulesDidLoad(const ModuleList &module_list) { auto *obj_file = module_sp->GetObjectFile(); if (!obj_file) return true; - Address start_address = obj_file->GetHeaderAddress(); + Address start_address = obj_file->GetBaseAddress(); auto load_ptr = static_cast( start_address.GetLoadAddress(&(m_process->GetTarget()))); if (load_ptr == 0 || load_ptr == LLDB_INVALID_ADDRESS) @@ -1572,16 +1578,6 @@ SwiftLanguageRuntime::GetMemberVariableOffset(CompilerType instance_type, return llvm::None; } -static size_t BaseClassDepth(ValueObject &in_value) { - ValueObject *ptr = &in_value; - size_t depth = 0; - while (ptr->IsBaseClass()) { - depth++; - ptr = ptr->GetParent(); - } - return depth; -} - /// Determine whether the scratch SwiftASTContext has been locked. static bool IsScratchContextLocked(Target &target) { if (target.GetSwiftScratchContextLock().try_lock()) { @@ -1620,7 +1616,7 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Class( auto metadata_address = remote_ast.getHeapMetadataForObject(instance_address); if (!metadata_address) { if (log) { - log->Printf("could not read heap metadata for object at %llu: %s\n", + log->Printf("could not read heap metadata for object at %lu: %s\n", class_metadata_ptr, metadata_address.getFailure().render().c_str()); } @@ -1633,8 +1629,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Class( /*skipArtificial=*/true); if (!instance_type) { if (log) { - log->Printf("could not get type metadata from address %llu: %s\n", - metadata_address.getValue(), + log->Printf("could not get type metadata from address %" PRIu64 " : %s\n", + metadata_address.getValue().getAddressData(), instance_type.getFailure().render().c_str()); } return false; @@ -2076,8 +2072,6 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Promise( } break; case swift::MetadataKind::Existential: { CompilerType protocol_type(promise_sp->FulfillTypePromise()); - SwiftASTContext *swift_ast_ctx = - llvm::dyn_cast_or_null(protocol_type.GetTypeSystem()); lldb::addr_t existential_address = in_value.GetAddressOf(); if (!existential_address || existential_address == LLDB_INVALID_ADDRESS) return false; @@ -2189,7 +2183,7 @@ bool SwiftLanguageRuntime::GetAbstractTypeName(StreamString &name, swift::TypeBase *base = swift_type.getPointer(); while (dependent_member) { base = dependent_member->getBase().getPointer(); - assoc.Printf(".%s", dependent_member->getName()); + assoc.Printf(".%s", dependent_member->getName().get()); dependent_member = llvm::dyn_cast(base); } @@ -2198,7 +2192,7 @@ bool SwiftLanguageRuntime::GetAbstractTypeName(StreamString &name, return false; name.Printf(u8"\u03C4_%d_%d%s", generic_type_param->getDepth(), - generic_type_param->getIndex(), assoc.GetString()); + generic_type_param->getIndex(), assoc.GetString().data()); return true; } @@ -3999,7 +3993,6 @@ void SwiftLanguageRuntime::DidFinishExecutingUserExpression( llvm::Optional SwiftLanguageRuntime::GetErrorReturnLocationAfterReturn( lldb::StackFrameSP frame_sp) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); llvm::Optional error_val; llvm::StringRef error_reg_name; @@ -4051,7 +4044,6 @@ llvm::Optional SwiftLanguageRuntime::GetErrorReturnLocationAfterReturn( llvm::Optional SwiftLanguageRuntime::GetErrorReturnLocationBeforeReturn( lldb::StackFrameSP frame_sp, bool &need_to_check_after_return) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); llvm::Optional error_val; if (!frame_sp) @@ -4075,8 +4067,6 @@ llvm::Optional SwiftLanguageRuntime::GetErrorReturnLocationBeforeReturn( if (error_loc_val_sp && error_loc_val_sp->GetError().Success()) error_val = error_loc_val_sp->GetValue(); -// if (log) -// log->Printf("Found return address: 0x%" PRIu64 " from error variable.", return_addr); return error_val; } @@ -4276,8 +4266,6 @@ class CommandObjectSwift_RefCount : public CommandObjectRaw { case ReferenceCountType::eReferenceWeak: Kind = "Weak"; break; - default: - llvm_unreachable("Unhandled refcount type in switch!"); } EvaluateExpressionOptions eval_options; diff --git a/source/Target/SystemRuntime.cpp b/source/Target/SystemRuntime.cpp index 3fdf6daa6afa..2006ba584267 100644 --- a/source/Target/SystemRuntime.cpp +++ b/source/Target/SystemRuntime.cpp @@ -1,16 +1,11 @@ //===-- SystemRuntime.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/SystemRuntime.h" #include "lldb/Core/PluginManager.h" #include "lldb/Target/Process.h" diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp index 1788b9567a4a..62a6f137cb88 100644 --- a/source/Target/Target.cpp +++ b/source/Target/Target.cpp @@ -1,18 +1,12 @@ //===-- Target.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -#include -// Other libraries and framework includes -#include "swift/Frontend/Frontend.h" -// Project includes +#include "lldb/Target/Target.h" #include "Plugins/ExpressionParser/Clang/ClangASTSource.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" @@ -26,14 +20,12 @@ #include "lldb/Breakpoint/BreakpointResolverScripted.h" #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Event.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Section.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Core/Section.h" #include "lldb/Core/SourceManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Core/ValueObject.h" @@ -60,15 +52,18 @@ #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/SystemRuntime.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" +#include +#include "swift/Frontend/Frontend.h" #include "swift/SIL/SILModule.h" using namespace lldb; @@ -205,6 +200,8 @@ void Target::DeleteCurrentProcess() { const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file) { + if (!listener_sp) + listener_sp = GetDebugger().GetListener(); DeleteCurrentProcess(); m_process_sp = Process::FindPlugin(shared_from_this(), plugin_name, listener_sp, crash_file); @@ -435,12 +432,11 @@ Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, false); } -BreakpointSP -Target::CreateBreakpoint(const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, - const char *func_name, uint32_t func_name_type_mask, - LanguageType language, lldb::addr_t offset, - LazyBool skip_prologue, bool internal, bool hardware) { +BreakpointSP Target::CreateBreakpoint( + const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_name, + FunctionNameType func_name_type_mask, LanguageType language, + lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool hardware) { BreakpointSP bp_sp; if (func_name) { SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList( @@ -463,9 +459,9 @@ lldb::BreakpointSP Target::CreateBreakpoint(const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const std::vector &func_names, - uint32_t func_name_type_mask, LanguageType language, - lldb::addr_t offset, LazyBool skip_prologue, - bool internal, bool hardware) { + FunctionNameType func_name_type_mask, + LanguageType language, lldb::addr_t offset, + LazyBool skip_prologue, bool internal, bool hardware) { BreakpointSP bp_sp; size_t num_names = func_names.size(); if (num_names > 0) { @@ -485,11 +481,13 @@ Target::CreateBreakpoint(const FileSpecList *containingModules, return bp_sp; } -BreakpointSP Target::CreateBreakpoint( - const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, const char *func_names[], - size_t num_names, uint32_t func_name_type_mask, LanguageType language, - lldb::addr_t offset, LazyBool skip_prologue, bool internal, bool hardware) { +BreakpointSP +Target::CreateBreakpoint(const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, + const char *func_names[], size_t num_names, + FunctionNameType func_name_type_mask, + LanguageType language, lldb::addr_t offset, + LazyBool skip_prologue, bool internal, bool hardware) { BreakpointSP bp_sp; if (num_names > 0) { SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList( @@ -785,7 +783,7 @@ void Target::GetBreakpointNames(std::vector &names) for (auto bp_name : m_breakpoint_names) { names.push_back(bp_name.first.AsCString()); } - std::sort(names.begin(), names.end()); + llvm::sort(names.begin(), names.end()); } bool Target::ProcessIsValid() { @@ -1473,20 +1471,20 @@ void Target::SetExecutableModule(ModuleSP &executable_sp, FileSpecList dependent_files; ObjectFile *executable_objfile = executable_sp->GetObjectFile(); - bool load_dependens; + bool load_dependents = true; switch (load_dependent_files) { case eLoadDependentsDefault: - load_dependens = executable_sp->IsExecutable(); + load_dependents = executable_sp->IsExecutable(); break; case eLoadDependentsYes: - load_dependens = true; + load_dependents = true; break; case eLoadDependentsNo: - load_dependens = false; + load_dependents = false; break; } - if (executable_objfile && load_dependens) { + if (executable_objfile && load_dependents) { executable_objfile->GetDependentModules(dependent_files); for (uint32_t i = 0; i < dependent_files.GetSize(); i++) { FileSpec dependent_file_spec( @@ -1510,13 +1508,33 @@ void Target::SetExecutableModule(ModuleSP &executable_sp, } } -bool Target::SetArchitecture(const ArchSpec &arch_spec) { +bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET)); bool missing_local_arch = !m_arch.GetSpec().IsValid(); bool replace_local_arch = true; bool compatible_local_arch = false; ArchSpec other(arch_spec); + // Changing the architecture might mean that the currently selected platform + // isn't compatible. Set the platform correctly if we are asked to do so, + // otherwise assume the user will set the platform manually. + if (set_platform) { + if (other.IsValid()) { + auto platform_sp = GetPlatform(); + if (!platform_sp || + !platform_sp->IsCompatibleArchitecture(other, false, nullptr)) { + ArchSpec platform_arch; + auto arch_platform_sp = + Platform::GetPlatformForArchitecture(other, &platform_arch); + if (arch_platform_sp) { + SetPlatform(arch_platform_sp); + if (platform_arch.IsValid()) + other = platform_arch; + } + } + } + } + if (!missing_local_arch) { if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) { other.MergeFrom(m_arch.GetSpec()); @@ -2693,249 +2711,22 @@ lldb::addr_t Target::GetPersistentSymbol(const ConstString &name) { lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr, AddressClass addr_class) const { - addr_t code_addr = load_addr; - switch (m_arch.GetSpec().GetMachine()) { - case llvm::Triple::mips: - case llvm::Triple::mipsel: - case llvm::Triple::mips64: - case llvm::Triple::mips64el: - switch (addr_class) { - case AddressClass::eData: - case AddressClass::eDebug: - return LLDB_INVALID_ADDRESS; - - case AddressClass::eUnknown: - case AddressClass::eInvalid: - case AddressClass::eCode: - case AddressClass::eCodeAlternateISA: - case AddressClass::eRuntime: - if ((code_addr & 2ull) || (addr_class == AddressClass::eCodeAlternateISA)) - code_addr |= 1ull; - break; - } - break; - - case llvm::Triple::arm: - case llvm::Triple::thumb: - switch (addr_class) { - case AddressClass::eData: - case AddressClass::eDebug: - return LLDB_INVALID_ADDRESS; - - case AddressClass::eUnknown: - case AddressClass::eInvalid: - case AddressClass::eCode: - case AddressClass::eCodeAlternateISA: - case AddressClass::eRuntime: - // Check if bit zero it no set? - if ((code_addr & 1ull) == 0) { - // Bit zero isn't set, check if the address is a multiple of 2? - if (code_addr & 2ull) { - // The address is a multiple of 2 so it must be thumb, set bit zero - code_addr |= 1ull; - } else if (addr_class == AddressClass::eCodeAlternateISA) { - // We checked the address and the address claims to be the alternate - // ISA which means thumb, so set bit zero. - code_addr |= 1ull; - } - } - break; - } - break; - - default: - break; - } - return code_addr; + auto arch_plugin = GetArchitecturePlugin(); + return arch_plugin ? + arch_plugin->GetCallableLoadAddress(load_addr, addr_class) : load_addr; } lldb::addr_t Target::GetOpcodeLoadAddress(lldb::addr_t load_addr, AddressClass addr_class) const { - addr_t opcode_addr = load_addr; - switch (m_arch.GetSpec().GetMachine()) { - case llvm::Triple::mips: - case llvm::Triple::mipsel: - case llvm::Triple::mips64: - case llvm::Triple::mips64el: - case llvm::Triple::arm: - case llvm::Triple::thumb: - switch (addr_class) { - case AddressClass::eData: - case AddressClass::eDebug: - return LLDB_INVALID_ADDRESS; - - case AddressClass::eInvalid: - case AddressClass::eUnknown: - case AddressClass::eCode: - case AddressClass::eCodeAlternateISA: - case AddressClass::eRuntime: - opcode_addr &= ~(1ull); - break; - } - break; - - default: - break; - } - return opcode_addr; + auto arch_plugin = GetArchitecturePlugin(); + return arch_plugin ? + arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class) : load_addr; } lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) { - addr_t breakable_addr = addr; - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); - - switch (m_arch.GetSpec().GetMachine()) { - default: - break; - case llvm::Triple::mips: - case llvm::Triple::mipsel: - case llvm::Triple::mips64: - case llvm::Triple::mips64el: { - addr_t function_start = 0; - addr_t current_offset = 0; - uint32_t loop_count = 0; - Address resolved_addr; - uint32_t arch_flags = m_arch.GetSpec().GetFlags(); - bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16; - bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips; - SectionLoadList §ion_load_list = GetSectionLoadList(); - - if (section_load_list.IsEmpty()) - // No sections are loaded, so we must assume we are not running yet and - // need to operate only on file address. - m_images.ResolveFileAddress(addr, resolved_addr); - else - section_load_list.ResolveLoadAddress(addr, resolved_addr); - - // Get the function boundaries to make sure we don't scan back before the - // beginning of the current function. - ModuleSP temp_addr_module_sp(resolved_addr.GetModule()); - if (temp_addr_module_sp) { - SymbolContext sc; - uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; - temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, - resolve_scope, sc); - Address sym_addr; - if (sc.function) - sym_addr = sc.function->GetAddressRange().GetBaseAddress(); - else if (sc.symbol) - sym_addr = sc.symbol->GetAddress(); - - function_start = sym_addr.GetLoadAddress(this); - if (function_start == LLDB_INVALID_ADDRESS) - function_start = sym_addr.GetFileAddress(); - - if (function_start) - current_offset = addr - function_start; - } - - // If breakpoint address is start of function then we dont have to do - // anything. - if (current_offset == 0) - return breakable_addr; - else - loop_count = current_offset / 2; - - if (loop_count > 3) { - // Scan previous 6 bytes - if (IsMips16 | IsMicromips) - loop_count = 3; - // For mips-only, instructions are always 4 bytes, so scan previous 4 - // bytes only. - else - loop_count = 2; - } - - // Create Disassembler Instance - lldb::DisassemblerSP disasm_sp( - Disassembler::FindPlugin(m_arch.GetSpec(), nullptr, nullptr)); - - ExecutionContext exe_ctx; - CalculateExecutionContext(exe_ctx); - InstructionList instruction_list; - InstructionSP prev_insn; - bool prefer_file_cache = true; // Read from file - uint32_t inst_to_choose = 0; - - for (uint32_t i = 1; i <= loop_count; i++) { - // Adjust the address to read from. - resolved_addr.Slide(-2); - AddressRange range(resolved_addr, i * 2); - uint32_t insn_size = 0; - - disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache); - - uint32_t num_insns = disasm_sp->GetInstructionList().GetSize(); - if (num_insns) { - prev_insn = disasm_sp->GetInstructionList().GetInstructionAtIndex(0); - insn_size = prev_insn->GetOpcode().GetByteSize(); - if (i == 1 && insn_size == 2) { - // This looks like a valid 2-byte instruction (but it could be a part - // of upper 4 byte instruction). - instruction_list.Append(prev_insn); - inst_to_choose = 1; - } else if (i == 2) { - // Here we may get one 4-byte instruction or two 2-byte instructions. - if (num_insns == 2) { - // Looks like there are two 2-byte instructions above our - // breakpoint target address. Now the upper 2-byte instruction is - // either a valid 2-byte instruction or could be a part of it's - // upper 4-byte instruction. In both cases we don't care because in - // this case lower 2-byte instruction is definitely a valid - // instruction and whatever i=1 iteration has found out is true. - inst_to_choose = 1; - break; - } else if (insn_size == 4) { - // This instruction claims its a valid 4-byte instruction. But it - // could be a part of it's upper 4-byte instruction. Lets try - // scanning upper 2 bytes to verify this. - instruction_list.Append(prev_insn); - inst_to_choose = 2; - } - } else if (i == 3) { - if (insn_size == 4) - // FIXME: We reached here that means instruction at [target - 4] has - // already claimed to be a 4-byte instruction, and now instruction - // at [target - 6] is also claiming that it's a 4-byte instruction. - // This can not be true. In this case we can not decide the valid - // previous instruction so we let lldb set the breakpoint at the - // address given by user. - inst_to_choose = 0; - else - // This is straight-forward - inst_to_choose = 2; - break; - } - } else { - // Decode failed, bytes do not form a valid instruction. So whatever - // previous iteration has found out is true. - if (i > 1) { - inst_to_choose = i - 1; - break; - } - } - } - - // Check if we are able to find any valid instruction. - if (inst_to_choose) { - if (inst_to_choose > instruction_list.GetSize()) - inst_to_choose--; - prev_insn = instruction_list.GetInstructionAtIndex(inst_to_choose - 1); - - if (prev_insn->HasDelaySlot()) { - uint32_t shift_size = prev_insn->GetOpcode().GetByteSize(); - // Adjust the breakable address - breakable_addr = addr - shift_size; - if (log) - log->Printf("Target::%s Breakpoint at 0x%8.8" PRIx64 - " is adjusted to 0x%8.8" PRIx64 " due to delay slot\n", - __FUNCTION__, addr, breakable_addr); - } - } - break; - } - } - return breakable_addr; + auto arch_plugin = GetArchitecturePlugin(); + return arch_plugin ? + arch_plugin->GetBreakableLoadAddress(addr, *this) : addr; } SourceManager &Target::GetSourceManager() { @@ -3359,18 +3150,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) { PlatformSP platform_sp(GetPlatform()); - // Finalize the file actions, and if none were given, default to opening up a - // pseudo terminal - const bool default_to_use_pty = platform_sp ? platform_sp->IsHost() : false; - if (log) - log->Printf("Target::%s have platform=%s, platform_sp->IsHost()=%s, " - "default_to_use_pty=%s", - __FUNCTION__, platform_sp ? "true" : "false", - platform_sp ? (platform_sp->IsHost() ? "true" : "false") - : "n/a", - default_to_use_pty ? "true" : "false"); - - launch_info.FinalizeFileActions(this, default_to_use_pty); + FinalizeFileActions(launch_info); if (state == eStateConnected) { if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) { @@ -3411,8 +3191,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) { } else { // Use a Process plugin to construct the process. const char *plugin_name = launch_info.GetProcessPluginName(); - CreateProcess(launch_info.GetListenerForProcess(debugger), plugin_name, - nullptr); + CreateProcess(launch_info.GetListener(), plugin_name, nullptr); } // Since we didn't have a platform launch the process, launch it here. @@ -3587,6 +3366,86 @@ Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) { return error; } +void Target::FinalizeFileActions(ProcessLaunchInfo &info) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); + + // Finalize the file actions, and if none were given, default to opening up a + // pseudo terminal + PlatformSP platform_sp = GetPlatform(); + const bool default_to_use_pty = + m_platform_sp ? m_platform_sp->IsHost() : false; + LLDB_LOG( + log, + "have platform={0}, platform_sp->IsHost()={1}, default_to_use_pty={2}", + bool(platform_sp), + platform_sp ? (platform_sp->IsHost() ? "true" : "false") : "n/a", + default_to_use_pty); + + // If nothing for stdin or stdout or stderr was specified, then check the + // process for any default settings that were set with "settings set" + if (info.GetFileActionForFD(STDIN_FILENO) == nullptr || + info.GetFileActionForFD(STDOUT_FILENO) == nullptr || + info.GetFileActionForFD(STDERR_FILENO) == nullptr) { + LLDB_LOG(log, "at least one of stdin/stdout/stderr was not set, evaluating " + "default handling"); + + if (info.GetFlags().Test(eLaunchFlagLaunchInTTY)) { + // Do nothing, if we are launching in a remote terminal no file actions + // should be done at all. + return; + } + + if (info.GetFlags().Test(eLaunchFlagDisableSTDIO)) { + LLDB_LOG(log, "eLaunchFlagDisableSTDIO set, adding suppression action " + "for stdin, stdout and stderr"); + info.AppendSuppressFileAction(STDIN_FILENO, true, false); + info.AppendSuppressFileAction(STDOUT_FILENO, false, true); + info.AppendSuppressFileAction(STDERR_FILENO, false, true); + } else { + // Check for any values that might have gotten set with any of: (lldb) + // settings set target.input-path (lldb) settings set target.output-path + // (lldb) settings set target.error-path + FileSpec in_file_spec; + FileSpec out_file_spec; + FileSpec err_file_spec; + // Only override with the target settings if we don't already have an + // action for in, out or error + if (info.GetFileActionForFD(STDIN_FILENO) == nullptr) + in_file_spec = GetStandardInputPath(); + if (info.GetFileActionForFD(STDOUT_FILENO) == nullptr) + out_file_spec = GetStandardOutputPath(); + if (info.GetFileActionForFD(STDERR_FILENO) == nullptr) + err_file_spec = GetStandardErrorPath(); + + LLDB_LOG(log, "target stdin='{0}', target stdout='{1}', stderr='{1}'", + in_file_spec, out_file_spec, err_file_spec); + + if (in_file_spec) { + info.AppendOpenFileAction(STDIN_FILENO, in_file_spec, true, false); + LLDB_LOG(log, "appended stdin open file action for {0}", in_file_spec); + } + + if (out_file_spec) { + info.AppendOpenFileAction(STDOUT_FILENO, out_file_spec, false, true); + LLDB_LOG(log, "appended stdout open file action for {0}", + out_file_spec); + } + + if (err_file_spec) { + info.AppendOpenFileAction(STDERR_FILENO, err_file_spec, false, true); + LLDB_LOG(log, "appended stderr open file action for {0}", + err_file_spec); + } + + if (default_to_use_pty && + (!in_file_spec || !out_file_spec || !err_file_spec)) { + llvm::Error Err = info.SetUpPtyRedirection(); + LLDB_LOG_ERROR(log, std::move(Err), "SetUpPtyRedirection failed: {0}"); + } + } + } +} + //-------------------------------------------------------------- // Target::StopHook //-------------------------------------------------------------- @@ -3759,7 +3618,8 @@ static constexpr PropertyDefinition g_properties[] = { "whose paths don't match the local file system."}, {"debug-file-search-paths", OptionValue::eTypeFileSpecList, false, 0, nullptr, {}, - "List of directories to be searched when locating debug symbol files."}, + "List of directories to be searched when locating debug symbol files. " + "See also symbols.enable-external-lookup."}, {"clang-module-search-paths", OptionValue::eTypeFileSpecList, false, 0, nullptr, {}, "List of directories to be searched when locating modules for Clang."}, @@ -3894,6 +3754,8 @@ static constexpr PropertyDefinition g_properties[] = { {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false, nullptr, {}, "If true, LLDB will show variables that are meant to " "support the operation of a language's runtime support."}, + {"display-recognized-arguments", OptionValue::eTypeBoolean, false, false, + nullptr, {}, "Show recognized arguments in variable listings by default."}, {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {}, "Disable lock-step debugging, instead control threads independently."}, {"require-hardware-breakpoint", OptionValue::eTypeBoolean, false, 0, @@ -3946,6 +3808,7 @@ enum { ePropertyTrapHandlerNames, ePropertySDKPath, ePropertyDisplayRuntimeSupportValues, + ePropertyDisplayRecognizedArguments, ePropertyNonStopModeEnabled, ePropertyRequireHardwareBreakpoints, ePropertyExperimental, @@ -4557,6 +4420,16 @@ void TargetProperties::SetDisplayRuntimeSupportValues(bool b) { m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); } +bool TargetProperties::GetDisplayRecognizedArguments() const { + const uint32_t idx = ePropertyDisplayRecognizedArguments; + return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); +} + +void TargetProperties::SetDisplayRecognizedArguments(bool b) { + const uint32_t idx = ePropertyDisplayRecognizedArguments; + m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b); +} + bool TargetProperties::GetNonStopModeEnabled() const { const uint32_t idx = ePropertyNonStopModeEnabled; return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx, false); diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp index 02b3ea8b7905..c0d0f91f6f23 100644 --- a/source/Target/TargetList.cpp +++ b/source/Target/TargetList.cpp @@ -1,20 +1,15 @@ //===-- TargetList.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// Project includes #include "lldb/Target/TargetList.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Event.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -22,10 +17,12 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/TildeExpressionResolver.h" #include "lldb/Utility/Timer.h" -// Other libraries and framework includes #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" @@ -120,8 +117,8 @@ Status TargetList::CreateTargetInternal( if (!user_exe_path.empty()) { ModuleSpecList module_specs; ModuleSpec module_spec; - module_spec.GetFileSpec().SetFile(user_exe_path, true, - FileSpec::Style::native); + module_spec.GetFileSpec().SetFile(user_exe_path, FileSpec::Style::native); + FileSystem::Instance().Resolve(module_spec.GetFileSpec()); // Resolve the executable in case we are given a path to a application // bundle like a .app bundle on MacOSX @@ -236,7 +233,7 @@ Status TargetList::CreateTargetInternal( // All platforms for all modules in the executable match, so we can // select this platform platform_sp = platforms.front(); - } else if (more_than_one_platforms == false) { + } else if (!more_than_one_platforms) { // No platforms claim to support this file error.SetErrorString("No matching platforms found for this file, " "specify one with the --platform option"); @@ -346,8 +343,8 @@ Status TargetList::CreateTargetInternal(Debugger &debugger, if (!arch.IsValid()) arch = specified_arch; - FileSpec file(user_exe_path, false); - if (!file.Exists() && user_exe_path.startswith("~")) { + FileSpec file(user_exe_path); + if (!FileSystem::Instance().Exists(file) && user_exe_path.startswith("~")) { // we want to expand the tilde but we don't want to resolve any symbolic // links so we can't use the FileSpec constructor's resolve flag llvm::SmallString<64> unglobbed_path; @@ -355,24 +352,24 @@ Status TargetList::CreateTargetInternal(Debugger &debugger, Resolver.ResolveFullPath(user_exe_path, unglobbed_path); if (unglobbed_path.empty()) - file = FileSpec(user_exe_path, false); + file = FileSpec(user_exe_path); else - file = FileSpec(unglobbed_path.c_str(), false); + file = FileSpec(unglobbed_path.c_str()); } bool user_exe_path_is_bundle = false; char resolved_bundle_exe_path[PATH_MAX]; resolved_bundle_exe_path[0] = '\0'; if (file) { - if (llvm::sys::fs::is_directory(file.GetPath())) + if (FileSystem::Instance().IsDirectory(file)) user_exe_path_is_bundle = true; if (file.IsRelative() && !user_exe_path.empty()) { llvm::SmallString<64> cwd; if (! llvm::sys::fs::current_path(cwd)) { - FileSpec cwd_file(cwd.c_str(), false); + FileSpec cwd_file(cwd.c_str()); cwd_file.AppendPathComponent(file); - if (cwd_file.Exists()) + if (FileSystem::Instance().Exists(cwd_file)) file = cwd_file; } } diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp index f657f0488774..3b14937b5810 100644 --- a/source/Target/Thread.cpp +++ b/source/Target/Thread.cpp @@ -1,16 +1,11 @@ //===-- Thread.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "Plugins/Process/Utility/UnwindLLDB.h" #include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h" @@ -18,7 +13,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" @@ -28,8 +22,10 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/StackFrameRecognizer.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/SystemRuntime.h" #include "lldb/Target/Target.h" @@ -49,6 +45,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-enumerations.h" @@ -1044,9 +1041,11 @@ void Thread::PushPlan(ThreadPlanSP &thread_plan_sp) { if (thread_plan_sp) { // If the thread plan doesn't already have a tracer, give it its parent's // tracer: - if (!thread_plan_sp->GetThreadPlanTracer()) + if (!thread_plan_sp->GetThreadPlanTracer()) { + assert(!m_plan_stack.empty()); thread_plan_sp->SetThreadPlanTracer( m_plan_stack.back()->GetThreadPlanTracer()); + } m_plan_stack.push_back(thread_plan_sp); thread_plan_sp->DidPush(); @@ -2236,3 +2235,32 @@ Status Thread::StepOut() { } return error; } + +ValueObjectSP Thread::GetCurrentException() { + if (auto frame_sp = GetStackFrameAtIndex(0)) + if (auto recognized_frame = frame_sp->GetRecognizedFrame()) + if (auto e = recognized_frame->GetExceptionObject()) + return e; + + // FIXME: For now, only ObjC exceptions are supported. This should really + // iterate over all language runtimes and ask them all to give us the current + // exception. + if (auto runtime = GetProcess()->GetObjCLanguageRuntime()) + if (auto e = runtime->GetExceptionObjectForThread(shared_from_this())) + return e; + + return ValueObjectSP(); +} + +ThreadSP Thread::GetCurrentExceptionBacktrace() { + ValueObjectSP exception = GetCurrentException(); + if (!exception) return ThreadSP(); + + // FIXME: For now, only ObjC exceptions are supported. This should really + // iterate over all language runtimes and ask them all to give us the current + // exception. + auto runtime = GetProcess()->GetObjCLanguageRuntime(); + if (!runtime) return ThreadSP(); + + return runtime->GetBacktraceThreadFromException(exception); +} diff --git a/source/Target/ThreadCollection.cpp b/source/Target/ThreadCollection.cpp index 2d63b67a6dbe..cf3c1e242999 100644 --- a/source/Target/ThreadCollection.cpp +++ b/source/Target/ThreadCollection.cpp @@ -1,9 +1,8 @@ //===-- ThreadCollection.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp index ee57a401f742..86248da49936 100644 --- a/source/Target/ThreadList.cpp +++ b/source/Target/ThreadList.cpp @@ -1,21 +1,15 @@ //===-- ThreadList.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes #include -// C++ Includes #include -// Other libraries and framework includes -// Project includes -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" @@ -23,6 +17,7 @@ #include "lldb/Target/ThreadPlan.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp index 31576b38260c..6570e1d103e0 100644 --- a/source/Target/ThreadPlan.cpp +++ b/source/Target/ThreadPlan.cpp @@ -1,24 +1,19 @@ //===-- ThreadPlan.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlan.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp index 65b114584177..2cce1e8e1f4e 100644 --- a/source/Target/ThreadPlanBase.cpp +++ b/source/Target/ThreadPlanBase.cpp @@ -1,18 +1,13 @@ //===-- ThreadPlanBase.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/ThreadPlanBase.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes // #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -61,10 +56,7 @@ bool ThreadPlanBase::ValidatePlan(Stream *error) { return true; } bool ThreadPlanBase::DoPlanExplainsStop(Event *event_ptr) { // The base plan should defer to its tracer, since by default it always // handles the stop. - if (TracerExplainsStop()) - return false; - else - return true; + return !TracerExplainsStop(); } Vote ThreadPlanBase::ShouldReportStop(Event *event_ptr) { diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp index d29ebc43efc4..94a69ecadf0d 100644 --- a/source/Target/ThreadPlanCallFunction.cpp +++ b/source/Target/ThreadPlanCallFunction.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanCallFunction.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -466,7 +461,7 @@ void ThreadPlanCallFunction::SetBreakpoints() { if (!backstop_name.IsEmpty()) { FileSpecList stdlib_module_list; stdlib_module_list.Append(FileSpec( - swift_runtime->GetStandardLibraryName().AsCString(), false)); + swift_runtime->GetStandardLibraryName().AsCString())); const LazyBool skip_prologue = eLazyBoolNo; const bool is_internal = true; const bool is_hardware = false; diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp index b90fd9edd766..8a7f2c7d95cc 100644 --- a/source/Target/ThreadPlanCallFunctionUsingABI.cpp +++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanCallFunctionUsingABI.h" #include "lldb/Core/Address.h" #include "lldb/Target/Process.h" diff --git a/source/Target/ThreadPlanCallOnFunctionExit.cpp b/source/Target/ThreadPlanCallOnFunctionExit.cpp index 2ea083dac45e..13e9542cfc39 100644 --- a/source/Target/ThreadPlanCallOnFunctionExit.cpp +++ b/source/Target/ThreadPlanCallOnFunctionExit.cpp @@ -1,9 +1,8 @@ //===-- ThreadPlanCallOnFunctionExit.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp index 7bf0dd39993e..fa83cf6f3346 100644 --- a/source/Target/ThreadPlanCallUserExpression.cpp +++ b/source/Target/ThreadPlanCallUserExpression.cpp @@ -1,19 +1,14 @@ //===-- ThreadPlanCallUserExpression.cpp -------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/ThreadPlanCallUserExpression.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Address.h" diff --git a/source/Target/ThreadPlanPython.cpp b/source/Target/ThreadPlanPython.cpp index 3a313e739ac4..f9c85ed6f64c 100644 --- a/source/Target/ThreadPlanPython.cpp +++ b/source/Target/ThreadPlanPython.cpp @@ -1,20 +1,14 @@ //===-- ThreadPlanPython.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/ThreadPlan.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Target/Process.h" @@ -24,6 +18,7 @@ #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanPython.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp index 6cd5d3ed67c1..4c76955c610b 100644 --- a/source/Target/ThreadPlanRunToAddress.cpp +++ b/source/Target/ThreadPlanRunToAddress.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanRunToAddress.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp index 53958841c765..cc520c56d62b 100644 --- a/source/Target/ThreadPlanShouldStopHere.cpp +++ b/source/Target/ThreadPlanShouldStopHere.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanShouldStopHere.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanShouldStopHere.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/LanguageRuntime.h" @@ -169,17 +164,17 @@ ThreadPlanSP ThreadPlanShouldStopHere::DefaultStepFromHereCallback( log->Printf("ThreadPlanShouldStopHere::DefaultStepFromHereCallback " "Queueing StepInRange plan to step through line 0 code."); return_plan_sp = - current_plan - ->GetThread().QueueThreadPlanForStepInRangeNoShouldStop( - false, range, sc, NULL, eOnlyDuringStepping, status, eLazyBoolCalculate, - eLazyBoolNo); + current_plan->GetThread().QueueThreadPlanForStepInRangeNoShouldStop( + false, range, sc, NULL, eOnlyDuringStepping, status, + eLazyBoolCalculate, eLazyBoolNo); } else { if (log) - log->Printf("ThreadPlanShouldStopHere::DefaultStepFromHereCallback " - "Queueing StepOverRange plan to step through line 0 code."); + log->Printf( + "ThreadPlanShouldStopHere::DefaultStepFromHereCallback " + "Queueing StepOverRange plan to step through line 0 code."); return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepOverRange( - false, range, sc, eOnlyDuringStepping, status, eLazyBoolNo); + false, range, sc, eOnlyDuringStepping, status, eLazyBoolNo); } } } diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp index 3904e3faf619..39f40e2ea863 100644 --- a/source/Target/ThreadPlanStepInRange.cpp +++ b/source/Target/ThreadPlanStepInRange.cpp @@ -1,17 +1,11 @@ //===-- ThreadPlanStepInRange.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes - #include "lldb/Target/ThreadPlanStepInRange.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Architecture.h" diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp index 2987135e1e49..b790db57851e 100644 --- a/source/Target/ThreadPlanStepInstruction.cpp +++ b/source/Target/ThreadPlanStepInstruction.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanStepInstruction.cpp ---------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp index b687efebb761..d19d3e8ca7ee 100644 --- a/source/Target/ThreadPlanStepOut.cpp +++ b/source/Target/ThreadPlanStepOut.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanStepOut.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Value.h" diff --git a/source/Target/ThreadPlanStepOverBreakpoint.cpp b/source/Target/ThreadPlanStepOverBreakpoint.cpp index 7497dbff1729..644a9762e41d 100644 --- a/source/Target/ThreadPlanStepOverBreakpoint.cpp +++ b/source/Target/ThreadPlanStepOverBreakpoint.cpp @@ -1,18 +1,13 @@ //===-- ThreadPlanStepOverBreakpoint.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Target/ThreadPlanStepOverBreakpoint.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/Log.h" diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp index beea2ce24fc3..47830bfdc068 100644 --- a/source/Target/ThreadPlanStepOverRange.cpp +++ b/source/Target/ThreadPlanStepOverRange.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanStepOverRange.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/CompileUnit.h" @@ -127,10 +122,7 @@ bool ThreadPlanStepOverRange::IsEquivalentContext( } } // Fall back to symbol if we have no decision from comp_unit/function/block. - if (m_addr_context.symbol && m_addr_context.symbol == context.symbol) { - return true; - } - return false; + return m_addr_context.symbol && m_addr_context.symbol == context.symbol; } bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) { diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp index 468b13e4f2b5..418485681bbd 100644 --- a/source/Target/ThreadPlanStepRange.cpp +++ b/source/Target/ThreadPlanStepRange.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanStepRange.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp index 9f4620f98772..4bd5f1cfa737 100644 --- a/source/Target/ThreadPlanStepThrough.cpp +++ b/source/Target/ThreadPlanStepThrough.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanStepThrough.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanStepThrough.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Target/CPPLanguageRuntime.h" diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp index 3a6fde6fb3b6..6bd543cdafdf 100644 --- a/source/Target/ThreadPlanStepUntil.cpp +++ b/source/Target/ThreadPlanStepUntil.cpp @@ -1,16 +1,11 @@ //===-- ThreadPlanStepUntil.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlanStepUntil.h" #include "lldb/Breakpoint/Breakpoint.h" diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp index acbbd4d8bcc2..129c0896d491 100644 --- a/source/Target/ThreadPlanTracer.cpp +++ b/source/Target/ThreadPlanTracer.cpp @@ -1,21 +1,17 @@ //===-- ThreadPlanTracer.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/DumpRegisterValue.h" #include "lldb/Core/Module.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Symbol/TypeList.h" @@ -30,6 +26,7 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/ThreadSpec.cpp b/source/Target/ThreadSpec.cpp index 444a5a5b262a..44418492650d 100644 --- a/source/Target/ThreadSpec.cpp +++ b/source/Target/ThreadSpec.cpp @@ -1,16 +1,11 @@ //===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadSpec.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/StructuredData.h" diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp index 7cd847a2f976..fc08e8438c56 100644 --- a/source/Target/UnixSignals.cpp +++ b/source/Target/UnixSignals.cpp @@ -1,16 +1,11 @@ //===-- UnixSignals.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/UnixSignals.h" #include "Plugins/Process/Utility/FreeBSDSignals.h" #include "Plugins/Process/Utility/LinuxSignals.h" diff --git a/source/Target/UnwindAssembly.cpp b/source/Target/UnwindAssembly.cpp index 3b2b7bf17025..869cf84865a1 100644 --- a/source/Target/UnwindAssembly.cpp +++ b/source/Target/UnwindAssembly.cpp @@ -1,16 +1,11 @@ //===-- UnwindAssembly.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/UnwindAssembly.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/PluginManager.h" diff --git a/source/Utility/ARM64_DWARF_Registers.h b/source/Utility/ARM64_DWARF_Registers.h index ce548a2aee80..64f69d643565 100644 --- a/source/Utility/ARM64_DWARF_Registers.h +++ b/source/Utility/ARM64_DWARF_Registers.h @@ -1,9 +1,8 @@ //===-- ARM64_DWARF_Registers.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/ARM64_ehframe_Registers.h b/source/Utility/ARM64_ehframe_Registers.h index 7f49314b3539..9b5cd931bf28 100644 --- a/source/Utility/ARM64_ehframe_Registers.h +++ b/source/Utility/ARM64_ehframe_Registers.h @@ -1,10 +1,9 @@ //===-- ARM64_ehframe_Registers.h -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/ARM_DWARF_Registers.h b/source/Utility/ARM_DWARF_Registers.h index ab91d8c99aa3..e33210dfbfbd 100644 --- a/source/Utility/ARM_DWARF_Registers.h +++ b/source/Utility/ARM_DWARF_Registers.h @@ -1,9 +1,8 @@ //===-- ARM_DWARF_Registers.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/ARM_ehframe_Registers.h b/source/Utility/ARM_ehframe_Registers.h index 2a4242314d52..1816b1d97497 100644 --- a/source/Utility/ARM_ehframe_Registers.h +++ b/source/Utility/ARM_ehframe_Registers.h @@ -1,10 +1,9 @@ //===-- ARM_ehframe_Registers.h -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/ArchSpec.cpp b/source/Utility/ArchSpec.cpp index ad4425b174f2..37432465745b 100644 --- a/source/Utility/ArchSpec.cpp +++ b/source/Utility/ArchSpec.cpp @@ -1,9 +1,8 @@ //===-- ArchSpec.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,15 +10,15 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/NameMatches.h" -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_C... +#include "lldb/lldb-defines.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/Twine.h" // for Twine +#include "llvm/ADT/Twine.h" #include "llvm/BinaryFormat/COFF.h" #include "llvm/BinaryFormat/ELF.h" -#include "llvm/BinaryFormat/MachO.h" // for CPUType::CPU_T... -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH +#include "llvm/BinaryFormat/MachO.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Host.h" using namespace lldb; @@ -610,10 +609,8 @@ const char *ArchSpec::GetArchitectureName() const { bool ArchSpec::IsMIPS() const { const llvm::Triple::ArchType machine = GetMachine(); - if (machine == llvm::Triple::mips || machine == llvm::Triple::mipsel || - machine == llvm::Triple::mips64 || machine == llvm::Triple::mips64el) - return true; - return false; + return machine == llvm::Triple::mips || machine == llvm::Triple::mipsel || + machine == llvm::Triple::mips64 || machine == llvm::Triple::mips64el; } std::string ArchSpec::GetTargetABI() const { @@ -815,6 +812,7 @@ bool ArchSpec::CharIsSignedByDefault() const { case llvm::Triple::ppc64le: case llvm::Triple::systemz: case llvm::Triple::xcore: + case llvm::Triple::arc: return false; } } @@ -1018,7 +1016,7 @@ bool ArchSpec::IsCompatibleMatch(const ArchSpec &rhs) const { return IsEqualTo(rhs, false); } -static bool isCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, +static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, llvm::Triple::EnvironmentType rhs) { if (lhs == rhs) return true; @@ -1095,9 +1093,7 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const { const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment(); - if (!isCompatibleEnvironment(lhs_triple_env, rhs_triple_env)) - return false; - return true; + return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env); } return false; } diff --git a/source/Utility/Args.cpp b/source/Utility/Args.cpp index 7c9fa8533695..6857c25472ec 100644 --- a/source/Utility/Args.cpp +++ b/source/Utility/Args.cpp @@ -1,9 +1,8 @@ //===-- Args.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/Baton.cpp b/source/Utility/Baton.cpp index 786be2fe9981..84e295e24686 100644 --- a/source/Utility/Baton.cpp +++ b/source/Utility/Baton.cpp @@ -1,9 +1,8 @@ //===-- Baton.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/Broadcaster.cpp b/source/Utility/Broadcaster.cpp similarity index 96% rename from source/Core/Broadcaster.cpp rename to source/Utility/Broadcaster.cpp index 198434b46c29..9e1b63807086 100644 --- a/source/Core/Broadcaster.cpp +++ b/source/Utility/Broadcaster.cpp @@ -1,27 +1,26 @@ //===-- Broadcaster.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/Broadcaster.h" +#include "lldb/Utility/Broadcaster.h" -#include "lldb/Core/Event.h" -#include "lldb/Core/Listener.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/Listener.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAnyCategoriesSet, Get... -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include // for find_if -#include // for make_shared -#include // for move +#include +#include +#include -#include // for assert -#include // for size_t +#include +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Utility/CMakeLists.txt b/source/Utility/CMakeLists.txt index 6040777276ec..4c981c6c54fa 100644 --- a/source/Utility/CMakeLists.txt +++ b/source/Utility/CMakeLists.txt @@ -9,7 +9,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) endif () if (NOT LLDB_DISABLE_LIBEDIT) - list(APPEND LLDB_SYSTEM_LIBS edit) + list(APPEND LLDB_SYSTEM_LIBS ${libedit_LIBRARIES}) endif() if (NOT LLDB_DISABLE_CURSES) list(APPEND LLDB_SYSTEM_LIBS ${CURSES_LIBRARIES}) @@ -45,6 +45,7 @@ add_lldb_library(lldbUtility ArchSpec.cpp Args.cpp Baton.cpp + Broadcaster.cpp Connection.cpp ConstString.cpp CompletionRequest.cpp @@ -53,17 +54,23 @@ add_lldb_library(lldbUtility DataEncoder.cpp DataExtractor.cpp Environment.cpp + FileCollector.cpp + Event.cpp FileSpec.cpp IOObject.cpp JSON.cpp LLDBAssert.cpp + Listener.cpp Log.cpp Logging.cpp NameMatches.cpp - Range.cpp + RegisterValue.cpp RegularExpression.cpp + Reproducer.cpp + Scalar.cpp SelectHelper.cpp SharingPtr.cpp + State.cpp Status.cpp Stream.cpp StreamCallback.cpp diff --git a/source/Utility/CompletionRequest.cpp b/source/Utility/CompletionRequest.cpp index c88747e2abe3..c62ec4f56ffa 100644 --- a/source/Utility/CompletionRequest.cpp +++ b/source/Utility/CompletionRequest.cpp @@ -1,9 +1,8 @@ //===-- CompletionRequest.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,11 +15,10 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos, int match_start_point, int max_return_elements, - StringList &matches) + CompletionResult &result) : m_command(command_line), m_raw_cursor_pos(raw_cursor_pos), m_match_start_point(match_start_point), - m_max_return_elements(max_return_elements), m_matches(&matches) { - matches.Clear(); + m_max_return_elements(max_return_elements), m_result(result) { // We parse the argument up to the cursor, so the last argument in // parsed_line is the one containing the cursor, and the cursor is after the @@ -36,8 +34,6 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line, m_cursor_char_position = strlen(m_partial_parsed_line.GetArgumentAtIndex(m_cursor_index)); - matches.Clear(); - const char *cursor = command_line.data() + raw_cursor_pos; if (raw_cursor_pos > 0 && cursor[-1] == ' ') { // We are just after a space. If we are in an argument, then we will @@ -58,3 +54,39 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line, } } } + +std::string CompletionResult::Completion::GetUniqueKey() const { + + // We build a unique key for this pair of completion:description. We + // prefix the key with the length of the completion string. This prevents + // that we could get any collisions from completions pairs such as these: + // "foo:", "bar" would be "foo:bar", but will now be: "4foo:bar" + // "foo", ":bar" would be "foo:bar", but will now be: "3foo:bar" + + std::string result; + result.append(std::to_string(m_completion.size())); + result.append(m_completion); + result.append(m_descripton); + return result; +} + +void CompletionResult::AddResult(llvm::StringRef completion, + llvm::StringRef description) { + Completion r(completion, description); + + // Add the completion if we haven't seen the same value before. + if (m_added_values.insert(r.GetUniqueKey()).second) + m_results.push_back(r); +} + +void CompletionResult::GetMatches(StringList &matches) const { + matches.Clear(); + for (const Completion &completion : m_results) + matches.AppendString(completion.m_completion); +} + +void CompletionResult::GetDescriptions(StringList &descriptions) const { + descriptions.Clear(); + for (const Completion &completion : m_results) + descriptions.AppendString(completion.m_descripton); +} diff --git a/source/Utility/Connection.cpp b/source/Utility/Connection.cpp index 9f6114f6ed5d..483a0c941be4 100644 --- a/source/Utility/Connection.cpp +++ b/source/Utility/Connection.cpp @@ -1,9 +1,8 @@ //===-- Connection.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/ConstString.cpp b/source/Utility/ConstString.cpp index 7916e2830473..80adb97bd307 100644 --- a/source/Utility/ConstString.cpp +++ b/source/Utility/ConstString.cpp @@ -1,9 +1,8 @@ //===-- ConstString.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,20 +11,20 @@ #include "lldb/Utility/Stream.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/iterator.h" // for iterator_facade_base -#include "llvm/Support/Allocator.h" // for BumpPtrAllocator -#include "llvm/Support/DJB.h" // for djbHash -#include "llvm/Support/FormatProviders.h" // for format_provider +#include "llvm/ADT/iterator.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/DJB.h" +#include "llvm/Support/FormatProviders.h" #include "llvm/Support/RWMutex.h" #include "llvm/Support/Threading.h" -#include // for min +#include #include -#include // for make_pair, pair +#include -#include // for PRIu64 -#include // for uint8_t, uint32_t, uint64_t -#include // for size_t, strlen +#include +#include +#include using namespace lldb_private; diff --git a/source/Utility/DataBufferHeap.cpp b/source/Utility/DataBufferHeap.cpp index e686ee8d35e5..5406cb97fe33 100644 --- a/source/Utility/DataBufferHeap.cpp +++ b/source/Utility/DataBufferHeap.cpp @@ -1,18 +1,13 @@ //===-- DataBufferHeap.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/DataBufferHeap.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes using namespace lldb_private; diff --git a/source/Utility/DataBufferLLVM.cpp b/source/Utility/DataBufferLLVM.cpp index 713c3c2814ea..4227e9b39960 100644 --- a/source/Utility/DataBufferLLVM.cpp +++ b/source/Utility/DataBufferLLVM.cpp @@ -1,9 +1,8 @@ //===--- DataBufferLLVM.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,8 +12,8 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" -#include // for assert -#include // for move +#include +#include using namespace lldb_private; @@ -27,34 +26,6 @@ DataBufferLLVM::DataBufferLLVM( DataBufferLLVM::~DataBufferLLVM() {} -std::shared_ptr -DataBufferLLVM::CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size, - uint64_t Offset) { - // If the file resides non-locally, pass the volatile flag so that we don't - // mmap it. - bool IsVolatile = !llvm::sys::fs::is_local(Path); - - auto Buffer = - llvm::WritableMemoryBuffer::getFileSlice(Path, Size, Offset, IsVolatile); - if (!Buffer) - return nullptr; - return std::shared_ptr( - new DataBufferLLVM(std::move(*Buffer))); -} - -std::shared_ptr -DataBufferLLVM::CreateFromPath(const llvm::Twine &Path) { - // If the file resides non-locally, pass the volatile flag so that we don't - // mmap it. - bool IsVolatile = !llvm::sys::fs::is_local(Path); - - auto Buffer = llvm::WritableMemoryBuffer::getFile(Path, -1, IsVolatile); - if (!Buffer) - return nullptr; - return std::shared_ptr( - new DataBufferLLVM(std::move(*Buffer))); -} - uint8_t *DataBufferLLVM::GetBytes() { return reinterpret_cast(Buffer->getBufferStart()); } diff --git a/source/Utility/DataEncoder.cpp b/source/Utility/DataEncoder.cpp index 7edee3c2f279..66a128f02eaa 100644 --- a/source/Utility/DataEncoder.cpp +++ b/source/Utility/DataEncoder.cpp @@ -1,9 +1,8 @@ //===-- DataEncoder.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -13,7 +12,7 @@ #include "lldb/Utility/Endian.h" #include "llvm/Support/Endian.h" -#include "llvm/Support/ErrorHandling.h" // for llvm_unreachable +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include diff --git a/source/Utility/DataExtractor.cpp b/source/Utility/DataExtractor.cpp index 947232943aa7..161a7a165999 100644 --- a/source/Utility/DataExtractor.cpp +++ b/source/Utility/DataExtractor.cpp @@ -1,18 +1,17 @@ //===-- DataExtractor.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/DataExtractor.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderBig -#include "lldb/lldb-forward.h" // for DataBufferSP -#include "lldb/lldb-types.h" // for offset_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" @@ -28,15 +27,15 @@ #include "llvm/Support/MD5.h" #include "llvm/Support/MathExtras.h" -#include // for min -#include // for array +#include +#include #include -#include // for uint8_t, uint32_t, uint64_t +#include #include -#include // for isprint -#include // for PRIx64, PRId64 -#include // for memcpy, memset, memchr +#include +#include +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Utility/Environment.cpp b/source/Utility/Environment.cpp index ea20267a2362..140533600712 100644 --- a/source/Utility/Environment.cpp +++ b/source/Utility/Environment.cpp @@ -1,9 +1,8 @@ //===-- Environment.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/Event.cpp b/source/Utility/Event.cpp similarity index 95% rename from source/Core/Event.cpp rename to source/Utility/Event.cpp index 3ebad7acdef7..f6256f7ca407 100644 --- a/source/Core/Event.cpp +++ b/source/Utility/Event.cpp @@ -1,24 +1,23 @@ //===-- Event.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/Event.h" +#include "lldb/Utility/Event.h" -#include "lldb/Core/Broadcaster.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Stream.h" -#include "lldb/Utility/StreamString.h" // for StreamString -#include "lldb/lldb-enumerations.h" // for Format::eFormatBytes +#include "lldb/Utility/StreamString.h" +#include "lldb/lldb-enumerations.h" #include -#include // for isprint +#include using namespace lldb; using namespace lldb_private; diff --git a/source/Utility/FileCollector.cpp b/source/Utility/FileCollector.cpp new file mode 100644 index 000000000000..1758ad8c82c9 --- /dev/null +++ b/source/Utility/FileCollector.cpp @@ -0,0 +1,148 @@ +//===-- FileCollector.cpp ---------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/FileCollector.h" + +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" + +using namespace lldb_private; +using namespace llvm; + +static bool IsCaseSensitivePath(StringRef path) { + SmallString<256> tmp_dest = path, upper_dest, real_dest; + + // Remove component traversals, links, etc. + if (!sys::fs::real_path(path, tmp_dest)) + return true; // Current default value in vfs.yaml + path = tmp_dest; + + // Change path to all upper case and ask for its real path, if the latter + // exists and is equal to path, it's not case sensitive. Default to case + // sensitive in the absence of real_path, since this is the YAMLVFSWriter + // default. + upper_dest = path.upper(); + if (sys::fs::real_path(upper_dest, real_dest) && path.equals(real_dest)) + return false; + return true; +} + +FileCollector::FileCollector(const FileSpec &root) : m_root(root) { + sys::fs::create_directories(m_root.GetPath(), true); +} + +bool FileCollector::GetRealPath(StringRef src_path, + SmallVectorImpl &result) { + SmallString<256> real_path; + StringRef FileName = sys::path::filename(src_path); + std::string directory = sys::path::parent_path(src_path).str(); + auto dir_with_symlink = m_symlink_map.find(directory); + + // Use real_path to fix any symbolic link component present in a path. + // Computing the real path is expensive, cache the search through the + // parent path directory. + if (dir_with_symlink == m_symlink_map.end()) { + auto ec = sys::fs::real_path(directory, real_path); + if (ec) + return false; + m_symlink_map[directory] = real_path.str(); + } else { + real_path = dir_with_symlink->second; + } + + sys::path::append(real_path, FileName); + result.swap(real_path); + return true; +} + +void FileCollector::AddFile(const Twine &file) { + std::lock_guard lock(m_mutex); + std::string file_str = file.str(); + if (MarkAsSeen(file_str)) + AddFileImpl(file_str); +} + +void FileCollector::AddFileImpl(StringRef src_path) { + std::string root = m_root.GetPath(); + + // We need an absolute src path to append to the root. + SmallString<256> absolute_src = src_path; + sys::fs::make_absolute(absolute_src); + + // Canonicalize src to a native path to avoid mixed separator styles. + sys::path::native(absolute_src); + + // Remove redundant leading "./" pieces and consecutive separators. + absolute_src = sys::path::remove_leading_dotslash(absolute_src); + + // Canonicalize the source path by removing "..", "." components. + SmallString<256> virtual_path = absolute_src; + sys::path::remove_dots(virtual_path, /*remove_dot_dot=*/true); + + // If a ".." component is present after a symlink component, remove_dots may + // lead to the wrong real destination path. Let the source be canonicalized + // like that but make sure we always use the real path for the destination. + SmallString<256> copy_from; + if (!GetRealPath(absolute_src, copy_from)) + copy_from = virtual_path; + + SmallString<256> dst_path = StringRef(root); + sys::path::append(dst_path, sys::path::relative_path(copy_from)); + + // Always map a canonical src path to its real path into the YAML, by doing + // this we map different virtual src paths to the same entry in the VFS + // overlay, which is a way to emulate symlink inside the VFS; this is also + // needed for correctness, not doing that can lead to module redefinition + // errors. + AddFileToMapping(virtual_path, dst_path); +} + +std::error_code FileCollector::CopyFiles(bool stop_on_error) { + for (auto &entry : m_vfs_writer.getMappings()) { + // Create directory tree. + if (std::error_code ec = + sys::fs::create_directories(sys::path::parent_path(entry.RPath), + /*IgnoreExisting=*/true)) { + if (stop_on_error) + return ec; + } + + // Copy file over. + if (std::error_code ec = sys::fs::copy_file(entry.VPath, entry.RPath)) { + if (stop_on_error) + return ec; + } + + // Copy over permissions. + if (auto perms = sys::fs::getPermissions(entry.VPath)) { + if (std::error_code ec = sys::fs::setPermissions(entry.RPath, *perms)) { + if (stop_on_error) + return ec; + } + } + } + return {}; +} + +std::error_code FileCollector::WriteMapping(const FileSpec &mapping_file) { + std::lock_guard lock(m_mutex); + + const std::string root = m_root.GetPath(); + m_vfs_writer.setCaseSensitivity(IsCaseSensitivePath(root)); + m_vfs_writer.setUseExternalNames(false); + + std::error_code ec; + raw_fd_ostream os(mapping_file.GetPath(), ec, sys::fs::F_Text); + if (ec) + return ec; + + m_vfs_writer.write(os); + + return {}; +} diff --git a/source/Utility/FileSpec.cpp b/source/Utility/FileSpec.cpp index 7135e33110d4..25d2278fe670 100644 --- a/source/Utility/FileSpec.cpp +++ b/source/Utility/FileSpec.cpp @@ -1,16 +1,14 @@ //===-- FileSpec.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" -#include "lldb/Utility/TildeExpressionResolver.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" @@ -22,14 +20,14 @@ #include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" -#include // for replace, min, unique -#include // for error_code -#include // for vector +#include +#include +#include -#include // for assert -#include // for PATH_MAX -#include // for size_t, NULL, snpr... -#include // for strcmp +#include +#include +#include +#include using namespace lldb; using namespace lldb_private; @@ -67,38 +65,17 @@ void Denormalize(llvm::SmallVectorImpl &path, FileSpec::Style style) { } // end anonymous namespace -void FileSpec::Resolve(llvm::SmallVectorImpl &path) { - if (path.empty()) - return; - - llvm::SmallString<32> Source(path.begin(), path.end()); - StandardTildeExpressionResolver Resolver; - Resolver.ResolveFullPath(Source, path); - - // Save a copy of the original path that's passed in - llvm::SmallString<128> original_path(path.begin(), path.end()); - - llvm::sys::fs::make_absolute(path); - if (!llvm::sys::fs::exists(path)) { - path.clear(); - path.append(original_path.begin(), original_path.end()); - } -} - FileSpec::FileSpec() : m_style(GetNativeStyle()) {} //------------------------------------------------------------------ // Default constructor that can take an optional full path to a file on disk. //------------------------------------------------------------------ -FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, Style style) - : m_style(style) { - SetFile(path, resolve_path, style); +FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) { + SetFile(path, style); } -FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, - const llvm::Triple &Triple) - : FileSpec{path, resolve_path, - Triple.isOSWindows() ? Style::windows : Style::posix} {} +FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &Triple) + : FileSpec{path, Triple.isOSWindows() ? Style::windows : Style::posix} {} //------------------------------------------------------------------ // Copy constructor @@ -227,16 +204,14 @@ const FileSpec &FileSpec::operator=(const FileSpec &rhs) { return *this; } -void FileSpec::SetFile(llvm::StringRef pathname, bool resolve) { - SetFile(pathname, resolve, m_style); -} +void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); } //------------------------------------------------------------------ // Update the contents of this object with a new path. The path will be split // up into a directory and filename and stored as uniqued string values for // quick comparison and efficient memory usage. //------------------------------------------------------------------ -void FileSpec::SetFile(llvm::StringRef pathname, bool resolve, Style style) { +void FileSpec::SetFile(llvm::StringRef pathname, Style style) { m_filename.Clear(); m_directory.Clear(); m_is_resolved = false; @@ -245,12 +220,7 @@ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve, Style style) { if (pathname.empty()) return; - llvm::SmallString<64> resolved(pathname); - - if (resolve) { - FileSpec::Resolve(resolved); - m_is_resolved = true; - } + llvm::SmallString<128> resolved(pathname); // Normalize the path by removing ".", ".." and other redundant components. if (needsNormalization(resolved)) @@ -273,15 +243,14 @@ void FileSpec::SetFile(llvm::StringRef pathname, bool resolve, Style style) { llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style); if(!filename.empty()) m_filename.SetString(filename); + llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style); if(!directory.empty()) m_directory.SetString(directory); } -void FileSpec::SetFile(llvm::StringRef path, bool resolve, - const llvm::Triple &Triple) { - return SetFile(path, resolve, - Triple.isOSWindows() ? Style::windows : Style::posix); +void FileSpec::SetFile(llvm::StringRef path, const llvm::Triple &Triple) { + return SetFile(path, Triple.isOSWindows() ? Style::windows : Style::posix); } //---------------------------------------------------------------------- @@ -316,49 +285,7 @@ bool FileSpec::FileEquals(const FileSpec &rhs) const { // Equal to operator //------------------------------------------------------------------ bool FileSpec::operator==(const FileSpec &rhs) const { - if (!FileEquals(rhs)) - return false; - if (DirectoryEquals(rhs)) - return true; - - // TODO: determine if we want to keep this code in here. - // The code below was added to handle a case where we were trying to set a - // file and line breakpoint and one path was resolved, and the other not and - // the directory was in a mount point that resolved to a more complete path: - // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling this out... - if (IsResolved() && rhs.IsResolved()) { - // Both paths are resolved, no need to look further... - return false; - } - - FileSpec resolved_lhs(*this); - - // If "this" isn't resolved, resolve it - if (!IsResolved()) { - if (resolved_lhs.ResolvePath()) { - // This path wasn't resolved but now it is. Check if the resolved - // directory is the same as our unresolved directory, and if so, we can - // mark this object as resolved to avoid more future resolves - m_is_resolved = (m_directory == resolved_lhs.m_directory); - } else - return false; - } - - FileSpec resolved_rhs(rhs); - if (!rhs.IsResolved()) { - if (resolved_rhs.ResolvePath()) { - // rhs's path wasn't resolved but now it is. Check if the resolved - // directory is the same as rhs's unresolved directory, and if so, we can - // mark this object as resolved to avoid more future resolves - rhs.m_is_resolved = (rhs.m_directory == resolved_rhs.m_directory); - } else - return false; - } - - // If we reach this point in the code we were able to resolve both paths and - // since we only resolve the paths if the basenames are equal, then we can - // just check if both directories are equal... - return DirectoryEquals(rhs); + return FileEquals(rhs) && DirectoryEquals(rhs); } //------------------------------------------------------------------ @@ -453,78 +380,8 @@ void FileSpec::Dump(Stream *s) const { } } -//------------------------------------------------------------------ -// Returns true if the file exists. -//------------------------------------------------------------------ -bool FileSpec::Exists() const { return llvm::sys::fs::exists(GetPath()); } - -bool FileSpec::Readable() const { - return GetPermissions() & llvm::sys::fs::perms::all_read; -} - -bool FileSpec::ResolveExecutableLocation() { - // CLEANUP: Use StringRef for string handling. - if (!m_directory) { - const char *file_cstr = m_filename.GetCString(); - if (file_cstr) { - const std::string file_str(file_cstr); - llvm::ErrorOr error_or_path = - llvm::sys::findProgramByName(file_str); - if (!error_or_path) - return false; - std::string path = error_or_path.get(); - llvm::StringRef dir_ref = llvm::sys::path::parent_path(path); - if (!dir_ref.empty()) { - // FindProgramByName returns "." if it can't find the file. - if (strcmp(".", dir_ref.data()) == 0) - return false; - - m_directory.SetCString(dir_ref.data()); - if (Exists()) - return true; - else { - // If FindProgramByName found the file, it returns the directory + - // filename in its return results. We need to separate them. - FileSpec tmp_file(dir_ref.data(), false); - if (tmp_file.Exists()) { - m_directory = tmp_file.m_directory; - return true; - } - } - } - } - } - - return false; -} - -bool FileSpec::ResolvePath() { - if (m_is_resolved) - return true; // We have already resolved this path - - // SetFile(...) will set m_is_resolved correctly if it can resolve the path - SetFile(GetPath(false), true); - return m_is_resolved; -} - -uint64_t FileSpec::GetByteSize() const { - uint64_t Size = 0; - if (llvm::sys::fs::file_size(GetPath(), Size)) - return 0; - return Size; -} - FileSpec::Style FileSpec::GetPathStyle() const { return m_style; } -uint32_t FileSpec::GetPermissions() const { - namespace fs = llvm::sys::fs; - fs::file_status st; - if (fs::status(GetPath(), st, false)) - return fs::perms::perms_not_known; - - return st.permissions(); -} - //------------------------------------------------------------------ // Directory string get accessor. //------------------------------------------------------------------ @@ -566,7 +423,7 @@ std::string FileSpec::GetPath(bool denormalize) const { } const char *FileSpec::GetCString(bool denormalize) const { - return ConstString{GetPath(denormalize)}.AsCString(NULL); + return ConstString{GetPath(denormalize)}.AsCString(nullptr); } void FileSpec::GetPath(llvm::SmallVectorImpl &path, @@ -602,39 +459,6 @@ size_t FileSpec::MemorySize() const { return m_filename.MemorySize() + m_directory.MemorySize(); } -void FileSpec::EnumerateDirectory(llvm::StringRef dir_path, - bool find_directories, bool find_files, - bool find_other, - EnumerateDirectoryCallbackType callback, - void *callback_baton) { - namespace fs = llvm::sys::fs; - std::error_code EC; - fs::recursive_directory_iterator Iter(dir_path, EC); - fs::recursive_directory_iterator End; - for (; Iter != End && !EC; Iter.increment(EC)) { - const auto &Item = *Iter; - llvm::ErrorOr Status = Item.status(); - if (!Status) - break; - if (!find_files && fs::is_regular_file(*Status)) - continue; - if (!find_directories && fs::is_directory(*Status)) - continue; - if (!find_other && fs::is_other(*Status)) - continue; - - FileSpec Spec(Item.path(), false); - auto Result = callback(callback_baton, Status->type(), Spec); - if (Result == eEnumerateDirectoryResultQuit) - return; - if (Result == eEnumerateDirectoryResultNext) { - // Default behavior is to recurse. Opt out if the callback doesn't want - // this behavior. - Iter.no_push(); - } - } -} - FileSpec FileSpec::CopyByAppendingPathComponent(llvm::StringRef component) const { FileSpec ret = *this; @@ -646,7 +470,7 @@ FileSpec FileSpec::CopyByRemovingLastPathComponent() const { llvm::SmallString<64> current_path; GetPath(current_path, false); if (llvm::sys::path::has_parent_path(current_path, m_style)) - return FileSpec(llvm::sys::path::parent_path(current_path, m_style), false, + return FileSpec(llvm::sys::path::parent_path(current_path, m_style), m_style); return *this; } @@ -664,7 +488,7 @@ void FileSpec::PrependPathComponent(llvm::StringRef component) { llvm::sys::path::append(new_path, llvm::sys::path::begin(current_path, m_style), llvm::sys::path::end(current_path), m_style); - SetFile(new_path, false, m_style); + SetFile(new_path, m_style); } void FileSpec::PrependPathComponent(const FileSpec &new_path) { @@ -675,7 +499,7 @@ void FileSpec::AppendPathComponent(llvm::StringRef component) { llvm::SmallString<64> current_path; GetPath(current_path, false); llvm::sys::path::append(current_path, m_style, component); - SetFile(current_path, false, m_style); + SetFile(current_path, m_style); } void FileSpec::AppendPathComponent(const FileSpec &new_path) { @@ -686,7 +510,7 @@ bool FileSpec::RemoveLastPathComponent() { llvm::SmallString<64> current_path; GetPath(current_path, false); if (llvm::sys::path::has_parent_path(current_path, m_style)) { - SetFile(llvm::sys::path::parent_path(current_path, m_style), false); + SetFile(llvm::sys::path::parent_path(current_path, m_style)); return true; } return false; @@ -732,6 +556,11 @@ bool FileSpec::IsAbsolute() const { return llvm::sys::path::is_absolute(current_path, m_style); } +void FileSpec::MakeAbsolute(const FileSpec &dir) { + if (IsRelative()) + PrependPathComponent(dir); +} + void llvm::format_provider::format(const FileSpec &F, raw_ostream &Stream, StringRef Style) { diff --git a/source/Utility/IOObject.cpp b/source/Utility/IOObject.cpp index df7929c4f911..5e3ccddb6a30 100644 --- a/source/Utility/IOObject.cpp +++ b/source/Utility/IOObject.cpp @@ -1,9 +1,8 @@ //===-- IOObject.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp index 7d70034ccabd..5c714b7b2a22 100644 --- a/source/Utility/JSON.cpp +++ b/source/Utility/JSON.cpp @@ -1,23 +1,22 @@ //===--------------------- JSON.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/JSON.h" -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" -#include // for PRIu64, PRId64 +#include #include -#include // for size_t -#include // for pair +#include +#include using namespace lldb_private; diff --git a/source/Utility/LLDBAssert.cpp b/source/Utility/LLDBAssert.cpp index 48c1b69e8947..5cbc61d4bec5 100644 --- a/source/Utility/LLDBAssert.cpp +++ b/source/Utility/LLDBAssert.cpp @@ -1,9 +1,8 @@ //===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -19,14 +18,14 @@ using namespace lldb_private; void lldb_private::lldb_assert(bool expression, const char *expr_text, const char *func, const char *file, unsigned int line) { - if (expression) - ; - else { - errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n", - expr_text, func, file, line); - errs() << "backtrace leading to the failure:\n"; - llvm::sys::PrintStackTrace(errs()); - errs() << "please file a bug report against lldb reporting this failure " - "log, and as many details as possible\n"; - } + if (LLVM_LIKELY(expression)) + return; + + errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n", + expr_text, func, file, line); + errs() << "backtrace leading to the failure:\n"; + llvm::sys::PrintStackTrace(errs()); + errs() << "please file a bug report against lldb reporting this failure " + "log, and as many details as possible\n"; + abort(); } diff --git a/source/Core/Listener.cpp b/source/Utility/Listener.cpp similarity index 96% rename from source/Core/Listener.cpp rename to source/Utility/Listener.cpp index a39ce6121b32..aeea5d6345a5 100644 --- a/source/Core/Listener.cpp +++ b/source/Utility/Listener.cpp @@ -1,25 +1,24 @@ //===-- Listener.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/Listener.h" +#include "lldb/Utility/Listener.h" -#include "lldb/Core/Broadcaster.h" -#include "lldb/Core/Event.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h" // for GetLogIfAllCategoriesSet, LIBL... +#include "lldb/Utility/Logging.h" -#include "llvm/ADT/Optional.h" // for Optional +#include "llvm/ADT/Optional.h" #include -#include // for make_shared -#include // for pair, make_pair +#include +#include using namespace lldb; using namespace lldb_private; @@ -251,9 +250,7 @@ class EventMatcher { return false; } - if (m_event_type_mask == 0 || m_event_type_mask & event_sp->GetType()) - return true; - return false; + return m_event_type_mask == 0 || m_event_type_mask & event_sp->GetType(); } private: diff --git a/source/Utility/Log.cpp b/source/Utility/Log.cpp index eb026fb04752..e7c6a852011d 100644 --- a/source/Utility/Log.cpp +++ b/source/Utility/Log.cpp @@ -1,9 +1,8 @@ //===-- Log.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,24 +11,24 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/Twine.h" // for operator+, Twine -#include "llvm/ADT/iterator.h" // for iterator_facade_base +#include "llvm/ADT/Twine.h" +#include "llvm/ADT/iterator.h" #include "llvm/Support/Chrono.h" -#include "llvm/Support/ManagedStatic.h" // for ManagedStatic +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/Signals.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" -#include // for duration, system_clock, syst... +#include #include #include -#include // for pair +#include -#include // for assert +#include #if defined(_WIN32) -#include // for getpid +#include #else #include #include diff --git a/source/Utility/Logging.cpp b/source/Utility/Logging.cpp index c9a6ef1bd1ea..ea774ce1503a 100644 --- a/source/Utility/Logging.cpp +++ b/source/Utility/Logging.cpp @@ -1,18 +1,17 @@ //===-- Logging.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/Logging.h" #include "lldb/Utility/Log.h" -#include "llvm/ADT/ArrayRef.h" // for ArrayRef +#include "llvm/ADT/ArrayRef.h" -#include // for va_end, va_list, va_start +#include using namespace lldb_private; diff --git a/source/Utility/NameMatches.cpp b/source/Utility/NameMatches.cpp index a76df3f929e8..5c9579ea7332 100644 --- a/source/Utility/NameMatches.cpp +++ b/source/Utility/NameMatches.cpp @@ -1,9 +1,8 @@ //===-- NameMatches.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/NameMatches.h" diff --git a/source/Utility/PPC64LE_DWARF_Registers.h b/source/Utility/PPC64LE_DWARF_Registers.h index 1a7503790e5d..548c1fda8600 100644 --- a/source/Utility/PPC64LE_DWARF_Registers.h +++ b/source/Utility/PPC64LE_DWARF_Registers.h @@ -1,9 +1,8 @@ //===-- PPC64LE_DWARF_Registers.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/PPC64LE_ehframe_Registers.h b/source/Utility/PPC64LE_ehframe_Registers.h index c5763b304711..77cb3e5924e7 100644 --- a/source/Utility/PPC64LE_ehframe_Registers.h +++ b/source/Utility/PPC64LE_ehframe_Registers.h @@ -1,9 +1,8 @@ //===-- PPC64LE_ehframe_Registers.h -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/PPC64_DWARF_Registers.h b/source/Utility/PPC64_DWARF_Registers.h index 7e3619e0da4d..6ba5b6ac3727 100644 --- a/source/Utility/PPC64_DWARF_Registers.h +++ b/source/Utility/PPC64_DWARF_Registers.h @@ -1,9 +1,8 @@ //===-- PPC64_DWARF_Registers.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/Range.cpp b/source/Utility/Range.cpp deleted file mode 100644 index 9d1d28ea484b..000000000000 --- a/source/Utility/Range.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//===--------------------- Range.cpp -----------------------------*- C++-*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Utility/Range.h" - -#include -#include - -using namespace lldb_utility; - -Range::Range(const Range &rng) : m_low(rng.m_low), m_high(rng.m_high) { - InitRange(); -} - -Range::Range(Range::ValueType low, Range::ValueType high) - : m_low(low), m_high(high) { - InitRange(); -} - -void Range::InitRange() { - if (m_low == OPEN_END) { - if (m_high == OPEN_END) - m_low = 0; - else { - // make an empty range - m_low = 1; - m_high = 0; - } - } -} - -Range &Range::operator=(const Range &rhs) { - if (&rhs != this) { - this->m_low = rhs.m_low; - this->m_high = rhs.m_high; - } - return *this; -} - -void Range::Flip() { std::swap(m_high, m_low); } - -void Range::Intersection(const Range &other) { - m_low = std::max(m_low, other.m_low); - m_high = std::min(m_high, other.m_high); -} - -void Range::Union(const Range &other) { - m_low = std::min(m_low, other.m_low); - m_high = std::max(m_high, other.m_high); -} - -void Range::Iterate(RangeCallback callback) { - ValueType counter = m_low; - while (counter <= m_high) { - bool should_continue = callback(counter); - if (!should_continue) - return; - counter++; - } -} - -bool Range::IsEmpty() { return (m_low > m_high); } - -Range::ValueType Range::GetSize() { - if (m_high == OPEN_END) - return OPEN_END; - if (m_high >= m_low) - return m_high - m_low + 1; - return 0; -} diff --git a/source/Core/RegisterValue.cpp b/source/Utility/RegisterValue.cpp similarity index 94% rename from source/Core/RegisterValue.cpp rename to source/Utility/RegisterValue.cpp index 4f908609dde9..e50592a2a312 100644 --- a/source/Core/RegisterValue.cpp +++ b/source/Utility/RegisterValue.cpp @@ -1,34 +1,33 @@ //===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/RegisterValue.h" +#include "lldb/Utility/RegisterValue.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-private-types.h" // for RegisterInfo, type128 +#include "lldb/lldb-defines.h" +#include "lldb/lldb-private-types.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include // for uint8_t, uint32_t, uint64_t -#include // for string -#include // for tie, tuple +#include +#include +#include #include -#include // for assert -#include // for PRIx64 -#include // for sscanf +#include +#include +#include using namespace lldb; using namespace lldb_private; @@ -157,6 +156,7 @@ bool RegisterValue::GetScalarValue(Scalar &scalar) const { return true; case 16: case 32: + case 64: if (buffer.length % sizeof(uint64_t) == 0) { const auto length_in_bits = buffer.length * 8; const auto length_in_uint64 = buffer.length / sizeof(uint64_t); @@ -380,7 +380,6 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, "unsupported unsigned integer byte size: %u", byte_size); break; } - // TODO: Shouldn't we be setting m_type here? break; case eEncodingSint: @@ -410,8 +409,6 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info, byte_size); break; } - - // TODO: Shouldn't we be setting m_type here? break; case eEncodingIEEE754: { @@ -478,7 +475,7 @@ bool RegisterValue::SignExtend(uint32_t sign_bitpos) { bool RegisterValue::CopyValue(const RegisterValue &rhs) { if (this == &rhs) - return rhs.m_type == eTypeInvalid ? false : true; + return rhs.m_type != eTypeInvalid; m_type = rhs.m_type; switch (m_type) { @@ -796,32 +793,7 @@ bool RegisterValue::operator==(const RegisterValue &rhs) const { } bool RegisterValue::operator!=(const RegisterValue &rhs) const { - if (m_type != rhs.m_type) - return true; - switch (m_type) { - case eTypeInvalid: - return false; - case eTypeUInt8: - case eTypeUInt16: - case eTypeUInt32: - case eTypeUInt64: - case eTypeUInt128: - case eTypeFloat: - case eTypeDouble: - case eTypeLongDouble: - return m_scalar != rhs.m_scalar; - case eTypeBytes: - if (buffer.length != rhs.buffer.length) { - return true; - } else { - uint8_t length = buffer.length; - if (length > kMaxRegisterByteSize) - length = kMaxRegisterByteSize; - return memcmp(buffer.bytes, rhs.buffer.bytes, length) != 0; - } - break; - } - return true; + return !(*this == rhs); } bool RegisterValue::ClearBit(uint32_t bit) { diff --git a/source/Utility/RegularExpression.cpp b/source/Utility/RegularExpression.cpp index 54f773365d99..bfbd101622eb 100644 --- a/source/Utility/RegularExpression.cpp +++ b/source/Utility/RegularExpression.cpp @@ -1,9 +1,8 @@ //===-- RegularExpression.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/Reproducer.cpp b/source/Utility/Reproducer.cpp new file mode 100644 index 000000000000..3fb0624c4fb1 --- /dev/null +++ b/source/Utility/Reproducer.cpp @@ -0,0 +1,225 @@ +//===-- Reproducer.cpp ------------------------------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/Reproducer.h" +#include "lldb/Utility/LLDBAssert.h" + +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Threading.h" +#include "llvm/Support/raw_ostream.h" + +using namespace lldb_private; +using namespace lldb_private::repro; +using namespace llvm; +using namespace llvm::yaml; + +Reproducer &Reproducer::Instance() { return *InstanceImpl(); } + +llvm::Error Reproducer::Initialize(ReproducerMode mode, + llvm::Optional root) { + lldbassert(!InstanceImpl() && "Already initialized."); + InstanceImpl().emplace(); + + switch (mode) { + case ReproducerMode::Capture: { + if (!root) { + SmallString<128> repro_dir; + auto ec = sys::fs::createUniqueDirectory("reproducer", repro_dir); + if (ec) + return make_error( + "unable to create unique reproducer directory", ec); + root.emplace(repro_dir); + } else { + auto ec = sys::fs::create_directory(root->GetPath()); + if (ec) + return make_error("unable to create reproducer directory", + ec); + } + return Instance().SetCapture(root); + } break; + case ReproducerMode::Replay: + return Instance().SetReplay(root); + case ReproducerMode::Off: + break; + }; + + return Error::success(); +} + +void Reproducer::Terminate() { + lldbassert(InstanceImpl() && "Already terminated."); + InstanceImpl().reset(); +} + +Optional &Reproducer::InstanceImpl() { + static Optional g_reproducer; + return g_reproducer; +} + +const Generator *Reproducer::GetGenerator() const { + std::lock_guard guard(m_mutex); + if (m_generator) + return &(*m_generator); + return nullptr; +} + +const Loader *Reproducer::GetLoader() const { + std::lock_guard guard(m_mutex); + if (m_loader) + return &(*m_loader); + return nullptr; +} + +Generator *Reproducer::GetGenerator() { + std::lock_guard guard(m_mutex); + if (m_generator) + return &(*m_generator); + return nullptr; +} + +Loader *Reproducer::GetLoader() { + std::lock_guard guard(m_mutex); + if (m_loader) + return &(*m_loader); + return nullptr; +} + +llvm::Error Reproducer::SetCapture(llvm::Optional root) { + std::lock_guard guard(m_mutex); + + if (root && m_loader) + return make_error( + "cannot generate a reproducer when replay one", + inconvertibleErrorCode()); + + if (!root) { + m_generator.reset(); + return Error::success(); + } + + m_generator.emplace(*root); + return Error::success(); +} + +llvm::Error Reproducer::SetReplay(llvm::Optional root) { + std::lock_guard guard(m_mutex); + + if (root && m_generator) + return make_error( + "cannot replay a reproducer when generating one", + inconvertibleErrorCode()); + + if (!root) { + m_loader.reset(); + return Error::success(); + } + + m_loader.emplace(*root); + if (auto e = m_loader->LoadIndex()) + return e; + + return Error::success(); +} + +FileSpec Reproducer::GetReproducerPath() const { + if (auto g = GetGenerator()) + return g->GetRoot(); + if (auto l = GetLoader()) + return l->GetRoot(); + return {}; +} + +Generator::Generator(const FileSpec &root) : m_root(root), m_done(false) {} + +Generator::~Generator() {} + +ProviderBase *Generator::Register(std::unique_ptr provider) { + std::lock_guard lock(m_providers_mutex); + std::pair> key_value( + provider->DynamicClassID(), std::move(provider)); + auto e = m_providers.insert(std::move(key_value)); + return e.first->getSecond().get(); +} + +void Generator::Keep() { + assert(!m_done); + m_done = true; + + for (auto &provider : m_providers) + provider.second->Keep(); + + AddProvidersToIndex(); +} + +void Generator::Discard() { + assert(!m_done); + m_done = true; + + for (auto &provider : m_providers) + provider.second->Discard(); + + llvm::sys::fs::remove_directories(m_root.GetPath()); +} + +const FileSpec &Generator::GetRoot() const { return m_root; } + +void Generator::AddProvidersToIndex() { + FileSpec index = m_root; + index.AppendPathComponent("index.yaml"); + + std::error_code EC; + auto strm = llvm::make_unique(index.GetPath(), EC, + sys::fs::OpenFlags::F_None); + yaml::Output yout(*strm); + + std::vector files; + files.reserve(m_providers.size()); + for (auto &provider : m_providers) { + files.emplace_back(provider.second->GetFile()); + } + + yout << files; +} + +Loader::Loader(const FileSpec &root) : m_root(root), m_loaded(false) {} + +llvm::Error Loader::LoadIndex() { + if (m_loaded) + return llvm::Error::success(); + + FileSpec index = m_root.CopyByAppendingPathComponent("index.yaml"); + + auto error_or_file = MemoryBuffer::getFile(index.GetPath()); + if (auto err = error_or_file.getError()) + return make_error("unable to load reproducer index", err); + + yaml::Input yin((*error_or_file)->getBuffer()); + yin >> m_files; + if (auto err = yin.error()) + return make_error("unable to read reproducer index", err); + + // Sort files to speed up search. + llvm::sort(m_files); + + // Remember that we've loaded the index. + m_loaded = true; + + return llvm::Error::success(); +} + +bool Loader::HasFile(StringRef file) { + assert(m_loaded); + auto it = std::lower_bound(m_files.begin(), m_files.end(), file.str()); + return (it != m_files.end()) && (*it == file); +} + +void ProviderBase::anchor() {} +char ProviderBase::ID = 0; +char FileProvider::ID = 0; +const char *FileInfo::name = "files"; +const char *FileInfo::file = "files.yaml"; diff --git a/source/Core/Scalar.cpp b/source/Utility/Scalar.cpp similarity index 91% rename from source/Core/Scalar.cpp rename to source/Utility/Scalar.cpp index 7082ca803d6f..adc583dda85e 100644 --- a/source/Core/Scalar.cpp +++ b/source/Utility/Scalar.cpp @@ -1,19 +1,18 @@ //===-- Scalar.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#include "lldb/Core/Scalar.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-types.h" // for offset_t +#include "lldb/lldb-types.h" #include "llvm/ADT/SmallString.h" @@ -38,7 +37,7 @@ static Scalar::Type PromoteToMaxType( const Scalar *&promoted_rhs_ptr // Pointer to the resulting possibly // promoted value of rhs (at most one of // lhs/rhs will get promoted) - ) { +) { Scalar result; // Initialize the promoted values for both the right and left hand side // values to be the objects themselves. If no promotion is needed (both right @@ -76,49 +75,6 @@ Scalar::Scalar() : m_type(e_void), m_float((float)0) {} Scalar::Scalar(const Scalar &rhs) : m_type(rhs.m_type), m_integer(rhs.m_integer), m_float(rhs.m_float) {} -// Scalar::Scalar(const RegisterValue& reg) : -// m_type(e_void), -// m_data() -//{ -// switch (reg.info.encoding) -// { -// case eEncodingUint: // unsigned integer -// switch (reg.info.byte_size) -// { -// case 1: m_type = e_uint; m_data.uint = reg.value.uint8; break; -// case 2: m_type = e_uint; m_data.uint = reg.value.uint16; break; -// case 4: m_type = e_uint; m_data.uint = reg.value.uint32; break; -// case 8: m_type = e_ulonglong; m_data.ulonglong = reg.value.uint64; -// break; -// break; -// } -// break; -// -// case eEncodingSint: // signed integer -// switch (reg.info.byte_size) -// { -// case 1: m_type = e_sint; m_data.sint = reg.value.sint8; break; -// case 2: m_type = e_sint; m_data.sint = reg.value.sint16; break; -// case 4: m_type = e_sint; m_data.sint = reg.value.sint32; break; -// case 8: m_type = e_slonglong; m_data.slonglong = reg.value.sint64; -// break; -// break; -// } -// break; -// -// case eEncodingIEEE754: // float -// switch (reg.info.byte_size) -// { -// case 4: m_type = e_float; m_data.flt = reg.value.float32; break; -// case 8: m_type = e_double; m_data.dbl = reg.value.float64; break; -// break; -// } -// break; -// case eEncodingVector: // vector registers -// break; -// } -//} - bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const { size_t byte_size = GetByteSize(); if (byte_size > 0) { @@ -150,7 +106,7 @@ const void *Scalar::GetBytes() const { const uint8_t *bytes; static float_t flt_val; static double_t dbl_val; - static uint64_t swapped_words[4]; + static uint64_t swapped_words[8]; switch (m_type) { case e_void: break; @@ -169,12 +125,12 @@ const void *Scalar::GetBytes() const { bytes += 8 - byte_size; } return bytes; + // getRawData always returns a pointer to an array of uint64_t values, + // where the least-significant word always comes first. On big-endian + // systems we need to swap the words. case e_sint128: case e_uint128: apint_words = m_integer.getRawData(); - // getRawData always returns a pointer to an array of two uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the two words. if (endian::InlHostByteOrder() == eByteOrderBig) { swapped_words[0] = apint_words[1]; swapped_words[1] = apint_words[0]; @@ -184,9 +140,6 @@ const void *Scalar::GetBytes() const { case e_sint256: case e_uint256: apint_words = m_integer.getRawData(); - // getRawData always returns a pointer to an array of four uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the four words. if (endian::InlHostByteOrder() == eByteOrderBig) { swapped_words[0] = apint_words[3]; swapped_words[1] = apint_words[2]; @@ -195,6 +148,21 @@ const void *Scalar::GetBytes() const { apint_words = swapped_words; } return reinterpret_cast(apint_words); + case e_sint512: + case e_uint512: + apint_words = m_integer.getRawData(); + if (endian::InlHostByteOrder() == eByteOrderBig) { + swapped_words[0] = apint_words[7]; + swapped_words[1] = apint_words[6]; + swapped_words[2] = apint_words[5]; + swapped_words[3] = apint_words[4]; + swapped_words[4] = apint_words[3]; + swapped_words[5] = apint_words[2]; + swapped_words[6] = apint_words[1]; + swapped_words[7] = apint_words[0]; + apint_words = swapped_words; + } + return reinterpret_cast(apint_words); case e_float: flt_val = m_float.convertToFloat(); return reinterpret_cast(&flt_val); @@ -231,6 +199,8 @@ size_t Scalar::GetByteSize() const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (m_integer.getBitWidth() / 8); case e_float: return sizeof(float_t); @@ -257,6 +227,8 @@ bool Scalar::IsZero() const { case e_uint128: case e_sint256: case e_uint256: + case e_uint512: + case e_sint512: return llvm::APInt::isSameValue(zero_int, m_integer); case e_float: case e_double: @@ -278,6 +250,7 @@ void Scalar::GetValue(Stream *s, bool show_type) const { case e_slonglong: case e_sint128: case e_sint256: + case e_sint512: s->PutCString(m_integer.toString(10, true)); break; case e_uint: @@ -285,6 +258,7 @@ void Scalar::GetValue(Stream *s, bool show_type) const { case e_ulonglong: case e_uint128: case e_uint256: + case e_uint512: s->PutCString(m_integer.toString(10, false)); break; case e_float: @@ -321,6 +295,10 @@ const char *Scalar::GetTypeAsCString() const { return "int256_t"; case e_uint256: return "unsigned int256_t"; + case e_sint512: + return "int512_t"; + case e_uint512: + return "unsigned int512_t"; case e_float: return "float"; case e_double: @@ -430,6 +408,12 @@ Scalar &Scalar::operator=(llvm::APInt rhs) { else m_type = e_uint256; break; + case 512: + if (m_integer.isSignedIntN(BITWIDTH_INT512)) + m_type = e_sint512; + else + m_type = e_uint512; + break; } return *this; } @@ -486,6 +470,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, true, @@ -550,6 +540,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, false, @@ -610,6 +606,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, true, @@ -666,6 +668,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, false, @@ -718,6 +726,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, true, @@ -766,6 +780,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, false, @@ -814,6 +834,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, true, @@ -858,6 +884,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, false, @@ -902,6 +934,12 @@ bool Scalar::Promote(Scalar::Type type) { success = true; break; + case e_sint512: + case e_uint512: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, true, @@ -942,6 +980,13 @@ bool Scalar::Promote(Scalar::Type type) { case e_uint256: success = true; break; + + case e_sint512: + case e_uint512: + m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512); + success = true; + break; + case e_float: m_float = llvm::APFloat(llvm::APFloat::IEEEsingle()); m_float.convertFromAPInt(m_integer, false, @@ -966,6 +1011,11 @@ bool Scalar::Promote(Scalar::Type type) { } break; + case e_sint512: + case e_uint512: + lldbassert(false && "unimplemented"); + break; + case e_float: switch (type) { case e_void: @@ -979,6 +1029,8 @@ bool Scalar::Promote(Scalar::Type type) { case e_uint128: case e_sint256: case e_uint256: + case e_uint512: + case e_sint512: break; case e_float: success = true; @@ -1012,6 +1064,8 @@ bool Scalar::Promote(Scalar::Type type) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: case e_float: break; case e_double: @@ -1041,6 +1095,8 @@ bool Scalar::Promote(Scalar::Type type) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: case e_float: case e_double: break; @@ -1086,6 +1142,10 @@ const char *Scalar::GetValueTypeAsCString(Scalar::Type type) { return "int256_t"; case e_uint256: return "uint256_t"; + case e_sint512: + return "int512_t"; + case e_uint512: + return "uint512_t"; } return "???"; } @@ -1163,6 +1223,13 @@ bool Scalar::MakeSigned() { m_type = e_sint256; success = true; break; + case e_sint512: + success = true; + break; + case e_uint512: + m_type = e_sint512; + success = true; + break; case e_float: success = true; break; @@ -1218,6 +1285,13 @@ bool Scalar::MakeUnsigned() { case e_uint256: success = true; break; + case e_sint512: + m_type = e_uint512; + success = true; + break; + case e_uint512: + success = true; + break; case e_float: success = true; break; @@ -1246,6 +1320,8 @@ signed char Scalar::SChar(char fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (schar_t)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue(); case e_float: return (schar_t)m_float.convertToFloat(); @@ -1272,6 +1348,8 @@ unsigned char Scalar::UChar(unsigned char fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (uchar_t)(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue(); case e_float: return (uchar_t)m_float.convertToFloat(); @@ -1298,6 +1376,8 @@ short Scalar::SShort(short fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (sshort_t)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8)) .getSExtValue(); case e_float: @@ -1326,6 +1406,8 @@ unsigned short Scalar::UShort(unsigned short fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (ushort_t)(m_integer.zextOrTrunc(sizeof(ushort_t) * 8)) .getZExtValue(); case e_float: @@ -1354,6 +1436,8 @@ int Scalar::SInt(int fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (sint_t)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue(); case e_float: return (sint_t)m_float.convertToFloat(); @@ -1380,6 +1464,8 @@ unsigned int Scalar::UInt(unsigned int fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (uint_t)(m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue(); case e_float: return (uint_t)m_float.convertToFloat(); @@ -1406,6 +1492,8 @@ long Scalar::SLong(long fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (slong_t)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue(); case e_float: return (slong_t)m_float.convertToFloat(); @@ -1432,6 +1520,8 @@ unsigned long Scalar::ULong(unsigned long fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (ulong_t)(m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue(); case e_float: return (ulong_t)m_float.convertToFloat(); @@ -1458,6 +1548,8 @@ long long Scalar::SLongLong(long long fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (slonglong_t)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)) .getSExtValue(); case e_float: @@ -1486,6 +1578,8 @@ unsigned long long Scalar::ULongLong(unsigned long long fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (ulonglong_t)(m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8)) .getZExtValue(); case e_float: @@ -1519,6 +1613,8 @@ llvm::APInt Scalar::SInt128(llvm::APInt &fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return m_integer; case e_float: case e_double: @@ -1542,52 +1638,8 @@ llvm::APInt Scalar::UInt128(const llvm::APInt &fail_value) const { case e_uint128: case e_sint256: case e_uint256: - return m_integer; - case e_float: - case e_double: - case e_long_double: - return m_float.bitcastToAPInt(); - } - return fail_value; -} - -llvm::APInt Scalar::SInt256(llvm::APInt &fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: - return m_integer; - case e_float: - case e_double: - case e_long_double: - return m_float.bitcastToAPInt(); - } - return fail_value; -} - -llvm::APInt Scalar::UInt256(const llvm::APInt &fail_value) const { - switch (m_type) { - case e_void: - break; - case e_sint: - case e_uint: - case e_slong: - case e_ulong: - case e_slonglong: - case e_ulonglong: - case e_sint128: - case e_uint128: - case e_sint256: - case e_uint256: + case e_sint512: + case e_uint512: return m_integer; case e_float: case e_double: @@ -1611,6 +1663,8 @@ float Scalar::Float(float fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return llvm::APIntOps::RoundAPIntToFloat(m_integer); case e_float: return m_float.convertToFloat(); @@ -1637,6 +1691,8 @@ double Scalar::Double(double fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return llvm::APIntOps::RoundAPIntToDouble(m_integer); case e_float: return (double_t)m_float.convertToFloat(); @@ -1663,6 +1719,8 @@ long double Scalar::LongDouble(long double fail_value) const { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: return (long_double_t)llvm::APIntOps::RoundAPIntToDouble(m_integer); case e_float: return (long_double_t)m_float.convertToFloat(); @@ -1694,6 +1752,8 @@ Scalar &Scalar::operator+=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer = a->m_integer + b->m_integer; break; @@ -1726,6 +1786,8 @@ Scalar &Scalar::operator<<=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: switch (rhs.m_type) { case e_void: case e_float: @@ -1743,6 +1805,8 @@ Scalar &Scalar::operator<<=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer = m_integer << rhs.m_integer; break; } @@ -1770,6 +1834,8 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: switch (rhs.m_type) { case e_void: case e_float: @@ -1787,6 +1853,8 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer = m_integer.lshr(rhs.m_integer); break; } @@ -1814,6 +1882,8 @@ Scalar &Scalar::operator>>=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: switch (rhs.m_type) { case e_void: case e_float: @@ -1831,6 +1901,8 @@ Scalar &Scalar::operator>>=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer = m_integer.ashr(rhs.m_integer); break; } @@ -1858,6 +1930,8 @@ Scalar &Scalar::operator&=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: switch (rhs.m_type) { case e_void: case e_float: @@ -1875,6 +1949,8 @@ Scalar &Scalar::operator&=(const Scalar &rhs) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer &= rhs.m_integer; break; } @@ -1893,6 +1969,7 @@ bool Scalar::AbsoluteValue() { case e_slonglong: case e_sint128: case e_sint256: + case e_sint512: if (m_integer.isNegative()) m_integer = -m_integer; return true; @@ -1903,6 +1980,7 @@ bool Scalar::AbsoluteValue() { return true; case e_uint128: case e_uint256: + case e_uint512: case e_float: case e_double: case e_long_double: @@ -1926,6 +2004,8 @@ bool Scalar::UnaryNegate() { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer = -m_integer; return true; case e_float: @@ -1949,6 +2029,8 @@ bool Scalar::OnesComplement() { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer = ~m_integer; return true; @@ -1981,6 +2063,8 @@ const Scalar lldb_private::operator+(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: result.m_integer = a->m_integer + b->m_integer; break; case Scalar::e_float: @@ -2013,6 +2097,8 @@ const Scalar lldb_private::operator-(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: result.m_integer = a->m_integer - b->m_integer; break; case Scalar::e_float: @@ -2040,6 +2126,7 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_slonglong: case Scalar::e_sint128: case Scalar::e_sint256: + case Scalar::e_sint512: if (b->m_integer != 0) { result.m_integer = a->m_integer.sdiv(b->m_integer); return result; @@ -2050,6 +2137,7 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_ulonglong: case Scalar::e_uint128: case Scalar::e_uint256: + case Scalar::e_uint512: if (b->m_integer != 0) { result.m_integer = a->m_integer.udiv(b->m_integer); return result; @@ -2091,6 +2179,8 @@ const Scalar lldb_private::operator*(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: result.m_integer = a->m_integer * b->m_integer; break; case Scalar::e_float: @@ -2121,6 +2211,8 @@ const Scalar lldb_private::operator&(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: result.m_integer = a->m_integer & b->m_integer; break; case Scalar::e_void: @@ -2153,6 +2245,8 @@ const Scalar lldb_private::operator|(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: result.m_integer = a->m_integer | b->m_integer; break; @@ -2185,6 +2279,7 @@ const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_slonglong: case Scalar::e_sint128: case Scalar::e_sint256: + case Scalar::e_sint512: if (b->m_integer != 0) { result.m_integer = a->m_integer.srem(b->m_integer); return result; @@ -2195,6 +2290,7 @@ const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_ulonglong: case Scalar::e_uint128: case Scalar::e_uint256: + case Scalar::e_uint512: if (b->m_integer != 0) { result.m_integer = a->m_integer.urem(b->m_integer); return result; @@ -2224,6 +2320,8 @@ const Scalar lldb_private::operator^(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: result.m_integer = a->m_integer ^ b->m_integer; break; @@ -2530,6 +2628,8 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: if (max_bit_pos == sign_bit_pos) return true; else if (sign_bit_pos < (max_bit_pos - 1)) { @@ -2594,6 +2694,7 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) { case Scalar::e_slonglong: case Scalar::e_sint128: case Scalar::e_sint256: + case Scalar::e_sint512: m_integer = m_integer.ashr(bit_offset) .sextOrTrunc(bit_size) .sextOrSelf(this_bit_size); @@ -2604,6 +2705,7 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) { case Scalar::e_ulonglong: case Scalar::e_uint128: case Scalar::e_uint256: + case Scalar::e_uint512: m_integer = m_integer.lshr(bit_offset) .zextOrTrunc(bit_size) .zextOrSelf(this_bit_size); @@ -2634,6 +2736,8 @@ bool lldb_private::operator==(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_uint128: case Scalar::e_sint256: case Scalar::e_uint256: + case Scalar::e_sint512: + case Scalar::e_uint512: return a->m_integer == b->m_integer; case Scalar::e_float: case Scalar::e_double: @@ -2646,37 +2750,7 @@ bool lldb_private::operator==(const Scalar &lhs, const Scalar &rhs) { } bool lldb_private::operator!=(const Scalar &lhs, const Scalar &rhs) { - // If either entry is void then we can just compare the types - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return lhs.m_type != rhs.m_type; - - Scalar - temp_value; // A temp value that might get a copy of either promoted value - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_uint: - case Scalar::e_slong: - case Scalar::e_ulong: - case Scalar::e_slonglong: - case Scalar::e_ulonglong: - case Scalar::e_sint128: - case Scalar::e_uint128: - case Scalar::e_sint256: - case Scalar::e_uint256: - return a->m_integer != b->m_integer; - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result != llvm::APFloat::cmpEqual) - return true; - } - return true; + return !(lhs == rhs); } bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) { @@ -2695,6 +2769,8 @@ bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) { case Scalar::e_slonglong: case Scalar::e_sint128: case Scalar::e_sint256: + case Scalar::e_sint512: + case Scalar::e_uint512: return a->m_integer.slt(b->m_integer); case Scalar::e_uint: case Scalar::e_ulong: @@ -2713,104 +2789,15 @@ bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) { } bool lldb_private::operator<=(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.sle(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.ule(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpLessThan || - result == llvm::APFloat::cmpEqual) - return true; - } - return false; + return !(rhs < lhs); } bool lldb_private::operator>(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.sgt(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.ugt(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpGreaterThan) - return true; - } - return false; + return rhs < lhs; } bool lldb_private::operator>=(const Scalar &lhs, const Scalar &rhs) { - if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void) - return false; - - Scalar temp_value; - const Scalar *a; - const Scalar *b; - llvm::APFloat::cmpResult result; - switch (PromoteToMaxType(lhs, rhs, temp_value, a, b)) { - case Scalar::e_void: - break; - case Scalar::e_sint: - case Scalar::e_slong: - case Scalar::e_slonglong: - case Scalar::e_sint128: - case Scalar::e_sint256: - return a->m_integer.sge(b->m_integer); - case Scalar::e_uint: - case Scalar::e_ulong: - case Scalar::e_ulonglong: - case Scalar::e_uint128: - case Scalar::e_uint256: - return a->m_integer.uge(b->m_integer); - case Scalar::e_float: - case Scalar::e_double: - case Scalar::e_long_double: - result = a->m_float.compare(b->m_float); - if (result == llvm::APFloat::cmpGreaterThan || - result == llvm::APFloat::cmpEqual) - return true; - } - return false; + return !(lhs < rhs); } bool Scalar::ClearBit(uint32_t bit) { @@ -2827,6 +2814,8 @@ bool Scalar::ClearBit(uint32_t bit) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer.clearBit(bit); return true; case e_float: @@ -2851,6 +2840,8 @@ bool Scalar::SetBit(uint32_t bit) { case e_uint128: case e_sint256: case e_uint256: + case e_sint512: + case e_uint512: m_integer.setBit(bit); return true; case e_float: diff --git a/source/Utility/SelectHelper.cpp b/source/Utility/SelectHelper.cpp index 0f6a96309504..3b61fcecac41 100644 --- a/source/Utility/SelectHelper.cpp +++ b/source/Utility/SelectHelper.cpp @@ -1,9 +1,8 @@ //===-- SelectHelper.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,14 +16,14 @@ #include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Status.h" -#include "lldb/lldb-enumerations.h" // for ErrorType::eErrorTypePOSIX -#include "lldb/lldb-types.h" // for socket_t +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-types.h" -#include "llvm/ADT/DenseMap.h" // for DenseMapPair, DenseMap, Dense... -#include "llvm/ADT/Optional.h" // for Optional +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" #include -#include // for microseconds, seconds, steady... +#include #include #if defined(_WIN32) diff --git a/source/Utility/SharingPtr.cpp b/source/Utility/SharingPtr.cpp index bdaedfb9b049..45f2a773758b 100644 --- a/source/Utility/SharingPtr.cpp +++ b/source/Utility/SharingPtr.cpp @@ -1,9 +1,8 @@ //===---------------------SharingPtr.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Core/State.cpp b/source/Utility/State.cpp similarity index 88% rename from source/Core/State.cpp rename to source/Utility/State.cpp index 4697ca4b5f17..51fe92bad77e 100644 --- a/source/Core/State.cpp +++ b/source/Utility/State.cpp @@ -1,17 +1,12 @@ //===-- State.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/State.h" +#include "lldb/Utility/State.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Utility/Status.cpp b/source/Utility/Status.cpp index f6dc228391b3..4d1b2723cb38 100644 --- a/source/Utility/Status.cpp +++ b/source/Utility/Status.cpp @@ -1,33 +1,35 @@ //===-- Status.cpp -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/Status.h" #include "lldb/Utility/VASPrintf.h" -#include "lldb/lldb-defines.h" // for LLDB_GENERIC_ERROR -#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType::eErr... -#include "llvm/ADT/SmallString.h" // for SmallString -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Errno.h" -#include "llvm/Support/FormatProviders.h" // for format_provider +#include "llvm/Support/FormatProviders.h" #include #include -#include // for string +#include #include #ifdef __APPLE__ #include #endif -#include // for uint32_t +#ifdef _WIN32 +#include +#endif +#include namespace llvm { class raw_ostream; @@ -87,7 +89,8 @@ llvm::Error Status::ToError() const { if (Success()) return llvm::Error::success(); if (m_type == ErrorType::eErrorTypePOSIX) - return llvm::errorCodeToError(std::error_code(m_code, std::generic_category())); + return llvm::errorCodeToError( + std::error_code(m_code, std::generic_category())); return llvm::make_error(AsCString(), llvm::inconvertibleErrorCode()); } @@ -106,6 +109,23 @@ const Status &Status::operator=(const Status &rhs) { Status::~Status() = default; +#ifdef _WIN32 +static std::string RetrieveWin32ErrorString(uint32_t error_code) { + char *buffer = nullptr; + std::string message; + // Retrieve win32 system error. + if (::FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&buffer, 0, NULL)) { + message.assign(buffer); + ::LocalFree(buffer); + } + return message; +} +#endif + //---------------------------------------------------------------------- // Get the error value as a NULL C string. The error string will be fetched and // cached on demand. The cached error string value will remain until the error @@ -128,6 +148,12 @@ const char *Status::AsCString(const char *default_error_str) const { m_string = llvm::sys::StrError(m_code); break; + case eErrorTypeWin32: +#if defined(_WIN32) + m_string = RetrieveWin32ErrorString(m_code); +#endif + break; + default: break; } diff --git a/source/Utility/Stream.cpp b/source/Utility/Stream.cpp index 8af8c19f210e..160932ab2515 100644 --- a/source/Utility/Stream.cpp +++ b/source/Utility/Stream.cpp @@ -1,9 +1,8 @@ //===-- Stream.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,7 +10,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/VASPrintf.h" -#include "llvm/ADT/SmallString.h" // for SmallString +#include "llvm/ADT/SmallString.h" #include "llvm/Support/LEB128.h" #include @@ -93,9 +92,9 @@ void Stream::QuotedCString(const char *cstr, const char *format) { //------------------------------------------------------------------ void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix, const char *suffix) { - if (prefix == NULL) + if (prefix == nullptr) prefix = ""; - if (suffix == NULL) + if (suffix == nullptr) suffix = ""; // int addr_width = m_addr_size << 1; // Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix); @@ -313,26 +312,25 @@ size_t Stream::PrintfAsRawHex8(const char *format, ...) { llvm::SmallString<1024> buf; VASprintf(buf, format, args); - size_t length = 0; + ByteDelta delta(*this); for (char C : buf) - length += _PutHex8(C, false); + _PutHex8(C, false); va_end(args); - return length; + return *delta; } size_t Stream::PutNHex8(size_t n, uint8_t uvalue) { - size_t bytes_written = 0; + ByteDelta delta(*this); for (size_t i = 0; i < n; ++i) - bytes_written += _PutHex8(uvalue, false); - return bytes_written; + _PutHex8(uvalue, false); + return *delta; } -size_t Stream::_PutHex8(uint8_t uvalue, bool add_prefix) { - size_t bytes_written = 0; +void Stream::_PutHex8(uint8_t uvalue, bool add_prefix) { if (m_flags.Test(eBinary)) { - bytes_written = Write(&uvalue, 1); + Write(&uvalue, 1); } else { if (add_prefix) PutCString("0x"); @@ -343,56 +341,62 @@ size_t Stream::_PutHex8(uint8_t uvalue, bool add_prefix) { char nibble_chars[2]; nibble_chars[0] = g_hex_to_ascii_hex_char[(uvalue >> 4) & 0xf]; nibble_chars[1] = g_hex_to_ascii_hex_char[(uvalue >> 0) & 0xf]; - bytes_written = Write(nibble_chars, sizeof(nibble_chars)); + Write(nibble_chars, sizeof(nibble_chars)); } - return bytes_written; } -size_t Stream::PutHex8(uint8_t uvalue) { return _PutHex8(uvalue, false); } +size_t Stream::PutHex8(uint8_t uvalue) { + ByteDelta delta(*this); + _PutHex8(uvalue, false); + return *delta; +} size_t Stream::PutHex16(uint16_t uvalue, ByteOrder byte_order) { + ByteDelta delta(*this); + if (byte_order == eByteOrderInvalid) byte_order = m_byte_order; - size_t bytes_written = 0; if (byte_order == eByteOrderLittle) { for (size_t byte = 0; byte < sizeof(uvalue); ++byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } else { for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } - return bytes_written; + return *delta; } size_t Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order) { + ByteDelta delta(*this); + if (byte_order == eByteOrderInvalid) byte_order = m_byte_order; - size_t bytes_written = 0; if (byte_order == eByteOrderLittle) { for (size_t byte = 0; byte < sizeof(uvalue); ++byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } else { for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } - return bytes_written; + return *delta; } size_t Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order) { + ByteDelta delta(*this); + if (byte_order == eByteOrderInvalid) byte_order = m_byte_order; - size_t bytes_written = 0; if (byte_order == eByteOrderLittle) { for (size_t byte = 0; byte < sizeof(uvalue); ++byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } else { for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte) - bytes_written += _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); + _PutHex8((uint8_t)(uvalue >> (byte * 8)), false); } - return bytes_written; + return *delta; } size_t Stream::PutMaxHex64(uint64_t uvalue, size_t byte_size, @@ -438,65 +442,66 @@ size_t Stream::PutLongDouble(long double ld, ByteOrder byte_order) { size_t Stream::PutRawBytes(const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order) { + ByteDelta delta(*this); + if (src_byte_order == eByteOrderInvalid) src_byte_order = m_byte_order; if (dst_byte_order == eByteOrderInvalid) dst_byte_order = m_byte_order; - size_t bytes_written = 0; const uint8_t *src = (const uint8_t *)s; bool binary_was_set = m_flags.Test(eBinary); if (!binary_was_set) m_flags.Set(eBinary); if (src_byte_order == dst_byte_order) { for (size_t i = 0; i < src_len; ++i) - bytes_written += _PutHex8(src[i], false); + _PutHex8(src[i], false); } else { for (size_t i = src_len - 1; i < src_len; --i) - bytes_written += _PutHex8(src[i], false); + _PutHex8(src[i], false); } if (!binary_was_set) m_flags.Clear(eBinary); - return bytes_written; + return *delta; } size_t Stream::PutBytesAsRawHex8(const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order) { + ByteDelta delta(*this); if (src_byte_order == eByteOrderInvalid) src_byte_order = m_byte_order; if (dst_byte_order == eByteOrderInvalid) dst_byte_order = m_byte_order; - size_t bytes_written = 0; const uint8_t *src = (const uint8_t *)s; bool binary_is_set = m_flags.Test(eBinary); m_flags.Clear(eBinary); if (src_byte_order == dst_byte_order) { for (size_t i = 0; i < src_len; ++i) - bytes_written += _PutHex8(src[i], false); + _PutHex8(src[i], false); } else { for (size_t i = src_len - 1; i < src_len; --i) - bytes_written += _PutHex8(src[i], false); + _PutHex8(src[i], false); } if (binary_is_set) m_flags.Set(eBinary); - return bytes_written; + return *delta; } size_t Stream::PutCStringAsRawHex8(const char *s) { - size_t bytes_written = 0; + ByteDelta delta(*this); bool binary_is_set = m_flags.Test(eBinary); m_flags.Clear(eBinary); while(*s) { - bytes_written += _PutHex8(*s, false); + _PutHex8(*s, false); ++s; } if (binary_is_set) m_flags.Set(eBinary); - return bytes_written; + return *delta; } diff --git a/source/Utility/StreamCallback.cpp b/source/Utility/StreamCallback.cpp index 97528439005a..b3d3adea78bc 100644 --- a/source/Utility/StreamCallback.cpp +++ b/source/Utility/StreamCallback.cpp @@ -1,9 +1,8 @@ //===-- StreamCallback.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/StreamGDBRemote.cpp b/source/Utility/StreamGDBRemote.cpp index 2620e3786d29..bd097db0ebb3 100644 --- a/source/Utility/StreamGDBRemote.cpp +++ b/source/Utility/StreamGDBRemote.cpp @@ -1,16 +1,15 @@ //===-- StreamGDBRemote.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/StreamGDBRemote.h" -#include "lldb/Utility/Flags.h" // for Flags -#include "lldb/Utility/Stream.h" // for Stream::::eBinary +#include "lldb/Utility/Flags.h" +#include "lldb/Utility/Stream.h" #include diff --git a/source/Utility/StreamString.cpp b/source/Utility/StreamString.cpp index 152096198858..bf9814d6c305 100644 --- a/source/Utility/StreamString.cpp +++ b/source/Utility/StreamString.cpp @@ -1,9 +1,8 @@ //===-- StreamString.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp index 7528350cf759..f0f6ad131c64 100644 --- a/source/Utility/StringExtractor.cpp +++ b/source/Utility/StringExtractor.cpp @@ -1,9 +1,8 @@ //===-- StringExtractor.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,9 +10,9 @@ #include -#include // for isxdigit, isspace +#include #include -#include // for memset +#include static inline int xdigit_to_sint(char ch) { if (ch >= 'a' && ch <= 'f') diff --git a/source/Utility/StringExtractorGDBRemote.cpp b/source/Utility/StringExtractorGDBRemote.cpp index 3cae06df3b1e..683b62cb2591 100644 --- a/source/Utility/StringExtractorGDBRemote.cpp +++ b/source/Utility/StringExtractorGDBRemote.cpp @@ -1,15 +1,14 @@ //===-- StringExtractorGDBRemote.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/StringExtractorGDBRemote.h" -#include // for isxdigit +#include #include StringExtractorGDBRemote::ResponseType diff --git a/source/Utility/StringLexer.cpp b/source/Utility/StringLexer.cpp index d5c7fc628988..af146749f085 100644 --- a/source/Utility/StringLexer.cpp +++ b/source/Utility/StringLexer.cpp @@ -1,9 +1,8 @@ //===--------------------- StringLexer.cpp -----------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/StringList.cpp b/source/Utility/StringList.cpp index 190cb9d682c9..fb0d9be8797d 100644 --- a/source/Utility/StringList.cpp +++ b/source/Utility/StringList.cpp @@ -1,22 +1,21 @@ //===-- StringList.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/StringList.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "llvm/ADT/ArrayRef.h" // for ArrayRef, makeArrayRef +#include "llvm/ADT/ArrayRef.h" -#include // for min -#include // for SIZE_MAX, uint32_t -#include // for size_t, strcspn, NULL +#include +#include +#include using namespace lldb_private; @@ -83,7 +82,7 @@ size_t StringList::GetMaxStringLength() const { const char *StringList::GetStringAtIndex(size_t idx) const { if (idx < m_strings.size()) return m_strings[idx].c_str(); - return NULL; + return nullptr; } void StringList::Join(const char *separator, Stream &strm) { diff --git a/source/Utility/StructuredData.cpp b/source/Utility/StructuredData.cpp index 55f003f245bf..b4bfe03a4140 100644 --- a/source/Utility/StructuredData.cpp +++ b/source/Utility/StructuredData.cpp @@ -1,9 +1,8 @@ //===---------------------StructuredData.cpp ---------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -12,14 +11,14 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/JSON.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "llvm/ADT/STLExtras.h" // for make_unique +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/MemoryBuffer.h" #include #include #include -#include // for numeric_limits +#include using namespace lldb_private; @@ -33,11 +32,6 @@ static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser); StructuredData::ObjectSP StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Status &error) { StructuredData::ObjectSP return_sp; - if (!input_spec.Exists()) { - error.SetErrorStringWithFormatv("input file {0} does not exist.", - input_spec); - return return_sp; - } auto buffer_or_error = llvm::MemoryBuffer::getFile(input_spec.GetPath()); if (!buffer_or_error) { @@ -149,7 +143,7 @@ static StructuredData::ObjectSP ParseJSONValue(JSONParser &json_parser) { } StructuredData::ObjectSP StructuredData::ParseJSON(std::string json_text) { - JSONParser json_parser(json_text.c_str()); + JSONParser json_parser(json_text); StructuredData::ObjectSP object_sp = ParseJSONValue(json_parser); return object_sp; } @@ -174,11 +168,11 @@ StructuredData::Object::GetObjectForDotSeparatedPath(llvm::StringRef path) { if (this->GetType() == lldb::eStructuredDataTypeArray) { std::pair match = path.split('['); - if (match.second.size() == 0) { + if (match.second.empty()) { return this->shared_from_this(); } errno = 0; - uint64_t val = strtoul(match.second.str().c_str(), NULL, 10); + uint64_t val = strtoul(match.second.str().c_str(), nullptr, 10); if (errno == 0) { return this->GetAsArray()->GetItemAtIndex(val); } @@ -231,7 +225,7 @@ void StructuredData::Float::Dump(Stream &s, bool pretty_print) const { } void StructuredData::Boolean::Dump(Stream &s, bool pretty_print) const { - if (m_value == true) + if (m_value) s.PutCString("true"); else s.PutCString("false"); diff --git a/source/Utility/TildeExpressionResolver.cpp b/source/Utility/TildeExpressionResolver.cpp index ae947059d8b9..b58f45728ce7 100644 --- a/source/Utility/TildeExpressionResolver.cpp +++ b/source/Utility/TildeExpressionResolver.cpp @@ -1,22 +1,21 @@ //===--------------------- TildeExpressionResolver.cpp ----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/TildeExpressionResolver.h" -#include // for assert -#include // for error_code +#include +#include -#include "llvm/ADT/STLExtras.h" // for any_of -#include "llvm/ADT/SmallVector.h" // for SmallVectorImpl +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/raw_ostream.h" // for fs +#include "llvm/Support/raw_ostream.h" #if !defined(_WIN32) #include @@ -59,7 +58,7 @@ bool StandardTildeExpressionResolver::ResolvePartial(StringRef Expr, struct passwd *user_entry; Expr = Expr.drop_front(); - while ((user_entry = getpwent()) != NULL) { + while ((user_entry = getpwent()) != nullptr) { StringRef ThisName(user_entry->pw_name); if (!ThisName.startswith(Expr)) continue; diff --git a/source/Utility/Timer.cpp b/source/Utility/Timer.cpp index fe7787458fa6..683192449764 100644 --- a/source/Utility/Timer.cpp +++ b/source/Utility/Timer.cpp @@ -1,9 +1,8 @@ //===-- Timer.cpp -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/Timer.h" @@ -12,11 +11,11 @@ #include #include #include -#include // for pair +#include #include -#include // for assert -#include // for va_end, va_list, va_start +#include +#include #include using namespace lldb_private; @@ -125,7 +124,7 @@ void Timer::DumpCategoryTimes(Stream *s) { return; // Later code will break without any elements. // Sort by time - std::sort(sorted.begin(), sorted.end(), CategoryMapIteratorSortCriterion); + llvm::sort(sorted.begin(), sorted.end(), CategoryMapIteratorSortCriterion); for (const auto &timer : sorted) s->Printf("%.9f sec for %s\n", timer.second / 1000000000., timer.first); diff --git a/source/Utility/UUID.cpp b/source/Utility/UUID.cpp index 3bc051144914..2a73f9a482ff 100644 --- a/source/Utility/UUID.cpp +++ b/source/Utility/UUID.cpp @@ -1,21 +1,17 @@ //===-- UUID.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/UUID.h" -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Stream.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" -// C Includes #include #include #include @@ -54,9 +50,7 @@ std::string UUID::GetAsString(llvm::StringRef separator) const { return result; } -void UUID::Dump(Stream *s) const { - s->PutCString(GetAsString().c_str()); -} +void UUID::Dump(Stream *s) const { s->PutCString(GetAsString()); } static inline int xdigit_to_int(char ch) { ch = tolower(ch); diff --git a/source/Utility/UriParser.cpp b/source/Utility/UriParser.cpp index a6d81e7a2c8b..282c3c6ed2eb 100644 --- a/source/Utility/UriParser.cpp +++ b/source/Utility/UriParser.cpp @@ -1,9 +1,8 @@ //===-- UriParser.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/UserID.cpp b/source/Utility/UserID.cpp index e65b8fa87d81..b76a1cd84f82 100644 --- a/source/Utility/UserID.cpp +++ b/source/Utility/UserID.cpp @@ -1,9 +1,8 @@ //===-- UserID.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/UuidCompatibility.h b/source/Utility/UuidCompatibility.h index df26f77ab52d..e992c0c79a1f 100644 --- a/source/Utility/UuidCompatibility.h +++ b/source/Utility/UuidCompatibility.h @@ -1,9 +1,8 @@ //===-- UuidCompatibility.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Utility/VASprintf.cpp b/source/Utility/VASprintf.cpp index 900d9754a9b4..0ad3615ba554 100644 --- a/source/Utility/VASprintf.cpp +++ b/source/Utility/VASprintf.cpp @@ -1,21 +1,20 @@ //===-- VASPrintf.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/VASPrintf.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" // for SmallVectorImpl -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" -#include // for assert -#include // for va_end, va_list, va_copy -#include // for vsnprintf, size_t +#include +#include +#include bool lldb_private::VASprintf(llvm::SmallVectorImpl &buf, const char *fmt, va_list args) { diff --git a/source/Utility/VMRange.cpp b/source/Utility/VMRange.cpp index 7e35d3ef0c65..f3f4ae7efc3c 100644 --- a/source/Utility/VMRange.cpp +++ b/source/Utility/VMRange.cpp @@ -1,23 +1,22 @@ //===-- VMRange.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "lldb/Utility/VMRange.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-types.h" #include -#include // for distance -#include // for const_iterator +#include +#include -#include // for size_t -#include // for UINT32_MAX, uint32_t +#include +#include using namespace lldb; using namespace lldb_private; diff --git a/source/lldb.cpp b/source/lldb.cpp index d5b9b2e53613..3515d8562063 100644 --- a/source/lldb.cpp +++ b/source/lldb.cpp @@ -1,9 +1,8 @@ //===-- lldb.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fd18d587c4dd..93242965da17 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -40,7 +40,7 @@ set(LLDB_TEST_USER_ARGS "" CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'") -# The .nodindex suffix is a marker for Spotlight to never index the +# The .noindex suffix is a marker for Spotlight to never index the # build directory. LLDB queries Spotlight to locate .dSYM bundles # based on the UUID embedded in a binary, and because the UUID is a # hash of filename and .text section, there *will* be conflicts inside @@ -85,12 +85,13 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) endif() endif() -if(LLDB_CODESIGN_IDENTITY) - list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}") +if(LLDB_CODESIGN_IDENTITY_USED) + list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY_USED}") endif() if(LLDB_BUILD_FRAMEWORK) - list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_DIR}/LLDB.framework) + get_target_property(framework_target_dir liblldb LIBRARY_OUTPUT_DIRECTORY) + list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_target_dir}/LLDB.framework) endif() if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin") @@ -98,11 +99,17 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin") --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY}) endif() -if(CMAKE_HOST_APPLE) +if (NOT "${LLDB_LIT_TOOLS_DIR}" STREQUAL "") + if (NOT EXISTS "${LLDB_LIT_TOOLS_DIR}") + message(WARNING "LLDB_LIT_TOOLS_DIR ${LLDB_LIT_TOOLS_DIR} does not exist.") + endif() +endif() + +if(CMAKE_HOST_APPLE AND DEBUGSERVER_PATH) list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH}) endif() -if(SKIP_DEBUGSERVER) +if(SKIP_TEST_DEBUGSERVER) list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver) endif() @@ -119,12 +126,20 @@ add_python_test_target(check-lldb-single # output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target. add_custom_target(check-lldb) +# Make check-lldb depend on all test dependencies. +add_dependencies(check-lldb lldb-test-deps) + # If we're building with an in-tree clang, then list clang as a dependency # to run tests. if (TARGET clang) add_dependencies(check-lldb clang) endif() +# If we build the framework, tests will use the tools in there. +if (TARGET lldb-framework) + add_dependencies(check-lldb lldb-framework) +endif() + # LLD is required to link test executables on Windows. if (CMAKE_SYSTEM_NAME MATCHES "Windows") if (TARGET lld) @@ -137,7 +152,6 @@ endif () # Run the lit-style tests and the unittests as part of the check-lldb target. add_dependencies(check-lldb check-lldb-lit) -add_custom_target(lldb-test-depends DEPENDS ${LLDB_TEST_DEPENDS}) -# This will add LLDB's test dependencies to the depenednecies for check-all and +# This will add LLDB's test dependencies to the dependencies for check-all and # include them in the test-depends target. set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS}) diff --git a/test/use_lldb_suite.py b/test/use_lldb_suite.py index 6e24b9da8d34..6a8c12d81898 100644 --- a/test/use_lldb_suite.py +++ b/test/use_lldb_suite.py @@ -4,7 +4,9 @@ def find_lldb_root(): - lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe())) + lldb_root = os.path.dirname( + os.path.abspath(inspect.getfile(inspect.currentframe())) + ) while True: lldb_root = os.path.dirname(lldb_root) if lldb_root is None: diff --git a/third_party/Python/module/unittest2/unittest2/result.py b/third_party/Python/module/unittest2/unittest2/result.py index 9d76429fb4ad..8f89816b772f 100644 --- a/third_party/Python/module/unittest2/unittest2/result.py +++ b/third_party/Python/module/unittest2/unittest2/result.py @@ -148,7 +148,9 @@ def addUnexpectedSuccess(self, test, bugnumber): def wasSuccessful(self): "Tells whether or not this result was a success" - return (len(self.failures) + len(self.errors) == 0) + return (len(self.failures) + + len(self.errors) + + len(self.unexpectedSuccesses) == 0) def stop(self): "Indicates that the tests should be aborted" diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index b44ddef8deb8..aeb646ab1a99 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,13 +1,20 @@ +add_subdirectory(argdumper) +add_subdirectory(driver) +add_subdirectory(intel-features) +add_subdirectory(lldb-mi) +add_subdirectory(lldb-test) +add_subdirectory(lldb-vscode) + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") add_subdirectory(darwin-debug) add_subdirectory(debugserver) endif() -add_subdirectory(argdumper) -add_subdirectory(driver) -add_subdirectory(lldb-mi) -if (LLDB_CAN_USE_LLDB_SERVER) + +if (LLDB_CAN_USE_LLDB_SERVER AND NOT SKIP_LLDB_SERVER_BUILD) add_subdirectory(lldb-server) endif() + +# BEGIN Swift Mods add_subdirectory(repl/swift) -add_subdirectory(intel-features) -add_subdirectory(lldb-test) +# END Swift Mods + diff --git a/tools/argdumper/CMakeLists.txt b/tools/argdumper/CMakeLists.txt index a59a4e7a8514..71c73cc195c2 100644 --- a/tools/argdumper/CMakeLists.txt +++ b/tools/argdumper/CMakeLists.txt @@ -1,4 +1,4 @@ -add_lldb_tool(lldb-argdumper INCLUDE_IN_SUITE +add_lldb_tool(lldb-argdumper argdumper.cpp LINK_LIBS diff --git a/tools/argdumper/argdumper.cpp b/tools/argdumper/argdumper.cpp index 67fd309fa14c..7fd8999c5dce 100644 --- a/tools/argdumper/argdumper.cpp +++ b/tools/argdumper/argdumper.cpp @@ -1,9 +1,8 @@ //===-- argdumper.cpp --------------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/darwin-debug/CMakeLists.txt b/tools/darwin-debug/CMakeLists.txt index c2b5cb486483..5be6e4ee4598 100644 --- a/tools/darwin-debug/CMakeLists.txt +++ b/tools/darwin-debug/CMakeLists.txt @@ -1,3 +1,3 @@ -add_lldb_tool(darwin-debug INCLUDE_IN_SUITE +add_lldb_tool(darwin-debug darwin-debug.cpp ) diff --git a/tools/darwin-debug/darwin-debug.cpp b/tools/darwin-debug/darwin-debug.cpp index e754ded474c4..3c9d025796f8 100644 --- a/tools/darwin-debug/darwin-debug.cpp +++ b/tools/darwin-debug/darwin-debug.cpp @@ -1,9 +1,8 @@ //===-- Launcher.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -24,7 +23,7 @@ //---------------------------------------------------------------------- #if defined(__APPLE__) -#include // for _NSGetEnviron() +#include #include #include #include diff --git a/tools/debugserver/CMakeLists.txt b/tools/debugserver/CMakeLists.txt index ae436b8f07c3..1dc32434ba40 100644 --- a/tools/debugserver/CMakeLists.txt +++ b/tools/debugserver/CMakeLists.txt @@ -8,8 +8,9 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) "${CMAKE_SOURCE_DIR}/../../cmake" "${CMAKE_SOURCE_DIR}/../../cmake/modules" ) - + include(LLDBStandalone) + include(debugserverConfig) include(AddLLDB) set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../") diff --git a/tools/debugserver/source/ARM_DWARF_Registers.h b/tools/debugserver/source/ARM_DWARF_Registers.h index 037d28bf1304..e892927f6cf9 100644 --- a/tools/debugserver/source/ARM_DWARF_Registers.h +++ b/tools/debugserver/source/ARM_DWARF_Registers.h @@ -1,9 +1,8 @@ //===-- ARM_DWARF_Registers.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/ARM_ehframe_Registers.h b/tools/debugserver/source/ARM_ehframe_Registers.h index 9d644b7dc50b..b1a085a506e0 100644 --- a/tools/debugserver/source/ARM_ehframe_Registers.h +++ b/tools/debugserver/source/ARM_ehframe_Registers.h @@ -1,10 +1,9 @@ //===-- ARM_ehframe_Registers.h -------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/CMakeLists.txt b/tools/debugserver/source/CMakeLists.txt index ec136039d349..f9cbd1fb0231 100644 --- a/tools/debugserver/source/CMakeLists.txt +++ b/tools/debugserver/source/CMakeLists.txt @@ -5,7 +5,6 @@ include_directories(${LLDB_SOURCE_DIR}/source) include_directories(MacOSX/DarwinLog) include_directories(MacOSX) -#include_directories(${CMAKE_CURRENT_BINARY_DIR}/MacOSX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/../resources/lldb-debugserver-Info.plist") @@ -31,95 +30,119 @@ check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSIO add_subdirectory(MacOSX) -set(generated_mach_interfaces - ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h - ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c - ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c - ) -add_custom_command(OUTPUT ${generated_mach_interfaces} - COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs - ) - -set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c) -set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) - -add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE} - COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver - > ${DEBUGSERVER_VERS_GENERATED_FILE} - DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl - ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj - ) - -set(lldbDebugserverCommonSources - DNBArch.cpp - DNBBreakpoint.cpp - DNB.cpp - DNBDataRef.cpp - DNBError.cpp - DNBLog.cpp - DNBRegisterInfo.cpp - DNBThreadResumeActions.cpp - JSON.cpp - StdStringExtractor.cpp - # JSON reader depends on the following LLDB-common files - ${LLDB_SOURCE_DIR}/source/Host/common/StringConvert.cpp - ${LLDB_SOURCE_DIR}/source/Host/common/SocketAddress.cpp - # end JSON reader dependencies - libdebugserver.cpp - PseudoTerminal.cpp - PThreadEvent.cpp - PThreadMutex.cpp - RNBContext.cpp - RNBRemote.cpp - RNBServices.cpp - RNBSocket.cpp - SysSignal.cpp - TTYState.cpp - - MacOSX/CFBundle.cpp - MacOSX/CFString.cpp - MacOSX/Genealogy.cpp - MacOSX/MachException.cpp - MacOSX/MachProcess.mm - MacOSX/MachTask.mm - MacOSX/MachThread.cpp - MacOSX/MachThreadList.cpp - MacOSX/MachVMMemory.cpp - MacOSX/MachVMRegion.cpp - MacOSX/OsLogger.cpp - ${generated_mach_interfaces} - ${DEBUGSERVER_VERS_GENERATED_FILE}) - -add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources}) - - -set(LLDB_CODESIGN_IDENTITY "lldb_codesign" - CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.") - -if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "") - set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.") - set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server") +# LLDB-specific identity, currently used for code signing debugserver. +set(LLDB_CODESIGN_IDENTITY "" CACHE STRING + "Override code sign identity for debugserver and for use in tests; falls back to LLVM_CODESIGNING_IDENTITY if set or lldb_codesign otherwise (Darwin only)") + +# Determine which identity to use and store it in the separate cache entry. +# We will query it later for LLDB_TEST_COMMON_ARGS. +if(LLDB_CODESIGN_IDENTITY) + set(LLDB_CODESIGN_IDENTITY_USED ${LLDB_CODESIGN_IDENTITY} CACHE INTERNAL "" FORCE) +elseif(LLVM_CODESIGNING_IDENTITY) + set(LLDB_CODESIGN_IDENTITY_USED ${LLVM_CODESIGNING_IDENTITY} CACHE INTERNAL "" FORCE) else() + set(LLDB_CODESIGN_IDENTITY_USED lldb_codesign CACHE INTERNAL "" FORCE) +endif() + +# Override locally, so the identity is used for targets created in this scope. +set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY_USED}) + +option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF) +option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF) + +# Incompatible options +if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER) + message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER") +endif() + +# Try to locate the system debugserver. +# Subsequent feasibility checks depend on it. +if(APPLE AND CMAKE_HOST_APPLE) execute_process( COMMAND xcode-select -p - OUTPUT_VARIABLE XCODE_DEV_DIR) - string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR) - if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/") - set(DEBUGSERVER_PATH - "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.") - elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/") - set(DEBUGSERVER_PATH - "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.") + OUTPUT_VARIABLE xcode_dev_dir) + string(STRIP ${xcode_dev_dir} xcode_dev_dir) + + set(debugserver_rel_path "LLDB.framework/Resources/debugserver") + set(debugserver_shared "${xcode_dev_dir}/../SharedFrameworks/${debugserver_rel_path}") + set(debugserver_private "${xcode_dev_dir}/Library/PrivateFrameworks/${debugserver_rel_path}") + + if(EXISTS ${debugserver_shared}) + set(system_debugserver ${debugserver_shared}) + elseif(EXISTS ${debugserver_private}) + set(system_debugserver ${debugserver_private}) + endif() +endif() + +# Handle unavailability +if(LLDB_USE_SYSTEM_DEBUGSERVER) + if(system_debugserver) + set(use_system_debugserver ON) + elseif(APPLE AND CMAKE_HOST_APPLE) + # Binary not found on system. Keep cached variable, to try again on reconfigure. + message(SEND_ERROR + "LLDB_USE_SYSTEM_DEBUGSERVER option set, but no debugserver found in:\ + ${debugserver_shared}\ + ${debugserver_private}") else() - message(SEND_ERROR "Cannot find debugserver on system.") + # Non-Apple target platform or non-Darwin host. Reset invalid cached variable. + message(WARNING "Reverting invalid option LLDB_USE_SYSTEM_DEBUGSERVER (Darwin only)") + set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "" FORCE) endif() - set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server") +elseif(NOT LLDB_NO_DEBUGSERVER) + # Default case: on Darwin we need the right code signing ID. + # See lldb/docs/code-signing.txt for details. + if(CMAKE_HOST_APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL "lldb_codesign") + set(msg "Cannot code sign debugserver with identity '${LLVM_CODESIGNING_IDENTITY}'.") + if(system_debugserver) + message(WARNING "${msg} Will fall back to system's debugserver.") + set(use_system_debugserver ON) + else() + message(WARNING "${msg} debugserver will not be available.") + endif() + else() + set(build_and_sign_debugserver ON) + endif() +endif() + +# TODO: We don't use the $ generator expression here, +# because the value of DEBUGSERVER_PATH is used to build LLDB_DOTEST_ARGS, +# which is used for configuring lldb-dotest.in, which does not have a generator +# step at the moment. +set(default_debugserver_path "${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX}") + +# Remember where debugserver binary goes and whether or not we have to test it. +set(DEBUGSERVER_PATH "" CACHE FILEPATH "Path to debugserver") +set(SKIP_TEST_DEBUGSERVER OFF CACHE BOOL "Building the in-tree debugserver was skipped") + +# Reset values in all cases in order to correctly support reconfigurations. +if(use_system_debugserver) + add_custom_target(debugserver + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${system_debugserver} ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMENT "Copying the system debugserver to LLDB's binaries directory.") + + # Don't test debugserver itself. + # Tests that require debugserver will use the copy. + set(DEBUGSERVER_PATH ${default_debugserver_path} CACHE FILEPATH "" FORCE) + set(SKIP_TEST_DEBUGSERVER ON CACHE BOOL "" FORCE) + + message(STATUS "Copy system debugserver from: ${system_debugserver}") +elseif(build_and_sign_debugserver) + # Build, sign and test debugserver (below) + set(DEBUGSERVER_PATH ${default_debugserver_path} CACHE FILEPATH "" FORCE) + set(SKIP_TEST_DEBUGSERVER OFF CACHE BOOL "" FORCE) + + message(STATUS "lldb debugserver: ${DEBUGSERVER_PATH}") +else() + # No tests for debugserver, no tests that require it. + set(DEBUGSERVER_PATH "" CACHE FILEPATH "" FORCE) + set(SKIP_TEST_DEBUGSERVER ON CACHE BOOL "" FORCE) + + message(STATUS "lldb debugserver will not be available.") endif() -message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}") -if (APPLE) +if(APPLE) if(IOS) find_library(BACKBOARD_LIBRARY BackBoardServices PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks) @@ -132,7 +155,7 @@ if (APPLE) find_library(LOCKDOWN_LIBRARY lockdown) if(NOT BACKBOARD_LIBRARY) - set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server" FORCE) + set(SKIP_TEST_DEBUGSERVER ON CACHE BOOL "" FORCE) endif() else() find_library(COCOA_LIBRARY Cocoa) @@ -143,7 +166,79 @@ if(HAVE_LIBCOMPRESSION) set(LIBCOMPRESSION compression) endif() -if(NOT SKIP_DEBUGSERVER) +if(LLDB_USE_ENTITLEMENTS) + if(IOS) + set(entitlements ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist) + else() + # Same entitlements file as used for lldb-server + set(entitlements ${LLDB_SOURCE_DIR}/resources/debugserver-macosx-entitlements.plist) + endif() +endif() + +if(build_and_sign_debugserver) + set(generated_mach_interfaces + ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h + ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c + ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c + ) + add_custom_command(OUTPUT ${generated_mach_interfaces} + COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs + ) + + set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c) + set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) + + add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE} + COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl + ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver + > ${DEBUGSERVER_VERS_GENERATED_FILE} + DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl + ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj + ) + + set(lldbDebugserverCommonSources + DNBArch.cpp + DNBBreakpoint.cpp + DNB.cpp + DNBDataRef.cpp + DNBError.cpp + DNBLog.cpp + DNBRegisterInfo.cpp + DNBThreadResumeActions.cpp + JSON.cpp + StdStringExtractor.cpp + # JSON reader depends on the following LLDB-common files + ${LLDB_SOURCE_DIR}/source/Host/common/StringConvert.cpp + ${LLDB_SOURCE_DIR}/source/Host/common/SocketAddress.cpp + # end JSON reader dependencies + libdebugserver.cpp + PseudoTerminal.cpp + PThreadEvent.cpp + PThreadMutex.cpp + RNBContext.cpp + RNBRemote.cpp + RNBServices.cpp + RNBSocket.cpp + SysSignal.cpp + TTYState.cpp + + MacOSX/CFBundle.cpp + MacOSX/CFString.cpp + MacOSX/Genealogy.cpp + MacOSX/MachException.cpp + MacOSX/MachProcess.mm + MacOSX/MachTask.mm + MacOSX/MachThread.cpp + MacOSX/MachThreadList.cpp + MacOSX/MachVMMemory.cpp + MacOSX/MachVMRegion.cpp + MacOSX/OsLogger.cpp + ${generated_mach_interfaces} + ${DEBUGSERVER_VERS_GENERATED_FILE}) + + add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources}) + target_link_libraries(lldbDebugserverCommon INTERFACE ${COCOA_LIBRARY} ${CORE_FOUNDATION_LIBRARY} @@ -161,12 +256,16 @@ if(NOT SKIP_DEBUGSERVER) COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION) endif() set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources}) - add_lldb_tool(debugserver INCLUDE_IN_SUITE + add_lldb_tool(debugserver debugserver.cpp LINK_LIBS lldbDebugserverCommon + + ENTITLEMENTS + ${entitlements} ) + if(IOS) set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS WITH_LOCKDOWN @@ -181,78 +280,28 @@ if(NOT SKIP_DEBUGSERVER) set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_FLAGS -F${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks ) - endif() -endif() - -if(IOS) - add_library(lldbDebugserverCommon_NonUI ${lldbDebugserverCommonSources}) - target_link_libraries(lldbDebugserverCommon_NonUI - INTERFACE ${COCOA_LIBRARY} - ${CORE_FOUNDATION_LIBRARY} - ${FOUNDATION_LIBRARY} - lldbDebugserverArchSupport - lldbDebugserverDarwin_DarwinLog - ${LIBCOMPRESSION}) - if(HAVE_LIBCOMPRESSION) - set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY - COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION) - endif() - - add_lldb_tool(debugserver-nonui - debugserver.cpp - LINK_LIBS - lldbDebugserverCommon_NonUI - ) -endif() + add_library(lldbDebugserverCommon_NonUI ${lldbDebugserverCommonSources}) + target_link_libraries(lldbDebugserverCommon_NonUI + INTERFACE ${COCOA_LIBRARY} + ${CORE_FOUNDATION_LIBRARY} + ${FOUNDATION_LIBRARY} + lldbDebugserverArchSupport + lldbDebugserverDarwin_DarwinLog + ${LIBCOMPRESSION}) + if(HAVE_LIBCOMPRESSION) + set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY + COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION) + endif() -set(entitlements_xml ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-macosx-entitlements.plist) -if(IOS) - set(entitlements_xml ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist) -else() - set(entitlements_xml ${CMAKE_CURRENT_SOURCE_DIR}/../../../resources/debugserver-macosx-entitlements.plist) -endif() + add_lldb_tool(debugserver-nonui + debugserver.cpp -set(LLDB_USE_ENTITLEMENTS_Default On) -option(LLDB_USE_ENTITLEMENTS "Use entitlements when codesigning (Defaults Off when using lldb_codesign identity, otherwise On)" ${LLDB_USE_ENTITLEMENTS_Default}) + LINK_LIBS + lldbDebugserverCommon_NonUI -if (SKIP_DEBUGSERVER) - if (CMAKE_HOST_APPLE) - # If we haven't built a signed debugserver, copy the one from the system. - add_custom_target(debugserver - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEBUGSERVER_PATH} ${CMAKE_BINARY_DIR}/bin - VERBATIM - COMMENT "Copying the system debugserver to LLDB's binaries directory.") - endif() -else() - if(LLDB_USE_ENTITLEMENTS) - set(entitlements_flags --entitlements ${entitlements_xml}) - endif() - execute_process( - COMMAND xcrun -f codesign_allocate - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE CODESIGN_ALLOCATE - ) - add_custom_command(TARGET debugserver - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} - codesign --force --sign ${LLDB_CODESIGN_IDENTITY} - ${entitlements_flags} - $ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin - ) - if(IOS) - add_custom_command(TARGET debugserver-nonui - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} - codesign --force --sign ${LLDB_CODESIGN_IDENTITY} - ${entitlements_flags} - $ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin - ) + ENTITLEMENTS + ${entitlements} + ) endif() endif() - - - - diff --git a/tools/debugserver/source/DNB.cpp b/tools/debugserver/source/DNB.cpp index 4f212a73d64e..6b57d488b2ff 100644 --- a/tools/debugserver/source/DNB.cpp +++ b/tools/debugserver/source/DNB.cpp @@ -1,9 +1,8 @@ //===-- DNB.cpp -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNB.h b/tools/debugserver/source/DNB.h index bce2c6abafd1..d32040b41110 100644 --- a/tools/debugserver/source/DNB.h +++ b/tools/debugserver/source/DNB.h @@ -1,9 +1,8 @@ //===-- DNB.h ---------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBArch.cpp b/tools/debugserver/source/DNBArch.cpp index 1312bcf7dfdd..931d623647fa 100644 --- a/tools/debugserver/source/DNBArch.cpp +++ b/tools/debugserver/source/DNBArch.cpp @@ -1,9 +1,8 @@ //===-- DNBArch.cpp ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBArch.h b/tools/debugserver/source/DNBArch.h index 317da70e6422..b5e2e25ef47e 100644 --- a/tools/debugserver/source/DNBArch.h +++ b/tools/debugserver/source/DNBArch.h @@ -1,9 +1,8 @@ //===-- DNBArch.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBBreakpoint.cpp b/tools/debugserver/source/DNBBreakpoint.cpp index 89a91287f9e3..890bde024bf0 100644 --- a/tools/debugserver/source/DNBBreakpoint.cpp +++ b/tools/debugserver/source/DNBBreakpoint.cpp @@ -1,9 +1,8 @@ //===-- DNBBreakpoint.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBBreakpoint.h b/tools/debugserver/source/DNBBreakpoint.h index 889478b28957..0b4e077ae8a9 100644 --- a/tools/debugserver/source/DNBBreakpoint.h +++ b/tools/debugserver/source/DNBBreakpoint.h @@ -1,9 +1,8 @@ //===-- DNBBreakpoint.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBDataRef.cpp b/tools/debugserver/source/DNBDataRef.cpp index 8c12b0afac69..073591c8afef 100644 --- a/tools/debugserver/source/DNBDataRef.cpp +++ b/tools/debugserver/source/DNBDataRef.cpp @@ -1,9 +1,8 @@ //===-- DNBDataRef.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBDataRef.h b/tools/debugserver/source/DNBDataRef.h index 9a19f20227e6..ecba580fbded 100644 --- a/tools/debugserver/source/DNBDataRef.h +++ b/tools/debugserver/source/DNBDataRef.h @@ -1,9 +1,8 @@ //===-- DNBDataRef.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBDefs.h b/tools/debugserver/source/DNBDefs.h index 46476490aa69..278caadd79d3 100644 --- a/tools/debugserver/source/DNBDefs.h +++ b/tools/debugserver/source/DNBDefs.h @@ -1,9 +1,8 @@ //===-- DNBDefs.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBError.cpp b/tools/debugserver/source/DNBError.cpp index cd04358a4eca..00933bce1a77 100644 --- a/tools/debugserver/source/DNBError.cpp +++ b/tools/debugserver/source/DNBError.cpp @@ -1,9 +1,8 @@ //===-- DNBError.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBError.h b/tools/debugserver/source/DNBError.h index 419f4b9492ed..2ca2d41de8eb 100644 --- a/tools/debugserver/source/DNBError.h +++ b/tools/debugserver/source/DNBError.h @@ -1,9 +1,8 @@ //===-- DNBError.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBLog.cpp b/tools/debugserver/source/DNBLog.cpp index c3d42a2a84da..3d60b59cc99f 100644 --- a/tools/debugserver/source/DNBLog.cpp +++ b/tools/debugserver/source/DNBLog.cpp @@ -1,9 +1,8 @@ //===-- DNBLog.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBLog.h b/tools/debugserver/source/DNBLog.h index 65181caa412d..47d8aeb066e2 100644 --- a/tools/debugserver/source/DNBLog.h +++ b/tools/debugserver/source/DNBLog.h @@ -1,9 +1,8 @@ //===-- DNBLog.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBRegisterInfo.cpp b/tools/debugserver/source/DNBRegisterInfo.cpp index b85b39378183..c224fc7056dc 100644 --- a/tools/debugserver/source/DNBRegisterInfo.cpp +++ b/tools/debugserver/source/DNBRegisterInfo.cpp @@ -1,9 +1,8 @@ //===-- DNBRegisterInfo.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -156,6 +155,7 @@ void DNBRegisterValueClass::Dump(const char *pre, const char *post) const { DNBLogError( "unsupported vector format %d, defaulting to hex bytes.", info.format); + [[clang::fallthrough]]; case VectorOfUInt8: snprintf(str, sizeof(str), "%s", "uint8 { "); pos = str + strlen(str); diff --git a/tools/debugserver/source/DNBRegisterInfo.h b/tools/debugserver/source/DNBRegisterInfo.h index d665e3cb9485..3aa0e03eaa10 100644 --- a/tools/debugserver/source/DNBRegisterInfo.h +++ b/tools/debugserver/source/DNBRegisterInfo.h @@ -1,9 +1,8 @@ //===-- DNBRegisterInfo.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBRuntimeAction.h b/tools/debugserver/source/DNBRuntimeAction.h index 85d7bc1df0a5..3f0d6021aeaa 100644 --- a/tools/debugserver/source/DNBRuntimeAction.h +++ b/tools/debugserver/source/DNBRuntimeAction.h @@ -1,9 +1,8 @@ //===-- DNBRuntimeAction.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBThreadResumeActions.cpp b/tools/debugserver/source/DNBThreadResumeActions.cpp index 4a97abc20e24..cb747eeeaa1e 100644 --- a/tools/debugserver/source/DNBThreadResumeActions.cpp +++ b/tools/debugserver/source/DNBThreadResumeActions.cpp @@ -1,9 +1,8 @@ //===-- DNBThreadResumeActions.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBThreadResumeActions.h b/tools/debugserver/source/DNBThreadResumeActions.h index 40d2da03e9e4..e2a25abca2a6 100644 --- a/tools/debugserver/source/DNBThreadResumeActions.h +++ b/tools/debugserver/source/DNBThreadResumeActions.h @@ -1,9 +1,8 @@ //===-- DNBThreadResumeActions.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/DNBTimer.h b/tools/debugserver/source/DNBTimer.h index 881b8cdcde76..9792c9b79ab3 100644 --- a/tools/debugserver/source/DNBTimer.h +++ b/tools/debugserver/source/DNBTimer.h @@ -1,9 +1,8 @@ //===-- DNBTimer.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/JSON.cpp b/tools/debugserver/source/JSON.cpp index 439918b6fcc4..548ee1407952 100644 --- a/tools/debugserver/source/JSON.cpp +++ b/tools/debugserver/source/JSON.cpp @@ -1,9 +1,8 @@ //===--------------------- JSON.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/JSON.h b/tools/debugserver/source/JSON.h index 252ff021f912..d843783ca52a 100644 --- a/tools/debugserver/source/JSON.h +++ b/tools/debugserver/source/JSON.h @@ -1,9 +1,8 @@ //===---------------------JSON.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/JSONGenerator.h b/tools/debugserver/source/JSONGenerator.h index 7af6ae60c5f7..463383cad2b4 100644 --- a/tools/debugserver/source/JSONGenerator.h +++ b/tools/debugserver/source/JSONGenerator.h @@ -1,17 +1,14 @@ //===-- JSONGenerator.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 __JSONGenerator_h_ #define __JSONGenerator_h_ -// C Includes -// C++ Includes #include #include @@ -184,7 +181,7 @@ class JSONGenerator { void SetValue(bool value) { m_value = value; } void Dump(std::ostream &s) const override { - if (m_value == true) + if (m_value) s << "true"; else s << "false"; @@ -264,7 +261,7 @@ class JSONGenerator { s << "{"; for (collection::const_iterator iter = m_dict.begin(); iter != m_dict.end(); ++iter) { - if (have_printed_one_elem == false) { + if (!have_printed_one_elem) { have_printed_one_elem = true; } else { s << ","; diff --git a/tools/debugserver/source/MacOSX/CFBundle.cpp b/tools/debugserver/source/MacOSX/CFBundle.cpp index 40f82b4243e0..6825fb374daa 100644 --- a/tools/debugserver/source/MacOSX/CFBundle.cpp +++ b/tools/debugserver/source/MacOSX/CFBundle.cpp @@ -1,9 +1,8 @@ //===-- CFBundle.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/CFBundle.h b/tools/debugserver/source/MacOSX/CFBundle.h index 09957af534b3..c56edee7a03a 100644 --- a/tools/debugserver/source/MacOSX/CFBundle.h +++ b/tools/debugserver/source/MacOSX/CFBundle.h @@ -1,9 +1,8 @@ //===-- CFBundle.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/CFString.cpp b/tools/debugserver/source/MacOSX/CFString.cpp index 84ad56774d7c..3061c429b9a8 100644 --- a/tools/debugserver/source/MacOSX/CFString.cpp +++ b/tools/debugserver/source/MacOSX/CFString.cpp @@ -1,9 +1,8 @@ //===-- CFString.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/CFString.h b/tools/debugserver/source/MacOSX/CFString.h index 18d60a5a74bd..47db507ce38b 100644 --- a/tools/debugserver/source/MacOSX/CFString.h +++ b/tools/debugserver/source/MacOSX/CFString.h @@ -1,9 +1,8 @@ //===-- CFString.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/CFUtils.h b/tools/debugserver/source/MacOSX/CFUtils.h index a904cd0ea6f0..9dae40670f34 100644 --- a/tools/debugserver/source/MacOSX/CFUtils.h +++ b/tools/debugserver/source/MacOSX/CFUtils.h @@ -1,9 +1,8 @@ //===-- CFUtils.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.cpp b/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.cpp index 2cb653894db4..2d831252bfec 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.cpp @@ -1,9 +1,8 @@ //===-- ActivityStore.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.h b/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.h index 35e0a85ad514..b66a789592c6 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/ActivityStore.h @@ -1,9 +1,8 @@ //===-- ActivityStore.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h b/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h index 8aebc79e6ec8..902cb000f018 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h @@ -1,9 +1,8 @@ //===-- ActivityStreamAPI.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp index 1e833c4cb165..7af822a066a1 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp @@ -1,9 +1,8 @@ //===-- DarwinLogCollector.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.h b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.h index a7d4e8a774c2..f12f5752bb98 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.h @@ -1,9 +1,8 @@ //===-- DarwinLogCollector.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogEvent.h b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogEvent.h index 6be3b81f3e10..fb142146bf88 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogEvent.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogEvent.h @@ -1,9 +1,8 @@ //===-- DarwinLogEvent.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogInterfaces.h b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogInterfaces.h index afb979f6cfe4..2bfcb50068ba 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogInterfaces.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogInterfaces.h @@ -1,9 +1,8 @@ //===-- DarwinLogInterfaces.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogTypes.h b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogTypes.h index e285e732e565..e9d84991a4ac 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogTypes.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogTypes.h @@ -1,9 +1,8 @@ //===-- DarwinLogTypes.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.cpp b/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.cpp index d78419d46617..c533c59fa9e2 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.cpp @@ -1,9 +1,8 @@ //===-- LogFilter.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.h b/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.h index 92caac297258..76ab60f1d9f8 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilter.h @@ -1,9 +1,8 @@ //===-- LogFilter.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.cpp b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.cpp index 12fbe77a9069..2d8c655fcf00 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.cpp @@ -1,9 +1,8 @@ //===-- LogFilterChain.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.h b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.h index e4888361e71f..f231c3082327 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterChain.h @@ -1,9 +1,8 @@ //===-- LogFilterChain.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.cpp b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.cpp index c8034fe1f222..bbf911f28cd6 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.cpp @@ -1,9 +1,8 @@ //===-- LogFilterExactMatch.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.h b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.h index dd514bc82744..5c0b9c223561 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterExactMatch.h @@ -1,9 +1,8 @@ //===-- LogFilterExactMatch.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.cpp b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.cpp index d21ce81c832c..9a09e55edba3 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.cpp @@ -1,9 +1,8 @@ //===-- LogFilterRegex.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.h b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.h index 4a5939217f07..5bcc366f077b 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogFilterRegex.h @@ -1,9 +1,8 @@ //===-- LogFilterRegex.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.cpp b/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.cpp index 5a31087f2316..6e5e26ddf898 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.cpp @@ -1,9 +1,8 @@ //===-- LogMessage.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.h b/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.h index bbc975133ece..1f5808c2cd14 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogMessage.h @@ -1,9 +1,8 @@ //===-- LogMessage.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.cpp b/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.cpp index 91347eaf12c7..b5855a9ff5e5 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.cpp +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.cpp @@ -1,9 +1,8 @@ //===-- LogMessageOsLog.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.h b/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.h index 18103e031592..5f50e390aa66 100644 --- a/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.h +++ b/tools/debugserver/source/MacOSX/DarwinLog/LogMessageOsLog.h @@ -1,9 +1,8 @@ //===-- LogMessageOsLog.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/Genealogy.cpp b/tools/debugserver/source/MacOSX/Genealogy.cpp index 22ff52abaa47..803eb913832b 100644 --- a/tools/debugserver/source/MacOSX/Genealogy.cpp +++ b/tools/debugserver/source/MacOSX/Genealogy.cpp @@ -1,9 +1,8 @@ ///===-- Activity.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -74,8 +73,7 @@ Genealogy::GetGenealogyInfoForThread(pid_t pid, nub_thread_t tid, // (else we'll need to hit the timeout for every thread we're asked about.) // We'll try again at the next public stop. - if (m_thread_activities.size() == 0 && - m_diagnosticd_call_timed_out == false) { + if (m_thread_activities.size() == 0 && !m_diagnosticd_call_timed_out) { GetActivities(pid, thread_list, task); } std::map::const_iterator search; diff --git a/tools/debugserver/source/MacOSX/Genealogy.h b/tools/debugserver/source/MacOSX/Genealogy.h index f398b63c6d92..d01df9e6fd89 100644 --- a/tools/debugserver/source/MacOSX/Genealogy.h +++ b/tools/debugserver/source/MacOSX/Genealogy.h @@ -1,10 +1,9 @@ //===-- Activity.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/GenealogySPI.h b/tools/debugserver/source/MacOSX/GenealogySPI.h index de9db2d2e64a..04a67ef074d5 100644 --- a/tools/debugserver/source/MacOSX/GenealogySPI.h +++ b/tools/debugserver/source/MacOSX/GenealogySPI.h @@ -1,9 +1,8 @@ //===-- ActivitySPI.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 __GenealogySPI_h__ diff --git a/tools/debugserver/source/MacOSX/MachException.cpp b/tools/debugserver/source/MacOSX/MachException.cpp index 01e5892d487d..5023eb51d943 100644 --- a/tools/debugserver/source/MacOSX/MachException.cpp +++ b/tools/debugserver/source/MacOSX/MachException.cpp @@ -1,9 +1,8 @@ //===-- MachException.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachException.h b/tools/debugserver/source/MacOSX/MachException.h index e1af12def10a..0a1d34170d67 100644 --- a/tools/debugserver/source/MacOSX/MachException.h +++ b/tools/debugserver/source/MacOSX/MachException.h @@ -1,9 +1,8 @@ //===-- MachException.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachProcess.h b/tools/debugserver/source/MacOSX/MachProcess.h index 2fb4dc5dbb6e..cd4930570d7e 100644 --- a/tools/debugserver/source/MacOSX/MachProcess.h +++ b/tools/debugserver/source/MacOSX/MachProcess.h @@ -1,9 +1,8 @@ //===-- MachProcess.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachProcess.mm b/tools/debugserver/source/MacOSX/MachProcess.mm index edbd012e6e2a..4992a1b612e5 100644 --- a/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/tools/debugserver/source/MacOSX/MachProcess.mm @@ -1,9 +1,8 @@ //===-- MachProcess.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -783,8 +782,8 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, uuid_unparse_upper(image_infos[i].macho_info.uuid, uuidstr); image_info_dict_sp->AddStringItem("uuid", uuidstr); - if (image_infos[i].macho_info.min_version_os_name.empty() == false && - image_infos[i].macho_info.min_version_os_version.empty() == false) { + if (!image_infos[i].macho_info.min_version_os_name.empty() && + !image_infos[i].macho_info.min_version_os_version.empty()) { image_info_dict_sp->AddStringItem( "min_version_os_name", image_infos[i].macho_info.min_version_os_name); image_info_dict_sp->AddStringItem( @@ -1602,7 +1601,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, void MachProcess::ReplyToAllExceptions() { PTHREAD_MUTEX_LOCKER(locker, m_exception_messages_mutex); - if (m_exception_messages.empty() == false) { + if (!m_exception_messages.empty()) { MachException::Message::iterator pos; MachException::Message::iterator begin = m_exception_messages.begin(); MachException::Message::iterator end = m_exception_messages.end(); @@ -1774,7 +1773,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, if (bp->IsHardware()) { bool hw_disable_result = m_thread_list.DisableHardwareBreakpoint(bp); - if (hw_disable_result == true) { + if (hw_disable_result) { bp->SetEnabled(false); // Let the thread list know that a breakpoint has been modified if (remove) { @@ -1909,7 +1908,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, if (wp->IsHardware()) { bool hw_disable_result = m_thread_list.DisableHardwareWatchpoint(wp); - if (hw_disable_result == true) { + if (hw_disable_result) { wp->SetEnabled(false); if (remove) m_watchpoints.Remove(addr); @@ -2179,7 +2178,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options, m_thread_list.Dump(); bool step_more = false; - if (m_thread_list.ShouldStop(step_more) && auto_resume == false) { + if (m_thread_list.ShouldStop(step_more) && !auto_resume) { // Wait for the eEventProcessRunningStateChanged event to be reset // before changing state to stopped to avoid race condition with // very fast start/stops diff --git a/tools/debugserver/source/MacOSX/MachTask.h b/tools/debugserver/source/MacOSX/MachTask.h index 1e0e2af9a92b..ad25f0e415f3 100644 --- a/tools/debugserver/source/MacOSX/MachTask.h +++ b/tools/debugserver/source/MacOSX/MachTask.h @@ -1,9 +1,8 @@ //===-- MachTask.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// //---------------------------------------------------------------------- @@ -18,14 +17,10 @@ #ifndef __MachTask_h__ #define __MachTask_h__ -// C Includes #include #include -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes #include "DNBDefs.h" #include "MachException.h" #include "MachVMMemory.h" diff --git a/tools/debugserver/source/MacOSX/MachTask.mm b/tools/debugserver/source/MacOSX/MachTask.mm index d05f50029f16..0b4f790ad14f 100644 --- a/tools/debugserver/source/MacOSX/MachTask.mm +++ b/tools/debugserver/source/MacOSX/MachTask.mm @@ -1,9 +1,8 @@ //===-- MachTask.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// //---------------------------------------------------------------------- diff --git a/tools/debugserver/source/MacOSX/MachThread.cpp b/tools/debugserver/source/MacOSX/MachThread.cpp index fc97825786a0..628b6282e7e1 100644 --- a/tools/debugserver/source/MacOSX/MachThread.cpp +++ b/tools/debugserver/source/MacOSX/MachThread.cpp @@ -1,9 +1,8 @@ //===-- MachThread.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -83,7 +82,7 @@ bool MachThread::SetSuspendCountBeforeResume(bool others_stopped) { DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); DNBError err; - if (MachPortNumberIsValid(m_mach_port_number) == false) + if (!MachPortNumberIsValid(m_mach_port_number)) return false; integer_t times_to_resume; @@ -121,7 +120,7 @@ bool MachThread::RestoreSuspendCountAfterStop() { DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); DNBError err; - if (MachPortNumberIsValid(m_mach_port_number) == false) + if (!MachPortNumberIsValid(m_mach_port_number)) return false; if (m_suspend_count > 0) { diff --git a/tools/debugserver/source/MacOSX/MachThread.h b/tools/debugserver/source/MacOSX/MachThread.h index a98d8aa2b05c..758bbf3b360a 100644 --- a/tools/debugserver/source/MacOSX/MachThread.h +++ b/tools/debugserver/source/MacOSX/MachThread.h @@ -1,9 +1,8 @@ //===-- MachThread.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachThreadList.cpp b/tools/debugserver/source/MacOSX/MachThreadList.cpp index 05e9627b591b..d133b1e19939 100644 --- a/tools/debugserver/source/MacOSX/MachThreadList.cpp +++ b/tools/debugserver/source/MacOSX/MachThreadList.cpp @@ -1,9 +1,8 @@ //===-- MachThreadList.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachThreadList.h b/tools/debugserver/source/MacOSX/MachThreadList.h index bcef695edf87..b9b7aa8c4c92 100644 --- a/tools/debugserver/source/MacOSX/MachThreadList.h +++ b/tools/debugserver/source/MacOSX/MachThreadList.h @@ -1,9 +1,8 @@ //===-- MachThreadList.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachVMMemory.cpp b/tools/debugserver/source/MacOSX/MachVMMemory.cpp index 754fb82dba3e..74ddae67958f 100644 --- a/tools/debugserver/source/MacOSX/MachVMMemory.cpp +++ b/tools/debugserver/source/MacOSX/MachVMMemory.cpp @@ -1,9 +1,8 @@ //===-- MachVMMemory.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachVMMemory.h b/tools/debugserver/source/MacOSX/MachVMMemory.h index 513b69ee709f..538e11232a8a 100644 --- a/tools/debugserver/source/MacOSX/MachVMMemory.h +++ b/tools/debugserver/source/MacOSX/MachVMMemory.h @@ -1,9 +1,8 @@ //===-- MachVMMemory.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/MachVMRegion.cpp b/tools/debugserver/source/MacOSX/MachVMRegion.cpp index c011c133ac38..1d6f4c7f9df4 100644 --- a/tools/debugserver/source/MacOSX/MachVMRegion.cpp +++ b/tools/debugserver/source/MacOSX/MachVMRegion.cpp @@ -1,9 +1,8 @@ //===-- MachVMRegion.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -166,10 +165,7 @@ bool MachVMRegion::GetRegionForAddress(nub_addr_t addr) { // doesn't mean that "addr" is in the range. The data in this object will // be valid though, so you could see where the next region begins. So we // return false, yet leave "m_err" with a successfull return code. - if ((addr < m_start) || (addr >= (m_start + m_size))) - return false; - - return true; + return !((addr < m_start) || (addr >= (m_start + m_size))); } uint32_t MachVMRegion::GetDNBPermissions() const { diff --git a/tools/debugserver/source/MacOSX/MachVMRegion.h b/tools/debugserver/source/MacOSX/MachVMRegion.h index 758112d236d7..2e6303c4b39b 100644 --- a/tools/debugserver/source/MacOSX/MachVMRegion.h +++ b/tools/debugserver/source/MacOSX/MachVMRegion.h @@ -1,9 +1,8 @@ //===-- MachVMRegion.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/OsLogger.cpp b/tools/debugserver/source/MacOSX/OsLogger.cpp index 40aeec73f0aa..5e13819de873 100644 --- a/tools/debugserver/source/MacOSX/OsLogger.cpp +++ b/tools/debugserver/source/MacOSX/OsLogger.cpp @@ -1,9 +1,8 @@ //===-- OsLogger.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/OsLogger.h b/tools/debugserver/source/MacOSX/OsLogger.h index 9afdcb974d9a..5a173c42b83b 100644 --- a/tools/debugserver/source/MacOSX/OsLogger.h +++ b/tools/debugserver/source/MacOSX/OsLogger.h @@ -1,9 +1,8 @@ //===-- OsLogger.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/ThreadInfo.h b/tools/debugserver/source/MacOSX/ThreadInfo.h index e9773caf9ea3..00c368c6ab04 100644 --- a/tools/debugserver/source/MacOSX/ThreadInfo.h +++ b/tools/debugserver/source/MacOSX/ThreadInfo.h @@ -1,10 +1,9 @@ //===-- ThreadInfo.h -----------------------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp b/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp index 2841ddb11081..0d2455e123db 100644 --- a/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp +++ b/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp @@ -1,9 +1,8 @@ //===-- DNBArchImpl.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h b/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h index e8622c4ec7eb..0bc1b50cdf92 100644 --- a/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h +++ b/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h @@ -1,9 +1,8 @@ //===-- DNBArchImpl.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp b/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp index 51bc5aaee5bb..8fedb984182d 100644 --- a/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp +++ b/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp @@ -1,9 +1,8 @@ //===-- DNBArchMachARM64.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h b/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h index cde0abf42d53..c6e4af683e01 100644 --- a/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h +++ b/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h @@ -1,9 +1,8 @@ //===-- DNBArchMachARM64.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp index adcd65002191..1854a9c831e6 100644 --- a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp +++ b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp @@ -1,9 +1,8 @@ //===-- DNBArchImplI386.cpp -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -889,10 +888,7 @@ bool DNBArchImplI386::RollbackTransForHWP() { LOG_WATCHPOINTS, "DNBArchImplI386::RollbackTransForHWP() SetDBGState() => 0x%8.8x.", kret); - if (kret == KERN_SUCCESS) - return true; - else - return false; + return kret == KERN_SUCCESS; } bool DNBArchImplI386::FinishTransForHWP() { m_2pc_trans_state = Trans_Done; @@ -918,7 +914,7 @@ uint32_t DNBArchImplI386::EnableHardwareWatchpoint(nub_addr_t addr, return INVALID_NUB_HW_INDEX; // We must watch for either read or write - if (read == false && write == false) + if (!read && !write) return INVALID_NUB_HW_INDEX; // Read the debug state diff --git a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h index ce56a540e092..80b3c1c59190 100644 --- a/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h +++ b/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h @@ -1,9 +1,8 @@ //===-- DNBArchImplI386.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h b/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h index e51ecfd24bef..6eab0ad7a5af 100644 --- a/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h +++ b/tools/debugserver/source/MacOSX/i386/MachRegisterStatesI386.h @@ -1,9 +1,8 @@ //===-- MachRegisterStatesI386.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp b/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp index 1653287430ad..141b6b72c2a4 100644 --- a/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp +++ b/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp @@ -1,9 +1,8 @@ //===-- DNBArchImpl.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h b/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h index 8aed9fc0f80a..f9c094b9189f 100644 --- a/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h +++ b/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h @@ -1,9 +1,8 @@ //===-- DNBArchImpl.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp index f0a3d2b001b2..4f32d44e69f8 100644 --- a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp +++ b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp @@ -1,9 +1,8 @@ //===-- DNBArchImplX86_64.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -844,10 +843,7 @@ bool DNBArchImplX86_64::RollbackTransForHWP() { "DNBArchImplX86_64::RollbackTransForHWP() SetDBGState() => 0x%8.8x.", kret); - if (kret == KERN_SUCCESS) - return true; - else - return false; + return kret == KERN_SUCCESS; } bool DNBArchImplX86_64::FinishTransForHWP() { m_2pc_trans_state = Trans_Done; @@ -873,7 +869,7 @@ uint32_t DNBArchImplX86_64::EnableHardwareWatchpoint(nub_addr_t addr, return INVALID_NUB_HW_INDEX; // We must watch for either read or write - if (read == false && write == false) + if (!read && !write) return INVALID_NUB_HW_INDEX; // Read the debug state diff --git a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h index ef2ba1ee09a6..2ec254de7f24 100644 --- a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h +++ b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h @@ -1,9 +1,8 @@ //===-- DNBArchImplX86_64.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h b/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h index fcb648dac59e..818396668373 100644 --- a/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h +++ b/tools/debugserver/source/MacOSX/x86_64/MachRegisterStatesX86_64.h @@ -1,10 +1,9 @@ //===-- MachRegisterStatesX86_64.h --------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/PThreadCondition.h b/tools/debugserver/source/PThreadCondition.h index 9cd64bf24723..2f9060da0280 100644 --- a/tools/debugserver/source/PThreadCondition.h +++ b/tools/debugserver/source/PThreadCondition.h @@ -1,9 +1,8 @@ //===-- PThreadCondition.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/PThreadEvent.cpp b/tools/debugserver/source/PThreadEvent.cpp index 1b0900ca7107..9a70b25a8802 100644 --- a/tools/debugserver/source/PThreadEvent.cpp +++ b/tools/debugserver/source/PThreadEvent.cpp @@ -1,9 +1,8 @@ //===-- PThreadEvent.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/PThreadEvent.h b/tools/debugserver/source/PThreadEvent.h index fbcd4593352b..00c8316ef077 100644 --- a/tools/debugserver/source/PThreadEvent.h +++ b/tools/debugserver/source/PThreadEvent.h @@ -1,9 +1,8 @@ //===-- PThreadEvent.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/PThreadMutex.cpp b/tools/debugserver/source/PThreadMutex.cpp index 32db862f6b42..118921aee5a8 100644 --- a/tools/debugserver/source/PThreadMutex.cpp +++ b/tools/debugserver/source/PThreadMutex.cpp @@ -1,9 +1,8 @@ //===-- PThreadMutex.cpp ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -13,10 +12,6 @@ #include "PThreadMutex.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "DNBTimer.h" #if defined(DEBUG_PTHREAD_MUTEX_DEADLOCKS) diff --git a/tools/debugserver/source/PThreadMutex.h b/tools/debugserver/source/PThreadMutex.h index c6ec293c5e59..075fdc9114f3 100644 --- a/tools/debugserver/source/PThreadMutex.h +++ b/tools/debugserver/source/PThreadMutex.h @@ -1,9 +1,8 @@ //===-- PThreadMutex.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/PseudoTerminal.cpp b/tools/debugserver/source/PseudoTerminal.cpp index 892574a61dcf..0a75bc9741ff 100644 --- a/tools/debugserver/source/PseudoTerminal.cpp +++ b/tools/debugserver/source/PseudoTerminal.cpp @@ -1,9 +1,8 @@ //===-- PseudoTerminal.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/PseudoTerminal.h b/tools/debugserver/source/PseudoTerminal.h index f6b71f8909a6..c14042a41c48 100644 --- a/tools/debugserver/source/PseudoTerminal.h +++ b/tools/debugserver/source/PseudoTerminal.h @@ -1,9 +1,8 @@ //===-- PseudoTerminal.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBContext.cpp b/tools/debugserver/source/RNBContext.cpp index c86511c6e226..87f24ccf1b9c 100644 --- a/tools/debugserver/source/RNBContext.cpp +++ b/tools/debugserver/source/RNBContext.cpp @@ -1,9 +1,8 @@ //===-- RNBContext.cpp ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBContext.h b/tools/debugserver/source/RNBContext.h index 0c649ae41007..c2a0d3374d7b 100644 --- a/tools/debugserver/source/RNBContext.h +++ b/tools/debugserver/source/RNBContext.h @@ -1,9 +1,8 @@ //===-- RNBContext.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBDefs.h b/tools/debugserver/source/RNBDefs.h index 5714099f5fcd..fbd51f499bf5 100644 --- a/tools/debugserver/source/RNBDefs.h +++ b/tools/debugserver/source/RNBDefs.h @@ -1,9 +1,8 @@ //===-- RNBDefs.h -----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBRemote.cpp b/tools/debugserver/source/RNBRemote.cpp index 0da918184876..54031fe4cf11 100644 --- a/tools/debugserver/source/RNBRemote.cpp +++ b/tools/debugserver/source/RNBRemote.cpp @@ -1,9 +1,8 @@ //===-- RNBRemote.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -44,7 +43,7 @@ #include -#include // for endianness predefines +#include #include #include #include @@ -1825,18 +1824,18 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) { } if (*c == '\0') { std::string command = get_identifier(line); - if (command.compare("set") == 0) { + if (command == "set") { std::string variable = get_identifier(line); std::string op = get_operator(line); std::string value = get_value(line); - if (variable.compare("logfile") == 0) { + if (variable == "logfile") { FILE *log_file = fopen(value.c_str(), "w"); if (log_file) { DNBLogSetLogCallback(FileLogCallback, log_file); return SendPacket("OK"); } return SendPacket("E71"); - } else if (variable.compare("logmask") == 0) { + } else if (variable == "logmask") { char *end; errno = 0; uint32_t logmask = @@ -3427,10 +3426,7 @@ static bool RNBRemoteShouldCancelCallback(void *not_used) { RNBRemoteSP remoteSP(g_remoteSP); if (remoteSP.get() != NULL) { RNBRemote *remote = remoteSP.get(); - if (remote->Comm().IsConnected()) - return false; - else - return true; + return !remote->Comm().IsConnected(); } return true; } @@ -3694,7 +3690,7 @@ rnb_err_t RNBRemote::HandlePacket_v(const char *p) { return HandlePacket_ILLFORMED( __FILE__, __LINE__, p, "Could not parse signal in vCont packet"); // Fall through to next case... - + [[clang::fallthrough]]; case 'c': // Continue thread_action.state = eStateRunning; @@ -3707,7 +3703,7 @@ rnb_err_t RNBRemote::HandlePacket_v(const char *p) { return HandlePacket_ILLFORMED( __FILE__, __LINE__, p, "Could not parse signal in vCont packet"); // Fall through to next case... - + [[clang::fallthrough]]; case 's': // Step thread_action.state = eStateStepping; @@ -3821,7 +3817,7 @@ rnb_err_t RNBRemote::HandlePacket_v(const char *p) { attach_failed_due_to_sip = true; } - if (attach_failed_due_to_sip == false) { + if (!attach_failed_due_to_sip) { int csops_flags = 0; int retval = ::csops(pid_attaching_to, CS_OPS_STATUS, &csops_flags, sizeof(csops_flags)); @@ -4234,7 +4230,7 @@ rnb_err_t RNBRemote::HandlePacket_GetProfileData(const char *p) { std::string name; std::string value; while (packet.GetNameColonValue(name, value)) { - if (name.compare("scan_type") == 0) { + if (name == "scan_type") { std::istringstream iss(value); uint32_t int_value = 0; if (iss >> std::hex >> int_value) { @@ -4264,11 +4260,11 @@ rnb_err_t RNBRemote::HandlePacket_SetEnableAsyncProfiling(const char *p) { std::string name; std::string value; while (packet.GetNameColonValue(name, value)) { - if (name.compare("enable") == 0) { + if (name == "enable") { enable = strtoul(value.c_str(), NULL, 10) > 0; - } else if (name.compare("interval_usec") == 0) { + } else if (name == "interval_usec") { interval_usec = strtoul(value.c_str(), NULL, 10); - } else if (name.compare("scan_type") == 0) { + } else if (name == "scan_type") { std::istringstream iss(value); uint32_t int_value = 0; if (iss >> std::hex >> int_value) { @@ -5294,7 +5290,7 @@ RNBRemote::GetJSONThreadsInfo(bool threads_with_valid_stop_info_only) { thread_dict_sp->AddStringItem("reason", reason_value); - if (threads_with_valid_stop_info_only == false) { + if (!threads_with_valid_stop_info_only) { const char *thread_name = DNBThreadGetName(pid, tid); if (thread_name && thread_name[0]) thread_dict_sp->AddStringItem("name", thread_name); @@ -5482,7 +5478,7 @@ rnb_err_t RNBRemote::HandlePacket_jThreadExtendedInfo(const char *p) { bool need_to_print_comma = false; - if (thread_activity_sp && timed_out == false) { + if (thread_activity_sp && !timed_out) { const Genealogy::Activity *activity = &thread_activity_sp->current_activity; bool need_vouchers_comma_sep = false; diff --git a/tools/debugserver/source/RNBRemote.h b/tools/debugserver/source/RNBRemote.h index 0c9c9856308a..d59f42af0be4 100644 --- a/tools/debugserver/source/RNBRemote.h +++ b/tools/debugserver/source/RNBRemote.h @@ -1,9 +1,8 @@ // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBServices.cpp b/tools/debugserver/source/RNBServices.cpp index b2f4910f8855..085aaddfaf15 100644 --- a/tools/debugserver/source/RNBServices.cpp +++ b/tools/debugserver/source/RNBServices.cpp @@ -1,9 +1,8 @@ //===-- RNBServices.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -57,9 +56,9 @@ int GetProcesses(CFMutableArrayRef plistMutableArray, bool all_users) { const pid_t pid = proc_info.kp_proc.p_pid; // Skip zombie processes and processes with unset status - if (kinfo_user_matches == false || // User is acceptable - pid == our_pid || // Skip this process - pid == 0 || // Skip kernel (kernel pid is zero) + if (!kinfo_user_matches || // User is acceptable + pid == our_pid || // Skip this process + pid == 0 || // Skip kernel (kernel pid is zero) proc_info.kp_proc.p_stat == SZOMB || // Zombies are bad, they like brains... proc_info.kp_proc.p_flag & P_TRACED || // Being debugged? diff --git a/tools/debugserver/source/RNBServices.h b/tools/debugserver/source/RNBServices.h index caa2b0fd199e..b7514f31b21e 100644 --- a/tools/debugserver/source/RNBServices.h +++ b/tools/debugserver/source/RNBServices.h @@ -1,9 +1,8 @@ //===-- RNBServices.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBSocket.cpp b/tools/debugserver/source/RNBSocket.cpp index 88136c210acc..80b55b5de3b7 100644 --- a/tools/debugserver/source/RNBSocket.cpp +++ b/tools/debugserver/source/RNBSocket.cpp @@ -1,9 +1,8 @@ //===-- RNBSocket.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/RNBSocket.h b/tools/debugserver/source/RNBSocket.h index 9f636d855621..da6c6d888748 100644 --- a/tools/debugserver/source/RNBSocket.h +++ b/tools/debugserver/source/RNBSocket.h @@ -1,9 +1,8 @@ //===-- RNBSocket.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/StdStringExtractor.cpp b/tools/debugserver/source/StdStringExtractor.cpp index d23f9319fa7b..a52e8aba5d9a 100644 --- a/tools/debugserver/source/StdStringExtractor.cpp +++ b/tools/debugserver/source/StdStringExtractor.cpp @@ -1,20 +1,15 @@ //===-- StdStringExtractor.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "StdStringExtractor.h" -// C Includes #include -// C++ Includes -// Other libraries and framework includes -// Project includes static inline int xdigit_to_sint(char ch) { if (ch >= 'a' && ch <= 'f') diff --git a/tools/debugserver/source/StdStringExtractor.h b/tools/debugserver/source/StdStringExtractor.h index c46978b61f4f..cc256f5655fc 100644 --- a/tools/debugserver/source/StdStringExtractor.h +++ b/tools/debugserver/source/StdStringExtractor.h @@ -1,22 +1,17 @@ //===-- StdStringExtractor.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 utility_StdStringExtractor_h_ #define utility_StdStringExtractor_h_ -// C Includes -// C++ Includes #include #include -// Other libraries and framework includes -// Project includes // Based on StringExtractor, with the added limitation that this file should not // take a dependency on LLVM, as it is used from debugserver. diff --git a/tools/debugserver/source/SysSignal.cpp b/tools/debugserver/source/SysSignal.cpp index c2995f362c03..9afbbec0987d 100644 --- a/tools/debugserver/source/SysSignal.cpp +++ b/tools/debugserver/source/SysSignal.cpp @@ -1,9 +1,8 @@ //===-- SysSignal.cpp -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/SysSignal.h b/tools/debugserver/source/SysSignal.h index c9827126c18b..b6fc67f9be78 100644 --- a/tools/debugserver/source/SysSignal.h +++ b/tools/debugserver/source/SysSignal.h @@ -1,9 +1,8 @@ //===-- SysSignal.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/TTYState.cpp b/tools/debugserver/source/TTYState.cpp index 5f10050fcdde..96699a360499 100644 --- a/tools/debugserver/source/TTYState.cpp +++ b/tools/debugserver/source/TTYState.cpp @@ -1,9 +1,8 @@ //===-- TTYState.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // diff --git a/tools/debugserver/source/TTYState.h b/tools/debugserver/source/TTYState.h index ab34015e1a42..01ef579cc6ce 100644 --- a/tools/debugserver/source/TTYState.h +++ b/tools/debugserver/source/TTYState.h @@ -1,9 +1,8 @@ //===-- TTYState.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // @@ -56,4 +55,4 @@ class TTYStateSwitcher { TTYState m_ttystates[2]; }; -#endif \ No newline at end of file +#endif diff --git a/tools/debugserver/source/debugserver-entitlements.plist b/tools/debugserver/source/debugserver-entitlements.plist index 7f1ae4615019..6d9f44536f94 100644 --- a/tools/debugserver/source/debugserver-entitlements.plist +++ b/tools/debugserver/source/debugserver-entitlements.plist @@ -12,8 +12,6 @@ com.apple.frontboard.debugapplications - run-unsigned-code - seatbelt-profiles debugserver diff --git a/tools/debugserver/source/debugserver.cpp b/tools/debugserver/source/debugserver.cpp index 7ae321ba431b..a56ae87bdc69 100644 --- a/tools/debugserver/source/debugserver.cpp +++ b/tools/debugserver/source/debugserver.cpp @@ -1,27 +1,24 @@ //===-- debugserver.cpp -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include #include -#include // for _NSGetEnviron() +#include #include #include #include #include -#include #include #include #include #include #include #include -#include #include #include diff --git a/tools/debugserver/source/libdebugserver.cpp b/tools/debugserver/source/libdebugserver.cpp index 0d27cfd89a3d..98e1f8d618d4 100644 --- a/tools/debugserver/source/libdebugserver.cpp +++ b/tools/debugserver/source/libdebugserver.cpp @@ -1,9 +1,8 @@ //===-- libdebugserver.cpp --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -176,7 +175,7 @@ RNBRunLoopMode HandleProcessStateChange(RNBRemoteSP &remote, bool initialize) { case eStateSuspended: case eStateCrashed: case eStateStopped: - if (initialize == false) { + if (!initialize) { // Compare the last stop count to our current notion of a stop count // to make sure we don't notify more than once for a given stop. nub_size_t prev_pid_stop_count = ctx.GetProcessStopCount(); diff --git a/tools/debugserver/source/libdebugserver.h b/tools/debugserver/source/libdebugserver.h index 2576e269ee60..17b048bcbbcf 100644 --- a/tools/debugserver/source/libdebugserver.h +++ b/tools/debugserver/source/libdebugserver.h @@ -1,9 +1,8 @@ //===-- libdebugserver.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index 9e01a6b67ea2..9636e1e2c790 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -1,12 +1,6 @@ -if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR - (CMAKE_SYSTEM_NAME MATCHES "NetBSD" )) - # These targets do not have getopt support, so they rely on the one provided by - # liblldb. However, getopt is not a part of the liblldb interface, so we have - # to link against the constituent libraries manually. Note that this is - # extremely scary as it introduces ODR violations, and it should go away as - # soon as possible. - set(host_lib lldbHost) -endif() +set(LLVM_TARGET_DEFINITIONS Options.td) +tablegen(LLVM Options.inc -gen-opt-parser-defs) +add_public_tablegen_target(LLDBOptionsTableGen) add_lldb_tool(lldb Driver.cpp @@ -14,9 +8,9 @@ add_lldb_tool(lldb LINK_LIBS liblldb - ${host_lib} LINK_COMPONENTS + Option Support ) @@ -24,4 +18,11 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) add_definitions( -DIMPORT_LIBLLDB ) endif() -add_dependencies(lldb ${LLDB_SUITE_TARGET}) +add_dependencies(lldb + LLDBOptionsTableGen + ${tablegen_deps} +) + +if(LLDB_BUILD_FRAMEWORK) + lldb_setup_framework_rpaths_in_tool(lldb) +endif() diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp index 31846f4c081f..a4e509a4aec1 100644 --- a/tools/driver/Driver.cpp +++ b/tools/driver/Driver.cpp @@ -1,17 +1,38 @@ //===-- Driver.cpp ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// #include "Driver.h" +#include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBStringList.h" + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/Signals.h" +#include "llvm/Support/WithColor.h" +#include "llvm/Support/raw_ostream.h" + #include #include +#include #include +#include +#include +#include + #include #include #include @@ -26,40 +47,50 @@ #include #endif -#include - -#include "lldb/API/SBBreakpoint.h" -#include "lldb/API/SBCommandInterpreter.h" -#include "lldb/API/SBCommandReturnObject.h" -#include "lldb/API/SBCommunication.h" -#include "lldb/API/SBDebugger.h" -#include "lldb/API/SBEvent.h" -#include "lldb/API/SBHostOS.h" -#include "lldb/API/SBLanguageRuntime.h" -#include "lldb/API/SBListener.h" -#include "lldb/API/SBProcess.h" -#include "lldb/API/SBStream.h" -#include "lldb/API/SBStringList.h" -#include "lldb/API/SBTarget.h" -#include "lldb/API/SBThread.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/ConvertUTF.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" -#include -#include - #if !defined(__APPLE__) #include "llvm/Support/DataTypes.h" #endif using namespace lldb; +using namespace llvm; + +namespace { +enum ID { + OPT_INVALID = 0, // This is not an option ID. +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES) \ + OPT_##ID, +#include "Options.inc" +#undef OPTION +}; + +#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; +#include "Options.inc" +#undef PREFIX + +const opt::OptTable::Info InfoTable[] = { +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES) \ + { \ + PREFIX, NAME, HELPTEXT, \ + METAVAR, OPT_##ID, opt::Option::KIND##Class, \ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, VALUES}, +#include "Options.inc" +#undef OPTION +}; + +class LLDBOptTable : public opt::OptTable { +public: + LLDBOptTable() : OptTable(InfoTable) {} +}; +} // namespace static void reset_stdin_termios(); static bool g_old_stdin_termios_is_valid = false; static struct termios g_old_stdin_termios; -static Driver *g_driver = NULL; +static Driver *g_driver = nullptr; // In the Driver::MainLoop, we change the terminal settings. This function is // added as an atexit handler to make sure we clean them up. @@ -70,395 +101,39 @@ static void reset_stdin_termios() { } } -typedef struct { - uint32_t usage_mask; // Used to mark options that can be used together. If (1 - // << n & usage_mask) != 0 - // then this option belongs to option set n. - bool required; // This option is required (in the current usage level) - const char *long_option; // Full name for this option. - int short_option; // Single character for this option. - int option_has_arg; // no_argument, required_argument or optional_argument - uint32_t completion_type; // Cookie the option class can use to do define the - // argument completion. - lldb::CommandArgumentType argument_type; // Type of argument this option takes - const char *usage_text; // Full text explaining what this options does and - // what (if any) argument to - // pass it. -} OptionDefinition; - -#define LLDB_3_TO_5 LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5 -#define LLDB_4_TO_5 LLDB_OPT_SET_4 | LLDB_OPT_SET_5 - -static constexpr OptionDefinition g_options[] = { - {LLDB_OPT_SET_1, true, "help", 'h', no_argument, 0, eArgTypeNone, - "Prints out the usage information for the LLDB debugger."}, - {LLDB_OPT_SET_2, true, "version", 'v', no_argument, 0, eArgTypeNone, - "Prints out the current version number of the LLDB debugger."}, - {LLDB_OPT_SET_3, true, "arch", 'a', required_argument, 0, - eArgTypeArchitecture, - "Tells the debugger to use the specified architecture when starting and " - "running the program. must " - "be one of the architectures for which the program was compiled."}, - {LLDB_OPT_SET_3, true, "file", 'f', required_argument, 0, eArgTypeFilename, - "Tells the debugger to use the file as the program to be " - "debugged."}, - {LLDB_OPT_SET_3, false, "core", 'c', required_argument, 0, eArgTypeFilename, - "Tells the debugger to use the fullpath to as the core file."}, - {LLDB_OPT_SET_5, true, "attach-pid", 'p', required_argument, 0, eArgTypePid, - "Tells the debugger to attach to a process with the given pid."}, - {LLDB_OPT_SET_4, true, "attach-name", 'n', required_argument, 0, - eArgTypeProcessName, - "Tells the debugger to attach to a process with the given name."}, - {LLDB_OPT_SET_4, true, "wait-for", 'w', no_argument, 0, eArgTypeNone, - "Tells the debugger to wait for a process with the given pid or name to " - "launch before attaching."}, - {LLDB_3_TO_5, false, "source", 's', required_argument, 0, eArgTypeFilename, - "Tells the debugger to read in and execute the lldb commands in the given " - "file, after any file provided on the command line has been loaded."}, - {LLDB_3_TO_5, false, "one-line", 'o', required_argument, 0, eArgTypeNone, - "Tells the debugger to execute this one-line lldb command after any file " - "provided on the command line has been loaded."}, - {LLDB_3_TO_5, false, "source-before-file", 'S', required_argument, 0, - eArgTypeFilename, "Tells the debugger to read in and execute the lldb " - "commands in the given file, before any file provided " - "on the command line has been loaded."}, - {LLDB_3_TO_5, false, "one-line-before-file", 'O', required_argument, 0, - eArgTypeNone, "Tells the debugger to execute this one-line lldb command " - "before any file provided on the command line has been " - "loaded."}, - {LLDB_3_TO_5, false, "one-line-on-crash", 'k', required_argument, 0, - eArgTypeNone, "When in batch mode, tells the debugger to execute this " - "one-line lldb command if the target crashes."}, - {LLDB_3_TO_5, false, "source-on-crash", 'K', required_argument, 0, - eArgTypeFilename, "When in batch mode, tells the debugger to source this " - "file of lldb commands if the target crashes."}, - {LLDB_3_TO_5, false, "source-quietly", 'Q', no_argument, 0, eArgTypeNone, - "Tells the debugger to execute this one-line lldb command before any file " - "provided on the command line has been loaded."}, - {LLDB_3_TO_5, false, "batch", 'b', no_argument, 0, eArgTypeNone, - "Tells the debugger to run the commands from -s, -S, -o & -O, and " - "then quit. However if any run command stopped due to a signal or crash, " - "the debugger will return to the interactive prompt at the place of the " - "crash."}, - {LLDB_3_TO_5, false, "editor", 'e', no_argument, 0, eArgTypeNone, - "Tells the debugger to open source files using the host's \"external " - "editor\" mechanism."}, - {LLDB_3_TO_5, false, "no-lldbinit", 'x', no_argument, 0, eArgTypeNone, - "Do not automatically parse any '.lldbinit' files."}, - {LLDB_3_TO_5, false, "no-use-colors", 'X', no_argument, 0, eArgTypeNone, - "Do not use colors."}, - {LLDB_OPT_SET_6, true, "python-path", 'P', no_argument, 0, eArgTypeNone, - "Prints out the path to the lldb.py file for this version of lldb."}, - {LLDB_3_TO_5, false, "script-language", 'l', required_argument, 0, - eArgTypeScriptLang, - "Tells the debugger to use the specified scripting language for " - "user-defined scripts, rather than the default. " - "Valid scripting languages that can be specified include Python, Perl, " - "Ruby and Tcl. Currently only the Python " - "extensions have been implemented."}, - {LLDB_3_TO_5, false, "debug", 'd', no_argument, 0, eArgTypeNone, - "Tells the debugger to print out extra information for debugging itself."}, - {LLDB_OPT_SET_7, true, "repl", 'r', optional_argument, 0, eArgTypeNone, - "Runs lldb in REPL mode with a stub process."}, - {LLDB_OPT_SET_7, true, "repl-language", 'R', required_argument, 0, - eArgTypeNone, "Chooses the language for the REPL."}}; - -static constexpr auto g_num_options = sizeof(g_options)/sizeof(OptionDefinition); - -static const uint32_t last_option_set_with_args = 2; - Driver::Driver() - : SBBroadcaster("Driver"), m_debugger(SBDebugger::Create(false)), - m_option_data() { + : SBBroadcaster("Driver"), m_debugger(SBDebugger::Create(false)) { // We want to be able to handle CTRL+D in the terminal to have it terminate // certain input m_debugger.SetCloseInputOnEOF(false); g_driver = this; } -Driver::~Driver() { g_driver = NULL; } - -// This function takes INDENT, which tells how many spaces to output at the -// front -// of each line; TEXT, which is the text that is to be output. It outputs the -// text, on multiple lines if necessary, to RESULT, with INDENT spaces at the -// front of each line. It breaks lines on spaces, tabs or newlines, shortening -// the line if necessary to not break in the middle of a word. It assumes that -// each output line should contain a maximum of OUTPUT_MAX_COLUMNS characters. - -void OutputFormattedUsageText(FILE *out, int indent, const char *text, - int output_max_columns) { - int len = strlen(text); - std::string text_string(text); - - // Force indentation to be reasonable. - if (indent >= output_max_columns) - indent = 0; - - // Will it all fit on one line? - - if (len + indent < output_max_columns) - // Output as a single line - fprintf(out, "%*s%s\n", indent, "", text); - else { - // We need to break it up into multiple lines. - int text_width = output_max_columns - indent - 1; - int start = 0; - int end = start; - int final_end = len; - int sub_len; - - while (end < final_end) { - // Dont start the 'text' on a space, since we're already outputting the - // indentation. - while ((start < final_end) && (text[start] == ' ')) - start++; - - end = start + text_width; - if (end > final_end) - end = final_end; - else { - // If we're not at the end of the text, make sure we break the line on - // white space. - while (end > start && text[end] != ' ' && text[end] != '\t' && - text[end] != '\n') - end--; - } - sub_len = end - start; - std::string substring = text_string.substr(start, sub_len); - fprintf(out, "%*s%s\n", indent, "", substring.c_str()); - start = end + 1; - } - } -} - -static void ShowUsage(FILE *out, Driver::OptionData data) { - uint32_t screen_width = 80; - uint32_t indent_level = 0; - const char *name = "lldb"; - - fprintf(out, "\nUsage:\n\n"); - - indent_level += 2; - - // First, show each usage level set of options, e.g. - // [options-for-level-0] - // - // [options-for-level-1] - // etc. - - uint32_t num_option_sets = 0; - - for (const auto &opt : g_options) { - uint32_t this_usage_mask = opt.usage_mask; - if (this_usage_mask == LLDB_OPT_SET_ALL) { - if (num_option_sets == 0) - num_option_sets = 1; - } else { - for (uint32_t j = 0; j < LLDB_MAX_NUM_OPTION_SETS; j++) { - if (this_usage_mask & 1 << j) { - if (num_option_sets <= j) - num_option_sets = j + 1; - } - } - } - } - - for (uint32_t opt_set = 0; opt_set < num_option_sets; opt_set++) { - uint32_t opt_set_mask; - - opt_set_mask = 1 << opt_set; - - if (opt_set > 0) - fprintf(out, "\n"); - fprintf(out, "%*s%s", indent_level, "", name); - bool is_help_line = false; - - for (const auto &opt : g_options) { - if (opt.usage_mask & opt_set_mask) { - CommandArgumentType arg_type = opt.argument_type; - const char *arg_name = - SBCommandInterpreter::GetArgumentTypeAsCString(arg_type); - // This is a bit of a hack, but there's no way to say certain options - // don't have arguments yet... - // so we do it by hand here. - if (opt.short_option == 'h') - is_help_line = true; - - if (opt.required) { - if (opt.option_has_arg == required_argument) - fprintf(out, " -%c <%s>", opt.short_option, arg_name); - else if (opt.option_has_arg == optional_argument) - fprintf(out, " -%c [<%s>]", opt.short_option, arg_name); - else - fprintf(out, " -%c", opt.short_option); - } else { - if (opt.option_has_arg == required_argument) - fprintf(out, " [-%c <%s>]", opt.short_option, arg_name); - else if (opt.option_has_arg == optional_argument) - fprintf(out, " [-%c [<%s>]]", opt.short_option, - arg_name); - else - fprintf(out, " [-%c]", opt.short_option); - } - } - } - if (!is_help_line && (opt_set <= last_option_set_with_args)) - fprintf(out, " [[--] [ ...]]"); - } - - fprintf(out, "\n\n"); - - // Now print out all the detailed information about the various options: long - // form, short form and help text: - // -- long_name - // - short - // help text - - // This variable is used to keep track of which options' info we've printed - // out, because some options can be in - // more than one usage level, but we only want to print the long form of its - // information once. - - Driver::OptionData::OptionSet options_seen; - Driver::OptionData::OptionSet::iterator pos; - - indent_level += 5; - - for (const auto &opt : g_options) { - // Only print this option if we haven't already seen it. - pos = options_seen.find(opt.short_option); - if (pos == options_seen.end()) { - CommandArgumentType arg_type = opt.argument_type; - const char *arg_name = - SBCommandInterpreter::GetArgumentTypeAsCString(arg_type); - - options_seen.insert(opt.short_option); - fprintf(out, "%*s-%c ", indent_level, "", opt.short_option); - if (arg_type != eArgTypeNone) - fprintf(out, "<%s>", arg_name); - fprintf(out, "\n"); - fprintf(out, "%*s--%s ", indent_level, "", opt.long_option); - if (arg_type != eArgTypeNone) - fprintf(out, "<%s>", arg_name); - fprintf(out, "\n"); - indent_level += 5; - OutputFormattedUsageText(out, indent_level, opt.usage_text, - screen_width); - indent_level -= 5; - fprintf(out, "\n"); - } - } - - indent_level -= 5; - - fprintf(out, "\n%*sNotes:\n", indent_level, ""); - indent_level += 5; - - fprintf(out, - "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will " - "be processed" - "\n%*sfrom left to right in order, with the source files and commands" - "\n%*sinterleaved. The same is true of the \"-S\" and \"-O\" " - "options. The before" - "\n%*sfile and after file sets can intermixed freely, the command " - "parser will" - "\n%*ssort them out. The order of the file specifiers (\"-c\", " - "\"-f\", etc.) is" - "\n%*snot significant in this regard.\n\n", - indent_level, "", indent_level, "", indent_level, "", indent_level, - "", indent_level, "", indent_level, ""); - - fprintf( - out, - "\n%*sIf you don't provide -f then the first argument will be the file " - "to be" - "\n%*sdebugged which means that '%s -- [ []]' also" - "\n%*sworks. But remember to end the options with \"--\" if any of your" - "\n%*sarguments have a \"-\" in them.\n\n", - indent_level, "", indent_level, "", name, indent_level, "", indent_level, - ""); -} - - static void BuildGetOptTable(std::vector