Commit Graph

97 Commits

Author SHA1 Message Date
Jaromir Capik
365a5fa517 pmap: empty output or crashes on ppc/s390 caused by wrong pidlist type
Previously the pidlist variable was defined as unsigned long *
whilst the openproc function accepts pid_t *.
Both target types differ in size (8 != 4) and therefore the issue
mainly affects big endian architectures.

This commit changes the pidlist type to pid_t * so that it's
compatible with openproc.
2013-02-05 22:10:18 +11:00
Craig Small
dca3c6d08f pmap vmflags support
Some new kernel version added a line in /proc/pid/smaps listing a processes vmflags. This broke pmap such that pmap -X and pmap -XX would always fail.

This patch adds support for the vmflags field so that -X and -XX work again AND they display the flags.

Merge commit 'refs/merge-requests/8' of git://gitorious.org/procps/procps into merge-requests/8
2013-01-24 22:39:42 +11:00
Andrey Bondarenko
bffb097ba0 pmap -x has RSS and Dirty summary
This is largely Andrey's patch based upon merge request #7
If KLONG != 8 the summary didn't print for RRS and Dirty, this commit
restores this behavour for both sizes.

Ref: https://gitorious.org/procps/procps/merge_requests/7

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-01-24 22:26:27 +11:00
William Orr
b9b3d02dac Added support for vmflags in pmap 2013-01-22 22:46:24 -05:00
Jim Warner
7e8ee148d7 pmap avoid SEGV potential with new X/XX detail options
While permissions suggests that /proc/#/smaps contents
are world-readable, in practice this file might not be
available to a non-root process. Whether this is a bug
in the kernel or an intentional design decision really
makes no difference. This commit will protect pmap -X.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit faec340719
Author: Dimitrios Apostolou <jimis@gmx.net>
Date:   Thu Sep 27 22:08:04 2012 +1000

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-23 06:48:36 +11:00
Sami Kerola
22ceeca4a6 pmap: fix compiler warnings
pmap.c:80:7: warning: declaration of 'mapbuf' shadows a global declaration [-Wshadow]
pmap.c:63:13: warning: shadowed declaration is here [-Wshadow]
pmap.c:137:37: warning: declaration of 'mapbuf' shadows a global declaration [-Wshadow]
pmap.c:63:13: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:01 +11:00
Sami Kerola
e677476aea pmap: remove memory leaks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:26:55 +11:00
Sami Kerola
c043c47ddd pmap: use correct types for memory allocation
Fixes error which did not happen always.  Changes of being affected by
the bug where greater the more there where pids defined as pmap argument.
The debian bug referral can almost certainly reproduce the problem,
especially when tried multiple times in row.

pmap: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr)
(((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >=
(unsigned long)((((__builtin_offsetof (struct malloc_chunk,
fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) -
1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) ==
0)' failed.

Reported-by: lee <lee@yun.yagibdah.de>
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=688180
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:22:11 +11:00
Dimitrios Apostolou
faec340719 Two new options for pmap, -X and -XX
Both options provide more information about a process using -X and -XX
flags. The data comes from /proc/PID/smaps so it may vary.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-09-27 22:08:04 +10:00
Sami Kerola
52269d22f3 all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Sami Kerola
d5c760ee07 pmap: use only address start to range determination
Fix to an edge case.  When user defined begining of address range to
be at between two allocations the previous allocation which ended to
that address was included to printout.  After this commit one will
see only allocations that are within range definition.

$ pmap -A00007f4e0df08000,00007f4e0df08000 895
895:   bash
00007f4e0dd08000   2048K -----  /lib/libreadline.so.6.2
00007f4e0df08000      8K r----  /lib/libreadline.so.6.2
 total             2056K

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-04 12:13:18 +01:00
Sami Kerola
ed57504c38 pmap: add range arguments parsing function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-04 12:13:18 +01:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
bd9abebd9f pmap: fix compiler format warnings
pmap.c: In function 'discover_shm_minor':
pmap.c:87:10: warning: ISO C does not support the '%Lx' gnu_scanf format [-Wformat]
pmap.c:87:10: warning: ISO C does not support the '%Lu' gnu_scanf format [-Wformat]
pmap.c: In function 'mapping_name':
pmap.c:128:3: warning: ISO C does not support the '%Lx' gnu_printf format [-Wformat]
pmap.c:128:3: warning: ISO C does not support the '%Lx' gnu_printf format [-Wformat]
pmap.c: In function 'one_proc':
pmap.c:265:10: warning: ISO C does not support the '%Lx' gnu_scanf format [-Wformat]
pmap.c:265:10: warning: ISO C does not support the '%Lu' gnu_scanf format [-Wformat]
pmap.c:315:11: warning: ISO C does not support the '%Lx' gnu_printf format [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:36:29 +11:00
Craig Small
502a79e02f Merge remote-tracking branch 'sami/to-craig' into sami-merge
Conflicts:
	pgrep.c
	w.c
2012-03-03 13:56:32 +11:00
Sami Kerola
cbb9e54587 pmap: ensure arg1 is not null, and set qualifers to match with usage [smatch scan]
pmap.c:436 main(59) error: we previously assumed 'arg1' could be null (see line 427)
pmap.c:136:3: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:142:4: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:150:2: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:300:8: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 21:43:36 +01:00
Mike Frysinger
fc3bf171ff pmap: fix const warning
pmap.c:300:8: warning: assignment discards 'const' qualifier
	from pointer target type [enabled by default]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-26 21:12:39 +01:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
c3405fab1a translations: group usage texts
Reference: http://www.freelists.org/post/procps/backporting,5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-02 16:29:03 +11:00
Craig Small
a99002e3fe Merge branch 'master' into nls
Conflicts:
	configure.ac
	pmap.c
	ps/Makefile.am
2011-12-26 09:11:27 +11:00
Craig Small
23e753fd47 Fixed pmap -x Kbytes column
The Kbytes column when using the pmap -x flag would always be zero. This
was because the diff variable was reset before it could be printed.
pmap with no -x was not impacted by this bug or fix.
2011-12-23 00:44:23 +11:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
c862a4caa5 nls: add functions which take translations to be used
Add the following three functions to most of the commands.

setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Jim Warner
86e938a333 pmap: correct 'rh analysis #2' patch and contrib document 2011-12-20 17:30:51 +01:00
Sami Kerola
1ef14f4bf9 includes: add xalloc.h to unify memory allocations
The xalloc.h provides necessary error checking.

Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:50 +01:00
Sami Kerola
d59cf08c9d pmap: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:04 +01:00
Sami Kerola
d50884788d pmap: new usage & fix coding style
Coding style fixed and more readable help output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:01 +01:00
Craig Small
380cc1e908 pmap: provide information for -x option
A patch from Debian.

Similiar idea to pmap written by Robert Love.

Bug-Debian: http://bugs.debian.org/347476
Bug-Debian: http://bugs.debian.org/505571
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-18 22:47:34 +11:00
Craig Small
9acfb07b23 pmap fix by Jim 2011-10-26 22:25:21 +11:00
Jim Warner
d3786c5321 rh analysis #2: pmap
http://www.freelists.org/post/procps/Scan-results,5
2011-10-19 09:33:43 +02:00
Craig Small
3ef4823f90 supgid/supgrp support, improved library interface
Library changes
   readproc
    . added support for supplementary groups
    . eliminated 2 potential mem leak sources
       . shortcut used for multi-threaded str
         vectors & ptrs was obsoleted
       . freeing of proc_t related dynamic
         memory now rests with the library
    . standardized/normalized many c comments
   sysinfo
    . corrected note regarding glibc & cpuinfo
   library.map
    . made the visible freeproc accessable
 Program changes
   pmap
    . initialized buffer for new readproc i/f
    . eliminated now obsolete free() call
   ps
    . added width aware supgrp support
    . initialized buffers for new readproc i/f
    . eliminated now obsolete free() calls
   top
    . added supgrp support as variable width
    . eliminated now obsolete free() calls
    . expoilted library freeproc function
    . corrected -h|v args text & spacing
    . updated some c comments
 Documentation changes
   ps.1
    . added supgid and supgrp
   top.1
    . added supgid and supgrp
    . addition of above required renumbering
      many fields in section 3a. DESCRIPTIONS
2011-08-01 21:28:46 +10:00
albert
b0210803bf update /dev/tty* info to May 2009 devices.txt 2009-05-03 06:39:33 +00:00
albert
0908258da6 tiny bit faster and neater 2005-01-11 02:02:37 +00:00
albert
7514c4e4a0 show full path when no -x or -d option (was buggy) 2005-01-10 23:41:10 +00:00
albert
c961f2604a leftovers in the 3.2.4 release 2004-11-04 20:50:59 +00:00
albert
4ab5a6c8c3 merge with procps2 free 2004-01-30 04:47:14 +00:00
albert
f4367392c8 check_gcc for -m64, pmap shows shmid 2004-01-29 22:28:13 +00:00
albert
74954d33e3 3.2.0 release prep; pmap -d 2004-01-29 05:05:37 +00:00
albert
98f8cbd614 output like Solaris 9, not Solaris 7 2004-01-29 03:33:44 +00:00
albert
a760a2c22d "top -p1" then hit "=" did SIGSEGV; flags not regenerated right 2004-01-28 21:53:44 +00:00
albert
1e1218cca8 pmap stack detection 2004-01-26 20:01:56 +00:00
albert
0db94e6a1a GPLONLY_ and PID-related stuff 2003-07-03 05:20:19 +00:00
albert
3e67b58ec2 satisfy GPL section 2a and LGPL section 2b name+date requirement 2002-12-15 00:30:17 +00:00
albert
b657e7e08a NORETURN 2002-12-09 07:53:09 +00:00
albert
9da12ae628 LGPL 2002-10-27 10:44:05 +00:00
albert
ea4be1f178 pmap 2002-10-27 10:35:13 +00:00
csmall
03a9b5a30f procps 010114 2002-02-01 22:47:29 +00:00