69 Commits

Author SHA1 Message Date
Alin Jerpelea
27d8ae36ba nshlib: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-30 18:02:50 +08:00
chao an
9c8a96aa51 nshlib: add support for disable sigmask from ps command
before:

nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 0069616 Idle_Task
    1     0 224 FIFO     Kthread   - Waiting  Signal    0000000000000000 0067536 loop_task
    2     0 224 FIFO     Kthread   - Waiting  Semaphore 0000000000000000 0067504 hpwork 0x400fcfe0 0x400fd028
    3     3 100 FIFO     Task      - Running            0000000000000000 0067536 nsh_main

after:

nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT       STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0069616 Idle_Task
    1     0 224 FIFO     Kthread   - Waiting  Signal    0067536 loop_task
    2     0 224 FIFO     Kthread   - Waiting  Semaphore 0067504 hpwork 0x400fcfe0 0x400fd028
    3     3 100 FIFO     Task      - Running            0067536 nsh_main

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-18 11:48:16 +08:00
yinshengkai
15b081f02d nshlib: fix top command sorting result error
qsort expects the return value to be -1,0,1

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-17 00:00:51 +08:00
buxiasen
4285c4df73 nsh/ps: fix -heap cut more than 10MB
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-16 18:23:54 +08:00
anjiahao
6979fca4dc nshlib: Support top command
show thread sort by cpuloading:
use `top [-n <num> ][ -d <delay>] [ -p <pidlist>] [ -h ]`

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-16 18:23:54 +08:00
anjiahao
6951b64038 nshlib: Reconstruct ps command for top command
divide data collection and data output into two parts

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 18:23:54 +08:00
yinshengkai
b90899b1d5 nshlib: ps supports noheap parameter
Obtaining the heap usage size requires traversing all memory.
When the number of threads is large, it will become very slow.

ps -heap
PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK              HEAP  STACK   USED  FILLED COMMAND
  0     0   0 FIFO     Kthread   - Ready              0000000000000000  4338432 2162672 0005196   0.2%  Idle_Task

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-16 18:23:54 +08:00
zhushiqshi
a655e067ef apps: added pid list for ps command.
Signed-off-by: zhushiqshi <zhushiqshi@xiaomi.com>
2024-10-16 18:23:54 +08:00
wangmingrong
c2597504e0 nsh: Fix PS printing misalignment
When the stack is allocated in megabytes, printing seven bits of ps will not align

Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-10-08 07:58:51 +02:00
Huang Qi
dca6c0cd91 nshlib: Add missing newline in cmd_pidof output
Add newline at the end of cmd_pidof to show nsh
prompt correctly.

Before this patch:
```
nsh> pidof wifi
3 nsh>
```

After:
```
nsh> pidof wifi
3
nsh>
```
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-27 23:24:22 +08:00
Michal Lenc
f81a094283 nshlib: add support for pkill command
This command looks through the currently running processes and kills
the those that match the selection criteria. This way system can send
signal to processes by name and without knowing the IDs.

Example (kill application hello):
	pkill -15 hello

The command can be turned off by NSH_DISABLE_PKILL option and depends
on FS_PROCFS.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-09-23 08:40:54 +08:00
wangmingrong
7981278021 apps/nshlib: Add the pidof command and API nsh_getpid
Add the API "nsh_getpid" in "nsh_fsutils. c" and the nsh command pidof. Temporarily support two parameters, - s, and process name

Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2023-08-29 02:58:45 +08:00
Petro Karashchenko
aed0e2873e apps: fix style issues in code
Add missing FAR and CODE to pointers
Remove FAR for non-pointer variables
Remove extra spaces and align the parameters
Add do {} while(0) wrapper in macro
Use nitems to calculate number of elements in arrays

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-06-11 18:47:50 +08:00
Masayuki Ishikawa
125cf7abe2 nshlib: Fix the ps command format
Summary:
- I noticed that the ps command shows the wrong format due to
  recent changes on sigmask length from 32bits to 64bits
- This commit fixes this issue

Impact:
- None

Testing:
- Tested with sabre-6quad:smp on qemu-7.1

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-03-29 14:50:26 +03:00
Huang Qi
f1ba1a40ed nsh: Improve performance of ps by merge nsh_output
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-03-03 17:41:39 +09:00
Junbo Zheng
79e770b0c6 apps/nshlib: add the missing FAR macro for all source files
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2022-09-22 14:22:13 +08:00
Junbo Zheng
45ef7f948f apps/nshlib: fix CI error
Error: /home/runner/work/incubator-nuttx-apps/incubator-nuttx-apps/apps/nshlib/nsh_proccmds.c:574:40: error: Operator/assignment must be preceded with whitespace
Error: Process completed with exit code 1.

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2022-09-21 16:37:34 +02:00
Junbo Zheng
06f39d10f1 apps/nshlib: add uptime command support
run uptime command on sim:
nsh>
nsh>
nsh> uptime
19:35:01 up  1:40, load average: 0.00, 0.00, 0.00
nsh>
nsh>
nsh> uptime -s
2022-09-16 17:54:26
nsh>
nsh>
nsh> uptime -p
up 1 hour, 40 minutes
nsh>
nsh>
nsh> uptime -h
Usage:
uptime [options]
Options:
-p, show uptime in pretty format
-h, display this help and exit
-s, system up since
nsh>
nsh>
nsh> uptime -abc
uptime: invalid option -- -abc
Usage:
uptime [options]
Options:
-p, show uptime in pretty format
-h, display this help and exit
-s, system up since
nsh>
nsh>
nsh> date
Fri, Sep 16 19:35:18 2022
nsh>
nsh>

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2022-09-21 16:37:34 +02:00
Fotis Panagiotopoulos
0cdb2cfa48 Fixed compiler warnings. 2022-08-23 01:39:59 +08:00
Jiuzhu Dong
ab43c625d1 nshlib/ps: update config MM_BACKTRACE to int type
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-27 02:43:28 +08:00
Fotis Panagiotopoulos
2d2e36c5e9 Fixed heap information output in nsh ps command. 2022-07-22 00:03:41 +08:00
Xiang Xiao
c252ec1481 Add printflike to all printf like functions
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-18 14:09:10 +03:00
Jiuzhu Dong
372621ed06 nshlib/ps: support display heap info for every task by cmd ps
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-24 02:16:00 +08:00
ligd
a4dd508c9c nshlib/nsh_proccmds.c: update ps_callback when get Group
Cause of "Group:" always have in file "status"

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-11 11:13:04 -03:00
Alin Jerpelea
4f3f62c8fc nshlib: update licenses to Apache
Gregory Nutt is has submitted the SGA

Uros Platise has submitted the ICLA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-06-11 02:42:05 -05:00
RoCorbera
42f4565129 nsh kill cmd can be executed with no signal option.
SIGTERM is the default signal, as in unix kill command.
nsh> kill [-<signal>] <pid>
2021-06-01 15:57:13 -03:00
Subhra Sankha Sarkar
36b1be0609 Fixed coding std issues 2020-10-29 04:20:17 -07:00
Juha Niskanen
eaeb6cc105 nshlib/Kconfig: Add missing NSH_DISABLE_DMESG, typos. 2019-11-08 07:52:22 -06:00
Gregory Nutt
8f5944c4a8 Squashed commit of the following:
include/ and netutils/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    nshlib/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    system/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    testing/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
    examples/:  Remove references to CONFIG_DISABLE_SIGNALS.  Signals can no longer be disabled.
2019-04-29 14:53:38 -06:00
GregoryN
3bf4b6d245 Merged altconsole into master 2018-12-08 18:53:54 -06:00
Tomasz Wozniak
71b45ed2c2 built-in libc defect workaround: replace '%6.6u' format with an equivalent '%06u' 2017-03-21 09:39:51 +01:00
Alan Carvalho de Assis
d506939b59 NSHLIB ps command: Eliminate 'defined but not used' warning in some configurations 2017-03-07 15:10:17 -06:00
Gregory Nutt
b1230ce87a NSH: Eliminate a warning about discarding const 2016-07-15 08:31:47 -06:00
David Alessio
f48b3c73b0 When Priority Inheritance is enabled, the format of /proc/<PID>/status changes to show both the current priority and the thread’s base priority. This messes up the format of cmd_ps.
The attached patch fixes cmd_ps to ignore the base priority.
2016-07-15 07:01:02 -06:00
Gregory Nutt
dd7c4c9493 NSH library: Don't show stack usage is CONFIG_STACK_COLORATION is not enabled. 2016-07-13 07:06:32 -06:00
David Alessio
1d8ef23b88 Use fixed point math for cmd_ps removing dependency on floating point libs. 2016-07-12 06:48:30 -06:00
David Alessio
63ff107419 Fix a typo a a preceding change. 2016-07-11 06:56:34 -06:00
David Alessio
f553fd1316 Recent enhancements to cmd_ps trips a floating point exception if LIBC_FLOATINGPOINT is not defined (at least on Cortex M4 w/ hardfloat). I’m using a buildroot gcc configured to support Cortex-M4F and the hard float ABI, target files are compiles with: -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard. I’m not sure the best way to address this, but the attached patch file is the first that comes to mind. Note, I added the float qualifier ‘F’ after a few constants to prevent the compiler from promoting the multiplication and division to double (expensive on M4F) then demoting to single float for the store. (sorry, it’s one of my many pet peeves ;)
`
2016-07-10 17:49:58 -06:00
David Sidrane
6eab2b7811 Take 2 2016-07-01 09:45:00 -10:00
Gregory Nutt
97e41cdcc5 Add a missing blank line 2016-07-01 13:27:15 -06:00
Gregory Nutt
57a0f88728 Revert "Review of last PR"
This reverts commit 0e4c247e1da6275205b86cda7560a7f26cc5f698.
2016-07-01 13:26:34 -06:00
Gregory Nutt
0e4c247e1d Review of last PR 2016-07-01 13:22:36 -06:00
David Sidrane
cbe1d33786 Allow stack usage to be disabled on contrained systems 2016-07-01 08:59:46 -10:00
Frank Benkert
65e050dbfb NSH: PS-Command: print out the stack usage if stack coloration is enabled. 2016-06-30 07:28:42 -06:00
Gregory Nutt
c6ac4d2581 NSH: ps command will show CPU if SMP is enabled 2016-02-19 15:33:32 -06:00
Gregory Nutt
a5fbb4cd24 Revert "NSHL: Format strings for nsh_output should all have IOBJ qualifier"
This reverts commit 186a101d2c62d604376a1ff2822734a631e12618.
2016-01-17 07:39:33 -06:00
Gregory Nutt
186a101d2c NSHL: Format strings for nsh_output should all have IOBJ qualifier 2016-01-06 08:31:56 -06:00
Gregory Nutt
eb1360d56e NSH: Add group ID or parent PID to ps command output (if available) 2015-11-30 08:05:34 -06:00
Gregory Nutt
7e7dd916ce apps/nshlib: The 'ps' command now uses /proc/(pid)/ to obtain task status information. A consequence of this is that you cannot use the 'ps' command if the procfs is not enabled and mounted at /proc. 2015-11-28 15:03:21 -06:00
Gregory Nutt
92b1eb36c8 nshlib: Move trim_dir() and foreach_direntry() from nsh_fscmds.c to nsh_fsutils.c as nsh_trimdir() and nsh_foreach_direntry(), respectively 2015-11-28 08:29:27 -06:00