[Lldb-commits] [lldb] ede7c02 - [lldb/COFF] Remove strtab zeroing hack

2020-07-17 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-17T13:24:59+02:00
New Revision: ede7c02b38c0c3adf7fb9ee308bd0f6d92a0eb4e

URL: 
https://github.com/llvm/llvm-project/commit/ede7c02b38c0c3adf7fb9ee308bd0f6d92a0eb4e
DIFF: 
https://github.com/llvm/llvm-project/commit/ede7c02b38c0c3adf7fb9ee308bd0f6d92a0eb4e.diff

LOG: [lldb/COFF] Remove strtab zeroing hack

Summary:
This code (recently responsible for a unaligned access sanitizer
failure) claims that the string table offset zero should result in an
empty string.

I cannot find any mention of this detail in the Microsoft COFF
documentation, and the llvm COFF parser also does not handle offset zero
specially. This code was introduced in 0076e7159, which also does not go
into specifics, citing "various bugfixes".

Given that this is obviously a hack, and does not cause tests to fail, I
think we should just delete it.

Reviewers: amccarth, markmentovai

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83881

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index d606b49130c4..5feec8167186 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -543,12 +543,6 @@ DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t 
offset, size_t size) {
   if (m_data.ValidOffsetForDataOfSize(offset, size))
 return DataExtractor(m_data, offset, size);
 
-  if (m_file) {
-// 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());
-  }
   ProcessSP process_sp(m_process_wp.lock());
   DataExtractor data;
   if (process_sp) {
@@ -652,12 +646,6 @@ Symtab *ObjectFilePECOFF::GetSymtab() {
   DataExtractor strtab_data = ReadImageData(
   m_coff_header.symoff + symbol_data_size, strtab_size);
 
-  // First 4 bytes should be zeroed after strtab_size has been read,
-  // because it is used as offset 0 to encode a NULL string.
-  uint32_t *strtab_data_start = const_cast(
-  reinterpret_cast(strtab_data.GetDataStart()));
-  ::memset(&strtab_data_start[0], 0, sizeof(uint32_t));
-
   offset = 0;
   std::string symbol_name;
   Symbol *symbols = m_symtab_up->Resize(num_syms);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9199457 - [LLDB/test] Simplify result formatter code

2020-07-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-20T14:56:49+02:00
New Revision: 9199457bfb5a77121a950df5417fadbf8174cdde

URL: 
https://github.com/llvm/llvm-project/commit/9199457bfb5a77121a950df5417fadbf8174cdde
DIFF: 
https://github.com/llvm/llvm-project/commit/9199457bfb5a77121a950df5417fadbf8174cdde.diff

LOG: [LLDB/test] Simplify result formatter code

Now that the main test results are reported through lit, and we only
have one formatter class, this code is unnecessarily baroque.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
lldb/packages/Python/lldbsuite/test_event/formatter/results_formatter.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 67f227cad715..3989ce1bc4d5 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -47,6 +47,7 @@
 from lldbsuite.test_event import formatter
 from . import test_result
 from lldbsuite.test_event.event_builder import EventBuilder
+from lldbsuite.test_event.formatter.results_formatter import ResultsFormatter
 from ..support import seven
 
 
@@ -453,27 +454,6 @@ def parseOptionsAndInitTestdirs():
 
 lldbtest_config.codesign_identity = args.codesign_identity
 
-
-def setupTestResults():
-"""Sets up test results-related objects based on arg settings."""
-
-# Create the results formatter.
-formatter_spec = formatter.create_results_formatter(
-
"lldbsuite.test_event.formatter.results_formatter.ResultsFormatter")
-if formatter_spec is not None and formatter_spec.formatter is not None:
-configuration.results_formatter_object = formatter_spec.formatter
-
-# Send an initialize message to the formatter.
-initialize_event = EventBuilder.bare_event("initialize")
-initialize_event["worker_count"] = 1
-
-formatter_spec.formatter.handle_event(initialize_event)
-
-# Make sure we clean up the formatter on shutdown.
-if formatter_spec.cleanup_func is not None:
-atexit.register(formatter_spec.cleanup_func)
-
-
 def setupSysPath():
 """
 Add LLDB.framework/Resources/Python to the search paths for modules.
@@ -933,8 +913,7 @@ def run_suite():
 #
 parseOptionsAndInitTestdirs()
 
-# Setup test results (test results formatter and output handling).
-setupTestResults()
+configuration.results_formatter_object = ResultsFormatter(sys.stdout)
 
 setupSysPath()
 

diff  --git a/lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py 
b/lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
index d6609d353c85..a1feb389321d 100644
--- a/lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
+++ b/lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
@@ -4,63 +4,3 @@
 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 """
 
-from __future__ import print_function
-from __future__ import absolute_import
-
-# System modules
-import importlib
-import socket
-import sys
-
-# Third-party modules
-
-# LLDB modules
-
-
-# Ignore method count on DTOs.
-# pylint: disable=too-few-public-methods
-class CreatedFormatter(object):
-"""Provides transfer object for returns from create_results_formatter()."""
-
-def __init__(self, formatter, cleanup_func):
-self.formatter = formatter
-self.cleanup_func = cleanup_func
-
-
-def create_results_formatter(formatter_name):
-"""Sets up a test results formatter.
-
-@param config an instance of FormatterConfig
-that indicates how to setup the ResultsFormatter.
-
-@return an instance of CreatedFormatter.
-"""
-
-# Create an instance of the class.
-# First figure out the package/module.
-components = formatter_name.split(".")
-module = importlib.import_module(".".join(components[:-1]))
-
-# Create the class name we need to load.
-cls = getattr(module, components[-1])
-
-# Handle formatter options for the results formatter class.
-formatter_arg_parser = cls.arg_parser()
-command_line_options = []
-
-formatter_options = formatter_arg_parser.parse_args(
-command_line_options)
-
-# Create the TestResultsFormatter given the processed options.
-results_formatter_object = cls(sys.stdout, formatter_options)
-
-def shutdown_formatter():
-"""Shuts down the formatter when it is no longer needed."""
-# Tell the formatter to write out anything it may have
-# been saving until the very end (e.g. xUnit results
-# can't complete its output until this point).
-results_formatter_object.send_terminate_as_needed()
-
-return CreatedFormatter(
-results_formatter_object,
-shutdown_formatter)

diff  --git 
a/lldb/packages/Python/lldbsuite/test_event/formatte

[Lldb-commits] [lldb] 9decf04 - [lldb/test] Simplify Makefile rules for .d files

2020-07-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-20T15:53:19+02:00
New Revision: 9decf0405fe1bd79325ca47dba15d8914608e242

URL: 
https://github.com/llvm/llvm-project/commit/9decf0405fe1bd79325ca47dba15d8914608e242
DIFF: 
https://github.com/llvm/llvm-project/commit/9decf0405fe1bd79325ca47dba15d8914608e242.diff

LOG: [lldb/test] Simplify Makefile rules for .d files

The sed line in the rules was adding the .d file as a target to the
dependency rules -- to ensure the file gets rebuild when the sources
change. The same thing can be achieved more elegantly with some -M
flags.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index b9a6937650d0..43352b620b16 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -727,28 +727,16 @@ endif
 # and the -MM option will list all non-system dependencies.
 #--
 %.d: %.c
-   @rm -f $@
-   @$(CC) -M $(CFLAGS) $< > $@.tmp && \
-   sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-   @rm -f $@.tmp
+   $(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 %.d: %.cpp
-   @rm -f $@
-   @$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
-   sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-   @rm -f $@.tmp
+   @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 %.d: %.m
-   @rm -f $@
-   @$(CC) -M $(CFLAGS) $< > $@.tmp && \
-   sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-   @rm -f $@.tmp
+   @$(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 %.d: %.mm
-   @rm -f $@
-   @$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
-   sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@
-   @rm -f $@.tmp
+   @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o
 
 #--
 # Include all of the makefiles for each source file so we don't have



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 7fadd70 - [lldb/Utility] Simplify Scalar::SetValueFromData

2020-07-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-20T15:56:56+02:00
New Revision: 7fadd7006932adfe65f445aad1e60fe8d7b81eec

URL: 
https://github.com/llvm/llvm-project/commit/7fadd7006932adfe65f445aad1e60fe8d7b81eec
DIFF: 
https://github.com/llvm/llvm-project/commit/7fadd7006932adfe65f445aad1e60fe8d7b81eec.diff

LOG: [lldb/Utility] Simplify Scalar::SetValueFromData

The function was fairly complicated and didn't support new bigger
integer sizes. Use llvm function for loading an APInt from memory to
write a unified implementation for all sizes.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index f215fa71c84c..0bb5c7d1b859 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -217,7 +217,7 @@ class Scalar {
   Status SetValueFromCString(const char *s, lldb::Encoding encoding,
  size_t byte_size);
 
-  Status SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
+  Status SetValueFromData(const DataExtractor &data, lldb::Encoding encoding,
   size_t byte_size);
 
   static bool UIntValueIsValidForSize(uint64_t uval64, size_t total_byte_size) 
{

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 6c48bbde532f..e2c1f37fe529 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -1068,12 +1068,9 @@ Status Scalar::SetValueFromCString(const char 
*value_str, Encoding encoding,
   return error;
 }
 
-Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
-size_t byte_size) {
+Status Scalar::SetValueFromData(const DataExtractor &data,
+lldb::Encoding encoding, size_t byte_size) {
   Status error;
-
-  type128 int128;
-  type256 int256;
   switch (encoding) {
   case lldb::eEncodingInvalid:
 error.SetErrorString("invalid encoding");
@@ -1081,100 +1078,26 @@ Status Scalar::SetValueFromData(DataExtractor &data, 
lldb::Encoding encoding,
   case lldb::eEncodingVector:
 error.SetErrorString("vector encoding unsupported");
 break;
-  case lldb::eEncodingUint: {
-lldb::offset_t offset = 0;
-
-switch (byte_size) {
-case 1:
-  operator=(data.GetU8(&offset));
-  break;
-case 2:
-  operator=(data.GetU16(&offset));
-  break;
-case 4:
-  operator=(data.GetU32(&offset));
-  break;
-case 8:
-  operator=(data.GetU64(&offset));
-  break;
-case 16:
-  if (data.GetByteOrder() == eByteOrderBig) {
-int128.x[1] = data.GetU64(&offset);
-int128.x[0] = data.GetU64(&offset);
-  } else {
-int128.x[0] = data.GetU64(&offset);
-int128.x[1] = data.GetU64(&offset);
-  }
-  operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
-  break;
-case 32:
-  if (data.GetByteOrder() == eByteOrderBig) {
-int256.x[3] = data.GetU64(&offset);
-int256.x[2] = data.GetU64(&offset);
-int256.x[1] = data.GetU64(&offset);
-int256.x[0] = data.GetU64(&offset);
-  } else {
-int256.x[0] = data.GetU64(&offset);
-int256.x[1] = data.GetU64(&offset);
-int256.x[2] = data.GetU64(&offset);
-int256.x[3] = data.GetU64(&offset);
-  }
-  operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x));
-  break;
-default:
-  error.SetErrorStringWithFormat(
-  "unsupported unsigned integer byte size: %" PRIu64 "",
-  static_cast(byte_size));
-  break;
-}
-  } break;
+  case lldb::eEncodingUint:
   case lldb::eEncodingSint: {
-lldb::offset_t offset = 0;
-
-switch (byte_size) {
-case 1:
-  operator=(static_cast(data.GetU8(&offset)));
-  break;
-case 2:
-  operator=(static_cast(data.GetU16(&offset)));
-  break;
-case 4:
-  operator=(static_cast(data.GetU32(&offset)));
-  break;
-case 8:
-  operator=(static_cast(data.GetU64(&offset)));
-  break;
-case 16:
-  if (data.GetByteOrder() == eByteOrderBig) {
-int128.x[1] = data.GetU64(&offset);
-int128.x[0] = data.GetU64(&offset);
-  } else {
-int128.x[0] = data.GetU64(&offset);
-int128.x[1] = data.GetU64(&offset);
-  }
-  operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
-  break;
-case 32:
-  if (data.GetByteOrder() == eByteOrderBig) {
-int256.x[3] = data.GetU64(&offset);
-int256.x[2] = data.GetU64(&offset);
-int256.x[1] = data.GetU64(&offset);
-int256.x[0] = data.GetU64(&offset);
-  } else {
-int256.x[0] = data.GetU64(&offset);
-int256.x[1] = data.GetU64(&offset);
-int256.x[2]

Re: [Lldb-commits] [lldb] f8df2e1 - [lldb/Reproducers] Always record the current working directory

2020-07-21 Thread Pavel Labath via lldb-commits
On 20/07/2020 20:54, Jonas Devlieghere via lldb-commits wrote:
> 
> Author: Jonas Devlieghere
> Date: 2020-07-20T11:54:11-07:00
> New Revision: f8df2e1a19913e997d8d6dbe573de977406e736e
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/f8df2e1a19913e997d8d6dbe573de977406e736e
> DIFF: 
> https://github.com/llvm/llvm-project/commit/f8df2e1a19913e997d8d6dbe573de977406e736e.diff
> 
> LOG: [lldb/Reproducers] Always record the current working directory
> 
> Setting the current working directory in the VFS will fail if the given
> path doesn't exist in the YAML mapping or on disk.
> 
> Added: 
> 
> 
> Modified: 
> lldb/include/lldb/Utility/Reproducer.h
> lldb/source/API/SBReproducer.cpp
> lldb/source/Initialization/SystemInitializerCommon.cpp
> lldb/test/Shell/Reproducer/TestWorkingDir.test
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
> b/lldb/include/lldb/Utility/Reproducer.h
> index 2714db8d2932..6fcb839684dc 100644
> --- a/lldb/include/lldb/Utility/Reproducer.h
> +++ b/lldb/include/lldb/Utility/Reproducer.h
> @@ -11,6 +11,7 @@
>  
>  #include "lldb/Utility/FileSpec.h"
>  #include "llvm/ADT/DenseMap.h"
> +#include "llvm/ADT/StringRef.h"
>  #include "llvm/Support/Error.h"
>  #include "llvm/Support/FileCollector.h"
>  #include "llvm/Support/YAMLTraits.h"
> @@ -149,6 +150,7 @@ class WorkingDirectoryProvider : public 
> Provider {
>}
>  
>void Update(llvm::StringRef path) { m_cwd = std::string(path); }
> +  llvm::StringRef GetWorkingDirectory() { return m_cwd; }
>  
>struct Info {
>  static const char *name;
> 
> diff  --git a/lldb/source/API/SBReproducer.cpp 
> b/lldb/source/API/SBReproducer.cpp
> index 0eb3429c4fef..9815bf11263c 100644
> --- a/lldb/source/API/SBReproducer.cpp
> +++ b/lldb/source/API/SBReproducer.cpp
> @@ -234,7 +234,10 @@ const char *SBReproducer::GetPath() {
>  
>  void SBReproducer::SetWorkingDirectory(const char *path) {
>if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
> -g->GetOrCreate().Update(path);
> +auto &wp = g->GetOrCreate();
> +wp.Update(path);
> +auto &fp = g->GetOrCreate();
> +fp.RecordInterestingDirectory(wp.GetWorkingDirectory());


If I'm not mistaken, this will (recursively) record the entire contents
of the CWD. That could be a _lot_. Are you that's what you wanted?

pl
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] cd05406 - [testsuite] Adapt lldb-server base test helper to run on arm64

2020-07-21 Thread Pavel Labath via lldb-commits
On 20/07/2020 23:38, Davide Italiano via lldb-commits wrote:
> @@ -1601,8 +1601,18 @@ def single_step_only_steps_one_instruction(
>  # variable value
>  if re.match("s390x", arch):
>  expected_step_count = 2
> +# ARM64 requires "4" instructions: 2 to compute the address (adrp, 
> add),
> +# one to materialize the constant (mov) and the store
> +if re.match("arm64", arch):
> +expected_step_count = 4
> +
>  self.assertEqual(step_count, expected_step_count)
>  
> +# ARM64: Once addresses and constants are materialized, only one
> +# instruction is needed.
> +if re.match("arm64", arch):
> +expected_step_count = 1
> +
>  # Verify we hit the next state.
>  args["expected_g_c1"] = "0"
>  args["expected_g_c2"] = "0"
> 

I have a feeling this was racing with aa73ee052f -- [lldb/test] Use
inline assembly for instruction counting tests.

There should be no need for magic step counts after that patch. (If
there is, I'd like to know why.)

pl
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5f4c850 - [lldb/test] Do a better job at setting (DY)LD_LIBRARY_PATH

2020-07-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-22T11:37:02+02:00
New Revision: 5f4c850e7b4f100a8c779ea52b492c87af076136

URL: 
https://github.com/llvm/llvm-project/commit/5f4c850e7b4f100a8c779ea52b492c87af076136
DIFF: 
https://github.com/llvm/llvm-project/commit/5f4c850e7b4f100a8c779ea52b492c87af076136.diff

LOG: [lldb/test] Do a better job at setting (DY)LD_LIBRARY_PATH

Summary:
registerSharedLibrariesWithTarget was setting the library path
environment variable to the process build directory, but the function is
also accepting libraries in other directories (in which case they won't
be found automatically).

This patch makes the function set the path variable correctly for these
libraries too. This enables us to remove the code for setting the path
variable in TestWeakSymbols.py, which was working only accidentally --
it was relying on the fact that
  launch_info.SetEnvironmentEntries(..., append=True)
would not overwrite the path variable it has set, but that is going to
change with D83306.

Reviewers: davide, jingham

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83552

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 25805726f9b3..d73d5344d6c1 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1881,8 +1881,7 @@ def registerSharedLibrariesWithTarget(self, target, 
shlibs):
 shlib_prefix = self.platformContext.shlib_prefix
 shlib_extension = '.' + self.platformContext.shlib_extension
 
-working_dir = self.get_process_working_directory()
-environment = ['%s=%s' % (shlib_environment_var, working_dir)]
+dirs = []
 # Add any shared libraries to our target if remote so they get
 # uploaded into the working directory on the remote side
 for name in shlibs:
@@ -1905,6 +1904,7 @@ def registerSharedLibrariesWithTarget(self, target, 
shlibs):
 # Make sure we found the local shared library in the above code
 self.assertTrue(os.path.exists(local_shlib_path))
 
+
 # Add the shared library to our target
 shlib_module = target.AddModule(local_shlib_path, None, None, None)
 if lldb.remote_platform:
@@ -1914,8 +1914,15 @@ def registerSharedLibrariesWithTarget(self, target, 
shlibs):
 os.path.basename(local_shlib_path))
 shlib_module.SetRemoteInstallFileSpec(
 lldb.SBFileSpec(remote_shlib_path, False))
+dir_to_add = self.get_process_working_directory()
+else:
+dir_to_add = os.path.dirname(local_shlib_path)
+
+if dir_to_add not in dirs:
+dirs.append(dir_to_add)
 
-return environment
+env_value = self.platformContext.shlib_path_separator.join(dirs)
+return ['%s=%s' % (shlib_environment_var, env_value)]
 
 def registerSanitizerLibrariesWithTarget(self, target):
 runtimes = []

diff  --git a/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py 
b/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
index b67b5b4efe0b..2b63fba00e65 100644
--- a/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
+++ b/lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
@@ -48,10 +48,6 @@ def do_test(self):
 
 launch_info = lldb.SBLaunchInfo(None)
 launch_info.SetWorkingDirectory(self.getBuildDir())
-# We have to point to the hidden directory to pick up the
-# version of the dylib without the weak symbols:
-env_expr = self.platformContext.shlib_environment_var + "=" + 
hidden_dir
-launch_info.SetEnvironmentEntries([env_expr], True)
 
 (self.target, _, thread, _) = lldbutil.run_to_source_breakpoint(
   self, "Set a breakpoint here",



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e00645c - [lldb/test] Delete result formatter machinery entirely

2020-07-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-22T11:53:41+02:00
New Revision: e00645cc7878da13c86339fd50a4fb78d8a698ad

URL: 
https://github.com/llvm/llvm-project/commit/e00645cc7878da13c86339fd50a4fb78d8a698ad
DIFF: 
https://github.com/llvm/llvm-project/commit/e00645cc7878da13c86339fd50a4fb78d8a698ad.diff

LOG: [lldb/test] Delete result formatter machinery entirely

After more investigation, I realised this part of the code is totally
unused. It was used for communicating the test results from the
"inferior" dotest process to the main "dosep" process running
everything. Now that everything is being orchestrated through lit, this
is not used for anything.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/test_result.py

Removed: 
lldb/packages/Python/lldbsuite/test_event/event_builder.py
lldb/packages/Python/lldbsuite/test_event/formatter/__init__.py
lldb/packages/Python/lldbsuite/test_event/formatter/results_formatter.py



diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 534bcbf59ac2..8c8f2509a863 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -19,7 +19,6 @@
 from . import configuration
 from . import test_categories
 from . import lldbtest_config
-from lldbsuite.test_event.event_builder import EventBuilder
 from lldbsuite.support import funcutils
 from lldbsuite.test import lldbplatform
 from lldbsuite.test import lldbplatformutil
@@ -100,10 +99,6 @@ def wrapper(*args, **kwargs):
 else:
 xfail_reason = expected_fn()
 if xfail_reason is not None:
-if configuration.results_formatter_object is not None:
-# Mark this test as expected to fail.
-configuration.results_formatter_object.handle_event(
-
EventBuilder.event_for_mark_test_expected_failure(self))
 xfail_func = unittest2.expectedFailure(func)
 xfail_func(*args, **kwargs)
 else:
@@ -445,21 +440,11 @@ def expectedFailureNetBSD(bugnumber=None):
 ['netbsd'],
 bugnumber)
 
-# Flakey tests get two chances to run. If they fail the first time round, the 
result formatter
-# makes sure it is run one more time.
-
-
+# TODO: This decorator does not do anything. Remove it.
 def expectedFlakey(expected_fn, bugnumber=None):
 def expectedFailure_impl(func):
 @wraps(func)
 def wrapper(*args, **kwargs):
-self = args[0]
-if expected_fn(self):
-# Send event marking test as explicitly eligible for rerunning.
-if configuration.results_formatter_object is not None:
-# Mark this test as rerunnable.
-configuration.results_formatter_object.handle_event(
-EventBuilder.event_for_mark_test_rerun_eligible(self))
 func(*args, **kwargs)
 return wrapper
 # Some decorators can be called both with no arguments (e.g. 
@expectedFailureWindows)

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 3989ce1bc4d5..3fb802f1c1aa 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -44,10 +44,7 @@
 from . import dotest_args
 from . import lldbtest_config
 from . import test_categories
-from lldbsuite.test_event import formatter
 from . import test_result
-from lldbsuite.test_event.event_builder import EventBuilder
-from lldbsuite.test_event.formatter.results_formatter import ResultsFormatter
 from ..support import seven
 
 
@@ -712,31 +709,17 @@ def visit(prefix, dir, names):
 
 # Visit all the python test files.
 for name in python_test_files:
-try:
-# Ensure we error out if we have multiple tests with the same
-# base name.
-# Future improvement: find all the places where we work with base
-# names and convert to full paths.  We have directory structure
-# to disambiguate these, so we shouldn't need this constraint.
-if name in configuration.all_tests:
-raise Exception("Found multiple tests with the name %s" % name)
-configuration.all_tests.add(name)
-
-# Run the relevant tests in the python file.
-visit_file(dir, name)
-except Exception as ex:
-# Convert this exception to a test event error for the file.
-test_filename = os.path.abspath(os.path.join(dir, name))
-if configuration.results_formatter_object is not None:
-# Grab the backtrace for the exception.
-import traceback
- 

[Lldb-commits] [lldb] c9d5a30 - [lldb] add printing of stdout compile errors to lldbsuite

2020-07-22 Thread Pavel Labath via lldb-commits

Author: Benson Li
Date: 2020-07-22T16:38:20+02:00
New Revision: c9d5a3058fcde50c2fe40a5eaaa939d0995d3cd2

URL: 
https://github.com/llvm/llvm-project/commit/c9d5a3058fcde50c2fe40a5eaaa939d0995d3cd2
DIFF: 
https://github.com/llvm/llvm-project/commit/c9d5a3058fcde50c2fe40a5eaaa939d0995d3cd2.diff

LOG: [lldb] add printing of stdout compile errors to lldbsuite

Summary: Add printing of the output of stdout during compile errors, in
addition to stderr output.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D83425

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test_event/build_exception.py

lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index d73d5344d6c1..4aad2867cf8f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -426,7 +426,7 @@ def system(commands, **kwargs):
 process = Popen(
 shellCommand,
 stdout=PIPE,
-stderr=PIPE,
+stderr=STDOUT,
 shell=True,
 **kwargs)
 pid = process.pid
@@ -440,14 +440,12 @@ def system(commands, **kwargs):
 cpe = CalledProcessError(retcode, cmd)
 # Ensure caller can access the stdout/stderr.
 cpe.lldb_extensions = {
-"stdout_content": this_output,
-"stderr_content": this_error,
+"combined_output": this_output,
 "command": shellCommand
 }
 raise cpe
 output = output + this_output.decode("utf-8")
-error = error + this_error.decode("utf-8")
-return (output, error)
+return output
 
 
 def getsource_if_available(obj):
@@ -1280,7 +1278,7 @@ def getCompilerVersion(self):
 version = 'unknown'
 
 compiler = self.getCompilerBinary()
-version_output = system([[compiler, "-v"]])[1]
+version_output = system([[compiler, "-v"]])
 for line in version_output.split(os.linesep):
 m = re.search('version ([0-9\.]+)', line)
 if m:

diff  --git a/lldb/packages/Python/lldbsuite/test_event/build_exception.py 
b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
index 3347d9fd7cf7..993214edd871 100644
--- a/lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -4,8 +4,7 @@ def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
 self.command = called_process_error.lldb_extensions.get(
 "command", "")
-self.build_error = called_process_error.lldb_extensions.get(
-"stderr_content", "")
+self.build_error = 
called_process_error.lldb_extensions["combined_output"]
 
 def __str__(self):
 return self.format_build_error(self.command, self.build_error)

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
index f5cf525427c8..aa5e20bd2f75 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py
@@ -146,7 +146,7 @@ def cleanup():
 if self.getCompiler().endswith('gcc') and not 
self.getCompiler().endswith('llvm-gcc'):
 import re
 gcc_version_output = system(
-[[lldbutil.which(self.getCompiler()), "-v"]])[1]
+[[lldbutil.which(self.getCompiler()), "-v"]])
 self.trace("my output:", gcc_version_output)
 for line in gcc_version_output.split(os.linesep):
 m = re.search('\(Apple Inc\. build ([0-9]+)\)', line)



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] 0d5fc82 - [lldb] Eliminate unneeded value parameters in Utility (NFC)

2020-07-23 Thread Pavel Labath via lldb-commits
On 22/07/2020 22:56, Jonas Devlieghere via lldb-commits wrote:
> -  ConstString operator=(ConstString rhs) {
> +  ConstString operator=(const ConstString &rhs) {

ConstString is trivially copyable (well, it has a user defined copy
constructor but it is trivial...).

Plus, not so long ago (D59030) we changed all `const ConstString &`s to
plain `ConstString`. It would be good to avoid flipping this back and
forth all the time.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9cdd68e - Recommit "[lldb/API] Overwrite variables with SBLaunchInfo::SetEnvironment(append=true)"

2020-07-23 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-23T14:17:57+02:00
New Revision: 9cdd68e7c1331efd3c0aec84ef925a1679a73771

URL: 
https://github.com/llvm/llvm-project/commit/9cdd68e7c1331efd3c0aec84ef925a1679a73771
DIFF: 
https://github.com/llvm/llvm-project/commit/9cdd68e7c1331efd3c0aec84ef925a1679a73771.diff

LOG: Recommit "[lldb/API] Overwrite variables with 
SBLaunchInfo::SetEnvironment(append=true)"

The patch was reverted 27d52cd86a2c because of failures in
TestWeakSymbols.py. These have now been addressed in D83552.

The original commit message was:
This function was documented to overwrite entries with D76111, which was
adding a couple of similar functions. However, this function (unlike the
functions added in that patch) was/is not actually overwriting variables
-- any pre-existing variables would get ignored.

This behavior does not seem to be intentional. In fact, before the refactor in
D41359, this function could introduce duplicate entries, which could
have very surprising effects both inside lldb and on other applications
(some applications would take the first value, some the second one; in
lldb, attempting to unset a variable could make the second variable
become active, etc.).

Overwriting seems to be the most reasonable behavior here, so change the
code to match documentation.

Differential Revision: https://reviews.llvm.org/D83306

Added: 


Modified: 
lldb/source/API/SBLaunchInfo.cpp
lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py

Removed: 




diff  --git a/lldb/source/API/SBLaunchInfo.cpp 
b/lldb/source/API/SBLaunchInfo.cpp
index ba13072e8f9b..cda8134c9853 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -190,9 +190,10 @@ void SBLaunchInfo::SetEnvironment(const SBEnvironment 
&env, bool append) {
   LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
  (const lldb::SBEnvironment &, bool), env, append);
   Environment &refEnv = env.ref();
-  if (append)
-m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
-  else
+  if (append) {
+for (auto &KV : refEnv)
+  m_opaque_sp->GetEnvironment().insert_or_assign(KV.first(), KV.second);
+  } else
 m_opaque_sp->GetEnvironment() = refEnv;
   m_opaque_sp->RegenerateEnvp();
 }

diff  --git a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py 
b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
index c1937f985e28..6389854ce58f 100644
--- a/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
+++ b/lldb/test/API/python_api/sbenvironment/TestSBEnvironment.py
@@ -53,6 +53,11 @@ def test_launch_info(self):
 launch_info.SetEnvironment(env, append=True)
 self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
 
+env.Set("FOO", "baz", overwrite=True)
+launch_info.SetEnvironment(env, append=True)
+self.assertEqual(launch_info.GetEnvironment().GetNumValues(), 
env_count + 1)
+self.assertEqual(launch_info.GetEnvironment().Get("FOO"), "baz")
+
 # Make sure we can replace the launchInfo's environment
 env.Clear()
 env.Set("BAR", "foo", overwrite=True)
@@ -120,6 +125,11 @@ def test_creating_and_modifying_environment(self):
 env.SetEntries(entries, append=False)
 self.assertEqualEntries(env, ["X=x", "Y=y"])
 
+entries.Clear()
+entries.AppendList(["X=y", "Y=x"], 2)
+env.SetEntries(entries, append=True)
+self.assertEqualEntries(env, ["X=y", "Y=x"])
+
 # Test clear
 env.Clear()
 self.assertEqualEntries(env, [])



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] 0d5fc82 - [lldb] Eliminate unneeded value parameters in Utility (NFC)

2020-07-24 Thread Pavel Labath via lldb-commits
On 23/07/2020 18:24, Adrian Prantl wrote:
> Is there some clever C++ way to prohibit taking an object's address (similar 
> to how you can delete a copy constructor)?
> 
> -- adrian

You could =delete the address-of operator, but redefining unary & is
generally frowned upon and I am not sure it will achieve what you want
-- it would not prevent anyone from binding a reference to an existing
object.

I don't think there's any way to prevent that, and even if it were, it
would likely break too much generic code which expects to accept objects
by const&.

pl
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] e89414f - [lldb/Utility] Clean up Scalar constructors

2020-07-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-27T10:06:56+02:00
New Revision: e89414f4060d3ff2afcd1c89fc028d61270c4d22

URL: 
https://github.com/llvm/llvm-project/commit/e89414f4060d3ff2afcd1c89fc028d61270c4d22
DIFF: 
https://github.com/llvm/llvm-project/commit/e89414f4060d3ff2afcd1c89fc028d61270c4d22.diff

LOG: [lldb/Utility] Clean up Scalar constructors

- move initialization to initializer lists
- make desctructor non-virtual (nothing else is)
- fix long double constructor so that it actually works

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 524b71523074..1dbcf80bfd89 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -60,41 +60,30 @@ class Scalar {
   };
 
   // Constructors and Destructors
-  Scalar();
-  Scalar(int v) : m_type(e_sint), m_float(static_cast(0)) {
-m_integer = llvm::APInt(sizeof(int) * 8, v, true);
-  }
-  Scalar(unsigned int v) : m_type(e_uint), m_float(static_cast(0)) {
-m_integer = llvm::APInt(sizeof(int) * 8, v);
-  }
-  Scalar(long v) : m_type(e_slong), m_float(static_cast(0)) {
-m_integer = llvm::APInt(sizeof(long) * 8, v, true);
-  }
-  Scalar(unsigned long v) : m_type(e_ulong), m_float(static_cast(0)) {
-m_integer = llvm::APInt(sizeof(long) * 8, v);
-  }
-  Scalar(long long v) : m_type(e_slonglong), m_float(static_cast(0)) {
-m_integer = llvm::APInt(sizeof(long long) * 8, v, true);
-  }
+  Scalar() : m_type(e_void), m_float(0.0f) {}
+  Scalar(int v)
+  : m_type(e_sint), m_integer(sizeof(v) * 8, v, true), m_float(0.0f) {}
+  Scalar(unsigned int v)
+  : m_type(e_uint), m_integer(sizeof(v) * 8, v, false), m_float(0.0f) {}
+  Scalar(long v)
+  : m_type(e_slong), m_integer(sizeof(v) * 8, v, true), m_float(0.0f) {}
+  Scalar(unsigned long v)
+  : m_type(e_ulong), m_integer(sizeof(v) * 8, v, false), m_float(0.0f) {}
+  Scalar(long long v)
+  : m_type(e_slonglong), m_integer(sizeof(v) * 8, v, true), m_float(0.0f) 
{}
   Scalar(unsigned long long v)
-  : m_type(e_ulonglong), m_float(static_cast(0)) {
-m_integer = llvm::APInt(sizeof(long long) * 8, v);
-  }
-  Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); }
-  Scalar(double v) : m_type(e_double), m_float(v) {
-m_float = llvm::APFloat(v);
+  : m_type(e_ulonglong), m_integer(sizeof(v) * 8, v, false), m_float(0.0f) 
{
   }
-  Scalar(long double v)
-  : m_type(e_long_double),
-m_float(llvm::APFloat::x87DoubleExtended(),
-llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
-(reinterpret_cast(&v))->x)) {}
-  Scalar(llvm::APInt v) : m_type(), m_float(static_cast(0)) {
-m_integer = llvm::APInt(std::move(v));
-m_type = GetBestTypeForBitSize(m_integer.getBitWidth(), true);
+  Scalar(float v) : m_type(e_float), m_float(v) {}
+  Scalar(double v) : m_type(e_double), m_float(v) {}
+  Scalar(long double v) : m_type(e_long_double), m_float(double(v)) {
+bool ignore;
+m_float.convert(llvm::APFloat::x87DoubleExtended(),
+llvm::APFloat::rmNearestTiesToEven, &ignore);
   }
-  // Scalar(const RegisterValue& reg_value);
-  virtual ~Scalar();
+  Scalar(llvm::APInt v)
+  : m_type(GetBestTypeForBitSize(v.getBitWidth(), true)),
+m_integer(std::move(v)), m_float(0.0f) {}
 
   /// Return the most efficient Scalar::Type for the requested bit size.
   static Type GetBestTypeForBitSize(size_t bit_size, bool sign);

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 27d5b3b88d33..9309f8d662da 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -126,8 +126,6 @@ static Scalar::Type PromoteToMaxType(
   return Scalar::e_void;
 }
 
-Scalar::Scalar() : m_type(e_void), m_float(static_cast(0)) {}
-
 bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const {
   size_t byte_size = GetByteSize();
   if (byte_size == 0) {
@@ -232,8 +230,6 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
   }
 }
 
-Scalar::~Scalar() = default;
-
 Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {
   // Scalar types are always host types, hence the sizeof().
   if (sign) {

diff  --git a/lldb/unittests/Utility/ScalarTest.cpp 
b/lldb/unittests/Utility/ScalarTest.cpp
index f6bc6a404c15..70ce0a81627d 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -92,6 +92,7 @@ TEST(ScalarTest, Getters) {
   CheckConversion(0x8765432112345678ull);
   CheckConversion(42.25f);
   CheckConversion(42.25);
+  CheckConversion(42.25L);
 
   EXPECT_EQ(APInt(128, 1) << 70, Scalar(std::pow(2.0f, 
70.0f)).SInt128(APInt()));
   EXPECT_EQ(APInt(128, -1, true) << 70,


   

[Lldb-commits] [lldb] 81d7eba - [lldb/Utility] Fix a bug in RangeMap::CombineConsecutiveRanges

2020-07-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-27T10:06:56+02:00
New Revision: 81d7ebaf5c369d42b77f9e3e47e2ac22c306ec04

URL: 
https://github.com/llvm/llvm-project/commit/81d7ebaf5c369d42b77f9e3e47e2ac22c306ec04
DIFF: 
https://github.com/llvm/llvm-project/commit/81d7ebaf5c369d42b77f9e3e47e2ac22c306ec04.diff

LOG: [lldb/Utility] Fix a bug in RangeMap::CombineConsecutiveRanges

The function didn't combine a large entry which overlapped several other
entries, if those other entries were not overlapping among each other.

E.g., (0,20),(5,6),(10,11) produced (0,20),(10,11)

Now it just produced (0,20).

Added: 


Modified: 
lldb/include/lldb/Utility/RangeMap.h
lldb/unittests/Utility/RangeMapTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index fb24c5a43479..118fdfd85fa9 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -194,41 +194,25 @@ template  class 
RangeVector {
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-// Can't combine if ranges if we have zero or one range
-if (m_entries.size() > 1) {
-  // The list should be sorted prior to calling this function
-  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->DoesAdjoinOrIntersect(*pos)) {
-  can_combine = true;
-  break;
-}
-  }
+auto first_intersect = std::adjacent_find(
+m_entries.begin(), m_entries.end(), [](const Entry &a, const Entry &b) 
{
+  return a.DoesAdjoinOrIntersect(b);
+});
+if (first_intersect == m_entries.end())
+  return;
 
-  // 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->DoesAdjoinOrIntersect(*pos))
-minimal_ranges.back().SetRangeEnd(
-std::max(prev->GetRangeEnd(), 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);
-  }
+// We we can combine at least one entry, then we make a new collection and
+// populate it accordingly, and then swap it into place.
+auto pos = std::next(first_intersect);
+Collection minimal_ranges(m_entries.begin(), pos);
+for (; pos != m_entries.end(); ++pos) {
+  Entry &back = minimal_ranges.back();
+  if (back.DoesAdjoinOrIntersect(*pos))
+back.SetRangeEnd(std::max(back.GetRangeEnd(), pos->GetRangeEnd()));
+  else
+minimal_ranges.push_back(*pos);
 }
+m_entries.swap(minimal_ranges);
   }
 
   BaseType GetMinRangeBase(BaseType fail_value) const {
@@ -353,6 +337,10 @@ template  class 
RangeVector {
 return nullptr;
   }
 
+  using const_iterator = typename Collection::const_iterator;
+  const_iterator begin() const { return m_entries.begin(); }
+  const_iterator end() const { return m_entries.end(); }
+
 protected:
   void CombinePrevAndNext(typename Collection::iterator pos) {
 // Check if the prev or next entries in case they need to be unioned with

diff  --git a/lldb/unittests/Utility/RangeMapTest.cpp 
b/lldb/unittests/Utility/RangeMapTest.cpp
index 8a243b656218..97432dca983d 100644
--- a/lldb/unittests/Utility/RangeMapTest.cpp
+++ b/lldb/unittests/Utility/RangeMapTest.cpp
@@ -12,6 +12,32 @@
 
 using namespace lldb_private;
 
+TEST(RangeVector, CombineConsecutiveRanges) {
+  using RangeVector = RangeVector;
+  using Entry = RangeVector::Entry;
+
+  RangeVector V;
+  V.Append(0, 1);
+  V.Append(5, 1);
+  V.Append(6, 1);
+  V.Append(10, 9);
+  V.Append(15, 1);
+  V.Append(20, 9);
+  V.Append(21, 9);
+  V.Sort();
+  V.CombineConsecutiveRanges();
+  EXPECT_THAT(V, testing::ElementsAre(Entry(0, 1), Entry(5, 2), Entry(10, 9),
+  Entry(20, 10)));
+
+  V.Clear();
+  V.Append(0, 20);
+  V.Append(5, 1);
+  V.Append(10, 1);
+  V.Sort();
+  V.CombineConsecutiveRanges();
+  EXPECT_THAT(V, testing::ElementsAre(Entry(0, 20)));
+}
+
 using RangeDataVectorT = RangeDataVector;
 using EntryT = RangeData

[Lldb-commits] [lldb] 2e828e7 - [lldb] Fix e89414f406 for msvc

2020-07-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-27T11:49:46+02:00
New Revision: 2e828e7579928e8cc1c5e53c84ab99ffb5afca03

URL: 
https://github.com/llvm/llvm-project/commit/2e828e7579928e8cc1c5e53c84ab99ffb5afca03
DIFF: 
https://github.com/llvm/llvm-project/commit/2e828e7579928e8cc1c5e53c84ab99ffb5afca03.diff

LOG: [lldb] Fix e89414f406 for msvc

MSVC finds the APInt construction ambiguous. Use a case to help it
choose the right constructor.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 1dbcf80bfd89..45ba7c012229 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -62,18 +62,23 @@ class Scalar {
   // Constructors and Destructors
   Scalar() : m_type(e_void), m_float(0.0f) {}
   Scalar(int v)
-  : m_type(e_sint), m_integer(sizeof(v) * 8, v, true), m_float(0.0f) {}
+  : m_type(e_sint), m_integer(sizeof(v) * 8, uint64_t(v), true),
+m_float(0.0f) {}
   Scalar(unsigned int v)
-  : m_type(e_uint), m_integer(sizeof(v) * 8, v, false), m_float(0.0f) {}
+  : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
+m_float(0.0f) {}
   Scalar(long v)
-  : m_type(e_slong), m_integer(sizeof(v) * 8, v, true), m_float(0.0f) {}
+  : m_type(e_slong), m_integer(sizeof(v) * 8, uint64_t(v), true),
+m_float(0.0f) {}
   Scalar(unsigned long v)
-  : m_type(e_ulong), m_integer(sizeof(v) * 8, v, false), m_float(0.0f) {}
+  : m_type(e_ulong), m_integer(sizeof(v) * 8, uint64_t(v), false),
+m_float(0.0f) {}
   Scalar(long long v)
-  : m_type(e_slonglong), m_integer(sizeof(v) * 8, v, true), m_float(0.0f) 
{}
+  : m_type(e_slonglong), m_integer(sizeof(v) * 8, uint64_t(v), true),
+m_float(0.0f) {}
   Scalar(unsigned long long v)
-  : m_type(e_ulonglong), m_integer(sizeof(v) * 8, v, false), m_float(0.0f) 
{
-  }
+  : m_type(e_ulonglong), m_integer(sizeof(v) * 8, uint64_t(v), false),
+m_float(0.0f) {}
   Scalar(float v) : m_type(e_float), m_float(v) {}
   Scalar(double v) : m_type(e_double), m_float(v) {}
   Scalar(long double v) : m_type(e_long_double), m_float(double(v)) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1956cf1 - [lldb/DWARF] Don't treat class declarations with children as definitions

2020-07-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-07-27T12:58:22+02:00
New Revision: 1956cf1042d3c406d9e9cefe47d3b43adf2bdbe1

URL: 
https://github.com/llvm/llvm-project/commit/1956cf1042d3c406d9e9cefe47d3b43adf2bdbe1
DIFF: 
https://github.com/llvm/llvm-project/commit/1956cf1042d3c406d9e9cefe47d3b43adf2bdbe1.diff

LOG: [lldb/DWARF] Don't treat class declarations with children as definitions

Summary:
This effectively reverts r188124, which added code to handle
(DW_AT_)declarations of structures with some kinds of children as
definitions. The commit message claims this is a workaround for some
kind of debug info produced by gcc. However, it does not go into
specifics, so it's hard to reproduce or verify that this is indeed still a
problem.

Having this code is definitely a problem though, because it mistakenly
declares incomplete dwarf declarations to be complete. Both clang (with
-flimit-debug-info) and gcc (by default) generate DW_AT_declarations of
structs with children. This happens when full debug info for a class is
not emitted in a given compile unit (e.g. because of vtable homing), but
the class has inline methods which are used in the given compile unit.
In that case, the compilers emit a DW_AT_declaration of a class, but
add a DW_TAG_subprogram child to it to describe the inlined instance of
the method.

Even though the class tag has some children, it definitely does not
contain enough information to construct a full class definition (most
notably, it lacks any members). Keeping the class as incomplete allows
us to search for a real definition in other modules, helping the
-flimit-debug-info flow. And in case the definition is not found we can
display a error message saying that, instead of just showing an empty
struct.

Reviewers: clayborg, aprantl, JDevlieghere, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D83302

Added: 
lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
lldb/test/API/functionalities/limit-debug-info/main.cpp
lldb/test/API/functionalities/limit-debug-info/one.cpp
lldb/test/API/functionalities/limit-debug-info/onetwo.h
lldb/test/API/functionalities/limit-debug-info/two.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 35e7c34734e2..7e3628504727 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1641,33 +1641,6 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
*unique_ast_entry_up);
 
-  if (attrs.is_forward_declaration && die.HasChildren()) {
-// Check to see if the DIE actually has a definition, some version of
-// GCC will
-// emit DIEs with DW_AT_declaration set to true, but yet still have
-// subprogram, members, or inheritance, so we can't trust it
-DWARFDIE child_die = die.GetFirstChild();
-while (child_die) {
-  switch (child_die.Tag()) {
-  case DW_TAG_inheritance:
-  case DW_TAG_subprogram:
-  case DW_TAG_member:
-  case DW_TAG_APPLE_property:
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-  case DW_TAG_enumeration_type:
-  case DW_TAG_typedef:
-  case DW_TAG_union_type:
-child_die.Clear();
-attrs.is_forward_declaration = false;
-break;
-  default:
-child_die = child_die.GetSibling();
-break;
-  }
-}
-  }
-
   if (!attrs.is_forward_declaration) {
 // Always start the definition for a class type so that if the class
 // has child classes or types that require the class to be created

diff  --git 
a/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py 
b/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
index 9408ad6eee1d..aa383d0005e4 100644
--- a/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ b/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -38,7 +38,8 @@ def test_one_and_two_debug(self):
 
 self._check_debug_info_is_limited(target)
 
-self.registerSharedLibrariesWithTarget(target, ["one", "two"])
+lldbutil.run_to_name_breakpoint(self, "main",
+extra_images=["one", "two"])
 
 # But when other shared libraries are loaded, we should be able to see
 # all members.
@@ -58,6 +59,10 @@ def test_one_and_two_debug(self):
 self.expect_expr("array_of_two[2].one[2].member", result_value="174")
 self.expect_expr("array_of_two[2].member", result_value="274")
 
+  

Re: [Lldb-commits] [lldb] 1d9b860 - Unify the return value of GetByteSize to an llvm::Optional (NFC-ish)

2020-07-27 Thread Pavel Labath via lldb-commits
On 27/07/2020 19:03, Adrian Prantl via lldb-commits wrote:
> Do you happen to have a link to a bot with the failures? Or can you send
> me the output in case it's an internal bot?
> 
> thanks,
> adrian
> 

This should do it:
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/14598
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] a06c28d - Temporarily revert "[test] Exit with an error if no tests are run."

2020-08-11 Thread Pavel Labath via lldb-commits
On 04/08/2020 17:34, Jordan Rupprecht via lldb-commits wrote:
> Thanks, that explains it! Namely this part:
> 
> if sys.platform.startswith('win32'):
>     # llvm.org/pr22274 : need a pexpect
> replacement for windows
>     class PExpectTest(object):
>         pass
> else:
>     import pexpect
>     class PExpectTest(TestBase):
> 
> For this change to reland, I'll need to make it always inherit from
> TestBase, but suppressed in some other way (maybe seeing if decorators
> like @skipIfWindows can be applied to whole test classes)

I believe that should be possible for @skipIfWindows (though not for
some of our other decorators).

pl
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bb91c9f - [cmake] Make gtest macro definitions a part the library interface

2020-08-11 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-11T15:22:44+02:00
New Revision: bb91c9fe7b62939fdb11ae42a31a5d5a61575ae7

URL: 
https://github.com/llvm/llvm-project/commit/bb91c9fe7b62939fdb11ae42a31a5d5a61575ae7
DIFF: 
https://github.com/llvm/llvm-project/commit/bb91c9fe7b62939fdb11ae42a31a5d5a61575ae7.diff

LOG: [cmake] Make gtest macro definitions a part the library interface

These definitions are needed by any file which uses gtest. Previously we
were adding them in the add_unittest function, but over time we've
accumulated libraries (which don't go through add_unittest) building on
gtest and this has resulted in proliferation of the definitions.

Making this a part of the library interface enables them to be managed
centrally. This follows a patch for -Wno-suggest-override (D84554) which
took a similar approach.

Differential Revision: https://reviews.llvm.org/D84748

Added: 


Modified: 
lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/Testing/Support/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt 
b/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
index c9891f2b0777..3faec7c8030b 100644
--- a/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
@@ -3,13 +3,6 @@ add_lldb_library(lldbSymbolHelpers
   YAMLModuleTester.cpp
   )
 
-# Our current version of gtest does not properly recognize C++11 support
-# with MSVC, so it falls back to tr1 / experimental classes.  Since LLVM
-# itself requires C++11, we can safely force it on unconditionally so that
-# we don't have to fight with the buggy gtest check.
-target_compile_definitions(lldbSymbolHelpers PUBLIC
-  -DGTEST_LANG_CXX11=1
-  -DGTEST_HAS_TR1_TUPLE=0)
 target_include_directories(lldbSymbolHelpers PUBLIC
   ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include
   ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index ac3d5c8e3c7d..7b8077efab51 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1400,15 +1400,8 @@ function(add_unittest test_suite test_name)
 set(EXCLUDE_FROM_ALL ON)
   endif()
 
-  # Our current version of gtest uses tr1/tuple which is deprecated on MSVC.
-  # Since LLVM itself requires C++14, we can safely force it off.
-  add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
-
   include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
   include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
-  if (NOT LLVM_ENABLE_THREADS)
-list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0)
-  endif ()
 
   if (SUPPORTS_VARIADIC_MACROS_FLAG)
 list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")

diff  --git a/llvm/lib/Testing/Support/CMakeLists.txt 
b/llvm/lib/Testing/Support/CMakeLists.txt
index fe460aeefc91..4f5345c1dc57 100644
--- a/llvm/lib/Testing/Support/CMakeLists.txt
+++ b/llvm/lib/Testing/Support/CMakeLists.txt
@@ -1,6 +1,3 @@
-add_definitions(-DGTEST_LANG_CXX11=1)
-add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
-
 add_llvm_library(LLVMTestingSupport
   Annotations.cpp
   Error.cpp

diff  --git a/llvm/utils/unittest/CMakeLists.txt 
b/llvm/utils/unittest/CMakeLists.txt
index e7caf37727fc..14c780342b60 100644
--- a/llvm/utils/unittest/CMakeLists.txt
+++ b/llvm/utils/unittest/CMakeLists.txt
@@ -19,9 +19,6 @@ include_directories(
   googlemock
   )
 
-# Gtest 1.8.0 uses tr1/tuple which is deprecated on MSVC, so we force it off.
-add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
-
 if(WIN32)
   add_definitions(-DGTEST_OS_WINDOWS=1)
 endif()
@@ -45,10 +42,6 @@ endif()
 set(LLVM_REQUIRES_RTTI 1)
 add_definitions( -DGTEST_HAS_RTTI=0 )
 
-if (NOT LLVM_ENABLE_THREADS)
-  add_definitions( -DGTEST_HAS_PTHREAD=0 )
-endif()
-
 find_library(LLVM_PTHREAD_LIBRARY_PATH pthread)
 if (LLVM_PTHREAD_LIBRARY_PATH)
   list(APPEND LIBS pthread)
@@ -76,6 +69,13 @@ if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
   set_target_properties(gtest PROPERTIES INTERFACE_COMPILE_OPTIONS 
"-Wno-suggest-override")
 endif()
 
+# Gtest 1.8.0 uses tr1/tuple which is deprecated on MSVC, so we force it off.
+target_compile_definitions(gtest PUBLIC GTEST_HAS_TR1_TUPLE=0)
+
+if (NOT LLVM_ENABLE_THREADS)
+  target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
+endif ()
+
 add_subdirectory(UnitTestMain)
 
 # When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 40d7742 - [lldb/Utility] Simplify Scalar::PromoteToMaxType

2020-08-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-14T11:09:16+02:00
New Revision: 40d774265b08fbfd0f3e2ffa79ce7feddbd060bc

URL: 
https://github.com/llvm/llvm-project/commit/40d774265b08fbfd0f3e2ffa79ce7feddbd060bc
DIFF: 
https://github.com/llvm/llvm-project/commit/40d774265b08fbfd0f3e2ffa79ce7feddbd060bc.diff

LOG: [lldb/Utility] Simplify Scalar::PromoteToMaxType

The function had very complicated signature, because it was trying to
avoid making unnecessary copies of the Scalar object. However, this
class is not hot enough to worry about these kinds of optimizations. My
making copies unconditionally, we can simplify the function and all of
its call sites.

Differential Revision: https://reviews.llvm.org/D85906

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 45ba7c012229..7e416c04f3ca 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -151,7 +151,7 @@ class Scalar {
   // automagically by the compiler, so no temporary objects will need to be
   // created. As a result, we currently don't need a variety of overloaded set
   // value accessors.
-  Scalar &operator+=(const Scalar &rhs);
+  Scalar &operator+=(Scalar rhs);
   Scalar &operator<<=(const Scalar &rhs); // Shift left
   Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic)
   Scalar &operator&=(const Scalar &rhs);
@@ -266,18 +266,18 @@ class Scalar {
 
 private:
   friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator-(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator/(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator*(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator&(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator|(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator%(const Scalar &lhs, const Scalar &rhs);
-  friend const Scalar operator^(const Scalar &lhs, const Scalar &rhs);
+  friend const Scalar operator-(Scalar lhs, Scalar rhs);
+  friend const Scalar operator/(Scalar lhs, Scalar rhs);
+  friend const Scalar operator*(Scalar lhs, Scalar rhs);
+  friend const Scalar operator&(Scalar lhs, Scalar rhs);
+  friend const Scalar operator|(Scalar lhs, Scalar rhs);
+  friend const Scalar operator%(Scalar lhs, Scalar rhs);
+  friend const Scalar operator^(Scalar lhs, Scalar rhs);
   friend const Scalar operator<<(const Scalar &lhs, const Scalar &rhs);
   friend const Scalar operator>>(const Scalar &lhs, const Scalar &rhs);
-  friend bool operator==(const Scalar &lhs, const Scalar &rhs);
+  friend bool operator==(Scalar lhs, Scalar rhs);
   friend bool operator!=(const Scalar &lhs, const Scalar &rhs);
-  friend bool operator<(const Scalar &lhs, const Scalar &rhs);
+  friend bool operator<(Scalar lhs, Scalar rhs);
   friend bool operator<=(const Scalar &lhs, const Scalar &rhs);
   friend bool operator>(const Scalar &lhs, const Scalar &rhs);
   friend bool operator>=(const Scalar &lhs, const Scalar &rhs);
@@ -297,18 +297,18 @@ class Scalar {
 //  Differentiate among members functions, non-member functions, and
 //  friend functions
 const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator-(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator/(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator*(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator&(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator|(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator%(const Scalar &lhs, const Scalar &rhs);
-const Scalar operator^(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator-(Scalar lhs, Scalar rhs);
+const Scalar operator/(Scalar lhs, Scalar rhs);
+const Scalar operator*(Scalar lhs, Scalar rhs);
+const Scalar operator&(Scalar lhs, Scalar rhs);
+const Scalar operator|(Scalar lhs, Scalar rhs);
+const Scalar operator%(Scalar lhs, Scalar rhs);
+const Scalar operator^(Scalar lhs, Scalar rhs);
 const Scalar operator<<(const Scalar &lhs, const Scalar &rhs);
 const Scalar operator>>(const Scalar &lhs, const Scalar &rhs);
-bool operator==(const Scalar &lhs, const Scalar &rhs);
+bool operator==(Scalar lhs, Scalar rhs);
 bool operator!=(const Scalar &lhs, const Scalar &rhs);
-bool operator<(const Scalar &lhs, const Scalar &rhs);
+bool operator<(Scalar lhs, Scalar rhs);
 bool operator<=(const Scalar &lhs, const Scalar &rhs);
 bool operator>(const Scalar &lhs, const Scalar &rhs);
 bool operator>=(const Scalar &lhs, const Scalar &rhs);

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 9309f8d662da..2ea1dafcf145 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -82,45 +82,19 @@ static bool IsSigned(S

[Lldb-commits] [lldb] e6b1b61 - [lldb] Fix py3 incompatibility in gdbremote_testcase.py

2020-08-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-14T12:15:25+02:00
New Revision: e6b1b61054c285efad7bf4ee0a4da53e56944d87

URL: 
https://github.com/llvm/llvm-project/commit/e6b1b61054c285efad7bf4ee0a4da53e56944d87
DIFF: 
https://github.com/llvm/llvm-project/commit/e6b1b61054c285efad7bf4ee0a4da53e56944d87.diff

LOG: [lldb] Fix py3 incompatibility in gdbremote_testcase.py

This didn't cause test failures since this variable is only used during
connection shutdown.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index cea0fee3aaaf..253fd35d461e 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -36,7 +36,7 @@ class GdbRemoteTestCaseBase(TestBase):
 # Default sleep time in seconds. The sleep time is doubled under Asan.
 DEFAULT_SLEEP   =  5  * (2  if ('ASAN_OPTIONS' in os.environ) else 1)
 
-_GDBREMOTE_KILL_PACKET = "$k#6b"
+_GDBREMOTE_KILL_PACKET = b"$k#6b"
 
 # Start the inferior separately, attach to the inferior on the stub
 # command line.



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] fdc6aea - [lldb] Check Decl kind when completing -flimit-debug-info types

2020-08-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-14T12:31:37+02:00
New Revision: fdc6aea3fd822b639baaa5b666fdf7598d08c8de

URL: 
https://github.com/llvm/llvm-project/commit/fdc6aea3fd822b639baaa5b666fdf7598d08c8de
DIFF: 
https://github.com/llvm/llvm-project/commit/fdc6aea3fd822b639baaa5b666fdf7598d08c8de.diff

LOG: [lldb] Check Decl kind when completing -flimit-debug-info types

The search for the complete class definition can also produce entries
which are not of the expected type. This can happen for instance when
there is a function with the same name as the class we're looking up
(which means that the class needs to be disambiguated with the
struct/class tag in most contexts).

Previously we were just picking the first Decl that the lookup returned,
which later caused crashes or assertion failures if it was not of the
correct type. This patch changes that to search for an entry of the
correct type.

Differential Revision: https://reviews.llvm.org/D85904

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
lldb/test/API/functionalities/limit-debug-info/main.cpp
lldb/test/API/functionalities/limit-debug-info/one.cpp
lldb/test/API/functionalities/limit-debug-info/onetwo.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 6d8773779a69..73042c205a5a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -870,13 +870,14 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl 
*From) {
   return dn_or_err.takeError();
 DeclContext *dc = *dc_or_err;
 DeclContext::lookup_result lr = dc->lookup(*dn_or_err);
-if (lr.size()) {
-  clang::Decl *lookup_found = lr.front();
-  RegisterImportedDecl(From, lookup_found);
-  m_decls_to_ignore.insert(lookup_found);
-  return lookup_found;
-} else
-  LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
+for (clang::Decl *candidate : lr) {
+  if (candidate->getKind() == From->getKind()) {
+RegisterImportedDecl(From, candidate);
+m_decls_to_ignore.insert(candidate);
+return candidate;
+  }
+}
+LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
   }
 
   return ASTImporter::ImportImpl(From);

diff  --git 
a/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py 
b/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
index aa383d0005e4..f9934df4eda4 100644
--- a/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ b/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -63,6 +63,9 @@ def test_one_and_two_debug(self):
 self.expect_expr("get_two().one().member", result_value="124")
 self.expect_expr("get_two().member", result_value="224")
 
+self.expect_expr("shadowed_one.member", result_value="47")
+self.expect_expr("shadowed_one.one", result_value="142")
+
 @skipIf(bugnumber="pr46284", debug_info="gmodules")
 @skipIfWindows # Clang emits type info even with -flimit-debug-info
 def test_two_debug(self):

diff  --git a/lldb/test/API/functionalities/limit-debug-info/main.cpp 
b/lldb/test/API/functionalities/limit-debug-info/main.cpp
index 1aad7e6f1e61..1fe4feb33664 100644
--- a/lldb/test/API/functionalities/limit-debug-info/main.cpp
+++ b/lldb/test/API/functionalities/limit-debug-info/main.cpp
@@ -1,23 +1,19 @@
 #include "onetwo.h"
 
 struct InheritsFromOne : One {
-  constexpr InheritsFromOne() = default;
   int member = 47;
 } inherits_from_one;
 
 struct InheritsFromTwo : Two {
-  constexpr InheritsFromTwo() = default;
   int member = 47;
 } inherits_from_two;
 
 struct OneAsMember {
-  constexpr OneAsMember() = default;
   member::One one;
   int member = 47;
 } one_as_member;
 
 struct TwoAsMember {
-  constexpr TwoAsMember() = default;
   member::Two two;
   int member = 47;
 } two_as_member;
@@ -28,4 +24,9 @@ array::Two array_of_two[3];
 result::One get_one() { return result::One(124); }
 result::Two get_two() { return result::Two(224); }
 
+// Note that there's also a function with the name func_shadow::One.
+struct ShadowedOne : func_shadow::One {
+  int member = 47;
+} shadowed_one;
+
 int main() { return get_one().member; }

diff  --git a/lldb/test/API/functionalities/limit-debug-info/one.cpp 
b/lldb/test/API/functionalities/limit-debug-info/one.cpp
index 70353a084edc..ce1d5d14ca06 100644
--- a/lldb/test/API/functionalities/limit-debug-info/one.cpp
+++ b/lldb/test/API/functionalities/limit-debug-info/one.cpp
@@ -6,3 +6,7 @@ array::One::~One() = default;
 
 result::One::One(int member) : member(member) {}
 result::One::~One() = default;
+
+void fun

[Lldb-commits] [lldb] 2d89a3b - [lldb] Forcefully complete a type when adding nested classes

2020-08-17 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-17T11:09:13+02:00
New Revision: 2d89a3ba121b96a4af9aecaf52205eab200394c3

URL: 
https://github.com/llvm/llvm-project/commit/2d89a3ba121b96a4af9aecaf52205eab200394c3
DIFF: 
https://github.com/llvm/llvm-project/commit/2d89a3ba121b96a4af9aecaf52205eab200394c3.diff

LOG: [lldb] Forcefully complete a type when adding nested classes

With -flimit-debug-info, we can run into cases when we only have a class
as a declaration, but we do have a definition of a nested class. In this
case, clang will hit an assertion when adding a member to an incomplete
type (but only if it's adding a c++ class, and not C struct).

It turns out we already had code to handle a similar situation arising
in the -gmodules scenario. This extends the code to handle
-flimit-debug-info as well, and reorganizes bits of other code handling
completion of types to move functions doing similar things closer
together.

Differential Revision: https://reviews.llvm.org/D85968

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 7e3628504727..1344523522d3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -230,31 +230,73 @@ TypeSP 
DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
   return type_sp;
 }
 
-static void CompleteExternalTagDeclType(TypeSystemClang &ast,
-ClangASTImporter &ast_importer,
-clang::DeclContext *decl_ctx,
-DWARFDIE die,
-const char *type_name_cstr) {
+static void ForcefullyCompleteType(CompilerType type) {
+  bool started = TypeSystemClang::StartTagDeclarationDefinition(type);
+  lldbassert(started && "Unable to start a class type definition.");
+  TypeSystemClang::CompleteTagDeclarationDefinition(type);
+  const clang::TagDecl *td = ClangUtil::GetAsTagDecl(type);
+  auto &ts = llvm::cast(*type.GetTypeSystem());
+  ts.GetMetadata(td)->SetIsForcefullyCompleted();
+}
+
+/// Complete a type from debug info, or mark it as forcefully completed if
+/// there is no definition of the type in the current Module. Call this 
function
+/// in contexts where the usual C++ rules require a type to be complete (base
+/// class, member, etc.).
+static void RequireCompleteType(CompilerType type) {
+  // Technically, enums can be incomplete too, but we don't handle those as 
they
+  // are emitted even under -flimit-debug-info.
+  if (!TypeSystemClang::IsCXXClassType(type))
+return;
+
+  if (type.GetCompleteType())
+return;
+
+  // No complete definition in this module.  Mark the class as complete to
+  // satisfy local ast invariants, but make a note of the fact that
+  // it is not _really_ complete so we can later search for a definition in a
+  // 
diff erent module.
+  // Since we provide layout assistance, layouts of types containing this class
+  // will be correct even if we  are not able to find the definition elsewhere.
+  ForcefullyCompleteType(type);
+}
+
+/// This function serves a similar purpose as RequireCompleteType above, but it
+/// avoids completing the type if it is not immediately necessary. It only
+/// ensures we _can_ complete the type later.
+static void PrepareContextToReceiveMembers(TypeSystemClang &ast,
+   ClangASTImporter &ast_importer,
+   clang::DeclContext *decl_ctx,
+   DWARFDIE die,
+   const char *type_name_cstr) {
   auto *tag_decl_ctx = clang::dyn_cast(decl_ctx);
   if (!tag_decl_ctx)
+return; // Non-tag context are always ready.
+
+  // We have already completed the type, or we have found its definition and 
are
+  // ready to complete it later (cf. ParseStructureLikeDIE).
+  if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
 return;
 
+  // We reach this point of the tag was present in the debug info as a
+  // declaration only. If it was imported from another AST context (in the
+  // gmodules case), we can complete the type by doing a full import.
+
   // If this type was not imported from an external AST, there's nothing to do.
   CompilerType type = ast.GetTypeForDecl(tag_decl_ctx);
-  if (!type || !ast_importer.CanImport(type))
-return;
-
-  auto qual_type = ClangUtil::GetQualType(type);
-  if (!ast_importer.RequireCompleteType(qual_type)) {
+  if (type && ast_importer.CanImport(type)) {

[Lldb-commits] [lldb] 67cdb89 - [lldb/Utility] Simplify and generalize Scalar class

2020-08-17 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-17T11:09:56+02:00
New Revision: 67cdb899c6b3ec231f35ca17a00023758ef127ba

URL: 
https://github.com/llvm/llvm-project/commit/67cdb899c6b3ec231f35ca17a00023758ef127ba
DIFF: 
https://github.com/llvm/llvm-project/commit/67cdb899c6b3ec231f35ca17a00023758ef127ba.diff

LOG: [lldb/Utility] Simplify and generalize Scalar class

The class contains an enum listing all host integer types as well as
some non-host types. This setup is a remnant of a time when this class
was actually implemented in terms of host integer types. Now that we are
using llvm::APInt, they are mostly useless and mean that each function
needs to enumerate all of these cases even though it treats most of them
identically.

I only leave e_sint and e_uint to denote the integer signedness, but I
want to remove that in a follow-up as well.

Removing these cases simplifies most of these functions, with the only
exception being PromoteToMaxType, which can no longer rely on a simple
enum comparison to determine what needs to be promoted.

This also makes the class ready to work with arbitrary integer sizes, so
it does not need to be modified when someone needs to add a larger
integer size.

Differential Revision: https://reviews.llvm.org/D85836

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 7e416c04f3ca..d1e0fdd888df 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -44,16 +44,6 @@ class Scalar {
 e_void = 0,
 e_sint,
 e_uint,
-e_slong,
-e_ulong,
-e_slonglong,
-e_ulonglong,
-e_sint128,
-e_uint128,
-e_sint256,
-e_uint256,
-e_sint512,
-e_uint512,
 e_float,
 e_double,
 e_long_double
@@ -68,16 +58,16 @@ class Scalar {
   : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
 m_float(0.0f) {}
   Scalar(long v)
-  : m_type(e_slong), m_integer(sizeof(v) * 8, uint64_t(v), true),
+  : m_type(e_sint), m_integer(sizeof(v) * 8, uint64_t(v), true),
 m_float(0.0f) {}
   Scalar(unsigned long v)
-  : m_type(e_ulong), m_integer(sizeof(v) * 8, uint64_t(v), false),
+  : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
 m_float(0.0f) {}
   Scalar(long long v)
-  : m_type(e_slonglong), m_integer(sizeof(v) * 8, uint64_t(v), true),
+  : m_type(e_sint), m_integer(sizeof(v) * 8, uint64_t(v), true),
 m_float(0.0f) {}
   Scalar(unsigned long long v)
-  : m_type(e_ulonglong), m_integer(sizeof(v) * 8, uint64_t(v), false),
+  : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
 m_float(0.0f) {}
   Scalar(float v) : m_type(e_float), m_float(v) {}
   Scalar(double v) : m_type(e_double), m_float(v) {}
@@ -131,7 +121,8 @@ class Scalar {
   /// Convert to an integer with \p bits and the given signedness.
   void TruncOrExtendTo(uint16_t bits, bool sign);
 
-  bool Promote(Scalar::Type type);
+  bool IntegralPromote(uint16_t bits, bool sign);
+  bool FloatPromote(Scalar::Type type);
 
   bool MakeSigned();
 
@@ -264,6 +255,11 @@ class Scalar {
 
   template  T GetAs(T fail_value) const;
 
+  static Type PromoteToMaxType(Scalar &lhs, Scalar &rhs);
+
+  using IntPromotionKey = std::pair;
+  IntPromotionKey GetIntKey() const;
+
 private:
   friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
   friend const Scalar operator-(Scalar lhs, Scalar rhs);

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 2ea1dafcf145..32082b50eaa8 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -39,17 +39,7 @@ static Category GetCategory(Scalar::Type type) {
   case Scalar::e_long_double:
 return Category::Float;
   case Scalar::e_sint:
-  case Scalar::e_slong:
-  case Scalar::e_slonglong:
-  case Scalar::e_sint128:
-  case Scalar::e_sint256:
-  case Scalar::e_sint512:
   case Scalar::e_uint:
-  case Scalar::e_ulong:
-  case Scalar::e_ulonglong:
-  case Scalar::e_uint128:
-  case Scalar::e_uint256:
-  case Scalar::e_uint512:
 return Category::Integral;
   }
   llvm_unreachable("Unhandled type!");
@@ -59,18 +49,8 @@ static bool IsSigned(Scalar::Type type) {
   switch (type) {
   case Scalar::e_void:
   case Scalar::e_uint:
-  case Scalar::e_ulong:
-  case Scalar::e_ulonglong:
-  case Scalar::e_uint128:
-  case Scalar::e_uint256:
-  case Scalar::e_uint512:
 return false;
   case Scalar::e_sint:
-  case Scalar::e_slong:
-  case Scalar::e_slonglong:
-  case Scalar::e_sint128:
-  case Scalar::e_sint256:
-  case Scalar::e_sint512:
   case Scalar::e_float:
   case Scalar::e_double:
   case Scalar::e_long_double:
@@ -79,18 +59,38 @@ static bool IsSigned(Scalar::Type type) {
   llvm_unreachable("

[Lldb-commits] [lldb] d736339 - [lldb] Add typedefs to the DeclContext they are created in

2020-08-19 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-19T14:57:43+02:00
New Revision: d7363397c669f611e379988ea12fb428847fce61

URL: 
https://github.com/llvm/llvm-project/commit/d7363397c669f611e379988ea12fb428847fce61
DIFF: 
https://github.com/llvm/llvm-project/commit/d7363397c669f611e379988ea12fb428847fce61.diff

LOG: [lldb] Add typedefs to the DeclContext they are created in

TypeSystemClang::CreateTypedef was creating a typedef in the right
DeclContext, but it was not actually adding it as a child of the
context. The resulting inconsistent state meant that we would be unable
to reference the typedef from an expression directly, but we could use
them if they end up being pulled in by some previous subexpression
(because the ASTImporter will set up the correct links in the expression
ast).

This patch adds the typedef to the decl context it is created in.

Differential Revision: https://reviews.llvm.org/D86140

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
lldb/test/API/lang/cpp/typedef/main.cpp

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 724826de63fa..d8616ef35b0f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2538,6 +2538,7 @@ def expect_expr(
 value_check = ValueCheck(type=result_type, value=result_value,
  summary=result_summary, 
children=result_children)
 value_check.check_value(self, eval_result, str(eval_result))
+return eval_result
 
 def invoke(self, obj, name, trace=False):
 """Use reflection to call a method dynamically with no argument."""

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 608cdc25d072..d80d07574073 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4495,6 +4495,7 @@ CompilerType TypeSystemClang::CreateTypedef(
 clang_ast, decl_ctx, clang::SourceLocation(), clang::SourceLocation(),
 &clang_ast.Idents.get(typedef_name),
 clang_ast.getTrivialTypeSourceInfo(qual_type));
+decl_ctx->addDecl(decl);
 SetOwningModule(decl, TypePayloadClang(payload).GetOwningModule());
 
 clang::TagDecl *tdecl = nullptr;

diff  --git a/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py 
b/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
index 2aa2bcfe431a..35a2fba7ca9d 100644
--- a/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
+++ b/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
@@ -29,8 +29,16 @@ def test_typedef(self):
 
 # First of all, check that we can get a typedefed type correctly in a 
simple case
 
-expr_result = frame.EvaluateExpression("(SF)s")
-self.assertTrue(expr_result.IsValid(), "Expression failed with: " + 
str(expr_result.GetError()))
+expr_result = self.expect_expr("(SF)s", 
result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ns::SF)s", 
result_children=[ValueCheck(value="0.5")])
+self.expect_expr("(ST::SF)s", 
result_children=[ValueCheck(value="0.5")])
+
+self.filecheck("image dump ast a.out", __file__, "--strict-whitespace")
+# CHECK:  {{^}}|-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}|-NamespaceDecl {{.*}} ns
+# CHECK-NEXT: {{^}}| `-TypedefDecl {{.*}} SF 'S'
+# CHECK:  {{^}}`-CXXRecordDecl {{.*}} struct ST definition
+# CHECK:  {{^}}  `-TypedefDecl {{.*}} SF 'S'
 
 typedef_type = expr_result.GetType();
 self.assertTrue(typedef_type.IsValid(), "Can't get `SF` type of 
evaluated expression")

diff  --git a/lldb/test/API/lang/cpp/typedef/main.cpp 
b/lldb/test/API/lang/cpp/typedef/main.cpp
index f1407b630a62..05757869ffec 100644
--- a/lldb/test/API/lang/cpp/typedef/main.cpp
+++ b/lldb/test/API/lang/cpp/typedef/main.cpp
@@ -7,7 +7,16 @@ struct S {
 
 typedef S SF;
 
+namespace ns {
+typedef S SF;
+}
+struct ST {
+  typedef S SF;
+};
+
 int main (int argc, char const *argv[]) {
   SF s{ .5 };
+  ns::SF in_ns;
+  ST::SF in_struct;
   return 0; // Set a breakpoint here
 }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9cc2f13 - [lldb] Clean up DW_AT_declaration-with-children.s test

2020-08-19 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-19T14:58:50+02:00
New Revision: 9cc2f13deeb30de3a2ce1854c36f6c0a8de86d6c

URL: 
https://github.com/llvm/llvm-project/commit/9cc2f13deeb30de3a2ce1854c36f6c0a8de86d6c
DIFF: 
https://github.com/llvm/llvm-project/commit/9cc2f13deeb30de3a2ce1854c36f6c0a8de86d6c.diff

LOG: [lldb] Clean up DW_AT_declaration-with-children.s test

Address some post-commit feedback on D85968.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s

Removed: 




diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s 
b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
index e00dc1961749..f17902918e38 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s
@@ -4,9 +4,8 @@
 
 # REQUIRES: x86
 
-# RUN: rm -rf %t
 # RUN: split-file %s %t
-# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj > %t.o
+# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o
 # RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
 # RUN:   -s %t/commands -o exit %t.o 2>&1 | FileCheck %s
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 9109311 - [lldb] Forcefully complete a type when adding typedefs

2020-08-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-20T15:19:10+02:00
New Revision: 9109311356cc9e74818dd7450020d9b85d2f8125

URL: 
https://github.com/llvm/llvm-project/commit/9109311356cc9e74818dd7450020d9b85d2f8125
DIFF: 
https://github.com/llvm/llvm-project/commit/9109311356cc9e74818dd7450020d9b85d2f8125.diff

LOG: [lldb] Forcefully complete a type when adding typedefs

This is very similar to D85968, only more elusive to since we were not
adding the typedef type to the relevant DeclContext until D86140, which
meant that the DeclContext was populated (and the relevant assertion
hit) only after importing the type into the expression ast in a
particular way.

I haven't checked whether this situation can be hit in the gmodules
case, but my money is on "yes".

Differential Revision: https://reviews.llvm.org/D86216

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_AT_declaration-with-children.s

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 486945ccbb8b..2fee87d98da8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -556,42 +556,51 @@ DWARFASTParserClang::ParseTypeModifier(const 
SymbolContext &sc,
   TypeSP type_sp;
   CompilerType clang_type;
 
-  if (tag == DW_TAG_typedef && attrs.type.IsValid()) {
-// Try to parse a typedef from the (DWARF embedded in the) Clang
-// module file first as modules can contain typedef'ed
-// structures that have no names like:
-//
-//  typedef struct { int a; } Foo;
-//
-// In this case we will have a structure with no name and a
-// typedef named "Foo" that points to this unnamed
-// structure. The name in the typedef is the only identifier for
-// the struct, so always try to get typedefs from Clang modules
-// if possible.
-//
-// The type_sp returned will be empty if the typedef doesn't
-// exist in a module file, so it is cheap to call this function
-// just to check.
-//
-// If we don't do this we end up creating a TypeSP that says
-// this is a typedef to type 0x123 (the DW_AT_type value would
-// be 0x123 in the DW_TAG_typedef), and this is the unnamed
-// structure type. We will have a hard time tracking down an
-// unnammed structure type in the module debug info, so we make
-// sure we don't get into this situation by always resolving
-// typedefs from the module.
-const DWARFDIE encoding_die = attrs.type.Reference();
-
-// First make sure that the die that this is typedef'ed to _is_
-// just a declaration (DW_AT_declaration == 1), not a full
-// definition since template types can't be represented in
-// modules since only concrete instances of templates are ever
-// emitted and modules won't contain those
-if (encoding_die &&
-encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) {
-  type_sp = ParseTypeFromClangModule(sc, die, log);
-  if (type_sp)
-return type_sp;
+  if (tag == DW_TAG_typedef) {
+// DeclContext will be populated when the clang type is materialized in
+// Type::ResolveCompilerType.
+PrepareContextToReceiveMembers(
+m_ast, GetClangASTImporter(),
+GetClangDeclContextContainingDIE(die, nullptr), die,
+attrs.name.GetCString());
+
+if (attrs.type.IsValid()) {
+  // Try to parse a typedef from the (DWARF embedded in the) Clang
+  // module file first as modules can contain typedef'ed
+  // structures that have no names like:
+  //
+  //  typedef struct { int a; } Foo;
+  //
+  // In this case we will have a structure with no name and a
+  // typedef named "Foo" that points to this unnamed
+  // structure. The name in the typedef is the only identifier for
+  // the struct, so always try to get typedefs from Clang modules
+  // if possible.
+  //
+  // The type_sp returned will be empty if the typedef doesn't
+  // exist in a module file, so it is cheap to call this function
+  // just to check.
+  //
+  // If we don't do this we end up creating a TypeSP that says
+  // this is a typedef to type 0x123 (the DW_AT_type value would
+  // be 0x123 in the DW_TAG_typedef), and this is the unnamed
+  // structure type. We will have a hard time tracking down an
+  // unnammed structure type in the module debug info, so we make
+  // sure we don't get into this situation by always resolving
+  // typedefs from the module.
+  const DWARFDIE encoding_die = attrs.type.Reference();
+
+  // First make sure that the die that this is typedef'ed to _is_
+  // just a declaration (DW_AT_declaration == 1), not a full
+  

[Lldb-commits] [lldb] 8a8a2dd - [lldb/Utility] Simplify Scalar handling of float types

2020-08-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-20T16:26:02+02:00
New Revision: 8a8a2dd3165e63b29e725526745427c6434f0654

URL: 
https://github.com/llvm/llvm-project/commit/8a8a2dd3165e63b29e725526745427c6434f0654
DIFF: 
https://github.com/llvm/llvm-project/commit/8a8a2dd3165e63b29e725526745427c6434f0654.diff

LOG: [lldb/Utility] Simplify Scalar handling of float types

Similarly to D85836, collapse all Scalar float types to a single enum
value, and use APFloat semantics to differentiate between. This
simplifies the code, and opens to door to supporting other floating
point semantics (which would be needed for fully supporting
architectures with more interesting float types such as PPC).

Differential Revision: https://reviews.llvm.org/D86220

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index d1e0fdd888df..4e0505e669dd 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -45,8 +45,6 @@ class Scalar {
 e_sint,
 e_uint,
 e_float,
-e_double,
-e_long_double
   };
 
   // Constructors and Destructors
@@ -70,8 +68,8 @@ class Scalar {
   : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
 m_float(0.0f) {}
   Scalar(float v) : m_type(e_float), m_float(v) {}
-  Scalar(double v) : m_type(e_double), m_float(v) {}
-  Scalar(long double v) : m_type(e_long_double), m_float(double(v)) {
+  Scalar(double v) : m_type(e_float), m_float(v) {}
+  Scalar(long double v) : m_type(e_float), m_float(double(v)) {
 bool ignore;
 m_float.convert(llvm::APFloat::x87DoubleExtended(),
 llvm::APFloat::rmNearestTiesToEven, &ignore);
@@ -114,15 +112,13 @@ class Scalar {
 
   void GetValue(Stream *s, bool show_type) const;
 
-  bool IsValid() const {
-return (m_type >= e_sint) && (m_type <= e_long_double);
-  }
+  bool IsValid() const { return (m_type >= e_sint) && (m_type <= e_float); }
 
   /// Convert to an integer with \p bits and the given signedness.
   void TruncOrExtendTo(uint16_t bits, bool sign);
 
   bool IntegralPromote(uint16_t bits, bool sign);
-  bool FloatPromote(Scalar::Type type);
+  bool FloatPromote(const llvm::fltSemantics &semantics);
 
   bool MakeSigned();
 
@@ -136,8 +132,6 @@ class Scalar {
   static Scalar::Type
   GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size);
 
-  static Scalar::Type GetValueTypeForFloatWithByteSize(size_t byte_size);
-
   // All operators can benefits from the implicit conversions that will happen
   // automagically by the compiler, so no temporary objects will need to be
   // created. As a result, we currently don't need a variety of overloaded set
@@ -257,8 +251,13 @@ class Scalar {
 
   static Type PromoteToMaxType(Scalar &lhs, Scalar &rhs);
 
-  using IntPromotionKey = std::pair;
-  IntPromotionKey GetIntKey() const;
+  enum class Category { Void, Integral, Float };
+  static Category GetCategory(Scalar::Type type);
+
+  using PromotionKey = std::tuple;
+  PromotionKey GetPromoKey() const;
+
+  static PromotionKey GetFloatPromoKey(const llvm::fltSemantics &semantics);
 
 private:
   friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 32082b50eaa8..1a27808068d6 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -26,17 +26,11 @@ using namespace lldb_private;
 using llvm::APFloat;
 using llvm::APInt;
 
-namespace {
-enum class Category { Void, Integral, Float };
-}
-
-static Category GetCategory(Scalar::Type type) {
+Scalar::Category Scalar::GetCategory(Scalar::Type type) {
   switch (type) {
   case Scalar::e_void:
 return Category::Void;
   case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
 return Category::Float;
   case Scalar::e_sint:
   case Scalar::e_uint:
@@ -52,49 +46,62 @@ static bool IsSigned(Scalar::Type type) {
 return false;
   case Scalar::e_sint:
   case Scalar::e_float:
-  case Scalar::e_double:
-  case Scalar::e_long_double:
 return true;
   }
   llvm_unreachable("Unhandled type!");
 }
 
-Scalar::IntPromotionKey Scalar::GetIntKey() const {
-  assert(GetCategory(GetType()) == Category::Integral);
-  return {m_integer.getBitWidth(), !IsSigned(m_type)};
+Scalar::PromotionKey Scalar::GetPromoKey() const {
+  Category cat = GetCategory(m_type);
+  switch (cat) {
+  case Category::Void:
+return {cat, 0, false};
+  case Category::Integral:
+return {cat, m_integer.getBitWidth(), !IsSigned(m_type)};
+  case Category::Float:
+return GetFloatPromoKey(m_float.getSemantics());
+  }
+  llvm_unreachable("Unhandled category!");
+}
+
+Scalar::PromotionKey Scalar::GetFloatPromoKey(const llvm::fltSemantics &sem)

[Lldb-commits] [lldb] 0e301fd - [lldb/Utility] Remove some Scalar type accessors

2020-08-24 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-24T11:45:30+02:00
New Revision: 0e301fd02386e01ca93a28e8c0484447fbb440a1

URL: 
https://github.com/llvm/llvm-project/commit/0e301fd02386e01ca93a28e8c0484447fbb440a1
DIFF: 
https://github.com/llvm/llvm-project/commit/0e301fd02386e01ca93a28e8c0484447fbb440a1.diff

LOG: [lldb/Utility] Remove some Scalar type accessors

Now that the number of Scalar "types" has been reduced, these don't make
sense anymore.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 4e0505e669dd..9d3a20c93898 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -75,11 +75,7 @@ class Scalar {
 llvm::APFloat::rmNearestTiesToEven, &ignore);
   }
   Scalar(llvm::APInt v)
-  : m_type(GetBestTypeForBitSize(v.getBitWidth(), true)),
-m_integer(std::move(v)), m_float(0.0f) {}
-
-  /// Return the most efficient Scalar::Type for the requested bit size.
-  static Type GetBestTypeForBitSize(size_t bit_size, bool sign);
+  : m_type(e_sint), m_integer(std::move(v)), m_float(0.0f) {}
 
   bool SignExtend(uint32_t bit_pos);
 
@@ -126,12 +122,6 @@ class Scalar {
 
   static const char *GetValueTypeAsCString(Scalar::Type value_type);
 
-  static Scalar::Type
-  GetValueTypeForSignedIntegerWithByteSize(size_t byte_size);
-
-  static Scalar::Type
-  GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size);
-
   // All operators can benefits from the implicit conversions that will happen
   // automagically by the compiler, so no temporary objects will need to be
   // created. As a result, we currently don't need a variety of overloaded set

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 1a27808068d6..e5a1454561f2 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -197,13 +197,9 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
   }
 }
 
-Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {
-  return sign ? e_sint : e_uint;
-}
-
 void Scalar::TruncOrExtendTo(uint16_t bits, bool sign) {
   m_integer = sign ? m_integer.sextOrTrunc(bits) : m_integer.zextOrTrunc(bits);
-  m_type = GetBestTypeForBitSize(bits, sign);
+  m_type = sign ? e_sint : e_uint;
 }
 
 bool Scalar::IntegralPromote(uint16_t bits, bool sign) {
@@ -262,16 +258,6 @@ const char *Scalar::GetValueTypeAsCString(Scalar::Type 
type) {
   return "???";
 }
 
-Scalar::Type
-Scalar::GetValueTypeForSignedIntegerWithByteSize(size_t byte_size) {
-  return e_sint;
-}
-
-Scalar::Type
-Scalar::GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size) {
-  return e_uint;
-}
-
 bool Scalar::MakeSigned() {
   bool success = false;
 
@@ -768,12 +754,7 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
   case lldb::eEncodingSint: {
 if (data.GetByteSize() < byte_size)
   return Status("insufficient data");
-Type type = GetBestTypeForBitSize(byte_size*8, encoding == 
lldb::eEncodingSint);
-if (type == e_void) {
-  return Status("unsupported integer byte size: %" PRIu64 "",
-static_cast(byte_size));
-}
-m_type = type;
+m_type = encoding == lldb::eEncodingSint ? e_sint : e_uint;
 if (data.GetByteOrder() == endian::InlHostByteOrder()) {
   m_integer = APInt::getNullValue(8 * byte_size);
   llvm::LoadIntFromMemory(m_integer, data.GetDataStart(), byte_size);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8298230 - [lldb/DWARF] More DW_AT_const_value fixes

2020-08-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-26T13:17:26+02:00
New Revision: 82982304d7095891b10faacdbf9b4eb73e92a92f

URL: 
https://github.com/llvm/llvm-project/commit/82982304d7095891b10faacdbf9b4eb73e92a92f
DIFF: 
https://github.com/llvm/llvm-project/commit/82982304d7095891b10faacdbf9b4eb73e92a92f.diff

LOG: [lldb/DWARF] More DW_AT_const_value fixes

This fixes several issues in handling of DW_AT_const_value attributes:
- the first is that the size of the data given by data forms does not
  need to match the size of the underlying variable. We already had the
  case to handle this for DW_FORM_(us)data -- this extends the handling
  to other data forms. The main reason this was not picked up is because
  clang uses leb forms in these cases while gcc prefers the fixed-size
  ones.
- The handling of DW_AT_strp form was completely broken -- we would end
  up using the pointer value as the result. I've reorganized this code
  so that it handles all string forms uniformly.
- In case of a completely bogus form we would crash due to
  strlen(nullptr).

Depends on D86311.

Differential Revision: https://reviews.llvm.org/D86348

Added: 
lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value-bitfields.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5ce392a57e0c..500d7567536e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3169,44 +3169,18 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
 DataExtractor(debug_info_data, block_offset, block_length),
 die.GetCU());
   } else if (DWARFFormValue::IsDataForm(form_value.Form())) {
-// Retrieve the value as a data expression.
-uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
-if (auto data_length = form_value.GetFixedSize())
-  location = DWARFExpression(
-  module,
-  DataExtractor(debug_info_data, data_offset, 
*data_length),
-  die.GetCU());
-else {
-  const uint8_t *data_pointer = form_value.BlockData();
-  if (data_pointer) {
-form_value.Unsigned();
-  } else if (DWARFFormValue::IsDataForm(form_value.Form())) {
-// we need to get the byte size of the type later after we
-// create the variable
-const_value = form_value;
-  }
-}
-  } else {
-// Retrieve the value as a string expression.
-if (form_value.Form() == DW_FORM_strp) {
-  uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
-  if (auto data_length = form_value.GetFixedSize())
-location = DWARFExpression(module,
-   DataExtractor(debug_info_data,
- data_offset,
- *data_length),
-   die.GetCU());
-} else {
-  const char *str = form_value.AsCString();
-  uint32_t string_offset =
-  str - (const char *)debug_info_data.GetDataStart();
-  uint32_t string_length = strlen(str) + 1;
-  location = DWARFExpression(module,
- DataExtractor(debug_info_data,
-   string_offset,
-   string_length),
- die.GetCU());
-}
+// Constant value size does not have to match the size of the
+// variable. We will fetch the size of the type after we create
+// it.
+const_value = form_value;
+  } else if (const char *str = form_value.AsCString()) {
+uint32_t string_length = strlen(str) + 1;
+location = DWARFExpression(
+module,
+DataExtractor(str, string_length,
+  die.GetCU()->GetByteOrder(),
+  die.GetCU()->GetAddressByteSize()),
+die.GetCU());
   }
 }
 break;

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value-bitfields.s 
b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value-bitfields

[Lldb-commits] [lldb] 219ccdf - [lldb/Utility] Use APSInt in the Scalar class

2020-08-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-27T15:05:47+02:00
New Revision: 219ccdfddecb963971ad14b5c14220b896d2c2e7

URL: 
https://github.com/llvm/llvm-project/commit/219ccdfddecb963971ad14b5c14220b896d2c2e7
DIFF: 
https://github.com/llvm/llvm-project/commit/219ccdfddecb963971ad14b5c14220b896d2c2e7.diff

LOG: [lldb/Utility] Use APSInt in the Scalar class

This enables us to further simplify some code because it no longer needs
to switch on the signedness of the type (APSInt handles that).

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 9d3a20c93898..332bb00489d0 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -14,7 +14,7 @@
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
 #include 
 #include 
 #include 
@@ -38,35 +38,35 @@ namespace lldb_private {
 // and values before performing these operations. Type promotion currently
 // follows the ANSI C type promotion rules.
 class Scalar {
+  template
+  static llvm::APSInt MakeAPSInt(T v) {
+static_assert(std::is_integral::value, "");
+static_assert(sizeof(T) <= sizeof(uint64_t), "Conversion loses 
precision!");
+return llvm::APSInt(
+llvm::APInt(sizeof(T) * 8, uint64_t(v), std::is_signed::value),
+std::is_unsigned::value);
+  }
+
 public:
   // FIXME: These are host types which seems to be an odd choice.
   enum Type {
 e_void = 0,
-e_sint,
-e_uint,
+e_int,
 e_float,
   };
 
   // Constructors and Destructors
   Scalar() : m_type(e_void), m_float(0.0f) {}
-  Scalar(int v)
-  : m_type(e_sint), m_integer(sizeof(v) * 8, uint64_t(v), true),
-m_float(0.0f) {}
+  Scalar(int v) : m_type(e_int), m_integer(MakeAPSInt(v)), m_float(0.0f) {}
   Scalar(unsigned int v)
-  : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
-m_float(0.0f) {}
-  Scalar(long v)
-  : m_type(e_sint), m_integer(sizeof(v) * 8, uint64_t(v), true),
-m_float(0.0f) {}
+  : m_type(e_int), m_integer(MakeAPSInt(v)), m_float(0.0f) {}
+  Scalar(long v) : m_type(e_int), m_integer(MakeAPSInt(v)), m_float(0.0f) {}
   Scalar(unsigned long v)
-  : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
-m_float(0.0f) {}
+  : m_type(e_int), m_integer(MakeAPSInt(v)), m_float(0.0f) {}
   Scalar(long long v)
-  : m_type(e_sint), m_integer(sizeof(v) * 8, uint64_t(v), true),
-m_float(0.0f) {}
+  : m_type(e_int), m_integer(MakeAPSInt(v)), m_float(0.0f) {}
   Scalar(unsigned long long v)
-  : m_type(e_uint), m_integer(sizeof(v) * 8, uint64_t(v), false),
-m_float(0.0f) {}
+  : m_type(e_int), m_integer(MakeAPSInt(v)), m_float(0.0f) {}
   Scalar(float v) : m_type(e_float), m_float(v) {}
   Scalar(double v) : m_type(e_float), m_float(v) {}
   Scalar(long double v) : m_type(e_float), m_float(double(v)) {
@@ -75,7 +75,7 @@ class Scalar {
 llvm::APFloat::rmNearestTiesToEven, &ignore);
   }
   Scalar(llvm::APInt v)
-  : m_type(e_sint), m_integer(std::move(v)), m_float(0.0f) {}
+  : m_type(e_int), m_integer(std::move(v), false), m_float(0.0f) {}
 
   bool SignExtend(uint32_t bit_pos);
 
@@ -108,7 +108,7 @@ class Scalar {
 
   void GetValue(Stream *s, bool show_type) const;
 
-  bool IsValid() const { return (m_type >= e_sint) && (m_type <= e_float); }
+  bool IsValid() const { return (m_type >= e_int) && (m_type <= e_float); }
 
   /// Convert to an integer with \p bits and the given signedness.
   void TruncOrExtendTo(uint16_t bits, bool sign);
@@ -116,6 +116,7 @@ class Scalar {
   bool IntegralPromote(uint16_t bits, bool sign);
   bool FloatPromote(const llvm::fltSemantics &semantics);
 
+  bool IsSigned() const;
   bool MakeSigned();
 
   bool MakeUnsigned();
@@ -234,7 +235,7 @@ class Scalar {
 
   // Classes that inherit from Scalar can see and modify these
   Scalar::Type m_type;
-  llvm::APInt m_integer;
+  llvm::APSInt m_integer;
   llvm::APFloat m_float;
 
   template  T GetAs(T fail_value) const;

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 3249ba5a02e3..3dd2813b5eb0 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -25,6 +25,7 @@ using namespace lldb_private;
 
 using llvm::APFloat;
 using llvm::APInt;
+using llvm::APSInt;
 
 Scalar::Category Scalar::GetCategory(Scalar::Type type) {
   switch (type) {
@@ -32,32 +33,19 @@ Scalar::Category Scalar::GetCategory(Scalar::Type type) {
 return Category::Void;
   case Scalar::e_float:
 return Category::Float;
-  case Scalar::e_sint:
-  case Scalar::e_uint:
+  case Scalar::e_int:
 retu

[Lldb-commits] [lldb] 9f5927e - [lldb/DWARF] Fix handling of variables with both location and const_value attributes

2020-08-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-27T15:05:47+02:00
New Revision: 9f5927e42bf4a7448dc9dd3a1550d1126c595dad

URL: 
https://github.com/llvm/llvm-project/commit/9f5927e42bf4a7448dc9dd3a1550d1126c595dad
DIFF: 
https://github.com/llvm/llvm-project/commit/9f5927e42bf4a7448dc9dd3a1550d1126c595dad.diff

LOG: [lldb/DWARF] Fix handling of variables with both location and const_value 
attributes

Class-level static constexpr variables can have both DW_AT_const_value
(in the "declaration") and a DW_AT_location (in the "definition")
attributes. Our code was trying to handle this, but it was brittle and
hard to follow (and broken) because it was processing the attributes in
the order in which they were found.

Refactor the code to make the intent clearer -- DW_AT_location trumps
DW_AT_const_value, and fix the bug which meant that we were not
displaying these variables properly (the culprit was the delayed parsing
of the const_value attribute due to a need to fetch the variable type.

Differential Revision: https://reviews.llvm.org/D86615

Added: 
lldb/test/Shell/SymbolFile/DWARF/DW_AT_location-DW_AT_const_value.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
index b401352c693d..fe6a55520978 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -42,6 +42,7 @@ class DWARFFormValue {
   DWARFFormValue(const DWARFUnit *unit) : m_unit(unit) {}
   DWARFFormValue(const DWARFUnit *unit, dw_form_t form)
   : m_unit(unit), m_form(form) {}
+  const DWARFUnit *GetUnit() const { return m_unit; }
   void SetUnit(const DWARFUnit *unit) { m_unit = unit; }
   dw_form_t Form() const { return m_form; }
   dw_form_t& FormRef() { return m_form; }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 500d7567536e..271821b24517 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3111,18 +3111,15 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
   const char *name = nullptr;
   const char *mangled = nullptr;
   Declaration decl;
-  uint32_t i;
   DWARFFormValue type_die_form;
   DWARFExpression location;
   bool is_external = false;
   bool is_artificial = false;
-  bool location_is_const_value_data = false;
-  bool has_explicit_location = false;
-  DWARFFormValue const_value;
+  DWARFFormValue const_value_form, location_form;
   Variable::RangeList scope_ranges;
   // AccessType accessibility = eAccessNone;
 
-  for (i = 0; i < num_attributes; ++i) {
+  for (size_t i = 0; i < num_attributes; ++i) {
 dw_attr_t attr = attributes.AttributeAtIndex(i);
 DWARFFormValue form_value;
 
@@ -3152,65 +3149,11 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
 is_external = form_value.Boolean();
 break;
   case DW_AT_const_value:
-// If we have already found a DW_AT_location attribute, ignore this
-// attribute.
-if (!has_explicit_location) {
-  location_is_const_value_data = true;
-  // The constant value will be either a block, a data value or a
-  // string.
-  auto debug_info_data = die.GetData();
-  if (DWARFFormValue::IsBlockForm(form_value.Form())) {
-// Retrieve the value as a block expression.
-uint32_t block_offset =
-form_value.BlockData() - debug_info_data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
-location = DWARFExpression(
-module,
-DataExtractor(debug_info_data, block_offset, block_length),
-die.GetCU());
-  } else if (DWARFFormValue::IsDataForm(form_value.Form())) {
-// Constant value size does not have to match the size of the
-// variable. We will fetch the size of the type after we create
-// it.
-const_value = form_value;
-  } else if (const char *str = form_value.AsCString()) {
-uint32_t string_length = strlen(str) + 1;
-location = DWARFExpression(
-module,
-DataExtractor(str, string_length,
-  die.GetCU()->GetByteOrder(),
-  die.GetCU()->GetAddressByteSize()),
-die.GetCU());
-  }
-}
+const_

[Lldb-commits] [lldb] 9cb222e - [cmake] Make gtest include directories a part of the library interface

2020-08-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-27T15:35:57+02:00
New Revision: 9cb222e749e8392517a138cf6645a7c220d671c8

URL: 
https://github.com/llvm/llvm-project/commit/9cb222e749e8392517a138cf6645a7c220d671c8
DIFF: 
https://github.com/llvm/llvm-project/commit/9cb222e749e8392517a138cf6645a7c220d671c8.diff

LOG: [cmake] Make gtest include directories a part of the library interface

This applies the same fix that D84748 did for macro definitions.
Appropriate include path is now automatically set for all libraries
which link against gtest targets, which avoids the need to set
include_directories in various parts of the project.

Differential Revision: https://reviews.llvm.org/D86616

Added: 


Modified: 
flang/CMakeLists.txt
libc/benchmarks/CMakeLists.txt
lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/Testing/Support/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt
polly/CMakeLists.txt

Removed: 




diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 73c2db55e8f8..03440b72ec8c 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -135,13 +135,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   if (FLANG_INCLUDE_TESTS)
 set(UNITTEST_DIR ${LLVM_BUILD_MAIN_SRC_DIR}/utils/unittest)
 if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
-  if (TARGET gtest)
-# LLVM Doesn't export gtest's include directorys, so do that here
-set_target_properties(gtest
-  PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
-  
"${UNITTEST_DIR}/googletest/include;${UNITTEST_DIR}/googlemock/include"
-  )
-  else()
+  if (NOT TARGET gtest)
 add_library(gtest
   ${UNITTEST_DIR}/googletest/src/gtest-all.cc
   ${UNITTEST_DIR}/googlemock/src/gmock-all.cc

diff  --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index 6f3cfdb64a5f..2275dad7f653 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -53,11 +53,6 @@ function(add_libc_benchmark_unittest target_name)
 EXCLUDE_FROM_ALL
 ${LIBC_BENCHMARKS_UNITTEST_SRCS}
   )
-  target_include_directories(${target_name}
-PRIVATE
-${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include
-${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include
-  )
   target_link_libraries(${target_name}
 PRIVATE
 gtest_main

diff  --git a/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt 
b/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
index 3faec7c8030b..38a518682853 100644
--- a/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
@@ -2,7 +2,3 @@ set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
 add_lldb_library(lldbSymbolHelpers
   YAMLModuleTester.cpp
   )
-
-target_include_directories(lldbSymbolHelpers PUBLIC
-  ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include
-  ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 1689d36171c3..a40cf17426fe 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1401,9 +1401,6 @@ function(add_unittest test_suite test_name)
 set(EXCLUDE_FROM_ALL ON)
   endif()
 
-  include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
-  include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
-
   if (SUPPORTS_VARIADIC_MACROS_FLAG)
 list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
   endif ()

diff  --git a/llvm/lib/Testing/Support/CMakeLists.txt 
b/llvm/lib/Testing/Support/CMakeLists.txt
index 4f5345c1dc57..ed2fd8ae43b2 100644
--- a/llvm/lib/Testing/Support/CMakeLists.txt
+++ b/llvm/lib/Testing/Support/CMakeLists.txt
@@ -12,6 +12,4 @@ add_llvm_library(LLVMTestingSupport
   Support
   )
 
-include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
-include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
 target_link_libraries(LLVMTestingSupport PRIVATE gtest)

diff  --git a/llvm/utils/unittest/CMakeLists.txt 
b/llvm/utils/unittest/CMakeLists.txt
index 14c780342b60..43c8fafdfc4c 100644
--- a/llvm/utils/unittest/CMakeLists.txt
+++ b/llvm/utils/unittest/CMakeLists.txt
@@ -11,14 +11,6 @@
 #
 # Project-wide settings
 
-# Where gtest's .h files can be found.
-include_directories(
-  googletest/include
-  googletest
-  googlemock/include
-  googlemock
-  )
-
 if(WIN32)
   add_definitions(-DGTEST_OS_WINDOWS=1)
 endif()
@@ -76,6 +68,11 @@ if (NOT LLVM_ENABLE_THREADS)
   target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
 endif ()
 
+target_include_directories(gtest
+  PUBLIC googletest/include googlemock/include
+  PRIVATE googletest googlemock
+  )
+
 add_subdirectory(UnitTestMain)
 
 # When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface

di

[Lldb-commits] [lldb] 0de1463 - [lldb] Fix Type::GetByteSize for pointer types

2020-08-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-27T15:37:49+02:00
New Revision: 0de1463373918ae424cdcfeaa5b318f45c528696

URL: 
https://github.com/llvm/llvm-project/commit/0de1463373918ae424cdcfeaa5b318f45c528696
DIFF: 
https://github.com/llvm/llvm-project/commit/0de1463373918ae424cdcfeaa5b318f45c528696.diff

LOG: [lldb] Fix Type::GetByteSize for pointer types

The function was returning an incorrect (empty) value on the first
invocation. Given that this only affected the first invocation, this
bug/typo went mostly unaffected. DW_AT_const_value were particularly
badly affected by this as the GetByteSize call is
SymbolFileDWARF::ParseVariableDIE is likely to be the first call of this
function, and its effects cannot be undone by retrying.

Depends on D86348.

Differential Revision: https://reviews.llvm.org/D86436

Added: 


Modified: 
lldb/source/Symbol/Type.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s

Removed: 




diff  --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index ecf0575b9a57..378523d00896 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -375,6 +375,7 @@ llvm::Optional 
Type::GetByteSize(ExecutionContextScope *exe_scope) {
   if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) {
 m_byte_size = arch.GetAddressByteSize();
 m_byte_size_has_value = true;
+return m_byte_size;
   }
 } break;
   }

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s 
b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s
index 67c89b62339b..2275ff25ce97 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value.s
@@ -5,10 +5,10 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t \
-# RUN:   -o "target variable udata data1 data2 data4 data8 string strp ref4" \
+# RUN:   -o "target variable udata data1 data2 data4 data8 string strp ref4 
udata_ptr" \
 # RUN:   -o exit | FileCheck %s
 
-# CHECK-LABEL: target variable udata data1 data2 data4 data8 string strp ref4
+# CHECK-LABEL: target variable
 ## Variable specified via DW_FORM_udata. This is typical for clang (10).
 # CHECK: (unsigned long) udata = 4742474247424742
 ## Variables specified via fixed-size forms. This is typical for gcc (9).
@@ -22,6 +22,8 @@
 # CHECK: (char [7]) strp = "strp"
 ## Bogus attribute form. Let's make sure we don't crash at least.
 # CHECK: (char [7]) ref4 = 
+## A variable of pointer type.
+# CHECK: (unsigned long *) udata_ptr = 0xdeadbeefbaadf00d
 
 .section.debug_abbrev,"",@progbits
 .byte   1   # Abbreviation Code
@@ -33,6 +35,13 @@
 .byte   8   # DW_FORM_string
 .byte   0   # EOM(1)
 .byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   15  # DW_TAG_pointer_type
+.byte   0   # DW_CHILDREN_no
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
 .byte   4   # Abbreviation Code
 .byte   1   # DW_TAG_array_type
 .byte   1   # DW_CHILDREN_yes
@@ -109,6 +118,9 @@
 .asciz  "unsigned long" # DW_AT_name
 .byte   8   # DW_AT_byte_size
 .byte   7   # DW_AT_encoding
+.Lulong_ptr:
+.byte   2   # Abbrev DW_TAG_pointer_type
+.long   .Lulong-.Lcu_begin0 # DW_AT_type
 
 .byte   10  # Abbrev DW_TAG_variable
 .asciz  "udata" # DW_AT_name
@@ -150,6 +162,11 @@
 .long   .Lchar_arr-.Lcu_begin0  # DW_AT_type
 .long   .Lulong-.Lcu_begin0 # DW_AT_const_value
 
+.byte   10  # Abbrev DW_TAG_variable
+.asciz  "udata_ptr" # DW_AT_name
+.long   .Lulong_ptr-.Lcu_begin0 # DW_AT_type
+.uleb128 0xdeadbeefbaadf00d # DW_AT_const_value
+
 .byte   0   # End Of Children Mark
 .Ldebug_info_end0:
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5b2b754 - [lldb/cmake] Fix linking of lldbUtilityHelpers for 9cb222e74

2020-08-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-27T16:06:59+02:00
New Revision: 5b2b754565602a8b49b68967e1810f592f175d6b

URL: 
https://github.com/llvm/llvm-project/commit/5b2b754565602a8b49b68967e1810f592f175d6b
DIFF: 
https://github.com/llvm/llvm-project/commit/5b2b754565602a8b49b68967e1810f592f175d6b.diff

LOG: [lldb/cmake] Fix linking of lldbUtilityHelpers for 9cb222e74

Added: 


Modified: 
lldb/unittests/TestingSupport/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/TestingSupport/CMakeLists.txt 
b/lldb/unittests/TestingSupport/CMakeLists.txt
index 67ebe3242629..4599ada1ec50 100644
--- a/lldb/unittests/TestingSupport/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/CMakeLists.txt
@@ -6,6 +6,7 @@ add_lldb_library(lldbUtilityHelpers
   LINK_LIBS
 lldbUtility
 lldbSymbolHelpers
+gtest
 
   LINK_COMPONENTS
 Support



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] dd63506 - [lldb/cmake] Fix linking of lldbSymbolHelpers for 9cb222e7

2020-08-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-27T16:40:17+02:00
New Revision: dd635062d867835cfe893698161277cc251b4456

URL: 
https://github.com/llvm/llvm-project/commit/dd635062d867835cfe893698161277cc251b4456
DIFF: 
https://github.com/llvm/llvm-project/commit/dd635062d867835cfe893698161277cc251b4456.diff

LOG: [lldb/cmake] Fix linking of lldbSymbolHelpers for 9cb222e7

I didn't find this locally because I have a /usr/include/gtest which is
similar enough to the bundled one to make things appear to work.

Added: 


Modified: 
lldb/unittests/TestingSupport/Symbol/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt 
b/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
index 38a518682853d..cdd65ca17fed2 100644
--- a/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/Symbol/CMakeLists.txt
@@ -1,4 +1,15 @@
 set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL ON)
 add_lldb_library(lldbSymbolHelpers
   YAMLModuleTester.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbPluginExpressionParserClang
+lldbPluginSymbolFileDWARF
+lldbPluginTypeSystemClang
+lldbUtilityHelpers
+
+  LINK_COMPONENTS
+ObjectYAML
   )



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1f9595e - [lldb] Reduce intentation in SymbolFileDWARF::ParseVariableDIE

2020-08-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-28T11:44:03+02:00
New Revision: 1f9595ede48d694b8506d22fd71f7ce13e00dafa

URL: 
https://github.com/llvm/llvm-project/commit/1f9595ede48d694b8506d22fd71f7ce13e00dafa
DIFF: 
https://github.com/llvm/llvm-project/commit/1f9595ede48d694b8506d22fd71f7ce13e00dafa.diff

LOG: [lldb] Reduce intentation in SymbolFileDWARF::ParseVariableDIE

using early exits. NFC.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 271821b24517..9f4556f791ae 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3091,363 +3091,350 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
   if (die.GetDWARF() != this)
 return die.GetDWARF()->ParseVariableDIE(sc, die, func_low_pc);
 
-  VariableSP var_sp;
   if (!die)
-return var_sp;
+return nullptr;
 
-  var_sp = GetDIEToVariable()[die.GetDIE()];
-  if (var_sp)
+  if (VariableSP var_sp = GetDIEToVariable()[die.GetDIE()])
 return var_sp; // Already been parsed!
 
   const dw_tag_t tag = die.Tag();
   ModuleSP module = GetObjectFile()->GetModule();
 
-  if ((tag == DW_TAG_variable) || (tag == DW_TAG_constant) ||
-  (tag == DW_TAG_formal_parameter && sc.function)) {
-DWARFAttributes attributes;
-const size_t num_attributes = die.GetAttributes(attributes);
-DWARFDIE spec_die;
-if (num_attributes > 0) {
-  const char *name = nullptr;
-  const char *mangled = nullptr;
-  Declaration decl;
-  DWARFFormValue type_die_form;
-  DWARFExpression location;
-  bool is_external = false;
-  bool is_artificial = false;
-  DWARFFormValue const_value_form, location_form;
-  Variable::RangeList scope_ranges;
-  // AccessType accessibility = eAccessNone;
-
-  for (size_t i = 0; i < num_attributes; ++i) {
-dw_attr_t attr = attributes.AttributeAtIndex(i);
-DWARFFormValue form_value;
-
-if (attributes.ExtractFormValueAtIndex(i, form_value)) {
-  switch (attr) {
-  case DW_AT_decl_file:
-decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
-form_value.Unsigned()));
-break;
-  case DW_AT_decl_line:
-decl.SetLine(form_value.Unsigned());
-break;
-  case DW_AT_decl_column:
-decl.SetColumn(form_value.Unsigned());
-break;
-  case DW_AT_name:
-name = form_value.AsCString();
-break;
-  case DW_AT_linkage_name:
-  case DW_AT_MIPS_linkage_name:
-mangled = form_value.AsCString();
-break;
-  case DW_AT_type:
-type_die_form = form_value;
-break;
-  case DW_AT_external:
-is_external = form_value.Boolean();
-break;
-  case DW_AT_const_value:
-const_value_form = form_value;
-break;
-  case DW_AT_location:
-location_form = form_value;
-break;
-  case DW_AT_specification:
-spec_die = form_value.Reference();
-break;
-  case DW_AT_start_scope:
-// TODO: Implement this.
-break;
-  case DW_AT_artificial:
-is_artificial = form_value.Boolean();
-break;
-  case DW_AT_accessibility:
-break; // accessibility =
-   // DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-  case DW_AT_declaration:
-  case DW_AT_description:
-  case DW_AT_endianity:
-  case DW_AT_segment:
-  case DW_AT_visibility:
-  default:
-  case DW_AT_abstract_origin:
-  case DW_AT_sibling:
-break;
-  }
-}
-  }
+  if (tag != DW_TAG_variable && tag != DW_TAG_constant &&
+  (tag != DW_TAG_formal_parameter || !sc.function))
+return nullptr;
 
-  // Prefer DW_AT_location over DW_AT_const_value. Both can be emitted e.g.
-  // for static constexpr member variables -- DW_AT_const_value will be
-  // present in the class declaration and DW_AT_location in the DIE 
defining
-  // the member.
-  bool location_is_const_value_data = false;
-  bool has_explicit_location = false;
-  bool use_type_size_for_value = false;
-  if (location_form.IsValid()) {
-has_explicit_location = true;
-if (DWARFFormValue::IsBlockForm(location_form.Form())) {
-  const DWARFDataExtractor &data = die.GetData();
-
-  uint32_t block_offset =
-  location_form.BlockData() - data.GetDataStart();
-  uint32_t block_length = location_form.Unsigned();
-  locatio

[Lldb-commits] [lldb] 9b50546 - [lldb/Utility] Polish the Scalar class

2020-08-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-08-28T11:51:25+02:00
New Revision: 9b50546b0b4087ec2ee8479d68e70b89c7956aaa

URL: 
https://github.com/llvm/llvm-project/commit/9b50546b0b4087ec2ee8479d68e70b89c7956aaa
DIFF: 
https://github.com/llvm/llvm-project/commit/9b50546b0b4087ec2ee8479d68e70b89c7956aaa.diff

LOG: [lldb/Utility] Polish the Scalar class

This patch is mostly about removing the "Category" enum, which was
very useful when the Type enum contained a large number of types, but
now the two are completely identical.

It also removes some other artifacts like unused typedefs and macros.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index 332bb00489d0..7403fd1d9717 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -20,18 +20,12 @@
 #include 
 
 namespace lldb_private {
+
 class DataExtractor;
 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 {
 
 // A class designed to hold onto values and their corresponding types.
 // Operators are defined and Scalar objects will correctly promote their types
@@ -48,7 +42,6 @@ class Scalar {
   }
 
 public:
-  // FIXME: These are host types which seems to be an odd choice.
   enum Type {
 e_void = 0,
 e_int,
@@ -219,21 +212,6 @@ class Scalar {
   }
 
 protected:
-  typedef char schar_t;
-  typedef unsigned char uchar_t;
-  typedef short sshort_t;
-  typedef unsigned short ushort_t;
-  typedef int sint_t;
-  typedef unsigned int uint_t;
-  typedef long slong_t;
-  typedef unsigned long ulong_t;
-  typedef long long slonglong_t;
-  typedef unsigned long long ulonglong_t;
-  typedef float float_t;
-  typedef double double_t;
-  typedef long double long_double_t;
-
-  // Classes that inherit from Scalar can see and modify these
   Scalar::Type m_type;
   llvm::APSInt m_integer;
   llvm::APFloat m_float;
@@ -242,10 +220,7 @@ class Scalar {
 
   static Type PromoteToMaxType(Scalar &lhs, Scalar &rhs);
 
-  enum class Category { Void, Integral, Float };
-  static Category GetCategory(Scalar::Type type);
-
-  using PromotionKey = std::tuple;
+  using PromotionKey = std::tuple;
   PromotionKey GetPromoKey() const;
 
   static PromotionKey GetFloatPromoKey(const llvm::fltSemantics &semantics);

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index 3dd2813b5eb0..9bf633d0c4e0 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -27,26 +27,13 @@ using llvm::APFloat;
 using llvm::APInt;
 using llvm::APSInt;
 
-Scalar::Category Scalar::GetCategory(Scalar::Type type) {
-  switch (type) {
-  case Scalar::e_void:
-return Category::Void;
-  case Scalar::e_float:
-return Category::Float;
-  case Scalar::e_int:
-return Category::Integral;
-  }
-  llvm_unreachable("Unhandled type!");
-}
-
 Scalar::PromotionKey Scalar::GetPromoKey() const {
-  Category cat = GetCategory(m_type);
-  switch (cat) {
-  case Category::Void:
-return PromotionKey{cat, 0, false};
-  case Category::Integral:
-return PromotionKey{cat, m_integer.getBitWidth(), m_integer.isUnsigned()};
-  case Category::Float:
+  switch (m_type) {
+  case e_void:
+return PromotionKey{e_void, 0, false};
+  case e_int:
+return PromotionKey{e_int, m_integer.getBitWidth(), 
m_integer.isUnsigned()};
+  case e_float:
 return GetFloatPromoKey(m_float.getSemantics());
   }
   llvm_unreachable("Unhandled category!");
@@ -58,7 +45,7 @@ Scalar::PromotionKey Scalar::GetFloatPromoKey(const 
llvm::fltSemantics &sem) {
   &APFloat::x87DoubleExtended()};
   for (const auto &entry : llvm::enumerate(order)) {
 if (entry.value() == &sem)
-  return PromotionKey{Category::Float, entry.index(), false};
+  return PromotionKey{e_float, entry.index(), false};
   }
   llvm_unreachable("Unsupported semantics!");
 }
@@ -67,13 +54,13 @@ Scalar::PromotionKey Scalar::GetFloatPromoKey(const 
llvm::fltSemantics &sem) {
 // expressions.
 Scalar::Type Scalar::PromoteToMaxType(Scalar &lhs, Scalar &rhs) {
   const auto &Promote = [](Scalar &a, const Scalar &b) {
-switch (GetCategory(b.GetType())) {
-case Category::Void:
+switch (b.GetType()) {
+case e_void:
   break;
-case Category::Integral:
+case e_int:
   a.IntegralPromote(b.m_integer.getBitWidth(), b.m_integer.isSigned());
   break;
-case Category::Float:
+case e_float:
   a.FloatPromote(b.m_float.getSemantics());
 }
   };
@@ -129,13 +116,13 @@ void Scalar::GetBytes(llvm::MutableArrayRef 
storage) const {
   const auto &store = [&](const llvm::APInt &val) {
 StoreIntToMemory(val, s

Re: [Lldb-commits] [lldb] 0e86f39 - [lldb/test] Fix TestPlatform*.py Windows failures (NFC)

2020-09-03 Thread Pavel Labath via lldb-commits
On 02/09/2020 21:42, Med Ismail Bennani via lldb-commits wrote:
> +#if defined(_WIN32) || defined(_WIN64)

BTW, _WIN32 is also defined for 64 bit windows systems -- the macro
really means "_not_ win16" rather than what the name would imply.

pl
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] af3789a - [lldb] Improve qemu interop for aarch64

2020-09-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-09-15T13:32:08+02:00
New Revision: af3789a188116e400dd021bae54d91dc543aca7d

URL: 
https://github.com/llvm/llvm-project/commit/af3789a188116e400dd021bae54d91dc543aca7d
DIFF: 
https://github.com/llvm/llvm-project/commit/af3789a188116e400dd021bae54d91dc543aca7d.diff

LOG: [lldb] Improve qemu interop for aarch64

qemu calls the "fp" and "lr" registers via their generic names
(x29/x30). This mismatch manifested itself as not being able to unwind
or display values of some local variables.

Added: 
lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml

Modified: 
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/AArch64/ABIAArch64.h

Removed: 




diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 5cf9fb4ad37f..7cae4cc42750 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -33,6 +33,12 @@ ABIAArch64::GetEHAndDWARFNums(llvm::StringRef name) {
   return MCBasedABI::GetEHAndDWARFNums(name);
 }
 
+std::string ABIAArch64::GetMCName(std::string reg) {
+  MapRegisterName(reg, "v", "q");
+  MapRegisterName(reg, "x29", "fp");
+  MapRegisterName(reg, "x30", "lr");
+  return reg;
+}
 uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
   return llvm::StringSwitch(name)
   .Case("pc", LLDB_REGNUM_GENERIC_PC)

diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 981145e2017e..bdff648f1b52 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -20,10 +20,7 @@ class ABIAArch64: public lldb_private::MCBasedABI {
   std::pair
   GetEHAndDWARFNums(llvm::StringRef name) override;
 
-  std::string GetMCName(std::string reg) override {
-MapRegisterName(reg, "v", "q");
-return reg;
-  }
+  std::string GetMCName(std::string reg) override;
 
   uint32_t GetGenericNum(llvm::StringRef name) override;
 

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
new file mode 100644
index ..9368de7b055a
--- /dev/null
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/TestQemuAArch64TargetXml.py
@@ -0,0 +1,73 @@
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+from textwrap import dedent
+
+class MyResponder(MockGDBServerResponder):
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return dedent("""\
+
+  
+aarch64
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
+  
+"""), False
+else:
+return None, False
+
+class TestQemuAarch64TargetXml(GDBRemoteTestBase):
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+@skipIfLLVMTargetMissing("AArch64")
+def test_register_augmentation(self):
+"""
+Test that we correctly associate the register info with the eh_frame
+register numbers.
+"""
+
+target = self.createTarget("basic_eh_frame-aarch64.yaml")
+self.server.responder = MyResponder()
+
+process = self.connect(target)
+lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+[lldb.eStateStopped])
+self.filecheck("image show-unwind -n foo", __file__,
+"--check-prefix=UNWIND")
+# UNWIND: eh_frame UnwindPlan:
+# UNWIND: row[0]:0: CFA=x29+16 => x30=[CFA-8]

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml 
b/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml
new file mode 100644
index ..acc66082495e
--- /dev/null
+++ 
b/lldb/test/API/functionalities/gdb_remote_client/basic_eh_frame-aarch64.yaml
@@ -0,0 +1,25 @@
+--- !ELF
+FileHea

[Lldb-commits] [lldb] 0a2213c - [lldb/cmake] Fix testing support library dependencies

2020-09-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-09-15T13:32:08+02:00
New Revision: 0a2213c6eb24c9deec738e30509815e5bddd860c

URL: 
https://github.com/llvm/llvm-project/commit/0a2213c6eb24c9deec738e30509815e5bddd860c
DIFF: 
https://github.com/llvm/llvm-project/commit/0a2213c6eb24c9deec738e30509815e5bddd860c.diff

LOG: [lldb/cmake] Fix testing support library dependencies

lldbUtilityHelpers does not depend on lldbSymbolHelpers. Remove that
dependency, and add direct lldbSymbolHelpers dependencies where needed.

Added: 


Modified: 
lldb/unittests/Expression/CMakeLists.txt
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
lldb/unittests/TestingSupport/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/Expression/CMakeLists.txt 
b/lldb/unittests/Expression/CMakeLists.txt
index 2f5304ab212d..0e8230d19bad 100644
--- a/lldb/unittests/Expression/CMakeLists.txt
+++ b/lldb/unittests/Expression/CMakeLists.txt
@@ -11,5 +11,6 @@ add_lldb_unittest(ExpressionTests
 lldbPluginTypeSystemClang
 lldbUtility
 lldbUtilityHelpers
+lldbSymbolHelpers
 LLVMTestingSupport
   )

diff  --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt 
b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index 64a7b78c478a..30620a61dc5f 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -11,8 +11,9 @@ add_lldb_unittest(SymbolFileDWARFTests
 lldbPluginSymbolFileDWARF
 lldbPluginSymbolFilePDB
 lldbPluginTypeSystemClang
-lldbUtilityHelpers
 lldbPluginPlatformMacOSX
+lldbUtilityHelpers
+lldbSymbolHelpers
   LINK_COMPONENTS
 Support
 DebugInfoPDB

diff  --git a/lldb/unittests/TestingSupport/CMakeLists.txt 
b/lldb/unittests/TestingSupport/CMakeLists.txt
index 4599ada1ec50..c62bc3b023b7 100644
--- a/lldb/unittests/TestingSupport/CMakeLists.txt
+++ b/lldb/unittests/TestingSupport/CMakeLists.txt
@@ -5,7 +5,6 @@ add_lldb_library(lldbUtilityHelpers
 
   LINK_LIBS
 lldbUtility
-lldbSymbolHelpers
 gtest
 
   LINK_COMPONENTS



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] beb768f - [lldb] Clean up Platform/CMakeLists.txt

2021-09-10 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-10T14:18:41+02:00
New Revision: beb768f40b47e23e05766738edc0e7723e2f98d4

URL: 
https://github.com/llvm/llvm-project/commit/beb768f40b47e23e05766738edc0e7723e2f98d4
DIFF: 
https://github.com/llvm/llvm-project/commit/beb768f40b47e23e05766738edc0e7723e2f98d4.diff

LOG: [lldb] Clean up Platform/CMakeLists.txt

Remove comments looking like preprocessor directives (thankfully cmake
does not have those yet), and sort the file.

Added: 


Modified: 
lldb/source/Plugins/Platform/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Plugins/Platform/CMakeLists.txt 
b/lldb/source/Plugins/Platform/CMakeLists.txt
index 5f284e517dcac..7d1e095311cbd 100644
--- a/lldb/source/Plugins/Platform/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/CMakeLists.txt
@@ -1,17 +1,9 @@
-#if (CMAKE_SYSTEM_NAME MATCHES "Linux")
-  add_subdirectory(Linux)
-#elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-  add_subdirectory(FreeBSD)
-#elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
-  add_subdirectory(NetBSD)
-#elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
-  add_subdirectory(OpenBSD)
-#elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  add_subdirectory(MacOSX)
-#elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
-  add_subdirectory(Windows)
-#endif()
-
-add_subdirectory(POSIX)
-add_subdirectory(gdb-server)
 add_subdirectory(Android)
+add_subdirectory(FreeBSD)
+add_subdirectory(gdb-server)
+add_subdirectory(Linux)
+add_subdirectory(MacOSX)
+add_subdirectory(NetBSD)
+add_subdirectory(OpenBSD)
+add_subdirectory(POSIX)
+add_subdirectory(Windows)



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c82dbc2 - [lldb] Skip TestGuiBasicDebug due to pr51833

2021-09-13 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-13T15:11:28+02:00
New Revision: c82dbc2924bd37fc497cdfe581a21810aace608d

URL: 
https://github.com/llvm/llvm-project/commit/c82dbc2924bd37fc497cdfe581a21810aace608d
DIFF: 
https://github.com/llvm/llvm-project/commit/c82dbc2924bd37fc497cdfe581a21810aace608d.diff

LOG: [lldb] Skip TestGuiBasicDebug due to pr51833

Added: 


Modified: 
lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py

Removed: 




diff  --git a/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py 
b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
index e0eca428b6bd2..a7df72509d58f 100644
--- a/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
+++ b/lldb/test/API/commands/gui/basicdebug/TestGuiBasicDebug.py
@@ -14,7 +14,7 @@ class TestGuiBasicDebugCommandTest(PExpectTest):
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
-@skipIf(oslist=["linux"], archs=["arm","aarch64"])
+@skipIf(bugnumber="llvm.org/pr51833")
 @skipIfCursesSupportMissing
 def test_gui(self):
 self.build()



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f22c63b - [lldb/test] Start pexpect tests with a custom HOME

2021-09-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-14T15:17:10+02:00
New Revision: f22c63b41bda01163a88b0bb9887a9324810732f

URL: 
https://github.com/llvm/llvm-project/commit/f22c63b41bda01163a88b0bb9887a9324810732f
DIFF: 
https://github.com/llvm/llvm-project/commit/f22c63b41bda01163a88b0bb9887a9324810732f.diff

LOG: [lldb/test] Start pexpect tests with a custom HOME

This addresses the flakyness of (at least) TestMultilineNavigation,
which was failing when the editline history of a concurrently executing
test made leaked in. Using a test-specific home directory ensures the
tests are independent.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbpexpect.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py 
b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
index f7c0e490105af..d3e3e8dde5d84 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -36,7 +36,8 @@ def launch(self, executable=None, extra_args=None, 
timeout=60, dimensions=None):
 args.extend(extra_args)
 
 env = dict(os.environ)
-env["TERM"]="vt100"
+env["TERM"] = "vt100"
+env["HOME"] = self.getBuildDir()
 
 import pexpect
 self.child = pexpect.spawn(



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bd590a5 - [lldb] Make Platform::DebugProcess take a Target reference

2021-09-16 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-16T11:33:47+02:00
New Revision: bd590a5f895f50ceb7669de1b4a69bbcc8adb38b

URL: 
https://github.com/llvm/llvm-project/commit/bd590a5f895f50ceb7669de1b4a69bbcc8adb38b
DIFF: 
https://github.com/llvm/llvm-project/commit/bd590a5f895f50ceb7669de1b4a69bbcc8adb38b.diff

LOG: [lldb] Make Platform::DebugProcess take a Target reference

instead of a pointer. There are just two callers of this function, and
both of them have a valid target pointer, so there's no need for all
implementations to concern themselves with whether the pointer is null.

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Target/Platform.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index df46466655c35..878739c46fa4a 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -363,11 +363,9 @@ class Platform : public PluginInterface {
   /// platforms will want to subclass this function in order to be able to
   /// intercept STDIO and possibly launch a separate process that will debug
   /// the debuggee.
-  virtual lldb::ProcessSP
-  DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
-   Target *target, // Can be nullptr, if nullptr create a new
-   // target, else use existing one
-   Status &error);
+  virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
+   Debugger &debugger, Target &target,
+   Status &error);
 
   virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
  llvm::StringRef plugin_name,

diff  --git a/lldb/source/Commands/CommandObjectPlatform.cpp 
b/lldb/source/Commands/CommandObjectPlatform.cpp
index 7760eba290d4b..cd4d880e7 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1171,7 +1171,7 @@ class CommandObjectPlatformProcessLaunch : public 
CommandObjectParsed {
   target->GetRunArguments(m_options.launch_info.GetArguments());
 
 ProcessSP process_sp(platform_sp->DebugProcess(
-m_options.launch_info, debugger, target, error));
+m_options.launch_info, debugger, *target, error));
 if (process_sp && process_sp->IsAlive()) {
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   return true;

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 925a3d110b1df..0919ba23e3713 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -177,11 +177,10 @@ Status PlatformAppleSimulator::DisconnectRemote() {
 #endif
 }
 
-lldb::ProcessSP PlatformAppleSimulator::DebugProcess(
-ProcessLaunchInfo &launch_info, Debugger &debugger,
-Target *target, // Can be NULL, if NULL create a new target, else use
-// existing one
-Status &error) {
+lldb::ProcessSP
+PlatformAppleSimulator::DebugProcess(ProcessLaunchInfo &launch_info,
+ Debugger &debugger, Target &target,
+ Status &error) {
 #if defined(__APPLE__)
   ProcessSP process_sp;
   // Make sure we stop at the entry point
@@ -195,7 +194,7 @@ lldb::ProcessSP PlatformAppleSimulator::DebugProcess(
   if (error.Success()) {
 if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
   ProcessAttachInfo attach_info(launch_info);
-  process_sp = Attach(attach_info, debugger, target, error);
+  process_sp = Attach(attach_info, debugger, &target, error);
   if (process_sp) {
 launch_info.SetHijackListener(attach_info.GetHijackListener());
 

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
index 2e6ce02635c53..fc428ad2be46a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
+++ b/lldb/source/Plugins/P

[Lldb-commits] [lldb] 9669223 - [lldb] Remove two #ifndef linux from Platform.cpp

2021-09-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-20T08:30:02+02:00
New Revision: 966922320f09b8bf6e4a69a32f344b3acec36434

URL: 
https://github.com/llvm/llvm-project/commit/966922320f09b8bf6e4a69a32f344b3acec36434
DIFF: 
https://github.com/llvm/llvm-project/commit/966922320f09b8bf6e4a69a32f344b3acec36434.diff

LOG: [lldb] Remove two #ifndef linux from Platform.cpp

These have been here since r215992, guarding the calls to HostInfo, but
their purpose unclear -- HostInfoLinux provides these functions and they
work fine.

Added: 


Modified: 
lldb/source/Target/Platform.cpp

Removed: 




diff  --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index a9b97f7957953..7f762a68710e8 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -497,24 +497,14 @@ bool Platform::GetOSBuildString(std::string &s) {
   s.clear();
 
   if (IsHost())
-#if !defined(__linux__)
 return HostInfo::GetOSBuildString(s);
-#else
-return false;
-#endif
-  else
-return GetRemoteOSBuildString(s);
+  return GetRemoteOSBuildString(s);
 }
 
 bool Platform::GetOSKernelDescription(std::string &s) {
   if (IsHost())
-#if !defined(__linux__)
 return HostInfo::GetOSKernelDescription(s);
-#else
-return false;
-#endif
-  else
-return GetRemoteOSKernelDescription(s);
+  return GetRemoteOSKernelDescription(s);
 }
 
 void Platform::AddClangModuleCompilationOptions(



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 791b6eb - [lldb] Speculative fix to TestGuiExpandThreadsTree

2021-09-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-21T10:01:00+02:00
New Revision: 791b6ebc86680168d634103b67a92a354c075cc4

URL: 
https://github.com/llvm/llvm-project/commit/791b6ebc86680168d634103b67a92a354c075cc4
DIFF: 
https://github.com/llvm/llvm-project/commit/791b6ebc86680168d634103b67a92a354c075cc4.diff

LOG: [lldb] Speculative fix to TestGuiExpandThreadsTree

This test relies on being able to unwind from an arbitrary place inside
libc. While I am not sure this is the cause of the observed flakyness,
it is known that we are not able to unwind correctly from some places in
(linux) libc.

This patch adds additional synchronization to ensure that the inferior
is in the main function (instead of pthread guts) when lldb tries to
unwind it. At the very least, it should make the test runs more
predictable/repeatable.

Added: 
lldb/test/API/commands/gui/expand-threads-tree/main.cpp

Modified: 
lldb/test/API/commands/gui/expand-threads-tree/Makefile
lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py

Removed: 
lldb/test/API/commands/gui/expand-threads-tree/main.c



diff  --git a/lldb/test/API/commands/gui/expand-threads-tree/Makefile 
b/lldb/test/API/commands/gui/expand-threads-tree/Makefile
index 0c11fbdd8669c..566938ca0cc4e 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/Makefile
+++ b/lldb/test/API/commands/gui/expand-threads-tree/Makefile
@@ -1,3 +1,3 @@
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 ENABLE_THREADS := YES
 include Makefile.rules

diff  --git 
a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py 
b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
index c3ec4b285ecd0..9eed5b0ef6c39 100644
--- a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
+++ b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py
@@ -22,7 +22,7 @@ def test_gui(self):
 self.build()
 
 self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
-self.expect("breakpoint set -r thread_start_routine", 
substrs=["Breakpoint 1", "address ="])
+self.expect("breakpoint set -n break_here", substrs=["Breakpoint 1", 
"address ="])
 self.expect("run", substrs=["stop reason ="])
 
 escape_key = chr(27).encode()
@@ -33,7 +33,7 @@ def test_gui(self):
 self.child.expect_exact("Threads")
 
 # The thread running thread_start_routine should be expanded.
-self.child.expect_exact("frame #0: thread_start_routine")
+self.child.expect_exact("frame #0: break_here")
 
 # Exit GUI.
 self.child.send(escape_key)

diff  --git a/lldb/test/API/commands/gui/expand-threads-tree/main.c 
b/lldb/test/API/commands/gui/expand-threads-tree/main.c
deleted file mode 100644
index 32e6d17c799a6..0
--- a/lldb/test/API/commands/gui/expand-threads-tree/main.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include 
-
-void *thread_start_routine(void *arg) { return NULL; }
-
-int main() {
-  pthread_t thread;
-  pthread_create(&thread, NULL, thread_start_routine, NULL);
-  pthread_join(thread, NULL);
-  return 0;
-}

diff  --git a/lldb/test/API/commands/gui/expand-threads-tree/main.cpp 
b/lldb/test/API/commands/gui/expand-threads-tree/main.cpp
new file mode 100644
index 0..5a7cbb78563c0
--- /dev/null
+++ b/lldb/test/API/commands/gui/expand-threads-tree/main.cpp
@@ -0,0 +1,24 @@
+#include "pseudo_barrier.h"
+#include 
+
+
+pseudo_barrier_t barrier_before;
+pseudo_barrier_t barrier_after;
+
+void break_here() {}
+
+void thread_func() {
+pseudo_barrier_wait(barrier_before);
+break_here();
+pseudo_barrier_wait(barrier_after);
+}
+
+int main() {
+  pseudo_barrier_init(barrier_before, 2);
+  pseudo_barrier_init(barrier_after, 2);
+  std::thread thread(thread_func);
+  pseudo_barrier_wait(barrier_before);
+  pseudo_barrier_wait(barrier_after);
+  thread.join();
+  return 0;
+}



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5685eb9 - [lldb] Fix DomainSocket::GetSocketName for unnamed sockets

2021-09-23 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-23T12:30:18+02:00
New Revision: 5685eb950da7c6901c8b264a3c93e8ea63b34d3d

URL: 
https://github.com/llvm/llvm-project/commit/5685eb950da7c6901c8b264a3c93e8ea63b34d3d
DIFF: 
https://github.com/llvm/llvm-project/commit/5685eb950da7c6901c8b264a3c93e8ea63b34d3d.diff

LOG: [lldb] Fix DomainSocket::GetSocketName for unnamed sockets

getpeername will return addrlen = 2 (sizeof sa_family_t) for unnamed
sockets (those not assigned a name with bind(2)). This is typically true
for client sockets as well as those created by socketpair(2).

This GetSocketName used to crash for sockets which were connected to
these kinds of sockets. Now it returns an empty string.

Added: 


Modified: 
lldb/source/Host/posix/DomainSocket.cpp
lldb/unittests/Host/SocketTest.cpp

Removed: 




diff  --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 7322b15200b4d..790458ee13d00 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -127,29 +127,34 @@ void DomainSocket::DeleteSocketFile(llvm::StringRef name) 
{
 }
 
 std::string DomainSocket::GetSocketName() const {
-  if (m_socket != kInvalidSocketValue) {
-struct sockaddr_un saddr_un;
-saddr_un.sun_family = AF_UNIX;
-socklen_t sock_addr_len = sizeof(struct sockaddr_un);
-if (::getpeername(m_socket, (struct sockaddr *)&saddr_un, &sock_addr_len) 
==
-0) {
-  std::string name(saddr_un.sun_path + GetNameOffset(),
-   sock_addr_len -
-   offsetof(struct sockaddr_un, sun_path) -
+  if (m_socket == kInvalidSocketValue)
+return "";
+
+  struct sockaddr_un saddr_un;
+  saddr_un.sun_family = AF_UNIX;
+  socklen_t sock_addr_len = sizeof(struct sockaddr_un);
+  if (::getpeername(m_socket, (struct sockaddr *)&saddr_un, &sock_addr_len) !=
+  0)
+return "";
+
+  if (sock_addr_len <= offsetof(struct sockaddr_un, sun_path))
+return ""; // Unnamed domain socket
+
+  llvm::StringRef name(saddr_un.sun_path + GetNameOffset(),
+   sock_addr_len - offsetof(struct sockaddr_un, sun_path) -
GetNameOffset());
-  if (name.back() == '\0') name.pop_back();
-  return name;
-}
-  }
-  return "";
+  if (name.back() == '\0')
+name = name.drop_back();
+
+  return name.str();
 }
 
 std::string DomainSocket::GetRemoteConnectionURI() const {
-  if (m_socket != kInvalidSocketValue) {
-return std::string(llvm::formatv(
-"{0}://{1}",
-GetNameOffset() == 0 ? "unix-connect" : "unix-abstract-connect",
-GetSocketName()));
-  }
-  return "";
+  std::string name = GetSocketName();
+  if (name.empty())
+return name;
+
+  return llvm::formatv(
+  "{0}://{1}",
+  GetNameOffset() == 0 ? "unix-connect" : "unix-abstract-connect", name);
 }

diff  --git a/lldb/unittests/Host/SocketTest.cpp 
b/lldb/unittests/Host/SocketTest.cpp
index 27d42f835718b..5593b7726919b 100644
--- a/lldb/unittests/Host/SocketTest.cpp
+++ b/lldb/unittests/Host/SocketTest.cpp
@@ -225,6 +225,8 @@ TEST_P(SocketTest, DomainGetConnectURI) {
   EXPECT_TRUE(UriParser::Parse(uri, scheme, hostname, port, path));
   EXPECT_EQ(scheme, "unix-connect");
   EXPECT_EQ(path, domain_path);
+
+  EXPECT_EQ(socket_b_up->GetRemoteConnectionURI(), "");
 }
 #endif
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] cd6893a - [lldb] Fix target-symbols-add-unwind.test for clang 7647a841

2021-09-24 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-24T09:06:44+02:00
New Revision: cd6893a5a346d1b9c34ba621adad5f881e250695

URL: 
https://github.com/llvm/llvm-project/commit/cd6893a5a346d1b9c34ba621adad5f881e250695
DIFF: 
https://github.com/llvm/llvm-project/commit/cd6893a5a346d1b9c34ba621adad5f881e250695.diff

LOG: [lldb] Fix target-symbols-add-unwind.test for clang 7647a841

We need a different flag combination to produce .debug_frame.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test 
b/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
index b4f0cc4c402cd..5420213d405e8 100644
--- a/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
+++ b/lldb/test/Shell/SymbolFile/target-symbols-add-unwind.test
@@ -5,7 +5,8 @@
 
 # RUN: cd %T
 # RUN: %clang_host %S/Inputs/target-symbols-add-unwind.c -g \
-# RUN:   -fno-unwind-tables -o target-symbols-add-unwind.debug
+# RUN:   -fno-unwind-tables -fno-asynchronous-unwind-tables \
+# RUN:   -o target-symbols-add-unwind.debug
 # RUN: llvm-objcopy --strip-debug target-symbols-add-unwind.debug \
 # RUN:   target-symbols-add-unwind.stripped
 # RUN: %lldb target-symbols-add-unwind.stripped -s %s -o quit | FileCheck %s



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d5629b5 - Fix rendezvous for rebase_exec=true case

2021-09-27 Thread Pavel Labath via lldb-commits

Author: Emre Kultursay
Date: 2021-09-27T13:27:27+02:00
New Revision: d5629b5d4d41ce71703105362f58dfcdbb6cc175

URL: 
https://github.com/llvm/llvm-project/commit/d5629b5d4d41ce71703105362f58dfcdbb6cc175
DIFF: 
https://github.com/llvm/llvm-project/commit/d5629b5d4d41ce71703105362f58dfcdbb6cc175.diff

LOG: Fix rendezvous for rebase_exec=true case

When rebase_exec=true in DidAttach(), all modules are loaded
before the rendezvous breakpoint is set, which means the
LoadInterpreterModule() method is not called and m_interpreter_module
is not initialized.

This causes the very first rendezvous breakpoint hit with
m_initial_modules_added=false to accidentally unload the
module_sp that corresponds to the dynamic loader.

This bug (introduced in D92187) was causing the rendezvous
mechanism to not work in Android 28. The mechanism works
fine on older/newer versions of Android.

Test: Verified rendezvous on Android 28 and 29
Test: Added dlopen test

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D109797

Added: 
lldb/test/API/functionalities/load_after_attach/Makefile
lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
lldb/test/API/functionalities/load_after_attach/b.cpp
lldb/test/API/functionalities/load_after_attach/main.cpp

Modified: 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 0bb383ff0c00..7732f27d27ca 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -449,14 +449,18 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
 if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress(
 &m_process->GetTarget()) == m_interpreter_base &&
 module_sp != m_interpreter_module.lock()) {
-  // If this is a duplicate instance of ld.so, unload it.  We may end 
up
-  // with it if we load it via a 
diff erent path than before (symlink
-  // vs real path).
-  // TODO: remove this once we either fix library matching or avoid
-  // loading the interpreter when setting the rendezvous breakpoint.
-  UnloadSections(module_sp);
-  loaded_modules.Remove(module_sp);
-  continue;
+  if (m_interpreter_module.lock() == nullptr) {
+m_interpreter_module = module_sp;
+  } else {
+// If this is a duplicate instance of ld.so, unload it.  We may end
+// up with it if we load it via a 
diff erent path than before
+// (symlink vs real path).
+// TODO: remove this once we either fix library matching or avoid
+// loading the interpreter when setting the rendezvous breakpoint.
+UnloadSections(module_sp);
+loaded_modules.Remove(module_sp);
+continue;
+  }
 }
 
 loaded_modules.AppendIfNeeded(module_sp);
@@ -627,6 +631,7 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() {
   }
 
   m_process->GetTarget().ModulesDidLoad(module_list);
+  m_initial_modules_added = true;
 }
 
 addr_t DynamicLoaderPOSIXDYLD::ComputeLoadOffset() {

diff  --git a/lldb/test/API/functionalities/load_after_attach/Makefile 
b/lldb/test/API/functionalities/load_after_attach/Makefile
new file mode 100644
index ..0f3fb37bdadf
--- /dev/null
+++ b/lldb/test/API/functionalities/load_after_attach/Makefile
@@ -0,0 +1,9 @@
+CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+lib_b:
+   $(MAKE) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_CXX_SOURCES=b.cpp DYLIB_NAME=lib_b
+all: lib_b
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py 
b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
new file mode 100644
index ..0e9b3c40ff2b
--- /dev/null
+++ b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
@@ -0,0 +1,63 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfRemote
+def test_load_after_attach(self):
+self.build()
+
+ctx = self.platformContext
+lib_name = ctx.shlib_prefix + 'lib_b.' + ctx.shlib_extension
+
+exe = self.getBuildArtifact("a.out")
+lib = self.getBuildArtifact(lib_name)
+
+# Spawn a new process.
+# use realpath to workaround llvm.org/pr48376
+# Pass path to solib for dlopen to properly locate the library.
+popen = self.spawnSubprocess(os.path.realpath(exe), args = 
[os.path.realpath(

[Lldb-commits] [lldb] 3dbf27e - [lldb] A different fix for Domain Socket tests

2021-09-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-27T18:00:27+02:00
New Revision: 3dbf27e762008757c0de7034c778d941bfeb0388

URL: 
https://github.com/llvm/llvm-project/commit/3dbf27e762008757c0de7034c778d941bfeb0388
DIFF: 
https://github.com/llvm/llvm-project/commit/3dbf27e762008757c0de7034c778d941bfeb0388.diff

LOG: [lldb] A different fix for Domain Socket tests

we need to drop nuls from the end of the string.

Added: 


Modified: 
lldb/source/Host/posix/DomainSocket.cpp

Removed: 




diff  --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 8138b6ff1dc4..0a43d00e93ee 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -143,7 +143,7 @@ std::string DomainSocket::GetSocketName() const {
   llvm::StringRef name(saddr_un.sun_path + GetNameOffset(),
sock_addr_len - offsetof(struct sockaddr_un, sun_path) -
GetNameOffset());
-  name = name.drop_while([](char c) { return c == '\0'; });
+  name = name.rtrim('\0');
 
   return name.str();
 }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 156cb4c - [lldb] Remove non-stop mode code

2021-09-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-28T14:13:50+02:00
New Revision: 156cb4cc64bec2b72aad9848f8181b338ff19ebc

URL: 
https://github.com/llvm/llvm-project/commit/156cb4cc64bec2b72aad9848f8181b338ff19ebc
DIFF: 
https://github.com/llvm/llvm-project/commit/156cb4cc64bec2b72aad9848f8181b338ff19ebc.diff

LOG: [lldb] Remove non-stop mode code

We added some support for this mode back in 2015, but the feature was
never productionized. It is completely untested, and there are known
major structural lldb issues that need to be resolved before this
feature can really be supported.

It also complicates making further changes to stop reply packet
handling, which is what I am about to do.

Differential Revision: https://reviews.llvm.org/D110553

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index fc9dd97515aa9..4ddaf3fe2fca6 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -206,10 +206,6 @@ class TargetProperties : public Properties {
 
   void SetUserSpecifiedTrapHandlerNames(const Args &args);
 
-  bool GetNonStopModeEnabled() const;
-
-  void SetNonStopModeEnabled(bool b);
-
   bool GetDisplayRuntimeSupportValues() const;
 
   void SetDisplayRuntimeSupportValues(bool b);

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp 
b/lldb/source/Commands/CommandObjectThread.cpp
index 7247601b292b0..1534959989d3e 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -292,16 +292,10 @@ class ThreadStepScopeOptionGroup : public OptionGroup {
 // Check if we are in Non-Stop mode
 TargetSP target_sp =
 execution_context ? execution_context->GetTargetSP() : TargetSP();
-if (target_sp && target_sp->GetNonStopModeEnabled()) {
-  // NonStopMode runs all threads by definition, so when it is on we don't
-  // need to check the process setting for runs all threads.
-  m_run_mode = eOnlyThisThread;
-} else {
-  ProcessSP process_sp =
-  execution_context ? execution_context->GetProcessSP() : ProcessSP();
-  if (process_sp && process_sp->GetSteppingRunsAllThreads())
-m_run_mode = eAllThreads;
-}
+ProcessSP process_sp =
+execution_context ? execution_context->GetProcessSP() : ProcessSP();
+if (process_sp && process_sp->GetSteppingRunsAllThreads())
+  m_run_mode = eAllThreads;
 
 m_avoid_regexp.clear();
 m_step_in_target.clear();

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index a4c71e864a767..803e5842cd7de 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -249,32 +249,6 @@ GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
   return packet_result;
 }
 
-bool GDBRemoteClientBase::SendvContPacket(
-llvm::StringRef payload, std::chrono::seconds interrupt_timeout,
-StringExtractorGDBRemote &response) {
-  Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  LLDB_LOGF(log, "GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
-
-  // we want to lock down packet sending while we continue
-  Lock lock(*this, interrupt_timeout);
-
-  LLDB_LOGF(log,
-"GDBRemoteCommunicationClient::%s () sending vCont packet: %.*s",
-__FUNCTION__, int(payload.size()), payload.data());
-
-  if (SendPacketNoLock(payload) != PacketResult::Success)
-return false;
-
-  OnRunPacketSent(true);
-
-  // wait for the response to the vCont
-  if (ReadPacket(response, llvm::None, false) == PacketResult::Success) {
-if (response.IsOKResponse())
-  return true;
-  }
-
-  return false;
-}
 bool GDBRemoteClientBase::ShouldStop(const UnixSignals &signals,
  StringExtractorGDBRemote &response) {
   std::lock_guard lock(m_mutex);

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
index 518b81318b6cc..43a5313eae6ad 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
@@ -59,10 +59,6 @@ class GDB

[Lldb-commits] [lldb] 9413ead - [lldb/test] Add ability to specify environment when spawning processes

2021-09-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-28T14:13:50+02:00
New Revision: 9413ead7bcbaf5d8876ee484256df65c2846c5c9

URL: 
https://github.com/llvm/llvm-project/commit/9413ead7bcbaf5d8876ee484256df65c2846c5c9
DIFF: 
https://github.com/llvm/llvm-project/commit/9413ead7bcbaf5d8876ee484256df65c2846c5c9.diff

LOG: [lldb/test] Add ability to specify environment when spawning processes

We only had that ability for regular debugger launches. This meant that
it was not possible to use the normal dlopen patterns in attach tests.
This fixes that.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
lldb/test/API/functionalities/load_after_attach/main.cpp

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index a899b1b154fe2..db350aee4a182 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -360,7 +360,7 @@ def pid(self):
 """Returns process PID if has been launched already."""
 
 @abc.abstractmethod
-def launch(self, executable, args):
+def launch(self, executable, args, extra_env):
 """Launches new process with given executable and args."""
 
 @abc.abstractmethod
@@ -379,13 +379,19 @@ def __init__(self, trace_on):
 def pid(self):
 return self._proc.pid
 
-def launch(self, executable, args):
+def launch(self, executable, args, extra_env):
+env=None
+if extra_env:
+env = dict(os.environ)
+env.update([kv.split("=", 1) for kv in extra_env])
+
 self._proc = Popen(
 [executable] + args,
 stdout=open(
 os.devnull) if not self._trace_on else None,
 stdin=PIPE,
-preexec_fn=lldbplatformutil.enable_attach)
+preexec_fn=lldbplatformutil.enable_attach,
+env=env)
 
 def terminate(self):
 if self._proc.poll() is None:
@@ -424,7 +430,7 @@ def __init__(self, install_remote):
 def pid(self):
 return self._pid
 
-def launch(self, executable, args):
+def launch(self, executable, args, extra_env):
 if self._install_remote:
 src_path = executable
 dst_path = lldbutil.join_remote_paths(
@@ -450,6 +456,9 @@ def launch(self, executable, args):
 launch_info.AddSuppressFileAction(1, False, True)
 launch_info.AddSuppressFileAction(2, False, True)
 
+if extra_env:
+launch_info.SetEnvironmentEntries(extra_env, True)
+
 err = lldb.remote_platform.Launch(launch_info)
 if err.Fail():
 raise Exception(
@@ -952,13 +961,13 @@ def cleanupSubprocesses(self):
 del p
 del self.subprocesses[:]
 
-def spawnSubprocess(self, executable, args=[], install_remote=True):
+def spawnSubprocess(self, executable, args=[], extra_env=None, 
install_remote=True):
 """ Creates a subprocess.Popen object with the specified executable 
and arguments,
 saves it in self.subprocesses, and returns the object.
 """
 proc = _RemoteProcess(
 install_remote) if lldb.remote_platform else 
_LocalProcess(self.TraceOn())
-proc.launch(executable, args)
+proc.launch(executable, args, extra_env=extra_env)
 self.subprocesses.append(proc)
 return proc
 

diff  --git 
a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py 
b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
index 0e9b3c40ff2b3..3b261e632d4c8 100644
--- a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
+++ b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
@@ -6,6 +6,7 @@
 class TestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfRemote
 def test_load_after_attach(self):
@@ -17,18 +18,19 @@ def test_load_after_attach(self):
 exe = self.getBuildArtifact("a.out")
 lib = self.getBuildArtifact(lib_name)
 
+target = self.dbg.CreateTarget(exe)
+environment = self.registerSharedLibrariesWithTarget(target, ["lib_b"])
+
 # Spawn a new process.
 # use realpath to workaround llvm.org/pr48376
 # Pass path to solib for dlopen to properly locate the library.
-popen = self.spawnSubprocess(os.path.realpath(exe), args = 
[os.path.realpath(lib)])
-pid = popen.pid
+popen = self.spawnSubprocess(os.path.realpath(exe), 
extra_env=environment)
 
 # Attach to the spawned process.
-self.runCmd("process attach -p " + str(pid))
-
-target = self.dbg.GetSelectedTarget()
-process = target.GetProcess()
-self.assertTrue(process, PROCESS_IS_VALID)
+

[Lldb-commits] [lldb] 7866dbb - [lldb/test] Remove a check from TestLoadAfterAttach

2021-09-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-28T14:47:46+02:00
New Revision: 7866dbb261240f71c79e70d2ed52351846f795cd

URL: 
https://github.com/llvm/llvm-project/commit/7866dbb261240f71c79e70d2ed52351846f795cd
DIFF: 
https://github.com/llvm/llvm-project/commit/7866dbb261240f71c79e70d2ed52351846f795cd.diff

LOG: [lldb/test] Remove a check from TestLoadAfterAttach

The two module retrieval methods (qXfer:libraries-svr4 and manual list
traversal) differ in how the handle the
manually-added-but-not-yet-loaded modules. The svr4 path will remove it,
while the manual one will keep in the list.

It's likely the two paths need ought to be synchronized, but right now,
this distinction is not relevant for the test.

Added: 


Modified: 
lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py 
b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
index 3b261e632d4c..de691e6fdda4 100644
--- a/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
+++ b/lldb/test/API/functionalities/load_after_attach/TestLoadAfterAttach.py
@@ -39,13 +39,6 @@ def test_load_after_attach(self):
 stopped_threads = lldbutil.continue_to_breakpoint(self.process(), 
breakpoint1)
 self.assertEqual(len(stopped_threads), 1)
 
-# Check that image list does not contain liblib_b before dlopen.
-self.match(
-"image list",
-patterns = [lib_name],
-matching = False,
-msg = lib_name + " should not have been in image list")
-
 # Change a variable to escape the loop
 self.runCmd("expression main_thread_continue = 1")
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f6e3abc - [lldb/gdb-remote] Remove last_stop_packet_mutex

2021-09-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-09-29T11:23:14+02:00
New Revision: f6e3abc53021dbbba4944a4fa38c5731994823e9

URL: 
https://github.com/llvm/llvm-project/commit/f6e3abc53021dbbba4944a4fa38c5731994823e9
DIFF: 
https://github.com/llvm/llvm-project/commit/f6e3abc53021dbbba4944a4fa38c5731994823e9.diff

LOG: [lldb/gdb-remote] Remove last_stop_packet_mutex

This is a remnant of the non-stop mode.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 903c132dbf0ca..4d3a4c7a072a7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -251,8 +251,7 @@ bool ProcessGDBRemote::CanDebug(lldb::TargetSP target_sp,
 ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
ListenerSP listener_sp)
 : Process(target_sp, listener_sp),
-  m_debugserver_pid(LLDB_INVALID_PROCESS_ID), m_last_stop_packet_mutex(),
-  m_register_info_sp(nullptr),
+  m_debugserver_pid(LLDB_INVALID_PROCESS_ID), m_register_info_sp(nullptr),
   m_async_broadcaster(nullptr, 
"lldb.process.gdb-remote.async-broadcaster"),
   m_async_listener_sp(
   Listener::MakeListener("lldb.process.gdb-remote.async-listener")),
@@ -1462,37 +1461,30 @@ bool ProcessGDBRemote::UpdateThreadIDList() {
 // See if we can get the thread IDs from the current stop reply packets
 // that might contain a "threads" key/value pair
 
-// Lock the thread stack while we access it
-// Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex);
-std::unique_lock stop_stack_lock(
-m_last_stop_packet_mutex, std::defer_lock);
-if (stop_stack_lock.try_lock()) {
-  if (m_last_stop_packet) {
-// Get the thread stop info
-StringExtractorGDBRemote &stop_info = *m_last_stop_packet;
-const std::string &stop_info_str =
-std::string(stop_info.GetStringRef());
+if (m_last_stop_packet) {
+  // Get the thread stop info
+  StringExtractorGDBRemote &stop_info = *m_last_stop_packet;
+  const std::string &stop_info_str = std::string(stop_info.GetStringRef());
 
-m_thread_pcs.clear();
-const size_t thread_pcs_pos = stop_info_str.find(";thread-pcs:");
-if (thread_pcs_pos != std::string::npos) {
-  const size_t start = thread_pcs_pos + strlen(";thread-pcs:");
-  const size_t end = stop_info_str.find(';', start);
-  if (end != std::string::npos) {
-std::string value = stop_info_str.substr(start, end - start);
-UpdateThreadPCsFromStopReplyThreadsValue(value);
-  }
+  m_thread_pcs.clear();
+  const size_t thread_pcs_pos = stop_info_str.find(";thread-pcs:");
+  if (thread_pcs_pos != std::string::npos) {
+const size_t start = thread_pcs_pos + strlen(";thread-pcs:");
+const size_t end = stop_info_str.find(';', start);
+if (end != std::string::npos) {
+  std::string value = stop_info_str.substr(start, end - start);
+  UpdateThreadPCsFromStopReplyThreadsValue(value);
 }
+  }
 
-const size_t threads_pos = stop_info_str.find(";threads:");
-if (threads_pos != std::string::npos) {
-  const size_t start = threads_pos + strlen(";threads:");
-  const size_t end = stop_info_str.find(';', start);
-  if (end != std::string::npos) {
-std::string value = stop_info_str.substr(start, end - start);
-if (UpdateThreadIDsFromStopReplyThreadsValue(value))
-  return true;
-  }
+  const size_t threads_pos = stop_info_str.find(";threads:");
+  if (threads_pos != std::string::npos) {
+const size_t start = threads_pos + strlen(";threads:");
+const size_t end = stop_info_str.find(';', start);
+if (end != std::string::npos) {
+  std::string value = stop_info_str.substr(start, end - start);
+  if (UpdateThreadIDsFromStopReplyThreadsValue(value))
+return true;
 }
   }
 }
@@ -2317,14 +2309,9 @@ void ProcessGDBRemote::RefreshStateAfterStop() {
   // date before we do that or we might overwrite what was computed here.
   UpdateThreadListIfNeeded();
 
-  // Scope for the lock
-  {
-// Lock the thread stack while we access it
-std::lock_guard guard(m_last_stop_packet_mutex);
-if (m_last_stop_packet)
-  SetThreadStopInfo(*m_last_stop_packet);
-m_last_stop_packet.reset();
-  }
+  if (m_last_stop_packet)
+SetThreadStopInfo(*m_last_stop_packet);
+  m_last_stop_packet.reset();
 
   // If we have queried for a default thread id
   if (m_initial_tid != LLDB_INVALID_THREAD_ID) {
@@ -2571,13 +2558,7 @@ void ProcessGDBRemote::S

[Lldb-commits] [lldb] 633ac51 - [lldb] Simplify TestCompletion.py

2021-10-01 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-01T15:49:23+02:00
New Revision: 633ac5170996da6a80a2236bed99913b66ed1d27

URL: 
https://github.com/llvm/llvm-project/commit/633ac5170996da6a80a2236bed99913b66ed1d27
DIFF: 
https://github.com/llvm/llvm-project/commit/633ac5170996da6a80a2236bed99913b66ed1d27.diff

LOG: [lldb] Simplify TestCompletion.py

Added: 


Modified: 
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 2bba1bfcb7dd6..8332048313a9d 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -233,7 +233,7 @@ def test_target_symbols_add_shlib(self):
 
 def test_log_file(self):
 # Complete in our source directory which contains a 'main.cpp' file.
-src_dir =  os.path.dirname(os.path.realpath(__file__)) + '/'
+src_dir =  self.getSourceDir() + '/'
 self.complete_from_to('log enable lldb expr -f ' + src_dir,
   ['main.cpp'])
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] fd9bc13 - [lldb] Fix a stray array access in Editline

2021-10-04 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-04T14:26:02+02:00
New Revision: fd9bc13803ee24bfa674311584126b83e059d756

URL: 
https://github.com/llvm/llvm-project/commit/fd9bc13803ee24bfa674311584126b83e059d756
DIFF: 
https://github.com/llvm/llvm-project/commit/fd9bc13803ee24bfa674311584126b83e059d756.diff

LOG: [lldb] Fix a stray array access in Editline

This manifested itself as an asan failure in TestMultilineNavigation.py.

Added: 


Modified: 
lldb/source/Host/common/Editline.cpp

Removed: 




diff  --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index b55061301f4d0..6898f8452161d 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1560,7 +1560,7 @@ bool Editline::GetLines(int first_line_number, StringList 
&lines,
   if (!interrupted) {
 // Save the completed entry in history before returning. Don't save empty
 // input as that just clutters the command history.
-if (m_input_lines.size() > 1 || !m_input_lines.front().empty())
+if (!m_input_lines.empty())
   m_history_sp->Enter(CombineLines(m_input_lines).c_str());
 
 lines = GetInputAsStringList();



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 93c1b3c - [lldb] Remove some anonymous namespaces

2021-10-04 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-05T08:35:18+02:00
New Revision: 93c1b3caf052f6575abffd29ae53441db2849534

URL: 
https://github.com/llvm/llvm-project/commit/93c1b3caf052f6575abffd29ae53441db2849534
DIFF: 
https://github.com/llvm/llvm-project/commit/93c1b3caf052f6575abffd29ae53441db2849534.diff

LOG: [lldb] Remove some anonymous namespaces

.. and reduce the scope of others. They don't follow llvm coding
standards (which say they should be used only when the same effect
cannot be achieved with the static keyword), and they set a bad example.

Added: 


Modified: 
lldb/source/API/SBTarget.cpp
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Core/PluginManager.cpp
lldb/source/Host/common/LockFileBase.cpp
lldb/source/Host/common/Socket.cpp
lldb/source/Host/common/TCPSocket.cpp
lldb/source/Host/common/UDPSocket.cpp
lldb/source/Host/common/XML.cpp
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/source/Host/posix/DomainSocket.cpp
lldb/source/Host/posix/HostProcessPosix.cpp
lldb/source/Host/posix/LockFilePosix.cpp
lldb/source/Host/posix/PipePosix.cpp
lldb/source/Host/windows/Host.cpp
lldb/source/Host/windows/HostThreadWindows.cpp
lldb/source/Host/windows/LockFileWindows.cpp
lldb/source/Host/windows/PipeWindows.cpp
lldb/source/Host/windows/ProcessLauncherWindows.cpp
lldb/source/Interpreter/OptionValuePathMappings.cpp
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/Platform/Android/AdbClient.cpp
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp

Removed: 




diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8829a55d57a4..af62d4e02eb1 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -73,9 +73,7 @@ using namespace lldb_private;
 
 #define DEFAULT_DISASM_BYTE_SIZE 32
 
-namespace {
-
-Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
+static Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
   std::lock_guard guard(target.GetAPIMutex());
 
   auto process_sp = target.GetProcessSP();
@@ -94,8 +92,6 @@ Status AttachToProcess(ProcessAttachInfo &attach_info, Target 
&target) {
   return target.Attach(attach_info, nullptr);
 }
 
-} // namespace
-
 // SBTarget constructor
 SBTarget::SBTarget() : m_opaque_sp() {
   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget);

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 8d5d5a31337c..c644463719d4 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -602,7 +602,6 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, 
bool load,
   }
 }
 
-namespace {
 static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
 SymbolContext &new_sc) {
   bool equivalent_scs = false;
@@ -640,7 +639,6 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext 
&old_sc,
   }
   return equivalent_scs;
 }
-} // anonymous namespace
 
 void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
 ModuleSP new_module_sp) {

diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index 012143576e52..c0669927b636 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1435,8 +1435,9 @@ namespace {
 typedef lldb::OptionValuePropertiesSP
 GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString, ConstString,
  bool can_create);
+}
 
-lldb::OptionValuePropertiesSP
+static lldb::OptionValuePropertiesSP
 GetSettingForPlugin(Debugger &debugger, ConstString setting_name,
 ConstString plugin_type_name,
 GetDebuggerPropertyForPluginsPtr get_debugger_property =
@@ -1452,13 +1453,13 @@ GetSettingForPlugin(Debugger &debugger, ConstString 
setting_name,
   return properties_sp;
 }
 
-bool CreateSettingForPlugin(
-Debugger &debugger, ConstString plugin_type_name,
-ConstString plugin_type_desc,
-const lldb::OptionValuePropertiesSP &properties_sp, ConstString 
description,
-bool is_global_property,
-GetDebuggerPropertyForPluginsPtr get_debugger_property =
-GetDebuggerPropertyForPlugins) {
+static bool
+CreateSe

[Lldb-commits] [lldb] ca5be06 - Revert "[lldb] Refactor variable parsing"

2021-10-05 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-05T10:46:30+02:00
New Revision: ca5be065c4c612554acdcae3ead01a1474eff296

URL: 
https://github.com/llvm/llvm-project/commit/ca5be065c4c612554acdcae3ead01a1474eff296
DIFF: 
https://github.com/llvm/llvm-project/commit/ca5be065c4c612554acdcae3ead01a1474eff296.diff

LOG: Revert "[lldb] Refactor variable parsing"

This commit has introduced test failures in internal google tests.
Working theory is they are caused by a genuine problem in the patch
which gets tripped by some debug info from system libraries.

Reverting while we try to reproduce the problem in a self-contained
fashion.

This reverts commit 601168e42037ac4433e74b920bb22f76d59ba420.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index c111ff6567364..f89fb1655d3bf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2135,7 +2135,7 @@ void SymbolFileDWARF::FindGlobalVariables(
   }
 }
 
-ParseAndAppendGlobalVariable(sc, die, variables);
+ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
 while (pruned_idx < variables.GetSize()) {
   VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
   if (name_is_mangled ||
@@ -2188,7 +2188,7 @@ void SymbolFileDWARF::FindGlobalVariables(const 
RegularExpression ®ex,
   return true;
 sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
 
-ParseAndAppendGlobalVariable(sc, die, variables);
+ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
 
 return variables.GetSize() - original_size < max_matches;
   });
@@ -3049,8 +3049,8 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const 
SymbolContext &sc) {
   /*check_hi_lo_pc=*/true))
 func_lo_pc = ranges.GetMinRangeBase(0);
   if (func_lo_pc != LLDB_INVALID_ADDRESS) {
-const size_t num_variables =
-ParseVariablesInFunctionContext(sc, function_die, func_lo_pc);
+const size_t num_variables = ParseVariables(
+sc, function_die.GetFirstChild(), func_lo_pc, true, true);
 
 // Let all blocks know they have parse all their variables
 sc.function->GetBlock(false).SetDidParseVariables(true, true);
@@ -3479,137 +3479,117 @@ SymbolFileDWARF::FindBlockContainingSpecification(
   return DWARFDIE();
 }
 
-void SymbolFileDWARF::ParseAndAppendGlobalVariable(
-const SymbolContext &sc, const DWARFDIE &die,
-VariableList &cc_variable_list) {
-  if (!die)
-return;
-
-  dw_tag_t tag = die.Tag();
-  if (tag != DW_TAG_variable && tag != DW_TAG_constant)
-return;
-
-  // Check to see if we have already parsed this variable or constant?
-  VariableSP var_sp = GetDIEToVariable()[die.GetDIE()];
-  if (var_sp) {
-cc_variable_list.AddVariableIfUnique(var_sp);
-return;
-  }
-
-  // We haven't already parsed it, lets do that now.
-  VariableListSP variable_list_sp;
-  DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die);
-  dw_tag_t parent_tag = sc_parent_die.Tag();
-  switch (parent_tag) {
-  case DW_TAG_compile_unit:
-  case DW_TAG_partial_unit:
-if (sc.comp_unit != nullptr) {
-  variable_list_sp = sc.comp_unit->GetVariableList(false);
-} else {
-  GetObjectFile()->GetModule()->ReportError(
-  "parent 0x%8.8" PRIx64 " %s with no valid compile unit in "
-  "symbol context for 0x%8.8" PRIx64 " %s.\n",
-  sc_parent_die.GetID(), sc_parent_die.GetTagAsCString(), die.GetID(),
-  die.GetTagAsCString());
-  return;
-}
-break;
-
-  default:
-GetObjectFile()->GetModule()->ReportError(
-"didn't find appropriate parent DIE for variable list for "
-"0x%8.8" PRIx64 " %s.\n",
-die.GetID(), die.GetTagAsCString());
-return;
-  }
-
-  var_sp = ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS);
-  if (!var_sp)
-return;
-
-  cc_variable_list.AddVariableIfUnique(var_sp);
-  if (variable_list_sp)
-variable_list_sp->AddVariableIfUnique(var_sp);
-}
-
-size_t SymbolFileDWARF::ParseVariablesInFunctionContext(
-const SymbolContext &sc, const DWARFDIE &die,
-const lldb::addr_t func_low_pc) {
-  if (!die || !sc.function)
+size_t SymbolFileDWARF::ParseVariables(const SymbolContext &sc,
+   const DWARFDIE &orig_die,
+   const lldb::addr_t func_low_pc,
+   bool parse_siblings, bool 
parse_children,
+   VariableList *cc_variable_list) {
+  if (!orig_die)
 return 0;
 
-  Block *block =
-  sc.function->GetBlock(/*can_create=*/true).

Re: [Lldb-commits] [lldb] 10f16bc - Revert "[lldb] [ABI/X86] Split base x86 and i386 classes"

2021-10-07 Thread Pavel Labath via lldb-commits

On 06/10/2021 19:57, Stella Stamenova via lldb-commits wrote:


Author: Stella Stamenova
Date: 2021-10-06T10:56:45-07:00
New Revision: 10f16bc7b2bfa0fb3589ac62fc8392854a3a2226

URL: 
https://github.com/llvm/llvm-project/commit/10f16bc7b2bfa0fb3589ac62fc8392854a3a2226
DIFF: 
https://github.com/llvm/llvm-project/commit/10f16bc7b2bfa0fb3589ac62fc8392854a3a2226.diff

LOG: Revert "[lldb] [ABI/X86] Split base x86 and i386 classes"

This change broke the windows lldb bot.



Is there a plan to do something about the flakyness of that bot? 
Currently, it's success rate is like 80%. At that rate, people will 
train themselves to ignore it even if they do get a notification (which 
did not happen here because the previous build was a flake).


Maybe just disable the test step? Or just make the test step not fail 
the build (IIRC, buildbot has that option) ?


regards,
Pavel
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 81a2f39 - [lldb/gdb-remote] Delete SendPacketsAndConcatenateResponses

2021-10-07 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-07T13:09:27+02:00
New Revision: 81a2f39307a1f2169203abeb66c7bb00b5496edc

URL: 
https://github.com/llvm/llvm-project/commit/81a2f39307a1f2169203abeb66c7bb00b5496edc
DIFF: 
https://github.com/llvm/llvm-project/commit/81a2f39307a1f2169203abeb66c7bb00b5496edc.diff

LOG: [lldb/gdb-remote] Delete SendPacketsAndConcatenateResponses

ReadExtFeature provides equivalent functionality. Also fix a but in
ReadExtFeature, which prevented it from being used for auxv data (it
contains nul characters).

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index a44e666427899..e49bf22512cf3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -686,54 +686,6 @@ bool GDBRemoteCommunicationClient::GetxPacketSupported() {
   return m_supports_x;
 }
 
-GDBRemoteCommunicationClient::PacketResult
-GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses(
-const char *payload_prefix, std::string &response_string) {
-  Lock lock(*this);
-  if (!lock) {
-Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS |
-   GDBR_LOG_PACKETS));
-LLDB_LOGF(log,
-  "error: failed to get packet sequence mutex, not sending "
-  "packets with prefix '%s'",
-  payload_prefix);
-return PacketResult::ErrorNoSequenceLock;
-  }
-
-  response_string = "";
-  std::string payload_prefix_str(payload_prefix);
-  unsigned int response_size = 0x1000;
-  if (response_size > GetRemoteMaxPacketSize()) { // May send qSupported packet
-response_size = GetRemoteMaxPacketSize();
-  }
-
-  for (unsigned int offset = 0; true; offset += response_size) {
-StringExtractorGDBRemote this_response;
-// Construct payload
-char sizeDescriptor[128];
-snprintf(sizeDescriptor, sizeof(sizeDescriptor), "%x,%x", offset,
- response_size);
-PacketResult result = SendPacketAndWaitForResponseNoLock(
-payload_prefix_str + sizeDescriptor, this_response);
-if (result != PacketResult::Success)
-  return result;
-
-const std::string &this_string = std::string(this_response.GetStringRef());
-
-// Check for m or l as first character; l seems to mean this is the last
-// chunk
-char first_char = *this_string.c_str();
-if (first_char != 'm' && first_char != 'l') {
-  return PacketResult::ErrorReplyInvalid;
-}
-// Concatenate the result so far (skipping 'm' or 'l')
-response_string.append(this_string, 1, std::string::npos);
-if (first_char == 'l')
-  // We're done
-  return PacketResult::Success;
-  }
-}
-
 lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(bool allow_lazy) 
{
   if (allow_lazy && m_curr_pid_is_valid == eLazyBoolYes)
 return m_curr_pid;
@@ -3982,8 +3934,7 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
 
 // more chunks
 case ('m'):
-  if (str.length() > 1)
-output << &str[1];
+  output << str.substr(1);
   offset += str.length() - 1;
   break;
 

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index fd3fe1ce29969..9b8b4cb887056 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -65,27 +65,6 @@ class GDBRemoteCommunicationClient : public 
GDBRemoteClientBase {
   // we are communicating with it.
   bool HandshakeWithServer(Status *error_ptr);
 
-  // For packets which specify a range of output to be returned,
-  // return all of the output via a series of request packets of the form
-  // 0,
-  // ,
-  // *2,
-  // *3,
-  // ...
-  // until a "$l..." packet is received, indicating the end.
-  // (size is in hex; this format is used by a standard gdbserver to
-  // return the given portion of the output specified by ;
-  // for example, "qXfer:libraries-svr4:read::fff,1000" means
-  // "return a chunk of the xml description file for shared
-  // library load addresses, where the chunk starts at offset 0xfff
-  // and continues for 0x1000 bytes").
-  // Concatenate the resulting server response packets together and
-  // return in response_string.  If any packet fails, the return value
-  // indicates that failure and the returned string value is undefined.
-  PacketResult
-  SendPacketsAndConcatenat

[Lldb-commits] [lldb] 3d7161e - [lldb] Remove shared_ptr from some global Properties objects

2021-10-08 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-08T10:43:37+02:00
New Revision: 3d7161e3c14c25a60a3c03aa4c07a1dc4e35511b

URL: 
https://github.com/llvm/llvm-project/commit/3d7161e3c14c25a60a3c03aa4c07a1dc4e35511b
DIFF: 
https://github.com/llvm/llvm-project/commit/3d7161e3c14c25a60a3c03aa4c07a1dc4e35511b.diff

LOG: [lldb] Remove shared_ptr from some global Properties objects

they're unnecessary, make the code longer, and their removal actually
ensures proper initialization in multithreaded scenarios.

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Target/Thread.h
lldb/include/lldb/lldb-forward.h
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/CommandInterpreter.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 878739c46fa4a..9aed70188097f 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -55,7 +55,6 @@ class PlatformProperties : public Properties {
   void SetDefaultModuleCacheDirectory(const FileSpec &dir_spec);
 };
 
-typedef std::shared_ptr PlatformPropertiesSP;
 typedef llvm::SmallVector MmapArgList;
 
 /// \class Platform Platform.h "lldb/Target/Platform.h"
@@ -84,7 +83,7 @@ class Platform : public PluginInterface {
 
   static void Terminate();
 
-  static const PlatformPropertiesSP &GetGlobalPlatformProperties();
+  static PlatformProperties &GetGlobalPlatformProperties();
 
   /// Get the native host platform plug-in.
   ///

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 741c9e1021cc6..5f4c1272ef28d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -106,8 +106,6 @@ class ProcessProperties : public Properties {
   std::unique_ptr m_experimental_properties_up;
 };
 
-typedef std::shared_ptr ProcessPropertiesSP;
-
 // ProcessAttachInfo
 //
 // Describes any information that is required to attach to a process.
@@ -501,7 +499,7 @@ class Process : public 
std::enable_shared_from_this,
 
   static void SettingsTerminate();
 
-  static const ProcessPropertiesSP &GetGlobalProperties();
+  static ProcessProperties &GetGlobalProperties();
 
   /// Find a Process plug-in that can debug \a module using the currently
   /// selected architecture.

diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 4ddaf3fe2fca6..c8fc66db7ef4a 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -562,7 +562,7 @@ class Target : public std::enable_shared_from_this,
 
   // Settings accessors
 
-  static const lldb::TargetPropertiesSP &GetGlobalProperties();
+  static TargetProperties &GetGlobalProperties();
 
   std::recursive_mutex &GetAPIMutex();
 

diff  --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 0f6b5741573ee..a48be19005153 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -57,8 +57,6 @@ class ThreadProperties : public Properties {
   uint64_t GetMaxBacktraceDepth() const;
 };
 
-typedef std::shared_ptr ThreadPropertiesSP;
-
 class Thread : public std::enable_shared_from_this,
public ThreadProperties,
public UserID,
@@ -149,7 +147,7 @@ class Thread : public std::enable_shared_from_this,
 
   static void SettingsTerminate();
 
-  static const ThreadPropertiesSP &GetGlobalProperties();
+  static ThreadProperties &GetGlobalProperties();
 
   lldb::ProcessSP GetProcess() const { return m_process_wp.lock(); }
 

diff  --git a/lldb/include/lldb/lldb-forward.h 
b/lldb/include/lldb/lldb-forward.h
index bb6ab1fa0a843..b68e9048ce3b4 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -399,7 +399,6 @@ typedef 
std::shared_ptr
 SyntheticChildrenFrontEndSP;
 typedef std::shared_ptr TargetSP;
 typedef std::weak_ptr TargetWP;
-typedef std::shared_ptr TargetPropertiesSP;
 typedef std::shared_ptr ThreadSP;
 typedef std::weak_ptr ThreadWP;
 typedef std::shared_ptr ThreadCollectionSP;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index eb092cc705c4b..1ddd95726f0c9 100644
--- a/lldb/source/Core/Debugg

[Lldb-commits] [lldb] f4145c0 - [lldb/gdb-remote] Refactor ReadExtFeature

2021-10-08 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-08T10:43:37+02:00
New Revision: f4145c074cb81441f2e4a965f618f9949fa4f071

URL: 
https://github.com/llvm/llvm-project/commit/f4145c074cb81441f2e4a965f618f9949fa4f071
DIFF: 
https://github.com/llvm/llvm-project/commit/f4145c074cb81441f2e4a965f618f9949fa4f071.diff

LOG: [lldb/gdb-remote] Refactor ReadExtFeature

replace stl and lldb apis with standard llvm ones.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index e49bf22512cf..c68fcc1789d8 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1703,17 +1703,13 @@ Status 
GDBRemoteCommunicationClient::LoadQXferMemoryMap() {
 return error;
   }
 
-  std::string xml;
-  lldb_private::Status lldberr;
-  if (!ReadExtFeature(ConstString("memory-map"), ConstString(""), xml,
-  lldberr)) {
-error.SetErrorString("Failed to read memory map");
-return error;
-  }
+  llvm::Expected xml = ReadExtFeature("memory-map", "");
+  if (!xml)
+return Status(xml.takeError());
 
   XMLDocument xml_document;
 
-  if (!xml_document.ParseMemory(xml.c_str(), xml.size())) {
+  if (!xml_document.ParseMemory(xml->c_str(), xml->size())) {
 error.SetErrorString("Failed to parse memory map xml");
 return error;
   }
@@ -3883,15 +3879,14 @@ GDBRemoteCommunicationClient::GetModulesInfo(
 
 // query the target remote for extended information using the qXfer packet
 //
-// example: object='features', annex='target.xml', out= return:
-// 'true'  on success
-//  'false' on failure (err set)
-bool GDBRemoteCommunicationClient::ReadExtFeature(
-const lldb_private::ConstString object,
-const lldb_private::ConstString annex, std::string &out,
-lldb_private::Status &err) {
-
-  std::stringstream output;
+// example: object='features', annex='target.xml'
+// return:  or error
+llvm::Expected
+GDBRemoteCommunicationClient::ReadExtFeature(llvm::StringRef object,
+ llvm::StringRef annex) {
+
+  std::string output;
+  llvm::raw_string_ostream output_stream(output);
   StringExtractorGDBRemote chunk;
 
   uint64_t size = GetRemoteMaxPacketSize();
@@ -3905,28 +3900,22 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
   while (active) {
 
 // send query extended feature packet
-std::stringstream packet;
-packet << "qXfer:" << object.AsCString("")
-   << ":read:" << annex.AsCString("") << ":" << std::hex << offset
-   << "," << std::hex << size;
+std::string packet =
+("qXfer:" + object + ":read:" + annex + ":" +
+ llvm::Twine::utohexstr(offset) + "," + llvm::Twine::utohexstr(size))
+.str();
 
 GDBRemoteCommunication::PacketResult res =
-SendPacketAndWaitForResponse(packet.str(), chunk);
+SendPacketAndWaitForResponse(packet, chunk);
 
-if (res != GDBRemoteCommunication::PacketResult::Success) {
-  err.SetErrorString("Error sending $qXfer packet");
-  return false;
-}
-
-const std::string &str = std::string(chunk.GetStringRef());
-if (str.length() == 0) {
-  // should have some data in chunk
-  err.SetErrorString("Empty response from $qXfer packet");
-  return false;
+if (res != GDBRemoteCommunication::PacketResult::Success ||
+chunk.GetStringRef().empty()) {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Error sending $qXfer packet");
 }
 
 // check packet code
-switch (str[0]) {
+switch (chunk.GetStringRef()[0]) {
 // last chunk
 case ('l'):
   active = false;
@@ -3934,20 +3923,19 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
 
 // more chunks
 case ('m'):
-  output << str.substr(1);
-  offset += str.length() - 1;
+  output_stream << chunk.GetStringRef().drop_front();
+  offset += chunk.GetStringRef().size() - 1;
   break;
 
 // unknown chunk
 default:
-  err.SetErrorString("Invalid continuation code from $qXfer packet");
-  return false;
+  return llvm::createStringError(
+  llvm::inconvertibleErrorCode(),
+  "Invalid continuation code from $qXfer packet");
 }
   }
 
-  out = output.str();
-  err.Success();
-  return true;
+  return output_stream.str();
 }
 
 // Notify the target that gdb is prepared to serve symbol lookup requests.

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h 

[Lldb-commits] [lldb] 8093c2e - [lldb] Make char[N] formatters respect the end of the array (PR44649)

2021-10-11 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-11T12:47:11+02:00
New Revision: 8093c2ea574b9f7cbeb6c150f6584446cfd93517

URL: 
https://github.com/llvm/llvm-project/commit/8093c2ea574b9f7cbeb6c150f6584446cfd93517
DIFF: 
https://github.com/llvm/llvm-project/commit/8093c2ea574b9f7cbeb6c150f6584446cfd93517.diff

LOG: [lldb] Make char[N] formatters respect the end of the array (PR44649)

I believe this is a more natural behavior, and it also matches what gdb
does.

Differential Revision: https://reviews.llvm.org/D111399

Added: 


Modified: 
lldb/source/DataFormatters/FormatManager.cpp
lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index 6c824d1f77284..2237fdd58a762 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -722,7 +722,7 @@ void FormatManager::LoadSystemFormatters() {
   new StringSummaryFormat(string_flags, "${var%s}"));
 
   lldb::TypeSummaryImplSP string_array_format(
-  new StringSummaryFormat(string_array_flags, "${var%s}"));
+  new StringSummaryFormat(string_array_flags, "${var%char[]}"));
 
   RegularExpression any_size_char_arr(llvm::StringRef("char \\[[0-9]+\\]"));
 

diff  --git 
a/lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp 
b/lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
index 670ed3db17483..ebc51d0c7aed1 100644
--- a/lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
@@ -1,7 +1,18 @@
 #include 
+#include 
+
+struct A {
+  char data[4];
+  char overflow[4];
+};
 
 int main (int argc, char const *argv[])
 {
+A a, b;
+// Deliberately write past the end of data to test that the formatter stops
+// at the end of array.
+memcpy(a.data, "FOOBAR", 7);
+memcpy(b.data, "FO\0BAR", 7);
 std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n"); 
//%self.addTearDownHook(lambda x: x.runCmd("setting set escape-non-printables 
true"))
 const char* constcharstar = stdstring.c_str();
 std::string longstring(
@@ -20,12 +31,15 @@ int main (int argc, char const *argv[])
   );
 const char* longconstcharstar = longstring.c_str();
 return 0; //% if self.TraceOn(): self.runCmd('frame variable')
-  //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() 
== '"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
- //% 
self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == 
'"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
- //% self.runCmd("setting set escape-non-printables false")
- //% self.assertTrue(self.frame().FindVariable('stdstring').GetSummary() 
== '"Hello\t\tWorld\nI am here\t\tto say hello\n"')
- //% 
self.assertTrue(self.frame().FindVariable('constcharstar').GetSummary() == 
'"Hello\t\tWorld\nI am here\t\tto say hello\n"')
+//% self.expect_var_path('stdstring', summary='"Hello\\t\\tWorld\\nI am 
here\\t\\tto say hello\\n"')
+//% self.expect_var_path('constcharstar', summary='"Hello\\t\\tWorld\\nI 
am here\\t\\tto say hello\\n"')
+//% self.runCmd("setting set escape-non-printables false")
+//% self.expect_var_path('stdstring', summary='"Hello\t\tWorld\nI am 
here\t\tto say hello\n"')
+//% self.expect_var_path('constcharstar', summary='"Hello\t\tWorld\nI am 
here\t\tto say hello\n"')
 //% 
self.assertTrue(self.frame().FindVariable('longstring').GetSummary().endswith('"...'))
 //% 
self.assertTrue(self.frame().FindVariable('longconstcharstar').GetSummary().endswith('"...'))
+//% self.expect_var_path("a.data", summary='"FOOB"')
+// FIXME: Should this be "FO\0B" instead?
+//% self.expect_var_path("b.data", summary='"FO"')
 }
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ca0ce99 - [lldb] Print embedded nuls in char arrays (PR44649)

2021-10-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-14T09:50:40+02:00
New Revision: ca0ce99fc87c9a49b4c4a69cc6e88594bf6eb13c

URL: 
https://github.com/llvm/llvm-project/commit/ca0ce99fc87c9a49b4c4a69cc6e88594bf6eb13c
DIFF: 
https://github.com/llvm/llvm-project/commit/ca0ce99fc87c9a49b4c4a69cc6e88594bf6eb13c.diff

LOG: [lldb] Print embedded nuls in char arrays (PR44649)

When we know the bounds of the array, print any embedded nuls instead of
treating them as terminators. An exception to this rule is made for the
nul character at the very end of the string. We don't print that, as
otherwise 99% of the strings would end in \0. This way the strings
usually come out the same as how the user typed it into the compiler
(char foo[] = "with\0nuls"). It also matches how they come out in gdb.

This resolves a FIXME left from D111399, and leaves another FIXME for dealing
with nul characters in "escape-non-printables=false" mode. In this mode the
characters cause the entire summary string to be terminated prematurely.

Differential Revision: https://reviews.llvm.org/D111634

Added: 


Modified: 
lldb/source/Core/ValueObject.cpp

lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
lldb/test/API/functionalities/data-formatter/stringprinter/main.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_const_value.s

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 9c1ba99da1d05..6794d0c7331d3 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -849,8 +849,10 @@ bool ValueObject::SetData(DataExtractor &data, Status 
&error) {
 
 static bool CopyStringDataToBufferSP(const StreamString &source,
  lldb::DataBufferSP &destination) {
-  destination = std::make_shared(source.GetSize() + 1, 0);
-  memcpy(destination->GetBytes(), source.GetString().data(), source.GetSize());
+  llvm::StringRef src = source.GetString();
+  src.consume_back(llvm::StringRef("\0", 1));
+  destination = std::make_shared(src.size(), 0);
+  memcpy(destination->GetBytes(), src.data(), src.size());
   return true;
 }
 
@@ -912,8 +914,8 @@ ValueObject::ReadPointedString(lldb::DataBufferSP 
&buffer_sp, Status &error,
   CopyStringDataToBufferSP(s, buffer_sp);
   return {0, was_capped};
 }
-buffer_sp = std::make_shared(cstr_len, 0);
-memcpy(buffer_sp->GetBytes(), cstr, cstr_len);
+s << llvm::StringRef(cstr, cstr_len);
+CopyStringDataToBufferSP(s, buffer_sp);
 return {cstr_len, was_capped};
   } else {
 s << "";
@@ -1196,6 +1198,7 @@ bool ValueObject::DumpPrintableRepresentation(
 options.SetQuote('"');
 options.SetSourceSize(buffer_sp->GetByteSize());
 options.SetIsTruncated(read_string.second);
+options.SetBinaryZeroIsTerminator(custom_format != 
eFormatVectorOfChar);
 formatters::StringPrinter::ReadBufferAndDumpToStream<
 lldb_private::formatters::StringPrinter::StringElementType::ASCII>(
 options);

diff  --git 
a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
 
b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
index 741acd0431bd0..c894b80228cfe 100644
--- 
a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
+++ 
b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
@@ -90,8 +90,8 @@ def test(self):
 
 # Different character arrays.
 # FIXME: Passing a 'const char *' will ignore any given format,
-self.assertIn('= " \\U001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', 
self.getFormatted("character array", "cstring"))
-self.assertIn('= " \\U001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', 
self.getFormatted("c-string", "cstring"))
+self.assertIn(r'= " \U001b\a\b\f\n\r\t\vaA09\0"', 
self.getFormatted("character array", "cstring"))
+self.assertIn(r'= " \U001b\a\b\f\n\r\t\vaA09\0"', 
self.getFormatted("c-string", "cstring"))
 self.assertIn(' = " \\e\\a\\b\\f\\n\\r\\t\\vaA09" " 
\\U001b\\a\\b\\f\\n\\r\\t\\vaA09"\n',
   self.getFormatted("c-string", "(char *)cstring"))
 self.assertIn('=\n', self.getFormatted("c-string", 
"(__UINT64_TYPE__)0"))
@@ -132,10 +132,10 @@ def test(self):
 self.assertIn('= 0x2007080c0a0d090b415a617a30391b00\n', 
self.getFormatted("OSType", string_expr))
 
 # bytes
-self.assertIn('= " \\U001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', 
self.getFormatted("bytes", "cstring"))
+self.assertIn(r'= " \U001b\a\b\f\n\r\t\vaA09\0"', 
self.getFormatted("bytes", "cstring"))
 
 # bytes with ASCII
-self.assertIn('= " \\U001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', 
self.getFormatted("bytes with ASCII", "cstring"))
+self.assertIn(r'=

[Lldb-commits] [lldb] fa639ed - [lldb] Fix TestStackCorefile.py for ca0ce99fc8

2021-10-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-14T10:38:48+02:00
New Revision: fa639eda6535732a5fd79c3f551d5a667b810963

URL: 
https://github.com/llvm/llvm-project/commit/fa639eda6535732a5fd79c3f551d5a667b810963
DIFF: 
https://github.com/llvm/llvm-project/commit/fa639eda6535732a5fd79c3f551d5a667b810963.diff

LOG: [lldb] Fix TestStackCorefile.py for ca0ce99fc8

Added: 


Modified: 
lldb/test/API/macosx/stack-corefile/main.c

Removed: 




diff  --git a/lldb/test/API/macosx/stack-corefile/main.c 
b/lldb/test/API/macosx/stack-corefile/main.c
index a52fb3056caa4..afc206b6de847 100644
--- a/lldb/test/API/macosx/stack-corefile/main.c
+++ b/lldb/test/API/macosx/stack-corefile/main.c
@@ -6,8 +6,7 @@ int main() {
   int *heap_int = (int*) malloc(sizeof (int));
   *heap_int = 10;
 
-  char stack_str[80];
-  strcpy (stack_str, "stack string");
+  char stack_str[] = "stack string";
   char *heap_str = (char*) malloc(80);
   strcpy (heap_str, "heap string");
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bc9b106 - [lldb] Fix an include in HostTest.cpp

2021-10-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-15T11:10:38+02:00
New Revision: bc9b106a5750cf05ddab1dfce2a77d73bcc7d44a

URL: 
https://github.com/llvm/llvm-project/commit/bc9b106a5750cf05ddab1dfce2a77d73bcc7d44a
DIFF: 
https://github.com/llvm/llvm-project/commit/bc9b106a5750cf05ddab1dfce2a77d73bcc7d44a.diff

LOG: [lldb] Fix an include in HostTest.cpp

The previous include was too broad, and its better if the host tests do
not depend on non-host libraries.

Added: 


Modified: 
lldb/unittests/Host/linux/HostTest.cpp

Removed: 




diff  --git a/lldb/unittests/Host/linux/HostTest.cpp 
b/lldb/unittests/Host/linux/HostTest.cpp
index 699ccba0a9849..78bbe470d6953 100644
--- a/lldb/unittests/Host/linux/HostTest.cpp
+++ b/lldb/unittests/Host/linux/HostTest.cpp
@@ -9,7 +9,7 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "gtest/gtest.h"
 
 using namespace lldb_private;



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d914aa4 - [lldb] Fix SymbolFilePDBTests for a3939e1

2021-10-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-18T11:59:01+02:00
New Revision: d914aa4ead2aabda2c9e2cf343d30ba8171e4ce2

URL: 
https://github.com/llvm/llvm-project/commit/d914aa4ead2aabda2c9e2cf343d30ba8171e4ce2
DIFF: 
https://github.com/llvm/llvm-project/commit/d914aa4ead2aabda2c9e2cf343d30ba8171e4ce2.diff

LOG: [lldb] Fix SymbolFilePDBTests for a3939e1

Added: 


Modified: 
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Removed: 




diff  --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 7c7d1902eefb9..d84980149d23e 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -153,7 +153,8 @@ TEST_F(SymbolFilePDBTests, TestAbilitiesForPDB) {
 
   SymbolFile *symfile = module->GetSymbolFile();
   EXPECT_NE(nullptr, symfile);
-  EXPECT_EQ(symfile->GetPluginName(), SymbolFilePDB::GetPluginNameStatic());
+  EXPECT_EQ(symfile->GetPluginName(),
+SymbolFilePDB::GetPluginNameStatic().GetStringRef());
 
   uint32_t expected_abilities = SymbolFile::kAllAbilities;
   EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b37efed - [lldb] Fix PDB/compilands.test for a3939e1

2021-10-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-18T14:11:47+02:00
New Revision: b37efed957ed0a0193d80020aefd55cb587dfc1f

URL: 
https://github.com/llvm/llvm-project/commit/b37efed957ed0a0193d80020aefd55cb587dfc1f
DIFF: 
https://github.com/llvm/llvm-project/commit/b37efed957ed0a0193d80020aefd55cb587dfc1f.diff

LOG: [lldb] Fix PDB/compilands.test for a3939e1

Added: 


Modified: 
lldb/test/Shell/SymbolFile/PDB/compilands.test

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/PDB/compilands.test 
b/lldb/test/Shell/SymbolFile/PDB/compilands.test
index 0bda82ee236fa..ecee5eb50d399 100644
--- a/lldb/test/Shell/SymbolFile/PDB/compilands.test
+++ b/lldb/test/Shell/SymbolFile/PDB/compilands.test
@@ -7,5 +7,5 @@ RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols 
%T/CompilandsTest.cpp.ex
 ; Link default libraries
 
 CHECK: Module [[CU:.*]]
-CHECK: SymbolFile pdb ([[CU]])
+CHECK: SymbolFile {{(native-)?}}pdb ([[CU]])
 CHECK: {{^[0-9A-F]+}}:   CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", 
file = '{{.*}}\CompilandsTest.cpp'



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1ef6bd9 - [lldb] Delete TestStandardUnwind

2021-10-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-18T15:22:10+02:00
New Revision: 1ef6bd9b1bffb3f0314840ad95cd554366fdbda7

URL: 
https://github.com/llvm/llvm-project/commit/1ef6bd9b1bffb3f0314840ad95cd554366fdbda7
DIFF: 
https://github.com/llvm/llvm-project/commit/1ef6bd9b1bffb3f0314840ad95cd554366fdbda7.diff

LOG: [lldb] Delete TestStandardUnwind

It's been broken (not failing, but not testing anything either) for
quite some time now, and nobody noticed. It also (by design) tests
stepping through libc code, which makes it completely non-hermetic.

It's not worth reviving such a test.

Added: 


Modified: 


Removed: 
lldb/test/API/functionalities/unwind/standard/Makefile
lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
lldb/test/API/functionalities/unwind/standard/hand_written/divmod.cpp
lldb/test/API/functionalities/unwind/standard/hand_written/fprintf.cpp
lldb/test/API/functionalities/unwind/standard/hand_written/new_delete.cpp



diff  --git a/lldb/test/API/functionalities/unwind/standard/Makefile 
b/lldb/test/API/functionalities/unwind/standard/Makefile
deleted file mode 100644
index 22f1051530f87..0
--- a/lldb/test/API/functionalities/unwind/standard/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py 
b/lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
deleted file mode 100644
index fdf488978cbd1..0
--- a/lldb/test/API/functionalities/unwind/standard/TestStandardUnwind.py
+++ /dev/null
@@ -1,175 +0,0 @@
-"""
-Test that we can backtrace correctly from standard functions.
-
-This test suit is a collection of automatically generated tests from the 
source files in the
-directory. Please DON'T add individual test cases to this file.
-
-To add a new test case to this test suit please create a simple C/C++ 
application and put the
-source file into the directory of the test cases. The test suit will 
automatically pick the
-file up and generate a test case from it in run time (with name 
test_standard_unwind_
-after escaping some special characters).
-"""
-
-from __future__ import print_function
-
-
-import unittest2
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-test_source_dirs = ["."]
-
-
-class StandardUnwindTest(TestBase):
-mydir = TestBase.compute_mydir(__file__)
-
-def standard_unwind_tests(self):
-# The following variables have to be defined for each architecture and 
OS we testing for:
-# base_function_names: List of function names where we accept that the 
stack unwinding is
-#  correct if they are on the stack. It should 
include the bottom most
-#  function on the stack and a list of functions 
where we know we can't
-#  unwind for any reason (list of expected failure 
functions)
-# no_step_function_names: The list of functions where we don't want to 
step through
-# instruction by instruction for any reason. 
(A valid reason is if
-# it is impossible to step through a function 
instruction by
-# instruction because it is special for some 
reason.) For these
-# functions we will immediately do a step-out when we hit them.
-
-triple = self.dbg.GetSelectedPlatform().GetTriple()
-if re.match("arm-.*-.*-android", triple):
-base_function_names = [
-"_start",# Base function on the stack
-"__memcpy_base", # Function reached by a fall through 
from the previous function
-"__memcpy_base_aligned",
-# Function reached by a fall through from the previous function
-]
-no_step_function_names = [
-"__sync_fetch_and_add_4",  # Calls into a special SO where we 
can't set a breakpoint
-"pthread_mutex_lock",
-# Uses ldrex and strex what interferes with the software single
-# stepping
-"pthread_mutex_unlock",
-# Uses ldrex and strex what interferes with the software single
-# stepping
-"pthread_once",
-# Uses ldrex and strex what interferes with the software single
-# stepping
-]
-elif re.match("aarch64-.*-.*-android", triple):
-base_function_names = [
-"do_arm64_start", # Base function on the stack
-]
-no_step_function_names = [
-None,
-"__cxa_guard_acquire",
-# Uses ldxr and stxr what interferes with the software single
-   

[Lldb-commits] [lldb] 8bac18b - [lldb] Reduce code duplication around inferior building

2021-10-19 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-19T12:09:41+02:00
New Revision: 8bac18be0e45adc7b096375bf4f65635fb994df0

URL: 
https://github.com/llvm/llvm-project/commit/8bac18be0e45adc7b096375bf4f65635fb994df0
DIFF: 
https://github.com/llvm/llvm-project/commit/8bac18be0e45adc7b096375bf4f65635fb994df0.diff

LOG: [lldb] Reduce code duplication around inferior building

We had two sets of build methods, whose bodies were largely
identical. This makes any kind of modification in their vicinity
repetitive and error-prone.

Replace each set with a single method taking an optional debug_info
parameter.

Differential Revision: https://reviews.llvm.org/D111989

Added: 


Modified: 
lldb/docs/testsuite/a-detailed-walkthrough.txt
lldb/packages/Python/lldbsuite/test/README-TestSuite
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/builders/darwin.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py

lldb/test/API/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
lldb/test/API/macosx/add-dsym/TestAddDsymDownload.py
lldb/test/API/macosx/add-dsym/TestAddDsymMidExecutionCommand.py

Removed: 




diff  --git a/lldb/docs/testsuite/a-detailed-walkthrough.txt 
b/lldb/docs/testsuite/a-detailed-walkthrough.txt
index fff5a40d1da77..8d374d5d81ea0 100644
--- a/lldb/docs/testsuite/a-detailed-walkthrough.txt
+++ b/lldb/docs/testsuite/a-detailed-walkthrough.txt
@@ -73,7 +73,7 @@ Now let's look inside the test method:
 
 def test_set_output_path(self):
 """Test that setting target.process.output-path for the launched 
process works."""
-self.buildDefault()
+self.build()
 
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -96,49 +96,12 @@ Now let's look inside the test method:
 self.expect(output, exe=False,
 startstr = "This message should go to standard out.")
 
-The self.buildDefault() statement is used to build a default binary for this
-test instance.  For this particular test case, since we don't really care what
-debugging format is used, we instruct the build subsystem to build the default
-binary for us.  The base class TestBase has defined three instance methods:
-
-def buildDefault(self, architecture=None, compiler=None, dictionary=None):
-"""Platform specific way to build the default binaries."""
-module = __import__(sys.platform)
-if not module.buildDefault(self, architecture, compiler, dictionary):
-raise Exception("Don't know how to build default binary")
-
-def buildDsym(self, architecture=None, compiler=None, dictionary=None):
-"""Platform specific way to build binaries with dsym info."""
-module = __import__(sys.platform)
-if not module.buildDsym(self, architecture, compiler, dictionary):
-raise Exception("Don't know how to build binary with dsym")
-
-def buildDwarf(self, architecture=None, compiler=None, dictionary=None):
-"""Platform specific way to build binaries with dwarf maps."""
-module = __import__(sys.platform)
-if not module.buildDwarf(self, architecture, compiler, dictionary):
-raise Exception("Don't know how to build binary with dwarf")
-
-And the test/plugins/darwin.py provides the implementation for all three build
-methods using the makefile mechanism.  We envision that linux plugin can use a
-similar approach to accomplish the task of building the binaries.
-
-macOS provides an additional way to manipulate archived DWARF debug symbol
-files and produces dSYM files.  The buildDsym() instance method is used by the
-test method to build the binary with dsym info.  For an example of this,
-see test/array_types/TestArrayTypes.py:
-
-@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
-def test_with_dsym_and_run_command(self):
-"""Test 'frame variable var_name' on some variables with array 
types."""
-self.buildDsym()
-self.array_types()
-
-This method is decorated with a skipUnless decorator so that it will only gets
-included into the test suite if the platform it is running on is 'darwin', 
a.k.a.
-macOS.
-
-Type 'man dsymutil' for more details. 
+The self.build() statement is used to build a binary for this
+test instance. This will build the binary for the current debug info format. If
+we wanted to avoid running the test for every supported debug info format we
+could annotate it with @no_debug_info_test. The test would then only be run for
+the default format.  The logic for building a test binary resides in the 
builder
+modules (packages/Python/lldbsuite/test/builders/builder.py)
 
 After the binary is built, it 

[Lldb-commits] [lldb] ffbff6c - [lldb/DWARF] Ignore debug info pointing to the low addresses

2021-10-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-20T11:19:30+02:00
New Revision: ffbff6c511ba230954013eca8d824a66f6b4f9a5

URL: 
https://github.com/llvm/llvm-project/commit/ffbff6c511ba230954013eca8d824a66f6b4f9a5
DIFF: 
https://github.com/llvm/llvm-project/commit/ffbff6c511ba230954013eca8d824a66f6b4f9a5.diff

LOG: [lldb/DWARF] Ignore debug info pointing to the low addresses

specifically, ignore addresses that point before the first code section.

This resurrects D87172 with several notable changes:
- it fixes a bug where the early exits in InitializeObject left
  m_first_code_address "initialized" to LLDB_INVALID_ADDRESS (0xfff..f),
  which caused _everything_ to be ignored.
- it extends the line table fix to function parsing as well, where it
  replaces a similar check which was checking the executable permissions
  of the section. This was insufficient because some
  position-independent elf executables can have an executable segment
  mapped at file address zero. (What makes this fix different is that it
  checks for the executable-ness of the sections contained within that
  segment, and those will not be at address zero.)
- It uses a different test case, with an elf file with near-zero
  addresses, and checks for both line table and function parsing.

Differential Revision: https://reviews.llvm.org/D112058

Added: 
lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/test/Shell/SymbolFile/DWARF/lit.local.cfg

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index c396e591ddc4..9078fa3cdc26 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -468,6 +468,8 @@ SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType 
language) {
 void SymbolFileDWARF::InitializeObject() {
   Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
 
+  InitializeFirstCodeAddress();
+
   if (!GetGlobalPluginProperties().IgnoreFileIndexes()) {
 StreamString module_desc;
 GetObjectFile()->GetModule()->GetDescription(module_desc.AsRawOstream(),
@@ -512,6 +514,25 @@ void SymbolFileDWARF::InitializeObject() {
   std::make_unique(*GetObjectFile()->GetModule(), *this);
 }
 
+void SymbolFileDWARF::InitializeFirstCodeAddress() {
+  InitializeFirstCodeAddressRecursive(
+  *m_objfile_sp->GetModule()->GetSectionList());
+  if (m_first_code_address == LLDB_INVALID_ADDRESS)
+m_first_code_address = 0;
+}
+
+void SymbolFileDWARF::InitializeFirstCodeAddressRecursive(
+const lldb_private::SectionList §ion_list) {
+  for (SectionSP section_sp : section_list) {
+if (section_sp->GetChildren().GetSize() > 0) {
+  InitializeFirstCodeAddressRecursive(section_sp->GetChildren());
+} else if (section_sp->GetType() == eSectionTypeCode) {
+  m_first_code_address =
+  std::min(m_first_code_address, section_sp->GetFileAddress());
+}
+  }
+}
+
 bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
   return version >= 2 && version <= 5;
 }
@@ -,6 +1132,12 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit 
&comp_unit) {
   // The Sequences view contains only valid line sequences. Don't iterate over
   // the Rows directly.
   for (const llvm::DWARFDebugLine::Sequence &seq : line_table->Sequences) {
+// Ignore line sequences that do not start after the first code address.
+// All addresses generated in a sequence are incremental so we only need
+// to check the first one of the sequence. Check the comment at the
+// m_first_code_address declaration for more details on this.
+if (seq.LowPC < m_first_code_address)
+  continue;
 std::unique_ptr sequence =
 LineTable::CreateLineSequenceContainer();
 for (unsigned idx = seq.FirstRowIndex; idx < seq.LastRowIndex; ++idx) {
@@ -2236,12 +2263,9 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE 
&orig_die,
   addr = sc.function->GetAddressRange().GetBaseAddress();
 }
 
-
-if (auto section_sp = addr.GetSection()) {
-  if (section_sp->GetPermissions() & ePermissionsExecutable) {
-sc_list.Append(sc);
-return true;
-  }
+if (addr.IsValid() && addr.GetFileAddress() >= m_first_code_address) {
+  sc_list.Append(sc);
+  return true;
 }
   }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index e02ae1347e84..6e58c8b6178e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -494,6 +494,11 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
 
   const lldb_private::FileSpecList &GetTypeUnitSupportFi

[Lldb-commits] [lldb] 551d118 - [lldb/test] Remove quote/unquote steps from the make invocations

2021-10-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-20T11:35:28+02:00
New Revision: 551d118805c808936956e464dc21e05acb478f78

URL: 
https://github.com/llvm/llvm-project/commit/551d118805c808936956e464dc21e05acb478f78
DIFF: 
https://github.com/llvm/llvm-project/commit/551d118805c808936956e464dc21e05acb478f78.diff

LOG: [lldb/test] Remove quote/unquote steps from the make invocations

None of the commands we run really rely on shell features. Running them
with shell=False, simplifies the code as there is no need for elaborate
quoting.

Differential Revision: https://reviews.llvm.org/D111990

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/builders/darwin.py
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index b49c6324c8ca..38e64220ed63 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -2,6 +2,7 @@
 import platform
 import subprocess
 import sys
+import itertools
 
 import lldbsuite.test.lldbtest as lldbtest
 import lldbsuite.test.lldbutil as lldbutil
@@ -25,11 +26,11 @@ def getExtraMakeArgs(self):
 Helper function to return extra argumentsfor the make system. This
 method is meant to be overridden by platform specific builders.
 """
-return ""
+return []
 
 def getArchCFlags(self, architecture):
 """Returns the ARCH_CFLAGS for the make system."""
-return ""
+return []
 
 def getMake(self, test_subdir, test_name):
 """Returns the invocation for GNU make.
@@ -59,29 +60,27 @@ def getMake(self, test_subdir, test_name):
 
 def getCmdLine(self, d):
 """
-Helper function to return a properly formatted command line argument(s)
-string used for the make system.
+Helper function to return a command line argument string used for the
+make system.
 """
 
-# If d is None or an empty mapping, just return an empty string.
+# If d is None or an empty mapping, just return an empty list.
 if not d:
-return ""
-pattern = '%s="%s"' if "win32" in sys.platform else "%s='%s'"
+return []
 
 def setOrAppendVariable(k, v):
 append_vars = ["CFLAGS", "CFLAGS_EXTRAS", "LD_EXTRAS"]
 if k in append_vars and k in os.environ:
 v = os.environ[k] + " " + v
-return pattern % (k, v)
+return '%s=%s' % (k, v)
 
-cmdline = " ".join(
-[setOrAppendVariable(k, v) for k, v in list(d.items())])
+cmdline = [setOrAppendVariable(k, v) for k, v in list(d.items())]
 
 return cmdline
 
-def runBuildCommands(self, commands, sender):
+def runBuildCommands(self, commands):
 try:
-lldbtest.system(commands, sender=sender)
+lldbtest.system(commands)
 except subprocess.CalledProcessError as called_process_error:
 # Convert to a build-specific error.
 # We don't do that in lldbtest.system() since that
@@ -93,7 +92,7 @@ def getArchSpec(self, architecture):
 Helper function to return the key-value string to specify the 
architecture
 used for the make system.
 """
-return ("ARCH=" + architecture) if architecture else ""
+return ["ARCH=" + architecture] if architecture else []
 
 def getCCSpec(self, compiler):
 """
@@ -104,9 +103,8 @@ def getCCSpec(self, compiler):
 if not cc and configuration.compiler:
 cc = configuration.compiler
 if cc:
-return "CC=\"%s\"" % cc
-else:
-return ""
+return ["CC=\"%s\"" % cc]
+return []
 
 def getSDKRootSpec(self):
 """
@@ -114,8 +112,8 @@ def getSDKRootSpec(self):
 used for the make system.
 """
 if configuration.sdkroot:
-return "SDKROOT={}".format(configuration.sdkroot)
-return ""
+return ["SDKROOT={}".format(configuration.sdkroot)]
+return []
 
 def getModuleCacheSpec(self):
 """
@@ -123,9 +121,9 @@ def getModuleCacheSpec(self):
 module cache used for the make system.
 """
 if configuration.clang_module_cache_dir:
-return "CLANG_MODULE_CACHE_DIR={}".format(
-configuration.clang_module_cache_dir)
-return ""
+return ["CLANG_MODULE_CACHE_DIR={}".format(
+configuration.clang_module_cache_dir)]
+return []
 
 def _getDebugInfoArgs(self, debug_info):
 if debug_info is None:
@@ -138,28 +136,23 @@ def _getDebugInfoArgs(self, debug_info):
 return ["MAKE_DSYM=NO", "MAKE_GMODULES

[Lldb-commits] [lldb] 2ace1e5 - [lldb] Remove ConstString from GetPluginNameStatic of some plugins

2021-10-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-21T12:58:45+02:00
New Revision: 2ace1e5753a49195ca17f3e175c7e189cf147760

URL: 
https://github.com/llvm/llvm-project/commit/2ace1e5753a49195ca17f3e175c7e189cf147760
DIFF: 
https://github.com/llvm/llvm-project/commit/2ace1e5753a49195ca17f3e175c7e189cf147760.diff

LOG: [lldb] Remove ConstString from GetPluginNameStatic of some plugins

This patch deals with ObjectFile, ObjectContainer and OperatingSystem
plugins. I'll convert the other types in separate patches.

In order to enable piecemeal conversion, I am leaving some ConstStrings
in the lowest PluginManager layers. I'll convert those as the last step.

Differential Revision: https://reviews.llvm.org/D112061

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/API/SBProcess.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h

lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp

lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
lldb/source/Target/OperatingSystem.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 2bee2edea6360..122c63183db27 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -121,7 +121,7 @@ class PluginManager {
   GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
 
   // OperatingSystem
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  OperatingSystemCreateInstance create_callback,
  DebuggerInitializeCallback 
debugger_init_callback);
 
@@ -131,7 +131,7 @@ class PluginManager {
   GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
 
   static OperatingSystemCreateInstance
-  GetOperatingSystemCreateCallbackForPluginName(ConstString name);
+  GetOperatingSystemCreateCallbackForPluginName(llvm::StringRef name);
 
   // Language
   static bool RegisterPlugin(ConstString name, const char *description,
@@ -170,7 +170,7 @@ class PluginManager {
 
   // ObjectFile
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ObjectFileCreateInstance create_callback,
  ObjectFileCreateMemoryInstance create_memory_callback,
  ObjectFileGetModuleSpecifications get_module_specifications,
@@ -188,16 +188,16 @@ class PluginManager {
   GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
 
   static ObjectFileCreateMemoryInstance
-  GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
+  GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name);
 
   static Status SaveCore(const lldb::ProcessSP &process_sp,
  const FileSpec &outfile,
  lldb::SaveCoreStyle &core_style,
- const ConstString plugin_name);
+ llvm::StringRef plugin_name);
 
   // ObjectContainer
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ObjectContainerCreateInstance create_callback,
  ObjectFileGetModuleSpecifications get_module_specifications);
 

diff  --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index acdf75a603160..797e19462800c 100644
--- a/lldb/source/A

[Lldb-commits] [lldb] 6c88086 - [lldb] Fix a thinko in 2ace1e57

2021-10-21 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-21T14:05:49+02:00
New Revision: 6c88086ba8046884bb30a72ae1a8bea95e46f022

URL: 
https://github.com/llvm/llvm-project/commit/6c88086ba8046884bb30a72ae1a8bea95e46f022
DIFF: 
https://github.com/llvm/llvm-project/commit/6c88086ba8046884bb30a72ae1a8bea95e46f022.diff

LOG: [lldb] Fix a thinko in 2ace1e57

An empty plugin name means we should try everything.

Picked up by the windows bot.

Added: 


Modified: 
lldb/source/Core/PluginManager.cpp

Removed: 




diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index d4a4d040ed082..39a412229d5fd 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -701,11 +701,11 @@ Status PluginManager::SaveCore(const lldb::ProcessSP 
&process_sp,
   Status error;
   auto &instances = GetObjectFileInstances().GetInstances();
   for (auto &instance : instances) {
-if (instance.name.GetStringRef() != plugin_name)
-  continue;
-if (instance.save_core &&
-instance.save_core(process_sp, outfile, core_style, error))
-  return error;
+if (plugin_name.empty() || instance.name.GetStringRef() == plugin_name) {
+  if (instance.save_core &&
+  instance.save_core(process_sp, outfile, core_style, error))
+return error;
+}
   }
   error.SetErrorString(
   "no ObjectFile plugins were able to save a core for this process");



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b5e9f83 - [lldb] Remove ConstString from ABI, Architecture and Disassembler plugin names

2021-10-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-22T10:29:19+02:00
New Revision: b5e9f83ea48e29f0fe6d03354303179e5daaec1e

URL: 
https://github.com/llvm/llvm-project/commit/b5e9f83ea48e29f0fe6d03354303179e5daaec1e
DIFF: 
https://github.com/llvm/llvm-project/commit/b5e9f83ea48e29f0fe6d03354303179e5daaec1e.diff

LOG: [lldb] Remove ConstString from ABI, Architecture and Disassembler plugin 
names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Core/Disassembler.cpp
lldb/source/Core/PluginManager.cpp
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
lldb/source/Plugins/ABI/ARC/ABISysV_arc.h
lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.h
lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
lldb/source/Plugins/ABI/ARM/ABISysV_arm.h
lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.h
lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
lldb/source/Plugins/ABI/Mips/ABISysV_mips.h
lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
lldb/source/Plugins/ABI/Mips/ABISysV_mips64.h
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.h
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h
lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.h
lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp
lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
lldb/source/Plugins/ABI/X86/ABISysV_i386.h
lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
lldb/source/Plugins/ABI/X86/ABISysV_x86_64.h
lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.h
lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.h
lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
lldb/source/Plugins/Architecture/Arm/ArchitectureArm.h
lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
lldb/source/Plugins/Architecture/Mips/ArchitectureMips.h
lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 122c63183db27..3c79cd2e6c146 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -54,7 +54,7 @@ class PluginManager {
   static void Terminate();
 
   // ABI
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ABICreateInstance create_callback);
 
   static bool UnregisterPlugin(ABICreateInstance create_callback);
@@ -62,7 +62,7 @@ class PluginManager {
   static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
 
   // Architecture
-  static void RegisterPlugin(ConstString name, llvm::StringRef description,
+  static void RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ArchitectureCreateInstance create_callback);
 
   static void UnregisterPlugin(ArchitectureCreateInstance create_callback);
@@ -71,7 +71,7 @@ class PluginManager {
   CreateArchitectureInstance(const ArchSpec &arch);
 
   // Disassembler
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  DisassemblerCreateInstance create_callback);
 
   static bool UnregisterPlugin(DisassemblerCreateInstance create_callback);
@@ -80,7 +80,7 @@ class PluginManager {
   GetDisassemblerCreateCallbackAtIndex(uint32_t idx);
 
   static DisassemblerCreateInstance
-  GetDisassemblerCreateCallbackForPluginName(ConstString name);
+  GetDisassemblerCreateCallbackForPluginName(llvm::StringRef name);
 
   // DynamicLoader
   static bool

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index d147f8fbb0dba..00d92053bc4f5 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -64,9 +64,8 @@ DisassemblerSP Disassembler::FindPlugin(const ArchSpec &arch,
   DisassemblerCreateInstance create_callback = nullptr;
 
   if (plugin_name) {
-ConstString const_plugin_name(plugin_name);
-create_callback

[Lldb-commits] [lldb] 8b8070e - Host::GetOSBuildString

2021-10-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-22T12:59:58+02:00
New Revision: 8b8070e23442351ae153e36a4d05790252c6ad96

URL: 
https://github.com/llvm/llvm-project/commit/8b8070e23442351ae153e36a4d05790252c6ad96
DIFF: 
https://github.com/llvm/llvm-project/commit/8b8070e23442351ae153e36a4d05790252c6ad96.diff

LOG: Host::GetOSBuildString

Added: 


Modified: 
lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
lldb/include/lldb/Host/linux/HostInfoLinux.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
lldb/include/lldb/Host/windows/HostInfoWindows.h
lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Host/netbsd/HostInfoNetBSD.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/source/Target/Platform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h 
b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index 56f20bbd23d3b..8207e9093f715 100644
--- a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -18,7 +18,7 @@ namespace lldb_private {
 class HostInfoFreeBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };

diff  --git a/lldb/include/lldb/Host/linux/HostInfoLinux.h 
b/lldb/include/lldb/Host/linux/HostInfoLinux.h
index 3220046488677..6287670606643 100644
--- a/lldb/include/lldb/Host/linux/HostInfoLinux.h
+++ b/lldb/include/lldb/Host/linux/HostInfoLinux.h
@@ -26,7 +26,7 @@ class HostInfoLinux : public HostInfoPosix {
   static void Terminate();
 
   static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
   static bool GetOSKernelDescription(std::string &s);
   static llvm::StringRef GetDistributionId();
   static FileSpec GetProgramFileSpec();

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 4623932ab2b4c..42c2872af2182 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -24,7 +24,7 @@ class HostInfoMacOSX : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::VersionTuple GetMacCatalystVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
   static FileSpec GetXcodeContentsDirectory();

diff  --git a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h 
b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
index f9ad66eb2b2af..021f8626733b0 100644
--- a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -18,7 +18,7 @@ namespace lldb_private {
 class HostInfoNetBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };

diff  --git a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h 
b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
index 7ec1d5fc3606d..ba5ac8cbb169f 100644
--- a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
+++ b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -18,7 +18,7 @@ namespace lldb_private {
 class HostInfoOpenBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
   static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };

diff  --git a/lldb/include/lldb/Host/windows/HostInfoWindows.h 
b/lldb/include/lldb/Host/windows/HostInfoWindows.h
index f01113e900493..d7f9e68254c9e 100644
--- a/lldb/include/lldb/Host/windows/HostInfoWindows.h
+++ b/lldb/include/lldb/Host/windows/HostInfoWindows.h
@@ -27,7 +27,7 @@ class HostInfoWindows : public HostInfoBase {
   static UserIDResolver &GetUserIDResolver();
 
   static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
   static bool GetOSKernelDescription(std::string &s);
   static bool GetHostname(std::string &s);
   static FileSpec GetProgramFileSpec();

diff  --git a/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp 
b/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
index 1b9e3ccaf1818..22af5bda66108 100644
--- a/

Re: [Lldb-commits] [lldb] 8b8070e - Host::GetOSBuildString

2021-10-22 Thread Pavel Labath via lldb-commits

For posterity, this was meant to have a slightly better commit message:

"Modernize Host::GetOSBuildString"

Oops.

On 22/10/2021 13:00, Pavel Labath via lldb-commits wrote:


Author: Pavel Labath
Date: 2021-10-22T12:59:58+02:00
New Revision: 8b8070e23442351ae153e36a4d05790252c6ad96

URL: 
https://github.com/llvm/llvm-project/commit/8b8070e23442351ae153e36a4d05790252c6ad96
DIFF: 
https://github.com/llvm/llvm-project/commit/8b8070e23442351ae153e36a4d05790252c6ad96.diff

LOG: Host::GetOSBuildString

Added:
 


Modified:
 lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
 lldb/include/lldb/Host/linux/HostInfoLinux.h
 lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
 lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
 lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
 lldb/include/lldb/Host/windows/HostInfoWindows.h
 lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
 lldb/source/Host/linux/HostInfoLinux.cpp
 lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
 lldb/source/Host/netbsd/HostInfoNetBSD.cpp
 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
 lldb/source/Target/Platform.cpp

Removed:
 




diff  --git a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h 
b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index 56f20bbd23d3b..8207e9093f715 100644
--- a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -18,7 +18,7 @@ namespace lldb_private {
  class HostInfoFreeBSD : public HostInfoPosix {
  public:
static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
  };

diff  --git a/lldb/include/lldb/Host/linux/HostInfoLinux.h 
b/lldb/include/lldb/Host/linux/HostInfoLinux.h
index 3220046488677..6287670606643 100644
--- a/lldb/include/lldb/Host/linux/HostInfoLinux.h
+++ b/lldb/include/lldb/Host/linux/HostInfoLinux.h
@@ -26,7 +26,7 @@ class HostInfoLinux : public HostInfoPosix {
static void Terminate();
  
static llvm::VersionTuple GetOSVersion();

-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
static bool GetOSKernelDescription(std::string &s);
static llvm::StringRef GetDistributionId();
static FileSpec GetProgramFileSpec();

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 4623932ab2b4c..42c2872af2182 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -24,7 +24,7 @@ class HostInfoMacOSX : public HostInfoPosix {
  public:
static llvm::VersionTuple GetOSVersion();
static llvm::VersionTuple GetMacCatalystVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
static FileSpec GetXcodeContentsDirectory();

diff  --git a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h 
b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
index f9ad66eb2b2af..021f8626733b0 100644
--- a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -18,7 +18,7 @@ namespace lldb_private {
  class HostInfoNetBSD : public HostInfoPosix {
  public:
static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
  };

diff  --git a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h 
b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
index 7ec1d5fc3606d..ba5ac8cbb169f 100644
--- a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
+++ b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -18,7 +18,7 @@ namespace lldb_private {
  class HostInfoOpenBSD : public HostInfoPosix {
  public:
static llvm::VersionTuple GetOSVersion();
-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
  };

diff  --git a/lldb/include/lldb/Host/windows/HostInfoWindows.h 
b/lldb/include/lldb/Host/windows/HostInfoWindows.h
index f01113e900493..d7f9e68254c9e 100644
--- a/lldb/include/lldb/Host/windows/HostInfoWindows.h
+++ b/lldb/include/lldb/Host/windows/HostInfoWindows.h
@@ -27,7 +27,7 @@ class HostInfoWindows : public HostInfoBase {
static UserIDResolver &GetUserIDResolver();
  
static llvm::VersionTuple GetOSVersion();

-  static bool GetOSBuildString(std::string &s);
+  static llvm::Optional GetOSBuildString();
static bo

[Lldb-commits] [lldb] 43f8845 - [lldb] Fix build errors from 8b8070e23

2021-10-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-22T14:28:52+02:00
New Revision: 43f8845dd371a842841a19aad063b735ff0c9ec2

URL: 
https://github.com/llvm/llvm-project/commit/43f8845dd371a842841a19aad063b735ff0c9ec2
DIFF: 
https://github.com/llvm/llvm-project/commit/43f8845dd371a842841a19aad063b735ff0c9ec2.diff

LOG: [lldb] Fix build errors from 8b8070e23

I missed windows and openbsd.

Added: 


Modified: 
lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
lldb/source/Host/windows/HostInfoWindows.cpp

Removed: 




diff  --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp 
b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 9617375babe1f..18ffa381fbb4e 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -29,20 +29,16 @@ llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
   return llvm::VersionTuple();
 }
 
-bool HostInfoOpenBSD::GetOSBuildString(std::string &s) {
+llvm::Optional HostInfoOpenBSD::GetOSBuildString() {
   int mib[2] = {CTL_KERN, KERN_OSREV};
   char osrev_str[12];
   uint32_t osrev = 0;
   size_t osrev_len = sizeof(osrev);
 
-  if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0) {
-::snprintf(osrev_str, sizeof(osrev_str), "%-8.8u", osrev);
-s.assign(osrev_str);
-return true;
-  }
+  if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0)
+return llvm::formatv("{0,8:8}", osrev).str();
 
-  s.clear();
-  return false;
+  return llvm::None;
 }
 
 bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {

diff  --git a/lldb/source/Host/windows/HostInfoWindows.cpp 
b/lldb/source/Host/windows/HostInfoWindows.cpp
index 54a07b71b2cdf..1e6ce0ce5b2df 100644
--- a/lldb/source/Host/windows/HostInfoWindows.cpp
+++ b/lldb/source/Host/windows/HostInfoWindows.cpp
@@ -74,19 +74,18 @@ llvm::VersionTuple HostInfoWindows::GetOSVersion() {
 info.wServicePackMajor);
 }
 
-bool HostInfoWindows::GetOSBuildString(std::string &s) {
-  s.clear();
+llvm::Optional HostInfoWindows::GetOSBuildString() {
   llvm::VersionTuple version = GetOSVersion();
   if (version.empty())
-return false;
+return llvm::None;
 
-  llvm::raw_string_ostream stream(s);
-  stream << "Windows NT " << version.getAsString();
-  return true;
+  return "Windows NT " + version.getAsString();
 }
 
 bool HostInfoWindows::GetOSKernelDescription(std::string &s) {
-  return GetOSBuildString(s);
+  llvm::Optional build = GetOSBuildString();
+  s = build.getValueOr("");
+  return build.hasValue();
 }
 
 bool HostInfoWindows::GetHostname(std::string &s) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f37463b - [lldb] Another build fix for 8b8070e23

2021-10-22 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-22T15:29:38+02:00
New Revision: f37463b2eef66dfae3ed669d1cbb2a34b643d071

URL: 
https://github.com/llvm/llvm-project/commit/f37463b2eef66dfae3ed669d1cbb2a34b643d071
DIFF: 
https://github.com/llvm/llvm-project/commit/f37463b2eef66dfae3ed669d1cbb2a34b643d071.diff

LOG: [lldb] Another build fix for 8b8070e23

This particular usage was guarded by !__linux__, so it broke everywhere
else. It should probably be replaced by something else.

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
index 3e31b1274597d..ea93d9944879c 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
@@ -161,7 +161,7 @@ lldb_private::Status PlatformRemoteMacOSX::GetFileWithUUID(
   if (m_remote_platform_sp) {
 std::string local_os_build;
 #if !defined(__linux__)
-HostInfo::GetOSBuildString(local_os_build);
+local_os_build = HostInfo::GetOSBuildString().getValueOr("");
 #endif
 std::string remote_os_build;
 m_remote_platform_sp->GetOSBuildString(remote_os_build);



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c1055f0 - [lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T10:32:35+02:00
New Revision: c1055f09190856ae58c9a075b4103d77623228ee

URL: 
https://github.com/llvm/llvm-project/commit/c1055f09190856ae58c9a075b4103d77623228ee
DIFF: 
https://github.com/llvm/llvm-project/commit/c1055f09190856ae58c9a075b4103d77623228ee.diff

LOG: [lldb/DWARF] Don't create lldb_private::Functions for gc'ed 
DW_TAG_subprograms

Front-load the first_valid_code_address check, so that we avoid creating
the function object (instead of simply refusing to use it in queries).

Differential Revision: https://reviews.llvm.org/D112310

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/dead-code-filtering.yaml

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index ffe24836955fa..00123a4b92160 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -32,7 +32,8 @@ class DWARFASTParser {
 
   virtual lldb_private::Function *
   ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit,
- const DWARFDIE &die) = 0;
+ const DWARFDIE &die,
+ const lldb_private::AddressRange &range) = 0;
 
   virtual bool
   CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index ec560f3fdd69d..a240784c942b0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2342,8 +2342,11 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
   return enumerators_added;
 }
 
-Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
-  const DWARFDIE &die) {
+Function *
+DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
+const DWARFDIE &die,
+const AddressRange &func_range) {
+  assert(func_range.GetBaseAddress().IsValid());
   DWARFRangeList func_ranges;
   const char *name = nullptr;
   const char *mangled = nullptr;
@@ -2363,94 +2366,75 @@ Function 
*DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
   if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, 
decl_line,
decl_column, call_file, call_line, call_column,
&frame_base)) {
+Mangled func_name;
+if (mangled)
+  func_name.SetValue(ConstString(mangled), true);
+else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
+  die.GetParent().Tag() == DW_TAG_partial_unit) &&
+ Language::LanguageIsCPlusPlus(
+ SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+ !Language::LanguageIsObjC(
+ SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+ name && strcmp(name, "main") != 0) {
+  // If the mangled name is not present in the DWARF, generate the
+  // demangled name using the decl context. We skip if the function is
+  // "main" as its name is never mangled.
+  bool is_static = false;
+  bool is_variadic = false;
+  bool has_template_params = false;
+  unsigned type_quals = 0;
+  std::vector param_types;
+  std::vector param_decls;
+  StreamString sstr;
+
+  DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+  sstr << decl_ctx.GetQualifiedName();
 
-// Union of all ranges in the function DIE (if the function is
-// discontiguous)
-AddressRange func_range;
-lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
-lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
-if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
-lowest_func_addr <= highest_func_addr) {
-  ModuleSP module_sp(die.GetModule());
-  func_range.GetBaseAddress().ResolveAddressUsingFileSections(
-  lowest_func_addr, module_sp->GetSectionList());
-  if (func_range.GetBaseAddress().IsValid())
-func_range.SetByteSize(highest_func_addr - lowest_func_addr);
-}
-
-if (func_range.GetBaseAddress().IsValid()) {
-  Mangled func_name;
-  if (mangled)
-func_name.SetValue(ConstString(mangled), true);
-  else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
-die.GetParent().Tag() == DW_TAG_partial_unit) &&
-   Language::Langu

[Lldb-commits] [lldb] 6fa1b4f - Remove ConstString from DynamicLoader, JITLoader and Instruction plugin names

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T10:32:35+02:00
New Revision: 6fa1b4ff4b05b9b9a432f7310802255c160c8f4f

URL: 
https://github.com/llvm/llvm-project/commit/6fa1b4ff4b05b9b9a432f7310802255c160c8f4f
DIFF: 
https://github.com/llvm/llvm-project/commit/6fa1b4ff4b05b9b9a432f7310802255c160c8f4f.diff

LOG: Remove ConstString from DynamicLoader, JITLoader and Instruction plugin 
names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Target/DynamicLoader.h
lldb/source/Core/DynamicLoader.cpp
lldb/source/Core/EmulateInstruction.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 3c79cd2e6c146..97f8dae1bcfd2 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -84,7 +84,7 @@ class PluginManager {
 
   // DynamicLoader
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  DynamicLoaderCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -94,11 +94,11 @@ class PluginManager {
   GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
 
   static DynamicLoaderCreateInstance
-  GetDynamicLoaderCreateCallbackForPluginName(ConstString name);
+  GetDynamicLoaderCreateCallbackForPluginName(llvm::StringRef name);
 
   // JITLoader
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  JITLoaderCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -108,7 +108,7 @@ class PluginManager {
   GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
 
   // EmulateInstruction
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  EmulateInstructionCreateInstance create_callback);
 
   static bool
@@ -118,7 +118,7 @@ class PluginManager {
   GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
 
   static EmulateInstructionCreateInstance
-  GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
+  GetEmulateInstructionCreateCallbackForPluginName(llvm::StringRef name);
 
   // OperatingSystem
   static bool RegisterPlugin(llv

[Lldb-commits] [lldb] 1397c56 - Fix windows build for 6fa1b4ff4

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T11:12:39+02:00
New Revision: 1397c56d7ae844033d8ba9b7dee2b1b30a6b37c0

URL: 
https://github.com/llvm/llvm-project/commit/1397c56d7ae844033d8ba9b7dee2b1b30a6b37c0
DIFF: 
https://github.com/llvm/llvm-project/commit/1397c56d7ae844033d8ba9b7dee2b1b30a6b37c0.diff

LOG: Fix windows build for 6fa1b4ff4

Added: 


Modified: 
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 0952e2da289e0..7990079170a61 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -624,7 +624,7 @@ lldb::addr_t ProcessWindows::GetImageInfoAddress() {
 DynamicLoaderWindowsDYLD *ProcessWindows::GetDynamicLoader() {
   if (m_dyld_up.get() == NULL)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
-this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
+this, DynamicLoaderWindowsDYLD::GetPluginNameStatic()));
   return static_cast(m_dyld_up.get());
 }
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 40e4ac3 - [lldb] Modernize Platform::GetOSBuildString

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T15:58:58+02:00
New Revision: 40e4ac3e5b3548aa77367da37aba52f2556b855e

URL: 
https://github.com/llvm/llvm-project/commit/40e4ac3e5b3548aa77367da37aba52f2556b855e
DIFF: 
https://github.com/llvm/llvm-project/commit/40e4ac3e5b3548aa77367da37aba52f2556b855e.diff

LOG: [lldb] Modernize Platform::GetOSBuildString

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/RemoteAwarePlatform.h
lldb/source/API/SBPlatform.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Target/Platform.cpp
lldb/source/Target/RemoteAwarePlatform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 7cb534afe6ecc..d1351d5c729b4 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -212,7 +212,7 @@ class Platform : public PluginInterface {
 
   bool SetOSVersion(llvm::VersionTuple os_version);
 
-  bool GetOSBuildString(std::string &s);
+  llvm::Optional GetOSBuildString();
 
   bool GetOSKernelDescription(std::string &s);
 
@@ -240,9 +240,8 @@ class Platform : public PluginInterface {
   // HostInfo::GetOSVersion().
   virtual bool GetRemoteOSVersion() { return false; }
 
-  virtual bool GetRemoteOSBuildString(std::string &s) {
-s.clear();
-return false;
+  virtual llvm::Optional GetRemoteOSBuildString() {
+return llvm::None;
   }
 
   virtual bool GetRemoteOSKernelDescription(std::string &s) {

diff  --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h 
b/lldb/include/lldb/Target/RemoteAwarePlatform.h
index 269d152998897..d8f7720d2fd96 100644
--- a/lldb/include/lldb/Target/RemoteAwarePlatform.h
+++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h
@@ -64,7 +64,7 @@ class RemoteAwarePlatform : public Platform {
  FileSpec &local_file) override;
 
   bool GetRemoteOSVersion() override;
-  bool GetRemoteOSBuildString(std::string &s) override;
+  llvm::Optional GetRemoteOSBuildString() override;
   bool GetRemoteOSKernelDescription(std::string &s) override;
   ArchSpec GetRemoteSystemArchitecture() override;
 

diff  --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 496c40a0678fe..71d6b1c41e32f 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -458,13 +458,11 @@ const char *SBPlatform::GetOSBuild() {
 
   PlatformSP platform_sp(GetSP());
   if (platform_sp) {
-std::string s;
-if (platform_sp->GetOSBuildString(s)) {
-  if (!s.empty()) {
-// Const-ify the string so we don't need to worry about the lifetime of
-// the string
-return ConstString(s.c_str()).GetCString();
-  }
+std::string s = platform_sp->GetOSBuildString().getValueOr("");
+if (!s.empty()) {
+  // Const-ify the string so we don't need to worry about the lifetime of
+  // the string
+  return ConstString(s).GetCString();
 }
   }
   return nullptr;

diff  --git 
a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
index 236eacebf7148..97b2b4a3b7401 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
@@ -630,13 +630,12 @@ Status PlatformRemoteDarwinDevice::GetSharedModule(
 uint32_t PlatformRemoteDarwinDevice::GetConnectedSDKIndex() {
   if (IsConnected()) {
 if (m_connected_module_sdk_idx == UINT32_MAX) {
-  std::string build;
-  if (GetRemoteOSBuildString(build)) {
+  if (llvm::Optional build = GetRemoteOSBuildString()) {
 const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
 for (uint32_t i = 0; i < num_sdk_infos; ++i) {
   const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
   if (strstr(sdk_dir_info.directory.GetFilename().AsCString(""),
- build.c_str())) {
+ build->c_str())) {
 m_connected_module_sdk_idx = i;
   }
 }

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
index ea93d9944879c..c654f3c4264f9 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
@@ -163,8 +163,8 @@ lldb_private::Status PlatformRemoteMacOSX::GetFileWithUUID(
 #if !defined(__linux__)
 local_

[Lldb-commits] [lldb] a53978c - [lldb] Remove a trailing \0 from the result of HostInfoMacOSX::GetOSBuildString

2021-10-25 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-25T17:33:06+02:00
New Revision: a53978c95c46a8bef563058fa35a688f8cbaaf88

URL: 
https://github.com/llvm/llvm-project/commit/a53978c95c46a8bef563058fa35a688f8cbaaf88
DIFF: 
https://github.com/llvm/llvm-project/commit/a53978c95c46a8bef563058fa35a688f8cbaaf88.diff

LOG: [lldb] Remove a trailing \0 from the result of 
HostInfoMacOSX::GetOSBuildString

This has been in there since forever, but only started to matter once
40e4ac3e changed how we print the string.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index e32cfb0aade0..5f141b08e866 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -60,7 +60,7 @@
   char cstr[PATH_MAX];
   size_t cstr_len = sizeof(cstr);
   if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0)
-return std::string(cstr, cstr_len);
+return std::string(cstr, cstr_len - 1);
 
   return llvm::None;
 }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b69564d - [lldb/DWARF] Move a declaration closer to its use

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T09:58:10+02:00
New Revision: b69564d94d90b83ccdcc501f811959c23aeec52a

URL: 
https://github.com/llvm/llvm-project/commit/b69564d94d90b83ccdcc501f811959c23aeec52a
DIFF: 
https://github.com/llvm/llvm-project/commit/b69564d94d90b83ccdcc501f811959c23aeec52a.diff

LOG: [lldb/DWARF] Move a declaration closer to its use

Adresses post-commit feedback on D112310.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ad5b44365054a..f8715398a052e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -863,7 +863,6 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit 
&comp_unit,
 
   // Union of all ranges in the function DIE (if the function is
   // discontiguous)
-  AddressRange func_range;
   lldb::addr_t lowest_func_addr = ranges.GetMinRangeBase(0);
   lldb::addr_t highest_func_addr = ranges.GetMaxRangeEnd(0);
   if (lowest_func_addr == LLDB_INVALID_ADDRESS ||
@@ -872,6 +871,7 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit 
&comp_unit,
 return nullptr;
 
   ModuleSP module_sp(die.GetModule());
+  AddressRange func_range;
   func_range.GetBaseAddress().ResolveAddressUsingFileSections(
   lowest_func_addr, module_sp->GetSectionList());
   if (!func_range.GetBaseAddress().IsValid())



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a458ef4 - [lldb] Remove ConstString from Platform plugin names

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T10:04:35+02:00
New Revision: a458ef4f732b27312d8a5d20d2843d8bff35daeb

URL: 
https://github.com/llvm/llvm-project/commit/a458ef4f732b27312d8a5d20d2843d8bff35daeb
DIFF: 
https://github.com/llvm/llvm-project/commit/a458ef4f732b27312d8a5d20d2843d8bff35daeb.diff

LOG: [lldb] Remove ConstString from Platform plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Target/Platform.h
lldb/source/API/SBDebugger.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.h
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Platform.cpp
lldb/unittests/Target/RemoteAwarePlatformTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 97f8dae1bcfd2..aa51069cf4539 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -211,7 +211,7 @@ class PluginManager {
 
   // Platform
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  PlatformCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -220,11 +220,11 @@ class PluginManager {
   static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
 
   static PlatformCreateInstance
-  GetPlatformCreateCallbackForPluginName(ConstString name);
+  GetPlatformCreateCallbackForPluginName(llvm::StringRef name);
 
-  static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
+  static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx);
 
-  static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx);
+  static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx);
 
   static void AutoCompletePlatformName(llvm::StringRef partial_name,
CompletionRequest &request);

diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index d1351d5c729b4..adf6d865ab184 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -223,7 +223,7 @@ class Platform : public PluginInterface {
 
   virtual ConstString GetFullNameForDylib(ConstString basename);
 
-  virtual const char *GetDescription() = 0;
+  virtual llvm::StringRef GetDescription() = 0;
 
   /// Report the current status for this platform.
   ///

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index d044061fb0e40..c22662d764a7f 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1114,7 +1114,7 @@ uint32_t SBDebugger::GetNumAvailablePlatforms() {
 
   uint32_t idx = 0;
   while (true) {
-if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) {
+if (PluginManager::GetPlatformPluginNameAtIndex(i

[Lldb-commits] [lldb] 0a39a9c - Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T11:17:02+02:00
New Revision: 0a39a9c2cb43f93c82908cabdf73fdd4918a26e5

URL: 
https://github.com/llvm/llvm-project/commit/0a39a9c2cb43f93c82908cabdf73fdd4918a26e5
DIFF: 
https://github.com/llvm/llvm-project/commit/0a39a9c2cb43f93c82908cabdf73fdd4918a26e5.diff

LOG: Modernize and simplify HostInfo::GetOSKernelDescription

Replace bool+by-ref argument with llvm::Optional, and move the common
implementation into HostInfoPOSIX. Based on my (simple) experiment,
the uname and the sysctl approach return the same value on MacOS, so
there's no need for a mac-specific implementation of this functionality.

Differential Revision: https://reviews.llvm.org/D112457

Added: 


Modified: 
lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
lldb/include/lldb/Host/linux/HostInfoLinux.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
lldb/include/lldb/Host/posix/HostInfoPosix.h
lldb/include/lldb/Host/windows/HostInfoWindows.h
lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Host/netbsd/HostInfoNetBSD.cpp
lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
lldb/source/Host/posix/HostInfoPosix.cpp
lldb/source/Host/windows/HostInfoWindows.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/source/Target/Platform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h 
b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index 8207e9093f71..b2f3f08cd145 100644
--- a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -19,7 +19,6 @@ class HostInfoFreeBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };
 }

diff  --git a/lldb/include/lldb/Host/linux/HostInfoLinux.h 
b/lldb/include/lldb/Host/linux/HostInfoLinux.h
index 628767060664..e2167b8a883d 100644
--- a/lldb/include/lldb/Host/linux/HostInfoLinux.h
+++ b/lldb/include/lldb/Host/linux/HostInfoLinux.h
@@ -27,7 +27,6 @@ class HostInfoLinux : public HostInfoPosix {
 
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static llvm::StringRef GetDistributionId();
   static FileSpec GetProgramFileSpec();
 

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 42c2872af218..de7ecc1e6d80 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -25,7 +25,6 @@ class HostInfoMacOSX : public HostInfoPosix {
   static llvm::VersionTuple GetOSVersion();
   static llvm::VersionTuple GetMacCatalystVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
   static FileSpec GetXcodeContentsDirectory();
   static FileSpec GetXcodeDeveloperDirectory();

diff  --git a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h 
b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
index 021f8626733b..32644ce79a69 100644
--- a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -19,7 +19,6 @@ class HostInfoNetBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };
 }

diff  --git a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h 
b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
index ba5ac8cbb169..01879ad5c0e4 100644
--- a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
+++ b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -19,7 +19,6 @@ class HostInfoOpenBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };
 }

diff  --git a/lldb/include/lldb/Host/posix/HostInfoPosix.h 
b/lldb/include/lldb/Host/posix/HostInfoPosix.h
index 825c79f53ecb..f1ff6b860864 100644
--- a/lldb/include/lldb/Host/posix/HostInfoPosix.h
+++ b/lldb/include/lldb/Host/posix/HostInfoPosix.h
@@ -22,6 +22,7 @@ class HostInfoPosix : public HostInfoBase {
 public:
   static size_t GetPageSize();
   static bool GetHostname(std::string &s);
+  static llvm::Optional GetOSKernelDescription();
 
   static uint32_t GetUserID();
   static uint32_t GetGroupID();

diff  --git a/lldb/include/lldb/Host/windows/Ho

[Lldb-commits] [lldb] 93c7ed8 - [lldb] Fix PlatformAppleSimulator for a458ef4f

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T13:03:47+02:00
New Revision: 93c7ed8c3f8e2b2966e565758d0992ec1b07a11f

URL: 
https://github.com/llvm/llvm-project/commit/93c7ed8c3f8e2b2966e565758d0992ec1b07a11f
DIFF: 
https://github.com/llvm/llvm-project/commit/93c7ed8c3f8e2b2966e565758d0992ec1b07a11f.diff

LOG: [lldb] Fix PlatformAppleSimulator for a458ef4f

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index c9c275caaeba..69692ddc77c4 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -529,8 +529,7 @@ static const char *g_ios_description = "iPhone simulator 
platform plug-in.";
 /// IPhone Simulator Plugin.
 struct PlatformiOSSimulator {
   static void Initialize() {
-PluginManager::RegisterPlugin(ConstString(g_ios_plugin_name),
-  g_ios_description,
+PluginManager::RegisterPlugin(g_ios_plugin_name, g_ios_description,
   PlatformiOSSimulator::CreateInstance);
   }
 
@@ -579,8 +578,7 @@ static const char *g_tvos_description = "tvOS simulator 
platform plug-in.";
 /// Apple TV Simulator Plugin.
 struct PlatformAppleTVSimulator {
   static void Initialize() {
-PluginManager::RegisterPlugin(ConstString(g_tvos_plugin_name),
-  g_tvos_description,
+PluginManager::RegisterPlugin(g_tvos_plugin_name, g_tvos_description,
   PlatformAppleTVSimulator::CreateInstance);
   }
 
@@ -621,8 +619,7 @@ static const char *g_watchos_description =
 /// Apple Watch Simulator Plugin.
 struct PlatformAppleWatchSimulator {
   static void Initialize() {
-PluginManager::RegisterPlugin(ConstString(g_watchos_plugin_name),
-  g_watchos_description,
+PluginManager::RegisterPlugin(g_watchos_plugin_name, g_watchos_description,
   PlatformAppleWatchSimulator::CreateInstance);
   }
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 49481b5 - Remove ConstString from Language, LanguageRuntime, SystemRuntime and SymbolFile plugin names

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-27T08:25:44+02:00
New Revision: 49481b538065a0ba5ba1d7cc901eeceb8bf344c0

URL: 
https://github.com/llvm/llvm-project/commit/49481b538065a0ba5ba1d7cc901eeceb8bf344c0
DIFF: 
https://github.com/llvm/llvm-project/commit/49481b538065a0ba5ba1d7cc901eeceb8bf344c0.diff

LOG: Remove ConstString from Language, LanguageRuntime, SystemRuntime and 
SymbolFile plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Core/PluginManager.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index aa51069cf4539..e027968c1b4d4 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -134,7 +134,7 @@ class PluginManager {
   GetOperatingSystemCreateCallbackForPluginName(llvm::StringRef name);
 
   // Language
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  LanguageCreateInstance create_callback);
 
   static bool UnregisterPlugin(LanguageCreateInstance create_callback);
@@ -143,7 +143,7 @@ class PluginManager {
 
   // LanguageRuntime
   static bool RegisterPlugin(
-  ConstString name, const char *description,
+  llvm::StringRef name, llvm::StringRef description,
   LanguageRuntimeCreateInstance create_callback,
   LanguageRuntimeGetCommandObject command_callback = nullptr,
   LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr);
@@ -160,7 +160,7 @@ class PluginManager {
   GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
 
   // SystemRuntime
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  SystemRuntimeCreateInstance create_callback);
 
   static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
@@ -314,7 +314,7 @@ class PluginManager {
 
   // SymbolFile
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  SymbolFileCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 

diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index fdf2aa7da4b32..db603c1160902 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -514,10 +514,11 @@ static LanguageInstances &GetLanguageInstances() {
   return g_instances;
 }
 
-bool PluginManager::RegisterPlugin(ConstString name, const char *description,
+bool PluginManager::RegisterPlugin(llvm:

[Lldb-commits] [lldb] f5158ca - Modernize Platform::GetOSKernelDescription

2021-10-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-27T10:46:47+02:00
New Revision: f5158ca48c260dd29136ab19ba8573226f087fb3

URL: 
https://github.com/llvm/llvm-project/commit/f5158ca48c260dd29136ab19ba8573226f087fb3
DIFF: 
https://github.com/llvm/llvm-project/commit/f5158ca48c260dd29136ab19ba8573226f087fb3.diff

LOG: Modernize Platform::GetOSKernelDescription

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/RemoteAwarePlatform.h
lldb/source/API/SBPlatform.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Target/Platform.cpp
lldb/source/Target/RemoteAwarePlatform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index adf6d865ab184..1106ce868761c 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -214,7 +214,7 @@ class Platform : public PluginInterface {
 
   llvm::Optional GetOSBuildString();
 
-  bool GetOSKernelDescription(std::string &s);
+  llvm::Optional GetOSKernelDescription();
 
   // Returns the name of the platform
   ConstString GetName();
@@ -244,9 +244,8 @@ class Platform : public PluginInterface {
 return llvm::None;
   }
 
-  virtual bool GetRemoteOSKernelDescription(std::string &s) {
-s.clear();
-return false;
+  virtual llvm::Optional GetRemoteOSKernelDescription() {
+return llvm::None;
   }
 
   // Remote Platform subclasses need to override this function

diff  --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h 
b/lldb/include/lldb/Target/RemoteAwarePlatform.h
index d8f7720d2fd96..f2a4ffae2aae3 100644
--- a/lldb/include/lldb/Target/RemoteAwarePlatform.h
+++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h
@@ -65,7 +65,7 @@ class RemoteAwarePlatform : public Platform {
 
   bool GetRemoteOSVersion() override;
   llvm::Optional GetRemoteOSBuildString() override;
-  bool GetRemoteOSKernelDescription(std::string &s) override;
+  llvm::Optional GetRemoteOSKernelDescription() override;
   ArchSpec GetRemoteSystemArchitecture() override;
 
   Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir,

diff  --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 71d6b1c41e32f..d7a86f0ad1ddc 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -473,13 +473,11 @@ const char *SBPlatform::GetOSDescription() {
 
   PlatformSP platform_sp(GetSP());
   if (platform_sp) {
-std::string s;
-if (platform_sp->GetOSKernelDescription(s)) {
-  if (!s.empty()) {
-// Const-ify the string so we don't need to worry about the lifetime of
-// the string
-return ConstString(s.c_str()).GetCString();
-  }
+std::string s = platform_sp->GetOSKernelDescription().getValueOr("");
+if (!s.empty()) {
+  // Const-ify the string so we don't need to worry about the lifetime of
+  // the string
+  return ConstString(s.c_str()).GetCString();
 }
   }
   return nullptr;

diff  --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 851d6291591a8..d0a8fc4ebf381 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -240,8 +240,9 @@ llvm::Optional 
PlatformRemoteGDBServer::GetRemoteOSBuildString() {
   return m_gdb_client.GetOSBuildString();
 }
 
-bool PlatformRemoteGDBServer::GetRemoteOSKernelDescription(std::string &s) {
-  return m_gdb_client.GetOSKernelDescription(s);
+llvm::Optional
+PlatformRemoteGDBServer::GetRemoteOSKernelDescription() {
+  return m_gdb_client.GetOSKernelDescription();
 }
 
 // Remote Platform subclasses need to override this function

diff  --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index b5e52e0219828..f3d7ef17ccabb 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -79,7 +79,7 @@ class PlatformRemoteGDBServer : public Platform, private 
UserIDResolver {
 
   llvm::Optional GetRemoteOSBuildString() override;
 
-  bool GetRemoteOSKernelDescription(std::string &s) override;
+  llvm::Optional GetRemoteOSKernelDescription() override;
 
   // Remote Platform subclasses need to override this function
   ArchSpec GetRemoteSystemArchitecture() override;

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemote

[Lldb-commits] [lldb] 560221a - [lldb] Modernize TestVLA.py

2021-10-27 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-27T12:47:56+02:00
New Revision: 560221ac7f5ca3d5dcae405587db066f4c4c8a7c

URL: 
https://github.com/llvm/llvm-project/commit/560221ac7f5ca3d5dcae405587db066f4c4c8a7c
DIFF: 
https://github.com/llvm/llvm-project/commit/560221ac7f5ca3d5dcae405587db066f4c4c8a7c.diff

LOG: [lldb] Modernize TestVLA.py

Use expect_expr/var_path instead of regular expect and substring checks

Added: 


Modified: 
lldb/test/API/lang/c/vla/TestVLA.py

Removed: 




diff  --git a/lldb/test/API/lang/c/vla/TestVLA.py 
b/lldb/test/API/lang/c/vla/TestVLA.py
index 215eadc41a739..758406d72e635 100644
--- a/lldb/test/API/lang/c/vla/TestVLA.py
+++ b/lldb/test/API/lang/c/vla/TestVLA.py
@@ -32,14 +32,19 @@ def test_vla(self):
 _, process, _, _ = lldbutil.run_to_source_breakpoint(
 self, "break here", lldb.SBFileSpec('main.c'))
 
-def test(a, array):
+def test(a):
+children = []
 for i in range(a):
-self.expect("fr v vla[%d]"%i, substrs=["int", "%d"%(a-i)])
-self.expect("expr vla[%d]"%i, substrs=["int", "%d"%(a-i)])
-self.expect("fr v vla", substrs=array)
+name = "[%d]"%i
+value = str(a-i)
+self.expect_var_path("vla"+name, type="int", value=value)
+self.expect_expr("vla"+name, result_type="int",
+result_value=value)
+children.append(ValueCheck(name=name, value=value))
+self.expect_var_path("vla", type="int[]", children=children)
 self.expect("expr vla", error=True, substrs=["incomplete"])
 
-test(2, ["int[]", "[0] = 2, [1] = 1"])
+test(2)
 process.Continue()
-test(4, ["int[]", "[0] = 4, [1] = 3, [2] = 2, [3] = 1"])
+test(4)
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5f4980f - [lldb] Remove ConstString from Process, ScriptInterpreter and StructuredData plugin names

2021-10-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-28T10:15:03+02:00
New Revision: 5f4980f004f052367b947ff3aa6cc142cea1c23f

URL: 
https://github.com/llvm/llvm-project/commit/5f4980f004f052367b947ff3aa6cc142cea1c23f
DIFF: 
https://github.com/llvm/llvm-project/commit/5f4980f004f052367b947ff3aa6cc142cea1c23f.diff

LOG: [lldb] Remove ConstString from Process, ScriptInterpreter and 
StructuredData plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Target/ProcessTrace.h
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Core/PluginManager.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
lldb/source/Target/Process.cpp
lldb/source/Target/ProcessTrace.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index e027968c1b4d4..dffceb93ebc63 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -230,7 +230,7 @@ class PluginManager {
CompletionRequest &request);
   // Process
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  ProcessCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -239,17 +239,17 @@ class PluginManager {
   static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx);
 
   static ProcessCreateInstance
-  GetProcessCreateCallbackForPluginName(ConstString name);
+  GetProcessCreateCallbackForPluginName(llvm::StringRef name);
 
-  static const char *GetProcessPluginNameAtIndex(uint32_t idx);
+  static llvm::StringRef GetProcessPluginNameAtIndex(uint32_t idx);
 
-  static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx);
+  static llvm::StringRef GetProcessPluginDescriptionAtIndex(uint32_t idx);
 
   static void AutoCompleteProcessName(llvm::StringRef partial_name,
   CompletionRequest &request);
 
   // ScriptInterpreter
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  lldb::ScriptLanguage script_lang,
  ScriptInterpreterCreateInstance create_callback);
 
@@ -297,7 +297,7 @@ class PluginManager {
   /// \return
   ///Returns true upon success; otherwise, false.
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  StructuredDataPluginCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr,
  StructuredDataFilterLaunchInfo filter_callback = nullptr);

diff  --git a/lldb/include/lldb/Target/ProcessTrace.h 
b/lldb/include/lldb/Target/ProcessTrace.h
index 8fa7928910d7d..037dea232cc02 100644
--- a/lldb/include/lldb/Target/ProcessTrace.h
+++ b/lldb/include/lldb/Target/ProcessTrace.h
@@ -23,9 +23,9 @@ class ProcessTrace : public PostMortemProcess {
 
   static void Terminate();
 
-  static ConstString GetPluginNameStatic();
+  static llvm::StringRef GetPluginNameStatic() { return "trace"; }
 
-  static const char *GetPluginDescriptionStatic();
+  static llvm::StringRef GetPluginDescriptionStatic();
 
   Pr

[Lldb-commits] [lldb] 349295f - [lldb/test] Allow indentation in inline tests

2021-10-28 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-28T14:39:02+02:00
New Revision: 349295fcf37ed1ff1ea98c18ea1b391741823916

URL: 
https://github.com/llvm/llvm-project/commit/349295fcf37ed1ff1ea98c18ea1b391741823916
DIFF: 
https://github.com/llvm/llvm-project/commit/349295fcf37ed1ff1ea98c18ea1b391741823916.diff

LOG: [lldb/test] Allow indentation in inline tests

This makes it possible to use for loops (and other language constructs)
in inline tests.

Differential Revision: https://reviews.llvm.org/D112706

Added: 
lldb/test/API/test_utils/TestInlineTest.py

Modified: 
lldb/packages/Python/lldbsuite/test/lldbinline.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbinline.py 
b/lldb/packages/Python/lldbsuite/test/lldbinline.py
index 0d1cb24a54dfd..e8d4d4d62c1f6 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -3,6 +3,7 @@
 
 # System modules
 import os
+import textwrap
 
 # Third-party modules
 import io
@@ -38,7 +39,7 @@ def parse_one_command(self, line):
 new_breakpoint = True
 
 if len(parts) == 2:
-command = parts[1].strip()  # take off whitespace
+command = parts[1].rstrip()
 new_breakpoint = parts[0].strip() != ""
 
 return (command, new_breakpoint)
@@ -68,6 +69,8 @@ def parse_source_files(self, source_files):
 else:
 current_breakpoint['command'] = current_breakpoint[
 'command'] + "\n" + command
+for bkpt in self.breakpoints:
+bkpt['command'] = textwrap.dedent(bkpt['command'])
 
 def set_breakpoints(self, target):
 for breakpoint in self.breakpoints:

diff  --git a/lldb/test/API/test_utils/TestInlineTest.py 
b/lldb/test/API/test_utils/TestInlineTest.py
new file mode 100644
index 0..21a3e2fd4bf2a
--- /dev/null
+++ b/lldb/test/API/test_utils/TestInlineTest.py
@@ -0,0 +1,33 @@
+from lldbsuite.test.lldbinline import CommandParser
+from lldbsuite.test.lldbtest import Base
+import textwrap
+
+
+class TestCommandParser(Base):
+
+mydir = Base.compute_mydir(__file__)
+
+def test_indentation(self):
+"""Test indentation handling"""
+filename = self.getBuildArtifact("test_file.cpp")
+with open(filename, "w") as f:
+f.write(textwrap.dedent("""\
+int q;
+int w; //% first break
+int e;
+int r; //% second break
+//% continue second
+//%   continuing indented
+  //% not indented
+int t; //% third break
+"""))
+p = CommandParser()
+p.parse_source_files([filename])
+
+def bkpt(line, cmd):
+return {'file_name': filename, 'line_number': line, 'command': cmd}
+self.assertEqual(
+p.breakpoints, [
+bkpt(2, 'first break'),
+bkpt(4, 'second break\ncontinue second\n  continuing 
indented\nnot indented'),
+bkpt(8, "third break")])



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] aee4925 - Recommit: Compress formatting of array type names (int [4] -> int[4])

2021-10-28 Thread Pavel Labath via lldb-commits

On 26/10/2021 23:14, Jim Ingham via lldb-commits wrote:




On Oct 26, 2021, at 12:45 PM, David Blaikie  wrote:

On Tue, Oct 26, 2021 at 12:15 PM Raphael Isemann  wrote:
Not sure how many LLDB users would (or can) write AST matchers though. And
 (lldb) type summary add "foo[4]" ...
is arguably easier on the eyes than
 type summary add
constantArrayType(allOf(hasSize(4),hasDeclaration(namedDecl(hasName("foo")`

Though presumably (& the example I think Jim was giving) more often the desire 
would be to write a matcher for arrays of any dimension, where it's:

"foo[\d+]" or similar (maybe having to escape the "[]"
compared to
arrayType(hasElementType(hasDeclaration(cxxRecordDecl(hasName("foo")
  
Which is, admittedly, still pretty verbose. But more type checked (for better and worse - annoying to get right (took me ages to figure out I needed "hasDeclaration" in there) but more robust once it is right)


(that's my best shot at a good AST matcher, not sure if we could make
this shorter, but that's probably what a user ends up with).

In this case it seems just comparing tokens instead of direct strings
is enough to make most users happy. And it doesn't require building
clang ASTs (which is always expensive).

Yeah, as much as I like the abstract purity of structural comparison, token 
comparison is probably close enough. (guess that has to involve LLDB walking 
through typedefs incrementally, etc - if typedefs can be used in pretty printer 
matching/searching, otherwise got to go strip out all the typedefs (from the 
users regex (if they are allowed there) and from the type of the thing being 
printed) and other sugar before comparison - guess that's done today somewhere)




The formatter matching does use a type hierarchy if it has one.  We walk the 
chain of typedefs looking for a match, first one wins.  We also match down 
class hierarchies, since if you only format the base class fields, it would be 
annoying to have to write a new formatter for each derived class just to get 
the base class fields printed.

We could also invent some mini-language for the type specification, like "char 
[*]" to mean an array of any size.  But I hesitate to introduce non-language 
features in here because then some other language we need to support will use those 
characters making them ambiguous.  And it's better to rely on facts people already know 
to specify this sort of thing, if possible.  But maybe having a slightly smart tokenizer 
and a few conventions for the common cases might make specifying matches less awkward.

But it doesn't require that we know about then names being matched, and will 
fall back now on either plain string matching or regex-es.



I've recently approached this issue from a slightly different angle 
(trying to format sizeless char arrays (char[]), and I've learned a 
couple of things which might be interesting to this discussion:
- besides typedefs, we also strip cv qualifiers (so a formatter for char 
* applies to const char * as well). However, we didn't to this for array 
types (so one had to include char [.*] and const char [.*] separately. 
(D112708 extends this behavior to arrays too)
- our formatters were not handling cv arrays separately, and the reason 
this worked is because they used unachored regexes, so "char [.*]" 
matched the last part of "const volatile char [47]"
- the unachored matching meant that these formatters were getting 
applied to completely unrelated types as well (e.g. MyStruct). 
(D112709 fixes the second two issues)


While I don't think it's realistic to expect that our users will learn 
how clang ast matchers (or any similar language) work, I think all of 
these examples show that the regex approach has a lot of pitfalls as 
well. It might be good to consider switching to a full-match regexes at 
least, as I think the template trick will affect most formatters, and I 
doubt users will remember to surround their expressions with ^$.


pl
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3abd063 - [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant arrays

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T11:13:59+02:00
New Revision: 3abd063fc793d2d56fc78287c61b73b2d7843bc5

URL: 
https://github.com/llvm/llvm-project/commit/3abd063fc793d2d56fc78287c61b73b2d7843bc5
DIFF: 
https://github.com/llvm/llvm-project/commit/3abd063fc793d2d56fc78287c61b73b2d7843bc5.diff

LOG: [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant 
arrays

Unqualify (constant) arrays recursively, just like we do for pointers.
This allows for better pretty printer matching.

Differential Revision: https://reviews.llvm.org/D112708

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 00daaad41a6e1..aa0a8086cb28c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4238,7 +4238,13 @@ static clang::QualType 
GetFullyUnqualifiedType_Impl(clang::ASTContext *ast,
   if (qual_type->isPointerType())
 qual_type = ast->getPointerType(
 GetFullyUnqualifiedType_Impl(ast, qual_type->getPointeeType()));
-  else
+  else if (const ConstantArrayType *arr =
+   ast->getAsConstantArrayType(qual_type)) {
+qual_type = ast->getConstantArrayType(
+GetFullyUnqualifiedType_Impl(ast, arr->getElementType()),
+arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
+arr->getIndexTypeQualifiers().getAsOpaqueValue());
+  } else
 qual_type = qual_type.getUnqualifiedType();
   qual_type.removeLocalConst();
   qual_type.removeLocalRestrict();

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
index 3906e48368054..f089038280e52 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -65,10 +65,12 @@ def cleanup():
 self.runCmd("type summary clear")
 
 self.runCmd(
-"type summary add --summary-string \"${var[]}\" -x 
\"int\\[[0-9]\\]")
+"type summary add --summary-string \"${var[]}\" -x 
\"^int\\[[0-9]\\]")
 
 self.expect("frame variable int_array",
 substrs=['1,2,3,4,5'])
+self.expect("frame variable const_int_array",
+substrs=['11,12,13,14,15'])
 
 # this will fail if we don't do [] as regex correctly
 self.runCmd(

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
index 857e2493e1a2d..e7a52fe73bd4c 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -144,7 +144,8 @@ int main (int argc, const char * argv[])
 cool_array[2].character = 'Q';
 
 int int_array[] = {1,2,3,4,5};
-
+const int const_int_array[] = {11, 12, 13, 14, 15};
+
 IWrapPointers wrapper;
 
 *int_array = -1;

diff  --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp 
b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 21ae5b01b0cc9..5b1154d2cd8b9 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -912,6 +912,32 @@ TEST_F(TestTypeSystemClang, AddMethodToObjCObjectType) {
   EXPECT_EQ(method->getDeclName().getObjCSelector().getAsString(), "foo");
 }
 
+TEST_F(TestTypeSystemClang, GetFullyUnqualifiedType) {
+  CompilerType bool_ = m_ast->GetBasicType(eBasicTypeBool);
+  CompilerType cv_bool = bool_.AddConstModifier().AddVolatileModifier();
+
+  // const volatile bool -> bool
+  EXPECT_EQ(bool_, cv_bool.GetFullyUnqualifiedType());
+
+  // const volatile bool[47] -> bool[47]
+  EXPECT_EQ(bool_.GetArrayType(47),
+cv_bool.GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool[47][42] -> bool[47][42]
+  EXPECT_EQ(
+  bool_.GetArrayType(42).GetArrayType(47),
+  cv_bool.GetArrayType(42).GetArrayType(47).GetFullyUnqualifiedType());
+
+  // const volatile bool * -> bool *
+  EXPECT_EQ(bool_.GetPointerType(),
+cv_bool.GetPointerType().GetFullyUnqualifiedType());
+
+  // const volatile bool *[47] -> bool *[47]
+  EXPECT_EQ(
+  bool_.GetPointerType().GetArrayType(47),
+  cv_bool.GetPointerType().GetArrayType(47).GetFu

[Lldb-commits] [lldb] 5e31601 - [lldb] Refactor C/C++ string and char summary providers

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Luís Ferreira
Date: 2021-10-29T11:22:02+02:00
New Revision: 5e316012d0ac2f621b906ef7170696ec83f02409

URL: 
https://github.com/llvm/llvm-project/commit/5e316012d0ac2f621b906ef7170696ec83f02409
DIFF: 
https://github.com/llvm/llvm-project/commit/5e316012d0ac2f621b906ef7170696ec83f02409.diff

LOG: [lldb] Refactor C/C++ string and char summary providers

This patch refactors C/C++ formatters to avoid repetitive code by using 
templates.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D112658
Signed-off-by: Luís Ferreira 

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 45c0cd213e0e6..132306359d518 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -32,8 +32,24 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-bool lldb_private::formatters::Char8StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+using StringElementType = StringPrinter::StringElementType;
+
+static constexpr std::pair
+getElementTraits(StringElementType ElemType) {
+  switch (ElemType) {
+  case StringElementType::UTF8:
+return std::make_pair("u8", lldb::eFormatUnicode8);
+  case StringElementType::UTF16:
+return std::make_pair("u", lldb::eFormatUnicode16);
+  case StringElementType::UTF32:
+return std::make_pair("U", lldb::eFormatUnicode32);
+  default:
+return std::make_pair(nullptr, lldb::eFormatInvalid);
+  }
+}
+
+template 
+static bool CharStringSummaryProvider(ValueObject &valobj, Stream &stream) {
   ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)
 return false;
@@ -46,65 +62,55 @@ bool lldb_private::formatters::Char8StringSummaryProvider(
   options.SetLocation(valobj_addr);
   options.SetProcessSP(process_sp);
   options.SetStream(&stream);
-  options.SetPrefixToken("u8");
+  options.SetPrefixToken(getElementTraits(ElemType).first);
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF8>(options)) {
+  if (!StringPrinter::ReadStringAndDumpToStream(options))
 stream.Printf("Summary Unavailable");
-return true;
-  }
 
   return true;
 }
 
-bool lldb_private::formatters::Char16StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
-  ProcessSP process_sp = valobj.GetProcessSP();
-  if (!process_sp)
-return false;
+template 
+static bool CharSummaryProvider(ValueObject &valobj, Stream &stream) {
+  DataExtractor data;
+  Status error;
+  valobj.GetData(data, error);
 
-  lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
-  if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+  if (error.Fail())
 return false;
 
-  StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
-  options.SetLocation(valobj_addr);
-  options.SetProcessSP(process_sp);
-  options.SetStream(&stream);
-  options.SetPrefixToken("u");
+  std::string value;
+  StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF16>(options)) {
-stream.Printf("Summary Unavailable");
-return true;
-  }
+  constexpr auto ElemTraits = getElementTraits(ElemType);
+  valobj.GetValueAsCString(ElemTraits.second, value);
 
-  return true;
-}
+  if (!value.empty())
+stream.Printf("%s ", value.c_str());
 
-bool lldb_private::formatters::Char32StringSummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
-  ProcessSP process_sp = valobj.GetProcessSP();
-  if (!process_sp)
-return false;
+  options.SetData(std::move(data));
+  options.SetStream(&stream);
+  options.SetPrefixToken(ElemTraits.first);
+  options.SetQuote('\'');
+  options.SetSourceSize(1);
+  options.SetBinaryZeroIsTerminator(false);
 
-  lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
-  if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
-return false;
+  return StringPrinter::ReadBufferAndDumpToStream(options);
+}
 
-  StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
-  options.SetLocation(valobj_addr);
-  options.SetProcessSP(process_sp);
-  options.SetStream(&stream);
-  options.SetPrefixToken("U");
+bool lldb_private::formatters::Char8StringSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+  return CharStringSummaryProvider(valobj, stream);
+}
 
-  if (!StringPrinter::ReadStringAndDumpToStream<
-  StringPrinter::StringElementType::UTF32>(options)) {
-stream.Printf("Summary Unavailable");
-return true;
-  }
+bool lldb_

[Lldb-commits] [lldb] eee887e - [lldb/test] Print build commands in trace mode

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T11:33:31+02:00
New Revision: eee887e03551685bc03657a61c2f36ff1b522919

URL: 
https://github.com/llvm/llvm-project/commit/eee887e03551685bc03657a61c2f36ff1b522919
DIFF: 
https://github.com/llvm/llvm-project/commit/eee887e03551685bc03657a61c2f36ff1b522919.diff

LOG: [lldb/test] Print build commands in trace mode

Running tests with -t prints all lldb commands being run. It makes sense
to print all the build commands as well.

Differential Revision: https://reviews.llvm.org/D112212

Added: 
lldb/test/API/test_utils/base/Makefile
lldb/test/API/test_utils/base/TestBaseTest.py
lldb/test/API/test_utils/base/return0.cpp

Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test_event/build_exception.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 8b17b585ae6c8..98057066f3f3c 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -82,15 +82,6 @@ def setOrAppendVariable(k, v):
 
 return cmdline
 
-def runBuildCommands(self, commands):
-try:
-lldbtest.system(commands)
-except subprocess.CalledProcessError as called_process_error:
-# Convert to a build-specific error.
-# We don't do that in lldbtest.system() since that
-# is more general purpose.
-raise build_exception.BuildError(called_process_error)
-
 def getArchSpec(self, architecture):
 """
 Helper function to return the key-value string to specify the 
architecture
@@ -140,11 +131,11 @@ def _getDebugInfoArgs(self, debug_info):
 return ["MAKE_DSYM=NO", "MAKE_GMODULES=YES"]
 return None
 
-def build(self, debug_info, architecture=None, compiler=None,
+def getBuildCommand(self, debug_info, architecture=None, compiler=None,
 dictionary=None, testdir=None, testname=None):
 debug_info_args = self._getDebugInfoArgs(debug_info)
 if debug_info_args is None:
-return False
+return None
 
 command_parts = [
 self.getMake(testdir, testname), debug_info_args, ["all"],
@@ -154,8 +145,7 @@ def build(self, debug_info, architecture=None, 
compiler=None,
 self.getCmdLine(dictionary)]
 command = list(itertools.chain(*command_parts))
 
-self.runBuildCommands([command])
-return True
+return command
 
 def cleanup(self, dictionary=None):
 """Perform a platform-specific cleanup after the test."""

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index d8940b996f8dc..92d7887e670ac 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,6 +45,7 @@
 import re
 import shutil
 import signal
+import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +69,7 @@
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
 from lldbsuite.test.builders import get_builder
+from lldbsuite.test_event import build_exception
 
 # See also dotest.parseOptionsAndInitTestdirs(), where the environment 
variables
 # LLDB_COMMAND_TRACE is set from '-t' option.
@@ -470,61 +472,6 @@ def launch(self, executable, args, extra_env):
 def terminate(self):
 lldb.remote_platform.Kill(self._pid)
 
-# From 2.7's subprocess.check_output() convenience function.
-# Return a tuple (stdoutdata, stderrdata).
-
-
-def system(commands, **kwargs):
-r"""Run an os command with arguments and return its output as a byte 
string.
-
-If the exit code was non-zero it raises a CalledProcessError.  The
-CalledProcessError object will have the return code in the returncode
-attribute and output in the output attribute.
-
-The arguments are the same as for the Popen constructor.  Example:
-
->>> check_output(["ls", "-l", "/dev/null"])
-'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'
-
-The stdout argument is not allowed as it is used internally.
-To capture standard error in the result, use stderr=STDOUT.
-
->>> check_output(["/bin/sh", "-c",
-...   "ls -l non_existent_file ; exit 0"],
-...  stderr=STDOUT)
-'ls: non_existent_file: No such file or directory\n'
-"""
-
-output = ""
-error = ""
-for shellCommand in commands:
-if 'stdout' in kwargs:
-raise ValueError(
-'stdout argument not allowed, it will be overridden.')
-process = Popen(
-shellCommand,
-stdout=PIPE,
-stderr=STDOUT,
-**kwargs)
-  

[Lldb-commits] [lldb] a394231 - [lldb] Remove ConstString from SymbolVendor, Trace, TraceExporter, UnwindAssembly, MemoryHistory and InstrumentationRuntime plugin names

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T12:08:57+02:00
New Revision: a3942318198937a163deeb10f2e3378f3bc69844

URL: 
https://github.com/llvm/llvm-project/commit/a3942318198937a163deeb10f2e3378f3bc69844
DIFF: 
https://github.com/llvm/llvm-project/commit/a3942318198937a163deeb10f2e3378f3bc69844.diff

LOG: [lldb] Remove ConstString from SymbolVendor, Trace, TraceExporter, 
UnwindAssembly, MemoryHistory and InstrumentationRuntime plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.cpp
lldb/source/Plugins/TraceExporter/ctf/TraceExporterCTF.h

lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
lldb/source/Target/Trace.cpp
lldb/source/Target/TraceExporter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index dffceb93ebc63..cd720d5a9d0fc 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -324,7 +324,7 @@ class PluginManager {
   GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
 
   // SymbolVendor
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  SymbolVendorCreateInstance create_callback);
 
   static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
@@ -334,7 +334,7 @@ class PluginManager {
 
   // Trace
   static bool RegisterPlugin(
-  ConstString name, const char *description,
+  llvm::StringRef name, llvm::StringRef description,
   TraceCreateInstanceForSessionFile create_callback_for_session_file,
   TraceCreateInstanceForLiveProcess create_callback_for_live_process,
   llvm::StringRef schema);
@@ -343,10 +343,10 @@ class PluginManager {
   UnregisterPlugin(TraceCreateInstanceForSessionFile create_callback);
 
   static TraceCreateInstanceForSessionFile
-  GetTraceCreateCallback(ConstString plugin_name);
+  GetTraceCreateCallback(llvm::StringRef plugin_name);
 
   static TraceCreateInstanceForLiveProcess
-  GetTraceCreateCallbackForLiveProcess(ConstString plugin_name);
+  GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name);
 
   /// Get the JSON schema for a trace session file corresponding to the given
   /// plugin.
@@ -357,7 +357,7 @@ class PluginManager {
   /// \return
   /// An empty \a StringRef if no plugin was found with that plugin name,
   /// otherwise the actual schema is returned.
-  static llvm::StringRef GetTraceSchema(ConstString plugin_name);
+  static llvm::StringRef GetTraceSchema(llvm::StringRef plugin_name);
 
   /// Get the JSON schema for a trace session file corresponding to the plugin
   /// given by its index.
@@ -376,16 +376,16 @@ class PluginManager {
   /// This callback is used to create a CommandObject that will be listed
   /// under "thread trace export". Can be \b null.
   static bool RegisterPlugin(
-  ConstString name, const char *description,
+  llvm::StringRef name, llvm::StringRef description,
   TraceExporterCreateInstance create_callback,
   ThreadTraceExportCommandCreator create_thread_trace_export_command);
 
   static Tr

[Lldb-commits] [lldb] b42d51b - [lldb/test] Replace shlex.join with shlex.quote

2021-10-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-29T13:42:06+02:00
New Revision: b42d51ba9ad1f85e6b6f3508e6c2c4ab5ee22ac1

URL: 
https://github.com/llvm/llvm-project/commit/b42d51ba9ad1f85e6b6f3508e6c2c4ab5ee22ac1
DIFF: 
https://github.com/llvm/llvm-project/commit/b42d51ba9ad1f85e6b6f3508e6c2c4ab5ee22ac1.diff

LOG: [lldb/test] Replace shlex.join with shlex.quote

join is only available since python-3.8, but the all the interesting
magic happens in shlex.quote, which has been around since 3.3.

Use shlex.quote, and instead provide a home-grown helper function to
handle the joining.

Differential Revision: https://reviews.llvm.org/D112802

Added: 


Modified: 
lldb/packages/Python/lldbsuite/support/seven.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test_event/build_exception.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/support/seven.py 
b/lldb/packages/Python/lldbsuite/support/seven.py
index 9b23d94b021dc..969b61d005c58 100644
--- a/lldb/packages/Python/lldbsuite/support/seven.py
+++ b/lldb/packages/Python/lldbsuite/support/seven.py
@@ -1,5 +1,6 @@
 import binascii
 import six
+import shlex
 
 if six.PY2:
 import commands
@@ -49,3 +50,7 @@ def unhexlify(hexstr):
 def hexlify(data):
 """Hex-encode string data. The result if always a string."""
 return bitcast_to_string(binascii.hexlify(bitcast_to_bytes(data)))
+
+# TODO: Replace this with `shlex.join` when minimum Python version is >= 3.8
+def join_for_shell(split_command):
+return " ".join([shlex.quote(part) for part in split_command])

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 92d7887e670ac..7477905a131d0 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -45,7 +45,6 @@
 import re
 import shutil
 import signal
-import shlex
 from subprocess import *
 import sys
 import time
@@ -68,6 +67,7 @@
 from . import test_categories
 from lldbsuite.support import encoded_file
 from lldbsuite.support import funcutils
+from lldbsuite.support import seven
 from lldbsuite.test.builders import get_builder
 from lldbsuite.test_event import build_exception
 
@@ -1423,7 +1423,7 @@ def build(
 self.runBuildCommand(command)
 
 def runBuildCommand(self, command):
-self.trace(shlex.join(command))
+self.trace(seven.join_for_shell(command))
 try:
 output = check_output(command, stderr=STDOUT, errors="replace")
 except CalledProcessError as cpe:

diff  --git a/lldb/packages/Python/lldbsuite/test_event/build_exception.py 
b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
index e1924ad86cde5..f960dca39067d 100644
--- a/lldb/packages/Python/lldbsuite/test_event/build_exception.py
+++ b/lldb/packages/Python/lldbsuite/test_event/build_exception.py
@@ -1,10 +1,10 @@
-import shlex
+from lldbsuite.support import seven
 
 class BuildError(Exception):
 
 def __init__(self, called_process_error):
 super(BuildError, self).__init__("Error when building test subject")
-self.command = shlex.join(called_process_error.cmd)
+self.command = seven.join_for_shell(called_process_error.cmd)
 self.build_error = called_process_error.output
 
 def __str__(self):



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


<    3   4   5   6   7   8   9   10   11   >