Bug 9362 - Failed to run and debug a project to qemux86 in Eclipse
Summary: Failed to run and debug a project to qemux86 in Eclipse
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 2.1
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.1.2
Assignee: brian avery
QA Contact: Valentin Hangan
URL:
Whiteboard: Krogoth backport needed
Depends on:
Blocks:
 
Reported: 2016-03-31 13:04 UTC by Valentin Hangan
Modified: 2016-11-28 19:18 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
profile-configuration-with-toolchain (80.83 KB, image/png)
2016-03-31 13:04 UTC, Valentin Hangan
no flags Details
run-project-results (403.35 KB, image/png)
2016-03-31 13:06 UTC, Valentin Hangan
no flags Details
debug-project-results (358.82 KB, image/png)
2016-03-31 13:07 UTC, Valentin Hangan
no flags Details
PowerTop (139.40 KB, image/png)
2016-04-13 09:00 UTC, Alexandru Roman
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Valentin Hangan 2016-03-31 13:04:34 UTC
Created attachment 3081 [details]
profile-configuration-with-toolchain

Commit: 21823cb466e79540567ad1a43ae6f93d850e4057
Eclipse version: luna, mars
OS: Fedora 21
Tested toolchain versions: 
  - poky-glibc-x86_64-core-image-sato-i586-toolchain-2.0+snapshot.sh (without "-ext")

Steps:

1. Download and install toolchain from AB (yocto-2.1_M3.rc2)
    - download toolchain http://autobuilder.yoctoproject.org/pub/releases/yocto-2.1_M3.rc2/toolchain/x86_64/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.0+snapshot.sh
   - run script poky-glibc-x86_64-core-image-sato-i586-toolchain-2.0+snapshot.sh
   - Enter target directory for toolchain: /home/yocto/eclipse-run/yocto-M3.rc2/installed/toolchain
   - Output:
"Poky (Yocto Project Reference Distro) SDK installer version 2.0+snapshot
========================================================================
Enter target directory for SDK (default: /opt/poky/2.0+snapshot): /home/yocto/eclipse-run/yocto-M3.rc2/installed/toolchain
You are about to install the SDK to "/home/yocto/eclipse-run/yocto-M3.rc2/installed/toolchain". Proceed[Y/n]? Y
Extracting SDK................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/yocto/eclipse-run/yocto-M3.rc2/installed/toolchain/environment-setup-i586-poky-linux
2. Download core-image-sato-sdk-qemux86.tar.bz2 archive for sysroot:   
http://autobuilder.yoctoproject.org/pub/releases/yocto-2.1_M3.rc2/machines/qemu/qemux86/core-image-sato-sdk-qemux86.tar.bz2
   - Clone poky
   - source oe-init-build-env
   - runqemu-extract-sdk /home/yocto/eclipse-run/yocto-M3.rc2/download/core-image-sato-sdk-qemux86.tar.bz2 /home/yocto/eclipse-run/yocto-M3.rc2/installed/qemux86
   - Output:
"Creating directory /home/yocto/eclipse-run/yocto-M3.rc2/installed/qemux86
Extracting rootfs tarball using pseudo...
/home/yocto/eclipse-run/yocto-M3.rc2/download/poky/build/tmp/sysroots/x86_64-linux/usr/bin/pseudo -P /home/yocto/eclipse-run/yocto-M3.rc2/download/poky/build/tmp/sysroots/x86_64-linux/usr tar -C "/home/yocto/eclipse-run/yocto-M3.rc2/installed/qemux86" --numeric-owner -xjf "/home/yocto/eclipse-run/yocto-M3.rc2/download/core-image-sato-sdk-qemux86.tar.bz2"
SDK image successfully extracted to /home/yocto/eclipse-run/yocto-M3.rc2/installed/qemux86
"
 
3. Download bzImage-qemux86.bin for QEMU Kernel (http://autobuilder.yoctoproject.org/pub/releases/yocto-2.1_M3.rc2/machines/qemu/qemux86/bzImage-qemux86.bin)

4.Configure in Eclipse a Yocto Project ADT profile with:
   - Cross Compiler Options: Standalone pre-built
   - Toolchain Root Location: /home/yocto/eclipse-run/yocto-M3.rc2/installed/toolchain (target directory for toolchain)
   - Sysroot Location: /home/yocto/eclipse-run/yocto-M3.rc2/installed/qemux86 (pointing where i extract sysroot from archive)
   - Target Options: QEMU
   - Kernel: /home/yocto/eclipse-run/yocto-M3.rc2/download/bzImage-qemux86.bin 

6. Apply settings for Standard Profile
7. Create a Hello Word C Project
 New-->Project-->C Project-->Yocto Project ADT Autotools Project-->Hello Word ANSI C Autotools Project

8. Reconfigure Project
9. Build Project
10. Run Project:
    - Run as --> Run Configuration
    - select project
    - Configure C/C++ Application" field input Remote Absolute File path for C/C++ Application with "home/root/myApplication"
    - create a ssh connection to qemu 
    - press Run button

Expected Results:

Console Output Eclipse
Last login: Thu Mar 31 12:29:23 2016 from 192.168.7.1
echo $PWD'>'
/home/root/myApplication;exit
root@qemux86:~# echo $PWD'>'
/home/root>
root@qemux86:~# /home/root/myApplication;exit
Hello World
logout

Output on qemux86 if you run ./myApplication
Hello World

Actual Results:

Console Output Eclipse
Last login: Thu Mar 31 12:22:45 2016 from 192.168.7.1
echo $PWD'>'
/home/root/myApplication;exit
root@qemux86:~# 

Output on qemux86 if you run ./myApplication
sh: ./myApplication: Permision denied

11. Debug Project
    - Debug as --> Debug Configuration
    - select project
    - Configure C/C++ Application" field input Remote Absolute File path for C/C++ Application with "home/root/myApplication"
    - create a ssh connection to qemu 
    - Use GDB(DSF) Automatic Remote Debugging Launcher
    - press Debug button

Expected Results:
    - Confirm Perspective Switch to open Debug perspective
    - Debug Perspective is open.

Actual Results
    - Launching myProject is blocked at 57% and after 5 minutes appears Problem Occured window with message: "Could not start gdbserver on the remote host. See console output for more details." but in console we don't have any change.
Comment 1 Valentin Hangan 2016-03-31 13:06:17 UTC
Created attachment 3082 [details]
run-project-results
Comment 2 Valentin Hangan 2016-03-31 13:07:31 UTC
Created attachment 3083 [details]
debug-project-results
Comment 3 Richard Purdie 2016-03-31 13:24:48 UTC
To be clear, the screenshot shows there are no execute permissions on the transferred binary. Given the others errors reported, there may be other issues too.
Comment 4 Alexandru Roman 2016-04-13 09:00:20 UTC
Created attachment 3123 [details]
PowerTop

On 2.1: 296dfbc9b3a3c0ed64b8e748c2868928b9c2aa8b I was unable to start PowerTOP.
Due RP last comment I think this bug is related.

Steps to reproduce:
1. Launch a qemu of target enviroment
2. Expose YoctoTools -> PowerTop to connect the target
3. Create ssh connection.
4. Run PowerTop
When you try to run PowerTop the process get stuck at "Generating powertop data file remotely"
In the attachment you can see the warnings from terminal.
Comment 5 Humberto Ibarra 2016-06-02 20:13:44 UTC
Have a similar problem, not sure if my input helps here. I'm working with 1.8.2 and get the exact same gdbserver error window when I try to debug with GTK C Autotools project. Console shows binding problem:

Last login: Thu Jun  2 20:06:52 2016 from 192.168.7.1
echo $PWD'>'
export DISPLAY=:0.0;gdbserver :2345 /home/root/myapp45;exit
root@qemux86:~# echo $PWD'>'
/home/root>
root@qemux86:~# export DISPLAY=:0.0;gdbserver :2345 /home/root/myapp45;exit
Can't bind address: Address already in use.
Exiting
logout


ANSI C Autotools and ANSI C++ Autotools do not throw these errors for me, only GTK. Also, this is only a debug problem since the run works fine.
Comment 6 Humberto Ibarra 2016-06-02 20:16:58 UTC
Forgot to point out that binary is successfully created. It works from target, but eclipse is just unable to debug it.
Comment 7 Humberto Ibarra 2016-06-29 20:06:10 UTC
Still happening on 2.2 M1
Comment 8 brian avery 2016-08-11 21:18:09 UTC
fixed and merged into master.  Still needs to be backported to krogoth.
Comment 9 brian avery 2016-08-12 02:23:48 UTC
For a workaround in case you are on a version without the fix is to change:
/etc/profile in the image or meta/recipes-core/base-files/base-files/profile if you are building an image from:
if [ -x /usr/bin/resize ];then
  resize >/dev/null
fi

to
if [ -x /usr/bin/resize ];then
  # Make sure we are on a serial console (i.e. the device used starts with /dev/tty),
  # otherwise we confuse e.g. the eclipse launcher which tries do use ssh
  test `tty | cut -c1-8` = "/dev/tty" && resize >/dev/null
fi
Comment 10 brian avery 2016-08-18 16:32:50 UTC
fixed in master: commit 5aca5bc9a13d9d4a477cfd2d04edbcc8a8a0e412

will close when fix goes into krogoth.
Comment 11 brian avery 2016-08-23 16:39:35 UTC
master fixed in: 5aca5bc9a13d9d4a477cfd2d04edbcc8a8a0e412
krogoth fixed in: eef3fb99d0e3f52ffb5d8676f9ac11e546aad511
Comment 12 Ernst Persson 2016-09-28 08:48:08 UTC
I think this causes
/etc/profile: line 34: test: too many arguments
Starting Xserver
/etc/profile: line 34: test: too many arguments
on every boot now...
Comment 13 brian avery 2016-09-29 14:49:49 UTC
reopened due to Ernst's issue.
Comment 14 brian avery 2016-09-29 14:50:07 UTC
Ernst: which image and version and machine are you using?

This line is testing to make sure we don't run busybox's resize if we are not logging in over serial:
test "`tty | cut -c1-8`" = "/dev/tty"
My guess is on your image
tty | cut -c1-8
is returning more than one thing. could you run the above and let me know what it returns on the image?

on the image you can also try replacing
test "`tty | cut -c1-8`" = "/dev/tty"
with
test "`tty | cut -c1-8| grep tty | head -1`" = "/dev/tty"
----
Temp workaround:
Just remove 
if [ -x /usr/bin/resize ];then
  # Make sure we are on a serial console (i.e. the device used starts with /dev/tty),
  # otherwise we confuse e.g. the eclipse launcher which tries do use ssh
  test "`tty | cut -c1-8`" = "/dev/tty" && resize >/dev/null
fi
from /etc/profile.
Comment 15 Ernst Persson 2016-10-03 07:36:15 UTC
I'm running Krogoth 2.1.1. A fix for this could be nice to have in Krogoth 2.1.2...
I'm running on a custom machine based on Boundary devices Sabrelite/Nitrogen 6x.
Kernel commandline has console=ttymxc1,115200 .

Now if I run test `tty | cut -c1-8` = "/dev/tty" in a shell I don't get any error, so I'm guessing that the bootup environment is slightly different. Let me see if I can grab that...
Comment 16 Ernst Persson 2016-10-03 08:18:25 UTC
Ok what happens is that I get
test not a tt = /dev/tty
/etc/profile: line 35: test: too many arguments

so some extra quotes should fix that. Like:
test "`tty | cut -c1-8`" = "/dev/tty" && resize >/dev/null

I also found the underlying issue, I'm missing CONFIG_LEGACY_PTYS
in my defconfig.
Comment 17 Jussi Kukkonen 2016-10-06 15:34:49 UTC
The "test: too many arguments" issue in qemu should be fixed in master with  following comment unless I misunderstood the issue.

commit 1100af93cb07caf24d568c039d52fb0c80714c30
Author: Jussi Kukkonen <jussi.kukkonen@intel.com>
Date:   Tue Aug 30 11:32:07 2016 +0300

    base-files: Add shell test quoting
    
    tty can return "not a tt" which results in warnings when /etc/profile
    is executed.
    
    (From OE-Core rev: eed586dd238efe859442b21b425f04e262bcdb2b)
Comment 18 brian avery 2016-11-28 19:18:01 UTC
fixed in f7e1cd9f85f8bd5f6ea92e747a80786a73b2aa0e
krogoth 2.1.2