= argc) { printf ( "Helloworld.n" ); } printf ( "Hello World %s!n" ,argv[ 1 ]); for (i = 1 ; i 100 ; i++) { result += i; } printf ( "result = %dn" , result ); return 0 ;} 編譯時加上 -g 參數(shù): gcc helloworld.c -o hellowrld -g 啟動調(diào)試 $ gdb helloWorldGNU gdb (GDB) Red Hat Enterprise Linux 8.2-12.el8 Copyright (C) 2018 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later //gnu.org/licenses/gpl.html > This is free software: you are free to change and redistribute it.There is" />

日B视频 亚洲,啪啪啪网站一区二区,91色情精品久久,日日噜狠狠色综合久,超碰人妻少妇97在线,999青青视频,亚洲一区二卡,让本一区二区视频,日韩网站推荐

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Linux系統(tǒng)中如何進行GDB調(diào)試

麥辣雞腿堡 ? 來源:嵌入式Linux充電站 ? 作者:Vincent ? 2023-10-04 15:52 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

編寫代碼

#include < stdio.h >

int main(int argc, char **argv)
{
    int i;
    int result = 0;

    if(1 >= argc)
    {
        printf("Helloworld.n");
    }
    printf("Hello World %s!n",argv[1]);

    for(i = 1; i <= 100; i++)  {
        result += i;
    }

    printf("result = %dn", result );

    return 0;
}

編譯時加上 -g 參數(shù):

gcc helloworld.c -o hellowrld -g

啟動調(diào)試

$ gdb helloWorld
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-12.el8
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:
    < http://www.gnu.org/software/gdb/documentation/ >.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from helloworld...done.
(gdb) run                  < ----------------------------- 不帶參數(shù)運行
Starting program: /home/zhuzhg/helloworld
Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-101.el8.x86_64
helloworld.
result = 5050
[Inferior 1 (process 1069013) exited normally]
(gdb) run China            < ----------------------------- 帶參數(shù)運行
Starting program: /home/zhuzhg/helloworld China
Hello World China!
result = 5050
[Inferior 1 (process 1071086) exited normally]
(gdb)
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • Linux
    +關(guān)注

    關(guān)注

    88

    文章

    11824

    瀏覽量

    219610
  • 調(diào)試
    +關(guān)注

    關(guān)注

    7

    文章

    653

    瀏覽量

    35936
  • 代碼
    +關(guān)注

    關(guān)注

    30

    文章

    4977

    瀏覽量

    74420
  • gdb
    gdb
    +關(guān)注

    關(guān)注

    0

    文章

    61

    瀏覽量

    13963
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點推薦

    使用GDB調(diào)試Linux應(yīng)用程序

    本篇講解使用GDB調(diào)試Linux應(yīng)用程序,以下以 `hellowld.c` 為例介紹 GDB調(diào)試入門。
    發(fā)表于 06-27 15:48 ?901次閱讀

    嵌入式LinuxGDB調(diào)試環(huán)境建立

    嵌入式LinuxGDB調(diào)試環(huán)境由Host和Target兩部分組成,Host端使用arm-linux-gdb,Target Board端使用gdbserver。這樣,應(yīng)
    發(fā)表于 04-02 14:33 ?1349次閱讀

    嵌入式Linux系統(tǒng)GDB遠程調(diào)試的實現(xiàn)

    stub是嵌入式系統(tǒng)的一段代碼,作為宿主機GDB和目標機調(diào)試程序間的一個媒介而存在。 就 目前而言,嵌入式Linux
    發(fā)表于 04-02 14:38 ?727次閱讀

    Linux應(yīng)用的GDB調(diào)試的原理及過程分析

    GDB調(diào)試是應(yīng)用程序在開發(fā)板上運行,然后在PC機上對開發(fā)板上得應(yīng)用程序進行調(diào)試,PC機運行GDB,開發(fā)板上運行GDBServer。在應(yīng)用程序
    發(fā)表于 03-05 09:44 ?3850次閱讀
    <b class='flag-5'>Linux</b>應(yīng)用的<b class='flag-5'>GDB</b><b class='flag-5'>調(diào)試</b>的原理及過程分析

    linux編程GDB調(diào)試功能

    GDB是一套字符界面的程序集,可以用它在linux調(diào)試C和C++程序,它提供了以下的功能:
    的頭像 發(fā)表于 05-05 23:49 ?3026次閱讀
    <b class='flag-5'>linux</b>編程<b class='flag-5'>GDB</b><b class='flag-5'>調(diào)試</b>功能

    嵌入式Linux GDB調(diào)試環(huán)境搭建與使用

    這里寫目錄標題簡介在Ubuntu下簡單體驗GDB嵌入式GDB移植GDB 常用命令參考網(wǎng)絡(luò)通信設(shè)置注意事項簡介Linux系統(tǒng)常用
    發(fā)表于 11-01 17:59 ?8次下載
    嵌入式<b class='flag-5'>Linux</b> <b class='flag-5'>GDB</b><b class='flag-5'>調(diào)試</b>環(huán)境搭建與使用

    Linux嵌入式 gdb VSCode圖形化調(diào)試教程

    文章目錄介紹GDB簡介交叉編譯器的gdb介紹在學(xué)習單片機的時候我們可以通過集成式IDE 來進行調(diào)試,比如MDK、IAR 等。在嵌入式linux
    發(fā)表于 11-02 12:21 ?15次下載
    <b class='flag-5'>Linux</b>嵌入式 <b class='flag-5'>gdb</b> VSCode圖形化<b class='flag-5'>調(diào)試</b>教程

    OpenHarmony系統(tǒng)使用gdb調(diào)試init

    。如果能使用gdb調(diào)試init,會極大的提高定位效率。 本文簡單描述了一下L2二次啟動的系統(tǒng)如何使用gdb調(diào)試init 首先將
    的頭像 發(fā)表于 12-26 12:10 ?1775次閱讀

    嵌入式Linux GDB是什么

    函數(shù)、設(shè)置斷點、查看變量等等,它是 UNIX/LINUX 操作系統(tǒng)下強大的程序調(diào)試工具。 gdb 支持多種語言
    的頭像 發(fā)表于 07-27 16:29 ?1579次閱讀
    嵌入式<b class='flag-5'>Linux</b> <b class='flag-5'>GDB</b>是什么

    在ubuntu調(diào)試GDB

    的 gcc 編譯器即可,注意需要加 -g 選項,才能使用 gdb 調(diào)試 arm-linux-gnueabihf-gcc gdbtest .c -o gdbtest -g //編譯測試程序,注意-g 選項
    的頭像 發(fā)表于 07-27 16:31 ?2037次閱讀
    在ubuntu<b class='flag-5'>中</b><b class='flag-5'>調(diào)試</b><b class='flag-5'>GDB</b>

    在板子調(diào)試GDB的方法

    系統(tǒng),比如 ubuntu、centos 等,我們可以直接運行 gdb調(diào)試程序。但是嵌入式芯片性能一般比較弱,所以直接在嵌入式系統(tǒng)
    的頭像 發(fā)表于 07-27 16:37 ?2477次閱讀
    在板子<b class='flag-5'>中</b><b class='flag-5'>調(diào)試</b><b class='flag-5'>GDB</b>的方法

    GDB調(diào)試何進行變量查看

    argc $3 = 1(gdb) print str $4 = 0x4006c8 "Hello World" 查看內(nèi)存: examine(簡寫為x)可以用來查看內(nèi)存地址的值。語法如下: x / [n] [f] [u] addr 其中: 單元類型常見有如下: 示例: (
    的頭像 發(fā)表于 09-26 16:17 ?3406次閱讀

    GDB調(diào)試工具的原理

    了。 1.2 執(zhí)行中進程調(diào)試 如果想對一個已經(jīng)執(zhí)行的進程進行調(diào)試,那么就要在gdb這個父進程調(diào)用ptrace(PTRACE_ATTA
    的頭像 發(fā)表于 11-09 17:04 ?2107次閱讀
    <b class='flag-5'>GDB</b><b class='flag-5'>調(diào)試</b>工具的原理

    linuxgdb調(diào)試遇到函數(shù)調(diào)用怎么辦?

    。 要順利進行函數(shù)調(diào)用的調(diào)試,首先需要準備好代碼和符號表。在編譯代碼時,需要加上 `-g` 參數(shù)來生成調(diào)試信息。這樣編譯器會在可執(zhí)行文件嵌入符號表,以供
    的頭像 發(fā)表于 01-31 10:33 ?1641次閱讀

    如何使用linuxgdb調(diào)試python程序

    如何使用linuxgdb調(diào)試python程序? 在Linux下,可以使用GDB(GNU調(diào)試
    的頭像 發(fā)表于 01-31 10:41 ?4119次閱讀
    荣昌县| 鹤峰县| 玉屏| 濮阳县| 阿克陶县| 炉霍县| 永宁县| 德惠市| 祁门县| 独山县| 寿光市| 兴城市| 上思县| 温州市| 夏河县| 吉林市| 甘德县| 平远县| 拉萨市| 赤壁市| 亚东县| 福建省| 庆城县| 锦屏县| 郯城县| 齐齐哈尔市| 钦州市| 桐城市| 江北区| 乌兰察布市| 鄂温| 远安县| 九江县| 黄平县| 石城县| 庆安县| 保康县| 平潭县| 梅河口市| 通山县| 新野县|