我在linux上使用gdb 6.8Debian版本。我一直很好奇c程序中的主要函数是如何执行的,如何在不同的地方播放和查看,我了解到函数__libc_start_main对此负有责任。__libc_start_main的参数包括: main的地址(就像我们从c中知道的,路径总是以argv的形式给出),下一个argc应该驻留在寄存器ESI中,下一个argv的地址应该在ECX中。
为了发挥作用,我制作了以下简单的程序cmdargs.c,它只是输出在start时给出的第一个命令行参数:
#include <stdio.h>
#include <stdlib.h>
int m
我在linux上用nasm编写汇编语言程序。问题是在使用gdb进行调试时,它不会在_start函数中执行步骤,并给出“单步执行直到退出函数_start”的消息。
此外,当我在第1行之后设置断点时,它说:
(gdb) break 2
Note: breakpoints 1 and 2 also set at pc 0x4000b0.
Breakpoint 3 at 0x4000b0: file new3.asm, line 2.
(gdb) break 3
Note: breakpoints 1, 2 and 3 also set at pc 0x4000b0.
Break
我在汇编中做了一个类,这个类是从C中的一个类中调用的。C类发送2个整数作为参数,但这并不相关,因为我得到了一个分段错误,我似乎不太明白原因。
以下是组装类的相关部分:
.global测试类测试类:
pushl %ebp
movl %esp, %ebp
subl $4, %esp #reserves space for local variable
movl 8(%ebp), %ebx #first argument of the function to %ebx
movl 12(%ebp), %ecx #second argume
我以前用TASM (在winXP上)编译我的asm代码,但是我遇到了一些问题,所以现在我使用了NASM (在linux上)。这个片段展示了我想要做的事情:
(gdb) list 35
30 xor ecx,ecx # ecx is a counter
31 mov bl, ' ' # this is what I'm looking for
32 count_spaces:
33 mov al,[esi] # grab a char
34 jz spaces
我尝试运行gdb来反汇编内核,并尝试运行:
root@debian:/home/jestinjoy# gdb /usr/src/linux-2.6.38.8/vmlinux
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 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 re
我将gcc编译器下载到我的linux环境中,并使用ssh进入vscode,在我的windows机器上模拟linux环境。我创建的编译文件和我的教授给我的makefile运行得很好,但是每当我使用我的教授还提供的gdb调试器进行调试时,调试器挂起,不允许我使用断点单步执行代码。我提供了调试器的代码以及cpp属性和任务文件。 调试器代码: {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For
我有一个关于测试的问题,在Debian Linux (Jessie/ gdb )中我不能完全解决这个问题。尝试调试汇编程序时,我无法让gdb接受输入重定向。下面是我尝试调试的代码:
#The program reverses the input given to it. For example "123456789" will
#become "987654321"
.global _start
readme:
pushw $0 #allocate 2 bytes onto the stack
movl $3,%eax
我正在努力学习C/C++编程,通过遵循麻省理工学院开放式课程的材料。我正在运行Windows,课程内容要求在Linux环境下使用gcc/g++编译器(针对C和C++)运行所有C/C++程序。它们还需要使用gdb和valgrind作为调试器。
我已经从gcc包中安装了MinGW /g++,我想知道是否有关于如何实现设置的具体说明。现在,我希望能够设置Linux、gdb和valgrind,并至少编写一个简单的程序,并在Linux环境中编译和运行它。现在我也安装了VirtualBox,但出于某种原因,我创建的虚拟机总是给出以下消息:FATAL: No bootable medium found! S