<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/lldb/source/Commands/CommandObjectSource.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[lldb] Eliminate SupportFileSP nullptr derefs (#168624)</title>
<updated>2025-11-21T00:45:11+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-11-21T00:45:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=06eac9feb92cba1d24e8a674c643aae1200d2bc8'/>
<id>06eac9feb92cba1d24e8a674c643aae1200d2bc8</id>
<content type='text'>
This patch fixes and eliminates the possibility of SupportFileSP ever
being nullptr. The support file was originally treated like a value
type, but became a polymorphic type and therefore has to be stored and
passed around as a pointer.

To avoid having all the callers check the validity of the pointer, I
introduced the invariant that SupportFileSP is never null and always
default constructed. However, without enforcement at the type level,
that's fragile and indeed, we already identified two crashes where
someone accidentally broke that invariant.

This PR introduces a NonNullSharedPtr to prevent that. NonNullSharedPtr
is a smart pointer wrapper around std::shared_ptr that guarantees the
pointer is never null. If default-constructed, it creates a
default-constructed instance of the contained type. Note that I'm using
private inheritance because you shouldn't inherit from standard library
classes due to the lack of virtual destructor. So while the new
abstraction looks like a `std::shared_ptr`, it is in fact **not** a
shared pointer. Given that our destructor is trivial, we could use
public inheritance, but currently there's no need for it.

rdar://164989579</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch fixes and eliminates the possibility of SupportFileSP ever
being nullptr. The support file was originally treated like a value
type, but became a polymorphic type and therefore has to be stored and
passed around as a pointer.

To avoid having all the callers check the validity of the pointer, I
introduced the invariant that SupportFileSP is never null and always
default constructed. However, without enforcement at the type level,
that's fragile and indeed, we already identified two crashes where
someone accidentally broke that invariant.

This PR introduces a NonNullSharedPtr to prevent that. NonNullSharedPtr
is a smart pointer wrapper around std::shared_ptr that guarantees the
pointer is never null. If default-constructed, it creates a
default-constructed instance of the contained type. Note that I'm using
private inheritance because you shouldn't inherit from standard library
classes due to the lack of virtual destructor. So while the new
abstraction looks like a `std::shared_ptr`, it is in fact **not** a
shared pointer. Given that our destructor is trivial, we could use
public inheritance, but currently there's no need for it.

rdar://164989579</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Correct style of error messages (#156774)</title>
<updated>2025-09-04T23:37:41+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2025-09-04T23:37:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=820f4402745dda82fca482f2b83925e2953e6ad9'/>
<id>820f4402745dda82fca482f2b83925e2953e6ad9</id>
<content type='text'>
The LLVM Style Guide says the following about error and warning messages
[1]:

&gt; [T]o match error message styles commonly produced by other tools,
&gt; start the first sentence with a lowercase letter, and finish the last
&gt; sentence without a period, if it would end in one otherwise.

I often provide this feedback during code review, but we still have a
bunch of places where we have inconsistent error message, which bothers
me as a user. This PR identifies a handful of those places and updates
the messages to be consistent.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The LLVM Style Guide says the following about error and warning messages
[1]:

&gt; [T]o match error message styles commonly produced by other tools,
&gt; start the first sentence with a lowercase letter, and finish the last
&gt; sentence without a period, if it would end in one otherwise.

I often provide this feedback during code review, but we still have a
bunch of places where we have inconsistent error message, which bothers
me as a user. This PR identifies a handful of those places and updates
the messages to be consistent.

[1] https://llvm.org/docs/CodingStandards.html#error-and-warning-messages</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb]Make `list` command work with  headers when possible. (#139002)</title>
<updated>2025-05-19T15:04:01+00:00</updated>
<author>
<name>Vy Nguyen</name>
<email>vyng@google.com</email>
</author>
<published>2025-05-19T15:04:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=dc25ab389c2d441ba378d4db56a4a61e3eedb889'/>
<id>dc25ab389c2d441ba378d4db56a4a61e3eedb889</id>
<content type='text'>
Given this simple test case:

```
// foo.h
extern int* ptr;
inline void g(int x) {
  *ptr = x; // should raise a SIGILL
}
//--------------
// foo.cc
#include "foo.h"
int* ptr;

//--------------
// main.cc

#include "foo.h"

int main() {
  g(123); // Call the inlined function and crash
  return 0;
}

$ clang -g main.cc foo.cc -o main.out
$ lldb main.out
```

When you run `main.out` under lldb, it'd stop inside `void g(int)`
because of the crash.
The stack trace would show that it had crashed in `foo.h`, but if you do
`list foo.h:2`, lldb would complain that it could not find the source
file, which is confusing.

This patch make `list` work with headers.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Given this simple test case:

```
// foo.h
extern int* ptr;
inline void g(int x) {
  *ptr = x; // should raise a SIGILL
}
//--------------
// foo.cc
#include "foo.h"
int* ptr;

//--------------
// main.cc

#include "foo.h"

int main() {
  g(123); // Call the inlined function and crash
  return 0;
}

$ clang -g main.cc foo.cc -o main.out
$ lldb main.out
```

When you run `main.out` under lldb, it'd stop inside `void g(int)`
because of the crash.
The stack trace would show that it had crashed in `foo.h`, but if you do
`list foo.h:2`, lldb would complain that it could not find the source
file, which is confusing.

This patch make `list` work with headers.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] print a notice when `source list` paging reaches the end of th… (#137515)</title>
<updated>2025-05-08T14:01:16+00:00</updated>
<author>
<name>Zax</name>
<email>44502668+hapeeeeee@users.noreply.github.com</email>
</author>
<published>2025-05-08T14:01:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b5674cb7be1b010be181883601a3674ceef38683'/>
<id>b5674cb7be1b010be181883601a3674ceef38683</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Fixing edge cases in "source list" (#126526)</title>
<updated>2025-02-21T12:13:34+00:00</updated>
<author>
<name>Pavel Labath</name>
<email>pavel@labath.sk</email>
</author>
<published>2025-02-21T12:13:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=71af48fafdb6319da38ee7e5f04e16ff548fe57e'/>
<id>71af48fafdb6319da38ee7e5f04e16ff548fe57e</id>
<content type='text'>
While looking at how to make Function::GetEndLineSourceInfo (which is
only used in "command source") work with discontinuous functions, I
realized there are other corner cases that this function doesn't handle.

The code assumed that the last line entry in the function will also
correspond to the last source line. This is probably true for
unoptimized code, but I don't think we can rely on the optimizer to
preserve this property. What's worse, the code didn't check that the
last line entry belonged to the same file as the first one, so if this
line entry was the result of inlining, we could end up using a line from
a completely different file.

To fix this, I change the algorithm to iterate over all line entries in
the function (which belong to the same file) and find the max line
number out of those. This way we can naturally handle the discontinuous
case as well.

This implementation is going to be slower than the previous one, but I
don't think that matters, because:
- this command is only used rarely, and interactively
- we have plenty of other code which iterates through the line table

I added some basic tests for the function operation. I don't claim the
tests to be comprehensive, or that the function handles all edge cases,
but test framework created here could be used for testing other
fixes/edge cases as well.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While looking at how to make Function::GetEndLineSourceInfo (which is
only used in "command source") work with discontinuous functions, I
realized there are other corner cases that this function doesn't handle.

The code assumed that the last line entry in the function will also
correspond to the last source line. This is probably true for
unoptimized code, but I don't think we can rely on the optimizer to
preserve this property. What's worse, the code didn't check that the
last line entry belonged to the same file as the first one, so if this
line entry was the result of inlining, we could end up using a line from
a completely different file.

To fix this, I change the algorithm to iterate over all line entries in
the function (which belong to the same file) and find the max line
number out of those. This way we can naturally handle the discontinuous
case as well.

This implementation is going to be slower than the previous one, but I
don't think that matters, because:
- this command is only used rarely, and interactively
- we have plenty of other code which iterates through the line table

I added some basic tests for the function operation. I don't claim the
tests to be comprehensive, or that the function handles all edge cases,
but test framework created here could be used for testing other
fixes/edge cases as well.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb][NFC] Make the target's SectionLoadList private. (#113278)</title>
<updated>2025-01-15T04:12:46+00:00</updated>
<author>
<name>Greg Clayton</name>
<email>gclayton@fb.com</email>
</author>
<published>2025-01-15T04:12:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c4fb7180cbbe977f1ab1ce945a691550f8fdd1fb'/>
<id>c4fb7180cbbe977f1ab1ce945a691550f8fdd1fb</id>
<content type='text'>
Lots of code around LLDB was directly accessing the target's section
load list. This NFC patch makes the section load list private so the
Target class can access it, but everyone else now uses accessor
functions. This allows us to control the resolving of addresses and will
allow for functionality in LLDB which can lazily resolve addresses in
JIT plug-ins with a future patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Lots of code around LLDB was directly accessing the target's section
load list. This NFC patch makes the section load list private so the
Target class can access it, but everyone else now uses accessor
functions. This allows us to control the resolving of addresses and will
allow for functionality in LLDB which can lazily resolve addresses in
JIT plug-ins with a future patch.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Fix source display for artificial locations (#115876)</title>
<updated>2024-11-13T08:56:00+00:00</updated>
<author>
<name>Pavel Labath</name>
<email>pavel@labath.sk</email>
</author>
<published>2024-11-13T08:56:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=39b2979a434e70a4ce76d4adf91572dcfc9662ff'/>
<id>39b2979a434e70a4ce76d4adf91572dcfc9662ff</id>
<content type='text'>
When retrieving the location of the function declaration, we were
dropping the file component on the floor, which resulted in an amusingly
confusing situation were we displayed the file containing the
implementation of the function, but used the line number of the
declaration. This patch fixes that.

It required a small refactor Function::GetStartLineSourceLineInfo to
return a SupportFile (instead of just the file spec), which in turn
necessitated changes in a couple of other places as well.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When retrieving the location of the function declaration, we were
dropping the file component on the floor, which resulted in an amusingly
confusing situation were we displayed the file containing the
implementation of the function, but used the line number of the
declaration. This patch fixes that.

It required a small refactor Function::GetStartLineSourceLineInfo to
return a SupportFile (instead of just the file spec), which in turn
necessitated changes in a couple of other places as well.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Avoid FileSpec indirection where we can use SupportFiles directly</title>
<updated>2024-09-03T21:38:39+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2024-09-03T17:33:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=98bde7fd872c10e49035d5dc5d2f2b44489f6a07'/>
<id>98bde7fd872c10e49035d5dc5d2f2b44489f6a07</id>
<content type='text'>
Now that more parts of LLDB know about SupportFiles, avoid going through
FileSpec (and losing the Checksum in the process). Instead, use the
SupportFile directly.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that more parts of LLDB know about SupportFiles, avoid going through
FileSpec (and losing the Checksum in the process). Instead, use the
SupportFile directly.
</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Deal with SupportFiles in SourceManager (NFC) (#106740)</title>
<updated>2024-08-30T17:58:32+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2024-08-30T17:58:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=130eddf7a13f15c9c48b7fa7faf60e9bbee4f703'/>
<id>130eddf7a13f15c9c48b7fa7faf60e9bbee4f703</id>
<content type='text'>
To support detecting MD5 checksum mismatches, deal with SupportFiles
rather than a plain FileSpecs in the SourceManager.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To support detecting MD5 checksum mismatches, deal with SupportFiles
rather than a plain FileSpecs in the SourceManager.</pre>
</div>
</content>
</entry>
<entry>
<title>[lldb] Store SupportFiles in SourceManager::File (NFC) (#106639)</title>
<updated>2024-08-30T14:18:55+00:00</updated>
<author>
<name>Jonas Devlieghere</name>
<email>jonas@devlieghere.com</email>
</author>
<published>2024-08-30T14:18:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ab40ae8ff9f87b6e3d68cab2c47d692016ede958'/>
<id>ab40ae8ff9f87b6e3d68cab2c47d692016ede958</id>
<content type='text'>
To support detecting MD5 checksum mismatches, store a SupportFile rather
than a plain FileSpec in SourceManager::File.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To support detecting MD5 checksum mismatches, store a SupportFile rather
than a plain FileSpec in SourceManager::File.</pre>
</div>
</content>
</entry>
</feed>
