n00b
n00b

Reputation: 111

Xcode lldb error in lauch program

i get smilar error when i try launch my application (c++ command line) from xcode , (the application work fine from terminal .

XCode: Could not launch "APP_X_Y" - 'A' packet returned an error: -1

i tried every mentioned solution in above question but none of them helped me.

i finally found problem is launching using LLDB so GDB works fine. but i want to debug my program using LLDB and launch with default config in xcode.

the error is in following lldb function:

Error
PlatformRemoteGDBServer::LaunchProcess (ProcessLaunchInfo &launch_info)
{
    Error error;
    lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;

    m_gdb_client.SetSTDIN ("/dev/null");
    m_gdb_client.SetSTDOUT ("/dev/null");
    m_gdb_client.SetSTDERR ("/dev/null");
    m_gdb_client.SetDisableASLR (launch_info.GetFlags().Test (eLaunchFlagDisableASLR));

    const char *working_dir = launch_info.GetWorkingDirectory();
    if (working_dir && working_dir[0])
    {
        m_gdb_client.SetWorkingDir (working_dir);
    }

    // Send the environment and the program + arguments after we connect
    const char **argv = launch_info.GetArguments().GetConstArgumentVector();
    const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector();

    if (envp)
    {
        const char *env_entry;
        for (int i=0; (env_entry = envp[i]); ++i)
        {
            if (m_gdb_client.SendEnvironmentPacket(env_entry) != 0)
                break;
        }
    }
    const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (5);
    int arg_packet_err = m_gdb_client.SendArgumentsPacket (argv);
    m_gdb_client.SetPacketTimeout (old_packet_timeout);
    if (arg_packet_err == 0)
    {
        std::string error_str;
        if (m_gdb_client.GetLaunchSuccess (error_str))
        {
            pid = m_gdb_client.GetCurrentProcessID ();
            if (pid != LLDB_INVALID_PROCESS_ID)
                launch_info.SetProcessID (pid);
        }
        else
        {
            error.SetErrorString (error_str.c_str());
        }
    }
    else
    {
        **error.SetErrorStringWithFormat("**'A' packet returned an error: %i",** arg_packet_err);**
    }
    return error;
}

as you can see 'a' packet error is in lldb now question is how can fix this problem ? is there any solution to reinstall / reconfigure LLDB in xcode? can anyone find where is problem from lldb function.

i'm using latest Mac OS + Xcode 4.6.3 latest

please share your ideas .

Upvotes: 1

Views: 3567

Answers (2)

RabbitHole
RabbitHole

Reputation: 336

I was in the same situation. It happened after updating to Xcode 5 in my case. After all it works fine now.

I followed the command line executions as per the comment from Jason Molenda.

When running "xcrun lldb ..." I got an error:

xcrun error failed to exec real xcrun. (no such file or directory)

After Googling, I figured this out:

xcode-select -print-path
/Developer

As my Xcode was not in there, I did:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

I don't know why, but it didn't work immediately in my case. After quitting Xcode, Terminal, etc., Xcode ran and debug worked as expected.

Upvotes: 1

Jason Molenda
Jason Molenda

Reputation: 15375

This error happens when debugserver cannot launch the app you are trying to debug. debugserver launches, attaches, stops, inspects and controls the process - it is a small program with all of these responsibilities. It communicates to lldb (possibly inside Xcode) via the "gdb remote protocol", with some minor extensions.

If you've built your own lldb, chances are that debugserver is not properly code signed so it cannot launch apps.

If you've changed your /etc/hosts file, check that you have a line like 127.0.0.1 localhost in there. Some people have modified their /etc/hosts (I have no idea why) and removed this line, and this has caused problems for lldb trying to communicate with debugserver.

Otherwise, check the output in Console.app to see if there are any useful messages logged.

Upvotes: 2

Related Questions