代码改变世界

随笔档案-2011年03月

[Advance] How to debug a program (下):示例

2011-03-23 13:10 by zhenjing, 1239 阅读, 收藏, 编辑
摘要: 原理:程序=指令+数据。 指令:用户代码(Text)+静态库+动态库。反汇编可得程序指令。 数据:Data -- 已初始化的全局数据,包括常量字符串;BSS -- 未初始化的全局数据;Heap; Stack;Register 阅读全文

[Advance] How to debug a program (上)

2011-03-22 12:16 by zhenjing, 2194 阅读, 收藏, 编辑
摘要: 介绍64位linux系统下的一种高级调试技巧。32位类似,内存分布略有区别。 阅读全文

[转] Real-World Concurrency

2011-03-15 13:37 by zhenjing, 540 阅读, 收藏, 编辑
摘要: 1. Know your cold paths from your hot paths. 弄清楚代码里的热门执行路径和冷门执行路径。 2. Intuition is frequently wrong—be data intensive. 直觉常常是错的,要靠数据说话。 3. Know when—and when not—to break up a lock. 知道什么时候把一个锁拆成多个,并知道什么时候不必这样做。 4. Be wary of readers/writer locks. 警惕读写锁。 5. Consider per-CPU locking. 考虑用每个 CPU 用一个锁。 6. Know when to broadcast—and when to signal. 知道什么时候用单个唤醒,什么时候用广播唤醒。 7. Learn to debug postmortem. 学会验尸 8. Design your systems to be composable. 设计系统(s),使之能相互组合。 9. Don’t use a semaphore where a 阅读全文

[转] Policies/Binary Compatibility Issues With C++

2011-03-15 11:11 by zhenjing, 758 阅读, 收藏, 编辑
摘要: C/C++ 的二进制兼容性 (binary compatibility)与ABI (application binary interface)关系甚大。到底如何判断一个改动是不是二进制兼容呢?这跟 C++ 的实现方式直接相关,虽然 C++ 标准没有规定 C++ 的 ABI,但是几乎所有主流平台都有明文或事实上的 ABI 标准。C++ ABI 的主要内容: * 函数参数传递的方式,比如 x86-64 用寄存器来传函数的前 4 个整数参数 * 虚函数的调用方式,通常是 vptr/vtbl 然后用 vtbl[offset] 来调用 * struct 和 class 的内存布局,通过偏移量来访问数据成员 * name mangling * RTTI 和异常处理的实现(以下本文不考虑异常处理) C/C++ 通过头文件暴露出动态库的使用方法,这个“使用方法”主要是给编译器看的,编译器会据此生成二进制代码,然后在运行的时候通过装载器(loader)把可执行文件和动态库绑到一起。如何判断一个改动是不是二进制兼容,主要就是看头文件暴露的这份“使 阅读全文

SQL批量删除与批量插入

2011-03-11 12:03 by zhenjing, 79820 阅读, 收藏, 编辑
摘要: SQL批量删除与批量插入 阅读全文

[转] SQL和C数据类型的映射

2011-03-03 17:01 by zhenjing, 3257 阅读, 收藏, 编辑
摘要: SQL Data Type 和 SQL和C数据类型的映射 阅读全文

[转] Buffer Overflows and You (下)

2011-03-03 11:59 by zhenjing, 810 阅读, 收藏, 编辑
摘要: Got root?Gentlemen, we can root it. We have the technology. We have the capability to root yet another poor idiot's server on the int4rw3bs. Steve Austin will be that man. Better than he was before. Better, stronger, faster, errrr...We spent all that time developing a small bit of shellcode. Let 阅读全文

[转] Buffer Overflows and You (上)

2011-03-03 11:48 by zhenjing, 797 阅读, 收藏, 编辑
摘要: Magical gnomes present: Buffer Overflows and You Is it the 90's? Are you wondering why your server is running slow? Why it's trying to ping flood some host in California? Why someone else is logged into your machine and you've recently become a prominent porn hosting provider? This site will help you figure it all out. And if you have a time machine, you can probably go back and do it to someone else! Before continuing, it's important to note that this guide is designed for 64-bit systems. 阅读全文
点击右上角即可分享
微信分享提示