# Freedom Studio Qemu printf and step issue

**URL:** <https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493>\
**Category:** HiFive Unmatched\
**Created:** [December 14, 2021, 6:27pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493 "2021-12-14T18:27:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![abirtz](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@abirtz](https://forums.sifive.com/u/abirtz)\
**Post date:** [December 14, 2021, 6:27pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/1 "2021-12-14T18:27:10Z")

</div>

1. printf: with multiple call some printf do not print to console.  
by example printf("%ld item is %ld \n", i, x); from o to 100  
print some of the first 50 and skip all other

Using  
fflush(stdout);  
setbuf(stdout, NULL);  
setlinebuf(stdout);  
after each printf does nothing.

1. stepping is assembly (one instruction at time, Qemu) work correctly most of the time.  
But it happen that “step” command (F6) do not stop after the instruction (instruction is not branch or jump).  
In loop stop happen anywhere in loop code (after or before).  
Instructions after the stepped instruction are executed correctly but “step” do not stop after the stepped instruction.

---

<div class="post-metadata">

**Author:** ![kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/kevin/32/1140_2.png) [@kevin](https://forums.sifive.com/u/kevin)\
**Post date:** [December 14, 2021, 7:12pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/2 "2021-12-14T19:12:01Z")

</div>

Hi Alain,

I’m not seeing this behavior running the latest qemu package I have (which is not released yet) using an example for loop as you mentioned. What qemu version and which bsp are you using?

-Kevin

---

<div class="post-metadata">

**Author:** ![kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/kevin/32/1140_2.png) [@kevin](https://forums.sifive.com/u/kevin)\
**Post date:** [December 14, 2021, 7:53pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/3 "2021-12-14T19:53:05Z")

</div>

Hi Alain, I was able to replicate the problem in the u54 bsp/machine. I’ll report back when I know more.

---

<div class="post-metadata">

**Author:** ![abirtz](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@abirtz](https://forums.sifive.com/u/abirtz)\
**Post date:** [December 15, 2021, 4:11pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/4 "2021-12-15T16:11:28Z")

</div>

Qemu: 5.10.2020-8-1 (from → Freedom Studio → macOS

---

<div class="post-metadata">

**Author:** ![kevin](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/kevin/32/1140_2.png) [@kevin](https://forums.sifive.com/u/kevin)\
**Post date:** [December 16, 2021, 6:41pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/5 "2021-12-16T18:41:40Z")

</div>

Hi Alain, It turns out that the problem you are seeing is unrelated to the one I found. We haven’t been able to reproduce your issue yet. We see full and reliable console output using that version of QEMU. Can you specify which BSP you are using, fro instance from this list?

![Snag_7ac824e](https://us1.discourse-cdn.com/flex020/uploads/sifive/original/2X/6/6904373960907c95c55d5a71cf898f1c98450465.png)

-Kevin

---

<div class="post-metadata">

**Author:** ![abirtz](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@abirtz](https://forums.sifive.com/u/abirtz)\
**Post date:** [December 17, 2021, 8:15pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/6 "2021-12-17T20:15:55Z")

</div>

BSP: qemu-sifive–s51

In Preferences the “Console buffer lines” was very low. I increase it by factor 20

I also increase “Console buffer size” and stack size so now everything work fine.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![abirtz](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@abirtz](https://forums.sifive.com/u/abirtz)\
**Post date:** [December 27, 2021, 2:10pm UTC](https://forums.sifive.com/t/freedom-studio-qemu-printf-and-step-issue/5493/7 "2021-12-27T14:10:05Z")

</div>

About step issue: don’t use editor to debug.  
Open a “Disassembly” window and click the “Link with Active Debug Context”.  
Debug only with this window. Set breakpoint, watchpoint and step only there.  
Within the “Disassembly” window step work correctly.
