Figure 74 shows the use of the EVAL command with pointers, variables, and bit fields. The pointers, variables, and bit fields are based on the source in Source for Sample EVAL Commands.
Figure 74. Sample EVAL Commands for Pointers, Variables, and Bit Fields
Pointers // Display a pointer >eval pc1 pc1 = SPP:0000C0260900107C // Assign a value to a pointer >eval pc2=pc1 pc2=pc1 = SPP:0000C0260900107C // Dereference a pointer >eval *pc1 *pc1 = 'C' // Take the address of a pointer >eval &pc1 &pc1 = SPP:0000C02609001040 // Build an expression with normal C precedence >eval *&pc1 *&pc1 = SPP:0000C0260900107C // Casting a pointer >eval *(short *)pc1 *(short *)pc1 = -15616 // Treat an unqualified array as a pointer >eval arr1 arr1 = SPP:0000C02609001070 // Apply the array type through dereferencing // (character in this example) >eval *arr1 *arr1 = 'A' // Override the formatting of an expression that is an lvalue >eval *arr1:s *arr1:s = "ABC" // Set a pointer to null by assigning 0 >eval pc1=0 pc1=0 = SYP:*NULL // Evaluate a function pointer >eval fncptr fncptr = PRP:0000A0CD0004F010 // Use the arrow operator >eval *pY->x.p *pY->x.p = ' ' Simple Variables // Perform logical operations >eval i1==u1 || i1<u1 i1==u1 || i1<u1 = 0 // Unary operators occur in proper order >eval i1++ i1++ = 100 // i1 is incremented after being used >eval i1 i1 = 101 // i1 is incremented before being used >eval ++i1 ++i1 = 102 // Implicit conversion >eval u1 = -10 u1 = -10 = 4294967286 // Implicit conversion >eval (int)u1 (int)u1 = -10 Bit Fields // Display an entire structure >eval bits bits.b1 = 1 bits.b4 = 2 // Work with a single member of a structure >eval bits.b4 = bits.b1 bits.b4 = bits.b1 = 1 // Bit fields are fully supported >eval bits.b1 << 2 bits.b1 << 2 = 4 // You can overflow bit fields, but no warning is generated >eval bits.b1 = bits.b1 << 2 bits.b1 = bits.b1 << 2 = 4 >eval bits.b1 bits.b1 = 0 |
The examples below show the use of the EVAL command with structures, unions, and enumerations. The structures, unions, and enumerations are based on the source in Source for Sample EVAL Commands.
Figure 75. Sample EVAL Commands for C Structures, Unions and Enumerations
Structures and Unions // Cast with typedefs >eval (struct z *)&zz (struct z *)&zz = SPP:0000C005AA0010D0 // Cast with tags >eval *(c *)&zz (*(c *)&zz).a = 1 (*(c *)&zz).b = SYP:*NULL Structures and Unions// Assign union members >eval u.x = -10 u.x = -10 = -10 // Display a union. The union is formatted for each definition >eval u u.y = 4294967286 u.x = -10 Enumerations // Display both the enumeration and its value >eval Color Color = blue (2) >eval Number Number = three (2) // Cast to a different enumeration >eval (enum color)Number (enum color)Number = blue (2) // Assign by number >eval Number = 1 Number = 1 = two (1) // Assign by enumeration >eval Number = three Number = three = three (2) // Use enums in an expression >eval arr1[one] arr1[one] = 'A' |
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.