Note that getAsInteger returns false on success, so be careful!<br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 20, 2017 at 6:09 AM Pavel Labath via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">labath added a comment.<br>
<br>
In <a href="https://reviews.llvm.org/D32149#731920" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32149#731920</a>, @krytarowski wrote:<br>
<br>
> In <a href="https://reviews.llvm.org/D32149#731887" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32149#731887</a>, @labath wrote:<br>
><br>
> > A test would infinitely times more valuable then a demo script. What is the tiniest core file you can produce on NetBSD? (on linux we've gotten them down to about 20K) Then we could check that in and write a test for it...<br>
><br>
><br>
> This is something I wanted to bring to the dev mailing list.<br>
><br>
> I wanted to prepare at least three tests, if possible four:<br>
><br>
> - one thread (if possible two variations: signal to one particular thread + signal to all threads)<br>
> - multiple threads (signal to one particular thread + signal to all threads)<br>
><br>
> And this in combination of all supported targets (x86_64, i386, etc).<br>
><br>
> Emitting SIGABRT for such program gives core of size 97kilobytes:<br>
><br>
> ``` int main(){for(;;);} ```<br>
><br>
> I will write assembly programs for the above cases, without libc.<br>
<br>
<br>
Cool, I am looking forward to the results.<br>
<br>
<br>
<br>
================<br>
Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:795<br>
+<br>
+ if ((note.n_name == "NetBSD-CORE") &&<br>
+ (note.n_type == NETBSD::NT_PROCINFO)) {<br>
----------------<br>
How about `StringRef name = note.n_name;`<br>
<br>
<br>
================<br>
Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:803<br>
+ m_auxv = DataExtractor(note_data);<br>
+ } else if ((note.n_name.substr(0, 12) == "NetBSD-CORE@")) {<br>
+ switch (arch.GetMachine()) {<br>
----------------<br>
Then this can be<br>
```<br>
else if (name.consume_front("NetBSD-CORE@")) {<br>
...<br>
if (name.getAsInteger(0, tid))<br>
error...<br>
```<br>
<br>
<br>
================<br>
Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:848<br>
+ if (siglwp == 0) {<br>
+ std::for_each(<br>
+ m_thread_data.begin(), m_thread_data.end(),<br>
----------------<br>
`for (auto &data: m_thread_data) data.signo = signo` seems shorter, more understandable, and consistent with other usages in this file.<br>
<br>
<br>
================<br>
Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:856<br>
+<br>
+ for (auto it = m_thread_data.begin(); it != m_thread_data.end(); ++it) {<br>
+ if (it->tid == siglwp) {<br>
----------------<br>
This could also be a range-based for.<br>
<br>
<br>
Repository:<br>
rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D32149" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32149</a><br>
<br>
<br>
<br>
</blockquote></div>