<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - LLDB can't attach to the PostgreSQL backend process"
href="https://llvm.org/bugs/show_bug.cgi?id=26924">26924</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLDB can't attach to the PostgreSQL backend process
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>afiskon@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I compiled PostgreSQL on FreeBSD 10.2 using CLang 3.7. The problem is that I
can't attach to the PostgreSQL backend process using LLDB 3.7:
```
[eax@freebsd102 ~]$ ps wuax | grep postgres
eax 29177 0.0 2.0 169592 20888 - Is 6:11PM 0:00.00 postgres:
checkpointer process (postgres)
eax 29178 0.0 2.0 169592 20924 - Ss 6:11PM 0:00.07 postgres: writer
process (postgres)
eax 29179 0.0 2.0 169592 20924 - Ss 6:11PM 0:00.01 postgres: wal
writer process (postgres)
eax 29180 0.0 2.1 169592 21140 - Is 6:11PM 0:00.01 postgres:
autovacuum launcher process (postgres)
eax 29181 0.0 1.0 24320 10216 - Ss 6:11PM 0:00.00 postgres: stats
collector process (postgres)
eax 29192 0.0 2.3 169592 23456 - Ss 6:14PM 0:00.04 postgres: eax
eax [local] idle (postgres)
eax 29083 0.0 2.0 169592 20880 0 S 6:06PM 0:00.07
/usr/home/eax/postgresql-install/bin/postgres -D
/home/eax/postgresql-install/data
eax 29196 0.0 0.2 18824 2340 1 S+ 6:15PM 0:00.00 grep postgres
[eax@freebsd102 ~]$ lldb -p 29192
(lldb) process attach --pid 29192
error: attach failed: unable to find executable for 'postgres: eax eax [local]
idle'
(lldb) q
```
In the same time everything works as expected for processes with "regular
names":
```
[eax@freebsd102 ~]$ lldb -p 29192
(lldb) process attach --pid 29192
error: attach failed: unable to find executable for 'postgres: eax eax [local]
idle'
(lldb) q
[eax@freebsd102 ~]$ lldb -p 29083
(lldb) process attach --pid 29083
Process 29083 stopped
Executable module set to "/usr/home/eax/postgresql-install/bin/postgres".
Architecture set to: x86_64-unknown-freebsd10.2-unknown.
(lldb) bt
* thread #1: tid = 100429, 0x000000080147beea libc.so.7`__sys_select + 10
* frame #0: 0x000000080147beea libc.so.7`__sys_select + 10
frame #1: 0x000000000081a326 postgres`ServerLoop + 262 at postmaster.c:1654
frame #2: 0x0000000000817db8 postgres`PostmasterMain(argc=3,
argv=0x00007fffffffeab0) + 6008 at postmaster.c:1298
frame #3: 0x00000000007481a9 postgres`main(argc=3, argv=0x00007fffffffeab0)
+ 793 at main.c:228
frame #4: 0x0000000000471baf postgres`_start + 367
(lldb) q
```
There is no such issue in gdb/gcc.
In the same time for such a program:
```
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
char new_name[] = "postgres: eax eax [local] idle";
int main(int argc, char* argv[])
{
memcpy(argv[0], new_name, sizeof(new_name));
printf("Parent: %d\n", getpid());
if(0 == fork()) {
printf("Child: %d\n", getpid());
}
sleep(100);
}
```
... everything works as expected:
```
[eax@freebsd102 ~/temp]$ /usr/local/bin/clang37 -O0 -g test.c -o test
[eax@freebsd102 ~/temp]$ ./test &
[1] 829
[eax@freebsd102 ~/temp]$ Parent: 829
Child: 830
[eax@freebsd102 ~/temp]$ lldb -p 829
(lldb) process attach --pid 829
Process 829 stopped
Executable module set to "./test".
Architecture set to: x86_64-unknown-freebsd10.2-unknown.
(lldb) bt
* thread #1: tid = 100363, 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
* frame #0: 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
frame #1: 0x000000080087ed1b libc.so.7`sleep + 43
frame #2: 0x00000000004008cf test`main(argc=1, argv=0x00007fffffffebb8) +
175 at test.c:18
frame #3: 0x000000000040073f test`_start + 367
(lldb) ^D
[1]+ Done ./test
[eax@freebsd102 ~/temp]$ lldb -p 830
(lldb) process attach --pid 830
Process 830 stopped
Executable module set to "./test".
Architecture set to: x86_64-unknown-freebsd10.2-unknown.
(lldb) b
No breakpoints currently set.
(lldb) bt
* thread #1: tid = 100351, 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
* frame #0: 0x00000008008f9cea libc.so.7`__sys_nanosleep + 10
frame #1: 0x000000080087ed1b libc.so.7`sleep + 43
frame #2: 0x00000000004008cf test`main(argc=1, argv=0x00007fffffffebb8) +
175 at test.c:18
frame #3: 0x000000000040073f test`_start + 367
(lldb) ^D
```
So the problem seems to be a bit more complicated then just handling changed
argv[0].</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>