subprocess.Popen (used internally by check_output) is not thread-safe
and may cause a thread to lock up if called simultaneously from multiple
threads. See
https://bugs.python.org/issue12739
This is fixed in Python 3.2, but since we're currently still on 2.7,
work around the issue by protecting the call with a lock.
The `-e` argument to match logcat output with a regex expression is not
present on older devices. If the target is running pre marshmallow fall
back to pipeing logcat into grep.
SerialError does not populate it's message attribute, so the message was
lost when re-raising as HostError. Pass the string representation of
SerialError into HostError instead.
Previously, when the gem5 simulation crashed, one would get errors
relating to pexpect reaching EOF, rather than an informative message
stating the gem5 itself had crashed. With this change, we catch some
of the common cases where this can happen, and inform the user if gem5
itself has crashed. In the event that the gem5 simulation itself has
not reported an error, we instead re-throw the original pexpect error.
Add new energy instrument that is based on arm-probe tool to manage AEP
Main advantages of this tool are:
- uses a config file for describing channels and shunt resistors value
- manages power topology description in the config file. This topology
is then used when computing power figures
- can create virtual power channel and aggregate channels
- support multiple AEP
- support auto-zero of AEP's channel
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Previously the root directory was used when checking for device
connection, on some devices this requires elevated permissions so now
use '/data/local/tmp' which should not have permission restrictions.
pexpect.spawn object expects the logger to have write() and flush()
methods, neither of which are present in logging.Logger. Create a
subclass that adds these missing methods to enable correct logging for
pexpect.spawn.
Ensure that source and destination are quoted and all space characters
are also escaped which is required for scp to work for file paths
containing spaces.
Only attempt to remove echoed commands from the shell during parsing
if gem5 is actually echoing commands otherwise this can cause incorrect
filtering.
Elsewhere in devlib, we strip '\r' characters and then handle it as if
it was just normal unix style '\n'.
However in adb_shell, we have a newline_separator option which defaults
to windows style '\r\n'.
This commit removes the newline_separator() function in the
AdbConnection class, removes the use of this function in execute()
function, and removes the parameter from adb_shell() function.
Instead, in the adb_shell() function, the same action as elsewhere in
devlib is performed: replace('\r\n', '\n').replace('\r', '\n')
Currently if you never call wait_for, the underlying pexpect will not
read bytes from the logcat command's output into the log file. So
when we get into get_log, we need to force it to read all the
already-available bytes.
Using a pexpect.spawn object simplifies the LogcatMonitor by removing
the need for a separate thread along with the synchronization that
brings. Since pexpect.spawn creates a logfile that is flushed with
each write, it also removes the need for code to handle flushing.
I originally wrote this to allow more complex features that are made
possible by the pexpect API, however I then discovered those features
are not necessary and did not submit this for merging.
However I then discovered that in Python 2.7,
threading.Event.wait (used in the `wait_for` method) makes the task
uninterriptible (i.e. can't be killed with Ctrl+C/SIGINT), which is
rather frustrating. This issue doesn't arise when using pexpect's
expect method, so that's why I'm submitting this now.
Previously FrameCollector.write_frames used "columns" argument only as a
filter for which columns to write, but the order would always be the
same as in raw output.
The Instrument API requires that the column ordering in the resulting
MeasurementsCsv matches the ordering of channels specified in reset()
(if any). This means the collectors should respect the ordering
specified in the "columns" parameter (which gets populated based on
active channels).
Calling stop before start will result in hanging in self._started.wait(),
because that event will never get set. Although stop before start is an illegal
usage pattern, let's try not to fail annoyingly.
If you call .start then immediately call .stop, the thread may not
yet have set ._logcat, resulting in an AttributeError.
I initially fixed this by setting _logcat = None in __init__, then putting the
`kill` calls inside `if self._logcat`. The problem with this, as pointed out by
@valschneider, is that we can then have this sequence:
main thread: monitor thread
stop() run()
if self._logcat: .
# False, don't kill process .
join() .
self._logcat = <...>
Therefore, just have the stop() method wait until the process is started before
unconditionally killing it.
Add gfxinfo_get_last_dump utility function to get the last gfxinfo dump
from a (potentially large) file containing a concatenation of such dumps
(as in the raw output of the GfxinfoFrames instrument).
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.