易截截图软件、单文件、免安装、纯绿色、仅160KB

在Linux下产生并调试core文件

 
转自 http://blog.china-pub.com/more.asp?name=uniware&id=35478
 
 
在Linux下产生并调试core文件
先看看我用的是个什么机器:
$ 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 <stdio.h>
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.


相关文档:

Socket编程:由Linux向Windows移植问题


转自:http://www.cic.tsinghua.edu.cn/jdx/book1/CHAPTER3.htm
 
在源文件开始增加#include <winsock.h>语句。
调用WSAStartup()函数初始化Windows Sockets DLL,并在结束时调用WSACleanup()函数通知Windows Sockets DLL释放资源。
将套接字的类型为int改为SOCKET。
获取、设置错误码不要使用全局变量er ......

Linux系统调用


功能描述:
获取一些文件相关的信息。
用法:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *path, struct stat *buf);
int fstat(int filedes, struct stat *buf);
int lstat(const char *path, struct stat *buf);
参数:
path:文件 ......

Linux下把kernel空间映射到用户进程空间(mmap实现)

 在mmap函数里,使用remap_pfn_range
函数。代码如下。注意要设置一下vma->vm_pgoff为你要map的io空间的物理地址对应的页。
arm  IO/ 内存统一编址  所以
#define io_remap_pfn_range(vma,from,pfn,size,prot) \
             &nb ......

linux PHP 环境搭建

一、登陆
1.进入linux
2.用户名: root
3.口令:123456
4.mysql 用户名 root 密码 123456
二、启动mysql与apache服务
1.启动mysq数据库:/usr/local/mysql/bin/./mysqld_safe --user=mysql &
2.停止mysql数据库:/usr/local/mysql/bin/mysqladmin -u root -p shutdown
3.启动apache: /usr/local/apache2/bin/./ap ......

linux客户端连接后中文乱码解决


用SSH登陆远程的linux服务器或用win浏览运行samba的linux服务器中有中文名的文件夹的时候,看到里面的中文文件名都是乱码,编辑文档的时候都是串行的,每次要export LANG=en麻烦死了。
上网四处搜索,求教高人,得此办法。
(1) 打开/etc/sysconfig/i18n
设置为:
LANG="zh_CN.GB2312"
LANGUAGE="zh_CN.GB18030:zh_CN ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号