vscode-ibmi
vscode-ibmi copied to clipboard
Debugging Failure
Question: Is it possible with version 2.9.0 to debug on PUB400, or is there something coming in a later release that we should wait for?
Last week (4/15), for the first time on PUB400.COM I was able to use VS Code to step through a program. Yeah!
On 4/19, Marco, another PUB400 user, tried debugging but he failed, getting "CPD0168 Not authorized to library DIMARCO1
". We're guessing that was because I was the user of the QB5ROUTER job and as such it had no access to his library. I killed my QB5ROUTER job.
Marco then tried debugging again, but got "EQAVS1007E on port 8005 could not be connected.
".
Today (4/22) I deleted the QIBM/UserData/IBMIDEBUGSERVICE/
since I owned it and had full rights. The only thing I couldn't delete was QIBM/UserData/IBMIDEBUGSERVICE/certs
, since that was owned by another user (train248).
I started again with the debug walkthrough and then tried debugging. Now I get port 8005 could not be connected:
I presume that is because someone else now "owns" the QB5ROUTER job:
wrkjob qb5router
No authority to job 246714/HEIKOW/QB5ROUTER.
I tried IBM iDebug: Stop Debug Service
and got "EQARD1028E The request to stop the Remote Debug Service daemon failed because port 8001 was invalid or the daemon was not running
."
Here's a link to the PUB400 Forum discussion in case it is useful. April 15 is where I start discussions with Marco: https://pub400.com/mbr/forum.nd/listposts?yBID=1&yBSID=3&yTID=2024-01-02-18.43.19.752652
Here's what I'm seeing in the DEBUG CONSOLE when debugging fails.
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"IBMiDebug","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true})
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsEvaluateForHovers":true,"supportsSetVariable":true,"supportsValueFormattingOptions":true,"supportsModulesRequest":true,"supportTerminateDebuggee":true,"supportsFunctionBreakpoints":true,"supportsConfigurationDoneRequest":true}}
From client: launch({"type":"IBMiDebug","request":"launch","name":"Remote debug: Launch a batch debug session","user":"LENNONS","password":"rea2mon3","host":"pub400.com","port":"8005","secure":false,"ignoreCertificateErrors":true,"subType":"batch","library":"LENNONS1","program":"AR3G","startBatchJobCommand":"SBMJOB CMD(CALL PGM(LENNONS1/AR3G)) INLLIBL(QIWS QTEMP QGPL LENNONS1 LENNONSB) CURLIB(LENNONS1) JOBQ(QSYSNOMAX) MSGQ(*USRPRF)","updateProductionFiles":true,"trace":true,"workbenchSettings":{"connection":{"connectionPort":8005},"updateProductionFiles":true,"enableDebugTracing":true},"__sessionId":"ccb7dd94-ecbe-48d0-a820-b9b84b526ae2"})
EQAVS1007E pub400.com on port 8005 could not be connected.
Message received: connect ECONNREFUSED 185.113.5.134:8005
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"EQAVS1007E pub400.com on port 8005 could not be connected.\nMessage received: connect ECONNREFUSED 185.113.5.134:8005\n"}}
EQAVS1007E pub400.com on port 8005 could not be connected.
Message received: connect ECONNREFUSED 185.113.5.134:8005
To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":false,"message":"EQAVS1007E pub400.com on port 8005 could not be connected.\nMessage received: connect ECONNREFUSED 185.113.5.134:8005","body":{"error":{"id":9999,"format":"EQAVS1007E pub400.com on port 8005 could not be connected.\nMessage received: connect ECONNREFUSED 185.113.5.134:8005","showUser":true}}}
Here's the OUTPUT tab when I start debugging a program:
/home/LENNONS: LC_ALL=EN_US.UTF-8 system "call QSYS/QZDFMDB2 PARM('-d' '-i' '-t')"
select OBJTYPE from table(qsys2.object_statistics('LENNONS1', '*PGM *SRVPGM', 'AR3G')) X
{
"code": 0,
"signal": null,
"stdout": "DB2>\n ?>\n\nOBJTYPE \n--------\n*PGM \n\n 1 RECORD(S) SELECTED.",
"stderr": ""
}
/home/LENNONS: test -r /QIBM/ProdData/IBMiDebugService/package.json { "code": 1, "signal": null, "stdout": "", "stderr": "" }
⚠️ REMOVE THIS LINE AND ANY SENSITIVE INFORMATION BELOW! ⚠️
Context | Version |
---|---|
Code for IBM i version | 2.9.0 |
Visual Studio Code version | 1.88.1 |
Operating System | win32_x64 |
Active extensions
Code for IBM i Walkthroughs (vscode-ibmi-walkthroughs): 0.4.0
Db2 for IBM i (vscode-db2i): 0.10.1
Emmet (emmet): 1.0.0
Error Lens (errorlens): 3.17.0
Extension Authoring (extension-editing): 1.0.0
Git (git): 1.0.0
Git Base (git-base): 1.0.0
GitHub (github): 0.0.1
IBM i Debug (ibmidebug): 1.0.0
IBM i Notebooks (vscode-ibmi-notebooks): 0.0.6
IBM i Project Explorer (vscode-ibmi-projectexplorer): 2.9.1
JSON Language Features (json-language-features): 1.0.0
Merge Conflict (merge-conflict): 1.0.0
NPM support for VS Code (npm): 1.0.1
Node Debug Auto-attach (debug-auto-launch): 1.0.0
Overtype (overtype): 0.5.0
RPGLE (vscode-rpgle): 0.26.5
Server Ready Action (debug-server-ready): 1.0.0
TypeScript and JavaScript Language Features (typescript-language-features): 1.0.0
compareit (compareit): 0.0.2
Remote system
Setting | Value |
---|---|
IBM i OS | V7R5M0 |
Tech Refresh | n/a |
CCSID | 37 |
Default CCSID | 37 |
SQL | Enabled |
Source dates | Disabled |
Enabled features
/QOpenSys/pkgs/bin | /usr/bin | /QSYS.lib/LENNONS2.lib | /QSYS.LIB | /QIBM/ProdData/IBMiDebugService/bin |
---|---|---|---|---|
bash | attr | GETNEWLIBL.PGM | QZDFMDB2.PGM | startDebugService.sh |
chsh | iconv | |||
git | setccsid | |||
grep | ||||
ls | ||||
md5sum | ||||
sort | ||||
stat | ||||
tar | ||||
tn5250 |
Shell env
BUILDLIB=LENNONS1
CURLIB=LENNONS1
HOME=/home/LENNONS
HOST=pub400.com
IFS_LIB=LENNONSB
IFS_SRCPF=VSCODE
LIB1=LENNONSB
LIBLS=LENNONSB LENNONS1 QGPL QTEMP QIWS
LOGIN=lennons
LOGNAME=lennons
MAIL=/var/spool/mail/lennons
OLDPWD=/home/LENNONS
PASE_USRGRP_LIMITED=N
PATH=/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
PWD=/home/LENNONS
SHELL=/QOpenSys/pkgs/bin/bash
SHLVL=1
SSH_CLIENT=71.63.120.199 49329 2222
SSH_CONNECTION=71.63.120.199 49329 185.113.5.134 2222
TZ=<UTC>0
USER=lennons
USERNAME=lennons
WORKDIR=/home/LENNONS
_=/QOpenSys/pkgs/bin/env
Variants
{
"american": "#@$",
"local": "#§$"
}
Errors
[
{
"command": "/QOpenSys/usr/bin/qsh",
"code": 1,
"stderr": "CPD0032: Not authorized to command CRTLIB in library *LIBL.\nCPF0001: Error found on CRTLIB command.",
"cwd": "/home/LENNONS"
},
{
"command": "/QOpenSys/usr/bin/qsh",
"code": 1,
"stderr": "CPF2125: No objects deleted.",
"cwd": "/home/LENNONS"
}
]
Hello Sam (Marco speaking) It seems that you succeeded to start the Debug Service. Indeed, I can see it listening on ports 8005 and 8001 through an ssh job using your profile.
And I can see that subdirectories and files which are created when Debug Service is started still have Read only authority for anyone else than you (as shown in attached Excel file created with "WITH OBJS AS (SELECT PATH_NAME FROM TABLE(QSYS2.IFS_OBJECT_STATISTICS(START_PATH_NAME => '/QIBM/UserData/IBMIDEBUGSERVICE', subtree_directories => 'YES'))) SELECT OBJS.PATH_NAME, OBJECT_TYPE, OWNER, DATA_AUTHORITY, OBJECT_OPERATIONAL, OBJECT_MANAGEMENT, OBJECT_EXISTENCE, OBJECT_ALTER, OBJECT_REFERENCE, DATA_READ, DATA_ADD, DATA_UPDATE, DATA_DELETE, DATA_EXECUTE FROM OBJS, TABLE(QSYS2.IFS_OBJECT_PRIVILEGES(PATH_NAME)) where AUTHORIZATION_NAME = '*PUBLIC';" SQL statement).
But wait... Just ran a couple of tests and it seems to work!
Files created by me at debug session time are owned by Sam's profile as he started the Debug Service.
-bash-5.2.15 [email protected]:/QIBM/UserData/IBMIDEBUGSERVICE/startDebugService_workspace $ ls -al
total 104
drwxr-sr-x 4 lennons 0 12288 Apr 23 10:00 .
drwxr-srwx 6 qsys 0 12288 Apr 22 23:44 ..
drwxr-sr-x 3 lennons 0 8192 Apr 23 05:03 .metadata
drwxr-sr-x 4 lennons 0 8192 Apr 23 10:00 DebugViewFiles
-rw-r--r-- 1 lennons 0 13122 Apr 23 09:54 PDT_DAAS_20240423_095155_0760_1_DAP.txt
-rw-r--r-- 1 lennons 0 6528 Apr 23 09:58 PDT_DAAS_20240423_095532_0528_2_DAP.txt
-rw-r--r-- 1 lennons 0 6260 Apr 23 10:00 PDT_DAAS_20240423_100038_0476_3_DAP.txt
-bash-5.2.15 [email protected]:/QIBM/UserData/IBMIDEBUGSERVICE/startDebugService_workspace $
So, sounds good to me now. To be clean it would be better in my opinion to change ownership of all directories and files (in /QIBM/UserData/IBMIDEBUGSERVICE) to say QPGMR and request Holger to include in his QSTRUPJD procedure starting the Debug Server (STRDBGSVR) and the Debug Service (invoke /QIBM/ProdData/IBMiDebugService/bin/startDebugService.sh script [I understand that this is what Code for i does when we invoke "IBM i Debug: Start Debug Service"]). This way, all jobs would be running under QPGMR profile, in place of the first user who succeeded to start the jobs.
@MarcoDeSenas
it would be better in my opinion to request Holger to include in his QSTRUPJD procedure
I'm in a dialog with Holger exactly about that (we're both members of CEAC). Stay tuned...
@MarcoDeSenas @chrjorgensen It is also working for me today 😃! I don't know why it wasn't yesterday.
Interestingly, some of the messages are in German. PUB400 is a German machine after all but I wonder is there is a way to fix that.
@chrjorgensen
I'm in a dialog with Holger exactly about that (we're both members of CEAC). Stay tuned..
Excellent, thanks. Staying tuned...
Hopefully whatever you come up with can become a documented recommendation for other systems that may have similar sharing/authority issues.
@chrjorgensen
it would be better in my opinion to request Holger to include in his QSTRUPJD procedure
I'm in a dialog with Holger exactly about that (we're both members of CEAC). Stay tuned...
Ideally, IBM could create two new TCP servers, one for the Debug Server and one for the Debug Service, and include them in the list of available servers for SERVER parameter of STRTCPSVR command. Just like existing *DBG server. Mmmmm, three distinct debug services, this is quite confusing for me! Another solution is to create two user-defined servers with ADDTCPSVR command and set them to autostart at IPL time.
Glad it works, even though you seriously messed with it 🤣 Code for IBM i 2.10 will bring several improvements around the debug service and its management.
The debug server is fine as it. It's been around for years, used by RDi, and well integrated with the OS (STR/ENDBGSVR
to start and stop it; native commands; cannot be run by anyone).
The debug service is not integrated with IBM i at all. It's a Java based HTTP server (because IBM wanted to reuse existing bricks I guess), delivered with some shell scripts and...that's it. At this point you're on your own.
We try to provide a good user experience in Code for IBM i by wrapping it in commands and automating the configuration as much as possible but at the core, it lacks an actual integration with the OS.
Anyway, keep an eye on this PR; this is where the next improvement will come from: https://github.com/codefori/vscode-ibmi/pull/1990
Once it's merged, Holger will be able to generate the certificate and configure the service so it can be called with a good old SBMJOB
. He'll be able to easily autostart it afterwards.