自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小猪爱拱地

勤奋和毅力是通向成功的阶梯

  • 博客(33)
  • 资源 (1)
  • 收藏
  • 关注

转载 POSIX File Capabilities

POSIX File CapabilitiesSometimes you need a particular program to do a specific task that requires administrative (root) privileges. You can run your program withsudo or chown your program to ro

2015-01-29 23:42:56 1065

原创 Linux下列举局域网内的IP地址

1. 使用 nmap命令:$ sudo nmap -sP 192.168.1.0/24[sudo] password for charles: Starting Nmap 6.40 ( http://nmap.org ) at 2015-01-29 22:04 CSTNmap scan report for promote.cache-dns.local (192.168.1.1)H

2015-01-29 22:12:15 3135

原创 Wireshark 不能检测无线网络的问题

在ubuntu 上安装了 wireshark之后,运行起来,发现,找不到无线网络。在网上查了相关资料之后,才知道,非root账号没有这个权限。可以使用下面的方法来设置权限:sudo groupadd wiresharksudo usermod -a -G wireshark $USERsudo chgrp wirshark /usr/bin/dumpcapsudo setcap

2015-01-29 22:00:30 2902

转载 pipelining

To make it easier to navigate this post, here are the contents:-------------------------------------- A. Data Hazards 1. Needing to forward 2. Needing to stall 3. Not needing anything

2015-01-28 08:13:23 771

转载 Memory access ordering part 3 - memory access ordering in the ARM Architecture

Memory access ordering part 3 - memory access ordering in the ARM ArchitecturePosted by leiflindholm in ARM Processors on Oct 19, 2011 6:36:00 PM In my previous posts, I have introduced th

2015-01-27 08:20:06 1569

转载 Memory access ordering part 2 - barriers and the Linux kernel

Memory access ordering part 2 - barriers and the Linux kernelPosted by leiflindholm in ARM Processors on Apr 11, 2011 4:05:00 PM My previous post provided an introduction to the concept of mem

2015-01-27 08:17:36 1078

转载 Memory access ordering Part 1 - an introduction

Memory access ordering - an introductionPosted by leiflindholm in ARM Processors on Mar 22, 2011 3:36:00 PM I recently gave a presentation at the Embedded Linux Conference Europe 2010 called

2015-01-27 08:15:11 872

转载 Configure with --host, --target and --build options

Configure with --host, --target and --build optionsWhen people configure a project like './configure', man often meets these three confusing options, which are more related with cross-compilation

2015-01-24 17:40:42 788

原创 GCC 共享库在链接时的搜索位置和优选次序

假设有两个相同的共享库,一个在标准的共享库搜索目录(/lib/i386-linux-gnu), 一个在非标准目录(/home/charles/tmp):p$ ls /home/charles/tmp/libshared.so /lib/i386-linux-gnu/libshared.so -l-rwxr-xr-x 1 root root 7706 Jan 24 14:56

2015-01-24 16:51:44 1442

原创 DBUS的 hello 消息

DBUS connection 在建立之前,需要给 dbus daemon 发一个 hello消息, 以便获得 connection 的 unique name.下面是 DBUS specification 里的一段话:Each connection has at least one name, assigned at connection time and returned in res

2015-01-24 14:22:34 1356

原创 GNU Debug Link

有有些程序会包含一个特殊的 gnu link 的section:$ objdump -h program | grep debugtest.gnu_debuglink: file format elf32-i386这个 gnu debug link 是为了调试用的。可以用如下的方法创建:1) 写一个小程序 test.c 如下:int i = 100;void fun(v

2015-01-24 12:48:43 4266

原创 Ubuntu 14.04 在 Nvidia 驱动升级(346.35)后屏幕闪烁

问题的原因是 Compiz/Unity 的 bug造成的。可以按如下方法更新Compiz/Unity:sudo add-apt-repository ppa:townsend/compiz-nvidia-refresh-testPPA descriptionThis PPA adds the patch to Compiz to (hopefully)

2015-01-24 00:24:35 3043

原创 Ubuntu 编译kernel 的几种方法

Method 1:1. Use apt-get source to download the Ubuntu version of the kernelapt-get source linux-image-$(uname -r)gives a folder that contains, for example:linux-3.2.0 linux_3.

2015-01-22 21:59:17 11640

原创 linux 进程的最大线程个数

1. 可以通过下面的方法查到:cat /proc/sys/kernel/threads-max 15882另外,一个进程实际的线程个数,可以从 /proc/{PID}/status里得出:/proc/544#cat status Name: kpsmousedState: S (sleeping)Tgid: 544Pid: 544PPid: 2TracerPid: 0

2015-01-15 02:51:05 2404

原创 函数调用参数和寄存器

1) MIPS 函数参数从左到右依次传递给 $a0~$a3.(gdb) where#0 Calculator::Multiply (this=0x411008, a=12, b=10) at testclass.cpp:29#1 0x004009b4 in main (argc=1, argv=0x7fff6e44) at testclass.cpp:37(gdb) p /

2015-01-12 22:44:42 3850

转载 Profiling the kernel

There are several facilities to see where the kernel spendsits resources. A simple one is the profiling function, thatstores the current EIP (instruction pointer) at each clock tick.Boot the kernel

2015-01-12 02:04:37 1108

转载 Trace and profile function calls with GCC

Software debugging is a complex task. There is always the need to collect all available information, in order to detect and understand the problem fast and to think of a proper solution. Sometimes it’

2015-01-11 23:58:44 799

原创 打印线程PID

测试程序如下:#include #include #include #include void * thread_start(void *arg){ printf("Process ID: %d, thread ID %d\n", getpid(), gettid());}int main(void){ pthread_t tid; pthread_

2015-01-11 13:08:24 3428

原创 mmap系统调用的实现

1.  GLIBC 文件 sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c:__ptr_t__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset){ if (offset & ((1 << MMAP_PAGE_SHIFT) - 1))

2015-01-11 12:45:59 1915

原创 GCC -fno-omit-frame-pointer

GCC 的  -O (-O1) 会打开  -fomit-frame-pointer,也就是,去掉函数调用时的frame pointer.我们可以看一个例子。int Calculator::Multiply(int a, int b){ printf("%d * %d = %d\n", a, b, a * b); return a * b;}上面的函数,如果加上 -

2015-01-11 01:30:45 18973 1

转载 Introduction to Linux Graphics drivers: DRM

Linux support for graphics cards are very important for desktop and mobile users: they want to run games, composite their applications and have a nice and modern user experience.So it’s usual that

2015-01-10 09:06:07 7900

原创 在 vim的状态栏显示 当前行所在的函数名字

在 .vimrc里添加:fun! ShowFuncName() let lnum = line(".") let col = col(".") echohl ModeMsg echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW')) echohl None call search("\\%" . lnum . "l" .

2015-01-10 00:33:48 4026

转载 Understanding the nature of ARM PC register

In ARM state, the value of the PC is the address of the current instruction plus 8 bytes.     In Thumb state:          For B, BL, CBNZ, and CBZ instructions, the value of the PC is the address o

2015-01-10 00:24:05 609

原创 把行末尾的换行符变成空格

测试数据如下:$ cat input line 1line 2line 3line 4方法一:sed ':a;N;$!ba;s/\n/ /g' input:a 是一个 label. N 取出下一行数据并合并到当前行; $ 表示最后一行, $!表示如果不是最后一行,转到 label a.方法二:while read line; do printf "%s" "$lin

2015-01-07 03:53:02 1697

转载 The Rule of Three

Rule of ThreeThe rule of three (also known as the Law of The Big Three or The Big Three) is arule of thumb in C++ (prior to C++11) that claims that if a class defines one of the followin

2015-01-07 01:21:29 1571

原创 Bind a const reference to temp variables

我们知道,对于临时变量,是不能在它的存在范围之外引用的。所以,下面的代码,编译是有问题的:#include class A {public:A();~A();void Print(void) const;};A::A(void){    std::cout << "constructor of A" << std::endl;}A::

2015-01-07 00:55:52 666

转载 Linked Lists and Work Queues

By Sreekrishnan Venkateswaran Wednesday, March 15th, 2006Several useful helper interfaces exist in the kernel to make life easier for developers. One example is the doubly-link

2015-01-06 11:27:05 812

转载 Copy constructors, assignment operators, and exception safe assignment

What is a copy constructor?A copy constructor is a special constructor for a class/struct that isused to make a copy of an existing instance. According to the C++standard, the copy constructor f

2015-01-06 03:30:29 725

转载 Debugging the Linux Kernel with debugfs

debugfs is a simple memory-based filesystem, designed specifically to debug Linux kernel code, and not to be confused with the debugfs filesystem utility. Introduced by Greg Kroah-Hartman in December

2015-01-06 03:08:40 988

原创 设置 GDB 代码搜索路径

在用GDB进行 debug的时候,可以用  directory 设置搜索目录,用 show direcories 显示设置的搜索目录:(gdb) show directories Source directories searched: $cdir:$cwd(gdb) directory /homeSource directories searched: /home:$cdir:$cw

2015-01-06 02:00:02 16244

转载 How module init function is called when the module is loaded

It depends on whether the driver is a built-in module or compiled as a loadable module. I'll be talking about a built-in module in this answer (one with y in .config):module_init expands to

2015-01-06 00:28:09 1060

转载 memfd_create(2)

For 4 months now we’ve been hacking on a new syscall for the linux-kernel, calledmemfd_create. The intention is to provide an easy way to get a file-descriptor for anonymous memory, without requirin

2015-01-05 08:29:20 2941

原创 在代码中设置断点

可以用汇编来实现。代码如下:int main(void){ int i = 0;#ifdef X86 asm ("int $0x03");#endif#ifdef ARM asm ("bkpt");#endif i = 10; return 0;}执行的时候,不用设置断点:$ gdb setbreakpoint --silent

2015-01-04 23:45:56 2099

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除