[Lldb-commits] [lldb] r289947 - Remove an unused type declaration.
Author: abidh Date: Fri Dec 16 08:44:34 2016 New Revision: 289947 URL: http://llvm.org/viewvc/llvm-project?rev=289947&view=rev Log: Remove an unused type declaration. Modified: lldb/trunk/tools/lldb-mi/Platform.h Modified: lldb/trunk/tools/lldb-mi/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/Platform.h?rev=289947&r1=289946&r2=289947&view=diff == --- lldb/trunk/tools/lldb-mi/Platform.h (original) +++ lldb/trunk/tools/lldb-mi/Platform.h Fri Dec 16 08:44:34 2016 @@ -18,12 +18,6 @@ #include "lldb/Host/HostGetOpt.h" #include "lldb/Host/windows/windows.h" -// This is not used by MI -struct timeval { - long tv_sec; - long tv_usec; -}; - struct winsize { long ws_col; }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D27223: Expression evaluation for overloaded C functions (redux)
ldrumm added inline comments. Comment at: include/lldb/Core/FastDemangle.h:22 +char * +FastDemangle(const char *mangled_name, size_t mangled_name_length, + std::function primitive_type_hook = nullptr); alexshap wrote: > some thoughts: > (also i assume i might be mistaken / missing smth) > in ./source/Core/Mangled.cpp at least 3 demanglers are used: > FastDemangle, itaniumDemangle, abi::__cxa_demangle . > Adding primitive_type_hook to FastDemangle makes the interface > more complicated & inconsistent (although yes, it's not particularly > consistent right now). You're right there are a bunch of manglers in use, and this is suboptimal. There is recent traction in LLVM to switch to using LLDB's FastDemangler once it supports everything; in terms of making the interface messy - you're again spot-on. None of the 4-or-so manglers visible to lldb have a symmetric API to support things like demangle -> remangle, so this is the least intrusive way I could come up with that didn't involve adding a new demangler to the list. I did think of several other possible approaches, including using the llvm demangler (which has no real public API apart from `llvm::itaniumDemangle` where the internal datastructure (`struct Db`) is not exposed, and modifying the llvm demangler to fix a problem in LLDB is going to be a much harder sell. Comment at: packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/main.c:17 +return 0; // break here +} alexshap wrote: > does this patch work when the functions come from a shared library ? > (i mean if we have libFoo.so which contains the implementations of > get_arg_type(float), get_arg_type(int), and then in lldb we want to call "p > get_arg_type(0.12f)") Yes. The only thing that matters to the current implementation is that we know the mangled symbol name. Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:449 +/// Given a mangled function `mangled`, replace all the primitive function type +/// arguments of `mangled` with type `replace`. +static ConstString SubsPrimitiveParmItanium(const char *mangled, clayborg wrote: > Don't you mean `search` instead of `mangled` above? I did. That was a silly mistake. Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:465-466 + std::unique_ptr output_buf(new char[max_len]); + ::memset(output_buf.get(), '\0', max_len); + ::strncpy(output_buf.get(), mangled, max_len - 1); + clayborg wrote: > Remove both lines above if you use a std::string. Also, why zero it first and > then copy the string over it? The reason I set it to zero first was that I didn't know how many replacements would be made or how many times `swap_parms_hook` would be called, so this case guarantees it's always NUL-terminated. I've switched to std::string as you suggested, which conveniently sidesteps the issue :) Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:471 + + auto swap_parms_hook = [&](const char *s) { +if (!s || !*s) clayborg wrote: > Does this only get called with parameters? Or does it get called for > everything? I'm not sure I follow; `s` should always be a valid pointer if that's what you mean? Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:476 +// Check whether we've found a substitutee +if (::strncmp(s, search, search_len) == 0) { + // account for the case where a replacement is of a different length clayborg wrote: > Use starts_with StringRef function. > > You also need to verify that there is a word boundary at the end of this. If > you are searching for "F", and replacing it with "E" and you get "Foo, Bar) > const" in `s` then this will match you will change it to "Eoo, Bar) const" > right? So you need to check `s[search.size]` and make sure it is a non > identifier character. Unless this function only gets called with identifier > boundaries. From my quick look at the FastDemangle changes, it seems that > this will get called with the entire remaining part of the string. This function only gets called when the demangler is trying to resolve a builtin type, so it only get called in a context where it's encoding a type, not an identifier. I could be wrong, but as far as I can tell, from reading the spec for itanium demangling (https://mentorembedded.github.io/cxx-abi/abi.html#mangle.builtin-type), and the code for the FastDemangler, this should be safe in the case you mentioned. https://reviews.llvm.org/D27223 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D27223: Expression evaluation for overloaded C functions (redux)
ldrumm updated this revision to Diff 81753. ldrumm marked 6 inline comments as done. ldrumm added a comment. updated to use StringRef-based parser rather than char pointers https://reviews.llvm.org/D27223 Files: include/lldb/Core/FastDemangle.h packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/Makefile packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/TestCallOverloadedCFunction.py packages/Python/lldbsuite/test/expression_command/call-overloaded-c-fuction/main.c source/Core/FastDemangle.cpp source/Expression/IRExecutionUnit.cpp source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h === --- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h +++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes @@ -93,7 +94,6 @@ } std::unique_ptr GetTypeScavenger() override; - lldb::TypeCategoryImplSP GetFormatters() override; HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override; @@ -142,6 +142,12 @@ static uint32_t FindEquivalentNames(ConstString type_name, std::vector &equivalents); + // Given a mangled function name, calculates some alternative manglings since + // the compiler mangling may not line up with the symbol we are expecting + static uint32_t + FindAlternateFunctionManglings(const ConstString mangled, + std::set &candidates); + //-- // PluginInterface protocol //-- Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -10,17 +10,22 @@ #include "CPlusPlusLanguage.h" // C Includes -// C++ Includes #include #include + +// C++ Includes #include +#include #include +#include // Other libraries and framework includes #include "llvm/ADT/StringRef.h" // Project includes #include "lldb/Core/ConstString.h" +#include "lldb/Core/FastDemangle.h" +#include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/UniqueCStringMap.h" @@ -440,6 +445,101 @@ return count; } +/// 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) { + Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE); + + const size_t max_len = + mangled.size() + mangled.count(search) * replace.size() + 1; + + // Make a temporary buffer to fix up the mangled parameter types and copy the + // original there + std::string output_buf; + output_buf.reserve(max_len); + output_buf.insert(0, mangled.str()); + ptrdiff_t replaced_offset = 0; + + auto swap_parms_hook = [&](const char *parsee) { +if (!parsee || !*parsee) + return; + +// Check whether we've found a substitutee +llvm::StringRef s(parsee); +if (s.startswith(search)) { + // account for the case where a replacement is of a different length to + // the original + replaced_offset += replace.size() - search.size(); + + ptrdiff_t replace_idx = (mangled.size() - s.size()) + replaced_offset; + output_buf.erase(replace_idx, search.size()); + output_buf.insert(replace_idx, replace.str()); +} + }; + + // FastDemangle will call our hook for each instance of a primitive type, + // allowing us to perform substitution + const char *const demangled = + FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook); + + if (log) +log->Printf("substituted mangling for %s:{%s} %s:{%s}\n", +mangled.str().c_str(), demangled, output_buf.c_str(), +FastDemangle(output_buf.c_str())); + + return output_buf == mangled ? ConstString() : ConstString(output_buf); +} + +uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings( +const ConstString mangled_name, std::set &alternates) { + const auto start_size = alternates.size(); + /// Get a basic set of alternative manglings for the given symbol `name`, by + /// making a few basic possible substitutions on basic types, storage duration + /// and `const`ness for the given symbol. The output parameter `al
[Lldb-commits] [lldb] r289956 - Fix broken escaping of commands in the build
Author: ldrumm Date: Fri Dec 16 10:38:25 2016 New Revision: 289956 URL: http://llvm.org/viewvc/llvm-project?rev=289956&view=rev Log: Fix broken escaping of commands in the build A combination of broken escaping in CMake and in the python swig generation scripts meant that the swig generation step would fail whenever there were spaces or special characters in parameters passed to swig. The fix for this in CMakeLists is to use the VERBATIM option on all COMMAND-based custom builders relying on CMake to properly escape each argument in the generated file. Within the python swig scripts, the fix is to call subprocess.Popen with a list of raw argument strings rather than ones that are incorrectly manually escaped, then passed to a shell subprocess via subprocess.Popen(' '.join(params)). This also prevents nasty things happening such as accidental command-injection. This allows us to have the swig / python executables in paths containing special chars and spaces, (or on shared storage on Win32, e.g \\some\path or C:\Program Files\swig\swig.exe). Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D26757 Modified: lldb/trunk/CMakeLists.txt lldb/trunk/scripts/CMakeLists.txt lldb/trunk/scripts/Python/prepare_binding_Python.py Modified: lldb/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=289956&r1=289955&r2=289956&view=diff == --- lldb/trunk/CMakeLists.txt (original) +++ lldb/trunk/CMakeLists.txt Fri Dec 16 10:38:25 2016 @@ -39,15 +39,19 @@ add_subdirectory(unittests) add_subdirectory(lit) if (NOT LLDB_DISABLE_PYTHON) -# Add a Post-Build Event to copy over Python files and create the symlink to liblldb.so for the Python API(hardlink on Windows) -add_custom_target( finish_swig ALL -COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py -"--srcRoot=${LLDB_SOURCE_DIR}" -"--targetDir=${LLDB_PYTHON_TARGET_DIR}" -"--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts" -"--prefix=${CMAKE_BINARY_DIR}" -"--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}" -"--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}" ${FINISH_EXTRA_ARGS} +# Add a Post-Build Event to copy over Python files and create the symlink +# to liblldb.so for the Python API(hardlink on Windows) +add_custom_target(finish_swig ALL +COMMAND + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py + --srcRoot=${LLDB_SOURCE_DIR} + --targetDir=${LLDB_PYTHON_TARGET_DIR} + --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts + --prefix=${CMAKE_BINARY_DIR} + --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR} + --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX} + ${FINISH_EXTRA_ARGS} +VERBATIM DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py COMMENT "Python script sym-linking LLDB Python API") @@ -78,7 +82,7 @@ if (NOT LLDB_DISABLE_PYTHON) add_custom_command( TARGET finish_swig POST_BUILD -COMMAND "${CMAKE_COMMAND}" -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} +COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM COMMENT "Copying Python DLL to LLDB binaries directory.") endif () endif () Modified: lldb/trunk/scripts/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=289956&r1=289955&r2=289956&view=diff == --- lldb/trunk/scripts/CMakeLists.txt (original) +++ lldb/trunk/scripts/CMakeLists.txt Fri Dec 16 10:38:25 2016 @@ -35,12 +35,13 @@ add_custom_command( DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Python/prepare_binding_Python.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Python/modify-python-lldb.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/prepare_bindings.py - ${framework_arg} - "--srcRoot=${LLDB_SOURCE_DIR}" - "--targetDir=${LLDB_PYTHON_TARGET_DIR}" - "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}" - "--prefix=${CMAKE_BINARY_DIR}" - "--swigExecutable=${SWIG_EXECUTABLE}" + ${framework_arg} + --srcRoot=${LLDB_SOURCE_DIR} + --targetDir=${LLDB_PYTHON_TARGET_DIR} + --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR} + --prefix=${CMAKE_BINARY_DIR} + --swigExecutable=${SWIG_EXECUTABLE} + VERBATIM COMMENT "Python script building LLDB Python wrapper") set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lldb.py PROPERTIES GENERATED 1) Modified: lldb/trunk/scripts/Python/prepare_binding_Python.py URL: ht
[Lldb-commits] [PATCH] D26757: Fix broken escaping of commands in the build
This revision was automatically updated to reflect the committed changes. Closed by commit rL289956: Fix broken escaping of commands in the build (authored by ldrumm). Changed prior to commit: https://reviews.llvm.org/D26757?vs=79578&id=81761#toc Repository: rL LLVM https://reviews.llvm.org/D26757 Files: lldb/trunk/CMakeLists.txt lldb/trunk/scripts/CMakeLists.txt lldb/trunk/scripts/Python/prepare_binding_Python.py Index: lldb/trunk/scripts/Python/prepare_binding_Python.py === --- lldb/trunk/scripts/Python/prepare_binding_Python.py +++ lldb/trunk/scripts/Python/prepare_binding_Python.py @@ -196,34 +196,37 @@ temp_dep_file_path = dependency_file + ".tmp" # Build the SWIG args list -command = [ -options.swig_executable, -"-c++", -"-shadow", -"-python", -"-threads", -"-I\"%s\"" % os.path.normcase( -os.path.join(options.src_root, "include")), -"-I\"%s\"" % os.path.normcase("./."), -"-D__STDC_LIMIT_MACROS", -"-D__STDC_CONSTANT_MACROS"] -if options.target_platform == "Darwin": -command.append("-D__APPLE__") -if options.generate_dependency_file: -command.append("-MMD -MF \"%s\"" % temp_dep_file_path) -command.extend([ -"-outdir", "\"%s\"" % config_build_dir, -"-o", "\"%s\"" % settings.output_file, -"\"%s\"" % settings.input_file -]) -logging.info("running swig with: %s", command) +is_darwin = options.target_platform == "Darwin" +gen_deps = options.generate_dependency_file +darwin_extras = ["-D__APPLE__"] if is_darwin else [] +deps_args = ["-MMD", "-MF", temp_dep_file_path] if gen_deps else [] +command = ([ +options.swig_executable, +"-c++", +"-shadow", +"-python", +"-threads", +"-I" + os.path.normpath(os.path.join(options.src_root, "include")), +"-I" + os.path.curdir, +"-D__STDC_LIMIT_MACROS", +"-D__STDC_CONSTANT_MACROS" +] ++ darwin_extras ++ deps_args ++ [ +"-outdir", config_build_dir, +"-o", settings.output_file, +settings.input_file +] +) +logging.info("running swig with: %r", command) # Execute swig process = subprocess.Popen( -' '.join(command), +command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, -shell=True) +) # Wait for SWIG process to terminate swig_stdout, swig_stderr = process.communicate() return_code = process.returncode @@ -265,15 +268,14 @@ the command line arguments to pass to it. """ command = [sys.executable] + script_and_args -command_line = " ".join(command) -process = subprocess.Popen(command, shell=False) +process = subprocess.Popen(command) script_stdout, script_stderr = process.communicate() return_code = process.returncode if return_code != 0: -logging.error("failed to run '%s': %s", command_line, script_stderr) +logging.error("failed to run %r: %r", command, script_stderr) sys.exit(return_code) else: -logging.info("ran script '%s'", command_line) +logging.info("ran script %r'", command) if script_stdout is not None: logging.info("output: %s", script_stdout) Index: lldb/trunk/scripts/CMakeLists.txt === --- lldb/trunk/scripts/CMakeLists.txt +++ lldb/trunk/scripts/CMakeLists.txt @@ -35,12 +35,13 @@ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Python/prepare_binding_Python.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Python/modify-python-lldb.py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/prepare_bindings.py - ${framework_arg} - "--srcRoot=${LLDB_SOURCE_DIR}" - "--targetDir=${LLDB_PYTHON_TARGET_DIR}" - "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}" - "--prefix=${CMAKE_BINARY_DIR}" - "--swigExecutable=${SWIG_EXECUTABLE}" + ${framework_arg} + --srcRoot=${LLDB_SOURCE_DIR} + --targetDir=${LLDB_PYTHON_TARGET_DIR} + --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR} + --prefix=${CMAKE_BINARY_DIR} + --swigExecutable=${SWIG_EXECUTABLE} + VERBATIM COMMENT "Python script building LLDB Python wrapper") set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/lldb.py PROPERTIES GENERATED 1) Index: lldb/trunk/CMakeLists.txt === --- lldb/trunk/CMakeLists.txt +++ lldb/trunk/CMakeLists.txt @@ -39,15 +39,19 @@ add_subdirectory(lit) if (NOT LLDB_DISABLE_PYTHON) -# Add a Post-Build Event to copy over Python files and create the symlink to liblldb.so for the Python API(hardlink on Windows) -
[Lldb-commits] [PATCH] D23977: Support of lldb on Kfreebsd
beanz added a comment. Looks fine to me. https://reviews.llvm.org/D23977 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D27780: Make OptionDefinition structure store a StringRef
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Ok, as long as the StringRef constructors are quick and efficient and not running strlen() each time I am good. https://reviews.llvm.org/D27780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D27780: Make OptionDefinition structure store a StringRef
zturner added a comment. Yea as I mentioned this whole plan might be killed by a blocker I ran into last night. I'm still trying to figure out if there's a workaround. https://reviews.llvm.org/D27780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D27223: Expression evaluation for overloaded C functions (redux)
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Looks good. https://reviews.llvm.org/D27223 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r289994 - Fix compiler warning.
Author: zturner Date: Fri Dec 16 15:35:12 2016 New Revision: 289994 URL: http://llvm.org/viewvc/llvm-project?rev=289994&view=rev Log: Fix compiler warning. Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=289994&r1=289993&r2=289994&view=diff == --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Dec 16 15:35:12 2016 @@ -1403,7 +1403,6 @@ protected: uint64_t uval64; int64_t sval64; bool success = false; -const size_t num_value_args = command.GetArgumentCount(); for (auto &entry : command) { switch (m_format_options.GetFormat()) { case kNumFormats: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] LLVM buildmaster will be restarted tonight
Hello everyone, LLVM buildmaster will be updated and restarted after 5 PM Pacific time today. Thanks Galina ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits