Skip to main content

Kernel Shell Usage

·845 words·4 mins
VxWorks Shell
Table of Contents
Free Training - This article is part of a series.
Part 17: This Article

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
#

  1. The C interpreter is a useful prototyping and debugging tool within the kernel space.
  2. Any global variable can be manipulated to:
  • Examine the values of program variables
  • Change the values of variables
  • *eate new variables
  1. 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.

C Interpreterer

Variables in the C Interpreter
#

  1. The kernel shell creates new variables when a value is assigned to an undefined symbol.
  2. The interpreter looks for symbol and _symbol in the symbol table.
  3. 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.
  4. Use casts to tell the kernel shell how to interpret non-integer types.
  5. Casting is temporary – you must cast on each access.
  6. The C interpreter supports:
  • long long type
  • unsigned types for any values
  • scientific notation

C Variable

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)
There is no support for C control structures (for, while, if, and so on) and the shell does not recognize data structures.

The Command interpreter in VxWorks
#

The Features of the Command Interpreter
#

Type cmd to change to the command interpreter.

  1. This provides the ability to monitor and debug RTPs.
  2. This interpreter mode is defined by a collection of commands.
  • File commands: pwd, cat, cd
  • Task commands: task spawn, task info, task delete
  1. Follows a UNIX-style syntax
[vxWorks *]# rtp exec -s -e var=value -- cal.vxe -y
  1. Supports command aliasing
[vxWorks *]# alias foo "task info"
  1. 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.

  1. Configure the VxWorks INCLUDE_DEBUG component to use the C interpreter dprintf() and hdprintf() functions.
  2. Configure the VxWorks INCLUDE_DEBUG_SHELL_CMD component to use the command interpreter dprintf command.
  3. 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.

Show Commands

Free Training - This article is part of a series.
Part 17: This Article

Related

Kernel Shell Configuration and Commands
·467 words·3 mins
VxWorks Shell
Command Line Editing and Object Module Loader
·566 words·3 mins
VxWorks Shell
Introduction to the Kernel Shell
·357 words·2 mins
VxWorks Shell