Learning Objectives #
After completing this section, you will be able to:
- Understand the C interpreter
- Understand the command interpreter
- Use common and useful kernel shell functions
The VxWorks kernel shell supports two modes: the C interpreter and the command interpreter, each designed for specific tasks in development, debugging, and system management.
Switching Between Shell Modes #
To switch between modes, type the interpreter name into the shell:
-> cmd
[vxWorks *]# C
->
You can also prefix a single command with an interpreter to execute it immediately:
-> cmd
[vxWorks *]# C x=42
New Symbol “x” added to kernel symbol table.
value = 42 = 0x2a = '*'
[vxWorks *]# C
->
The C Interpreter in VxWorks #
Features of the C Interpreter #
-
Ideal for prototyping and debugging in kernel space
-
Allows manipulation of global variables:
- Examine values
- Change values
- Create new variables
-
Invokes almost any function in memory:
- Passes up to 10 arguments to functions, padding with zeros if needed
- Prints function call results and other evaluated expressions
Using the C Interpreter #
Type C (uppercase) to start the interpreter. Its syntax closely resembles standard C:
Working with Variables #
- Assigning a value to an undefined symbol creates a new variable
- Interpreter searches for symbols in the symbol table
- 32-bit vs 64-bit interpreters interpret integer sizes differently
- Use casts to interpret non-integer types (temporary per access)
- Supported types include:
long long,unsigned types, scientific notation
C Interpreter Notes #
- Parentheses in function calls can sometimes be omitted:
-> func &mac, 27
- Symbolic macros are not supported:
-> sem1 = semMCreate(SEM_Q_PRIORITY) # ❌
-> sem1 = semMCreate(0x1) # ✅
The Command Interpreter in VxWorks #
Features of the Command Interpreter #
Switch to the command interpreter using:
-> cmd
-
Monitor and debug RTPs
-
UNIX-style commands:
- File:
pwd,cat,cd - Task:
task spawn,task info,task delete
- File:
-
Supports command aliasing:
[vxWorks *]# alias foo "task info"
- Symbol evaluation:
[vxWorks *]# echo Address = &test Value = $test
RTP Commands in Command Interpreter #
- Launch help:
-> help rtp - Launch an RTP:
-> rtp exec fn - Show all RTPs:
-> rtp - Attach to one RTP:
-> rtp attach 0xN - Show tasks in attached RTP:
-> rtp task
Command Interpreter Features #
Supports shell control characters:
- Pipe:
[vxWorks *]# cat file.txt | more
- Backquote evaluation:
[vxWorks *]# bp 'expr &printf + 0x4'
- Input/output redirection:
[vxWorks *]# cat file > file2
[vxWorks *]# /foo/bar/rtp.vxe < file2 >> file2
Useful Shell Functions #
Debugging Commands #
Dynamic printf commands (dprintf) help locate race conditions and debug without recompiling:
- Enable
INCLUDE_DEBUGfordprintf()andhdprintf()in C interpreter - Enable
INCLUDE_DEBUG_SHELL_CMDfor command interpreterdprintf - Allows runtime printf insertion in kernel modules or RTPs
System Information Commands #
| Function | Description |
|---|---|
devs() |
Lists all devices on the target system |
lkup() |
Searches symbol tables with regex |
lkAddr() |
Finds symbols near a specific address |
printErrno() |
Displays the most recent error status |
Show Functions #
Provide detailed target system info (C interpreter only, requires associated VIP component):
taskShow()– ConfigureINCLUDE_TASK_SHOWmemShow()– ConfigureINCLUDE_MEM_SHOW