I am learning NASM x64 and searched for debugger. Not only did I try gdb, but SASM also. Unfortunately, they are both not viable options for me(*). According to the issue (see comments section), it is possible to do debug NASM in Qt Creator. But i can't hit any breakpoints and see register values, for example.
Here my setup is:
- CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
enable_language(ASM_NASM)
project(untitled LANGUAGES C ASM_NASM)
SET(CMAKE_BUILD_TYPE Debug)
set(CMAKE_ASM_NASM_FLAGS_DEBUG "-g -F dwarf")
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> \
<FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
add_executable(untilted main.c lab.asm)
set_target_properties(untilted PROPERTIES NASM_OBJ_FORMAT elf64)
- main.c
extern void asm_main();
int main()
{
asm_main();
return 0;
}
- lab.asm
bits 64
SYS_WRITE equ 1
STDOUT equ 1
NEW_LINE_CHARACTER equ 10
section .data
msg: db "Hello, World", NEW_LINE_CHARACTER, 0 ; length is 13
section .text
global asm_main
asm_main:
xor rax, rax
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, msg
mov rdx, 13
syscall
ret
So that's it. As you can see my build configuration is set to Debug(left down corner). So I would really appreciate any help with this issue.
*P.S yeah, probably, i am to lazy and not hardcore enough to use gdb 'cause i once did a lab in 600 lines in NASM and it was good but at the same time bad experience( it is better to learn c++ metaprogramming i dunno). Besides, it is a bit difficult to study and work when a russian drone or rocket can fly into your house, but as a ukrainian zoomer i am used to that kind of crap. I know that nobody asked to tell you that story, but i just want to finish my second year at university with systems programming done and be alive.