*scratch*

It is not a diary the most people have rather a *scratch* Emacs buffer. It keeps notes about everything related to Linux, Open Source, UNIX, MacOSX and software engineering.

Wednesday, February 16, 2005

 

dmalloc patch for C++ "non throw" new()/delete() operators

DMALLOC patch, it helps to replace C++ memory operators

new(std::nothrow)()
new(std::nothrow)()[]
delete(std::nothrow)()
delete(std::nothrow)()[]

It has been tested on AIX with VA C++ 5.0 however it shall be all right on most C++ compilers as well. Just update VACPP depended section according to the compiler/libs implementation. March 2005, GCC 3 had been tested with no problem at all and many other compilers shall work all right.

The patch is here. Compile the source and include object file into libdmalloccxx.a and libdmallocthcxx.a.

Saturday, February 12, 2005

 

Tape Drive 3590 commands & utils

Get the status of the tape:

    tapeutil -f /dev/rmt0 status


Query tape position:

    tapeutil -f /dev/rmt0 qrypos

 

verify a file in GEOSHARE format

There is a legacy utility called dlisu from Schlumberger. It prints a GEOSHARE file into the stdout in tree format of tags.

 

teTeX cyrillic support


\\usepackage[a4paper,12pt]{article}
\\usepackage[T2A]{fontenc}
\\usepackage[koi8-r]{inputenc}
\\usepackage[russian]{babel}

 

wget to archive whole site or a web page recursively

    wget -rpkl 99 http://iis1.cps.unizar.es/Oreilly/index.htm


-l 99 is a depth of recursion.
-k and -p garantee links updates and all nessesary files download like pictures, sound and CSS.

Use full path including index.html!

 

AIX linker & compiler useful flags

Dynamic linker flags:

export LDR_CNTRL=MAXDATA=0x80000000
start_process_here
unset LDR_CNTRL

IBM VA C/C++ flags:

-qsource creates .lst file right after CPP.
-qshowinc prints the list of header files included.
-bsmap:my_name_of_map_file creates a log of all mapped symbols, sorted
-bmap:my_name_of_map_file creates a log of all mapped symbols, unsorted
-bsxref:my_name_of_cross_ref creates a log of all cross referenced symbols, sorted
-bxref:my_name_of_cross_ref creates a log of all cross referenced symbols, unsorted
-bscalls:my_name_of_calls_ref creates a log of calls aka reverse cross references, unsorted
-bcalls:my_name_of_calls_ref creates a log of calls aka reverse cross references, sorted

/usr/include/syms.h has macro defintions and explains the content of log files produced by the commands shown above.

 

Seismic Uni* tips

Generate new binary and ASCII headers:
    cat my.sgy | segyread tape=- bfile=/tmp/binary hfile=/tmp/header | segyhdrs endian=0 bfile=./my.binary hfile=my.header ns=1750 dt=4000 jobid=1111 lino=1111 reno=1234


endian=0 is a i386 system, for example Linux
ns number of samples per trace
dt sample interval
jobid, lino, reno must be taken from the original SEGY file if necessary.

Binary header content could be printed in an ASCII form called parameters:
    cut ./my.sgy | segyread tape=- bfile=/tmp/binary hfile=/tmp/header


SEGY file create from an existing one. Some filters could be inserted between to modify the data.
    cut ./my.sgy | segyread tape=- bfile=/tmp/binary hfile=/tmp/header | segywrite endian=0 hfile=./all.header bfile=./1111.binary verbose=1 buff=0 tape=./1.sgy


Print trace headers or/and file header in ASCII:
    cut ./my.sgy | segyread tape=- bfile=/tmp/binary hfile=/tmp/header | suascii bare=2


bare=2 is for headers
bare=1 prints traces amplitudes
bare=0 both traces amplitudes and headers

Among others SUMAX and SUMEAN to print max/min and a global weigth. SURESAMP allows to resample seismic traces by sample rate and number of samples.

Print trace header field by key:
    cut my.sgy | segyread tape=- bfile=/tmp/binary hfile=/tmp/header | sugethw tracl

tracl is a keyword to print from trace header, here some tips:

tracl is a trace sequence number within line. [1]
tracr is a trace sequence number within reel/file. [4]
fldr is a field record number aka inline [9]
tracf is a trace number with field record. [13]
ep is ShortPoint aka energy source point [17]
cdp is ensemble point [21]
cdpt is trace number within CDP ensemble [25]


Get a help aka list of all SU commands/utils:

    suhelp


Look for a entry of string in SU docs:

    sufind find_a_string


Grep a name from the list with short description:

    suname | fgrep -i ascii


Remember! The most of all names are capitalized.

 

Emacs shortcut to remember

c-mode ifdef-hiding minor mode:

C-c @ h hide all ifdefs
C-c @ s show all ifdefs
C-c @ d define a macro to hide ifdefs
C-c @ u undefine a macro to unhide ifdefs

 

default malloc debugging capabilities in GNU libc

The notes from GNU libc manuals.

Memory checking in a program can be enabled as automatic or manual. The former is one by setting the environment variable MALLOC_CHECK_:
MALLOC_CHECK_=1 my_prog

This mechanism is able to catch a fair number of boundary overflows and, in some cases, to protect the program from crashing. The action undertaken when a fault is detected depends on the value of MALLOC_CHECK_: 1 prints a warning message to stderr but does not abort the program; 2 aborts the program without any output; and 3 combines the effects of 1 and 2. MALLOC_CHECK_=3 must produce a core file and some error messages into STDERR.

From the glibc docs:

You can ask malloc to check the consistency of dynamic storage by using the mcheck function. This function is a GNU extension, declared in `mcheck.h'.

Function: int mcheck (void (*abortfn) (enum mcheck_status status))

Calling mcheck tells malloc to perform occasional consistency checks. These will catch things such as writing past the end of a block that was allocated with malloc. The abortfn argument is the function to call when an inconsistency is found. If you supply a null pointer, then mcheck uses a default function which prints a message and calls abort (see section Aborting a Program). The function you supply is called with one argument, which says what sort of inconsistency was detected; its type is described below.

It is too late to begin allocation checking once you have allocated anything with malloc. So mcheck does nothing in that case. The function returns -1 if you call it too late, and 0 otherwise (when it is successful).

The easiest way to arrange to call mcheck early enough is to use the option -lmcheck when you link your program; then you don't need to modify your program source at all. Alternately you might use a debugger to insert a call to mcheck whenever the program is started, for example these gdb commands will automatically call mcheck whenever the program starts:
(gdb) break main
Breakpoint 1, main (argc=2, argv=0xbffff964) at whatever.c:10
(gdb) command 1
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>call mcheck(0)
>continue
>end
(gdb) ...


Another possibility to check for and guard against bugs in the use of malloc, realloc and free is to set the environment variable MALLOC_CHECK_. When MALLOC_CHECK_ is set, a special (less efficient) implementation is used which is designed to be tolerant against simple errors, such as double calls of free with the same argument, or overruns of a single byte (off-by-one bugs). Not all such errors can be proteced against, however, and memory leaks can result. If MALLOC_CHECK_ is set to 0, any detected heap corruption is silently ignored; if set to 1, a diagnostic is printed on stderr; if set to 2, abort is called immediately. This can be useful because otherwise a crash may happen much later, and the true cause for the problem is then very hard to track down.

So, what's the difference between using MALLOC_CHECK_ and linking with -lmcheck? MALLOC_CHECK_ is orthognal with respect to -lmcheck. -lmcheck has been added for backward compatibility. Both MALLOC_CHECK_ and -lmcheck should uncover the same bugs - but using MALLOC_CHECK_ you don't need to recompile your application.

If you want to check the whole heap and not only one block, you can call mcheck_check_all() to walk through all the active blocks. You also can instruct the memory management routines to use mcheck_check_all(), instead of checking only the current block by initializing mcheck_pedantic() instead of mcheck(). Be aware, though, that this approach is rather time consuming.

 

legacy Purify 4.X strange license messages

It is very confusing to get some error messages from a product and immediately the explanation how to avoid it! Here is the message from Purify 4.X on Solaris:
Purify: Error: Couldn't get a license. Exiting.
To run the program with Purify functionality disabled,
use the command

(csh) setenv PURIFYOPTIONS "-continue-without-license=yes $PURIFYOPTIONS"
(ksh) PURIFYOPTIONS="-continue-without-license=yes $PURIFYOPTIONS"; export PURIFYOPTIONS

The options section of the manual has more information.

Friday, February 11, 2005

 

Install Oracle 9.2 AMD64 on x86-64 RedHat WS 3.0 Update 4

Installing Oracle 9i AMD64 on x86-64 has a problem on RedHat WS 3.0 Update 4 x86-64 version. It stalls during naeet.o linking. To avoid that happen set:
export LD_ASSUME_KERNEL=2.4.1

before launching Oracle installer. It is something with Java VM does not support Native POSIX Treads, so LD_ASSUME_KERNEL=2.4.1 tells the dynamic linker to use legacy implementation of Linux threads.

It has been something about GCC version of 2.96 shall be used during Oracle installation but it looks like all right to me with default 3.2.

Oracle installation notes has a list of compatibility packages had to be deployed prior to the installation.

Archives

December 2004   January 2005   February 2005   March 2005   May 2005   July 2005   October 2005   January 2006   March 2006   May 2006   July 2006   December 2006   January 2007   February 2007   May 2007   July 2007   November 2007   January 2008   February 2008   July 2008   August 2008   September 2008   November 2008   April 2009  

This page is powered by Blogger. Isn't yours?