The way I would gather the globals the process looks at would be to slip something into the logon code that traced all the $zr changes to a trace file. Its not exactly what you asked for as it wouldn't be on a different process.

    s %oldzr=""

    zbreak /trace:all:"/durable/trace.log"

    zbreak $:"T":"%oldzr'=$zr":"s %oldzr=$zr w $zr"

    d ..yourthing()

You could try to %Studio.Debugger Attach to the user's process and do a similar thing.

Could you pretend to be the compiler and run the generator method? Might be a problem if the method does anything other than generate code.

Class temp.proc
{

ClassMethod showcode(classname, methodname)
{
    n %class,%code,%method,%compiledclass,%compiledmethod,%parameter
    
    s %compiledclass=##class(%Dictionary.CompiledClass).%OpenId(classname)
    s %compiledmethod=##class(%Dictionary.CompiledMethod).%OpenId(classname_"||"_methodname)
    s generatorclassname=%compiledmethod.Origin
    s %class=##class(%Dictionary.ClassDefinition).%OpenId(classname)
    s %method=##class(%Dictionary.MethodDefinition).%OpenId(generatorclassname_"||"_methodname)
        
    s key="" f  { s param=%compiledclass.Parameters.GetNext(.key) q:key=""  s %parameter(param.Name)=param.Default }
    
    s %code=##class(%Stream.MethodGenerator).%New()

    s exec=" d "_methodname_"^"_generatorclassname_".G1(%class,%code,%method,%compiledclass,%compiledmethod,.%parameter)"
    x exec
    
    d %code.Rewind()
    w %code.Read()
}

 

I am not sure if all the variables here are set correctly, or if the generator code always ends up in a G1 or even if this is a good idea, was just thinking.

This is not code I have used before.