$ valgrind ./invalid_free
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: strlen
valgrind: in an object with soname matching: ld.so.1
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld.so.1
valgrind:
valgrind: Possible fix: install glibc's debuginfo package on this machine.
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
$ aptitude install libc-dbg
2009-04-07
Valgrind for PowerPC on Debian
Posted by
Clark J. Wang
-
9:51 PM
0
comments
Labels: *nix, C/CPP, Debian/Ubuntu, Utils
2008-03-13
2008-02-20
2008-02-05
acct(2)
NAME
acct -- enable or disable process accounting
SYNOPSIS
#include <unistd.h>
int
acct(const char *file);
DESCRIPTION
The acct() call enables or disables the collection of system accounting
records. If the argument file is a nil pointer, accounting is disabled.
If file is an existing pathname (null-terminated), record collection is
enabled and for every process initiated which terminates under normal
conditions an accounting record is appended to file. Abnormal conditions
of termination are reboots or other fatal system problems. Records for
processes which never terminate can not be produced by acct().
For more information on the record structure used by acct(), see
/usr/include/sys/acct.h and acct(5).
This call is permitted only to the super-user.
NOTES
Accounting is automatically disabled when the file system the accounting
file resides on runs out of space; it is enabled when space once again
becomes available.
Posted by
Display Name
-
11:27 PM
0
comments
2007-10-21
MPC: Makefile, Project and Workspace Creator
A fragile build system may preclude you from supporting diversity. Diversity in terms of platform targets for your software enables you to keep your vendor options open. Makefile, Project, and workspace Creator was originally developed by OCI to assist the ACE and TAO open source development community in supporting multi-platform software.
Developing applications that span platforms (portable code) has the beneficial side effect of producing more robust implementations. It does this by keeping your developers close to the mainstream of language features. MPC minimizes the additional cost normally associated with supporting more than one platform.
MPC was originally developed for, is used with, and is delivered with the ACE and TAO open source code. However, MPC can be used in almost any situation as a tool, able to compliment and simplify your existing build environments. It's more than just a Makefile generator; it supports multiple versions of make (GNU, Microsoft, Borland, Automake), Visual C++ 6.0 and Visual Studio 7.1 and 8.
MPC is therefore copyrighted by OCI and licensed under the same generous terms as TAO. Click here to read the terms.
The goal of MPC is to enable you to..... script once.... and build many.......
Background: Maintaining multiple build tool files for a multi-platform project can be tedious, especially if it is constantly changing and evolving. A project may support GNU Makefiles, Visual C++ project files, Borland Makefiles, and many others. Adding or deleting files, changing project options or even changing the name of the target within your project will incur a time expense to modify each build tool file. Synchronization is a must to ensure the integrity of a build. A single location to store project specific information is needed to avoid repetitious, tedious modifications to multiple build tool files. Adding a new IDE should not be a source of concern and should not have a negative impact on the build process. Some Make systems such as GNUMake and Clearmake may not work well together, which will force you to choose between them. This should not happen. Many projects will benefit from the integration of more than one tool. The build environment should be inclusive, not mutually exclusive. This is where “Make-Project-Creator” (MPC) comes into the picture.
For more details, download the PDF (chapter 4) from the TAO 1.4a Developer’s Guide. This discusses how to get started with MPC.
Posted by
Display Name
-
8:42 PM
0
comments
Labels: *nix, C/CPP, Network/Security
Building ACE on Mac OS X 10.4.10 (Tiger) PPC
- cd ~/tmp
- tar -xjf ACE-5.6.tar.bz2
- export ACE_ROOT=~/tmp/ACE_wrappers
- export DYLD_LIBRARY_PATH=$ACE_ROOT/ace:$ACE_ROOT/lib
- cd $ACE_ROOT
- vi $ACE_ROOT/ace/config.h: #include "ace/config-macosx-tiger.h"
- vi $ACE_ROOT/include/makeinclude/platform_macros.GNU: include $(ACE_ROOT)/include/makeinclude/platform_macosx_tiger.GNU
- make (3.80)
- Make would fail in directory apps/gperf/tests. Ignore it.
--
The full packages do contain all sources with pre generated makefiles for GNU make, Visual C++ 7.1/8.0, Borland C++ make, and GNU autoconf. The sources only packes just contain the sources, you have to generate your own makefiles with MPC.
Posted by
Display Name
-
8:23 PM
0
comments
Labels: *nix, Apple, C/CPP, Network/Security
2007-10-20
DYLD_LIBRARY_PATH (Mac OS X)
DYLD_LIBRARY_PATH (Mac OS X) vs. LD_LIBRARY_PATH (Linux)
Posted by
Display Name
-
9:45 PM
0
comments
2007-09-19
fdatasync(2)
fdatasync() flushes all data buffers of a file to disk (before the system call returns). It resembles fsync() but is not required to update the metadata such as access time.
Applications that access databases or log files often write a tiny data fragment (e.g., one line in a log file) and then call fsync() immediately in order to ensure that the written data is physically stored on the harddisk. Unfortunately, fsync() will always initiate two write operations: one for the newly written data and another one in order to update the modification time stored in the inode. If the modification time is not a part of the transaction concept fdatasync() can be used to avoid unnecessary inode disk write operations.
Posted by
Display Name
-
4:11 PM
0
comments
2007-09-15
GDB: set breakpoints for a specific thread
gdb> b breakpoint thread 7 if (cond is true)
Posted by
Display Name
-
3:35 PM
0
comments
2007-09-05
Pitfall of strerror_r() of GNU libc
int strerror_r(int errnum, char *buf, size_t n);
CONFORMING TO: SVID 3, POSIX, 4.3BSD, ISO/IEC 9899:1990 (C89).
strerror_r() with prototype as given above is specified by SUSv3, and was in use under Digital Unix and HP Unix. An incompatible function, with prototype
char *strerror_r(int errnum, char *buf, size_t n);
is a GNU extension used by glibc (since 2.0), and must be regarded as obsolete in view of SUSv3. The GNU version may, but need not, use the user-supplied buffer. If it does, the result may be truncated in case the supplied buffer is too small. The result is always NUL-terminated.
Posted by
Display Name
-
5:52 PM
0
comments
[C] Non-static local vars locate on stack?
刚才讨论问题时发现公司两大主力 developer 竟不清楚这个问题,看来不能仅通过这些技术细节来判断一个人的能力大小。引申思考:面试题的科学性?
Posted by
Display Name
-
11:02 AM
0
comments
Stack size of processes/threads
- ulimit -s
- getrlimit(RLIMIT_STACK)
- setrlimit(RLIMIT_STACK)
- pthread_attr_setstacksize()
- pthread_attr_getstacksize()
SEE ALSO: Advanced Linux Programming, POSIX Thread Programming
Posted by
Display Name
-
10:49 AM
0
comments
Labels: *nix, C/CPP, Shell/Scripting
2007-09-01
Terminal 上常见的几个 signal
- SIGHUP: Hangup detected on controlling terminal or death of controlling process
- SIGINT: Interrupt from keyboard (Ctrl-C)
- SIGQUIT: Quit from keyboard (Ctrl-\)
- SIGTSTP: Stop typed at tty (Ctrl-Z)
- SIGCONT: Continue if stopped (fg)
- SIGTTIN: tty input for background process
- SIGTTOU: tty output for background process (一般情况下 terminal 没有 enable 这个 signal, 可以用 `stty tostop' 来 enable)
Posted by
Display Name
-
5:14 PM
0
comments
C++ vs Java vs Python vs Ruby : a first impression
一哥们儿用 Red-Black tree 的实现对四种 languages 做的比较, 有些意思, 收藏.
2007-08-24
getconf - retrieve standard configuration variables
The getconf utility prints the value of a POSIX or X/Open path or system configuration variable to the standard output.
-- getconf(1)
SEE ALSO: pathconf(2), confstr(3), sysconf(3)
Posted by
Display Name
-
7:36 PM
0
comments
Labels: *nix, C/CPP, Shell/Scripting
2007-08-21
SWIG: Simplified Wrapper and Interface Generator
SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of languages including common scripting languages such as Perl, PHP, Python, Tcl, Ruby and PHP. The list of supported languages also includes non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), Java, Modula-3 and OCAML. Also several interpreted and compiled Scheme implementations (Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. SWIG may be freely used, distributed, and modified for commercial and non-commercial use.
Posted by
Display Name
-
2:15 PM
0
comments
Labels: *nix, C/CPP, Perl, Python, Tcl/Expect
2007-07-18
2007-07-05
[gcc] -rdynamic
> BTW, why is it that the -soname option and the -rdynamic
> option are not in the man page for gcc?
Essentially because they are really linker options, passed by gcc down to
ld. This is strictly true for -soname: the comma-separated list
following -Wl option of gcc is passed directly to the linker, after
replacing the commas with spaces (you can see this if you gcc -v). No
other processing is done on it by the compiler proper.
The -rdynamic option is slightly different. It seems to have been
introduced as a high-level interface to the linker, to (a) force the
allocation of a global symbol table in the final executable, even if it's
not strictly needed, and (b) cause the inclusion of the global symbols in
that symbol table.
- Under linux, gcc interprets it by setting the "-export-dynamic" option for ld, which has that effect, according to the linux ld manpage.
- Under IRIX it's ignored, and the program's happy as a clam.
- Under SunOS-4.1, gcc interprets it by setting the -dc -dp options for ld, which again forces the allocation of the symbol table in the code produced (see ld(1) on a Sun).
Wonder if we should mailbomb gcc-bug@gnu.org until they fix their man/info
pages ;-)
-- From http://www.cim.mcgill.ca/~franco/OpSys-304-427/messages/node59.html
Posted by
Display Name
-
3:10 PM
0
comments
Hacking HelloWorld
HackingHelloWorld (PDF)
- From Jim Huang (黃敬群 / jserv)
[Keywords: hello world]
Posted by
Display Name
-
1:52 PM
0
comments
修改常量字符串导致的 segmentation fault
昨天一同事遇到的问题, 帮他解决了一下, 备忘 :-)
$ cat foo.c
#include
int main(int argc, char *argv[])
{
char *s = "foo;bar;car";
strtok(s, ";");
return 0;
}
$ gcc foo.c
$ ./a.out
Segmentation fault
$ gcc -S foo.c
$ cat foo.s
.file "foo.c"
.section .rodata ; read only data (?)
.LC0:
.string "foo;bar;car"
.LC1:
.string ";"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
subl %eax, %esp
movl $.LC0, -4(%ebp)
movl $.LC1, 4(%esp)
movl -4(%ebp), %eax
movl %eax, (%esp)
call strtok
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (GNU) 4.0.3 (Ubuntu 4.0.3-1ubuntu5)"
.section .note.GNU-stack,"",@progbits
$
Posted by
Display Name
-
9:42 AM
0
comments
