[Bug 25194] New: LLDB-Server Assertion raised when single stepping on MIPS

Bug ID 25194
Summary LLDB-Server Assertion raised when single stepping on MIPS
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter aidan@codeplay.com
CC llvm-bugs@lists.llvm.org
Classification Unclassified

When using LLDB-Server on the Android Mips32 emulator and assertion is raised
when performing a single step.  The sample program attached can be used to
reproduce this problem.

The sample program was compiled using the mips toolchain from the Android NDK,
specificaly: gcc version 4.9 20140827 (prerelease) (GCC).
The binary was compiled at -O0 with debug info.

The test case is as follows:

<main.cpp>
#include <stdio.h>
#include <unistd.h>

static volatile bool e = true;

int main() {

    printf("hello world!\n");

    while (e) {
        usleep(1);
    }

    printf( "exiting...\n" );
    return 0;
}
</main.cpp>

If I place a breakpoint on line 11 (usleep) and then inside of usleep for 10
instructions or so, the following occurs.

1|root@generic_mips:/data # ./lldb-server-3.8.0-s g *:1234 -- test             
using the default platform: host
Launched 'test' as process 963...
lldb-server-local_buildListening to port 1234 for a connection from *...
Connection established.
/home/aidan/rs/llvm/tools/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp:1640:
lldb_private::Error
lldb_private::process_linux::NativeProcessLinux::SetupSoftwareSingleStepping(lldb_private::process_linux::NativeThreadLinux&):
assertion "pc_it != baton.m_register_values.end() && "Emulation was successfull
but PC wasn't updated"" failed
Aborted 

>From the perspective of lldb server I see this:

(lldb) s
Process 963 stopped
* thread #1: tid = 963, 0x77d35748, name = 'test', stop reason = instruction
step into
    frame #0: 0x77d35748
->  0x77d35748: addiu  $sp, $sp, -40
    0x77d3574c: addiu  $7, $6, 16960
    0x77d35750: mfhi   $5
    0x77d35754: sw     $ra, 36($sp)
(lldb) s
Process 963 exited with status = -1 (0xffffffff) lost connection

I have seen the same assersion fire up when single stepping in a more
complicated scenario.

My version of LLDB was build from the upstream git mirror from commit:
adb9afc13ea113e2daeed6c739ecc2d52e2fd7d7

I have attached the source code for the sample, and a copy of my compiled
binary.

Sagar changed bug 25194

What | Removed | Added |

Comment # 1 on bug 25194 from Sagar

Fixed by commit rL254379.