QtCreator: attach to remote process on QNX



  • I want to debug a process on a QNX target that does not support gdbserver. However, it is possible to attach to the remote process using 'target' command in gdb:

    user@Ubuntu12:~/projects/source.target$ ntoarmv7-gdb
    ...
    (gdb) target qnx imx6:8000
    Remote debugging using imx6:8000
    MsgNak received - resending
    Remote target is little-endian
    (gdb) file ~/projects/build.target/dist/program
    Reading symbols from /home/user/projects/build.target/dist/program...done
    (gdb) attach 352312
    ...

    Now I can debug the process like it was running on my local machine.

    The question is: How to perform this inside the QtCreator? I tried all options provided by QtCreator 3.2.2 including "Attach to remote QNX application...". I set up a QNX device with ssh connection, I see all running processes on the target, select my program, enter information in "Project source directory" and "Local executable" an then select "Attach to Process". But then nothing happens, not even an error message, just nothing!

    Does anyone have a clue what is going wrong here or where to look for error messages that could help to find out where the problem is?

    BR, Udo



  • There's a debugger log (Windows->Views->Debugger Log) and a place to report problems (bugreports.qt-project.org).

    In theory, Creator uses "target qnx" automatically if your GDB is identified as one serving QNX targets.



  • Thank you for this hint. Here the last lines of the output:

    @>&"Traceback (most recent call last):\n"

    &" File "<string>", line 1, in <module>\n"
    &" File "/home/user/Qt/Tools/QtCreator/share/qtcreator/debugger/gdbbridge.py", line 14, in <module>\n"
    &" import struct\n"
    &" File "/opt/qnx650/host/linux/x86/usr/python27/lib/python2.7/struct.py", line 1, in <module>\n"
    &" from _struct import *\n"
    &"ImportError: No module named _struct\n"
    &"Error while executing Python code.\n"
    27^error,msg="Error while executing Python code."
    dNOTE: ENGINE SETUP FAILED
    dState changed from EngineSetupRequested(1) to EngineSetupFailed(2) [master]
    dHANDLE RUNCONTROL FINISHED
    sDebugger finished.
    dHANDLE RUNCONTROL START FAILED
    dState changed from EngineSetupFailed(2) to DebuggerFinished(23) [master]

    dQUIT DEBUGGER REQUESTED IN STATE 23

    28^done@

    Is this a bug of QtCreator or a configuration problem of my machine?

    Current configuration:

    user@Ubuntu12:~/src$ python --version
    Python 2.7.3
    user@Ubuntu12:~/src$ which python
    /usr/bin/python

    Content of /opt/qnx650/host/linux/x86/usr/python27/lib/python2.7/struct.py:

    user@Ubuntu12:~/src$ cat /opt/qnx650/host/linux/x86/usr/python27/lib/python2.7/struct.py
    @from _struct import *
    from _struct import _clearcache
    from _struct import doc@



  • The problem is in fact the QNX configuration:

    The system python works:
    @user@Ubuntu12:~$ /usr/bin/python -c 'import _struct'@

    The QNX python does not:
    @user@Ubuntu12:~$ /opt/qnx650/host/linux/x86/usr/python27/bin/python -c 'import _struct'
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ImportError: No module named _struct
    @

    I'm not familiar with python and haven't found a solution yet, so maybe someone has a clue how to solve this.



  • I tried several things but without success. First I replaced /opt/qnx650/host/linux/x86/usr/python27/bin/python by /usr/bin/python, which did not help. Then I turned of most of the option in the debugger settings (pretty printers ...) ...

    Current questions are:

    1. How can I determine / set which python binary is used?
    2. Where do the following settings come from:
      @
      <39-interpreter-exec console "python sys.path.insert(1, '/home/user/Qt/Tools/QtCreator/share/qtcreator/debugger/')"
      <40-interpreter-exec console "python sys.path.append('/opt/qnx650/host/linux/x86/usr/bin/data-directory/python')"
      <41-interpreter-exec console "python from gdbbridge import *"
      @
      and how can I change them? The path /opt/qnx650/host/linux/x86/usr/bin/data-directory/python for instance does not exist on my machine.


  • Line 1 points to Qt Creator's code to interface GDB. That needs to exist. Line 2 is a fallback in case you run a locally GDB build without 'make install'. That typically does not exist, and is harmless if it doesn't, the 'append' gives lowest priority to that path.

    Your QNX gdb seems to live in /opt/qnx650/host/linux/x86/usr/bin/gdb. Run that as
    @/opt/qnx650/host/linux/x86/usr/bin/gdb -ex 'python import struct'@

    Does that work, or does it produce errors?

    Also, do you have accidentally PYTHONPATH or PYTHONHOME environment variables set?



  • Using just python fails, using /usr/bin/python works:

    @
    user@Ubuntu12:~$ /opt/qnx650/host/linux/x86/usr/bin/ntoarmv7-gdb -ex 'python import struct'
    GNU gdb (GDB) 7.5 qnx (rev. 791)
    Copyright (C) 2012 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law. Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-unknown-nto-qnx8.0.0eabi".
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/opt/qnx650/host/linux/x86/usr/python27/lib/python2.7/struct.py", line 1, in <module>
    from _struct import *
    ImportError: No module named _struct
    Error while executing Python code.
    (gdb) quit
    @

    @
    user@Ubuntu12:~$ /opt/qnx650/host/linux/x86/usr/bin/ntoarmv7-gdb -ex '/usr/bin/python import struct'
    GNU gdb (GDB) 7.5 qnx (rev. 791)
    Copyright (C) 2012 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law. Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-unknown-nto-qnx8.0.0eabi".
    Undefined command: "". Try "help".
    (gdb) quit
    @

    PYTHONPATH and PYTHONHOME are not set. I tried to set them to /usr/lib/python2.7, but then I get

    @
    user@Ubuntu12:~$ export PYTHONHOME=/usr/lib/python2.7
    user@Ubuntu12:~$ /opt/qnx650/host/linux/x86/usr/bin/ntoarmv7-gdb -ex 'python import struct'
    ImportError: No module named site
    @

    The QNX specific .py files are located in /opt/qnx650/host/linux/x86/usr/python27/lib/python2.7 .

    strace shows that alway the /opt/qnx650 path is used for searching the .py files, regardless which value I set to PYTHONPATH or PYTHONHOME. Is there a way to explicitly define which python binary will be used for this "gdb -ex ..." call?



  • The "python" in the -ex parameter is a GDB-internal command, not a path or filename. If you pass "/usr/bin/python", GDB tries to interpret that as an intenal command plus its nparameters. A command starts with letters, so when it sees "/" as first character it complains (rightfully) that the 'empty' command "" is undefined. So the second snippet you posted does not indicate that something "works".

    The first snippet indicates that this GDB installation is broken (and/or the Python it is using) is broken. There's nothing Qt Creator can do about it.

    Maybe talking to the people who provided that setup would be a way forward.



  • Thanks for this comment, I did not realise that this is an error!

    I asked our QNX team and they provided a new gdb wich supports "python with _struct" - great!

    Now I have a different problem. The messages with the python errors occured when I tried "Debug --> Start Debugging --> Attach to remote Debug Server...". This works now with the new gdb until two popups: (1) "Execution Error. Cannot continue debugged process: The program is not bein run" and (2) "Failed to shutdown application: Application process could not be stopped: The program is not being run."

    So I tried the "attach to process" approach described in my first post ("target qnx imx6:8000" followed by "attach PID"). However, if I try this in QtCreator, then nothing happens. I go to "Debug --> Start Debugging --> Attach to remote QNX application..." and select the running process on the target which I want to debug. I set "Project source directory" and "Local executable" and press "Attach to Process". There is no reaction at all! No message, no popup, no entry in "Debug log" nor in "General messages" ...

    What am I missing now?



  • Can you open a bug report at bugreports.qt-project.org and attach the full debugger log? I don't really like spending my time on forums that require me to open up my browser setting for third party "apis" and "analytics"


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.