Question
Norman W. Freeman · Nov 29, 2022

Is there a way to modify %SYS classes for debugging purposes ?

I got an error that occurs inside %CSP.Broker. That class is located inside %SYS namespace.

I tried lot of things (including checking system logs) but ultimately what would really help would be to be able to modify that class to add my own logs into it.

If I try to modify it, I got this error message: 

Item '%CSP.Broker' is mapped from a database that you do no have write permissions on.

What I also tried (but failed) : to create a new class outside %SYS namespace (eg: SomeNamespace.MyBroker) and copy code implementation of %CSP.Broker into that class (just changing name of the class). I compiled it, then redirected my requests to that class. It does not work as %CSP.Broker except to be run in %SYS.

I know modifying %SYS classes is not a good idea (as they might not work anymore as you would expect), but it would be temporary and only for debugging in this case.

Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 EDT
0
0 272
Discussion (5)5
Log in or sign up to continue

It is always interesting to see how far down the debugging Rabbit Hole you can go, but in cases where product classes are throwing errors it's always best to contact InterSystems Support.  You get bonus points if you can provide a sample class which can demonstrate the problem ;)

Hi @Norman W. Freeman 

The way to achieve wat you need is: uncheck the database Mount Read-Only of IRISLIB in the Management Portal:

 Watchout because you can damage your instance.

What error did you get?

Are you sure, that the error is inside %CSP.Broker?

%CSP.Broker is a dispatch class to call server-side methods.

In most cases the error happens in the application method that is called via %CSP.Broker.

Enable logging for CSP Broker and see if any additional information is logged in ^ISCLOG:

USER>zn "%SYS"

%SYS>kill ^ISCLOG, ^%ISCLOG

%SYS>set ^%ISCLOG("Category","CSPBroker")=3

%SYS>set ^%ISCLOG=3

To disable logging:

%SYS>kill ^%ISCLOG

If %CSP.Broker is used to call ZEN Methods then enable also ZEN logs:

%SYS>do ##class(%ZEN.Utils).%StartLog()

%SYS>do ##class(%ZEN.Utils).%ShowLog()
1  13:40:51.606 OnPreHTTP               /csp/sys/%CSP.Portal.Home.zen
2  13:40:51.809 InvokeInstanceMethod    138@%ZEN.Auxiliary.jsonProvider:RefreshFromServer
3  13:40:51.830 InvokeClassMethod       %CSP.Portal.Home.GetNamespaceList
4  13:40:51.845 InvokeInstanceMethod    169@%ZEN.Component.html:ReallyRefreshContents

%SYS>do ##class(%ZEN.Utils).%StopLog()

The ObjectScript command
   ZBREAK %method^%CSP.Broker.1
or
   ZBREAK zmethod^%CSP.Broker.1
will allow you to set an ObjectScript debugging breakpoint at the entry of "%method" or "method" of that class.  The ObjectScript commands  BREAK "S" or BREAK "S+" would then allow you to single step through the statements in that method.  See documentation on ObjectScript debugging for more details.

Unfortunately, the ObjectScript routine %CSP.Broker.1 on my IRIS instance is "deployed" which means the %CSP.Broker.1.int routine source code is not available and I assume the %CSP.Broker.cls source code is also not available.  Without one of these source files you will be debugging and single stepping blind through the ObjectScript commands.  Some of InterSystems classes and routines are not "deployed" which means you can do Command-line Routine Debugging.  You can also modify those classes/routines after you change the IRISLIB database from readonly to read-write.

It is best that you take the advice above to contact support in the InterSystems WRC.