-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patched ps that can report used memory
- Loading branch information
1 parent
1654d9d
commit 9a18a29
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
ROOT=../../../.. | ||
FUZIX_ROOT=$(ROOT) | ||
USERCPU=armm0 | ||
VERBOSE=1 | ||
include $(FUZIX_ROOT)/Target/rules.$(USERCPU) | ||
|
||
UTILS = ps.c | ||
UTILSO = $(UTILS:.c=.o) | ||
UTILSBIN = $(UTILS:.c=) | ||
|
||
.PHONY: all clean | ||
|
||
all: $(UTILSBIN) | ||
|
||
clean: | ||
rm -f *.o | ||
rm -f $(UTILSBIN) | ||
rm -f progbase.h | ||
rm -f ps.c | ||
|
||
$(UTILSBIN): %: %.o | ||
$(LINKER) $(CRT0) $^ -o $@ $(LINKER_OPT) $(LINKER_TAIL) | ||
|
||
ps.c: ps-rpipico.patch | ||
cp ../../../../Applications/util/ps.c . | ||
patch ps.c < ps-rpipico.patch | ||
|
||
%.o: %.c progbase.h | ||
$(CC) $(CFLAGS) $(CCOPTS) -c $< | ||
|
||
progbase.h: ../build/fuzix.elf | ||
nm ../build/fuzix.elf | grep progbase | awk '{print "#define PROGBASE 0x" $$1}' > progbase.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- ../../../../Applications/util/ps.c 2024-02-12 16:06:26.445511000 -0700 | ||
+++ ps.c 2024-03-31 10:58:57.708871714 -0600 | ||
@@ -35,6 +35,7 @@ | ||
#include <pwd.h> | ||
#include <fcntl.h> | ||
#include <time.h> | ||
+#include "progbase.h" | ||
|
||
#define TTY_MAJOR 2 /* Be nice if we didn't have to | ||
just know this */ | ||
@@ -66,6 +67,9 @@ | ||
#define OF_TIME 8192 /* Cumulative execution time */ | ||
#define OF_CMD 16384 /* Command line */ | ||
|
||
+#define BLOCKSIZE 4096 | ||
+#define alignup(v,a) (uint8_t*)((intptr_t)((v) + (a)-1) & ~((a)-1)) | ||
+ | ||
static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec"; | ||
|
||
static char mapstat(char s) | ||
@@ -348,7 +352,11 @@ | ||
if (outflags & OF_ADDR) | ||
fputs(" - ", stdout); | ||
if (outflags & OF_SZ) | ||
- fputs(" - ", stdout); | ||
+ { | ||
+ long size = pp->p_top - PROGBASE; | ||
+ size = (long)alignup(size, BLOCKSIZE) / 1024; | ||
+ printf("%5d ", size); | ||
+ } | ||
if (outflags & OF_WCHAN) { | ||
if (pp->p_status > 2) | ||
printf(" %4x ", (unsigned int)pp->p_wait); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters