P and –pg, Kpic and –pic, Kpic – HP SunSoft Pascal 4.0 User Manual

Page 63: Using the -p option, Using the -pg option

Advertising
background image

The Pascal Compiler

39

3

–p

and

–pg

The

–p

and

–pg

options instruct the compiler to produce code that counts the

number of times each routine is called. The profiling is based on a periodic
sample taken by the system, rather than by line counters.

Using the

-p

Option

To generate an execution profile using the

–p

option:

1. Compile with the

–p

option.

2. Run

a.out

, which produces a

mon.out

executable file.

3. Type

prof a.out

. The program prints a profile.

Using the

-pg

Option

To generate an execution profile using the

–pg

option:

1. Compile with the

–pg

option.

2. Run

a.out

, which produces a

gmon.out

executable file, a more

sophisticated profiling tool than

mon.out

.

3. Type

gprof a.out

. The program prints a profile.

–pic

,

-Kpic

and

–PIC

,

-KPIC

The

-pic

and

-PIC

options cause the compiler to generate position-

independent code (PIC). One of these options should be used for objects
which are then put into shared libraries. With PIC, each reference to a global
datum is generated as a dereference of a pointer in the global offset table. Each
function call is generated in

pc

-relative addressing mode through a procedure

linkage table.

The size of the global offset table is limited to 8Kbytes with

-pic

. The

-PIC

option expands the global offset table to handle 32-bit addresses for those rare
cases where there are too many data objects for

-pic

.

For more information on

PIC

, see the section on shared libraries in the Solaris

documentation.

Advertising