[comp.sys.hp] Static data problems in Motif Application

albert@netcom.UUCP (Albert Hui) (08/22/90)

I am working with a large Motif application on the 825 running HPUX 7.0.
The Motif version I believe is 1.0 with most dates on the Motif include files
marked Oct 12, 1989.

I am having problems with static data not getting initialized correctly.
In the xdb debugger, after the first statement in main, the static data
is corrupted already.  The static data that gets corrupted is a Xt translation
table, so it causes an abort pretty early.  The first statement does not 
do anything useful.

I cannot duplicate the problems with smaller programs that do not use
the Motif and X11 libraries.  Does anyone know what is the latest
version of Motif 1.0 for the 825?  What is the latest version of Xt
and X11 libraries?  I need to know if I am using a consistent set
of libraries for my application.

From the map that is generated by the -Wl,-m option, I can see that
static data is located in the $THIS_DATA areas.  What's interesting is
that $THIS_DATA$ sometimes have many of them that shared the same
address.  Does anyone know what this means?

Has anyone seen internal errors in xdb when examining structures of
a motif application?  I see IE546 quite often.   

Thanks.


My Motif application's makefile:

########################### start of makefile
CCOPTS = -Aa -DSYSV -DNLS16 -Dhp9000s800 \
			-I/users/albert/cwsport/cws/mdlw/ -z \
			-g -W c,-w1 -W c,-e -c 

MDLWLIB = somelib.a

MDLWMAIN = main.o

DBMOD = /usr/lib/xdbend.o

DRAWOBJS = ... # many objects
MDLWMODS = ... # many objects

.c.o:
	cc $(CCOPTS) $*.c

XLIBS = -lMrm -lXm -lXt -lX11 -lPW -lm

cws_draw : $(DRAWOBJS) $(MDLWMODS) $(MDLWMAIN)
	cc -W l,-m -o $@ $(MDLWMAIN) $(MDLWMODS) $(DRAWOBJS) $(DBMOD) $(XLIBS) 
########################## end of makefile

shankar@hpclscu.HP.COM (Shankar Unni) (08/23/90)

> From the map that is generated by the -Wl,-m option, I can see that
> static data is located in the $THIS_DATA areas.  What's interesting is
> that $THIS_DATA$ sometimes have many of them that shared the same
> address.  Does anyone know what this means?

The easy question first (:-)):

To reduce the load on the linker, the C compiler gathers all statics in a
compilation unit together, and assigns them one symbol, and all loads and
stores of these statics are done with an appropriate offset off this
symbol.

Two such symbols are generated: "$THIS_DATA$" for initialized statics, and
"$THIS_BSS$" for uninitialized statics (these go into the data and BSS
areas, respectively).

About the other problems, the only thing that I can suggest immediately is
to contact an HP response center and let them take a crack at it.. (your
static problem may be due to some startup code in main() trashing your
data. You mentioned "first statement in main". What would be in that first
statement?

Another thing would be to start up xdb and go into assembly mode ("td").
Single-step till you hit the first instruction of main, and then look at
the static (i.e. before any code under main() has run). If it is trashed at
that point, then you have a deeper problem...
-----
Shankar Unni                                   E-Mail: 
Hewlett-Packard California Language Lab.     Internet: shankar@hpda.hp.com
Phone : (408) 447-5797                           UUCP: ...!hplabs!hpda!shankar