首页
关于
友链
留言
统计
Search
1
基于Rocky Linux 8.10系统使用源码搭建LNMP环境,附加安装SQLite
324 阅读
2
阿里云轻量应用服务器图文安装红帽系统RHEL8.10
73 阅读
3
.NET Framework
56 阅读
4
博客测试文章
33 阅读
5
VMware Workstation Pro
20 阅读
软件整理
C/C++学习笔记
Linux学习笔记
博客搭建
杂项
Search
标签搜索
Nginx
测试
LNMP
Typecho
红帽系统
Alpine Linux
GRUB
windows
PowerShell
MySQL
SQLite
PHP
Rocky Linux
HTTPS
SSL
Let's Encrypt
GDB
博客
Apache
SQLite3
hansyee
累计撰写
105
篇文章
累计收到
2
条评论
首页
栏目
软件整理
C/C++学习笔记
Linux学习笔记
博客搭建
杂项
页面
关于
友链
留言
统计
搜索到
105
篇与
的结果
2026-03-28
windows10安装WSL
作为一个C/C++开发人员,与linux打交道是必不可少的,那么使用linux的方式有很多,例如实体机安装linux发行版、虚拟机软件如VMware安装linux发行版、购买云服务器等。这些方式要么成本大,要么使用步骤繁琐。现在,最好的方式莫过于使用wsl(Windows Subsystem for Linux)了,安装和使用都极其简单,只用一条命令即可安装和启动一个linux虚拟机。详细资料可参考微软官方Windows Subsystem for Linux 文档。安装启用适用于Linux的Windows子系统使用管理员的PowerShell运行:dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart检查运行WSL2的要求若要更新到WSL2,必须运行Windows 10对于x64系统:版本1903或更高版本,内部版本为18362.1049或更高版本。对于ARM64系统:版本2004或更高版本,内部版本为19041或更高版本。或 Windows 11。启用虚拟机功能使用管理员的PowerShell运行:dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart重启电脑下载Linux内核更新包源码地址:https://github.com/microsoft/WSL2-Linux-KernelWSL2 Linux 内核更新包适用于 x64 计算机WSL2 Linux 内核更新包适用于 ARM64 计算机将WSL2设置为默认版本打开PowerShell并运行以下命令,在安装新的Linux分发版时将WSL2设置为默认版本:wsl --set-default-version 2安装所选 Linux 分发版Ubuntu 24.04 LTS(x64,arm64)https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2404-240425.AppxBundleUbuntu 22.04 LTS(x64,arm64)https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2204-221101.AppxBundleUbuntu 20.04 LTS(x64,arm64)https://wslstorestorage.blob.core.windows.net/wslblob/CanonicalGroupLimited.UbuntuonWindows_2004.2021.825.0.AppxBundleUbuntu 18.04 LTS(x64)https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu_1804.2019.522.0_x64.appxUbuntu 18.04 LTS ARM (arm64)https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu_1804.2018.726.0_ARM.appxUbuntu 16.04 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu_1604.2019.523.0_x64.appxDebian GNU/Linux (x64, arm64)https://publicwsldistros.blob.core.windows.net/wsldistrostorage/TheDebianProject.DebianGNULinux_1.12.2.0_neutral___76v4gfsz19hv4.AppxBundleKali Linux 滚动https://wslstorestorage.blob.core.windows.net/wslblob/KaliLinux.54290C8133FEE_1.1.4.0_neutral_~_ey8k8hqnwqnmg.AppxBundleOracle Linux 9.1 (x64)https://publicwsldistros.blob.core.windows.net/wsldistrostorage/OracleLinux_9.1-230428.AppxOracle Linux 8.7 (x64)https://publicwsldistros.blob.core.windows.net/wsldistrostorage/OracleLinux_8.7-230428.AppxOracle Linux 8.5 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/OracleLinux8.5_8.5.1.0.AppxOracle Linux 7.9 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/OracleLinux7.9_7.9.1.0.AppxopenSUSE Tumbleweed (x64)https://wslstorestorage.blob.core.windows.net/wslblob/openSUSE-Tumbleweed-20220224.appxopenSUSE Leap 15.6 (x64)https://publicwsldistros.blob.core.windows.net/wsldistrostorage/SUSELeap15p6-240801_x64.AppxopenSUSE Leap 15.3 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/openSUSE-Leap-15.3-WSL-20220224.appxopenSUSE Leap 15.2 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/openSUSELeap15-2.appxSUSE Linux Enterprise Server 15 SP6 (x64)https://publicwsldistros.blob.core.windows.net/wsldistrostorage/SUSELinuxEnterprise15SP6-241001_x64.AppxSUSE Linux Enterprise Server 15 SP5 (x64)https://publicwsldistros.blob.core.windows.net/wsldistrostorage/SUSELinuxEnterprise15_SP5-240801.AppxSUSE Linux Enterprise Server 15 SP3 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/SUSE-Linux-Enterprise-Server-15.3-WSL-20220224.appxSUSE Linux Enterprise Server 15 SP2 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/SUSELinuxEnterpriseServer15SP2.appxSUSE Linux Enterprise Server 12 (x64)https://wslstorestorage.blob.core.windows.net/wslblob/SLES-12_v1.appx用于 WSL 的 Fedora Remix (x64, arm64)https://github.com/WhitewaterFoundry/Fedora-Remix-for-WSL/releases使用Add-AppxPackage安装Appx包下载分发版后,导航到包含下载的文件夹,并在该目录中运行以下命令,其中app-name是Linux分发.appx文件的名称。Add-AppxPackage .\app_name.Appx设置Linux用户名和密码使用WSL安装Linux发行版的过程完成后,使用“开始”菜单打开该发行版(默认情况下为 Ubuntu)。 系统将要求你为Linux发行版创建“用户名”和“密码”。此用户名和密码特定于安装的每个单独的Linux分发版,与Windows用户名无关。请注意,输入密码时,屏幕上不会显示任何内容。这称为盲人键入。你不会看到你正在键入的内容,这是完全正常的。创建用户名和密码后,该帐户将是分发版的默认用户,并将在启动时自动登录。此帐户将被视为Linux管理员,能够运行sudo管理命令。在WSL上运行的每个Linux发行版都有其自己的Linux用户帐户和密码。每当添加分发版、重新安装或重置时,都必须配置一个Linux用户帐户。WSL的基本命令安装wsl --install列出可用的分发版wsl --list --online列出已安装的分发版wsl --list --verbose从PowerShell或CMD运行特定的Linux分发版wsl --distribution <Distribution Name> --user <User Name>立即终止所有正在运行的分发版和 WSL 2 轻型实用工具虚拟机wsl --shutdown终止指定的分发或阻止其运行wsl --terminate <Distribution Name>注销和卸载WSL分发版wsl --unregister <DistributionName>
2026年03月28日
2 阅读
0 评论
0 点赞
2026-03-28
网站迁移问题记录
前端时间因为一些原因将阿里云服务器上的系统从Rocky Linux 8.10变更到Ubuntu 24.04 LTS了,在变更之前呢,将上面之前自建的Typecho博客,也就是本站点迁移到了很久之前买的一个共享云虚拟主机上。 迁移过程还算比较顺利,因为网站使用的SQLite3数据库,图资源用的七牛云存储,基本只要将网站目录的整个文件夹上传到云虚拟主机即可,再修改一些参数就能正常访问了,这里记录下遇到的一些问题。Typecho博客的SQLite数据库路径配置问题 得益于SQLite3单文件数据库的特性,迁移数据比较方便,直接整个文件复制即可。但是需要注意的是,在不同环境下,数据库的位置参数要同步更新,否则无法正常访问。在安装好的Typecho博客的根目录下的config.inc.php文件内,就有如下类似配置:// config db $db = new \Typecho\Db('SQLite', 'typecho_'); $db->addServer(array ( 'file' => '/var/www/html/all_17zturn_com/usr/123456.db', ), \Typecho\Db::READ | \Typecho\Db::WRITE); \Typecho\Db::set($db);其中的file就指定了SQLite数据库文件的位置,如果要迁移到不同的环境,就必须要更改这个参数。拿我的共享云虚拟主机举例,它需要修改为:'file' => '/usr/home/username/htdocs/usr/123456.db',这里的username是云虚拟主机实际的用户名,这样修改后才能正常读取数据库。SQLite数据库版本问题 遇到的第二个问题就是云服务器和云虚拟主机对SQLite3数据库的版本支持不同。因为云虚拟主机是我很早之前买的一款共享虚拟主机(因为及其便宜就一直在续费以作备用),支持的软件版本相对较旧,并且其软件配置相对固定,个人无法做很大调整,而云服务器就灵活很多,可自主选择软件版本,本站点就是基于当时的最新软件搭建而成。所以迁移之后,打开网站的第一个问题就是数据库无法正常访问。 对于这个问题,我采用了最笨但有效的方法:直接重新安装一次博客,数据库依然选择SQLite,这样就会自动生成一个新的匹配当前环境的数据库文件,然后将原数据库的数据导入到这个新的数据库即可。 伪静态问题 迁移后发现地址重写功能没有了,因为自建的环境是基于Nginx的,自己写了地址重定义规则。而云虚拟主机使用的Apache服务器,这里主要参考使用URL Rewrite配置云虚拟主机的伪静态功能来写地址重定义规则。主要是在网站根目录下新建.htaccess文件,添加如下内容即可:<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] </IfModule>
2026年03月28日
0 阅读
0 评论
0 点赞
2026-02-27
Visual Studio
Visual Studio 2017 下载地址2017社区版:https://aka.ms/vs/15/release/vs_community.exe2017专业版:https://aka.ms/vs/15/release/vs_professional.exe2017企业版:https://aka.ms/vs/15/release/vs_enterprise.exe企业版离线下载(包含所有功能和所有语言)vs_enterprise.exe --layout c:\vs_2017_enterprise_offline企业版序列号NJVYC-BMHX2-G77MM-4XJMR-6Q8QF专业版序列号KBJFW-NXHK6-W4WJM-CRMQB-G3CDH
2026年02月27日
1 阅读
0 评论
0 点赞
2025-07-09
C/C++标准文档
C标准转自:https://www.open-std.org/jtc1/sc22/wg14/https://www.open-std.org/jtc1/sc22/wg14/www/projects#9899修订发布草案C2yNot availableN3550 [2025-05-04]C23ISO/IEC 9899:2024N3220 [2024-02-22] [early C2y draft)C17ISO/IEC 9899:2018N2310 [2018-11-11] [early C23 draft)C11ISO/IEC 9899:2011N1570 [2011-04-04]C99ISO/IEC 9899:1999N1256 [2007-09-07]C95ISO/IEC 9899:1990/Amd 1:1995Not availableC90ISO/IEC 9899:1990Not availableC89ANSI X3.159-1989NIST publicationC++标准转自:https://www.open-std.org/jtc1/sc22/wg21/https://www.open-std.org/jtc1/sc22/wg21/docs/standards#14882修订发布草案C++23ISO/IEC 14882:2023N4950C++20ISO/IEC 14882:2020N4849C++17ISO/IEC 14882:2017N4659C++14ISO/IEC 14882:2014N3797C++11ISO/IEC 14882:2011N3242
2025年07月09日
8 阅读
0 评论
0 点赞
2025-07-09
linux文档汇总
Linux man-pages project官网https://www.kernel.org/doc/man-pages/Githttps://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/镜像网站https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/在线手册https://man7.org/linux/man-pages/index.html
2025年07月09日
3 阅读
0 评论
1 点赞
2024-12-22
格式工厂[FormatFactory]
官网地址中文网页: http://www.pcgeshi.com/index.html下载地址版本平台架构链接备注最新版windowsx86FormatFactory_setup.exe 5.12.0.0windowsx86FormatFactory_5.12.0.0_setup.exe 5.11.0.0windowsx86FormatFactory_5.11.0.0_setup.exe 3.8.0.0windowsx86FormatFactory_3.8.0.0_setup.exe 2024-12-22 12:55:49 星期日
2024年12月22日
3 阅读
0 评论
0 点赞
2024-12-22
ImgBurn
官网地址英文网页: https://www.imgburn.com/下载地址版本平台架构链接备注2.5.8windowsx86SetupImgBurn_2.5.8.0.exeSHA1: 6A3D20796E1FCD4169D5D339AF6E491DCEA3367C2.5.8windowsx86汉化文件汉化文件2024-12-22 12:43:07 星期日
2024年12月22日
7 阅读
0 评论
0 点赞
2024-12-21
MP3TAG
官网地址英文网页: https://www.mp3tag.de/en/index.html下载地址版本平台架构链接备注3.28windowsx86mp3tagv328setup.exe 3.28windowsx64mp3tagv328-x64-setup.exe 3.05windowsx86mp3tagv305setup.exewindows xp/vista2.39windowsx86mp3tagv239setup.exewindows 20002.32awindowsx86mp3tagv232asetup.exewindows 95/98/ME/NT42024-12-21 14:36:34 星期六
2024年12月21日
4 阅读
0 评论
0 点赞
2024-11-09
gdb的简单使用
常用命令如果希望程序可以调试,在编译时需要加入-g选项,该选项告诉编译器生成调试信息,包括行号、变量名、变量值等;并且不能同时使用-O的优化选项,这可能会改变代码的原始结构和执行流程,进而影响调试。 进入调试的方式: gdb target-program或gdb -q target-program。-q表示不打印gdb版本信息,界面较为干净。命令简写说明set args 设置程序运行的参数 如需要运行:./demo aa bb cc 则设置方式:set args aa bb ccbreakb设置断点 b 20 表示在第20行设置断点,可以设置多个断点info breakpoints 显示断点delete breakpointsd删除断点 d 20 表示删除序号为20的断点,不加序号则删除所有断点runr开始/重新运行程序, 程序运行到断点的位置会停下来,如果没有遇到断点,程序一直运行下去nextn执行当前行语句,如果该语句为函数调用,不会进入函数内部steps执行当前行语句,如果该语句为函数调用,则进入函数内部。如果是库函数或者第三方库函数,则进不到函数内部,因为没有源代码,只要有源码的地方都能进去printp显示变量或表达式的值,如果是指针变量则显示指针指向的变量的地址。 如果p后面是表达式,会执行这个表达式。还可以作为变量的赋值语句来用continuec继续运行程序,遇到下一个断点停止,如果没有遇到断点,程序将一直运行set var 设置变量的值 存在变量 int i; char name[21]; 设置值 set var i = 10086 set var name = "JacksonWang"quitq退出gdbstart 单步执行,运行程序,并停留在第一个执行语句finish 在进入到函数内部的情况下,结束当前函数,回到函数调用点backtracebt查函数调用堆栈until 当你厌倦了在一个循环体内单步跟踪时,这个命令可以运行程序直到退出循环体。 until 行号:运行至某行,不仅仅用来跳出循环b 23 if a>b 条件断点设置, if后面跟着条件示例源码#include <iostream> #include <string> using namespace std; void func(int i, string &s) { cout << "i = " << i << " s = " << s << endl; } int main(int argc, char *argv[]) { if (argc != 3) { cout << "执行方式:test 编号 姓名" << endl; cout << "如:test 100 张三" << endl; return -1; } int i = stoi(argv[1]); string s = argv[2]; func(i, s); func(i, s); for (auto i = 0; i < 10; ++i) { string s = "第" + to_string(i)+ "个编号"; cout << s << endl; } return 0; }调试过程[devuser@Rocky8-online gdb调试]$ gdb test GNU gdb (GDB) Rocky Linux 8.2-20.el8.0.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: --Type <RET> for more, q to quit, c to continue without paging-- <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from test...done. (gdb) set args 100 张三 (gdb) b 23 Breakpoint 1 at 0x4018aa: file main.cpp, line 23. (gdb) b 25 Breakpoint 2 at 0x4018be: file main.cpp, line 25. (gdb) b 27 Breakpoint 3 at 0x4018d2: file main.cpp, line 27. (gdb) info breakpointsbreakpoint keep y 0x00000000004018aa in main(int, char**) at main.cpp:23breakpoint keep y 0x00000000004018be in main(int, char**) at main.cpp:25breakpoint keep y 0x00000000004018d2 in main(int, char**) at main.cpp:27(gdb) d 27No breakpoint number 27.(gdb) d 3(gdb) info breakpointsNum Type Disp Enb Address Whatbreakpoint keep y 0x00000000004018aa in main(int, char**) at main.cpp:23breakpoint keep y 0x00000000004018be in main(int, char**) at main.cpp:25(gdb) rStarting program: /home/devuser/workspace/c_c++/test/gdb调试/test 100 张三Breakpoint 1, main (argc=3, argv=0x7fffffffded8) at main.cpp:23func(i, s);Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-251.el8_10.2.x86_64 libgcc-8.5.0-22.el8_10.x86_64 libstdc++-8.5.0-22.el8_10.x86_64(gdb) ni = 100 s = 张三Breakpoint 2, main (argc=3, argv=0x7fffffffded8) at main.cpp:25func(i, s);(gdb) p i$1 = 100(gdb) p s$2 = "张三"(gdb) set var i = 200(gdb) sfunc (i=200, s="张三") at main.cpp:8cout << "i = " << i << " s = " << s << endl;(gdb) ni = 200 s = 张三}(gdb) nmain (argc=3, argv=0x7fffffffded8) at main.cpp:27for (auto i = 0; i < 10; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) n第0个编号string s = "第" + to_string(i)+ "个编号";(gdb) nfor (auto i = 0; i < 10; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) n第1个编号string s = "第" + to_string(i)+ "个编号";(gdb) nfor (auto i = 0; i < 10; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) n第2个编号string s = "第" + to_string(i)+ "个编号";(gdb) nfor (auto i = 0; i < 10; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) n第3个编号string s = "第" + to_string(i)+ "个编号";(gdb) untilfor (auto i = 0; i < 10; ++i)(gdb) 第4个编号第5个编号第6个编号第7个编号第8个编号第9个编号return 0;(gdb) qA debugging session is active. Inferior 1 [process 1959176] will be killed. Quit anyway? (y or n) y[devuser@Rocky8-online gdb调试]$调试core文件如果程序在运行时发生了内存错误,会被内核强行终止,提示“段错误”,内存的状态可保存在core文件中,方便进一步分析查找问题。 注:默认情况下,不会生成core文件,需要修改系统参数。 调试方式如下:首先使用ulimit -a查看系统限制参数[devuser@Rocky8-online gdb调试]$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 6955 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 262144 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 6955 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited使用ulimit -c unlimited把core file size改为unlimited运行程序,产生core文件运行gdb target-program core-file在gdb中,使用bt查看函数调用栈示例源码#include <iostream> #include <string> #include <cstring> using namespace std; void func(int i, string &s) { cout << "i = " << i << " s = " << s << endl; } void corefunc() { char *p = nullptr; *p = 'A'; strcpy(p, "cplusplus"); cout << "p = " << p << endl; } int main(int argc, char *argv[]) { if (argc != 3) { cout << "执行方式:test 编号 姓名" << endl; cout << "如:test 100 张三" << endl; return -1; } int i = stoi(argv[1]); string s = argv[2]; func(i, s); func(i, s); corefunc(); for (auto i = 0; i < 10; ++i) { string s = "第" + to_string(i)+ "个编号"; cout << s << endl; } return 0; }调试过程 使用systemd的系统不会直接产生core文件,可按如下方法使用coredumpctl命令生成[devuser@Rocky8-online gdb调试]$ cat /proc/sys/kernel/core_pattern |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e [devuser@Rocky8-online gdb调试]$ coredumpctl TIME PID UID GID SIG COREFILE EXE Sat 2024-11-09 16:12:16 CST 1959992 1000 1000 11 present /home/devuser/workspace/c_c++/test/gdb调试/test Sat 2024-11-09 16:16:17 CST 1960127 1000 1000 11 present /home/devuser/workspace/c_c++/test/gdb调试/test Sat 2024-11-09 16:22:23 CST 1960569 1000 1000 11 present /home/devuser/workspace/c_c++/test/gdb调试/test [devuser@Rocky8-online gdb调试]$ coredumpctl -o core dump 1960569 PID: 1960569 (test) UID: 1000 (devuser) GID: 1000 (devuser) Signal: 11 (SEGV) Timestamp: Sat 2024-11-09 16:22:23 CST (7min ago) Command Line: ./test 100 Executable: /home/devuser/workspace/c_c++/test/gdb调试/test Control Group: /user.slice/user-1000.slice/session-727.scope Unit: session-727.scope Slice: user-1000.slice Session: 727 Owner UID: 1000 (devuser) Boot ID: 3715d4f161824bbf9481b064cc42f893 Machine ID: 74da068e81f448da853c64463d64e826 Hostname: Rocky8-online Storage: /var/lib/systemd/coredump/core.test.1000.3715d4f161824bbf9481b064cc42f893.1960569.1731140543000000.lz4 Message: Process 1960569 (test) of user 1000 dumped core. Stack trace of thread 1960569: #0 0x00000000004017b7 n/a (/home/devuser/workspace/c_c++/test/gdb调试/test) #1 0x0000000000401936 n/a (/home/devuser/workspace/c_c++/test/gdb调试/test) #2 0x00007f182025d7e5 __libc_start_main (libc.so.6) #3 0x000000000040168e n/a (/home/devuser/workspace/c_c++/test/gdb调试/test) [devuser@Rocky8-online gdb调试]$ ls -l total 704 -rw-rw-r--. 1 devuser devuser 499712 Nov 9 16:29 core drwxrwxr-x. 2 devuser devuser 6 Nov 9 15:12 include drwxrwxr-x. 2 devuser devuser 6 Nov 9 15:12 lib -rw-rw-r--. 1 devuser devuser 724 Nov 9 16:11 main.cpp -rw-rw-r--. 1 devuser devuser 117328 Nov 9 16:12 main.o -rw-rw-r--. 1 devuser devuser 1428 Nov 9 15:43 Makefile -rwxrwxr-x. 1 devuser devuser 92672 Nov 9 16:12 test[devuser@Rocky8-online gdb调试]$ gdb test core GNU gdb (GDB) Rocky Linux 8.2-20.el8.0.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: --Type <RET> for more, q to quit, c to continue without paging-- <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from test...done. [New LWP 1960569] Core was generated by `./test 100 张三'. Program terminated with signal SIGSEGV, Segmentation fault.*p = 'A';Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-251.el8_10.2.x86_64 libgcc-8.5.0-22.el8_10.x86_64 libstdc++-8.5.0-22.el8_10.x86_64(gdb) bt0 0x00000000004017b7 in corefunc () at main.cpp:151 0x0000000000401936 in main (argc=3, argv=0x7fff0d021a78) at main.cpp:36(gdb)调试正在运行中的程序gdb target-program -p pid示例源码#include <iostream> #include <chrono> #include <thread> using namespace std; int main(int argc, char *argv[]) { for (auto i = 0; i < 1000000; ++i) { string s = "第" + to_string(i)+ "个编号"; cout << s << endl; std::this_thread::sleep_for(std::chrono::seconds(5)); } return 0; }调试过程[devuser@Rocky8-online gdb调试]$ ps -ef | grep test devuser 1954586 1952692 0 13:35 pts/0 00:00:00 gdb test devuser 1962014 1954938 0 19:00 pts/1 00:00:00 ./test devuser 1962280 1962066 0 19:01 pts/2 00:00:00 grep --color=auto test [devuser@Rocky8-online gdb调试]$ gdb test -p 1962014 GNU gdb (GDB) Rocky Linux 8.2-20.el8.0.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: --Type <RET> for more, q to quit, c to continue without paging-- <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from test...done. Attaching to program: /home/devuser/workspace/c_c++/test/gdb调试/test, process 1962014 Reading symbols from /lib64/libstdc++.so.6...Reading symbols from .gnu_debugdata for /lib64/libstdc++.so.6...(no debugging symbols found)...done. (no debugging symbols found)...done. Reading symbols from /lib64/libm.so.6...Reading symbols from .gnu_debugdata for /lib64/libm.so.6...(no debugging symbols found)...done. (no debugging symbols found)...done. Reading symbols from /lib64/libgcc_s.so.1...Reading symbols from .gnu_debugdata for /lib64/libgcc_s.so.1...(no debugging symbols found)...done. (no debugging symbols found)...done. Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done. Reading symbols from /lib64/ld-linux-x86-64.so.2...done. 0x00007fdb54a00068 in nanosleep () from /lib64/libc.so.6 Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-251.el8_10.2.x86_64 libgcc-8.5.0-22.el8_10.x86_64 libstdc++-8.5.0-22.el8_10.x86_64 (gdb) n Single stepping until exit from function nanosleep, which has no line number information.while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR)(gdb) n}(gdb) nmain (argc=1, argv=0x7ffef61ed998) at main.cpp:11string s = "第" + to_string(i)+ "个编号";(gdb) nfor (auto i = 0; i < 1000000; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) nstd::this_thread::sleep_for(std::chrono::seconds(5));(gdb) nnnstring s = "第" + to_string(i)+ "个编号";(gdb) nfor (auto i = 0; i < 1000000; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) nstd::this_thread::sleep_for(std::chrono::seconds(5));(gdb) nnnnnstring s = "第" + to_string(i)+ "个编号";(gdb) nfor (auto i = 0; i < 1000000; ++i)(gdb) nstring s = "第" + to_string(i)+ "个编号";(gdb) ncout << s << endl;(gdb) nstd::this_thread::sleep_for(std::chrono::seconds(5));(gdb) cContinuing.
2024年11月09日
17 阅读
0 评论
0 点赞
2024-10-24
C++运算符优先级表
结合律运算符功能用法举例左::全局作用域::name 左::类作用域class::name 左::命名空间作用域namespace::name ———————————————————————————————————————左.成员选择object.member 左->成员选择pointer->member 左[]下标expr[expr] 左()函数调用name(expr_list) 左()类型构造type(expr_list) ———————————————————————————————————————右++后置递增运算lvalue++ 右--后置递减运算lvalue-- 右typeid类型IDtypeid(type) 右typeid运行时类型IDtypeid(expr) 右static_cast const_cast dynamic_cast reinterpret_cast类型转换cast_name\<type\>(expr) ———————————————————————————————————————右++前置递增运算++lvalue 右--前置递减运算--lvalue 右~按位求反~expr 右!逻辑非!expr 右-一元负号-expr 右+一元正号+expr 右*解引用*expr 右&取地址&lvalue 右()类型转换(type)expr 右sizeof对象的大小sizeof expr 右sizeof类型的大小sizeof(type) 右Sizeof...参数包的大小sizeof...(name) 右new创建对象new type 右new[]创建数组new type[size] 右delete释放对象delete expr 右delete[]释放数组delete[] expr 右noexcept能否抛出异常noexcept(expr) ———————————————————————————————————————左->*指向成员选择的指针ptr->*ptr_to_member 左.*指向成员选择的指针obj.*ptr_to_member ———————————————————————————————————————左*乘法expr * expr 左/除法expr / expr 左%取模(取余)expr % expr ———————————————————————————————————————左+加法expr + expr 左-减法expr - expr ———————————————————————————————————————左<<向左移位expr << expr 左>>向右移位expr >> expr ———————————————————————————————————————左<小于expr < expr 左<=小于等于expr <= expr 左>大于expr > expr 左>=大于等于expr >= expr ———————————————————————————————————————左==相等expr == expr 左!=不相等expr != expr ———————————————————————————————————————左&按位与expr & expr ———————————————————————————————————————左^位异或expr ^ expr ———————————————————————————————————————左\ 按位或expr \expr ———————————————————————————————————————左&&逻辑与expr && expr ———————————————————————————————————————左\\ 逻辑或expr \\expr ———————————————————————————————————————右? :条件表达式expr ? expr : expr ———————————————————————————————————————右=赋值lvalue = expr ———————————————————————————————————————右*=, /=, %= +=, -= <<=, >>= &=, \=, ^=复合赋值lvalue += expr等 右throw抛出异常throw expr ———————————————————————————————————————左,逗号表达式expr,expr
2024年10月24日
8 阅读
0 评论
0 点赞
1
2
...
11