host.kill_children() is used to properly kill the logcat process
when it is IO blocked.
The logcat regexp argument is now within double quotes, as having
parenthesis within the regexp could break the command.
LogcatMonitor.search() has been renamed to wait_for() to make the
behaviour of the method more explicit. A non-blocking version of
this method has been added and is named search().
All values in the gem5 statistics log file are numeric. This commit adds a
cast on the strings read from the stats file to native numeric values when
and logs a warning in case of a malformed entry.
numeric() conversion function is expanded to handle percentage values in
the form "10.123%". The result is the numeric part converted to a float
and divided by 100, e.g. 0.10123.
Gem5's statistics log file contains plenty of interesting information
that are not exposed so far. This module enables control and parsing of
the statistics file by:
- configuring periodic dumps of statistics;
- marking Regions of Interest (ROIs);
- and extracting values of specific fields during the ROIs.
If we execute a command such as:
'am start -a android.intent.action.VIEW -d nothing'
on Hikey960 with AOSP master, we do get an error message:
'Error: Activity not started, unable to resolve Intent ...'
but the error code is set to 0. Furthermore, that error message
is outputted to STDERR and not STDOUT.
The current error checking in adb_shell() is done by either
reading the error code or finding an error string in the
standard output. This commit adds a check of the error output,
and also changes the regular expression that is used to find
an error string as it wasn't generic enough.
Add a FrameCollector implementation that utilizes the output from
surfaceflinger (the Android compositor). This is is the only method for
accessing rendering data on older Android devices.
When providing a source file with wildcards (e.g. *ramp*.log)
to be pulled from the target, this might involve transferring
multiple files.
Add support for the transfer of multiple files in the pull method.
Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
The pull method used when connecting to gem5 uses the 'm5 writefile'.
This only works if the file to pulled in, is in the current working directory
on the target. The file therefore might need to be copied on the target, from its
original location to the working directory.
The previous implemention of this was incorrect and used information about the
current working directory on the host.
The format of an ls command is an implementation detail rather than
something of immediate interest to the user. Debug level is more
appropriate than info for this kind of message.
If a command is executed "as_root", SshConnection always prepended
"sudo" invocation to the command, even if the user name is "root". This
causes problems on patforms that do not have "sudo".
This commit changes this behavior so that sudo is never used for root
users.
If the ADB command fails (e.g. if you provide the wrong device ID), adb_command
raises a CalledProcessError. CalledProcessError doesn't print the output of the
failed command, so you get a useless error message.
This is relevent here in particular as _setup_ls is the first thing to run an
ADB command if a non-IP device ID is provided.
Catch the CalledProcessError and instead raise a HostError with the command
output in the exception message.
Commit 28891a82 made it easier to debug issues during walk_modules by
attaching the specific name of the module being loaded to the exception.
However, the error may not originite in the imported module, but one of
the modules that module itself is importing.
To further facilitate debugging, exc_info (which contains the traceback)
for the orginal ImportError is now also attached to the raised
HostError.
ADB commands always expect a device ID as first parameter, here
unfortunately we need to pass it as an optional one to avoid breaking
existing clients.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Previously, if an error had occured while attempting to load a module
during walk_modules, it was propagated to the loading code. This
meant that walk_modules could, in theory, raise any exception at all,
and that it was not always possible to tell exactly where the exception
originated.
Now, all encounted errors are re-raised as HostError, which preserves
the original exception in an attribute and sets "modpath" attribute to
point to the module that originated it.
Moved TimeoutError from devlib.util.misc to devlib.exception. It was
previously defined in misc because it needed to be there when the code
was part of WA in order to prevent an import cycle. This is not
necessary in devlib, so it is moved to be with the other exception
definitions.
This is the first in a series of commits to allow for the use of gem5 as a target in devlib.
The interaction with the gem5 simulation is done by the Gem5Connection, a type of TelnetConnection.
There are two types of Gem5Connections (Linux and Android) as they differ slightly in the implementation
of some methods. Other types of connections have only been changed to make them uniform (e.g. arguments for init method)
Changes to be committed:
modified: devlib/__init__.py
modified: devlib/host.py
modified: devlib/utils/android.py
modified: devlib/utils/ssh.py
On older combinations of ADB/Android versions, the adb host command always
exits with 0 if it was able to run the command on the target, even if the
command failed (https://code.google.com/p/android/issues/detail?id=3254).
When we need the target's exit code (check_exit_code=True), we currently work
around this behaviour by echoing the target's exit code after the command and
parsing it out of the output.
The ADB behaviour is now "fixed" on newer versions with newer Androids (It's not
clear which versions these are and it appears that different builds of ADB with
the same version number differ in this respect). For those version combinations
adb_shell will currently raise a CalledProcessError when check_exit_code=False
and the target command fails.
So lets now use the "echo $?" trick whether or not we need the exit code.
Fixes https://github.com/ARM-software/devlib/issues/85
When ANDROID_HOME is defined, ANDROID_HOME/platform-tools was appended
to the PATH in the environment of the Python interpreter. That meant
that if an adb binary was in PATH, it would be picked in preference to
the one under ANDROID_HOME. This is now reversed so that ANDROID_HOME
takes precedence.
Perviously, a parameter passed into SshConnection controlled whether the
connection was established over SSH or Telnet. Now, there is a separate
class for Telnet connections.
When there are multiple matches for the wildcard, the output has been
observed to have a space at the end. That means the pull command doesn't
work. This commit fixes that.
When using 'check_exit_code' and 'as_root' options for adb_shell with
a command containing single quotes, the provided command was escaped
twice which has now been avoided.
Similarly to other uses of ls, the change to multi-column default output
format has confused this API. Add in a similar routine to other objects
which use ls, so that we can try to figure out if we have a multi-column
default and control the output if so, or just use the plain command if
that doesn't work and hope it is still single column output.
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
If you try to disconnect a device and there are none, certain versions
of adb return 1, which leads to a TargetError and stops everything in
its tracks.
Try to mitigate this by checking if the device we want to disconnect is
connected before we make the disconnect call.
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
This is a fix for
https://github.com/ARM-software/devlib/issues/60
Apprently, being an instance of Hashable does not mean that the object
is, in fact, hashable. So rather than testing for hashability, try to
hash the object and handle the potential error by falling back to the
old method.
This is further to commit 6d854fd4dc
Due to the way certain objects are handled, getting the frist few bytes
of an object may not be enough (e.g. strings do not store their values
inline). To further mitigate the issue, hash the object where possible.
memoized() used id() to get "unique" representations for arguments
passed to a function, in order to ensure that results for the same
function called with different arguments are treated differently.
However, Python object identities are only guaranteed to be unique at a
particular point in time. It is possible than a particular ID gets
reused for a different object if the previous object associated with
that ID no longer exists. In particular, in CPython, the IDs are just
addresses of the corresponding PyObject's in memory. If a PyObject gets
garbage collected, another object may get allocated in its place, and
the new object will "inherit" the ID by virtue of being in the same
memory location. If the new object is then used to call a memoized
function that was previously called with the old object, the old cached
result will be incorrectly returned.
To get around this issue, the cache is now indexed not only by the ID of
an object but also but the first few bytes of its value.
NOTE: there is still a potential issue it two relatively large objects
gets allocated in the same place and happen to share the first few
(currently 32) bytes, and are then both used as parameters to the same
memoized function. The only way around that is to hash the entire value
of the object. However, given the performance penalty that would incur
for larger object, and the unlikeliness of this situation actually
arising, it is currently deemed not worth it.
Added a function to reset the memo cache used by memoized decorator,
which would force all memoized functions to re-evalued their results
when they are next called. This is primarily intended for debugging.
If username is set to None, no '-l' option is appended to the telnet command.
If password is set to None, devlib does not wait for a password prompt when
connecting.