[Lldb-commits] [lldb] Support target names with dots in more utilities (PR #65812)

2023-10-19 Thread James Henderson via lldb-commits

jh7370 wrote:

@dankm, is there a particular reason you haven't merged this change in yet?

FWIW, the formatter check failed for some reason, but I'm not sure it's related 
to any formatting issue. Please verify by running clang-format on your changes 
before merging.

https://github.com/llvm/llvm-project/pull/65812
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Rename lldb-vscode to lldb-dap (PR #69264)

2023-10-19 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett approved this pull request.


https://github.com/llvm/llvm-project/pull/69264
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-19 Thread David Spickett via lldb-commits


@@ -135,5 +135,5 @@ def test_watch_address_with_invalid_watch_size(self):
 self.expect(
 error.GetCString(),
 exe=False,
-substrs=["watch size of %d is not supported" % 365],
+substrs=["Setting one of the watchpoint resources failed"],

DavidSpickett wrote:

Yeah I don't think it would need to be super specific, that is what logs are 
for. Drawing the distinction between failed because the stub didn't have 
resources, and failed because the stub exploded, that's more what I'd like to 
see.

And here the original error message is actually still pretty vague. It tells me 
that size N isn't support, but not what is supported (which is a whole other 
thing).

https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-19 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/68845
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via lldb-commits

lawben wrote:

As nobody has come forward in the the last two days, I'm gonna merge this now. 
I'll have a look a mangling this for Microsoft in a follow-up, as this may 
require a few changes. I'm not yet sure what has to be changed for mangling.

https://github.com/llvm/llvm-project/pull/69010
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Lawrence Benson via lldb-commits

https://github.com/lawben closed https://github.com/llvm/llvm-project/pull/69010
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

2023-10-19 Thread Timm Baeder via lldb-commits

tbaederr wrote:

Have you seen the failing buildbots?

https://github.com/llvm/llvm-project/pull/69010
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Allow specifying a custom escape prefix for LLDB commands (PR #69238)

2023-10-19 Thread Walter Erquinigo via lldb-commits


@@ -52,12 +52,17 @@ llvm::StringRef GetAsString(const llvm::json::Value &value);
 /// \param[in] key
 /// The key to use when extracting the value
 ///
+/// \param[in] defaultValue
+/// The default value to return if the key is not present
+///
 /// \return
 /// A llvm::StringRef that contains the string value for the
-/// specified \a key, or an empty string if there is no key that
+/// specified \a key, or the default value if there is no key that
 /// matches or if the value is not a string.
-llvm::StringRef GetString(const llvm::json::Object &obj, llvm::StringRef key);
-llvm::StringRef GetString(const llvm::json::Object *obj, llvm::StringRef key);
+llvm::StringRef GetString(const llvm::json::Object &obj, llvm::StringRef key,
+  llvm::StringRef defaultValue = "");
+llvm::StringRef GetString(const llvm::json::Object *obj, llvm::StringRef key,
+  llvm::StringRef defaultValue = "");

walter-erquinigo wrote:

oh wow, good catch

https://github.com/llvm/llvm-project/pull/69238
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Allow specifying a custom escape prefix for LLDB commands (PR #69238)

2023-10-19 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/69238

>From adcf4b7ad6ec67805293af99300643075a02b75b Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 16 Oct 2023 15:08:20 -0400
Subject: [PATCH] [lldb-vscode] Allow specifying a custom escape character for
 LLDB commands

We've been using the backtick as our escape character, however that leads to a 
weird experience on VS Code, because on most hosts, as soon as you type the 
backtick on VS Code, the IDE will introduce another backtick. As changing the 
default escape character might be out of question because other plugins might 
rely on it, we can instead introduce an option to change this variable upon 
lldb-vscode initialization.
FWIW, my users will be using : instead ot the backtick.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  |  4 ++
 .../test/tools/lldb-vscode/vscode.py  |  9 +++-
 .../lldb-vscode/console/TestVSCode_console.py | 46 +--
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 10 ++--
 lldb/tools/lldb-vscode/JSONUtils.h| 11 +++--
 lldb/tools/lldb-vscode/VSCode.cpp | 11 +++--
 lldb/tools/lldb-vscode/VSCode.h   |  1 +
 lldb/tools/lldb-vscode/lldb-vscode.cpp|  4 ++
 lldb/tools/lldb-vscode/package.json   | 10 
 9 files changed, 90 insertions(+), 16 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index 8cd4e8454c89099..2e4a13b2fa2eed3 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -351,6 +351,7 @@ def launch(
 postRunCommands=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 """Sending launch request to vscode"""
 
@@ -389,6 +390,7 @@ def cleanup():
 postRunCommands=postRunCommands,
 enableAutoVariableSummaries=enableAutoVariableSummaries,
 enableSyntheticChildDebugging=enableSyntheticChildDebugging,
+commandEscapePrefix=commandEscapePrefix,
 )
 
 if expectFailure:
@@ -425,6 +427,7 @@ def build_and_launch(
 lldbVSCodeEnv=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 """Build the default Makefile target, create the VSCode debug adaptor,
 and launch the process.
@@ -455,4 +458,5 @@ def build_and_launch(
 postRunCommands=postRunCommands,
 enableAutoVariableSummaries=enableAutoVariableSummaries,
 enableSyntheticChildDebugging=enableSyntheticChildDebugging,
+commandEscapePrefix=commandEscapePrefix,
 )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index 5ee0800b27a5699..d5e213d3e13db8f 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -731,6 +731,7 @@ def request_launch(
 postRunCommands=None,
 enableAutoVariableSummaries=False,
 enableSyntheticChildDebugging=False,
+commandEscapePrefix="`",
 ):
 args_dict = {"program": program}
 if args:
@@ -774,6 +775,7 @@ def request_launch(
 args_dict["postRunCommands"] = postRunCommands
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
+args_dict["commandEscapePrefix"] = commandEscapePrefix
 command_dict = {"command": "launch", "type": "request", "arguments": 
args_dict}
 response = self.send_recv(command_dict)
 
@@ -1015,7 +1017,12 @@ def terminate(self):
 
 class DebugAdaptor(DebugCommunication):
 def __init__(
-self, executable=None, port=None, init_commands=[], log_file=None, 
env=None
+self,
+executable=None,
+port=None,
+init_commands=[],
+log_file=None,
+env=None,
 ):
 self.process = None
 if executable is not None:
diff --git a/lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py 
b/lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py
index d28e98b37c589dd..8eb02257ec6c5c5 100644
--- a/lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py
+++ b/lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py
@@ -2,16 +2,20 @@
 Test lldb-vscode setBreakpoints request
 """
 
+import lldbvscode_testcase
 import vscode
+from lldbsuite.test import lldbutil
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbvs

[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-10-19 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

I was thinking more about this last night, I'm not sure the word "discrete" is 
the right word for what this describes. It's not a bad word per se, but if a 
ProgressEvent isn't discrete, it's not really "continuous" either (or any of 
the other antonyms of discrete that I can think of). It seems like the 
dichotomy is less "discrete vs continuous" and more like "one vs many".

That being said, what do you think of the name `is_aggregate`?

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -696,3 +696,55 @@ template <> bool SetNumberFromPyObject(double 
&number, PyObject *obj) {
   $1 = $input == Py_None;
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
+
+// For lldb::SBModuleLocateDwoCallback
+// The `baton` is the actual Python function passed, and we invoke the `baton` 
via a SWIG function.
+%typemap(in) (lldb::SBModuleLocateDwoCallback callback,
+  void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  if ($input == Py_None) {
+$1 = nullptr;
+$2 = nullptr;
+  } else {
+PythonCallable callable = Retain($input);
+if (!callable.IsValid()) {
+  PyErr_SetString(PyExc_TypeError, "Need a valid callable object");
+  SWIG_fail;
+}
+
+llvm::Expected arg_info = callable.GetArgInfo();
+if (!arg_info) {
+  PyErr_SetString(PyExc_TypeError,
+  ("Could not get arguments: " +
+  llvm::toString(arg_info.takeError())).c_str());

bulbazord wrote:

The way you're building this string is a little difficult to parse because I 
originally thought the `.c_str()` was attached to the `std::string` returned by 
`llvm::toString`. I would suggest making it more explicit by building the 
string ahead of time instead of doing it inline.

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1168,4 +1168,58 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+// `comp_dir` is allowed to be NULL. All other arguments must be valid values.
+static SBError LLDBSwigPythonCallLocateDwoCallback(
+void *baton, const SBFileSpec &objfile_spec_sb,
+const char *dwo_name, const char *comp_dir, const int64_t dwo_id, 
SBFileSpec &located_dwo_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+  if (dwo_name == NULL) {
+return SBError("`dwo_name` is NULL. Expected a valid string.");
+  }
+  PythonString dwo_name_arg(dwo_name);
+  PythonObject comp_dir_arg(PyRefType::Borrowed, Py_None);
+  if (comp_dir != NULL) {
+comp_dir_arg = PythonString(comp_dir);
+  }
+  PythonObject dwo_id_arg = PythonInteger(dwo_id);
+  PythonObject objfile_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(objfile_spec_sb));
+  PythonObject located_dwo_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(located_dwo_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_cast(baton));
+  if (!callable.IsValid()) {
+return SBError("The callback callable is not valid.");
+  }
+
+  PythonObject result = callable(objfile_spec_arg,
+ dwo_name_arg,
+ comp_dir_arg,
+ dwo_id_arg,
+ located_dwo_file_spec_arg);
+
+  if (!result.IsAllocated())
+return SBError("No result.");
+  lldb::SBError *sb_error_ptr = nullptr;
+  if (SWIG_ConvertPtr(result.get(), (void **)&sb_error_ptr,
+  SWIGTYPE_p_lldb__SBError, 0) == -1) {
+return SBError("Result is not SBError.");

bulbazord wrote:

Error message -- "The return value from the python callback was not an SBError".

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -696,3 +696,55 @@ template <> bool SetNumberFromPyObject(double 
&number, PyObject *obj) {
   $1 = $input == Py_None;
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
+
+// For lldb::SBModuleLocateDwoCallback
+// The `baton` is the actual Python function passed, and we invoke the `baton` 
via a SWIG function.
+%typemap(in) (lldb::SBModuleLocateDwoCallback callback,
+  void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {

bulbazord wrote:

IMO it's simpler and easier to read if you apply De Morgan's here.

```
if ($input != Py_None && !PyCallable_Check(reinterpret_cast($input))) {
```

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1168,4 +1168,58 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+// `comp_dir` is allowed to be NULL. All other arguments must be valid values.
+static SBError LLDBSwigPythonCallLocateDwoCallback(
+void *baton, const SBFileSpec &objfile_spec_sb,
+const char *dwo_name, const char *comp_dir, const int64_t dwo_id, 
SBFileSpec &located_dwo_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+  if (dwo_name == NULL) {
+return SBError("`dwo_name` is NULL. Expected a valid string.");
+  }
+  PythonString dwo_name_arg(dwo_name);
+  PythonObject comp_dir_arg(PyRefType::Borrowed, Py_None);
+  if (comp_dir != NULL) {
+comp_dir_arg = PythonString(comp_dir);
+  }
+  PythonObject dwo_id_arg = PythonInteger(dwo_id);
+  PythonObject objfile_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(objfile_spec_sb));
+  PythonObject located_dwo_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(located_dwo_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_cast(baton));
+  if (!callable.IsValid()) {
+return SBError("The callback callable is not valid.");
+  }
+
+  PythonObject result = callable(objfile_spec_arg,
+ dwo_name_arg,
+ comp_dir_arg,
+ dwo_id_arg,
+ located_dwo_file_spec_arg);
+
+  if (!result.IsAllocated())
+return SBError("No result.");

bulbazord wrote:

Same here for the error message. I'd suggest "The executed python callback did 
not return a value" or something similar.

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

Because SymbolFile is holding onto the function pointer as a static member, 
this is a global setting that you can't apply to only just one `SBDebugger` 
object. It's an all-or-nothing thing.
Maybe that's what you want, but LLDB already has architectural issues with 
certain functionality being difficult to detangle from global state (e.g. 
Logging). Maybe we could make it a property of the Debugger instead?

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -677,3 +677,30 @@ void SBModule::GarbageCollectAllocatedModules() {
   const bool mandatory = false;
   ModuleList::RemoveOrphanSharedModules(mandatory);
 }
+
+void SBModule::SetLocateDwoCallback(lldb::SBModuleLocateDwoCallback callback,
+void *baton) {
+  LLDB_INSTRUMENT();

bulbazord wrote:

the instrumentation macro needs all the arguments passed to the method.
```
LLDB_INSTRUMENT(callback, baton);
```

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -696,3 +696,55 @@ template <> bool SetNumberFromPyObject(double 
&number, PyObject *obj) {
   $1 = $input == Py_None;
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
+
+// For lldb::SBModuleLocateDwoCallback
+// The `baton` is the actual Python function passed, and we invoke the `baton` 
via a SWIG function.
+%typemap(in) (lldb::SBModuleLocateDwoCallback callback,
+  void *baton) {
+  if (!($input == Py_None ||
+PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+  }
+
+  if ($input == Py_None) {
+$1 = nullptr;
+$2 = nullptr;
+  } else {
+PythonCallable callable = Retain($input);
+if (!callable.IsValid()) {
+  PyErr_SetString(PyExc_TypeError, "Need a valid callable object");
+  SWIG_fail;
+}
+
+llvm::Expected arg_info = callable.GetArgInfo();
+if (!arg_info) {
+  PyErr_SetString(PyExc_TypeError,
+  ("Could not get arguments: " +
+  llvm::toString(arg_info.takeError())).c_str());
+  SWIG_fail;
+}
+
+if (arg_info.get().max_positional_args != 5) {
+  PyErr_SetString(PyExc_TypeError, "Expected 5 argument callable object");
+  SWIG_fail;
+}
+
+// NOTE: When this is called multiple times, this will leak the Python
+// callable object as other callbacks, because this does not call Py_DECREF
+// the object. But it should be almost zero impact since this method is
+// expected to be called only once.

bulbazord wrote:

If it's only meant to be called once, maybe we could add some code to clean it 
up later? 🙂 

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -139,6 +139,13 @@ typedef void (*SBDebuggerDestroyCallback)(lldb::user_id_t 
debugger_id,
 typedef SBError (*SBPlatformLocateModuleCallback)(
 void *baton, const SBModuleSpec &module_spec, SBFileSpec &module_file_spec,
 SBFileSpec &symbol_file_spec);
+
+typedef SBError (*SBModuleLocateDwoCallback)(void *baton,
+ const SBFileSpec &objfile_spec,
+ const char *dwo_name,
+ const char *comp_dir,
+ const int64_t dwo_id,

bulbazord wrote:

+1

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1168,4 +1168,58 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+// `comp_dir` is allowed to be NULL. All other arguments must be valid values.
+static SBError LLDBSwigPythonCallLocateDwoCallback(
+void *baton, const SBFileSpec &objfile_spec_sb,
+const char *dwo_name, const char *comp_dir, const int64_t dwo_id, 
SBFileSpec &located_dwo_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+  if (dwo_name == NULL) {
+return SBError("`dwo_name` is NULL. Expected a valid string.");
+  }
+  PythonString dwo_name_arg(dwo_name);
+  PythonObject comp_dir_arg(PyRefType::Borrowed, Py_None);
+  if (comp_dir != NULL) {
+comp_dir_arg = PythonString(comp_dir);
+  }
+  PythonObject dwo_id_arg = PythonInteger(dwo_id);
+  PythonObject objfile_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(objfile_spec_sb));
+  PythonObject located_dwo_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(located_dwo_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_cast(baton));
+  if (!callable.IsValid()) {
+return SBError("The callback callable is not valid.");
+  }
+
+  PythonObject result = callable(objfile_spec_arg,
+ dwo_name_arg,
+ comp_dir_arg,
+ dwo_id_arg,
+ located_dwo_file_spec_arg);
+
+  if (!result.IsAllocated())
+return SBError("No result.");
+  lldb::SBError *sb_error_ptr = nullptr;
+  if (SWIG_ConvertPtr(result.get(), (void **)&sb_error_ptr,
+  SWIGTYPE_p_lldb__SBError, 0) == -1) {
+return SBError("Result is not SBError.");
+  }
+
+  if (sb_error_ptr->Success()) {
+lldb::SBFileSpec *located_dwo_file_spec_ptr = nullptr;
+if (SWIG_ConvertPtr(located_dwo_file_spec_arg.get(),
+(void **)&located_dwo_file_spec_ptr,
+SWIGTYPE_p_lldb__SBFileSpec, 0) == -1)
+  return SBError("located_dwo_file_spec is not SBFileSpec.");

bulbazord wrote:

"located_dwo_file_spec is not of type SBFileSpec"

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1742,20 +1742,37 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
   if (std::shared_ptr dwp_sp = GetDwpSymbolFile())
 return dwp_sp;
 
-  FileSpec dwo_file(dwo_name);
-  FileSystem::Instance().Resolve(dwo_file);
-  bool found = false;
+  const char *comp_dir =
+  cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir, nullptr);
+
+  // Try locating the dwo via the callback first.
+  FileSpec dwo_file;
+  SymbolFile::LocateDwoCallback locate_dwo_callback =
+  SymbolFile::GetLocateDwoCallback();
+  if (locate_dwo_callback) {
+const FileSpec &objfile_spec = m_objfile_sp->GetFileSpec();
+Status error = locate_dwo_callback(objfile_spec, dwo_name, comp_dir,
+   dwarf_cu->GetDWOId().value(), dwo_file);
+if (error.Fail()) {
+  GetObjectFile()->GetModule()->ReportWarning(
+  "locate DWO callback failed with error: {0}",
+  error.AsCString("unknown error"));
+}

bulbazord wrote:

Logging seems fine to me, many users might not even be aware that the dwo 
callback is installed into their session. Adding warnings like this can get 
spammy pretty quickly.

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1168,4 +1168,58 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+// `comp_dir` is allowed to be NULL. All other arguments must be valid values.
+static SBError LLDBSwigPythonCallLocateDwoCallback(
+void *baton, const SBFileSpec &objfile_spec_sb,
+const char *dwo_name, const char *comp_dir, const int64_t dwo_id, 
SBFileSpec &located_dwo_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+  if (dwo_name == NULL) {
+return SBError("`dwo_name` is NULL. Expected a valid string.");
+  }
+  PythonString dwo_name_arg(dwo_name);
+  PythonObject comp_dir_arg(PyRefType::Borrowed, Py_None);
+  if (comp_dir != NULL) {
+comp_dir_arg = PythonString(comp_dir);
+  }
+  PythonObject dwo_id_arg = PythonInteger(dwo_id);
+  PythonObject objfile_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(objfile_spec_sb));
+  PythonObject located_dwo_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(located_dwo_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_cast(baton));

bulbazord wrote:

You need to check for `NULL` before calling `Retain` because it will assert if 
it's passed `NULL`.

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1168,4 +1168,58 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+// `comp_dir` is allowed to be NULL. All other arguments must be valid values.
+static SBError LLDBSwigPythonCallLocateDwoCallback(
+void *baton, const SBFileSpec &objfile_spec_sb,
+const char *dwo_name, const char *comp_dir, const int64_t dwo_id, 
SBFileSpec &located_dwo_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+  if (dwo_name == NULL) {
+return SBError("`dwo_name` is NULL. Expected a valid string.");
+  }

bulbazord wrote:

The LLVM Style guide specifies dropping braces for 1 line if/else/loop blocks.

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1168,4 +1168,58 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+// `comp_dir` is allowed to be NULL. All other arguments must be valid values.
+static SBError LLDBSwigPythonCallLocateDwoCallback(
+void *baton, const SBFileSpec &objfile_spec_sb,
+const char *dwo_name, const char *comp_dir, const int64_t dwo_id, 
SBFileSpec &located_dwo_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+  if (dwo_name == NULL) {
+return SBError("`dwo_name` is NULL. Expected a valid string.");
+  }
+  PythonString dwo_name_arg(dwo_name);
+  PythonObject comp_dir_arg(PyRefType::Borrowed, Py_None);
+  if (comp_dir != NULL) {
+comp_dir_arg = PythonString(comp_dir);
+  }
+  PythonObject dwo_id_arg = PythonInteger(dwo_id);
+  PythonObject objfile_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(objfile_spec_sb));
+  PythonObject located_dwo_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(located_dwo_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_cast(baton));
+  if (!callable.IsValid()) {
+return SBError("The callback callable is not valid.");

bulbazord wrote:

This error doesn't make a lot of sense for somebody trying to use this 
functionality. Maybe something like "Argument 'baton' is not a valid Python 
callback"?

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -0,0 +1,119 @@
+"""
+Test module locate dwo callback functionality
+"""
+
+import ctypes
+import shutil
+from lldbsuite.test.decorators import *
+import lldb
+from lldbsuite.test import lldbtest, lldbutil
+
+
+class LocateDwoCallbackTestCase(lldbtest.TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+lldbtest.TestBase.setUp(self)
+
+self.build()
+self.exe = self.getBuildArtifact("a.out")
+self.dwos = [
+ self.getBuildArtifact("main.dwo"),
+ self.getBuildArtifact("foo.dwo")
+]
+
+def run_program(self):
+# Set a breakpoint at main
+target = self.dbg.CreateTarget(self.exe)
+self.assertTrue(target, lldbtest.VALID_TARGET)
+lldbutil.run_break_set_by_symbol(self, "main")
+
+# Now launch the process, and do not stop at entry point.
+self.process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
+self.assertTrue(self.process, lldbtest.PROCESS_IS_VALID)
+
+def check_symbolicated(self):
+thread = self.process.GetSelectedThread()
+frame = thread.GetSelectedFrame()
+self.assertEquals(len(frame.get_arguments()), 2)
+
+def check_not_symbolicated(self):
+thread = self.process.GetSelectedThread()
+frame = thread.GetSelectedFrame()
+self.assertNotEquals(len(frame.get_arguments()), 2)
+
+def moveDwos(self):
+"""Move the dwos to a subdir in the build dir"""
+dwo_folder = os.path.join(self.getBuildDir(), "dwos")
+lldbutil.mkdir_p(dwo_folder)
+for dwo in self.dwos:
+shutil.move(dwo, dwo_folder)
+
+@skipIfWindows
+@skipIfDarwin
+def test_set_non_callable(self):
+with self.assertRaises(TypeError):
+lldb.SBModule.SetLocateDwoCallback("a")
+
+@skipIfWindows
+@skipIfDarwin

bulbazord wrote:

This test should work on Windows and Darwin.

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -1742,20 +1742,37 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
   if (std::shared_ptr dwp_sp = GetDwpSymbolFile())
 return dwp_sp;
 
-  FileSpec dwo_file(dwo_name);
-  FileSystem::Instance().Resolve(dwo_file);
-  bool found = false;
+  const char *comp_dir =
+  cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir, nullptr);
+
+  // Try locating the dwo via the callback first.
+  FileSpec dwo_file;
+  SymbolFile::LocateDwoCallback locate_dwo_callback =
+  SymbolFile::GetLocateDwoCallback();
+  if (locate_dwo_callback) {

bulbazord wrote:

You could merge these since `locate_dwo_callback` isn't used later on.
```
if (SymbolFile::LocateDwoCallback locate_dwo_callback = 
SymbolFile::GetLocateDwoCallback()) {
```

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-19 Thread Alex Langford via lldb-commits


@@ -0,0 +1,119 @@
+"""
+Test module locate dwo callback functionality
+"""
+
+import ctypes
+import shutil
+from lldbsuite.test.decorators import *
+import lldb
+from lldbsuite.test import lldbtest, lldbutil
+
+
+class LocateDwoCallbackTestCase(lldbtest.TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+lldbtest.TestBase.setUp(self)
+
+self.build()
+self.exe = self.getBuildArtifact("a.out")
+self.dwos = [
+ self.getBuildArtifact("main.dwo"),
+ self.getBuildArtifact("foo.dwo")
+]
+
+def run_program(self):
+# Set a breakpoint at main
+target = self.dbg.CreateTarget(self.exe)
+self.assertTrue(target, lldbtest.VALID_TARGET)
+lldbutil.run_break_set_by_symbol(self, "main")
+
+# Now launch the process, and do not stop at entry point.
+self.process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
+self.assertTrue(self.process, lldbtest.PROCESS_IS_VALID)
+
+def check_symbolicated(self):
+thread = self.process.GetSelectedThread()
+frame = thread.GetSelectedFrame()
+self.assertEquals(len(frame.get_arguments()), 2)
+
+def check_not_symbolicated(self):
+thread = self.process.GetSelectedThread()
+frame = thread.GetSelectedFrame()
+self.assertNotEquals(len(frame.get_arguments()), 2)
+
+def moveDwos(self):
+"""Move the dwos to a subdir in the build dir"""
+dwo_folder = os.path.join(self.getBuildDir(), "dwos")
+lldbutil.mkdir_p(dwo_folder)
+for dwo in self.dwos:
+shutil.move(dwo, dwo_folder)
+
+@skipIfWindows
+@skipIfDarwin

bulbazord wrote:

This test should work on Windows and Darwin.

https://github.com/llvm/llvm-project/pull/69517
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix std::variant invalid index crash (PR #69614)

2023-10-19 Thread via lldb-commits

https://github.com/jeffreytan81 created 
https://github.com/llvm/llvm-project/pull/69614

None

>From 126723c82207d50e5d2b475b0b259312a8f1eb5c Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Thu, 19 Oct 2023 09:42:21 -0700
Subject: [PATCH] Fix std::variant invalid index crash

---
 lldb/examples/synthetic/gnu_libstdcpp.py  |  5 
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  3 ++-
 .../TestDataFormatterLibStdcxxVariant.py  | 26 +++
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 29c926167fb440c..f778065aaca3771 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -914,6 +914,11 @@ def get_variant_npos_value(index_byte_size):
 if index == npos_value:
 return " No Value"
 
+# Invalid index can happen when the variant is not initialized yet.
+template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments()
+if index >= template_arg_count:
+return " "
+
 active_type = data_obj.GetType().GetTemplateArgumentType(index)
 return f" Active Type = {active_type.GetDisplayTypeName()} "
 
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index f1353db2631ddc6..df06ba0ed952af7 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7183,7 +7183,8 @@ GetNthTemplateArgument(const 
clang::ClassTemplateSpecializationDecl *decl,
   // (including the ones preceding the parameter pack).
   const auto &pack = args[last_idx];
   const size_t pack_idx = idx - last_idx;
-  assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
+  if (pack_idx >= pack.pack_size())
+return nullptr;
   return &pack.pack_elements()[pack_idx];
 }
 
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
index 96a9c8d30c45b00..ba1641888b6f30f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
@@ -71,3 +71,29 @@ def test_with_run_command(self):
 substrs=["v_many_types_no_value =  No Value"],
 )
 """
+
+@add_test_categories(["libstdcxx"])
+def test_invalid_variant_index(self):
+"""Test LibStdC++ data formatter for std::variant with invalid 
index."""
+self.build()
+
+(self.target, self.process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+lldbutil.continue_to_breakpoint(self.process, bkpt)
+
+self.expect(
+"frame variable v1",
+substrs=["v1 =  Active Type = int  {", "Value = 12", "}"],
+)
+
+var_v1 = thread.frames[0].FindVariable("v1")
+var_v1_raw_obj = var_v1.GetNonSyntheticValue()
+index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
+self.assertTrue(index_obj and index_obj.IsValid())
+
+INVALID_INDEX = "100"
+index_obj.SetValueFromCString(INVALID_INDEX)
+
+self.expect("frame variable v1", substrs=["v1 =  "])

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


[Lldb-commits] [lldb] Fix std::variant invalid index crash (PR #69614)

2023-10-19 Thread via lldb-commits

https://github.com/jeffreytan81 edited 
https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

2023-10-19 Thread via lldb-commits

https://github.com/jeffreytan81 edited 
https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

2023-10-19 Thread via lldb-commits

https://github.com/jeffreytan81 ready_for_review 
https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

2023-10-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (jeffreytan81)


Changes

This is relanding of https://github.com/llvm/llvm-project/pull/69253. 
`TestTemplatePackArgs.py` is passing now.

https://github.com/llvm/llvm-project/pull/68012/files added new data formatters 
for LibStdC++ std::variant.

However, this formatter can crash if std::variant's index field has invalid 
value (exceeds the number of template arguments).
This can happen if the current IP stops at a place std::variant is not 
initialized yet.

This patch fixes the crash by ensuring the index is a valid value and fix 
GetNthTemplateArgument() to make sure it is not crashing.

---
Full diff: https://github.com/llvm/llvm-project/pull/69614.diff


3 Files Affected:

- (modified) lldb/examples/synthetic/gnu_libstdcpp.py (+5) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 (+26) 


``diff
diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 29c926167fb440c..f778065aaca3771 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -914,6 +914,11 @@ def get_variant_npos_value(index_byte_size):
 if index == npos_value:
 return " No Value"
 
+# Invalid index can happen when the variant is not initialized yet.
+template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments()
+if index >= template_arg_count:
+return " "
+
 active_type = data_obj.GetType().GetTemplateArgumentType(index)
 return f" Active Type = {active_type.GetDisplayTypeName()} "
 
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index f1353db2631ddc6..df06ba0ed952af7 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7183,7 +7183,8 @@ GetNthTemplateArgument(const 
clang::ClassTemplateSpecializationDecl *decl,
   // (including the ones preceding the parameter pack).
   const auto &pack = args[last_idx];
   const size_t pack_idx = idx - last_idx;
-  assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
+  if (pack_idx >= pack.pack_size())
+return nullptr;
   return &pack.pack_elements()[pack_idx];
 }
 
diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
index 96a9c8d30c45b00..ba1641888b6f30f 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
@@ -71,3 +71,29 @@ def test_with_run_command(self):
 substrs=["v_many_types_no_value =  No Value"],
 )
 """
+
+@add_test_categories(["libstdcxx"])
+def test_invalid_variant_index(self):
+"""Test LibStdC++ data formatter for std::variant with invalid 
index."""
+self.build()
+
+(self.target, self.process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp", False)
+)
+
+lldbutil.continue_to_breakpoint(self.process, bkpt)
+
+self.expect(
+"frame variable v1",
+substrs=["v1 =  Active Type = int  {", "Value = 12", "}"],
+)
+
+var_v1 = thread.frames[0].FindVariable("v1")
+var_v1_raw_obj = var_v1.GetNonSyntheticValue()
+index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
+self.assertTrue(index_obj and index_obj.IsValid())
+
+INVALID_INDEX = "100"
+index_obj.SetValueFromCString(INVALID_INDEX)
+
+self.expect("frame variable v1", substrs=["v1 =  "])

``




https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-10-19 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

"Aggregate" can work. These are moreso status updates than than they are 
progress reports and I need to work on the documentation in the code that 
explains what I'm trying to accomplish.

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Rename lldb-vscode to lldb-dap (PR #69264)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/69264
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] Remove duplicated code in DWARFParser (PR #69531)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

🥳

https://github.com/llvm/llvm-project/pull/69531
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere requested changes to this pull request.

I already discussed this offline with Chelsea, but yeah I agree that "discrete" 
isn't very informative. Regardless of the name we pick, we should include an 
example too to help clarify its meaning. I'd also prefer to use an enum rather 
than a boolean for this, so that we don't have naked `true`/`false` all over 
the place or avoid inline comments. 

https://github.com/llvm/llvm-project/pull/69516
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

2023-10-19 Thread David Spickett via lldb-commits


@@ -7183,7 +7183,8 @@ GetNthTemplateArgument(const 
clang::ClassTemplateSpecializationDecl *decl,
   // (including the ones preceding the parameter pack).
   const auto &pack = args[last_idx];
   const size_t pack_idx = idx - last_idx;
-  assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
+  if (pack_idx >= pack.pack_size())
+return nullptr;

DavidSpickett wrote:

Is this change needed now that the formatter is checking the number of 
arguments up front?

https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] Remove duplicated code in DWARFParser (PR #69531)

2023-10-19 Thread David Blaikie via lldb-commits


@@ -73,137 +69,18 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   m_tag = abbrevDecl->getTag();
   m_has_children = abbrevDecl->hasChildren();
   // Skip all data in the .debug_info or .debug_types for the attributes
-  dw_form_t form;
   for (const auto &attribute : abbrevDecl->attributes()) {
-form = attribute.Form;
-std::optional fixed_skip_size =
-DWARFFormValue::GetFixedSize(form, cu);
-if (fixed_skip_size)
-  offset += *fixed_skip_size;
-else {
-  bool form_is_indirect = false;
-  do {
-form_is_indirect = false;
-uint32_t form_size = 0;
-switch (form) {
-// Blocks if inlined data that have a length field and the data bytes
-// inlined in the .debug_info/.debug_types
-case DW_FORM_exprloc:
-case DW_FORM_block:
-  form_size = data.GetULEB128(&offset);
-  break;
-case DW_FORM_block1:
-  form_size = data.GetU8_unchecked(&offset);
-  break;
-case DW_FORM_block2:
-  form_size = data.GetU16_unchecked(&offset);
-  break;
-case DW_FORM_block4:
-  form_size = data.GetU32_unchecked(&offset);
-  break;
-
-// Inlined NULL terminated C-strings
-case DW_FORM_string:
-  data.GetCStr(&offset);
-  break;
-
-// Compile unit address sized values
-case DW_FORM_addr:
-  form_size = cu->GetAddressByteSize();
-  break;
-case DW_FORM_ref_addr:
-  if (cu->GetVersion() <= 2)
-form_size = cu->GetAddressByteSize();
-  else
-form_size = 4;
-  break;
+if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, cu))
+  continue;
 
-// 0 sized form
-case DW_FORM_flag_present:
-  form_size = 0;
-  break;
-
-// 1 byte values
-case DW_FORM_addrx1:
-case DW_FORM_data1:
-case DW_FORM_flag:
-case DW_FORM_ref1:
-case DW_FORM_strx1:
-  form_size = 1;
-  break;
-
-// 2 byte values
-case DW_FORM_addrx2:
-case DW_FORM_data2:
-case DW_FORM_ref2:
-case DW_FORM_strx2:
-  form_size = 2;
-  break;
-
-// 3 byte values
-case DW_FORM_addrx3:
-case DW_FORM_strx3:
-  form_size = 3;
-  break;
-
-// 4 byte values
-case DW_FORM_addrx4:
-case DW_FORM_data4:
-case DW_FORM_ref4:
-case DW_FORM_strx4:
-  form_size = 4;
-  break;
-
-// 8 byte values
-case DW_FORM_data8:
-case DW_FORM_ref8:
-case DW_FORM_ref_sig8:
-  form_size = 8;
-  break;
-
-// signed or unsigned LEB 128 values
-case DW_FORM_addrx:
-case DW_FORM_loclistx:
-case DW_FORM_rnglistx:
-case DW_FORM_sdata:
-case DW_FORM_udata:
-case DW_FORM_ref_udata:
-case DW_FORM_GNU_addr_index:
-case DW_FORM_GNU_str_index:
-case DW_FORM_strx:
-  data.Skip_LEB128(&offset);

dwblaikie wrote:

Ah, right - of course. Thanks for walking me through it!

https://github.com/llvm/llvm-project/pull/69531
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][NFCI] Remove duplicated code in DWARFParser (PR #69531)

2023-10-19 Thread David Blaikie via lldb-commits

https://github.com/dwblaikie approved this pull request.


https://github.com/llvm/llvm-project/pull/69531
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bd21efe - [lldb] Fix ASCII art in CommandObjectSource.h (NFC)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-19T10:30:38-07:00
New Revision: bd21efe24c7670bc8d6f5c3bb92f12b0d1983e0b

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

LOG: [lldb] Fix ASCII art in CommandObjectSource.h (NFC)

Added: 


Modified: 
lldb/source/Commands/CommandObjectSource.h

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectSource.h 
b/lldb/source/Commands/CommandObjectSource.h
index f2117bd6ca3f794..d552508f448ec4d 100644
--- a/lldb/source/Commands/CommandObjectSource.h
+++ b/lldb/source/Commands/CommandObjectSource.h
@@ -1,5 +1,4 @@
-//===-- CommandObjectSource.h.h ---*- C++
-//-*-===//
+//===-- CommandObjectSource.h ---*- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -14,8 +13,6 @@
 
 namespace lldb_private {
 
-// CommandObjectMultiwordSource
-
 class CommandObjectMultiwordSource : public CommandObjectMultiword {
 public:
   CommandObjectMultiwordSource(CommandInterpreter &interpreter);



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


[Lldb-commits] [lldb] [Reland] Detect against invalid variant index for LibStdC++ std::variant data formatters (PR #69614)

2023-10-19 Thread via lldb-commits


@@ -7183,7 +7183,8 @@ GetNthTemplateArgument(const 
clang::ClassTemplateSpecializationDecl *decl,
   // (including the ones preceding the parameter pack).
   const auto &pack = args[last_idx];
   const size_t pack_idx = idx - last_idx;
-  assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
+  if (pack_idx >= pack.pack_size())
+return nullptr;

jeffreytan81 wrote:

It is requested by @clayborg's comment in the original patch:
```
If this is what was crashing, we should modify the GetTemplateArgumentType() to 
not crash with an inalid index as part of this fix.
```

https://github.com/llvm/llvm-project/pull/69614
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5bae3a0 - [lldb] Remove CompileUnit::SetSupportFiles overload (NFC)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-19T11:14:25-07:00
New Revision: 5bae3a0b0ccf8f4f2bcffc86453197f3cc5a9829

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

LOG: [lldb] Remove CompileUnit::SetSupportFiles overload (NFC)

CompileUnit::SetSupportFiles had two overloads, one that took and lvalue
reference and one that takes an rvalue reference. This removes both and
replaces it with an overload that takes the FileSpecList by value and
moves it into the member variable.

Because we're storing the value as a member, this covers both cases. If
the new FileSpecList was passed by lvalue reference, we'd copy it into
the member anyway. If it was passed as an rvalue reference, we'll have
created a new instance using its move and then immediately move it again
into our member. In either case the number of copies remains unchanged.

Added: 


Modified: 
lldb/include/lldb/Symbol/CompileUnit.h
lldb/source/Symbol/CompileUnit.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompileUnit.h 
b/lldb/include/lldb/Symbol/CompileUnit.h
index 229ee2d27a703fd..93f191b49985847 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -331,8 +331,7 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// A line table object pointer that this object now owns.
   void SetLineTable(LineTable *line_table);
 
-  void SetSupportFiles(const FileSpecList &support_files);
-  void SetSupportFiles(FileSpecList &&support_files);
+  void SetSupportFiles(FileSpecList support_files);
 
   void SetDebugMacros(const DebugMacrosSP &debug_macros);
 

diff  --git a/lldb/source/Symbol/CompileUnit.cpp 
b/lldb/source/Symbol/CompileUnit.cpp
index 280425d5874b494..c9796973940a248 100644
--- a/lldb/source/Symbol/CompileUnit.cpp
+++ b/lldb/source/Symbol/CompileUnit.cpp
@@ -178,11 +178,7 @@ void CompileUnit::SetLineTable(LineTable *line_table) {
   m_line_table_up.reset(line_table);
 }
 
-void CompileUnit::SetSupportFiles(const FileSpecList &support_files) {
-  m_support_files = support_files;
-}
-
-void CompileUnit::SetSupportFiles(FileSpecList &&support_files) {
+void CompileUnit::SetSupportFiles(FileSpecList support_files) {
   m_support_files = std::move(support_files);
 }
 



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


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/69388

>From bafeea33e1aea4a9e947220a78801ef241106eac Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 18 Oct 2023 17:16:50 -0700
Subject: [PATCH 1/2] [lldb] Refactor InstrumentationRuntimeAsan

This commit refactors InstrumentationRuntimeASan by pulling out reusable
code into a separate ReportRetriever class. The purpose of the
refactoring is to allow reuse of the ReportRetriever class in another
plugin.

rdar://112491689
---
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../ASan/CMakeLists.txt   |   5 +-
 .../ASan/InstrumentationRuntimeASan.cpp   | 242 ++---
 .../ASan/InstrumentationRuntimeASan.h |   7 -
 .../InstrumentationRuntime/CMakeLists.txt |   1 +
 .../Utility/CMakeLists.txt|  10 +
 .../Utility/ReportRetriever.cpp   | 252 ++
 .../Utility/ReportRetriever.h |  34 +++
 8 files changed, 315 insertions(+), 237 deletions(-)
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/CMakeLists.txt
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.h

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 36f3030c5226d60..206ff4ed7e6ad05 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -527,6 +527,7 @@ enum InstrumentationRuntimeType {
   eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002,
   eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
   eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
+  eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
   eNumInstrumentationRuntimeTypes
 };
 
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index 0b29027018463fe..b746a16b31f7789 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -4,10 +4,7 @@ add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
   LINK_LIBS
 lldbBreakpoint
 lldbCore
-lldbExpression
-lldbInterpreter
 lldbSymbol
 lldbTarget
-  LINK_COMPONENTS
-Support
+lldbPluginInstrumentationRuntimeUtility
   )
diff --git 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 5fcdc808bbb154c..a09c89103b0e3dd 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -9,23 +9,14 @@
 #include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/StreamFile.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Stream.h"
 
-#include "llvm/ADT/StringSwitch.h"
+#include "Plugins/InstrumentationRuntime/Utility/ReportRetriever.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -69,169 +60,6 @@ bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
   return symbol != nullptr;
 }
 
-const char *address_sanitizer_retrieve_report_data_prefix = R"(
-extern "C"
-{
-int __asan_report_present();
-void *__asan_get_report_pc();
-void *__asan_get_report_bp();
-void *__asan_get_report_sp();
-void *__asan_get_report_address();
-const char *__asan_get_report_description();
-int __asan_get_report_access_type();
-size_t __asan_get_report_access_size();
-}
-)";
-
-const char *address_sanitizer_retrieve_report_data_command = R"(
-struct {
-int present;
-int access_type;
-void *pc;
-void *bp;
-void *sp;
-void *address;
-size_t access_size;
-const char *description;
-} t;
-
-t.present = __asan_report_present();
-t.access_type = __asan_get_report_access_type();
-t.pc = __asan_get_report_pc();
-t.bp = __asan_get_report_bp();
-t.sp = __asan_get_report_sp();
-t.address = __asan_get_report_address();
-t.access_size = __asan_get_report_access_size();
-t.description = __asan_get_report_description();
-t
-)";
-
-StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
-  ProcessSP process_sp = GetProcessSP();
-  if (!process_sp)
-return StructuredDat

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/69388

>From bafeea33e1aea4a9e947220a78801ef241106eac Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 18 Oct 2023 17:16:50 -0700
Subject: [PATCH 1/2] [lldb] Refactor InstrumentationRuntimeAsan

This commit refactors InstrumentationRuntimeASan by pulling out reusable
code into a separate ReportRetriever class. The purpose of the
refactoring is to allow reuse of the ReportRetriever class in another
plugin.

rdar://112491689
---
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../ASan/CMakeLists.txt   |   5 +-
 .../ASan/InstrumentationRuntimeASan.cpp   | 242 ++---
 .../ASan/InstrumentationRuntimeASan.h |   7 -
 .../InstrumentationRuntime/CMakeLists.txt |   1 +
 .../Utility/CMakeLists.txt|  10 +
 .../Utility/ReportRetriever.cpp   | 252 ++
 .../Utility/ReportRetriever.h |  34 +++
 8 files changed, 315 insertions(+), 237 deletions(-)
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/CMakeLists.txt
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.h

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 36f3030c5226d60..206ff4ed7e6ad05 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -527,6 +527,7 @@ enum InstrumentationRuntimeType {
   eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002,
   eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
   eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
+  eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
   eNumInstrumentationRuntimeTypes
 };
 
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index 0b29027018463fe..b746a16b31f7789 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -4,10 +4,7 @@ add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
   LINK_LIBS
 lldbBreakpoint
 lldbCore
-lldbExpression
-lldbInterpreter
 lldbSymbol
 lldbTarget
-  LINK_COMPONENTS
-Support
+lldbPluginInstrumentationRuntimeUtility
   )
diff --git 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 5fcdc808bbb154c..a09c89103b0e3dd 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -9,23 +9,14 @@
 #include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/StreamFile.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Stream.h"
 
-#include "llvm/ADT/StringSwitch.h"
+#include "Plugins/InstrumentationRuntime/Utility/ReportRetriever.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -69,169 +60,6 @@ bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
   return symbol != nullptr;
 }
 
-const char *address_sanitizer_retrieve_report_data_prefix = R"(
-extern "C"
-{
-int __asan_report_present();
-void *__asan_get_report_pc();
-void *__asan_get_report_bp();
-void *__asan_get_report_sp();
-void *__asan_get_report_address();
-const char *__asan_get_report_description();
-int __asan_get_report_access_type();
-size_t __asan_get_report_access_size();
-}
-)";
-
-const char *address_sanitizer_retrieve_report_data_command = R"(
-struct {
-int present;
-int access_type;
-void *pc;
-void *bp;
-void *sp;
-void *address;
-size_t access_size;
-const char *description;
-} t;
-
-t.present = __asan_report_present();
-t.access_type = __asan_get_report_access_type();
-t.pc = __asan_get_report_pc();
-t.bp = __asan_get_report_bp();
-t.sp = __asan_get_report_sp();
-t.address = __asan_get_report_address();
-t.access_size = __asan_get_report_access_size();
-t.description = __asan_get_report_description();
-t
-)";
-
-StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
-  ProcessSP process_sp = GetProcessSP();
-  if (!process_sp)
-return StructuredDat

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits


@@ -1,5 +1,7 @@
+add_subdirectory(Libsanitizers)

usama54321 wrote:

I moved the plugin in the parent directory. However, I was not sure how to name 
the plugin so I have currently named the folder as ASanLibsanitizers and named 
the files as InstrumentationRuntimeASan.cpp which matches the original ASan 
plugin naming. I did this mostly to keep the filename/macro short and will 
appreciate any feedback on this.

https://github.com/llvm/llvm-project/pull/69388
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits

usama54321 wrote:

Thanks a lot for the feedback @bulbazord and @JDevlieghere. I have updated the 
PR. I will appreciate any feedback about the directory/file naming convention 
after the update.

https://github.com/llvm/llvm-project/pull/69388
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/69388

>From bafeea33e1aea4a9e947220a78801ef241106eac Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 18 Oct 2023 17:16:50 -0700
Subject: [PATCH 1/2] [lldb] Refactor InstrumentationRuntimeAsan

This commit refactors InstrumentationRuntimeASan by pulling out reusable
code into a separate ReportRetriever class. The purpose of the
refactoring is to allow reuse of the ReportRetriever class in another
plugin.

rdar://112491689
---
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../ASan/CMakeLists.txt   |   5 +-
 .../ASan/InstrumentationRuntimeASan.cpp   | 242 ++---
 .../ASan/InstrumentationRuntimeASan.h |   7 -
 .../InstrumentationRuntime/CMakeLists.txt |   1 +
 .../Utility/CMakeLists.txt|  10 +
 .../Utility/ReportRetriever.cpp   | 252 ++
 .../Utility/ReportRetriever.h |  34 +++
 8 files changed, 315 insertions(+), 237 deletions(-)
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/CMakeLists.txt
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.h

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 36f3030c5226d60..206ff4ed7e6ad05 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -527,6 +527,7 @@ enum InstrumentationRuntimeType {
   eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002,
   eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
   eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
+  eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
   eNumInstrumentationRuntimeTypes
 };
 
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index 0b29027018463fe..b746a16b31f7789 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -4,10 +4,7 @@ add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
   LINK_LIBS
 lldbBreakpoint
 lldbCore
-lldbExpression
-lldbInterpreter
 lldbSymbol
 lldbTarget
-  LINK_COMPONENTS
-Support
+lldbPluginInstrumentationRuntimeUtility
   )
diff --git 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 5fcdc808bbb154c..a09c89103b0e3dd 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -9,23 +9,14 @@
 #include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/StreamFile.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Stream.h"
 
-#include "llvm/ADT/StringSwitch.h"
+#include "Plugins/InstrumentationRuntime/Utility/ReportRetriever.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -69,169 +60,6 @@ bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
   return symbol != nullptr;
 }
 
-const char *address_sanitizer_retrieve_report_data_prefix = R"(
-extern "C"
-{
-int __asan_report_present();
-void *__asan_get_report_pc();
-void *__asan_get_report_bp();
-void *__asan_get_report_sp();
-void *__asan_get_report_address();
-const char *__asan_get_report_description();
-int __asan_get_report_access_type();
-size_t __asan_get_report_access_size();
-}
-)";
-
-const char *address_sanitizer_retrieve_report_data_command = R"(
-struct {
-int present;
-int access_type;
-void *pc;
-void *bp;
-void *sp;
-void *address;
-size_t access_size;
-const char *description;
-} t;
-
-t.present = __asan_report_present();
-t.access_type = __asan_get_report_access_type();
-t.pc = __asan_get_report_pc();
-t.bp = __asan_get_report_bp();
-t.sp = __asan_get_report_sp();
-t.address = __asan_get_report_address();
-t.access_size = __asan_get_report_access_size();
-t.description = __asan_get_report_description();
-t
-)";
-
-StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
-  ProcessSP process_sp = GetProcessSP();
-  if (!process_sp)
-return StructuredDat

[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-10-19 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/69516

>From 073ba299ab15c487bff28212563b5a103bdc5f60 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Wed, 18 Oct 2023 13:07:51 -0700
Subject: [PATCH 1/5] [lldb][progress] Add discrete boolean flag to progress
 reports

This commit adds a boolean flag `is_discrete` is to progress reports in
LLDB. The flag is set to false by default and indicates if a progress event is 
discrete, i.e. an
operation that has no clear start and end and can happen multiple times
during the course of a debug session. Operations that happen
in this manner will report multiple individual progress events as they
happen, so this flag gives the functionality to group multiple progress
events so they can be reported in a less haphazard manner.
---
 lldb/include/lldb/Core/Debugger.h|  2 +-
 lldb/include/lldb/Core/DebuggerEvents.h  |  7 +--
 lldb/include/lldb/Core/Progress.h| 10 +-
 lldb/source/Core/Debugger.cpp| 16 +---
 lldb/source/Core/DebuggerEvents.cpp  |  1 +
 lldb/source/Core/Progress.cpp|  4 ++--
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp|  2 +-
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp|  2 +-
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp |  4 ++--
 lldb/source/Symbol/LocateSymbolFile.cpp  |  2 +-
 .../progress_reporting/TestProgressReporting.py  | 11 +++
 11 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 5532cace606bfed..8e21502dac6dee2 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -618,7 +618,7 @@ class Debugger : public 
std::enable_shared_from_this,
   static void ReportProgress(uint64_t progress_id, std::string title,
  std::string details, uint64_t completed,
  uint64_t total,
- std::optional debugger_id);
+ std::optional debugger_id, bool 
is_discrete);
 
   static void ReportDiagnosticImpl(DiagnosticEventData::Type type,
std::string message,
diff --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 982b9701f89..88455d8d60bb488 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -21,10 +21,11 @@ class Stream;
 class ProgressEventData : public EventData {
 public:
   ProgressEventData(uint64_t progress_id, std::string title, std::string 
update,
-uint64_t completed, uint64_t total, bool debugger_specific)
+uint64_t completed, uint64_t total, bool debugger_specific,
+bool is_discrete)
   : m_title(std::move(title)), m_details(std::move(update)),
 m_id(progress_id), m_completed(completed), m_total(total),
-m_debugger_specific(debugger_specific) {}
+m_debugger_specific(debugger_specific), m_is_discrete(is_discrete) {}
 
   static llvm::StringRef GetFlavorString();
 
@@ -52,6 +53,7 @@ class ProgressEventData : public EventData {
   const std::string &GetTitle() const { return m_title; }
   const std::string &GetDetails() const { return m_details; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }
+  bool IsDiscrete() const { return m_is_discrete; }
 
 private:
   /// The title of this progress event. The value is expected to remain stable
@@ -68,6 +70,7 @@ class ProgressEventData : public EventData {
   uint64_t m_completed;
   const uint64_t m_total;
   const bool m_debugger_specific;
+  const bool m_is_discrete;
   ProgressEventData(const ProgressEventData &) = delete;
   const ProgressEventData &operator=(const ProgressEventData &) = delete;
 };
diff --git a/lldb/include/lldb/Core/Progress.h 
b/lldb/include/lldb/Core/Progress.h
index b2b8781a43b0591..a48255fc88cf69b 100644
--- a/lldb/include/lldb/Core/Progress.h
+++ b/lldb/include/lldb/Core/Progress.h
@@ -69,8 +69,13 @@ class Progress {
   ///
   /// @param [in] debugger An optional debugger pointer to specify that this
   /// progress is to be reported only to specific debuggers.
+  ///
+  /// @param [in] is_discrete Boolean indicating whether or not
+  /// this progress report will happen once during a debug session or multiple
+  /// times as individual progress reports.
   Progress(std::string title, uint64_t total = UINT64_MAX,
-   lldb_private::Debugger *debugger = nullptr);
+   lldb_private::Debugger *debugger = nullptr,
+   bool is_discrete = false);
 
   /// Destroy the progress object.
   ///
@@ -110,6 +115,9 @@ class Progress {
   /// to ensure that we don't send progress updates after progress has
   /// completed.
   bool m_complete = false;
+  /// Set to true if the progress event is discrete; meaning it will happen

[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Joseph Huber via lldb-commits


@@ -0,0 +1,17 @@
+//===-- Implementation of the GPU lroundf function

jhuber6 wrote:

This and some other headers need to be reformatted.

https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Joseph Huber via lldb-commits


@@ -0,0 +1,21 @@
+//===-- Implementation of the GPU atan2f function

jhuber6 wrote:

Fix header

https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Joseph Huber via lldb-commits

https://github.com/jhuber6 approved this pull request.

LG after fixing the header formatting.

https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Joseph Huber via lldb-commits


@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU logbf function

jhuber6 wrote:

Fix header

https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Joseph Huber via lldb-commits

https://github.com/jhuber6 edited 
https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits

https://github.com/usama54321 updated 
https://github.com/llvm/llvm-project/pull/69388

>From bafeea33e1aea4a9e947220a78801ef241106eac Mon Sep 17 00:00:00 2001
From: usama 
Date: Wed, 18 Oct 2023 17:16:50 -0700
Subject: [PATCH 1/2] [lldb] Refactor InstrumentationRuntimeAsan

This commit refactors InstrumentationRuntimeASan by pulling out reusable
code into a separate ReportRetriever class. The purpose of the
refactoring is to allow reuse of the ReportRetriever class in another
plugin.

rdar://112491689
---
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../ASan/CMakeLists.txt   |   5 +-
 .../ASan/InstrumentationRuntimeASan.cpp   | 242 ++---
 .../ASan/InstrumentationRuntimeASan.h |   7 -
 .../InstrumentationRuntime/CMakeLists.txt |   1 +
 .../Utility/CMakeLists.txt|  10 +
 .../Utility/ReportRetriever.cpp   | 252 ++
 .../Utility/ReportRetriever.h |  34 +++
 8 files changed, 315 insertions(+), 237 deletions(-)
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/CMakeLists.txt
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
 create mode 100644 
lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.h

diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 36f3030c5226d60..206ff4ed7e6ad05 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -527,6 +527,7 @@ enum InstrumentationRuntimeType {
   eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002,
   eInstrumentationRuntimeTypeMainThreadChecker = 0x0003,
   eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004,
+  eInstrumentationRuntimeTypeLibsanitizersAsan = 0x0005,
   eNumInstrumentationRuntimeTypes
 };
 
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
index 0b29027018463fe..b746a16b31f7789 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/CMakeLists.txt
@@ -4,10 +4,7 @@ add_lldb_library(lldbPluginInstrumentationRuntimeASan PLUGIN
   LINK_LIBS
 lldbBreakpoint
 lldbCore
-lldbExpression
-lldbInterpreter
 lldbSymbol
 lldbTarget
-  LINK_COMPONENTS
-Support
+lldbPluginInstrumentationRuntimeUtility
   )
diff --git 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 5fcdc808bbb154c..a09c89103b0e3dd 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -9,23 +9,14 @@
 #include "InstrumentationRuntimeASan.h"
 
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Host/StreamFile.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
-#include "lldb/Target/StopInfo.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "lldb/Utility/Stream.h"
 
-#include "llvm/ADT/StringSwitch.h"
+#include "Plugins/InstrumentationRuntime/Utility/ReportRetriever.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -69,169 +60,6 @@ bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
   return symbol != nullptr;
 }
 
-const char *address_sanitizer_retrieve_report_data_prefix = R"(
-extern "C"
-{
-int __asan_report_present();
-void *__asan_get_report_pc();
-void *__asan_get_report_bp();
-void *__asan_get_report_sp();
-void *__asan_get_report_address();
-const char *__asan_get_report_description();
-int __asan_get_report_access_type();
-size_t __asan_get_report_access_size();
-}
-)";
-
-const char *address_sanitizer_retrieve_report_data_command = R"(
-struct {
-int present;
-int access_type;
-void *pc;
-void *bp;
-void *sp;
-void *address;
-size_t access_size;
-const char *description;
-} t;
-
-t.present = __asan_report_present();
-t.access_type = __asan_get_report_access_type();
-t.pc = __asan_get_report_pc();
-t.bp = __asan_get_report_bp();
-t.sp = __asan_get_report_sp();
-t.address = __asan_get_report_address();
-t.access_size = __asan_get_report_access_size();
-t.description = __asan_get_report_description();
-t
-)";
-
-StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
-  ProcessSP process_sp = GetProcessSP();
-  if (!process_sp)
-return StructuredDat

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-19 Thread Usama Hameed via lldb-commits


@@ -1,5 +1,7 @@
+add_subdirectory(Libsanitizers)

usama54321 wrote:

More specifically, I have named the file 
`ASanLibsanitizers/InstrumentationRuntimeASan.cpp` instead of 
`ASanLibsanitizers/InstrumentationRuntimeASanLibsanitizers.cpp`

https://github.com/llvm/llvm-project/pull/69388
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Anton Rydahl via lldb-commits

AntonRydahl wrote:

> LG after fixing the header formatting.

Thanks a bunch! I don't know how I did not notice the misformatted headers. I 
have fixed those now.

https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)

2023-10-19 Thread Anton Rydahl via lldb-commits

https://github.com/AntonRydahl closed 
https://github.com/llvm/llvm-project/pull/66034
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f9632ce - [lldb] Remove FileSpecList::GetFileSpecPointerAtIndex (NFC)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-19T13:13:31-07:00
New Revision: f9632cee30b788df7a6241d7802224d8f633973a

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

LOG: [lldb] Remove FileSpecList::GetFileSpecPointerAtIndex (NFC)

There's only one use and it eventually converts the pointer into a
reference. Simplify things and always use references.

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Utility/FileSpecList.h
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Target/Target.cpp
lldb/source/Utility/FileSpecList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 8752b42a9518983..82045988018b606 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -683,7 +683,7 @@ class Target : public std::enable_shared_from_this,
   // Use this to create a breakpoint from a load address and a module file spec
   lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr,
  bool internal,
- const FileSpec *file_spec,
+ const FileSpec &file_spec,
  bool request_hardware);
 
   // Use this to create Address breakpoints:

diff  --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 6b88cd2f3091379..14e8069f5ebd6d2 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -155,19 +155,6 @@ class FileSpecList {
   /// returned.
   const FileSpec &GetFileSpecAtIndex(size_t idx) const;
 
-  /// Get file specification pointer at index.
-  ///
-  /// Gets a file from the file list. The file objects that are returned can
-  /// be tested using FileSpec::operator void*().
-  ///
-  /// \param[in] idx
-  /// An index into the file list.
-  ///
-  /// \return
-  /// A pointer to a contained FileSpec object at index \a idx.
-  /// If \a idx is out of range, then an NULL is returned.
-  const FileSpec *GetFileSpecPointerAtIndex(size_t idx) const;
-
   /// Get the memory cost of this object.
   ///
   /// Return the size in bytes that this object takes in memory. This returns

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 327dae4fd2afbba..18cbb9528b717a5 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -603,8 +603,8 @@ class CommandObjectBreakpointSet : public 
CommandObjectParsed {
   //  will track the load location of the library.
   size_t num_modules_specified = m_options.m_modules.GetSize();
   if (num_modules_specified == 1) {
-const FileSpec *file_spec =
-m_options.m_modules.GetFileSpecPointerAtIndex(0);
+const FileSpec &file_spec =
+m_options.m_modules.GetFileSpecAtIndex(0);
 bp_sp = target.CreateAddressInModuleBreakpoint(
 m_options.m_load_addr, internal, file_spec, m_options.m_hardware);
   } else if (num_modules_specified == 0) {

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 069b7bcdc40e614..5f8756c57675c95 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -480,12 +480,12 @@ BreakpointSP Target::CreateBreakpoint(const Address 
&addr, bool internal,
 
 lldb::BreakpointSP
 Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal,
-const FileSpec *file_spec,
+const FileSpec &file_spec,
 bool request_hardware) {
   SearchFilterSP filter_sp(
   new SearchFilterForUnconstrainedSearches(shared_from_this()));
   BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(
-  nullptr, file_addr, file_spec ? *file_spec : FileSpec()));
+  nullptr, file_addr, file_spec));
   return CreateBreakpoint(filter_sp, resolver_sp, internal, request_hardware,
   false);
 }

diff  --git a/lldb/source/Utility/FileSpecList.cpp 
b/lldb/source/Utility/FileSpecList.cpp
index e5e0ac3e5981b1b..35486fdc7eff16e 100644
--- a/lldb/source/Utility/FileSpecList.cpp
+++ b/lldb/source/Utility/FileSpecList.cpp
@@ -140,12 +140,6 @@ const FileSpec &FileSpecList::GetFileSpecAtIndex(size_t 
idx) const {
   return g_empty_file_spec;
 }
 
-const FileSpec *FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const {
-  if (idx < m_files.size())
-return &m_files[idx];
-  return nullptr;
-}
-
 // Return the s

[Lldb-commits] [lldb] ea9e116 - [lldb][NFCI] Remove duplicated code in DWARFParser (#69531)

2023-10-19 Thread via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-10-19T14:10:31-07:00
New Revision: ea9e116e5a24e834142bc4024b57697b48599a9e

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

LOG: [lldb][NFCI] Remove duplicated code in DWARFParser (#69531)

The method DWARFDebugInfoEntry::Extract needs to skip over all the data
in the debug_info / debug_types section for each DIE. It had the logic
to do so hardcoded inside a loop, when it already exists in a neatly
isolated function.

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index a18836e5d94..1b0fefedf983694 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -50,16 +50,12 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   lldbassert(abbr_idx <= UINT16_MAX);
   m_abbr_idx = abbr_idx;
 
-  // assert (fixed_form_sizes);  // For best performance this should be
-  // specified!
-
   if (m_abbr_idx == 0) {
 m_tag = llvm::dwarf::DW_TAG_null;
 m_has_children = false;
 return true; // NULL debug tag entry
   }
 
-  lldb::offset_t offset = *offset_ptr;
   const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
   if (abbrevDecl == nullptr) {
 cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
@@ -74,137 +70,18 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   m_tag = abbrevDecl->getTag();
   m_has_children = abbrevDecl->hasChildren();
   // Skip all data in the .debug_info or .debug_types for the attributes
-  dw_form_t form;
   for (const auto &attribute : abbrevDecl->attributes()) {
-form = attribute.Form;
-std::optional fixed_skip_size =
-DWARFFormValue::GetFixedSize(form, cu);
-if (fixed_skip_size)
-  offset += *fixed_skip_size;
-else {
-  bool form_is_indirect = false;
-  do {
-form_is_indirect = false;
-uint32_t form_size = 0;
-switch (form) {
-// Blocks if inlined data that have a length field and the data bytes
-// inlined in the .debug_info/.debug_types
-case DW_FORM_exprloc:
-case DW_FORM_block:
-  form_size = data.GetULEB128(&offset);
-  break;
-case DW_FORM_block1:
-  form_size = data.GetU8_unchecked(&offset);
-  break;
-case DW_FORM_block2:
-  form_size = data.GetU16_unchecked(&offset);
-  break;
-case DW_FORM_block4:
-  form_size = data.GetU32_unchecked(&offset);
-  break;
-
-// Inlined NULL terminated C-strings
-case DW_FORM_string:
-  data.GetCStr(&offset);
-  break;
-
-// Compile unit address sized values
-case DW_FORM_addr:
-  form_size = cu->GetAddressByteSize();
-  break;
-case DW_FORM_ref_addr:
-  if (cu->GetVersion() <= 2)
-form_size = cu->GetAddressByteSize();
-  else
-form_size = 4;
-  break;
+if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, cu))
+  continue;
 
-// 0 sized form
-case DW_FORM_flag_present:
-  form_size = 0;
-  break;
-
-// 1 byte values
-case DW_FORM_addrx1:
-case DW_FORM_data1:
-case DW_FORM_flag:
-case DW_FORM_ref1:
-case DW_FORM_strx1:
-  form_size = 1;
-  break;
-
-// 2 byte values
-case DW_FORM_addrx2:
-case DW_FORM_data2:
-case DW_FORM_ref2:
-case DW_FORM_strx2:
-  form_size = 2;
-  break;
-
-// 3 byte values
-case DW_FORM_addrx3:
-case DW_FORM_strx3:
-  form_size = 3;
-  break;
-
-// 4 byte values
-case DW_FORM_addrx4:
-case DW_FORM_data4:
-case DW_FORM_ref4:
-case DW_FORM_strx4:
-  form_size = 4;
-  break;
-
-// 8 byte values
-case DW_FORM_data8:
-case DW_FORM_ref8:
-case DW_FORM_ref_sig8:
-  form_size = 8;
-  break;
-
-// signed or unsigned LEB 128 values
-case DW_FORM_addrx:
-case DW_FORM_loclistx:
-case DW_FORM_rnglistx:
-case DW_FORM_sdata:
-case DW_FORM_udata:
-case DW_FORM_ref_udata:
-case DW_FORM_GNU_addr_index:
-case DW_FORM_GNU_str_index:
-case DW_FORM_strx:
-  data.Skip_LEB128(&offset);
-  break;
-
-case DW_FORM_indirect:
-  form_is_indirect = true;
-  form = static_cast(data.GetULEB128(&offset));
- 

[Lldb-commits] [lldb] [lldb][NFCI] Remove duplicated code in DWARFParser (PR #69531)

2023-10-19 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan closed 
https://github.com/llvm/llvm-project/pull/69531
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 969ba9f - [lldb] Remove FileSpecList::GetFilesMatchingPartialPath (NFC)

2023-10-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-19T15:17:36-07:00
New Revision: 969ba9ff1477d9dc350aa1b3f5fd23b6f6af76cd

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

LOG: [lldb] Remove FileSpecList::GetFilesMatchingPartialPath (NFC)

This function is unused and unimplemented.

Added: 


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

Removed: 




diff  --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 14e8069f5ebd6d2..77587aa917916b8 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -200,9 +200,6 @@ class FileSpecList {
 return false;
   }
 
-  static size_t GetFilesMatchingPartialPath(const char *path, bool dir_okay,
-FileSpecList &matches);
-
   const_iterator begin() const { return m_files.begin(); }
   const_iterator end() const { return m_files.end(); }
 

diff  --git a/lldb/source/Utility/FileSpecList.cpp 
b/lldb/source/Utility/FileSpecList.cpp
index 35486fdc7eff16e..d5369ac4bbe5160 100644
--- a/lldb/source/Utility/FileSpecList.cpp
+++ b/lldb/source/Utility/FileSpecList.cpp
@@ -156,9 +156,3 @@ size_t FileSpecList::MemorySize() const {
 
 // Return the number of files in the file spec list.
 size_t FileSpecList::GetSize() const { return m_files.size(); }
-
-size_t FileSpecList::GetFilesMatchingPartialPath(const char *path,
- bool dir_okay,
- FileSpecList &matches) {
-  return 0;
-}



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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH] Update stdckdint.h and make it available in pre-C23 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

https://github.com/ZijunZhaoCCK ready_for_review 
https://github.com/llvm/llvm-project/pull/69649
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: None (ZijunZhaoCCK)


Changes

Update some tests and docs.

---
Full diff: https://github.com/llvm/llvm-project/pull/69649.diff


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1-1) 
- (modified) clang/lib/Headers/stdckdint.h (-4) 
- (modified) clang/test/C/C2x/n2359.c (-5) 
- (modified) clang/test/C/C2x/n2683.c (+1) 
- (modified) clang/test/C/C2x/n2683_2.c (+1) 
- (modified) clang/test/Headers/stdckdint.c (+5-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

``




https://github.com/llvm/llvm-project/pull/69649
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread Jessica Clarke via lldb-commits


@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"

jrtc27 wrote:

And this test needs to stay

https://github.com/llvm/llvm-project/pull/69649
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread Jessica Clarke via lldb-commits


@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.

jrtc27 wrote:

Don't start a sentence with And

https://github.com/llvm/llvm-project/pull/69649
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread Jessica Clarke via lldb-commits


@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L

jrtc27 wrote:

This needs to stay, `__STDC_VERSION_STDCKDINT_H__` is defined by C23, not just 
something Clang invented

https://github.com/llvm/llvm-project/pull/69649
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH] Update stdckdint.h and make it available in pre-C23 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 1/2] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

>From 4e2fd920121b15e014a6146c6c6672973bae4443 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 2/2] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst   | 2 +-
 clang/lib/Headers/stdckdint.h | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0de52a5bf122f4..1b1f25ae244ef9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang 

[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 1/2] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

>From 4e2fd920121b15e014a6146c6c6672973bae4443 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 2/2] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst   | 2 +-
 clang/lib/Headers/stdckdint.h | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0de52a5bf122f4..1b1f25ae244ef9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang 

[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-19 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 1/3] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

>From 4e2fd920121b15e014a6146c6c6672973bae4443 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 2/3] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst   | 2 +-
 clang/lib/Headers/stdckdint.h | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0de52a5bf122f4..1b1f25ae244ef9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang