打印“数组"来自gdb中的.bss [英] Printing "array" from .bss in gdb
本文介绍了打印“数组"来自gdb中的.bss的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的nasm x86汇编代码包含以下内容:
my nasm x86 assembly code contains the following:
; The code should mimic the following C-code:
; int a[10];
; for (int i = 0; i < 10; i++){
; a[i] = i;
; }
SECTION .data
arraylen dd 10
SECTION .bss
array RESD 10
SECTION .text
global main
main:
mov ecx, 0
mov eax, 0
loop:
inc ecx
mov dword [array+eax*4], ecx
inc eax
cmp ecx, arraylen
jl loop
end:
mov ebx, 0
mov eax, 1
int 0x80
现在我要检查的是此代码是否在gdb中有效.
但是,我如何打印array
?
Now what i want is to check whether this code works in gdb.
However, how do i print array
?
print array
仅返回$1 = 1
.
print array + X
不幸的是算术运算,即
例如print array + 50
实际上打印1 + 50 = 51
而不是不存在的第51个数组元素.
print array + X
unfortunately is an arithmetical operation, i.e.
e.g. print array + 50
actually prints 1+50 = 51
and not the non-existent 51st array element.
推荐答案
您可以这样做:
(gdb) x/10 &array
0x8049618: 1 2 3 4
0x8049628: 5 6 7 8
0x8049638: 9 10
PS:您的代码已损坏,需要cmp ecx, [arraylen]
.
PS: Your code is broken, you need cmp ecx, [arraylen]
.
这篇关于打印“数组"来自gdb中的.bss的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文