实验:使用GDB查看结构体在内存中的存储方式
结构体在内存中的表示形式是怎么样的?
结构体在内存中和普通变量存储没有太大的区别。
首先我们看看,计算机如何读取普通变量:
普通变量例如int是占据4个字节,计算机读内存的时候会从起始地址开始读,读4个字节,按照int的规则将二进制转化为整形。所以读取普通变量我们要知道起始地址和数据类型(占据长度,解读方式)。
再看看计算机如何读取结构体变量:
结构体是自定义变量,是由多个普通变量组成的。我们读取结构体变量,实际上是读取结构体包含的数据成员。例如结构体T包含三个数据成员:char var1,int var2,long var3。计算机如果读取结构体变量 t 的数据成员var1,计算机需要知道结构体变量的地址 &t,已知这个结构体变量占据16个字节,那么从起始地址开始往后16个字节,都存储了结构体变量的数据成员。如果我们再知道数据成员var1相对于结构体起始地址的偏移,我们就可以像读取普通变量一样读取结构体数据成员。
#include<stdio.h>
#pragma pack()
#define offset(type, name) (size_t)(&(((type *)0)->name))
typedef struct Test{
char var1; //1
int var2; //4
long var3; //8
char var4; //1
}Test_t;
/*
64bit:
Test_t:
cxxx iiii //在char后面填充,使得后一个变量int从对齐参数的整数倍
llll llll
cxxx xxxx //结构体总长度必须为对齐参数的整数倍,因此在结构体尾部填充。
32bit:
Test_t:
cxxx iiii
llll cxxx
*/
int main(int argc, char** argv){
Test_t t1;
t1.var1 = 'A';
t1.var2 = 99;
t1.var3 = 999;
printf("struct->var1: %ld \n", offset(Test_t, var1));
printf("struct->var2: %ld \n", offset(Test_t, var2));
printf("struct->var3: %ld \n", offset(Test_t, var3));
printf("struct->var4: %ld \n", offset(Test_t, var4));
printf("struct: %ld \n", sizeof(t1));
return 0;
}
针对上述测试代码,我使用了GDB调试工具对程序内存进行查看。想看看结构体在内存中的表现形式是怎样的。
$ gcc -g -o struct_test struct_test.c
$ gdb
(gdb) file struct_test
(gdb) start
编译,打开gdb,在gdb中加载程序,调用main函数,创建结构体变量,此时下一步是对结构体成员赋值。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoUAAACFCAYAAAAttoL9AAAAAXNSR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98K/tzZ3k9uM7L/qYQAAAAz8WlEDjB0f9Vy/8qBgDcjUshcJKjlzouhQCAO/24FM6/rZi00OYmrcF3ePrnftf5OvtmNfw8AQDu9PtS6P1C0hi/sDC+A5OXv9ud5+vuGdXdcWYAABSXQvzQ+Zyf/l148vnG2fhZAgA8EZdC/ND5nJ/+Xdg53+jxeLW75ryz5wIAcIb0/2iiv7zmL8lJ6/D+7OebfcZZzmNn2nVUF8Xt2orid9Pz21zXU18bAOD9hZdC+8unWuMzdD7Xnc9+9fvk7TFiGvdqsvjdOmcHAOAu7qWw+wuLX2yfp/OZ7nzutiebMXJevrtvt07NPS2vdteVswEAOOqPS+HKLyt+sX2ezme6+7nPvqh/xLOaqM/q1r2SPdMTzwgA+G4/LoXZLyovxy+2z9P5THc/99nX+S51aiLdulc68noAAHiF35fC6peWzfML7TNln3kWH7HOd6IzM5rVmT90617pyOsBAOAVflwKPVocxfFZos9YP39bY9eRrEZneM9K+6Zu3at55/FiHav1AAB0uf9HEwDPxKUQAHAVLoXAG+FSCAC4CpdCAAAA5JfCV/6tBH8DAgAAcJ/wUnjHJe3Ve3IRBQAA+D/upfDOy9Kr9vb2GTFl86rKX6Fzro47zg4AAJ7sr//8L4tglCBKCvCqAAAAAElFTkSuQmCC" alt="进入main函数">
我们在赋值前查看一下此时结构体变量t1在内存的表现是怎样的。
(gdb) print &t1 #打印结构体变量t1的地址
(gdb) x/24xb &t1 #读取24次内存,每次读一个字节,以16进制的形式打印
使用print打印了结构体变量t1的地址,通过x/<n/f/u> <addr>的形式查看程序的内存,详情见以下博文。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnoAAABnCAYAAACXfe9gAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABMSSURBVHhe7ZtRkiU5qkTfAnqxs9De0zzTBzUUCTgEoauIm/5xbBTugJycj5RVVf/ff/7zn//+888/hBBCCCHky+BDjxBCCCHkS+FDjxB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2eLvUaW3MSL4/WbG59trWehvzTVPIL+tur9TTk76b1J3oouHDVWzzV93StIV9rni5EflW7SmW+/s7ursyKtFNU8unvzIu0rP80d+Xv6FHtCSr59HeUHe2E/FN4uaymv6M90H7IP4WXy2r6O9vjqncSL5fV9HfmeRryT1PJl+2D+pG/m/Zf3S4tC4jCv9X3dK0h39Kd153fpTp/adm9kVedf4pqvqV1ar2z932azk5Z9sirzj9FNd/SstxoJ+SfItrV07Id0H7IP0W0q6dlO6D9kH+KaFdP69R650w7RWenTq13zrRd8KFniPyle1R9D+17tR1/SnX+0rJ7I686/xTVfEvLdAvyF3rOKbwckZZljjzps3i1J/CyRFqWG+2E/FNEu3patgPaD/mniHb1tGwHtB/yTxHt6mmdWu+caafo7NSp9c6Ztgs+9AyRv2Ou1qb+lOr8pWX3Rl51/imq+ZZ2xy7d+t1Ud1palj3ysp4nEO3qadkuaE/knyLa1dOyHdB+yD9FtKunZTug/ZB/imhXT+vUeudMO0Vnp06td860Xfx56C06waKQKPxbfU/X2m7ffnv1okceAs1HfqYvKv0nQfkyH9VbMu8U2X5Wi/J39Kj2FGg/5Ge6gPyToP2Qn+kC8k+C9kN+pgvIPwnab7d/mmn+qb+Tvx56ixUgCim6nKM6q4lueZPv1Xza1zWet0A+IurXupyjOqtpor6nkO0lupxtndatF9VEdaeIMmldzrpOa9aLaqz/BKJsWpezrtOa9Sr+U4iyaV3Ouk5r1qv4TyHKpnU5R3VWE93i1Z0myqZ1OaM6D+SfJsqndTmjOg/k7+LHQ48QQgghhHwHfOgRQgghhHwpfOgRQgghhHwp6UPvk3+XfOLvrQkhhBBCvpnwoXfi4cXHHiGEEELIfbgPvZMPLj72CCGEEELuYdtDb82QOfqMuONuQgghhBDyz3//H0HvkQLpFTQIAAAAAElFTkSuQmCC" alt="赋值前内存">
我们看到此时的内存杂乱无章。我们步进程序,给结构体变量var1赋值,再查看一次内存。
(gdb) step #执行下一条语句
(gdb) x/24xb &t1
(gdb) x/24db &t1 #以十进制的形式打印内存
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAngAAACmCAYAAABJPPJMAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAB0KSURBVHhe7Z3dimXJcYXPA8xr+Al6wBc2GN8YecBgDMIXYhgk90jyaCT3g847ycq2o4iKWvGTO3ee3DvPuvjozLUiIiP2Lqik/vrx7Xef//rNN98QQgghhJBN+NsF70doEEIIIYSQe/L49l/9C94vv/wC9Rk88yxCCCGEkJ1xv4K34sLFSx4hhBBCyDiPT+Bn8FZetHjJI4QQQggZA34F74xLVqshdfQ644yzCSGEEEJemccnc8E784Kla/XUnXnJ4wWSEEIIIbvz4Vu0vOARQgghhNybrq/gNc9S9WVtdUTme0htTcXzYqxu14QQQgghV6R8wbN6trdaW9u9rC2R54Fyqpqna62t7V7WhBBCCCFX4sP/ZOFdXKye7a2W+RU9oprTc6bWMp8QQggh5Co8Ppk/dBxdWponIC/SqjmRntHyNF6MpyO0r+M9jRBCCCFkNR++Rds4cpnJcqo1s3N66KmfnTu7V0IIIYSQs+j6O3hN11jP7rWG9rLWeHoGyss0b420ts7iCSGEEEKuwOOf/v330LAXGHShQTGC3utYrVk8vYLU1aC4hufrXOvLHnmEEEIIIVfi8atf/xEaDX2RQZeaMy86V7808VJHCCGEkLvw+I/vf4IGol1yNChmR15xZkIIIYTcl8f3//UzNAghhBBCyD15/P6//wINQgghhBByTz78oWNCCCGEEHJvHp/UBU//rJn382aRR16Dq75/+dhc9TGanZ35hBBCyFm8fQUPfdKxmt7zk9Tr0d65gPyVoJ6e2ac9q3dPCCGEnMnj2///r8rQJxyt8RPSa1B5z1f8WMg+fmeTnb+6P0IIIa/F2/9kceQTFNmPynu+4sdC9vGb0WIRKBaBYrWW+YQQQsiZvPsZPAv6BNX+FcQj90e/1+z9Rh7C1rR7L87T7d4j888EnaW1zI80QgghpJe3b9Fa7Ceatkea3pP7U3mnR9579rGT7UXTOooRIm8G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37nec4yo7zv7vgNdpgaDity9qLs5roljv5KObZvo5BXiPzIyRXU/WR19D5dwbN1ohitHd37GwCit0Vzr/3/NF8yGvofImz2p3w5noVdpv/wwWPEEIIIYTcG17wCCGEEEI2gxc8QgghhJDNCC94z/xe9Ct/358QQggh5EzcC96KC9ezz+SlkhBCCCE7Ai94Ky8+zzobndM0jfU1mT+DSl8VVvROCCGEkOcx7YKnLyN6nXHG2RXsOehcr5em9/TZG4/Q+UdrSR+jvRBCCCHkynzz1/8FACLbYxq6Db8AAAAASUVORK5CYII=" alt="赋值变量1后内存">
我们很明显发现在0x7ffffffee370的值发生了改变,也就是结构体变量t1所在地址的第一个字节被修改了。结合我们我们的赋值语句:给结构体第一个char变量赋值,我们很容易发现:结构体第一个char变量就在结构体变量t1地址0偏移的地方。十六进制的0x41转换为十进制就是65,正好是A的ascii码。
再次步进,给第二个结构体变量赋值,再次查看内存。
(gdb) step #执行下一条语句
(gdb) x/24xb &t1
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnYAAABpCAYAAAC3S26eAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABK2SURBVHhe7d1Lrh1HjoBhLcArca2nZ72Bkl2AZ43eVK+i2/VSDb2e2xUFs0BRfAQzMk/kSf2DD4gkGUyGzgVOQA/703/94T8//uOPv3z88MMPAAAAeGNc7AAAAB6Cix0AAMBD/H6x++wmhy9fvrjxK7zyXQAAAE/zz4vdHz5+/PFHN7njosXlDgAA4Jjwj2J3XrC43AEAAPRderEbPaSPXlfOeDcAAMD3xr3YnXmx0r06fa+83HFxBAAAT8TFDgAA4CHaF7uRs2bzsrZxT5WPSG9tJhfV2LhdAwAA3MWn//nvb/9VbHRpsfHq2cbG2j7L2spyEW/PbCyK69hY22dZAwAA7Pbpt99++/jll7nfsbPx6tnGqvxMPDO7p/NOHavyAAAAO7UudsPICS+XxWb3ZPHK2KdFNVHco/O6PooBAADs4F7shiO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zurFsjNU56vyu0Rn9WLZGarzVfldorN6sU6tt85iu3TO1Kn11lnsDN/8L8U6g0RDVcO+a96L69jVefvs1Us8ylWq/lU+iw8z+3eq5svyVb2V5XbJzmdj0fydeFS7S3W+Kp/FRZXfqTpflc/iosrvVJ2vymdxUeV3qs53dX631flX82dx/1+x44XRUBKXdVRnYxK33inv1bw6r2u83FDlK9F+HZd1VGdjWrTvLrJzSVzWtk7HbS6qiep2iWbScVnrOh2zuajG5u8gmk3HZa3rdMzmZvJ3Ec2m47LWdTpmczP5u4hm03FZR3U2JnHLq9stmk3HZV3Vear8btF8Oi7rqs5T5c/gXuwAAADwfrjYAQAAPAQXOwAAgIcoL3ZX/1mw9sp3AQAAPE16sdtx0eJyBwAAcEx4sdt5weJyBwAA0HfpxW70kD56XTnj3QAAAN8b92J35sVK9+r05XIHAADQw8UOAADgEX74+H/wv3T+jbr6QgAAAABJRU5ErkJggg==" alt="赋值变量2后内存">
对比上一次的内存,我们发现不是第二个字节的值被修改,而是第五个字节的值被修改了。这是结构体存储时候做的字节对齐,给第一个char变量后填充了3个字节,避免第二个变量int横跨边界。十六进制的0x63就是十进制的99。我们知道int变量占据4个字节,因此下一个long变量存储从0x7ffffffee378开始,长度为8个字节。显然存储采用了小端存储的方式:低字节存储在内存的低地址。
下一条语句是给变量3赋值999,十进制的999对于十六进制的0x3E7,因此我们猜测下一次内存在0x7ffffffee378开始的前两个字节会被修改。
0x7ffffffee378 0xe7 0x03 0x00 0x00 ...
我们继续步进,给变量3赋值,查看内存验证我们的想法。
(gdb) step #执行下一条语句
(gdb) x/24xb &t1
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnQAAADLCAYAAADnag5GAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAClWSURBVHhe7Z1NjmXJjaXfArSB3ILmmgndk+qJgAK6CqgSVJmR2UCrMlM1ioVqT+qykOhNp/P38trjvc/P4EPSziFppL+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t="赋值变量3后内存">
显然我们的猜测是正确的!
实验:使用GDB查看结构体在内存中的存储方式的更多相关文章
- C语言结构体在内存中的存储情况探究------内存对齐
条件(先看一下各个基本类型都占几个字节): void size_(){ printf("char类型:%d\n", sizeof(char)); printf("int类 ...
- <转载>浅谈C/C++的浮点数在内存中的存储方式
C/C++浮点数在内存中的存储方式 任何数据在内存中都是以二进制的形式存储的,例如一个short型数据1156,其二进制表示形式为00000100 10000100.则在Intel CPU架构的系统中 ...
- C语言中浮点数在内存中的存储方式
关于多字节数据类型在内存中的存储问题 //////////////////////////////////////////////////////////////// int ,short 各自是4. ...
- QList介绍(QList比QVector更快,这是由它们在内存中的存储方式决定的。QStringList是在QList的基础上针对字符串提供额外的函数。at()操作比操作符[]更快,因为它不需要深度复制)非常实用
FROM:http://apps.hi.baidu.com/share/detail/33517814 今天做项目时,需要用到QList来存储一组点.为此,我对QList类的说明进行了如下翻译. QL ...
- Float在内存中的存储方式及IEC61131处理
Float在内存中的存储方式及IEC61131处理 1,fp32(32bits float)类型数据在存储器中占用4Bytes存储,且遵循IEEE-754标准: 一个浮点数分三部分组成: 符号位s(1 ...
- 数据在内存中的存储方式( Big Endian和Little Endian的区别 )(x86系列则采用little endian方式存储数据)
https://www.cnblogs.com/renyuan/archive/2013/05/26/3099766.html 1.故事的起源 “endian”这个词出自<格列佛游记>.小 ...
- c语言结构体在内存中存储,字节对齐
注意: 出于效率的考虑,C语言引入了字节对齐机制,一般来说,不同的编译器字节对齐机制有所不同,但还是有以下3条通用准则: (1)结构体变量的大小能够被其最宽基本类型成员的大小所整除: (2)结构体每个 ...
- C/C++浮点数在内存中的存储方式
一.内存表示 任何数据在内存中都是以二进制的形式存储的,浮点数的表示是把一个数的有效数字和数的范围在计算机的一个存储单元中分别予以表示,数的小数点位置随比例因子的不同而在一定范围内自由浮动.如下图是3 ...
- float和double在内存中的存储方式
本文转载于:http://wenku.baidu.com/link?url=ARfMiXVHCwCZJcqfA1gfeVkMOj9RkLlR9fIexbgs9gDdV8rIS48A1_xe1y6YgX ...
随机推荐
- php基础文档
目录 PHP简介 PHP概述和名词解释 PHP常见数据类型 PHP运算符 PHP流程控制语句 PHP函数 PHP类与对象 PHP会话session与缓存cookie(扩展) 1.PHP简介 PHP,即 ...
- ubuntu 交叉编译 busybox 1.31.1
目的:静态编译 Busybox_arm64 1.13.1 环境:Ubuntu 18.04.3 #----------------环境配置 # aarch64-linux-gnu-g++ sudo ap ...
- 小白学 Python 爬虫(8):网页基础
人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...
- ctf中关于图片的隐写随笔(不全)
①JPG图片的结束符,十六进制常为FFD9 ②binwalk的原理是:检查常见的文件头信息,如果不符合,一定有隐藏信息.③JPG是有损压缩,PNG是无损压缩,BMP是不压缩. 隐写的基本原理:图片查看 ...
- java多线程的wait、notify/notifyAll区别
1.wait().notify/notifyAll() 方法是Object的本地final方法,无法被重写. 2.wait()使当前线程阻塞,前提是 必须先获得锁,一般配合synchronized ...
- .net压缩文件
首先nuget安装DotNetZip 代码很少
- 【Android - 组件】之IntentFilter的匹配规则
我们知道,Activity的启动模式分为两种,分别是显式启动和隐式启动.显式启动需要明确的指定被启动的对象的组件信息,包括包名和类名:而隐式启动需要 Intent 能够匹配目标组件的 IntentFi ...
- jenkins + maven + nexus + [ svn 或 GitLab 或 GitHub ]
目录 介绍 DevOps平台四大模块 针对DevOps开源项目 Jenkins 介绍 Maven 介绍 maven的核心概念介绍 SVN介绍 Nexus介绍 Maven私服的 个特性: 流程图 环境搭 ...
- 有趣的动态规划(golang版本)
多年前就听过这个动态规划,最近在复习常用算法的时候才认真学习了一下,发现蛮有意思,和大家安利一波. 定义: 准确来说,动态规划师吧一个复杂问题分解成若干个子问题,并且寻找最优子问题的一种思想,而不是一 ...
- 寻找键盘bug
被这句阻拦了