Losing prompt when running any python commands

I’m seeing something a little odd but I’m not really sure if it’s a bug.

If I start lldb (on Linux) and then execute any python commands, then set a target and a breakpoint and run it, when the breakpoint goes off I’ve lost my prompt. It’s sitting there waiting for input, but I don’t see the “(lldb)” that should be there. This happens when I run any python commands at all. It appears to just lose the prompt. Some commands will cause the prompt to return (like bt) but others like n or step execute but the prompt doesn’t return.

This loss of prompt also happens if you run any python commands with command script import.

Is there some sort of mode or is this a bug?

Here’s some sample output where I run the python command “script print lldb”

matthews@matthews-linux:~/work/llvm/llvm/build$ bin/lldb -x
(lldb) script print lldb
<module ‘lldb’ from ‘/data/work/llvm/llvm/build/lib/python2.7/site-packages/lldb/init.py’>
(lldb) target create /home/matthews/bin/mytest
Current executable set to ‘/home/matthews/bin/mytest’ (x86_64).
(lldb) b main
Breakpoint 1: where = mytest`main + 30 at test.c:14, address = 0x000000000040054e
(lldb) run
Process 20443 launched: ‘/home/matthews/bin/mytest’ (x86_64)
Process 20443 stopped

  • thread #1: tid = 0x4fdb, 0x000000000040054e mytestmain(argc=1, argv=0x00007fff62b4b058) + 30 at test.c:14, stop reason = breakpoint 1.1 frame #0: 0x000000000040054e mytestmain(argc=1, argv=0x00007fff62b4b058) + 30 at test.c:14
    11 int main(int argc, char *argv)
    12 {
    13 int i;
    → 14 printf(“Argc=%d\n”, argc);
    15 for(i=0;i<argc;i++)
    16 printf(“Argument %d: %s\n”, i, argv[i]);
    17
    <should be an (lldb) prompt here but it’s just blank and waiting for input>

FYI Matthew,

I can reproduce this issue consistently on Ubuntu 12.04 with libedit 2.11, Unity 5.0 and Gnome terminal 3.4.1.1 (all current defaults). According to http://llvm.org/bugs/show_bug.cgi?id=14637, a work-around is to upgrade libedit (the NetBSD editline library) to version 3.0,

  • Ashok

It's a bug — I've heard reports that building against a newer libedit will fix the problem:

However, most distributions ship with an ancient version. I'm not sure if there's any (licensing or other) restrictions that would prevent someone from checking in the updated libedit into lldb source tree…I haven't really had time to look at this problem in detail though..

Dan

For what it's worth, on FreeBSD lldb picks up the base system's
libedit, which shares a common ancestry with NetBSD. This problem is
not reproducible here.

Looking at libedit was on my list, so I’ll take a look at this and see what can be done.

If we are thinking of building a readline/editline/other line editor package as part of LLDB, we might take a look around and see if there aren't any other non GPLv3 line editors we would rather use.

I have heard that zsh might have a nice line editor that could be used. I am not sure how well libedit stacks up to competing line editors.

Greg Clayton

I can verify that using the libedit from http://www.thrysoee.dk/editline/ does fix the problems with losing the prompt after running a python script. Though its build/install doesn’t overwrite the stock Ubuntu version so it was kind of painful to switch just temporarily. Lldb did seem to build just fine with it. It also seemed to handle up-arrow/history and backspace better than the stock version, though I don’t really have a repro case for bugs I’ve seen in that area. (where backing up causes you to get lost on the edit line)

I’m not sure we really want to move it into lldb though, but I’d say it’s definitely a requirement if you want to use lldb on Linux.

What are your concerns with checking in an updated libedit (or another similar library like the zsh that Greg mentioned)? As far as I understand, the BSD licensing is permissive enough to do that, and there's other (albeit less critical) libraries checked into the LLDB source tree, such as pexpect.

Dan

I think the license should be fine, but I’m not a lawyer. The real question is how would you like it integrated in? I’ll take a look at pexpect and see how it was merged in. At the very least I assume you’ll want some way to allow the build system to use the system version instead. Is there anything else that it needs to do?

Yeah, after thinking about this a little more, I'm not sure how nice it will be to integrate libedit into the lldb source tree — it looks like lots of activity is going on in libedit upstream, and it will be annoying to tie ourselves to a single version, or to update the version we build against at some regular interval.

I had a chat with Sylvestre (cc'd; he's responsible for the Debian/Ubuntu llvm-toolchain packages) and he's looking into what it would take to update the libedit-dev version that we're all building against. If it's possible to just update everyone's libedit packages, I think that would be a more favourable route to a less buggy LLDB on Debian/Ubuntu :slight_smile:

Cheers,
Dan

I don't see anyone extra cc'd?

What would this "update libedit-dev" look like? We've got most folks
running Ubuntu 12.04 and it'd sure be nice to be able to build with a
#define set (or the like) to get a newer version of libedit that doesn't
have these issues even if it isn't enabled by default on those platforms.

Thanks.
-Mike

Looks like the list stripped out the extra CC..I'm trying to add Sylvestre to the "to:" field in case that helps.

Sylvestre, regarding the eventual libedit update, would people with existing released versions of Ubuntu be able to take advantage of it (via a 3rd party repo like llvm.org/apt) or would it be something that's targeting strictly upcoming releases of Debian/Ubuntu? That is to say, what's the easiest way to get lldb built against libedit 3.0 (statically or otherwise) into the hands of people who are running Ubuntu 12.04 for example?

Thanks,
Dan

Sure. I could backport it for the distributions I am supporting on
llvm.org/apt/.

However, before doing so, I would just like to hear back from the
current libedit maintainer (to avoid duplicating the work on the package).

Thanks
Sylvestre

In case anyone else is running into prompt issues on Linux, we took libedit
3.1, compiled it, shoved it in lldb/extern/libedit/libedit-3.1 and made the
changes below to our working lldb source tree. (
https://bitbucket.org/mikesart/lldb_branch ) This is allowing us to get
around these issues until a more official solution is worked out.
-Mike

source/CMakeLists.txt

if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
set( LLDB_SYSTEM_LIBS
  ${LLDB_SOURCE_DIR}/extern/libedit/libedit-3.1/lib/libedit.a
  tinfo
  python2.7
  )
else()
set( LLDB_SYSTEM_LIBS
  edit
  python2.7
  )
endif()

tools/driver/CMakeLists.txt

if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
include_directories("../../extern/libedit/libedit-3.1/include")
endif()

Thanks for the feedback.

By the way, I have the agreement from the current maintainer of libedit
in Debian/Ubuntu to help him with the packaging.

I pushed the almost finished version here:
http://anonscm.debian.org/gitweb/?p=collab-maint/libedit.git;a=summary

The main thing remaining to check is the consistency of the API between
the old release that we had and this one. I will do that in a couple of
weeks (I am off).

Sylvestre

I uploaded the latest version of libedit in Debian experimental:
http://packages.qa.debian.org/libe/libedit.html
and requested a sync for Ubuntu Saucy:

Hopefully, this will fix the lldb issues.
I requested for feedback from some Debian maintainers/teams on this new
releases. Once I get enough, I will upload this version in Debian
unstable (and it will migrate to Debian testing aka jessie).
I will backport it for http://llvm.org/apt/ at some point.

Sylvestre

Hello,

I uploaded the latest version of libedit in Debian experimental:
Debian Package Tracking System - libedit
and requested a sync for Ubuntu Saucy:
Bug #1208524 “Sync libedit 3.1-20130712-1~exp2 (main) from Debia...” : Bugs : libedit package : Ubuntu

Hopefully, this will fix the lldb issues.
I requested for feedback from some Debian maintainers/teams on this new
releases. Once I get enough, I will upload this version in Debian
unstable (and it will migrate to Debian testing aka jessie).
I will backport it for LLVM Debian/Ubuntu packages at some point.

An update on the subject:

I didn't get any bad feedback on this next upstream release.
Therefor, I uploaded libedit to Debian unstable [1] this morning (Paris time) and requested for a sync for Ubuntu saucy [2].

Cheers,
Sylvestre
[1] Accepted libedit 3.1-20130712-1 (source amd64)
[2] Bug #1216011 “Sync libedit 3.1-20130712-1 (main) from Debian uns...” : Bugs : libedit package : Ubuntu

That's awesome! Thanks Sylvestre; it will be nice to not have the prompt
disappear anymore :slight_smile: