Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: functions called and defined in pcode  (Read 8818 times)
Carlos L.
Posts: 20


« on: February 15, 2016, 11:57:35 am »

Do I have any way or tool to find which functions are defined and called inside a pcode module(42m) without going into debug mode?.

On the original 4gl the code was compiled to object files and we could dump and find out which functions were called and defined in that particular file.
Since our project is huge and we do not use studio due to a lot of homemade preprocessing this tool would be very usefull.

Thanks
Reuben B.
Four Js
Posts: 1049


« Reply #1 on: February 15, 2016, 09:25:50 pm »

Before I joined 4Js, at the company I worked for we had some home made shell scripts that parsed the source overnight as part of the daily build/smoke test and generated that sort of information. grep ""^FUNCTION" *.4gl | cut -d " " -f2 | cut -d "("    gives you list of functions and then grep -n "function-name(" *.4gl tells you where it is called.  There was a bit more to it than that but it gets you nearly there.

Now I'd use Studio.  Just because you have a lot of homemade preprocessing does not stop you using Studio.  Studio is quite configurable and appropriate use of build rules, file types, you can mold Studio to fit round your existing development environment.  Then you will see the information you seek in the .4pwdb file once dependencies are created.  The content in this file is used for code structure https://4js.com/online_documentation/fjs-gst-manual-html/#c_gst_ce_code_structure_view.html and the dependency diagram/sequence diagram https://4js.com/online_documentation/fjs-gst-manual-html/#t_gst_tour_anaylzecode.html.  In theory, if you wanted to carry on with your existing development environment, just having Studio installed and configured, and a .4pw for your program, you could run gsmake at the command line using -generate-4pwdb https://4js.com/online_documentation/fjs-gst-manual-html/#c_gst_projectmgr_gsmake.html to build up .4pwdb

Otherwise make sure you have looked at the various command line options for fglcomp, fglrun.  (fglcomp -h, fglrun -h will list the public options).   fglrun -p will run your program and tell you what functions were actually called (along with the time spent in them), fglcomp --build-rdd will produce a file that contains info about structure of the program.  You maybe able to get the information you seek from that output.  Also if you have not looked inside a .42r, have a look using (octal dumps (od) and string dump (string)), it might give you info as to what functions are called within a program.

Hope that helps. 

Reuben




Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Rene S.
Four Js
Posts: 111


« Reply #2 on: February 16, 2016, 07:28:16 am »

Hello,
try the (undocumented) option -r (reassemble) of fglrun:

fglrun -r module.42m # prints the byte code human readable.
or run
fglrun -r module.42m | grep "^Function" # finds all functions defined in this module.

Important: this feature is undocumented and will remain undocumented: it has been developed to validate the result of the compiler.
Rene S.
Four Js
Posts: 111


« Reply #3 on: February 16, 2016, 07:31:25 am »

BTW: search for "Number of method-references". You'll see "what has been called from this module".
Carlos L.
Posts: 20


« Reply #4 on: February 16, 2016, 03:40:57 pm »

fglcomp -r is really what I was looking for!
Thanks for the help!
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines