Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

R1837 Debugger can't load all line info from lst file generated by sdcc

2 posters

Go down  Message [Page 1 of 1]

royqh1979



In the lst file generated by sdcc, there might be some comment or other info lines immediately following a source line info comment.

These source line info won't be loaded by the debugger.

The patch tring to fix it.

R1837 Debugger can't load all line info from lst file generated by sdcc Snap211
Attachments
R1837 Debugger can't load all line info from lst file generated by sdcc Attachmentlineno.zip
You don't have permission to download attachments.
(1 Kb) Downloaded 2 times

arcachofo

arcachofo

I noticed that the SDCC debugger is not working properly.
You can see that not all source files are mapped:

R1837 Debugger can't load all line info from lst file generated by sdcc Snap613

I will have a look.
In any case I don't understand this patch: "found = false" , but "found" is already false?
Or maybe this patch didn't catch some other change?



Last edited by arcachofo on Fri Sep 01, 2023 11:18 am; edited 1 time in total

royqh1979



arcachofo wrote:I noticed that the SDCC debugger is not working properly.
You can see that not all source files are mapped:

R1837 Debugger can't load all line info from lst file generated by sdcc 23

I will have a look.
In any case I don't understand this patch: "found = false" , but "found" is already false?
Or maybe this patch didn't catch some other change?

In the old code, the found flag is cleared the next line after a line number is found. ( just after if (found) { )

In the patch, the found flag is only cleared when a code line is found.

arcachofo

arcachofo

In the old code, the found flag is cleared the next line after a line number is found. ( just after if (found) { )

In the patch, the found flag is only cleared when a code line is found.
Oh yes... maybe I need new glasses.

In any case doing these changes here can make other debuggers to fail.
This is quite tricky, because the fact that some source code appears in the list file does not mean that necessarily is followed by a line containing the address.

And this fix might work in some cases and fail in other cases.
For example, seems to me that here it ill fail:
Code:
                                    309 ;------------------------------------------------------------
                                    310 ;   /home/roy/sources/simulide/mcs51/led_timer/led_timer.c:5: void main(void) {
                                    311 ;   -----------------------------------------
                                    312 ;    function main
                                    313 ;   -----------------------------------------
      000000                        314 _main:
                          000007  315    ar7 = 0x07
                          000006  316    ar6 = 0x06
                          000005  317    ar5 = 0x05
If I understand correctly, your fix will ignore lines until line 315, and take address = 7, which is wrong.

As we have a dedicated debugger for SDCC, we could do the parsing in SdccDebugger::postProcess() instead of calling BaseDebugger::postProcess()

But debugging SDCC is tricky...

royqh1979



I think we need a "step instruction" debug button to help debug sdcc and other non asm sources...

royqh1979



Patch updated.

Overwrite Sdcc::postProcess() and handle the map source line in it.

lines that don't have ";"(comment line) / ":" (label), and have"[xxx]" is treated as an instruction.
Attachments
R1837 Debugger can't load all line info from lst file generated by sdcc Attachmentlineno.zip
You don't have permission to download attachments.
(2 Kb) Downloaded 1 times

arcachofo

arcachofo

Patch updated.

Overwrite Sdcc::postProcess() and handle the map source line in it.

lines that don't have ";"(comment line) / ":" (label), and have"[xxx]" is treated as an instruction.
Nice.
Patch applied at Rev 1841.

royqh1979



arcachofo wrote:
Patch updated.

Overwrite Sdcc::postProcess() and handle the map source line in it.

lines that don't have ";"(comment line) / ":" (label), and have"[xxx]" is treated as an instruction.
Nice.
Patch applied at Rev 1841.

Sorry but there's an extra qDebug() not cleaned in the patch.

at line 125 in src/gui/editorwidget/debuggers/sdccdebugger.cpp:

Code:
                   qDebug("%d %x", srcLineNumber, m_codeStart+address);

arcachofo

arcachofo

Sorry but there's an extra qDebug() not cleaned in the patch.

at line 125 in src/gui/editorwidget/debuggers/sdccdebugger.cpp:
Ok... I will push it with some other changes.

royqh1979



arcachofo wrote:
Sorry but there's an extra qDebug() not cleaned in the patch.

at line 125 in src/gui/editorwidget/debuggers/sdccdebugger.cpp:
Ok... I will push it with some other changes.

Thanks. And can I make a patch for "Step instruction" button? I really need it to debug sdcc c codes.

arcachofo

arcachofo

Thanks. And can I make a patch for "Step instruction" button? I really need it to debug sdcc c codes.
I'm thinking about that right now.

Ideally when stepping instructions it should print the disassembled instruction in the message panel.
Thinking if that could be retrieved from the lst file...

In any case if you have something in mind that works for you, go ahead and we will see the details and posible issues later.

royqh1979



arcachofo wrote:
Thanks. And can I make a patch for "Step instruction" button? I really need it to debug sdcc c codes.
I'm thinking about that right now.

Ideally when stepping instructions it should print the disassembled instruction in the message panel.
Thinking if that could be retrieved from the lst file...

In any case if you have something in mind that works for you, go ahead and we will see the details and posible issues later.

Yes, sources could be retrieved from the lst file while postprocessing.

But where to display it and the debug button ? another editor window or in the mcu monitor?

arcachofo

arcachofo

But where to display it and the debug button ? another editor window or in the mcu monitor?
My first idea is to display the instruction at the bottom panel in the editor.
Maybe something like this:

R1837 Debugger can't load all line info from lst file generated by sdcc Kk23

The button is another issue to solve.
It should appear only in some cases.

arcachofo

arcachofo

Mixing the debugger with some kind of instruction step in the Mcu Monitor could be a bit too cumbersome.
In my opinion it should be one or another but not both at the same time.
Or you control the execution from the editor while debugging or you control it in Mcu Monitor while in normal simulation.



arcachofo

arcachofo

Another option would be to try to debug the asm file generated by sdcc.

arcachofo

arcachofo

Regardless of "step instruction" it would be useful to debug SDCC asm files.
So now it is posible to debug asm files generated by SDCC (Rev 1843):

Open asm file in Editor and select compiler: "SDCC_asm".
This works if hex, lst and map files are in the same folder.

If you compile the .c file and switch to the .asm file, right-click and "Reload Document" before starting the debugger.

KerimF likes this post

royqh1979



Splendid!

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum