On 02/15/2018 02:21 PM, Pavel Labath wrote:
I've tried your sample, and I was indeed able to reproduce the
problem. What makes your case special is that "sin" and "cos" are
indirect functions (STT_GNU_IFUNC), so we have to do some extra work
(call the resolver function) to resolve them.
I've changed my sample to dlsym() a regular function instead of an indirect
stub, and got a breakpoint hit, but:
(lldb) attach 16196
Process 16196 stopped
* thread #1, name = 'main', stop reason = signal SIGSTOP
frame #0: 0x0000000000400798 main`main(argc=1, argv=0x00007ffd6f662668) at
main.c:16
13 for (a = 0; a < DELAY + argc; a++)
14 for (b = 0; b < DELAY + argc; b++)
15 for (c = 0; c < DELAY + argc; c++)
-> 16 z += a + b + c;
17 while (1)
18 {
19 void *handle = dlopen ("libfoo.so", RTLD_LAZY);
Executable module set to "/home/dantipov/tmp/t-dl2/main".
Architecture set to: x86_64--linux.
(lldb) breakpoint set -n foo
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) process continue
Process 16196 resuming
1 location added to breakpoint 1
(lldb) error: ld-linux-x86-64.so.2 0x0005d207: adding range [0x14eea-0x14f5a) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of
this error message
error: ld-linux-x86-64.so.2 0x0005d207: adding range [0x14f70-0x14f76) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this
error message
error: ld-linux-x86-64.so.2 0x0005d268: adding range [0x14eea-0x14f5a) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this
error message
error: ld-linux-x86-64.so.2 0x0005d268: adding range [0x14f70-0x14f76) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this
error message
Process 16196 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
frame #0: 0x00007f3b1a8536f7
libfoo.so`foo(v=0.00000000000003907985046680551) at libfoo.c:6
3 double
4 foo (double v)
5 {
-> 6 return sin (v) + cos (v);
7 }
This seems to be an another bug, isn't it?
Dmitry
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may
contain
confidential information. Any unauthorized review, use, disclosure or
distribution
is prohibited. If you are not the intended recipient, please contact the
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
#include <math.h>
double
foo (double v)
{
return sin (v) + cos (v);
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dlfcn.h>
#define DELAY 2000
int
main (int argc, char *argv[])
{
/* Busy loop long enough to attach the debugger before dlopen happens. */
int a, b, c, z = 0;
for (a = 0; a < DELAY + argc; a++)
for (b = 0; b < DELAY + argc; b++)
for (c = 0; c < DELAY + argc; c++)
z += a + b + c;
while (1)
{
void *handle = dlopen ("libfoo.so", RTLD_LAZY);
if (handle)
{
int i;
double sum = 0.0;
double (*fooptr) (double) = dlsym (handle, "foo");
for (i = 0; i < 10; i++)
sum += fooptr (drand48 ());
printf ("%lf\n", sum);
dlclose (handle);
}
else
fprintf (stderr, "can't open shared object\n");
sleep (1);
}
return z;
}
all: libfoo.so main
libfoo.so: libfoo.c
gcc -fPIC -O0 -g3 -shared -o libfoo.so libfoo.c -lm
main: main.c
gcc -O0 -g3 -o main main.c -ldl
clean:
rm -f libfoo.so main
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev