广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    Pintos的编译、跟踪及动态调试方法

    来源:网络收集  点击:  时间:2025-02-17
    【导读】:
    今天小编和大家分享Pintos的编译、跟踪及动态调试方法经验,希望对大家有所帮助。工具/原料morePC方法/步骤1/6分步阅读

    pintos/src/threads/build,下输入make 命令,然后再输入 make check 命令来测试,输入 make clean 来清空之前编译的结果的,那么这个目录下的Makefile应该是一个总的Makefile了,看看这个Makefile里面的内容,一点一点来解析吧!

    2/6

    # -*- makefile -*-

    SRCDIR = ../..

    #所有存放源文件的目录,也就是 pintos/src/

    all: kernel.bin loader.bin

    #这个all是标签,Makefile中的第一个目标会被作为其默认目标,由于伪目标的特性是,总是被执行的,

    #所以其依赖的 kernel.bin loader.bin 就总是不如“all”这个目标新。所以,这2个二进制文件总会更新

    include ../../Make.config

    include ../Make.vars

    include ../../tests/Make.tests

    3/6

    这个是Makefile的前面几行,all是个标签,输入命令 make all 的话就会运行 kernel.bin loader.bin 这2个程序

    然后看到 include 了一个文件,去看看 pintos/src/Make.config

    那么对3个这Makefile的文件的解析我都写在这里了:

    首先是../../Make.config:

    # -*- makefile -*-

    SHELL = /bin/sh

    #指定使用的shell

    VPATH = $(SRCDIR)

    #特殊变量 VPATH 指定文件的查找路径

    # Binary utilities.

    # If the host appears to be x86, use the normal tools.

    # If its x86-64, use the compiler and linker in 32-bit mode.

    # Otherwise assume cross-tools are installed as i386-elf-*.

    X86 = i.86\|pentium.*\|\|nexgen\|viac3\|6x86\|athlon.*\|i86pc

    # .*是模糊匹配,\|是管道的转义

    X86_64 = x86_64

    4/6

    # Pintos doesnt compile/run properly using gcc 4.3+. Force 4.1 for now.

    # 这句话的意思大概是 必须是4.1版本的gcc 才可以正常编译

    CCPROG = /usr/class/cs140/x86_64/bin/i586-elf-gcc

    ifeq ($(strip $(shell command -v $(CCPROG) 2 /dev/null)),)

    #strip函数:功能:去掉string字串中开头和结尾的空字符。返回被去掉空格的字符串值。

    #如果strip这个函数返回为空的话

    #strip是函数名, 函数参数是 $(shell command -v $(CCPROG) 2 /dev/null) ,单独的一个变量

    #参考博客: http://www.cnblogs.com/bethal/p/5430229.html

    # 这个函数会新生成一个Shell程序来执行命令

    CCPROG = gcc

    endif

    5/6

    ifneq (0, $(shell expr `uname -m` : $(X86)))

    CC = $(CCPROG)

    LD = ld

    OBJCOPY = objcopy

    else

    ifneq (0, $(shell expr `uname -m` : $(X86_64)))

    CC = $(CCPROG) -m32

    LD = ld -melf_i386

    OBJCOPY = objcopy

    else

    CC = i386-elf-gcc

    LD = i386-elf-ld

    OBJCOPY = i386-elf-objcopy

    endif

    endif

    ifeq ($(strip $(shell command -v $(CC) 2 /dev/null)),)

    $(warning *** Compiler ($(CC)) not found. Did you set $$PATH properly? Please refer to the Getting Started section in the documentation for details. ***)

    endif

    6/6

    # Compiler and assembler invocation.

    DEFINES =

    WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wsystem-headers

    CFLAGS = -g -msoft-float -O

    CPPFLAGS = -nostdinc -I$(SRCDIR) -I$(SRCDIR)/lib

    ASFLAGS = -Wa,--gstabs

    LDFLAGS =

    DEPS = -MMD -MF $(@:.o=.d)

    # Turn off -fstack-protector, which we dont support.

    ifeq ($(strip $(shell echo | $(CC) -fno-stack-protector -E - /dev/null 21; echo $$?)),0)

    CFLAGS += -fno-stack-protector

    endif

    # Turn off --build-id in the linker, which confuses the Pintos loader.

    ifeq ($(strip $(shell $(LD) --help | grep -q build-id; echo $$?)),0)

    LDFLAGS += -Wl,--build-id=none

    endif

    注意事项

    如有不明者,还请咨询专业人士。

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_1240473.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-07 16:19:35  耗时:0.042
    0.0418s