
LINUX paractice
文章平均质量分 77
foreverfresh
这个作者很懒,什么都没留下…
展开
-
修改c shell 提示符
目标:修改提示符为pwd,如下样式/dar/home/robin/LINUX >1. bash: in ~/.bashrcexport PS1="/w > " or PS1="/w > "; expport PS12. csh/tcsh: (1) set boot shell to csh: "chsh username" or "vi /etc/passwd"(2)原创 2006-11-30 17:28:00 · 1865 阅读 · 0 评论 -
为什么程序会出现Bus Error?
最近在论坛上看到一个程序员在询问Bus Error的问题。他有一个非常简单的测试程序,将一个short数组中第二个成员变量的地址附给一个int型的指针,接着给该指针赋值,大致代码如下: short array[10];int * p = (int *) &array[1];*p = 1;运行的平台是Solaris for SPARC,使用的编译器是GCC,程序执行到指针赋值的时转载 2007-11-30 20:42:00 · 26728 阅读 · 2 评论 -
一道题关于linux分页
int a = 1000;int main ()...{ int *b = &a - (0x1000/4); printf("*b = %d ",*b); printf("b = %p ",b); printf("&a = %p ",&a); printf("a = %d ",a);}i386 linux下用gcc编译 结果是什么? resul转载 2007-12-24 16:35:00 · 809 阅读 · 0 评论 -
怎样判别一个object file或binary是不是debug版?
如何判断可执行文件是否携带了调试信息? Q: 某些时候需要知道编译可执行文件时是否携带了调试信息(比如是否指定了-g编译 选项)。检查可执行文件中是否包含".stab" elf section,".stab" section用于 保存相关调试信息。下面这个脚本演示如何判断可执行文件是否携带调试信息if [ $# -le 0 ] then echo "Usage: $1 f转载 2008-05-16 01:26:00 · 1185 阅读 · 0 评论 -
代码测试、调试与优化的小结
代码写完以后往往要做测试(或验证)、调试,可能还要优化。 关于测试(或验证),通常对应着两个英文单词verification和validation,在资料[1]中有关于这个的定义和一些深入的讨论,在资料[2]中,很多人给出了自己的看法。但是我想正如资料[2]提到的: “The differences between verification and validation are un转载 2008-06-03 00:23:00 · 1264 阅读 · 0 评论 -
GDB checkpoint
GDB checkpoint原创 2011-02-21 14:30:00 · 1321 阅读 · 1 评论 -
C语言之struct大小、首地址与内存对齐
被问到如下问题:给定一个结构体中某个变量地址,可否得到结构体变量的地址?答案是可以,但是对不同的场合有不同的结果;这与微处理器平台、编译器的处理不可分割。首先,对于处理器,大尾端、小尾端的因素必须考虑;其次:一、 ANSI C标准中并没有规定,相邻声明的变量在内存中一定要相邻。为了程序的高效性,内存对齐问题由编译器自行灵活处理,这样导致相邻的变量之间可能会有一些转载 2012-03-02 10:59:55 · 759 阅读 · 0 评论 -
why gcc can link objs with multiple same symbols after ar?
1. why gcc can link objs with multiple same symbols after ar? what's the difference comparing with linking before ar?2. If multiple same symbols are allowable in linking, then what's the rule to res原创 2006-12-18 15:05:00 · 939 阅读 · 1 评论 -
GCC 中零长数组与变长数组
前两天看程序,发现在某个函数中有下面这段程序:int n; //define a variable nint array[n]; //define an array with length n在我所学的C语言知识中,这种数组的定义在编译时就应该有问题的,因为定义数组时,数组的长度必须要是一个大于0的整型字面值或定义为 const 的常量转载 2014-02-10 18:13:51 · 802 阅读 · 1 评论 -
error: cannot allocate memory in static TLS block
If shared library declease a single TLS global variable of size 1 (one) byte, and this TLS variable is accessed by the binary linking against it the shared library doesnt get loaded because there is an error creating the static TLS block.原创 2017-12-29 16:08:46 · 4649 阅读 · 1 评论 -
Linux应用层的定时器Timer使用详解
Linux应用层的定时器Timer使用详解转载 2017-12-29 16:17:23 · 22242 阅读 · 2 评论 -
LINUX 下多进程调试方法
#include stdio.h> #include unistd.h>int main() ...{ if(fork() == 0) ...{ printf("Child Process say hello to you! "); sleep(5); exit(0);原创 2007-04-12 14:57:00 · 3861 阅读 · 1 评论 -
在共享库中设置断点
From: Debugging a Program With dbx在共享库中设置断点dbx 对使用连接运行时链接程序的编程接口的代码提供全面的调试支持:调用 dlopen()、dlclose() 及其关联函数的代码。运行时链接程序在程序执行期间会绑定和解开共享库。利用对 dlopen() 和 dlclose() 的调试支持可步入函数,或在动态共享库的函数中以在程序启动时在链接的库中设置断点的转载 2007-04-12 19:12:00 · 1069 阅读 · 0 评论 -
Linux Kenel Development(2nd Edition)--reading digest
Questions:1. What is the two spaces?kenel space and user space2. What is the two contexts?interupt context and process context3. What is process?The process is one of the fundament原创 2006-12-06 15:11:00 · 1146 阅读 · 0 评论 -
library linking on LINUX
file list: original files were from chapter 20 of Linux系统分析与高级编程技术 1. hello2.c --test bench for static linking and linking with shared lib#include "Semaphore.h"#include stdio.h>void print_messag原创 2006-12-01 18:01:00 · 1164 阅读 · 1 评论 -
Linux Device Drivers(3rd Edition)--reading digest
1. Does interupt belong to kernel space?Unix transfers execution from user space to kernel space whenever an application issues a system call or is suspended by a hardware interrupt. Kernel code exe原创 2006-12-07 19:06:00 · 755 阅读 · 0 评论 -
关于Solaris的syslog机制
关于Solaris的syslog机制 syslog机制负责发送、记录系统内核及工具所产生的信息,由syslog()调用、syslogd守护进程和配置文件/etc/syslog.conf组成。当系统内核及工具产生信息时,通过调用syslog(),把信息送往syslogd,syslogd再根据/etc/syslog.conf中的配置要求,将这些信息分别作如下处理: 1.记录到系统日志中; 2.输转载 2006-12-07 19:47:00 · 1001 阅读 · 0 评论 -
tty和console
终端是一种字符型设备,它有多种类型,通常使用tty来简称各种类型的终端设备。tty是Teletype的缩写。Teletype是最早出现的一种终端设备,很象电传打字机(或者说就是),是由Teletype公司生产的。在Linux系统的设备特殊文件目录/dev/下,终端特殊设备文件一般有以下几种:rcX?a61.串行端口终端(/dev/ttySn)$s3sH 串行端口终端(Serial Port转载 2006-12-08 11:14:00 · 1205 阅读 · 0 评论 -
为fedora 4 安装中文
增加font,支持中文显示 自动挂载好了,重启吧。如果是上面说到的双系统,并且hda1挂载到/mnt/win/的话,把/mnt/win/WINDOWS/fonts里所有的中文字体和你需要的英文字体复制到/usr/share/fonts/里边吧,具体方法在Release Note里说得很清楚了,照着做一遍。(如果不是双系统,那只好自己去找一个Windows的机器然后拷贝C:/WINDOWS/转载 2006-12-12 20:36:00 · 896 阅读 · 0 评论 -
Redhatlinux9.0的samba设置详解
from:http://hi.baidu.com/mxd1982/blog/item/01f726ad27f11b094b36d646.html1.安装samba首先验证您的机器中是否已经安装sambarpm -qa|grep samba,如果出现samba-common-2.2.7a-7.9.0samba-client-2.2.7a-7.9.0samba-2.2.7a转载 2006-12-12 21:01:00 · 875 阅读 · 0 评论 -
Udev介绍
第一、什么是udev? 这篇文章UDEV Primer给我们娓娓道来,花点时间预习一下是值得的。当然,不知道udev是什么也没关系,把它当个助记符好了,有了下面的上路指南,可以节省很多时间。我们只需要树立一个信念:udev很简单!嵌入式的udev应用尤其简单。 第二、为什么udev要取代devfs? 这是生产关系适应生产力的需要,udev好,devfs坏,用好的不用坏的。 udev转载 2006-12-13 16:22:00 · 2096 阅读 · 0 评论 -
Linux Porgramming Unleashed--reading digest
chapter 241. nm [options] fileThe nm command lists all of the symbols encoded in an object or binary file.Table 24.1 nm OPTIONSOption Description-C|-demangle原创 2006-12-20 23:38:00 · 841 阅读 · 0 评论 -
vi常用命令的使用
vi编辑器是AIX操作系统维护模式下可用的唯一编辑器,也是所有UNIX系统的标准编辑器。它具有命令行编辑功能,可作为某些程序的缺省编辑器。vi编辑器是全屏编辑器,有两种操作方式:命令方式(状态)和文本输入方式(状态)。其命令方式的格式为单字母命令,调用命令时只需输入一个字母即可完成简单的编辑功能。 vi的调用格式在异地登录的用户必须首先设置终端类型$ TERM=vt100,或将转载 2007-02-07 18:08:00 · 1325 阅读 · 0 评论 -
TLS的四种模式 Global Dynamic,Local Dynamic,Initial Exec和Local Exec
TLS的4种模式:Global Dynamic, Local Dynamic, Initial Exec和Local Exec。转载 2017-12-29 16:26:05 · 5718 阅读 · 0 评论