Symbol records: Location in RAM / Registers

  • Stefan Falk

    Stefan Falk - 2014-06-13

    Hi folks and sorry for my second post today but I'm having a hard time to find out how I can do the following:

    I have a parser that extracts all information from a CDB file. My problem is stuff like many variables or if-scoped variables. Let me show you what I mean ...

    If I have an if-condition like this:

        if(a > 0)
            int ifvar = 12;
            int ifvar2 = 2;
            int ifvar3 = 2;
            int ifvar4 = 2;
            int ifvar5 = 2;
            int ifvar6 = 2;
            ifvar6 += ifvar * ifvar3;
            a *= ifvar + ifvar2 + ifvar3 + ifvar4 + ifvar5 + ifvar6;
            int ifvar = 12;
            int ifvar2 = 2;
            int ifvar3 = 2;
            int ifvar4 = 2;
            int ifvar5 = 2;
            int ifvar6 = 2;
            a *= ifvar + ifvar2 + ifvar3 + ifvar4 + ifvar5 + ifvar6;

    The CDB file will contain these lines:


    As you can see in the documentary for Symbol Records the R and the [] tell me, that those values will be stored inside registers.

    And this is my problem. Assume that I am using Eclipse and want to know what value ifvar6 has and all I got was the name itself and my program counter address that I am able to obtain.

    It may be possible to obtain the scope information from Eclipse (still have to find out that) but anywy.. the [] would give me a headache anyway since there are no registers defined.

    Can someone put me out of my misery?

    Best regards!

  • Maarten Brock

    Maarten Brock - 2014-06-15

    If there are no registers mentioned then I don't think you can find them. If there really are registers allocated (not A, B, DPTR) for these variables (check the .asm) then this might be a bug.

    I also doubt that the CDB file will give you information on the scope of a variable. Maybe parsing the generated .asm/.lst/.rst file can help here.

  • Stefan Falk

    Stefan Falk - 2014-06-18

    Well parsing the .asm can not be the answer to this ^^

    I took a look at the .lst and .rst files (they look the same to me). The according entries look like:

    1274 ;------------------------------------------------------------
    1275 ;Allocation info for local variables in function 'main'
    1276 ;------------------------------------------------------------
    1277 ;local_int Allocated to registers r4 r5
    1278 ;local_int1 Allocated with name '_main_local_int1_1_9'
    1279 ;local_int2 Allocated with name '_main_local_int2_1_9'
    1280 ;local_int3 Allocated with name '_main_local_int3_1_9'
    1281 ;local_int4 Allocated to registers
    1282 ;local_int5 Allocated to registers
    1283 ;intarray Allocated with name '_main_intarray_1_9'
    1284 ;anstractarray Allocated with name '_main_anstractarray_1_9'
    1285 ;strct Allocated with name '_main_strct_1_9'
    1286 ;anstrct Allocated with name '_main_anstrct_1_9'
    1287 ;ifvar Allocated to registers r2 r3
    1288 ;ifvar2 Allocated with name '_main_ifvar2_3_11'
    1289 ;ifvar3 Allocated to registers r4 r5
    1290 ;ifvar4 Allocated with name '_main_ifvar4_3_11'
    1291 ;ifvar5 Allocated to registers
    1292 ;ifvar6 Allocated to registers
    1293 ;ifvar Allocated to registers
    1294 ;ifvar2 Allocated to registers
    1295 ;ifvar3 Allocated to registers
    1296 ;ifvar4 Allocated to registers
    1297 ;ifvar5 Allocated to registers
    1298 ;ifvar6 Allocated to registers
    1299 ;------------------------------------------------------------

    And that's it. For example ifvar6 has no location.

    I really would have to look at the assembly code to find out where it is located.

    Do you think this is a bug? Should I file a bug-report on this or do you think this might become fixed?

    We would like to use the SDCC and debug those programs in Eclipse. We have our own debugger that talks to the device over another server and our goal is to replace the C51 by Keil with the SDCC.

    May I ask you for a little advice here? :D

    Best regards.

  • Maarten Brock

    Maarten Brock - 2014-06-18

    Of course the .asm .lst and .rst are mostly the same. They just contain each a bit more information than the former.

    Without seeing what the generated asm is, I can only assume that ifvar6 is optimized into ACC, B and/or DPTR for a single use only or in this case more likely constant propagated. If so, then there are no registers (or memory) allocated and you cannot view them in a debugger. It would require disabling optimizations to make them visible.


Log in to post a comment.