Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger interpret symbols from data segments as code #1358

Open
rdos314 opened this issue Dec 18, 2024 · 4 comments
Open

Debugger interpret symbols from data segments as code #1358

rdos314 opened this issue Dec 18, 2024 · 4 comments
Labels

Comments

@rdos314
Copy link
Member

rdos314 commented Dec 18, 2024

When I create a mixed source device driver, all code segments are in segment 0001 and all data segments are in segment 0002 in the map file. When an address higher than __END_YI is found, then the debugger will claim source is not available, and will claim the module is segdefns and will show the address in the assembly window as __END_YI +xxxxxxxx. The symbol __END_YI is in segment 0002, and thus is a data segment and not a code segment. Why does the debugger believe that a data segment is related to the currently executing code?

I note that in segdefns.asm, there are public definitions for the symbols, which might fool the debugger into thinking it's code. Why are these in the data segment and not in the code segment?

Contents of the map file:

Open Watcom Linker Version 2.0 beta Nov 26 2024 02:33:17 (64-bit)
Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Created on: 24/12/18 21:55:31
Executable Image: exec.rdv
creating a 32-bit RDOS Device driver executable

                    +------------+
                    |   Groups   |
                    +------------+

Group Address Size
===== ======= ====

DGROUP 0002:00000000 00012bf0

                    +--------------+
                    |   Segments   |
                    +--------------+

Segment Class Group Address Size
======= ===== ===== ======= ====

BEGTEXT CODE AUTO 0001:00000000 00000007
_TEXT CODE AUTO 0001:00000010 00005378
_NULL BEGDATA DGROUP 0002:00000000 00000004
_AFTERNULL BEGDATA DGROUP 0002:00000004 00000000
_DATA DATA DGROUP 0002:00000004 00000083
data DATA DGROUP 0002:00000088 00000230
CONST DATA DGROUP 0002:000002b8 000000ae
CONST2 DATA DGROUP 0002:00000368 00000000
XIB DATA DGROUP 0002:00000368 00000000
XI DATA DGROUP 0002:00000368 00000006
XIE DATA DGROUP 0002:0000036e 00000000
YIB DATA DGROUP 0002:0000036e 00000000
YI DATA DGROUP 0002:0000036e 00000000
YIE DATA DGROUP 0002:0000036e 00000000
TIB DATA DGROUP 0002:0000036e 00000000
TI DATA DGROUP 0002:0000036e 00000000
TIE DATA DGROUP 0002:0000036e 00000000
_BSS BSS DGROUP 0002:00000370 0000287c
STACK STACK DGROUP 0002:00002bf0 00010000

                    +----------------+
                    |   Memory Map   |
                    +----------------+
  • = unreferenced symbol
  • = symbol only referenced locally

Address Symbol
======= ======

Module: execbase.obj(C:\rdos\kernel\os\execbase.asm)
0001:0000350e InitExec_
Module: utimer.obj(C:\rdos\kernel\os\utimer.asm)
0001:00003c99 AllocateUserTimer
0001:00003d45 FreeUserTimer
0001:00003f4a InitTimer_
Module: exec.obj(exec)
0001:00003f85+ ImplGetModuleCount
0001:00003fb8+ ImplModuleLoaded
0001:000041bd+ ImplModuleUnloaded
0001:000042b4+ ImplModuleIdToSel
0001:000043b4+ ImplGetModuleId
0001:00004497+ ImplGetProcessCount
0001:000044ca+ ImplProcessCreated
0001:000046fb+ ImplProcessTerminated
0001:00004895+ ImplProcessIdToSel
0001:00004995+ ImplGetProcessId
0001:00004a78 StartWaitProcess
0001:00004bc7 StopWaitProcess
0001:00004cef GetProcExit
0001:00004e36+ InitGates_
0001:0000504d main_
0002:00000004+ _ActiveModules
0002:00000008+ _NextMid
0002:0000000c+ _ActiveProcesses
0002:00000010+ _NextPid
0002:00000014+ _CurrExitInd
0002:00000370+ _ExitArr
0002:00000b70+ _ModuleArr
0002:00001770+ _ProcessArr
0002:00002bc0+ _ProcessSection
0002:00002bc6+ _ModuleSection
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(stk)
0001:000050a5 __CHK
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(cstrtrdk)
0001:000050b6 cexit
0001:000050e3 cstart
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(mainrdk)
0002:00000020* __AccessFileH
0002:00000024* __ReleaseFileH
0002:00000028* __AccessIOB
0002:0000002c* __ReleaseIOB
0002:00000030* __AccessNHeap
0002:00000034* __AccessFHeap
0002:00000038* __ReleaseNHeap
0002:0000003c* __ReleaseFHeap
0002:00000040* __AccessTDList
0002:00000044* __ReleaseTDList
0001:000051b0 __RdosMain
0001:00005240 _exit
0002:00000048* __AccessFList
0002:0000004c* __ReleaseFList
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(initrtns)
0001:00005260 __InitRtns
0001:000052b0 __FiniRtns
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(segdefns)
0001:00000003 ___begtext
0002:00000000* __nullarea
0002:00000368 __Start_XI
0002:0000036e __End_XI
0002:0000036e __Start_YI
0002:0000036e __End_YI
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(crwdata)
0002:00000081 __osmajor
0002:00000082 __osminor
0002:00000058 __LpCmdLine
0002:0000005c __LpPgmName
0002:00000050* __dynend
0002:00000054* __curbrk
0002:00000070* __cbyte
0002:00000074* __cbyte2
0002:00000078* __child
0002:0000007d* __Envptr
0002:00000060* __STACKLOW
0002:00000064* __STACKTOP
0002:00000068 __ASTACKSIZ
0002:0000006c __ASTACKPTR
0002:0000007c* __no87
0002:00000083* ___FPE_handler
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(cmain386)
0001:00005310 __CMain
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(dosseg)
0000:00001234 DOSseg
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(cinit)
0001:00005360 _CommonInit
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(___argc)
0002:00002be0 ____Argc
0002:00002be6 ___Argv
Module: C:\ow\rel\lib386\rdosdev\clib3r.lib(exit)
0001:00005370 exit

0001:00005383* exit

                    +---------------------+
                    |   Module Segments   |
                    +---------------------+

! = 32-bit segment
c = initialized communal data

Module Segment Class Address Size
====== ======= ===== ======= ====

C:\rdos\kernel\os\execbase.asm
_TEXT CODE 0001:00000010 ! 00003c89
_DATA DATA 0002:00000004 ! 00000000
data DATA 0002:00000088 ! 00000230
C:\rdos\kernel\os\utimer.asm
_TEXT CODE 0001:00003c99 ! 000002ec
_DATA DATA 0002:00000004 ! 00000000
exec _TEXT CODE 0001:00003f85 ! 0000111d
CONST DATA 0002:000002b8 ! 000000ae
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000004 ! 00000014
_BSS BSS 0002:00000370 ! 0000285c
stk _TEXT CODE 0001:000050a4 ! 00000011
_DATA DATA 0002:00000018 ! 00000000
XIB DATA 0002:00000368 ! 00000000
XI DATA 0002:00000368 ! 00000006
XIE DATA 0002:0000036e ! 00000000
YIB DATA 0002:0000036e ! 00000000
YI DATA 0002:0000036e ! 00000000
YIE DATA 0002:0000036e ! 00000000
cstrtrdk _TEXT CODE 0001:000050b6 ! 000000d7
_DATA DATA 0002:00000018 ! 00000006
XIB DATA 0002:00000368 ! 00000000
XI DATA 0002:0000036e ! 00000000
XIE DATA 0002:0000036e ! 00000000
YIB DATA 0002:0000036e ! 00000000
YI DATA 0002:0000036e ! 00000000
YIE DATA 0002:0000036e ! 00000000
mainrdk _TEXT CODE 0001:00005190 ! 000000b5
CONST DATA 0002:00000368 ! 00000000
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000020 ! 00000030
_BSS BSS 0002:00002bd0 ! 0000000c
initrtns _TEXT CODE 0001:00005250 ! 000000b3
CONST DATA 0002:00000368 ! 00000000
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000050 ! 00000000
segdefns _TEXT CODE 0001:00005304 ! 00000000
_DATA DATA 0002:00000050 ! 00000000
TIB DATA 0002:0000036e ! 00000000
TI DATA 0002:0000036e ! 00000000
TIE DATA 0002:0000036e ! 00000000
XIB DATA 0002:00000368 ! 00000000
XI DATA 0002:0000036e ! 00000000
XIE DATA 0002:0000036e ! 00000000
YIB DATA 0002:0000036e ! 00000000
YI DATA 0002:0000036e ! 00000000
YIE DATA 0002:0000036e ! 00000000
BEGTEXT CODE 0001:00000000 ! 00000007
_NULL BEGDATA 0002:00000000 ! 00000004
_AFTERNULL BEGDATA 0002:00000004 ! 00000000
CONST DATA 0002:00000368 ! 00000000
data DATA 0002:000002b8 ! 00000000
_BSS BSS 0002:00002bdc ! 00000000
STACK STACK 0002:00002bf0 ! 00010000
crwdata _TEXT CODE 0001:00005304 ! 00000001
_DATA DATA 0002:00000050 ! 00000037
cmain386 _TEXT CODE 0001:00005310 ! 00000049
CONST DATA 0002:00000368 ! 00000000
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000088 ! 00000000
dosseg _TEXT CODE 0001:0000535c ! 00000000
_DATA DATA 0002:00000088 ! 00000000
cinit _TEXT CODE 0001:00005360 ! 00000001
CONST DATA 0002:00000368 ! 00000000
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000088 ! 00000000
___argc _TEXT CODE 0001:00005370 ! 00000000
CONST DATA 0002:00000368 ! 00000000
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000088 ! 00000000
_BSS BSS 0002:00002be0 ! 0000000c
exit _TEXT CODE 0001:00005370 ! 00000018
CONST DATA 0002:00000368 ! 00000000
CONST2 DATA 0002:00000368 ! 00000000
_DATA DATA 0002:00000088 ! 00000000

                    +--------------------+
                    |   Libraries Used   |
                    +--------------------+

C:\ow\rel\lib386\rdosdev\clib3r.lib

rdos314 added a commit that referenced this issue Dec 19, 2024
@rdos314
Copy link
Member Author

rdos314 commented Dec 19, 2024

By removing the public definitions for XI/YI and related rtns segments, the debugger now shows the source code correctly.

I suspect 32-bit code assumes a flat memory model where code & data relate to the same memory, but this is not true for the 32-bit compact memory model that RDOS device drivers use. In this model, code and data do not overlap.

@jmalak
Copy link
Member

jmalak commented Dec 19, 2024

If this behave as described then you need to review the trap address mapping code, function trap_retval TRAP_CORE( Map_addr )( void ).
It is in bld/trap/lcl/rdos/c/accmap.c which should recognize memory models and identify segments info.
Anyway FLAT debug segments are defined in bld/dig/h/digtypes.h, but you need to use specific segments used by your non-flat model.
I am not sure, probably you will need to review DIP code for change debug segment info values.
You should review wlink code for RDOS debug segments info setup.

I think Causeway extender trap file doesn't use FLAT memory model for 32-bit DLL code and data, that you could use it as idea.

@rdos314
Copy link
Member Author

rdos314 commented Dec 20, 2024

The local trap gates are not used since I use TCP/IP debugging from a Windows machine. I have my own server for RDOS. I can see that it sends back "32-bit device", and not flat memory model. Also, it's only the source code that fails to show, everything else works, like inspecting local and global variables. The source code also is mapped correctly (with the changes) and when not using mixed-language code.

@jmalak
Copy link
Member

jmalak commented Dec 20, 2024

OK. It is probably relate to issue #1354
I will review #1354 and fix it then I expect this issue should dismissed.

@jmalak jmalak added the bug label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants