Learning Objectives #
After this section you will be able to:
- Understand the C interpreter
- Understand the command interpreter
- Use some useful shell functions
The Two Shell Modes #
The kernel shell can use two modes: the C interpreter and the command interpreter. To switch between the two modes, you need to type the name of the interpreter into the shell. C for the C interpreter and cmd for the command interpreter.
-> cmd
[vxWorks *]# C
->
You can also type an interpreter’s name before a command to execute a single command using that interpreter.
-> cmd
[vxWorks *]# C x=42
New Symbol “x” added to kernel symbol table.
value = 42 = 0x2a = '*'
[vxWorks *]# C
->
The C interpreter in VxWorks #
The Features of the C Interpreter #
- The C interpreter is a useful prototyping and debugging tool within the kernel space.
- Any global variable can be manipulated to:
- Examine the values of program variables
- Change the values of variables
- *eate new variables
- You can invoke almost any function in memory.
- When invoking a subroutine, the kernel shell passes ten arguments to the subroutine, padding with zeros if necessary.
- The shell prints the values of the function call (and other expressions) that it evaluates.
How to Evoke the C Interpreter #
Type C (upper case) to start the C interpreter.
The command syntax is generally the same as in the C language, as show in this example.
Variables in the C Interpreter #
- The kernel shell creates new variables when a value is assigned to an undefined symbol.
- The interpreter looks for symbol and _symbol in the symbol table.
- The 32-bit VxWorks C interpreter interprets variables as 32-bit integers, whereas the 64-bit VxWorks C interpreter interprets variables as 64-bit integers.
- Use casts to tell the kernel shell how to interpret non-integer types.
- Casting is temporary – you must cast on each access.
- The C interpreter supports:
- long long type
- unsigned types for any values
- scientific notation
Additional Information #
The C interpreter has some syntax differences.
You can omit function call parentheses if the entire expression is the call. For example:
-> func &mac, 27
not
-> 2 * func &mac, 27
The shell does not recognize symbolic macros.
Do not enter symbolic macros.
-> sem1 = semMCreate(SEM_Q_PRIORITY)
Enter
-> sem1 = semMCreate(0x1)
The Command interpreter in VxWorks #
The Features of the Command Interpreter #
Type cmd to change to the command interpreter.
- This provides the ability to monitor and debug RTPs.
- This interpreter mode is defined by a collection of commands.
- File commands: pwd, cat, cd
- Task commands: task spawn, task info, task delete
- Follows a UNIX-style syntax
[vxWorks *]# rtp exec -s -e var=value -- cal.vxe -y
- Supports command aliasing
[vxWorks *]# alias foo "task info"
- Has a special syntax for symbols
[vxWorks *]# echo Address = &test Value = $test
Command Interpreter RTP Support #
This is a list of the most common commands for working with RTPs:
- Launch help
-> help rtp
- Launch an RTP
-> rtp exec fn
- Show all RTPs
-> rtp
- One RTP context
-> rtp attach 0xN
- Show tasks in an attached RTP
-> rtp task
Command Interpreter Functionality #
The command interpreter supports common shell control characters:
- Pipe input and output (|)
[vxWorks *]# cat file.txt | more
- Backquote (`) characters to evaluate a command
[vxWorks *]# bp 'expr &printf + 0x4'
- Redirection for input and output (> » <)
[vxWorks *]# cat file > file2
[vxWorks *]# /foo/bar/rtp.vxe < file2 >> file2
Useful Shell Commands #
There are a few commands worth always having ready, these range from debugging, memory management, to analytics.
Debugging Commands #
The dynamic printf command or dprintf is particularly useful if it is unclear where to set breakpoints, as well as to find race conditions that are hidden when the application is stopped.
- Configure the VxWorks INCLUDE_DEBUG component to use the C interpreter dprintf() and hdprintf() functions.
- Configure the VxWorks INCLUDE_DEBUG_SHELL_CMD component to use the command interpreter dprintf command.
- The dynamic printf command:
- Lets you install printf statements at run-time without having to recompile and reload applications or the kernel
- Can be used in both the kernel module or in RTP applications
System Information Commands #
Displaying system information is a valuable tool when working a project, here is a list the most common commands:
Function | Description |
---|---|
devs() | Lists all devices known on the target system. |
lkup() | Takes a regular expression as an argument and will list symbols from the symbol tables. |
lkAddr() | Takes an address as a parameter and lists the symbols whose values are near the specified address. |
printErrno() | Describes the most recent error status value. |
Show Commands #
Show functions display useful information about the target system. Invoke them from the C interpreter of the kernel shell. They must include the associated component in the VIP.
- For taskShow(), configure the INCLUDE_TASK_SHOW component.
- For memShow(), configure the INCLUDE_MEM_SHOW component.