R
R
RokkerRuslan2014-05-17 07:34:14
linux
RokkerRuslan, 2014-05-17 07:34:14

How to properly debug a program that uses I/O?

We have a program on assembler.

1 .data
  2 str:
  3         .string "test\n"
  4 
  5 .text
  6 
  7 .globl main
  8 
  9 main:
 10 
 11         pushl   $str
 12         call    printf
 13         addl    $4, %esp
 14         movl    $0, %eax
 15         ret

Compile, run.
$ gcc -g temp.s
$ ./a.out 
test

That's right, we are trying to debug:
(gdb) run > log
Starting program: /home/rokker/yadisk/tmp/temps/a.out > log

Breakpoint 1, main () at temp.s:11
pushl	$str
(gdb) s
call	printf
(gdb) s
__printf (format=0x804a020 "test\n") at printf.c:28
printf.c: No such file or directory.

The point is to put the output of the program in the log file. The same type of error occurs when using scanf.
ubuntu 14.04,
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1),
GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2014-05-17
@jcmvbkbc

printf.c: No such file or directory.
The point is to put the output of the program in the log file. The same type of error occurs when using scanf.

This is the message from gdb that it cannot find the printf.c file with the source code for the printf function you stepped into. It has nothing to do with the output to the log file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question