Operating System - HP-UX
1752815 Members
6008 Online
108789 Solutions
New Discussion юеВ

Getting sizes of source/header files from executable with using the what utility

 
Alex Vinokur
Frequent Advisor

Getting sizes of source/header files from executable with using the what utility

Hi,


I need to get size of source/header files from executables/libraties with using the what utiliry.

Getting sizes of source files is shown below.

Is there any way to get also sizes of header files?

Thanks,

Alex Vinokur



====== Environment : BEGIN ======

> uname -lmrsv
HP-UX B.11.23 U ia64 unlimited-user license

> aCC -V
aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]

> make -v
GNU Make 3.81

====== Environment : END ======


====== makefile1 : BEGIN ======
# makefile1

CC = aCC
CFLAGS = +DD64 -AA
CFLAGS += -DFILE_WC="`wc $<`"
LDFLAGS = +DD64 -AA

SOURCES=foo_main.cpp foo.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: clean $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
$(CC) $(CFLAGS) -c $<

clean:
@rm -rf $(EXECUTABLE) $(OBJECTS)
====== makefile1 : END ======


====== foo_macro.h : BEGIN ======
// File foo_macro.h

#ifndef __FOO_MACRO_H__
#define __FOO_MACRO_H__

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

#define FIRST_SCCS_CHAR "@"
#define SCCS_PREFIX FIRST_SCCS_CHAR"(#)"

#define SOURCE_IDENT_INFO SCCS_PREFIX""__FILE__",\tSize = "TOSTRING(FILE_WC)

#define HEADER_IDENT_INFO SCCS_PREFIX""__FILE__",\tSize = ???"


static const char id_foo_macro[] = HEADER_IDENT_INFO;


#endif // __FOO_MACRO_H__
====== foo_macro.h : BEGIN ======


====== foo.h : BEGIN ======
// File foo.h

#ifndef __FOO_H__
#define __FOO_H__


#include "foo_macro.h"

static const char id_foo[] = HEADER_IDENT_INFO;

#endif // __FOO_H__
====== foo.h : BEGIN ======



====== foo2.h : BEGIN ======
// File foo2.h

#ifndef __FOO2_H__
#define __FOO2_H__

#include "foo_macro.h"

static const char id_foo2[] = HEADER_IDENT_INFO;

#endif // __FOO2_H__
====== foo2.h : BEGIN ======



====== foo.cpp : BEGIN ======
// File foo.cpp
#include "foo.h"
#include "foo2.h"

static const char id[] = SOURCE_IDENT_INFO;
====== foo.cpp : BEGIN ======


====== foo_main.cpp : BEGIN ======

// File foo_main.cpp
#include "foo.h"

static const char id[] = SOURCE_IDENT_INFO;

int main()
{
return 0;
}

====== foo_main.cpp : BEGIN ======



###################################
// Compilation
> make -f makefile1
aCC +DD64 -AA -DFILE_WC="`wc foo_main.cpp`" -c foo_main.cpp
aCC +DD64 -AA -DFILE_WC="`wc foo.cpp`" -c foo.cpp
aCC +DD64 -AA foo_main.o foo.o -o hello

> what hello
hello:
foo_macro.h, Size = ???
foo.h, Size = ???
foo_main.cpp, Size = 9 17 110 foo_main.cpp
foo_macro.h, Size = ???
foo.h, Size = ???
foo2.h, Size = ???
foo.cpp, Size = 5 13 96 foo.cpp




2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: Getting sizes of source/header files from executable with using the what utility

>Is there any way to get also sizes of header files?

Only if you make your script smarter and have it search though all of the -I paths to find the header. And you would need a macro for each header you were interested in.
Alex Vinokur
Frequent Advisor

Re: Getting sizes of source/header files from executable with using the what utility


We have some progress. We can get sizes of header files with using the what utility


====== Environment : BEGIN ======



> uname -lmrsv


HP-UX B.11.23 U ia64 unlimited-user license


> aCC -V


aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]


> make -v


GNU Make 3.81

====== Environment : END ======


====== makefile2 : BEGIN ======

# makefile1

MAKEFILE = makefile2
MAKEDEPEND = makedepend

CC = aCC
CFLAGS = +DD64 -AA

APP_INCLUDES = -I. -I./inc

CFLAGS += -DSOURCE_FILE_WC="`wc $<`" -DHEADER_FILE_WC="`makedepend $(APP_INCLUDES) $<; cat makefile | tail -1 | sed "s/.*://" | xargs wc | tr '"'"'"\n"'"'"' '"'"'" '"'"'" "
LDFLAGS = +DD64 -AA

SOURCES=foo_main.cpp foo.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: clean $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
$(MAKEDEPEND) $<
$(CC) $(CFLAGS) $(APP_INCLUDES) -c $<

clean:
@rm -rf $(EXECUTABLE) $(OBJECTS)


====== makefile2 : END ======


====== foo_macro.h : BEGIN ======

// File foo_macro.h

#ifndef __FOO_MACRO_H__
#define __FOO_MACRO_H__

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

#define FIRST_SCCS_CHAR "@"
#define SCCS_PREFIX FIRST_SCCS_CHAR"(#)"

#define SOURCE_IDENT_INFO SCCS_PREFIX"SOURCE_SISE "__FILE__": \tSize = "TOSTRING(SOURCE_FILE_WC)

#define HEADER_IDENT_INFO SCCS_PREFIX"HEADER_SISE "__FILE__": \tSizes = "TOSTRING(HEADER_FILE_WC)


#endif // __FOO_MACRO_H__

====== foo_macro.h : BEGIN ======



====== foo.h : BEGIN ======

// File foo.h

#ifndef __FOO_H__
#define __FOO_H__


#include "foo_macro.h"

#include


#endif // __FOO_H__

====== foo.h : END ======




====== foo2.h : BEGIN ======

// File foo2.h

#ifndef __FOO2_H__
#define __FOO2_H__

#include "foo_macro.h"


#endif // __FOO2_H__

====== foo2.h : END ======



====== foo.cpp : BEGIN ======

// File foo.cpp
#include "foo.h"
#include "foo2.h"

static const char id1[] = SOURCE_IDENT_INFO;
static const char id2[] = HEADER_IDENT_INFO;

====== foo.cpp : END ======


====== foo_main.cpp : BEGIN ======

// File foo_main.cpp
#include "foo.h"

static const char id1[] = SOURCE_IDENT_INFO;
static const char id2[] = HEADER_IDENT_INFO;

int main()
{
return 0;
}

====== foo_main.cpp : END ======

###################################
// Compilation


> make -f makefile2
makedepend foo_main.cpp
makedepend: warning: foo_main.cpp (reading foo.h, line 9): cannot find include file "iostream"
not in iostream
not in /usr/include/iostream
aCC +DD64 -AA -DSOURCE_FILE_WC="`wc foo_main.cpp`" -DHEADER_FILE_WC="`makedepend -I. -I./inc foo_main.cpp; cat makefile | tail -1 | sed "s/.*://" | xargs wc | tr '"'"'"\n"'"'"' '"'"'" '"'"'" " -I. -I./inc -c foo_main.cpp
makedepend: warning: foo_main.cpp (reading foo.h, line 9): cannot find include file "iostream"
not in iostream
not in ./iostream
not in ./inc/iostream
not in /usr/include/iostream
makedepend foo.cpp
makedepend: warning: foo.cpp (reading foo.h, line 9): cannot find include file "iostream"
not in iostream
not in /usr/include/iostream
makedepend: warning: foo.cpp, line 3: cannot find include file "foo2.h"
not in foo2.h
not in foo2.h
not in /usr/include/foo2.h
aCC +DD64 -AA -DSOURCE_FILE_WC="`wc foo.cpp`" -DHEADER_FILE_WC="`makedepend -I. -I./inc foo.cpp; cat makefile | tail -1 | sed "s/.*://" | xargs wc | tr '"'"'"\n"'"'"' '"'"'" '"'"'" " -I. -I./inc -c foo.cpp
makedepend: warning: foo.cpp (reading foo.h, line 9): cannot find include file "iostream"
not in iostream
not in ./iostream
not in ./inc/iostream
not in /usr/include/iostream
aCC +DD64 -AA foo_main.o foo.o -o hello



> what hello
hello:
SOURCE_SISE foo_main.cpp: Size = 10 23 156 foo_main.cpp
HEADER_SISE foo_main.cpp: Sizes = 17 14 124 foo.h 17 36 428 foo_macro.h 34 50 552 total
SOURCE_SISE foo.cpp: Size = 7 19 143 foo.cpp
HEADER_SISE foo.cpp: Sizes = 17 14 124 foo.h 17 36 428 foo_macro.h 9 12 101 ./inc/foo2.h 43 62 653 total