[lldb-dev] Odd behavior with test TestThreadSelectionBug.py

2019-05-14 Thread Ted Woodward via lldb-dev
This test uses the responder and a python OS plugin.

When I run the full test suite, it passes, with this thread list:
runCmd: thread list
output: Process 1 stopped
* thread #1: tid = 0x0001, 0x, name = 'one', queue = 'queue1'
  thread #2: tid = 0x0002, 0x, name = 'two', queue = 'queue2'
  thread #3: tid = 0x0003, 0x, name = 'three', queue = 'queue3', stop 
reason = signal SIGINT

When I run the test by itself, it fails with this thread list:
runCmd: thread list
output: Process 1 stopped
* thread #2: tid = 0x1, 0x, name = 'one', queue = 'queue1'
  thread #3: tid = 0x2, 0x, name = 'two', queue = 'queue2'
  thread #4: tid = 0x3, 0x, name = 'three', queue = 'queue3', 
stop reason = signal SIGINT

Anyone have any idea why this is?

packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py
___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


[lldb-dev] Access to TLS variables on GNU/Linux

2019-05-14 Thread Florian Weimer via lldb-dev
I'm trying to access thread-local variables using the API on GNU/Linux.
Here's my test program:

#include 
#include 
#include 

#include 
#include 
#include 

thread_local int global_tls_variable
  __attribute__ ((tls_model ("initial-exec")))= 17;

int
main(void)
{
  // Target process for the debugger.
  pid_t pid = fork();
  if (pid < 0)
err(1, "fork");
  if (pid == 0)
while (true)
  pause();

  lldb::SBDebugger::Initialize();
  {
lldb::SBDebugger debugger{lldb::SBDebugger::Create()};
if (!debugger.IsValid())
  errx(1, "SBDebugger::Create failed");

lldb::SBTarget target{debugger.CreateTarget(nullptr)};
if (!target.IsValid())
  errx(1, "SBDebugger::CreateTarget failed");

lldb::SBAttachInfo attachinfo(pid);
lldb::SBError error;
lldb::SBProcess process{target.Attach(attachinfo, error)};
if (!process.IsValid())
  errx(1, "SBTarget::Attach failed: %s", error.GetCString());

lldb::SBValue value{target.FindFirstGlobalVariable("global_tls_variable")};
if (!value.IsValid())
  errx(1, "SBTarget::FindFirstGlobalVariable: %s",
   value.GetError().GetCString());
printf("global_tls_variable (LLDB): %d\n",
   (int) value.GetValueAsSigned());
printf("value type: %d\n", (int) value.GetValueType());
  }
  lldb::SBDebugger::Terminate();

  if (kill(pid, SIGKILL) != 0)
err(1, "kill");
  if (waitpid(pid, NULL, 0) < 0)
err(1, "waitpid");

  return 0;
}

It prints:

global_tls_variable (LLDB): 0
value type: 4

The target process has loaded libpthread.so.0, so it's not the usual
problem of libthread_db not working without libpthread.

On the other hand, I realize now that the lldb command cannot access TLS
variables, either.  Is this expected to work at all?

I'm using lldb-7.0.1-1.fc29.x86_64 from Fedora 29 (which is built around
GCC 8 and glibc 2.28).

Thanks,
Florian
___
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev