If catching the exception is done with "except Exception as e:" this
will work only from 2.6. To maintain backward compatibility with 2.4 I
have used sys.exc_info(). A bit of a wart, but it works.
It's a function call in 3.x and redundant parentheses around an
expression on 2.x. This works fine as long as all prints have just a
single argument. One print statement with two arguments was changed to
use % formatting instead.
If '-t' is specified and a filter such as '-U me' is specified, the
pid total displayed is the total number of pids instead of the number
of filtered pids.
I was getting an error with pie charts on some systems
with very small memory usage.
$ smem -S data.tar --pie=command
Traceback (most recent call last):
File "/usr/local/bin/smem", line 636, in <module>
showpids()
File "/usr/local/bin/smem", line 246, in showpids
showtable(pt.keys(), fields, columns.split(), options.sort or 'pss')
File "/usr/local/bin/smem", line 455, in showtable
showpie(l, sort)
File "/usr/local/bin/smem", line 498, in showpie
while values and (t + values[-1 - c] < (tm * .02) or
IndexError: list index out of range
I traced it to a bug in showpie, where there's some confused
usage of a list index and list popping.
In showpie, c is used to index into the values in a while
loop that removes entries from the end of a sorted list,
and aggregates their values for use in an "other" entry,
added to the list before display.
Moving (and using) the index is wrong because the list is being
chopped from the end as we go. This warps the value of 'other',
but under normal circumstances would probably not be noticeable
because these items have very small values.
However, if several items are popped, and the list is very short,
it can result in the list index error above.
Also, truncating the values and labels in the subsequent
conditional is redundant with the pop in the loop.
Below is a patch to fix these problems.
-- Tim
---
smem | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Here is a patch for the smem man page. It includes the following:
* A new section on embedded usage briefly describing smemcap
NOTE: Someone please doublecheck it,
since I am not an embedded developer.
* Mentions that kernel image for -K option must be uncompressed.
* A new copyright section.
* A new resources section.
* Replaces notes with a requirements section.
* Adds a couple of commands to the see also list.
* Fixes a couple typos.
- totalmem should return kB when provided manually
- firmware size never goes below zero
- add comments
- calculate kernel portion of cached by subtracting mapped rather than
anonymous
- get rid of sum() bits for silly column totals