Title: Using SCOProvided Development and Programming Tools Ron Record John Wolfe rrsco.com jlwsco.com
1Using SCO-Provided Development and
Programming Tools Ron Record
John Wolfe rr_at_sco.com
jlw_at_sco.com
2Agenda
- Overview of SCO provided Development Systems
- Suggested open source tools
- Building open source applications
- Getting source, configuration and build issues
- Debugging techniques
- truss, debug, dynamic memory debugging
- FUR function reorganizer
- Packaging tools
- custom and pkgadd
3 ReviewOpenServer 6.0.0
Development System
4How OpenServer 6 is Structured
One OpenServer 6 User Experience Install,
desktop, sys admin, commands
Legacy Apps
Modern Apps
SVR5/ UDK ABI
OSR ABI
OpenServer 6 dev tools /usr/ccs/bin/
OpenServer 6 dev tools /osr5/usr/ccs/bin/
OSR System Libs /osr5/usr/lib/
SVR5/UDK System Libs /usr/lib/
One OpenServer 6 Kernel
OSR5 sys calls
SVR5 sys calls
5Application Binary Interface What is that?
- What an app looks like at the binary level
- content and layout of information that it
presents to system loaders and linkers (object
file format) - How different modules of an app communicate
- function call conventions
- size and layout of basic data types
- size and layout of compound data types -
structures, unions, bit-fields - How an app communicates with the OS
- pathnames, sys call numbers, errnos, ioctl's
- size and layout of basic and aggregate system
data types
6OpenServer 6 SVR5 ABI - default
- OpenServer 6 Devsys for SVR5 (UDK) ABI
- OpenServer 6 Devsys using -K udk option
- or - /usr/bin/cc which defaults to K udk
- use for single certification on UnixWare 7 and
OpenServer 6 - use for modernizing existing OSR5 apps
- use for device driver development (IHVs)
- used to relink the OpenServer 6.0.x SVR5 kernel
- provides access to NEW features
- threads and LFS (gt 2 Gbyte files)
7OpenServer 6 OSR ABI
- OpenServer 6 Devsys for OSR ABI
- OpenServer 6 Devsys using -K osr option
- or /osr5/usr/bin/cc which defaults to K osr
- set PATH environment variable with /osr5/usr/bin
before /bin, /usr/bin or /usr/ccs/bin - use for binary compatibility to legacy OSR5 apps
- provides more modern C and C compilers
- Standards Conformance (almost) C and C
- same level of code generation and optimization as
in the SVR5/UDK compilers - 64-bit long long
- NOT available - threads or large files (gt 2
Gbytes)
8Mixing OSR and UDK ABI Object Files
- No safe way to link OSR5 ABI and SVR5/UDK ABI
relocatable or shared objects (.o/.a/.so) - no way to intercept different system data types
- no way to intercept different bit-field layouts
and function calling conventions - no way to intercept system calls from objects
- Linker will reject mixture of objects, by default
- Force link mode provided - I know what Im
doing - but you probably dont
- not recommended
9Building Legacy OpenServer 5 Apps
- When is OSR ABI needed?
- when linking with existing OSR5 .o/.a/.so objects
- Use OSR ABI compilers
- same as UDK but with -Kosr for OSR ABI
- modern, reliable, standard, optimizing
- 64-bit long long integer available
- LFS, threads and EFT not available
- can accept OSR5 COFF objects as input to linker
- but cannot generate COFF
- can link with existing OSR5 C .o/.a/.so objects
- but cannot link with existing OSR5 C objects
- use CC -Xo to compile very old OSR5 C sources
10Want new features but need compatibility with old
OSR5 library?
- If your own, recompile
- If from another ISV, get vendor to provide new,
SVR5 ABI-built libraries - If neither is possible ...
- make app into 2 processes
- one process calls old lib
- compile -Kosr
- one process uses new features
- compile -Kudk
- use socket, pipe, IPC, etc. to communicate
between processes
11Guidance on modernizing existing apps Threads
- Must modify to use threads
- pthreads API more standard than SVR4/UI threads
- use -Kudk to recompile application
- use -Kpthread when compiling threaded code
- fixes some things like global errno automatically
- Existing OSR5 source may not be thread-safe!
- may use non-reentrant functions such as strtok()
- use ltnamegt_r() replacements when available
- may store application data globally
- may return pointers to static data
- must study your code
12Guidance on modernizing existing apps Large
files
- Go forward with Large File Summit (LFS) APIs
- use -Kudk to recompile application
- create files up to one terabyte in size
- can use size-specific interfaces
- fopen64, lseek64, etc.
- or, can use regular fopen, lseek, etc.
- cc -D_FILE_OFFSET_BITS64
- off_t, etc. become 64 bits
- must use vxfs filesystem and create filesystem
with largefiles flag - mkfs or fsadm_vxfs to turn on/off
- ulimit must be set to unlimited
13Guidance on modernizing existing apps
Fundamental system types
- Be careful with expanded fundamental system types
(EFT) - Size change between OSR5 and OSR6 in UDK mode
- mode_t, dev_t, uid_t, gid_t, nlink_t, pid_t,
ino_t, sigset_t - typically size goes from 16 bits to 32 bits
- system or app structs containing them also
change size - e.g., struct stat contains both dev_t and ino_t
- dev_t also changes how major, minor numbers
packed - all consequences of SVR5 infusion into OpenServer
6 kernel - Change should be transparent unless your code has
assumptions about size
14Guidance on modernizing existing apps C
- Existing OSR5 DevSys C compiler is old!
- ATT Cfront-based, c. 1992, buggy
- predates 1998 ISO language/library standards
- large-scale changes in language since then
- If your sources were developed with it
- expect they will not compile cleanly now
- source fix-ups are usually straight forward
- youre doing your code a favor!
- for bad cases try the CC -Xo option
- old library classes will all still be there
15Guidance on modernizing existing apps C ABI
issues
- C ABIs are unique for each compiler
- Exception handling implementation
- Class object layout
- Virtual function table pointer position
- Base class sub-object order
- Virtual function call mechanism
- Virtual function table format
- Use of thunks
- Name mangling conventions
- Cannot mix C compiler objects
- SCO (USLC) C ? Cfront C ? GNU g
16Features of the OpenServer 6 Dev Sys
- C Compilation System
- C Compilation System
- C/C Debugger
- memtool
- fur
- Except where noted, features apply to Dev Sys
used for both SVR5/UDK and OSR ABIs and to UDK on
UW7 - A major upgrade compared to existing (and
outdated) OSR5 Development System product!!
17The OpenServer 6 -K mode switch
- Compilers
- /usr/ccs/bin/cc defaults to -Kudk
- /osr5/usr/ccs/bin/cc defaults to -Kosr
- cross-ABI compiles are allowed
- /usr/ccs/bin/cc -Kosr ...
- /osr5/usr/ccs/bin/cc -Kudk
- ditto CC for C compiles as ld also
- Use cc or CC to do linking links against
correct ABI startup routines. - Other Dev Sys commands
- have -K osr udk option if necessary (e.g. lint)
- dont have option if irrelevant (e.g. lex and
yacc)
18OpenServer 6 C Compiler
- Robust compiler, excellent IA-32 code generation
- Standards-conforming libraries and headers
- Profiled versions of libraries
- prof, lprof in both ABIs
- fprof SVR5/UDK ABI only
- Standard set of command line tools, fully
internationalized - Conformance checking (-Xc) is against C 90
standard - Support for Java native methods SVR5/UDK ABI
only
- Almost all of C 99 - ISO/IEC 98991999
- inline, restrict, variable argument macro
functions, 60 other features - Only things missing
- variable-length arrays
- complex and imaginary numbers
- minor variances in snprintf(3S)
- some new C99 library functions and headers may
be SVR5/UDK ABI only - Option Xb will disable inline and restrict
keywords
19OpenServer 6 C Compiler
- Accurate, robust implementation
- Almost all of the C standard - ISO/IEC
148821998 - except rarely-used export keyword, placement
delete, function-try-blocks, two-phase template
name binding, multi-byte characters in source
code, partial specialization of a class member
template
- Complete C Std Library
- STL, iostreams, string, locale, numerics, etc.
- fast and thread-safe
- Excellent IA-32 code generation
- Exception Handling - high
- performance
- Device driver support
- Thread safety SVR5/UDK ABI only
- Support for Java native methods SVR5/UDK ABI
only
20 Basic - Suggested - Optional
Open Source Tools
21Basic Open-Source Tools
- Starter set
- gmake
- autoconf ( 2.13 and 2.59 )
- automake - synched with autoconf
- GNU m4
- Probably will need (at sometime)
- bison
- gawk
- flex
22Highly Suggested Open-Source Tools
- Depending on personal preferences, project build
or change submission requirements - GNU diff
- GNU patch
- CVS Concurrent Version System
- GNU tar
23Optional Open-Source Tools
- GNU binutils (gas and ld)
- OSR6 assembler
- does not have Willamette SIMD instructions
- Minor differences in SIMD mnemonics
- GNU GCC
- SIMD instructions are in GCC asm statements
- Avoid g especially for graphics
- C ABI issues
- RPM
24Acquiring Open-Source Tools
- OpenServer 5.0.7 GNU Development Tools
- After chsysinfo osr5
- Install GNU m4, bison, flex, diff, patch, awk,
make, CVS and configuration creation tools - DO NOT INSTALL !!!!
- GCC not dual ABI aware
- - Generates OSR5 ABI code
- Looks in /usr/include for OSR 5 system headers
- Looks in /usr/lib /usr/ccs/lib for link
libraries - GDB
- - Not SVR5 kernel aware
25Acquiring Open-Source Tools - cont.
- UDK 7.1.4 OSTools set
- Install individual packages not the set
-
- chsysinfo uw7
- pkgadd -d ltmnt-ptgt GNUm4 GNUautomk \
GNUautocf GNUmake GNUawk GNUbison \
Osflex -
- GCC 2.95.3 and GDB are configured for SVR5
- SVR5 /usr/gnu/lib/libstdc.so.2.10.0
26Acquiring Open-Source Tools - cont.
- Additional tools or runtime required to build a
project - Check for availability on Skunkware
- May be part of project source
- Part of the normal build sequence
- May need to be built as a first step
- May move to the front of your project list
- May be optional interface(s)
- Defer / omit now
- Build later and rebuild complete project.
27 Building Open Source Applications
Getting Project Source
28Getting the Source - From Where ?
- SCO FTP site
- ftp//ftp.sco.com/pub/openserver6/600/opensrc
- ftp//ftp.sco.com/pub/unixware7/714/opensrc
- ftp//ftp.sco.com/pub/openserver5/507/opensrc/sour
ce - SCO Skunkware
- http//www.sco.com/skunkware
- ftp//ftp2.sco.com/pub/skunkware/src/
- ftp//ftp2.sco.com/pub/skunkware/osr6/src/patches/
- ftp//ftp2.sco.com/pub/skunkware/uw7/src/patches/
29Getting the Source - From Where cont.
- Freshmeat web site
- http//freshmeat.net
- FileWatcher web site
- http//filewatcher.org
- Free Software Foundation FTP
- ftp//ftp.gnu.org/gnu
- SUSE Source RPMs FTP site
- ftp//ftp.suse.com/pub/suse/i386/update/ltversiongt/
rpm/src/ - SourceForge web site
- http//sourceforge.net
30Source Formats
- Varying Source release formats choice of
project maintainers - tar or cpio file archives
- Often compressed GNU gzip or
- zip archive files
- cvs repository on project hosted site
- Linux source RPMs
- Good source for recent patches
- Spec file can provide configuration guidance
- Start with patches from the last release
31Managing Source Build Changes
- Important to track ALL changes
- Avoid reinventing the wheel
- Probably need most, if not all, changes in next
release - Help others in the SCO community to customize to
their needs - Ultimately to contribute source, build and
config. changes back to the open-source community - Others can reproduce problems and provide
solutions or work-arounds
32Source Changes - cont
- Preserve the original source file
- Do not over-write previously saved originals
- mv file file.orig preserve orig file date
- cp file.orig file modified file todays
date - chmod uww file
- Create empty original for every new file
- touch file.orig
33Source Changes - cont
- Use context or unified diff to capture changes
- cd TOP_OF_SRC_TREE
- for i in find . name .orig do
- echo i
- diff -c-u i i.orig
- done gt project_cumulative_patch.date
- Context or unified diff not applicable to
non-text files - .jar, compressed data, binaries, .jpeg, .pdf,
etc. - Copy/replace entirely
34Source Changes - Build Afresh
- Some open-source projects are configurable for
separate source and object directories - Makefile design/implementation
- Blow away the object directory and make again
- Reconstruct project source
- Unwind source into clean directory
- cd TOP_OF_SRC_TREE
- gzcat compressed_tar_archive tar -xf -
- Reapply cumulative patches
- patch -b p0 lt projectcumulative_patch.date
\ - 2gt1 tee
log.patch
35Source Changes - Using Previous Patches
- Prev. release patches may not apply cleanly
- Source code changes in area of your patch
- Some changes bought-back into project source
- Project source restructure
- Unapplied patches written to file.rej
- Review rejections rework as needed
- find . -name '.rej'
36 Building Open Source Applications
Configuration Issues
37config.guess
- 2001 submitted UW7 changes to FSF to standardize
SVR5 triplet - Handled OpenUNIX 8
- i?86578
- You may need to update for OSR 6.0.0
- i?865678
- Produces triplet
- i?86-unknown-sysv5ltOS namegtltversiongt
38Configure Scripts ? triplet override
- preset HOST / TARGET / BUILD
- SVR5 ABI
- i586-sco-sysv5
- OSR5 ABI
- i586-sco-sco3.2v5.0.7
- add -Kosr to CFLAGS, CXXFLAGS, LDFLAGS
- or set PATH for OSR5 ABI preference
39Configure Scripts
- Override default use of gcc, if installed
- CCcc
- CPPCC E
- CXXCC
- RANLIBtrue
- Use cc or CC to do the linking
- Avoid use of compilation or linking options that
specify default header or library paths - Avoid -I/usr/include I/usr/include/sys
- Avoid -L/usr lib -L/usr/ccs/lib
40Absence of config.guess
- configure and configure.in directly use uname
- SCO_SV typically configures for OpenServer 5
- Correct if using OSR5 ABI
- Unable to handle LFS files
- Resolution recognize SCO_SV and release 5 as
OpenServer 6.0.0 and force selection of SVR5 - Hand edit the configure script
- or
- Modify autoconf/aclocal.m4
- Rerun autoconf to regenerate an updated configure
script
41scoutils
- ftp//ftp2.sco.com/pub/skunkware/osr6/vols/scoutil
s-1.3Sc-VOLS.cpio - Shell script frontends
- Configure build open-source
- /usr/bin/Configure, /usr/bin/Build
/usr/bin/Prep - Project source at
- /usr/src/sco/ltcategorygt/ltprojectgt-ltversiongt.tar.bz
2 - Project patch at
- /usr/src/sco/patches/ltprojectgt-ltversiongt-osr6.patc
h - cd /usr/src/sco/ltcategorygt
- Build ltprojectgt
42scoutils - cont.
- Build
- Extracts source
- Applies patch
- Run
- ltprojectgt-ltversiongt/Configure-OSR6, if it exists
- /usr/bin/Configure, otherwise
- Then run
- ltprojectgt-ltversiongt/Build-OSR6, if it exists
- GNU make , otherwise
43 Building Open Source Applications
GCC-isms
44Need information about gcc extensions?
- Check the gcc information provided in earlier
ports - OSTools UW 7.1.4
- GNUTool Chain OSR 5.0.7
- /usr/gnu/bin/info gcc
- Select C extensions
45GCC-isms VarArg Macro Functions
- GCC provided early VarArg Macro Functions
- define eprintf(format, args)
- fprintf(stderr, format, args)
- Supported ISO/IEC 9899 Standard feature
- define eprintf(format, ) \
- fprintf(stderr, format, __VA_ARGS__)
- Condition the change
- ifdef __USLC__
- ISO format
- else
- GNU format
- endif
46GCC-isms return ltvoid expressiongt
- GCC accepts
- void bar() return
- void foo()
- return bar()
-
- To be ISO compliant, change to
- void foo()
- bar()
- return
47GCC-isms inline C functions
- GCC supported inline C functions
- Treat function as statement expression at point
of call - ISO/IEC 9899 added inline C funtions
- Supported on OSR 6.0.0 and UW 7.1.4
- Designed to work with C inline in common
headers - Requires 1 and only 1 external definition
generated - If in module source file, probably not an issue
- Potential PROBLEM if in a header file
- Suppress inline keyword during configuration
- CCcc Xb
48GCC-isms statement expressions
- Compound statement in parentheses
- Probably encountered in define
- define maxint(a,b) \
- (int _a (a), _b (b) _a gt _b ? _a _b
) - If in a header file, conditionally replace with C
static function - static int maxint(a,b)
- return (a gt b ? a b)
-
49GCC-isms __attribute__
- Functions specify side-effects
- Variables packed, aligned, section, weak
- Types packed, aligned
- Format in declarations or definitions
- __attribute__((ltattr_namegt(ltarggt)))
- Change needed
- Conditionally remove attribute modifier
- Use, as appropriate
- pragma pack(ltngt)
- pragma weak ltid1gt ltid2gt
50GCC-isms Enhanced Asms
- Feature is generally unique to each compiler
- Used for
- Better or specialized optimization/performance
- Access to hardware registers/instructions not
typically utilized by the C/C code generator - With exception to Willamette SIMD instr.
- Recode to SCO Enhanced ASM Function
- Prototyped as function Called as a function
- Follow i386 calling convention
- Preserve user and stack registers edi, esi,
ebx, ebp, esp - Return values in eax (edx) or fp0
51GCC-isms Enhanced Asms - cont.
- OSR 6.0.0 Documentation
- Software Development
- Programming in C and C
- Enhanced ASM facility
- asm type identifier ( param-list )
- storage-mode-spec-line
- asm-body
-
- storage-mode-spec-line
- storage-mode identifier , identifier
52GCC-isms Enhanced Asms ? cont.
- Enable optimization of function calling ASM
function by - pragma partial_optimization ltidentifiergt
- If and only if
- Followed calling and register conventions
- Register ebp has not been modified
- Register esp not modified with movl
- No branch into or out of ASM function
- auto or param only modified if address of
variable is passed to ASM function - Auto or param accessed if passed by name or
address to ASM function
53GCC-isms no equivalents (at present)
- Extended ASMs with Willamette SIMD
- Use GCC or separate assembly source compiled
with GNU assembler - Variable Length Arrays
- Local can be recoded using alloca() at function
entry - Use GCC
54 Building Open Source Applications
C Issues
55Template Instantiation
- Different behavior GNU g and SCO C
- Can present problems in compilation or linking
- GNU g
- Instantiates all possibly needed templates in
each object file - Separately named .text sections
- GNU collect2/ld eliminates duplicates when
linking
56Template Instantiation - cont.
- SCO (USLC) implicit instantiation
- C compiler determines where/when templates are
instantiated - At link time
- When collected into .so, a.out or .a
- Use CC command to do the linking
- Implementation
- Template declaration in xxxx.h
- Template definition in xxxx.c same directory as
xxxx.h - Auxiliary files created by compiler
- source.ti source.ii (where .o created)
- Info to recompile
- Templates visible and to be instantiated in that
.o - C compiler implicitly includes xxxx.c for
needed template in xxxx.h
57Template Instantiation - cont.
- Non implicit source construction
- Declaration and definition in header file
- Similarly named .c file visible
- Probably related in functionality since same
name - Contains non-template class/function definitions
- If .c file is implicitly included in multiple .o
- Multiply-defined errors at link time
- Header also contains non-template class/function
definitions - Multiple definitions if headers used by more than
single .o - Solution use preprocessor defines to control
visibility of non-template definitions
58Template Instantiation - cont.
- C templates archives
- Object file is now disassociated from .ti .ii
- Cannot recompile to get needed instantiation
- ERROR - undefined template function later in the
build - needed templates must be resolved prior to
adding to archive - CC Tprelink_objects (OBJS)
- ar ltoptionsgt ltarchive_filegt (OBJS)
59Friend Name Injection Change
- Slight scoping change in the 1998 C Standard
- Previously friend name was injected in the
enclosing scope - If file scope, became friend to everyone
- Pre-GCC 3.x code may run into this
- Most has probably been updated over the last 4
years
60 Debugging
truss
61Truss trace system calls signals
- One or many processes
- Optionally follow forked process(es)
- Optionally indicate LWP id of threaded process
- Asserts control (monitors) process through /proc
file system - Supports both SVR5 and OSR5 ABI processes
- Selectively display or suppress
- System calls
- Signals
- I/O by file descriptor
- Machine faults
- Display system call arguments
62Truss command format
- truss -flcaein -tvx ! syscall . . .
- -s ! signal . . . -m ! fault . . .
-rw ! fd . . . - -o outfile command -p pid
- Defaults
- -tall
- -v!all
- -sall
- -mall -m!fltpage
- -r!all
- -w!all
63 Debugging with debug
64OpenServer 6 Debugger - debug
- Graphical user interface
- User configurable screen layouts
- Command line interface
- powerful, shell-like command language
- command history, command aliases
- Strong C and C symbolic debugging
- Step through inline functions, header code,
exceptions - Controls multi-process, multi-threaded apps
- follow forks in both parent and children
processes - Understands ELF/COFF, DWARF I/II executables
65debug - How to get started
- debug man page
- help command in the debugger
- help lists available commands and topics
- help ltcmd-topicgt - format and details about
command or topic - Use the on-line/locally installed debugger doc.
Debugging and analyzing C C Programs - Command line and GUI
- Tutorials, explanations, and tips
66debug - Command Format
- debug com_opts -p -f allnoneprocs -r
\
-l start_loc cmd_line - debug com_opts -f allnoneprocs \
-l load_file process... - debug com_opts -p -m path -c core_file
object - debug com_opts -p -m path core_file
- com_opts -V -i cx -X opt -d
defaults
-s path -Ya,dir
67debug - Command Line Interface
- Creating a debug session
- create
- grab
- Process Execution
- run -bfr u location
- step -io -c count
- next predefined alias for step -o
- release
- halt
68debug - Stop Events
- Break points function, statement, instruction
address - Watch point value in memory changes
- Expression logical expression is true
- Create with
- stop -p proc_list -c count stop_expr
command - Aliased as b
- Manage stop events with
- delete
- disable / enable
- change
- stop
69debug - Other Events
- Signals default monitors every signal
- signal -d -i signal,...
- signal -p proclist -iq signal, ...
command - cancel - removes specified signal(s) from
pending signals - kill - send specified signal(s)
- C exceptions
- exception -d -i throw catch
- exception -p proclist -iq throw
catch - type command
70debug - Other Events
- System call tracing
- syscall -p proclist -eqx -c count call
... command - On Stop define action for any stop
- onstop -p proclist command
- Managing all events
- events - list event(s) and associate info
- enable, disable, delete
71debug - Displaying Data Process Information
- stack - display function call back trace
- list - list source statements
- print - print variables and expressions
- Defaults to type of variable
- Optional printf() style format string
- dump - hexadecimal/character dump
- dis - disassembly of code
- regs general, control, FP MMX registers
- map list process memory map
- whatis info on variable, function or type
- identify identify a location in memory
72debug - Personal Configuration
- alias command
- define alternate / abbreviated commands
- use to establish dbx-like or gdb-like commands
- build complex, repetitive, conditional command
sequences - HOME/.debugrc
- startup debug command script
- establish my_former_debugger-like configuration
- debug d ltalt_startupgt
- uses specific alternate startup script instead of
default
73debug - logon / logoff / script
- logon ltlog_filegt
- logs debug commands entered and output to a file
- generated output appears as comments
- capture complete history
- capture repetitive command sequence
- logoff
- Terminate logging
- script ltfilegt
- reads debug commands from ltfilegt
74debug - For dbx or gdb users
- dbx users
- Section 3 of the Porting Guide A Guide to debug
for dbx Users - gdb users
- command comparisons from May/June 2000 SCO World
article - Summary is in the on-line handout
75Debug GUI default layout
76 Debugging Dynamic Memory
memtool
77memtool - Catching Dynamic Memory
Errors
- SVR5/UDK ABI only
- Diagnose dynamic memory allocation errors
- writing beyond a block of memory
- using deallocated blocks
- memory leaks
- bad arguments passed to C malloc() or C new()
- Does not catch general pointer misuses or writing
outside local or global arrays - Runs the application under the hidden control of
the debugger and the dynamic C library malloc
runtime checking
78memtool Under the covers
diagnostic output
internal (two-way) command-line communication
basic diagnostic information
dynamic C library
memtool
user interaction
debug
application process
process control
79memtool (cont'd)
- Diagnostics include one to three stack traces
- when detected
- when (de)allocated
- previous use (for realloc() or free())
- Erroneously modified block diagnostics include an
annotated memory dump snapshot for the block - Each diagnostic comes with an explanation
short, medium, or long (user selectable) - Application need not be rebuilt or relinked
- debugging (-g flag) provides much better info
80 Debugging Dynamic Memory
SVR5 - MALLOC_CHECKS
81MALLOC_CHECKS - SVR5
- Environment variable activated memory checking in
the SVR5 C runtime - No recompilation needed - dynamic libc.so.1
- MALLOC_CHECKSltnumbergt
- 1 basic-fill mode
- 3 safe-copy mode - duplicate arena block
headers - 5 added-space mode allocation padded
- mallinfo() - check arena integrity
- 2, 4, 6 above with arena check on all malloc
calls - -1, -5 high memory edge with electric fence
- -3, -7 low memory edge with electric fence
82 Debugging Dynamic Memory
OSR5 - duma / dmalloc
83OSR5 ABI support
- COMING SOON !!
- to a
- Skunkware Web-site Near You
84 FUR
FUnction Reorganizer
85fur - FUnction Reorganization
- Instruments and reorders code in relocatable
objects - at code block level - changes function order - locality of reference
- reorder code blocks within functions - improves
branch prediction - move low-usage code to pseudo functions
- Profile guided optimization without recompilation
- Actual uses
- Has been used to optimize SCO kernels and
libraries - OEMs used fur to gain 15 improvement in Oracle
DB server - TPCC benchmarks - Used for J2SE and soon for Firefox browser
86fur Block profiling 1
- Compile and partially link as relocatable object
- for C, must prelink before linking
-Tprelink_objects - ld -r o xxxx.rel to link no runtime libraries
- save a copy of the xxxx.rel
- Use fur to instrument every basic block of the
xxxx.rel - fur b all flow K ltkeep_filegt \
- -c mkblocklog p ltlog_dirgt/block.xxxx
xxxx.rel - instruments xxxx.rel and generates logging code
- Complete the link producing an instrumented a.out
- cc/CC xxxx.rel .. log.xxxx.o
- Run representative workloads
- multiple runs creates consecutive block.xxxx.??
87fur Block profiling 2
- Analyze all the log files, creating optimal
reordering file - copy saved xxxx.rel to xxxx.rel
- fur r o ltorder_filegt -k ltkeep_filegt \
- -f ltlog_dirgt/block.xxxx.01,ltlog_dirgt/block.xxxx.
02, -m xxxx.rel - Apply the reordering file against the xxxx.rel
and complete the FINAL link - fur o ltorder_filegt -k ltkeep_filegt xxxx.rel
- cc/CC xxxx.rel
- Once ltorder_filegt is obtained and preserved, only
steps 1 and 6 need be done on subsequent
rebuilds - If function shape changes, fur will NOT reorder
that function - Heavy source changes repeat all steps to
produce current ltorder_filegt
88 Packaging Metapkg
and CDMT for OpenServer
89Creating custom installable packages for
OpenServer with Metapkg
- Download and install metapkg fromftp//ftp2.sco.co
m/pub/skunkware/osr6/metapkg/ - Install metapkg and reman binaries anywhere in
root's execution PATH - Create a symbolic link for mkcdmt (and mkpkgadd
if pkgadd installable packages are desired) - ln -s /usr/bin/metapkg /usr/bin/mkcdmt
- ln -s /usr/bin/metapkg /usr/bin/mkpkgadd
- Documentation in doc subdirectory
ftp//ftp2.sco.com/pub/skunkware/osr6/metapkg/doc/
- Examples in examples subdirectory
ftp//ftp2.sco.com/pub/skunkware/osr6/metapkg/exam
ples/
90Preparing the Packaging Hierarchy
- Create input directory and populate dist
directory - Create dist/cntl/ scripts, if any
- Create ltpackage namegt.mkcdmt control file
- Specify non-default permissions and ownership
- Symbolic links specified as additional exports
- Dependencies and updated versions listed here
- Run mkcdmt. For example
- mkcdmt -f -h -d pwd -P gimp \
- -D "GNU Image Manipulation Program" \
- -V 2.2.7Sb -p pwd/gimp.mkcdmt
- Run make
91Sample Metapkg Control File
- prepare ("Checking and preparing distribution")
- auto_compress_texinfo()
- auto_format_mansource()
- auto_strip(TRUE,TRUE)
-
- package ("/", "METAPKG_DESCRIPTION", "QT3")
-
- file ("/usr/lib/qt3/mkspecs/unixware-cc/qmake.co
nf") - access (SERVER)
-
- file ("/usr/lib/qt3/lib/libqt-mt.so.3.3.8")
- addexport ("/usr/lib/qt3/lib/libqt-mt.so",
normal) -
-
- component ("qt3", "METAPKG_VERSION",
"METAPKG_DESCRIPTION") -
- dependency ("SCOgwxlibs")
- upgrades("3.3.5")
92Custom Control Scripts (OpenServer)
- Review CDMT documentation at http//osr600doc.sco.
com/en/manCDMT/CONTENTS.html - Use cqs script for pre-installation system prep
for example, creation of new users/groups - Use ccs script for install/removal config during
phases - Adding/removing entries in SCO Help doc system
- Setting system specific configuration parameters
- Enabling/disabling automatic startup of
service(s) - Initializing product configuration (e.g. Setup
cache) - Mostly used during PRE_INSTALL, POST_INSTALL,
PRE_REMOVE, and POST_REMOVE phases - If desired, create usr/share/meta/doc/... entries
for SCO Help
93Example CCS Script (Part 1)
- !/bin/sh
- scriptname"0"
- step"1"
- keywords"2"
- Pkglist"3"
- . ccsSetup.sh
- doPostExport()
- -x /usr/bin/doctool
- /usr/bin/doctool --add DOC/SDK_qt3.desktop
-
94Example CCS Script (Part 2)
- doPreUnExport()
- -x /usr/bin/doctool
- /usr/bin/doctool remove DOC/SDK_qt3.deskto
p -
-
- DOCDevSysDoc/SDKhome/SDKgroup/SDK_qt3
- ccs_return_value0
- case "step" in
- POST_EXPORT) doPostExport
- PRE_UNEXPORT) doPreUnExport
- esac
- exit ccs_return_value
95 Packaging
SVR4 Package Datastream
96Prepare Distribution Hierarchy
- Populate distribution tree
- Correct permissions/ownership/group
- Set default configuration parameters
- Create admin and pkginfo files at top of tree
- PKG"MyProd"
- NAME"MyProd"
- VERSION"1.0.1"
- CATEGORY"application"
- CLASSES"MyProd"
- ARCH"i386"
- BASEDIR/
97Prepare Distribution Hierarchy (continued)
- Simple admin file
- Basedirask
- Create installation scripts if necessary
- preinstall/postinstall
- preremove/postremove
- Create prototype file
- Entries for admin/pkginfo/install scripts
- i adminadmin
- i pkginfopkginfo
- find ltdirectoriesgt -print pkgproto gtgt prototype
98Create the Package
- Edit prototype file changing any relative
symbolic links to absolute symbolic links - Run pkgmk
- pkgmk -o -c -d pwd -r pwd
- Run pkgtrans, if desired, to create a pkgadd
datastream - pkgtrans -s pwd pwd/MyProd.pkg MyProd
- Install and test newly created package
- pkgadd -d pwd/MyProd.pkg all
99Creating Packages Using Skunkware's mkpkg
- Download and install the mkpkg package
- ftp//ftp2.sco.com/pub/skunkware/uw7/Packages/mkpk
g-1.1.pkg - Extract distribution tree into empty directory
- Set correct permissions/ownership
- Run
- mkpkg ltpackage namegt ltpackage versiongt
- Create installation scripts if necessary
- If necessary, edit prototype file and run
- ./MakePKG
- Install and test newly created package
- pkgadd -d pwd/MyProd.pkg all
100 Guidance / Assistance
101OpenServer 6 Support Resources
- Porting Guide
- http//www.sco.com/support/docs/openserver/600/por
ting/osr6portingTOC.html - Upgrade Guide
- http//www.sco.com/support/docs/openserver/600/upg
rade/index.html - Online Documentation and Late News
- http//www.sco.com/support/docs/openserver/
102OpenServer 6 Support Resources
- Support Download Page for OpenServer 6
- http//www.sco.com/support/update/download
/product.php?pfid12prid20 - SCO Legend Mailing List Public
- Legend-subscribe_at_list.sco.com
- legend_at_sco.com
- Porting/Migration Alias
- osr5to6_at_sco.com
- Knowledge base
- http//wdb1.sco.com/kb/search