On some systems CPUs sometimes remain idle for several seconds. If a
trace capture begins during one of these long idle periods, that CPU's
idle state is unknown (in practice it is probably in its deepest
available state from cpuidle's perspective but that can't be known for
sure).
The solution to the equivalent problem for cpufreq is to read the
current frequencies from sysfs and inject artificial cpu_frequency
events using trace_marker (see cpu_freq_trace_all_frequencies in
bin/scripts/shutils.in). However we can't read the current idle state
from sysfs.
Instead, wake up each CPU by executing the "true" command on it via
taskset.
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>
When this information is not needed, this avoids executing 4 commands on
the host for each CPU, which significantly speeds up initialising the
cpuidle module.
Currently when using set_all_governors to try to set an unsupported
governor, the error is a somewhat cryptic "sh: echo: I/O error". Add a
check that diagnoses this error.
In order to avoid slowing down the "good" path, the check for
unsupported governors is only done if the failure has already occured.
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 6d854fd4dc59936142fff811e575cd034a308c43
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.
We expect ls to output single column listings. Previous to Linaro Android
16.09 release, this was the default. From the 16.09 release onwards, the
default is multi-column. Unfortunately, pre-16.09 ls does not support the
'-1' option to guarantee single column output.
Test for ls supporting '-1' and use it if possible.
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
Configuration sysfs files required by ftrace are usually accessible only by
the root user. In systems where ADB does not run as root by default, the
initialisation of the ftrace module fails.
This patch ensure that all ftrace commands are executed with root privileges.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
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.
Prior to this commit, measurements to be collected were specified via
"sites" and "kinds" parameters. This has the limitation that if you
wanted measurments of kind X from site A and kind Y from site B, you'd
have to specify them as
reset(sites=['A', 'B'], kinds=['X', 'Y'])
Which would have the effect of also collecting measurments Y for site A
and measurments X for site B. This commit adds the option of specifying
individual channels, via thier labels, e.g.
reset(channels=['A_X', 'B_Y'])
so that only the channels you're interested in will be collected.
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.
kick_off relies on nohup, which may not work properly unless the command
for it is explicitly backgrounded with "&", which was not being done in
the AndroidTarget implementation of kick_off().
When passing an idle state ID to get_states(), nothing is returned. Also, there
is a wrong call to enable() in the method.
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
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.
The "adb connect" command is not required for USB connected devices.
This patch is a small update to use "adb connect" only for android devices
accessed by IP address.
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
Added a method for extracting compressed on-target files and archives.
The method extacts the specified on-target path (the method is based on
the extension) and return the path to extracted content.
Most invocations of target.execute() pass as_root=self.is_rooted .
However, is_rooted is not what you want to do here. as_root tells the
connection to wrap the command around sudo/su to execute the command as
root. is_rooted returns True if the device can run commands as
root (for example, if we are connected as root). If you are already
connected as root, there is no need to wrap the command around sudo, you
are already root. In that case, as_root should always be false.
Define a new property for the target called needs_su that returns true
if the target needs to run a command to get superuser privileges.
Using the wrapt module we can improve the memoize decorator. In fact, it allows
to preserve the attributes of the memoized function, such as signature,
docstring, path to the file where the function is implemented, and so on.
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>