On Android 7.1.1 the error is fired on "stderr" on previous versions on
"stdout"
Change-Id: I72c06694a22084d455e26eea95ddfdb8a93a39b2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Method to find the pid is changed. Not all android versions support grep
and test commands
Task-number: QTCREATORBUG-17272
Change-Id: Ifa67444af55eaf06fb2d6f6bb0439cfaf3bf305e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
"m_tries" and "m_wasStarted" must be initialized before "m_psProc-
>start" call, because m_psProc will emit "QIODevice::readyRead" signal
before the function ends.
Change-Id: I10c63ca2d15c362d6df04018757b1916b9989893
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Previously, the code depended on the device to send the whole "ps"
output back quickly after "ps" was written to the shell. If the output
was not there by the time the input was considered written by Qt
Creator, we would mis-parse the port and generate wrong conclusions on
if the process was actually running or not.
By filtering the correct line from the ps output on the device and
outputting a clear negative result when none is found we can determine
the "running" status of the process more easily. Each output line
directly corresponds to the state of the process at the time when ps
ran. We buffer the output in order to guard against lines being broken
up during transmission.
Change-Id: I0e1726b7f0d725d982a0f2d60d0c8ab7d59fc371
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
We don't need to do this for plain character literals as we allow
casting those to QString now.
Change-Id: I25569cfb8a2ff618176b7d5ab048f03ecaaee460
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This removes the need for blocking queued connections and runAsync(),
reducing the risk of deadlocks and eliminating unguarded concurrent
access to various members of AndroidRunner. No mutex locking is
necessary anymore as all communication between the two threads is
either done on initialization, before the worker thread starts, or
via queued signals.
Change-Id: Icc2fcc2c0ce73d1c226bc4740413e57490d1cbc6
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
We're not using it as QThread.
Change-Id: Ib277325179a46fe7d153ff9d37043f54d0d41037
Reviewed-by: Vikas Pachdha <vikas.pachdha@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Running SynchronousProcess (for adb) on the GUI thread is dangerous as
it might process unrelated events without returning, breaking
assumptions in other parts of Qt Creator. Rather run those things on a
worker thread, with a separate event loop, like we already do it when
starting processes.
Furthermore, returning, from start() or stop() while a thread is
running that accesses internals of AndroidRunner is also dangerous,
because most methods of AndroidRunner are not protected by relevant
mutexes and especially the destructor might get invoked while the
worker thread is still runnig. Thus, wait for the worker threads to
finish, in start() and stop().
This is a crutch, of course, as with proper locking we could keep the
GUI thread responsive while the adb commands are running, but just
serializing the execution reduces the risk of further breakage for now.
Change-Id: Ife92dc19aa8111374413590c3156027ba759746f
Task-number: QTCREATORBUG-16667
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
If ps is run from a different thread than the GUI thread, then we are
obviously not dealing with the "checkPID" function that's running every
second. We don't need to be overly prudent about starting another
process then. On the other hand, the blocking queued connection relies
on the ps shell not getting closed from a different thread in between
and it is generally a risk for creating dead locks.
Change-Id: Ief49fb18cc3199dc345c4d9ca0ee24b66d33343c
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Use SynchronousProcess::runBlocking in favor of SychronousProcess::run.
This avoid nested event loops which can produce really strange crashes
if not use carefully.
This patch only converts those processes that have a timeout of less
than 5 seconds or use the default timeout.
Change-Id: I9de8899dcc946af7049ea357a91972996c0256a1
Reviewed-by: Vikas Pachdha <vikas.pachdha@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
waitForFinish returns false if the process is no longer running at
the time of the call. Handle that throughout the codebase.
Change-Id: Ia7194095454e82efbd4eb88f2d55926bdd09e094
Reviewed-by: hjk <hjk@theqtcompany.com>
Don't try to write from another thread into a process stdin. Fixes
"QSocketNotifier: Socket notifiers cannot be enabled or disabled from
another thread" warnings.
Change-Id: Id93a40a6bee6d4042cf600c8fabb06bf965d8ccc
Reviewed-by: hjk <hjk@theqtcompany.com>
This solves the ambiguity between 0 and -1 being the "invalid" port.
Change-Id: I3bac11dd4117bb1820fbd58186699925b73df1c5
Reviewed-by: hjk <hjk@theqtcompany.com>
Creating a QProcess every second is very VERY expensive, making the QtCreator UI
experience pretty bad, the UI was not responsive when debugging or even when
running an Android application from QtCreator.
Thanks to Intel's VTUNE I could spot and fix the problem in minutes.
Change-Id: I6d3dc71db93e91d9846101a1877bab017df41aba
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Using the AndroidRunnable is easy for other plugins to run custom adb
commands before intent is started and after it's stopped.
Change-Id: I012ae87c92cea16aa8074dce2dc6f2b0c4ebeb30
Reviewed-by: hjk <hjk@theqtcompany.com>
The start point is the if (m_useLocalQtLibs) block in AndroidRunner
constructor which seems to be effectless since 8d27ec6 (Android: Fix
debugging applications that link many modules)
Change-Id: I7850c1f53a003553ae1b3fdf0881f4c9fedf7b15
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Android SDK Tools 24.x ship an adb that requires in the 'adb shell'
command an additional level of quotes for parameters with spaces
compared to previous versions. That broke the passing of the
gdbserver start command and consequently debugger startup.
Task-number: QTCREATORBUG-15032
Change-Id: I442355821641d4c6a632b50d1065c442736711aa
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
-1 is not a valid quint16 number. It gets converted to 65535, which is
a valid port number. So, instead, use port number 0 which isn't valid
(if you try to bind to it, the OS chooses a port for you).
Found by ICC
src/plugins/android/androidrunner.cpp(150): warning #68: integer conversion resulted in a change of sign
Change-Id: I7de033f80b0e4431b7f1ffff13fc4e4f0f7af445
Reviewed-by: BogDan Vatra <bogdan@kde.org>
The services need to be loaded before the first QML engine is created.
The first QML engine may be created before a client connects. When the
JavaScript debug service is loaded the engine is put into interpreter
mode as we don't support debugging in JIT mode. Profiling, however
should be done in JIT mode, whenever possible.
Thus, in order to avoid the loading of unnecessary plugins and to get
better results from the QML profiler we tell the debug server which
services we expect, even before the client connects. Qt 5.6 will support
additional command line arguments to specify the services and this
change uses them.
Change-Id: I6dcee016c39995e9adada6eaf0e39d8299c9b7e7
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: hjk <hjk@theqtcompany.com>
We do that for Android 5 and onwards.
Change-Id: Ia79fbf3cd50ed561e5dba1b8707d296fe1daa82d
Task-number: QTCREATORBUG-14663
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This provides a way for third-party plugins to implement run
modes without the need to add a value to the central enum or
using manual workarounds like RunMode(*(int*)&someUniqueObject).
Instead of centrally defined enum values this uses Core::Id that could
be defined anywhere.
Change-Id: Ic350e3d8dbb8042c61b2d4ffec993ca151f53099
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
- Move sysRoot, debuggerCommand, targetAbi to DebuggerRunParameters,
they are always the one coming from the kit.
- Move projectSource{Directory,Files} to DebuggerRunParameters,
they are alway coming from the runConfiguration's project
- Pass RunConfiguration always as separate parameter, that's
what related code does.
Change-Id: I9965a052237af53fa2d170701bc88b552cab12ed
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
When debugging an application we will add a few arguments
to the command line for launching the application. We would do
the same for every library etc. required by the modules linked
to the application. At some point, the command line would become
too long and fail to execute.
Passing the libraries, libs_prefix, etc. on the command line
is not necessary, since the parameters are already included in
the AndroidManifest.xml, otherwise it would not be possible to
launch the application from the device itself.
Change-Id: I93a7f64a4ce32ebb2b25c54b0d17ae2b23706e24
Task-number: QTCREATORBUG-13691
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
Security permissions prevent access to files not owned by the current
process. This patch replaces the file based handshake protocol with
a local server based implementation. The server waits for QTC to connect
to it and sends back the current process ID. This new mechanism works
on pre 5.0 devices as well.
The existing file based handshake remains and can be activiated via the
env variable QTC_ANDROID_USE_FILE_HANDSHAKE.
Task-number: QTCREATORBUG-13418
Change-Id: Ie40ec801f265a9e13c3220f300798c27abd97ae2
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This is mostly a copy of the commit message of 06d4c0b2e but its
more convenient to have it in the code than to browse git history.
Change-Id: I97a7a3c10f07fc268ba67986f1e830ee92d9c28d
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Use one less signal for result passing.
Change-Id: I6209d248fb01056835ef65b91981b9b2747d6f7f
Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Starting with Qt 5.4 we are packaging the gdbserver tool as libgdbserver.so,
otherwise gradle will refuse to add it to the package. Gdbserver is renamed
also for ant.
Change-Id: I4ef6408226ab05ea7b4e3d6f41dd368f5a602c7d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Starting with Qt 5.4 we are packaging the gdbserver tool as gdbserver.so,
otherwise gradle will refuse to add it to the package. Gdbserver is renamed
also for ant.
Change-Id: I6da3ad54de591c124fe56d5464e74099dfd901a1
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
On some machines adb takes a longer than 5s to finish. The reasons for
that are unknown.
Change-Id: I949dc40b8f407aa98be0456df47a9ebe88e230a5
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
If you trigger a fatal signal e.g. dividing by 0, you'll get a message
with an "F/" prefix. That should be red, too, just like "E/" and "W/".
Change-Id: I8bef7ebf4e8c7d7ac3794750306073043852634b
Reviewed-by: Daniel Teske <daniel.teske@digia.com>