avatar
Today is 星期天
2010年09月5日

搜索结果 文章索引模板: 十一月 2009

2009年11月24日

传说中的libmysqlclient.so诞生啦

由 晨笛 — 分类目录: 技术评论暂缺

在cygwin下成功编译mysql-5.1倒没有遇到太大问题,执行:


./configure --without-readline --without-libedit
make

时间较长,但没有出错,只是编译完成后我要的libmysqlclient.so(dll)没有生成。

下面提供解决办法:

定位到源码目录下的libmysql子目录,执行:


gcc -shared -o libmysqlclient.dll -Wl,--out-implib=libmysqlclient.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive .libs/libmysqlclient.a -Wl,--no-whole-archive -lcrypt -lz

即可:-)

2009年11月8日

修复SVN仓库

由 晨笛 — 分类目录: 技术评论暂缺

> I’m running SUSE 10.2 with svn from the SUSE Subversion repo.
>
> LC_ALL=C
> svn –version
> svn, version 1.5.0 (dev build)
>    compiled Jun  5 2008, 16:16:44
>

Not even a Release Candidate, just head of the branch. :(

> After the last update on the 5th I get this error when committing:
> svn: Can’t open file ‘/srv/svn/repos/oneiros/db/txn-current’: No such
> file or directory
>

Hmm.  ’svnadmin verify’ doesn’t complain if txn-current is missing, and
’svnadmin recover’ doesn’t recreate it either.  However, ’svnadmin dump’
doesn’t complain either!  So, a dump|load might work for you:

    % svn –version -q
    1.5.0-final
    % svnlook youngest repos1
    1
    % rm -f repos1/db/txn-current
    % svnadmin create repos2
    % svnadmin -q dump repos1 | svnadmin -q load repos2
    % svnlook youngest repos2
    1
    % cat repos2/db/txn-current
    1
    # swap the repositories, relocate the wc, and commit.  Works.

Daniel
> And surely, /srv/svn/repos/oneiros/db/txn-current doesn’t exist.
>
> Here’s an ls of /srv/svn/repos/oneiros/db/:
> current  format  fs-type  indexes.sqlite  revprops  revs  transactions
>  txn-current-lock  uuid  write-lock
> transactions is empty, txn-current’s size is 0.
> svnadmin lstxns /srv/svn/repos/oneiros/ shows no transactions.
>
> Creating an empty /srv/svn/repos/oneiros/db/txn-current only changes

2009年11月1日

在linux下产生并调试core文件

由 晨笛 — 分类目录: Unix评论暂缺

$ uname -a
$ vi foo.c
$ gcc -Wall -g foo.c
$ ./a.out
$ ls -l core.*
$ ulimit -c 1024
$ ulimit -a
$ ./a.out
$ ls -l core.*
$ gdb –core=core.9128
(gdb) file ./a.out
(gdb) l

先看看我用的是个什么机器:

$ uname -a
Linux dev 2.4.21-9.30AXsmp #1 SMP Wed May 26 23:37:09 EDT 2004 i686 i686 i386 GNU/Linux

再看看默认的一些参数,注意core file size是个0,程序出错时不会产生core文件了。

$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) 4
max memory size (kbytes, -m) unlimited
open files (-n) 2048
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7168
virtual memory (kbytes, -v) unlimited

写个简单的程序,看看core文件是不是会被产生。

$ more foo.c

#include

static void sub(void);

int main(void)
{
sub();
return 0;
}

static void sub(void)
{
int *p = NULL;

/* derefernce a null pointer, expect core dump. */
printf(“%d”, *p);
}

$ gcc -Wall -g foo.c
$ ./a.out
Segmentation fault

$ ls -l core.*
ls: core.*: No such file or directory

没有找到core文件,我们改改ulimit的设置,让它产生。1024是随便取的,要是core文件大于1024个块,就产生不出来了。

$ ulimit -c 1024

$ ulimit -a
core file size (blocks, -c) 1024
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) 4
max memory size (kbytes, -m) unlimited
open files (-n) 2048
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7168
virtual memory (kbytes, -v) unlimited

$ ./a.out
Segmentation fault (core dumped)
$ ls -l core.*
-rw——- 1 uniware uniware 53248 Jun 30 17:10 core.9128

注意看上述的输出信息,多了个(core dumped)。确实产生了一个core文件,9128是该进程的PID。我们用GDB来看看这个core。

$ gdb –core=core.9128
GNU gdb Asianux (6.0post-0.20040223.17.1AX)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i386-asianux-linux-gnu”.
Core was generated by `./a.out’.
Program terminated with signal 11, Segmentation fault.
#0 0×08048373 in ?? ()
(gdb) bt
#0 0×08048373 in ?? ()
#1 0xbfffd8f8 in ?? ()
#2 0×0804839e in ?? ()
#3 0xb74cc6b3 in ?? ()
#4 0×00000000 in ?? ()

此时用bt看不到backtrace,也就是调用堆栈,原来GDB还不知道符号信息在哪里。我们告诉它一下:

(gdb) file ./a.out
Reading symbols from ./a.out…done.
Using host libthread_db library “/lib/tls/libthread_db.so.1″.
(gdb) bt
#0 0×08048373 in sub () at foo.c:17
#1 0×08048359 in main () at foo.c:8

此时backtrace出来了。

(gdb) l
8 sub();
9 return 0;
10 }
11
12 static void sub(void)
13 {
14 int *p = NULL;
15
16 /* derefernce a null pointer, expect core dump. */
17 printf(“%d”, *p);
(gdb)

Ubuntu升级命令

由 晨笛 — 分类目录: Unix评论暂缺

如果针对版本升级命令:
sudo apt-get update
sudo update-manager -c -d然后选选择upgrade

如果是普通升级的命令:
sudo apt-get update
sudo apt-get upgrade

如果针对单一软件升级的命令:
sudo apt-get update
sudo apt-get upgrade package_name_your_want_to_upgrade

如果你要全部升级的话:
sudo apt-get dist-upgrade

© 2010 晨笛的博客 All rights reserved - Wallow theme by TwoBeers Crew - Powered by WordPress - 使用愉快!