10Sstevel@tonic-gate#!/bin/ksh 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 61605Spetede# Common Development and Distribution License (the "License"). 71605Spetede# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate# 231605Spetede# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate# Use is subject to license terms. 250Sstevel@tonic-gate# 260Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate# 280Sstevel@tonic-gate 290Sstevel@tonic-gate# 300Sstevel@tonic-gate# Create dummy functions for each of the functions in the module API. We can 310Sstevel@tonic-gate# then link a module against an object file created from the output of this 320Sstevel@tonic-gate# script to determine whether or not that module restricts itself to the API. 330Sstevel@tonic-gate# If the module uses functions outside of the module API, then it cannot be 340Sstevel@tonic-gate# used as a kmdb module. 350Sstevel@tonic-gate# 360Sstevel@tonic-gatenawk ' 370Sstevel@tonic-gate /^[ ]*global:[ ]*$/ { 380Sstevel@tonic-gate printing = 1; 390Sstevel@tonic-gate next; 400Sstevel@tonic-gate } 410Sstevel@tonic-gate 420Sstevel@tonic-gate /^[ ]*local:[ ]*$/ { 430Sstevel@tonic-gate printing = 0; 440Sstevel@tonic-gate next; 450Sstevel@tonic-gate } 460Sstevel@tonic-gate 470Sstevel@tonic-gate # Skip blank lines and comments 480Sstevel@tonic-gate /^$/ { next; } 490Sstevel@tonic-gate /^[ ]*#/ { next;} 500Sstevel@tonic-gate 510Sstevel@tonic-gate # Print globals only 520Sstevel@tonic-gate printing == 0 { next; } 530Sstevel@tonic-gate 540Sstevel@tonic-gate # Symbols beginning with "kmdb_" are not in the module API - they are 550Sstevel@tonic-gate # private to kmdb. 560Sstevel@tonic-gate $1 ~ /^kmdb_/ { next; } 570Sstevel@tonic-gate 581605Spetede # Symbols which have the token "variable" are seen as an int 591605Spetede $3 ~ /variable/ { 601605Spetede if (seen[$1]) { 611605Spetede next; 621605Spetede } 631605Spetede 641605Spetede seen[$1] = 1; 651605Spetede 661605Spetede printf("int %s = 0;\n", substr($1, 1, length($1) - 1)); 671605Spetede next; 681605Spetede } 691605Spetede 700Sstevel@tonic-gate $1 !~ /;$/ { next; } 710Sstevel@tonic-gate 720Sstevel@tonic-gate # Print everything else that we have not already seen as a function 730Sstevel@tonic-gate # definition so we can create our filter. 740Sstevel@tonic-gate { 750Sstevel@tonic-gate if (seen[$1]) { 760Sstevel@tonic-gate next; 770Sstevel@tonic-gate } 780Sstevel@tonic-gate 790Sstevel@tonic-gate seen[$1] = 1; 800Sstevel@tonic-gate 810Sstevel@tonic-gate printf("void %s(void) {}\n", substr($1, 1, length($1) - 1)); 820Sstevel@tonic-gate } 830Sstevel@tonic-gate' 840Sstevel@tonic-gate 850Sstevel@tonic-gate# 860Sstevel@tonic-gate# kmdb modules cannot have their own _init, _fini, or _info routines. By 870Sstevel@tonic-gate# creating dummies for them here, a link against an object file created from 880Sstevel@tonic-gate# the output of this script will fail if the module defines one of them. 890Sstevel@tonic-gate# 900Sstevel@tonic-gateecho "void _init(void) {}" 910Sstevel@tonic-gateecho "void _info(void) {}" 920Sstevel@tonic-gateecho "void _fini(void) {}" 93*1651Spetede# 94*1651Spetede# The SunStudio compiler may generate calls to _memcpy and so we 95*1651Spetede# need to make sure that the correct symbol exists for these calls. 96*1651Spetede# 97*1651Spetedeecho "void _memcpy(void) {}" 98