gdb core 调试过程说明 – 搞机Pro网 .home .main .sec-panel-head .j-newslist, .search-results .pagination, .home .load-more-wrap { display: none; } .single .entry-content img { display: block; margin-left: auto; margin-right: auto; } .single-post .entry-content iframe { width: 100%; height: 500px; } @media (max-width: 767px){ .single-post .entry-content iframe { width: 100%; height: 300px; } } LA.init({id: \”JhQPBU91LuYhvCSn\”,ck: \”JhQPBU91LuYhvCSn\”,autoTrack:true}) function isMobile() { var userAgent = navigator.userAgent.toLowerCase(); return /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(userAgent); } .q-content .topic-tab,.q-content .q-answer .as-user,.q-content .q-answer .as-comment-name,.profile-QAPress-tab .QAPress-tab-item{color: #1471CA;} .q-content .q-topic-wrap a:hover,.q-content .q-answer .as-action a:hover,.q-content .topic-tab:hover,.q-content .topic-title:hover{color:#0D62B3;} .q-content .put-top,.q-content .topic-tab.current-tab,.q-content .q-answer .as-submit .btn-submit,.q-content .q-answer .as-comments-submit,.q-content .q-add-header .btn-post,.q-content .q-pagination .current,.q-btn-new,.profile-QAPress-tab .QAPress-tab-item.active,.q-mobile-ask a{background-color:#1471CA;} .q-content .q-answer .as-submit .btn-submit:hover,.q-content .q-answer .as-comments-submit:hover,.q-content .q-add-header .btn-post:hover,.q-content .topic-tab.current-tab:hover,.q-content .q-pagination a:hover,.q-btn-new:hover,.profile-QAPress-tab .QAPress-tab-item:hover,.q-mobile-ask a:hover{background-color:#0D62B3;} .q-content .q-answer .as-comments-input:focus,.profile-QAPress-tab .QAPress-tab-item{border-color: #1471CA;} .profile-QAPress-tab .QAPress-tab-item:hover{border-color: #0D62B3;} var _hmt = _hmt || []; _hmt.push([\’_trackPageview\’]); (function() { var hm = document.createElement(\”script\”); hm.src = \”//hm.baidu.com/hm.js?fe211990b79c55d240b27f5ba7fcb1e5\”; hm.setAttribute(\’async\’, \’true\’); document.getElementsByTagName(\’head\’)[0].appendChild(hm); })(); a, .text-primary, .btn.active, .btn:active, .btn:focus, .btn:hover, .btn.btn-primary .badge, .panel-primary>.panel-heading .badge, .member-form-tab li.active a, .member-account-menu .member-nav-icon, .member-lp-process li.active p, .wpcom-profile .user-group, .wpcom-profile .wpcom-profile-nav li.active a, .wpcom-profile .profile-tab-item.active, .user-card-name .user-group, .plyr–full-ui input[type=range], body>header.header .nav>li.active>a, body>header.header .dropdown-menu>.active>a, .entry .entry-info .nickname, .entry .entry-content .has-theme-color-color, .entry-bar-inner .user-group, .entry-action .btn-dashang, .entry-action .btn-zan, .entry-readmore-btn, .form-submit-text span, .widget_profile .user-group, .list.tabs .tab.active a, .load-more, .kx-list .kx-time{color: #102750;}.bg-primary, .btn.btn-primary, .btn.btn-primary.disabled.focus, .btn.btn-primary.disabled:focus, .btn.btn-primary.disabled:hover, .btn.btn-primary[disabled].focus, .btn.btn-primary[disabled]:focus, .btn.btn-primary[disabled]:hover, fieldset[disabled] .btn.btn-primary.focus, fieldset[disabled] .btn.btn-primary:focus, fieldset[disabled] .btn.btn-primary:hover, .nav-pills>li.active>a, .nav-pills>li.active>a:focus, .nav-pills>li.active>a:hover, .label-primary, .panel-primary>.panel-heading, .action.action-color-1 .action-item, .entry .entry-content .has-theme-color-background-color, .comment-reply-title:before, .comments-title:before, .entry-related-title:before, .widget-title:before, .search-form .submit, .sec-panel-head h1 span:before, .sec-panel-head h2 span:before, .sec-panel-head h3 span:before, .wpcom-slider .swiper-pagination .swiper-pagination-bullet-active, .tagHandler ul.tagHandlerContainer li.tagItem{background-color: #102750;}.form-control:focus, .btn.active, .btn:active, .btn.btn-primary, .btn.btn-primary.active, .btn.btn-primary:active, .btn.btn-primary.disabled.focus, .btn.btn-primary.disabled:focus, .btn.btn-primary.disabled:hover, .btn.btn-primary[disabled].focus, .btn.btn-primary[disabled]:focus, .btn.btn-primary[disabled]:hover, fieldset[disabled] .btn.btn-primary.focus, fieldset[disabled] .btn.btn-primary:focus, fieldset[disabled] .btn.btn-primary:hover, .nav .open>a, .nav .open>a:focus, .nav .open>a:hover, .panel-primary, .panel-primary>.panel-heading, .wpcom-profile .profile-tab-item.active, .search-form input.keyword:focus, .load-more{border-color: #102750;}.btn.active:before, .btn:active:before, .btn:focus:before, .btn:hover:before, .TCaptcha-button .TCaptcha-icon:after, .wpcom-profile .user-group, .user-card-name .user-group, .smartphoto-loader, .entry-bar-inner .user-group, .entry-action .btn-dashang, .entry-action .btn-zan, .entry-readmore-btn, .widget-kx-list .kx-item:before, .widget_profile .user-group, .kx-list .kx-time:before{border-color: #102750;}.btn.active:after, .btn:active:after, .btn:focus:after, .btn:hover:after, .page-numbers>li.active, .pagination>li.active, .swiper-pagination-bullet-active, .swiper-pagination-progress .swiper-pagination-progressbar, .hot-slider .swiper-button-next, .hot-slider .swiper-button-prev, .action .action-item-inner h2, .action .action-item-inner h3, .action .action-item-inner h4, .TCaptcha-button .TCaptcha-icon i, .TCaptcha-button .TCaptcha-icon:before, .member-account-menu .active:before, .member-lp-process li.active i, .member-lp-process li.processed .process-line, .wpcom-profile .user-group:after, .wpcom-profile .profile-tab-item.active:after, .user-card-name .user-group:after, .modules-video .modal-player, .social-login-form .sl-input-submit, .plyr–audio .plyr__control.plyr__tab-focus, .plyr–audio .plyr__control:hover, .plyr–audio .plyr__control[aria-expanded=true], .plyr–video .plyr__control.plyr__tab-focus, .plyr–video .plyr__control:hover, .plyr–video .plyr__control[aria-expanded=true], .plyr__control–overlaid, .plyr__control–overlaid:focus, .plyr__control–overlaid:hover, .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before, .entry-bar-inner .user-group:after, .post-loop-default .item-title a .sticky-post, .post-loop-card .item-title .sticky-post, .post-loop-image .item-title .sticky-post, .sidebar .widget_nav_menu ul li.current-menu-item a, .sidebar .widget_nav_menu ul li.current-post-parent a, .widget_profile .user-group:after, .list.tabs .tab.active a:after, .kx-list .kx-date:before{background-color: #102750;}.panel-primary>.panel-heading+.panel-collapse>.panel-body{border-top-color: #102750;}.panel-primary>.panel-footer+.panel-collapse>.panel-body, .member-form-tab li.active{border-bottom-color: #102750;}.wpcom-profile .wpcom-profile-nav li.active a{border-bottom-color: #102750;}.entry .entry-content .h3, .entry .entry-content h3, .entry .member-account-content .woocommerce h2{border-left-color: #102750;}a:hover, .breadcrumb>li a:hover, .page-numbers .pagination-go .pgo-btn:hover, .pagination .pagination-go .pgo-btn:hover, .close:focus, .close:hover, .action .action-share-item:hover, .member-form .form-group.active .wi, .member-form .form-group.active .show-password .wi:hover, .member-form .form-group.error .show-password .wi:hover, .member-form .show-password .wi:hover, .member-form-tab a:hover, .member-account-name a:hover, .member-account-menu li:hover, .wpcom-profile .wpcom-profile-nav a:hover, .wpcom-profile .follow-item .follow-item-text .follow-item-name a:hover, .wpcom-profile-main .profile-posts-list .item-title a:hover, .wpcom-profile-main .profile-comments-list .comment-item-link a:hover, .hentry .member-account-wrap .notify-list .notify-item.status-1 .notify-item-title a:hover, .hentry .member-account-wrap .notify-list .notify-item-title a:hover, .user-card-name:hover, body>header.header .nav>li>a:hover, body>header.header .wpcom-adv-menu>.menu-item-style>.menu-item-wrap>li>a:hover, .navbar-action .login:focus, .navbar-action .login:hover, .navbar-action .profile a:hover, .navbar-search-close:hover, .navbar-search-btn:hover, .navbar-search-icon:focus, .navbar-search-icon:hover, .entry .entry-info a:focus, .entry .entry-info a:hover, .entry .entry-content .has-theme-hover-color, .entry .entry-content .wp-block-wpcom-accordion .panel-heading .panel-title a:hover, .entry .entry-content .wp-block-wpcom-accordion .panel-heading .panel-title a:hover .wi, .entry-bar .info-item a:hover, .comments-list .comment-children .comment-text-reply a:hover, .comments-list .reply a:hover, .comment-body .nickname a:hover, #cancel-comment-reply-link:hover, .post-loop-list .item a:hover, .post-loop-default .item-title a:hover, .post-loop-default .item-meta a:hover, .post-loop-card .item-title a:hover, .post-loop-image .item-title a:hover, .post-loop-image .item-meta-author .avatar:hover, .widget ol a:hover, .widget ul a:hover, .widget_kuaixun .widget-title-more:hover, .widget_profile .profile-name:hover, .sec-panel-head .more:hover, .el-boxed .sec-panel-head h1 span a:hover, .el-boxed .sec-panel-head h2 span a:hover, .el-boxed .sec-panel-head h3 span a:hover, .list.tabs .tab a:hover, .list-links a:focus, .list-links a:hover, .kx-list .kx-content h2 a:hover, .kx-meta .j-mobile-share:hover, .modules-category-posts .sec-panel-more a:hover{color: #021d4d;}.page-numbers>li:hover, .pagination>li:hover, .hot-slider .swiper-button-prev:hover, .hot-slider .swiper-container-rtl .swiper-button-next:hover, .hot-slider .swiper-button-next:hover, .hot-slider .swiper-container-rtl .swiper-button-prev:hover, .member-account-menu .active:hover:before, .wpcom-profile .wpcom-profile-setcover:hover, .wpcom-profile .profile-tab-item:hover, .social-login-form .sl-input-submit:hover, body>header.header .dropdown-menu>.active>a:focus, body>header.header .dropdown-menu>.active>a:hover, body>header.header .dropdown-menu>li>a:hover, body>header.header .wpcom-adv-menu>.menu-item-style>.menu-item-wrap .dropdown-menu li a:hover, .entry-tag a:focus, .entry-tag a:hover, .wpcom-shortcode-tags li:hover, .page-no-sidebar.member-login .btn-home:hover, .page-no-sidebar.member-register .btn-home:hover, .post-loop-default .item-category:hover, .post-loop-card .item-img .item-category:hover, .post-loop-image .item-img .item-category:hover, .widget .tagcloud a:hover, .sidebar .widget_nav_menu ul li.current-menu-item .sub-menu a:hover, .sidebar .widget_nav_menu ul li.current-post-parent .sub-menu a:hover, .sidebar .widget_nav_menu ul li a:hover, .footer-sns .sns-icon:after, .list.tabs .tab.active a:hover:after, .load-more:focus, .load-more:hover, .modules-carousel-posts .sec-panel-more .swiper-button-next:hover, .modules-carousel-posts .sec-panel-more .swiper-button-prev:hover{background-color: #021d4d;}.page-numbers .pagination-go .pgo-input:focus, .pagination .pagination-go .pgo-input:focus, .member-form .form-group.active .form-input, .wpcom-profile .wpcom-profile-setcover:hover, .wpcom-profile .profile-tab-item:hover, .entry-tag a:focus, .entry-tag a:hover, .entry-action .btn-dashang.liked, .entry-action .btn-dashang:hover, .entry-action .btn-zan.liked, .entry-action .btn-zan:hover, .entry-readmore-btn:hover, .widget .tagcloud a:hover, .widget-kx-list .kx-item:hover:before, .widget-kx-list .kx-item.active:before, .load-more:focus, .load-more:hover{border-color: #021d4d;}.action .action-item:hover, .entry .entry-content .has-theme-hover-background-color, .entry-action .btn-dashang.liked, .entry-action .btn-dashang:hover, .entry-action .btn-zan.liked, .entry-action .btn-zan:hover, .entry-readmore-btn:hover, .search-form .submit:hover, .wpcom-slider .swiper-pagination span:hover, .tagHandler ul.tagHandlerContainer li.tagItem:hover{background-color: #021d4d;}.member-form-tab li.active:hover{border-bottom-color: #021d4d;}.member-account-input input:focus, .member-account-input select:focus, .member-account-input textarea:focus, .modules-carousel-posts .sec-panel-more .swiper-button-next:hover, .modules-carousel-posts .sec-panel-more .swiper-button-prev:hover{border-color: #021d4d;}.wpcom-profile .wpcom-profile-nav a:hover{border-bottom-color: #021d4d;}@media (max-width:991px){.navbar-collapse{background-color: #102750;}}@media (max-width:767px){.entry-bar .info-item.share .mobile{background-color: #102750;}} body>header.header{background-color: #fff;;} body>header.header .logo img{max-height: 40px;} @media (max-width: 767px){ body>header.header .logo img{max-height: 36px;} } .entry .entry-video{ height: 482px;} @media (max-width: 1219px){ .entry .entry-video{ height: 386.49883449883px;} } @media (max-width: 991px){ .entry .entry-video{ height: 449.41724941725px;} } @media (max-width: 767px){ .entry .entry-video{ height: 344.28571428571px;} } @media (max-width: 500px){ .entry .entry-video{ height: 241px;} } 首页 手机 数码 电脑 科技 软件 市场营销 综合 登录 注册 投稿 搞机Pro网首页科技软件 gdb core 调试过程说明 往日随风 • 2022-05-02 20:43:27 • 软件 1.前言 当我们遇到问题的时候,可以加打印信息追踪流程,但更有效的方式是:调试。如果你使用的是keil,可以借助stlink或者jlink进行调试。如果你是使用的gnu工具链,硬件支持jlink,那么我们可以借助gdb+jlink的方式进行调试;如果我们硬件支持的是stlink,则可以借助gdb+openocd+stlink进行调试。 2.使用GDB调试OneOS GDB,全称GNU Project debugger,是UNIX及UNIX-like下的强大调试工具,同时也支持对嵌入式系统进行调试。对嵌入式系统进行调试时,是以远程调试的方式进行的,调试环境的软硬件连接如下: 在上图的结构中,支持嵌入式芯片调试的GDB Server有多款,这里主要介绍OpenOCD和J-Link GDB Server。 J-Link GDB Server由SEGGER公司推出,仅支持使用Jlink作为调试适配器进行调试 OpenOCD,全称Open On-Chip Debugger,是一款针对嵌入式芯片调试的开源软件,支持市面上大多数的调试适配器,例如stlink、DAPlink、Jlink等。OpenOCD支持GDB查看RTOS线程,OneOS已对其进行了适配。使用OpenOCD作为GDB Server,可以查看OneOS所有线程的调用栈和栈上的临时变量,对于调试,能提供更多的信息 3.gdb结合stlink调试 这里以万耦开发板stm32f401-vet-oneos为例演示调试过程,由于OpenOCD配合Jlink使用时,需要将Jlink的驱动切换成通用usb驱动
1.前言
当我们遇到问题的时候,可以加打印信息追踪流程,但更有效的方式是:调试。如果你使用的是keil,可以借助stlink或者jlink进行调试。如果你是使用的gnu工具链,硬件支持jlink,那么我们可以借助gdb+jlink的方式进行调试;如果我们硬件支持的是stlink,则可以借助gdb+openocd+stlink进行调试。
2.使用GDB调试OneOS
GDB,全称GNU Project debugger,是UNIX及UNIX-like下的强大调试工具,同时也支持对嵌入式系统进行调试。对嵌入式系统进行调试时,是以远程调试的方式进行的,调试环境的软硬件连接如下:
在上图的结构中,支持嵌入式芯片调试的GDB Server有多款,这里主要介绍OpenOCD和J-Link GDB Server。
- J-Link GDB Server由SEGGER公司推出,仅支持使用Jlink作为调试适配器进行调试
- OpenOCD,全称Open On-Chip Debugger,是一款针对嵌入式芯片调试的开源软件,支持市面上大多数的调试适配器,例如stlink、DAPlink、Jlink等。OpenOCD支持GDB查看RTOS线程,OneOS已对其进行了适配。使用OpenOCD作为GDB Server,可以查看OneOS所有线程的调用栈和栈上的临时变量,对于调试,能提供更多的信息
3.gdb结合stlink调试
这里以万耦开发板stm32f401-vet-oneos为例演示调试过程,由于OpenOCD配合Jlink使用时,需要将Jlink的驱动切换成通用usb驱动(OpenOCD不支持Jlink的原生驱动,如果需要,可以使用zadig这款开源软件将Jlink驱动切换成WinUSB或libusb),为了方便起见,在使用OpenOCD调试时,调试适配器选择stlink。
3.1 获取OpenOCD
下载预编译的Windows版本请点击OpenOCD下载。
3.2 目录结构
OpenOCD编译后的二进制文件目录结构如下:
3.2 添加环境变量
OPENOCD_BIN_PATH="D:Programopenocdbin"
OPENOCD_SCRIPT_PATH="D:Programopenocdshareopenocdscripts"
3.3 配置文件oneos.cfg
在stm32f401-vet-oneos工程目录下创建配置文件oneos.cfg,文件内容如下:
# this need match your debug adaptor and target device
source [find interface/stlink-v2.cfg]
source [find target/stm32f4x.cfg]
# config openocd support OneOS
$_TARGETNAME configure -rtos oneos
# halt target after gdb attached
$_TARGETNAME configure -event gdb-attach { halt }
3.4 启动openOCD
在OneOS-Lite代码根目录运行OneOS-Cube,执行如下命令:
%OPENOCD_BIN_PATH%openocd.exe -c "gdb_port 5000" -s %OPENOCD_SCRIPT_PATH% -f .projectsstm32f401-vet-oneosoneos.cfg
运行成功后的界面如下,此时OpenOCD已配置完成:
4 启动gdb调试
在OneOS-Lite代码根目录下运行OneOS-Cube,执行如下命令运行GDB
arm-none-eabi-gdb.exe .outstm32f401-vet-oneosoneos.elf
在GDB命令行交互界面中执行如下命令连接GDB Server,其中:5000是GDB Server的tcp端口号,对应上面OpenOCD运行时指定的gdb_port(如果使用J-Link GDB Server,则端口选择上面显示的2331)
target remote localhost:5000
连接成功后,GDB命令行交互界面如下
5.开始调试OneOS-Lite
- 查看当前线程调用栈和临时变量
- 查看所有正在运行的线程(J-Link GDB Server不支持此命令)
- 切换到其他线程并查看调用栈与临时变量(J-Link GDB Server不支持此命令)
- 打断点
b entry
- 重新加载
load
更多的GDB用法,请查看官方文档。