Jump to content
Sign in to follow this  
MvGulik

Function recursion scanning (?)

Recommended Posts

MvGulik

Just thinking/working on some source code recursion scanner. (nothing fancy, just a basic potential problem locator/scanner)

But I'm kinda at a loss at finding a nice or good way go about is.

Steps that passed my mind.

- Find all function(definitions) names. [working]

- Get hold of function code. (from full source) [working]

- Scan function code for calls to other function. [initial scan: working]

At this point I got array(s) with:

- User-function(def) names.

- User-function(unique) call count from that function. (+names of those calls)

Here is where I kinda run out of ideas. :mellow:

Probably just need some more time to come up with something ...


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
MvGulik

... almost done with initial working version by the looks of it. :mellow:

Mmm, If you like me to test run it on your code. Prep link, to source, in zip. (unless its some small code case.)

(normal function calls support only. So 'OtherFunction' in (for example) AdlibRegister("OtherFunction") are ignored.)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
monoscout999

So... you can search the function in the script, but you can not find the function called inside the function?... the /striponly parameter of the offucscator will find all the function used and put it in the script, maybe you can look the way that the ofuscator do his things to find out that.

Share this post


Link to post
Share on other sites
MvGulik

... but you can not find the function called inside the function?

No silly. :mellow:

I just did not spend any time on scanning for function call's that are made from things like GUICtrlSetOnEvent(<CTRL-ID>, "function") or AdlibRegister("function").

When things are working ok, adding that part should not be a problem. But its currently not a priority to me. (ergo: not supported (yet))

---

But, yea ... description of the function call type's I was revering to was truly unclear.

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
monoscout999

Sorry but my english in not very good and sometimes i can not undertand the meaning :S can you be more clear?

Share this post


Link to post
Share on other sites
MvGulik

Not sure if 'I' can be more clearer ... trying anyway.

The code target(idea) is to look for possible/potential function call paths that can be taken inside a given code source.

With the initial idea to detect/locate function-call recursion/loops, spanning multiple functions. But I imaging the data might also be used for other things. Like creation a flow-chart displaying the function links ...

But I suck at the data management that is involved with tree-like data collections.

So the last part is somewhat the core of the OP question.

Example: (from a previous test run.)

Paths found.

A>B1>C1:[END]
A>B1>C2>C1:[END]
A>B2>D1:[END]
A>B2>D2>D1:[END]
A>B2>D3>D2>D1:[END]
Based on the following test-code setup.
Func A()
    B1()
    B2()
EndFunc
Func B1()
    C1()
    C2()
EndFunc
Func B2()
    D1()
    D2()
    D3()
EndFunc
Func C1()
    ;; terminator.
EndFunc
Func C2()
    C1()
EndFunc
Func D1()
    ;; terminator.
EndFunc
Func D2()
    D1()
EndFunc
Func D3()
    D2()
EndFunc

- Currently trying to get rid of the issues that surfaced when test running it on some real source codes.

---

Got tangled up in the data management I used ... need to take a step back and take a other look at it. (progress on hold)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • c.haslam
      By c.haslam
      cDebug.au3 includes four main debugging UDFs: _GuiDebug(), _ConsDebug(), _ClipDebug() and _FormatValsForDebug(). They all dump the values of all AutoIt subtypes and expressions, in a structured manner, including nested arrays (up to 3 dimensions) and slices of them, and even DLL structs and maps. It is an alternative to a graphical debugger, offering GUI output.
      The format for calling the UDFs has been designed to make coding a call as convenient and fast as possible, minimizing coding effort and the chances of errors: the $name argument is often the same as the variables arguments, enclosed in quote marks.
      For DLL structures, if you specify a tag, cDebug checks for differences between it and what it detects. If you only specify a structure variable, it can report the structure it detects, with the values of elements.
      It does much more than MsgBox(), ConsoleWrite() and _ArrayDisplay(), in a definitely user-friendly manner, and does its best to avoid hiding your code in SciTE.
      #include cDebug no maps.au3 or cDebug.au3 at the top of your script. If you #include cDebug.au3 (the version with maps)  #include #AutoIt3Wrapper_Version=B before #include cDebug.au3
      It is fully documented in cDebug.pdf   .  During debugging and development of new features, the current version is used to debug the upcoming version, so there is much testing, even so  bugs are always possible, particularly in new features, such as reporting elements of maps whose keys match a regular expression. Bug reports and suggestions are welcome.
      These UDFs have been in regular use for some years.
      Because when cDebug was developed, maps were a use at your own risk feature, there are two streams of cDebug:
      cDebug.au3 reports maps, so to use it you must be running a version of AutoIt that supports maps, e.g. 3.3.15.0, and #include cDebug.au3 cDebug no maps.au3 does not report maps, so you can be running any recent version of AutoIt, e.g. 3.3.14.5, and #include cDebug no maps.au3 The only difference between the two streams is that map-reporting code is commented out in cDebug no maps.au3 .
      A teaser
      This script:
      #AutoIt3Wrapper_Version=B ; beta 3.3.15.0 or greater is mandatory for cDebug.au3 #include "cDebug.au3" Local $seasons[] $seasons.summer = 'May to September' $seasons.spring = 'April' $seasons.fall = 'October to November' $seasons.winter = 'December to March' Local $aCats[3][3] = [['jack','black',3],['suki','grey',4],[$seasons,'','']] Local $i = 1 Local $tStruct = DllStructCreate('uint') DllStructSetData($tStruct,1,2018) _GuiDebug('At line '&@ScriptLineNumber,'$cats,jack is,$cats[..][$i],$i,hex,structure{uint}', _ $aCats,$aCats[0][2],$aCats,$i,Hex(-$i),$tstruct) produces:

       
      Edit history
      See documentation PDF
      Acknowledgements
      Melba23, Kafu, ProgAndy, jchd
    • valdemar1977
      By valdemar1977
      Dbug is graphical debugger for AutoIt.
      Project started by @Heron in 2009 and now supported by @asdf8 and @valdemar1977.
      Features
      Debug the complete script or just parts of it Display run status (line number of currently executed function) GUI default always-on-top in the upper right corner for comfortable debugging WM_NOTIFY and WM_COMMAND hook to prevent interference with possible message handlers Display scope, type and value of variables, expressions, macro's and constants (global AND function local) Execute commands in an immediate window. Can be expressions, functions and assignments Detailed display of array, struct and object variables Dynamic display of variable value in the source code (under cursor) Array table viewer with ability to view the sub-arrays, the correct handling of macro @Error, @Extended and other changes OEM and ANSI console output Conditional breakpoints Saving settings and debugging state and much more... How to use
      Extract from downloaded archive _Dbug.au3 to your Autoit include dir Add #include <_Dbug.au3> in to your code and run code Before compile or buid comment or remove #include <_Dbug.au3> from your code
    • c.haslam
      By c.haslam
      cDebug.au3 includes four main debugging UDFs: _GuiDebug(), _ConsDebug(), _ClipDebug() and _FormatValsForDebug(). They all dump the values of all AutoIt subtypes and expressions, in a structured manner, including nested arrays and slices of them, and even DLL structs and maps. It is an alternative to a graphical debugger, offering GUI output.
      The format for calling the UDFs has been designed to make coding a call as convenient and fast as possible, minimizing coding effort and the chances of errors: the $name argument is often the same as the variables arguments, enclosed in quote marks.
      For DLL structures, if you specify a tag, cDebug checks for differences between it and what it detects. If you only specify a structure variable, it can report the structure it detects, with the values of elements.
      It does much more than MsgBox(), ConsoleWrite() and _ArrayDisplay(), in a definitely user-friendly manner, and does its best to avoid hiding your code in SciTE.
      It is fully documented.  During development of new features, the current version is used to debug the upcoming version, so there is much testing.
      These UDFs have been in regular use for some years. Suggestions and bug reports are most welcome.
      Get the latest version in Example Scripts
      #AutoIt3Wrapper_Version=B ; beta 3.3.15.0 or greater is mandatory for cDebug.au3, not for cDebug no maps.au3 #include "cDebug.au3" Local $seasons[] $seasons.summer = 'May to September' $seasons.spring = 'April' $seasons.fall = 'October to November' $seasons.winter = 'December to March' Local $aCats[3][3] = [['jack','black',3],['suki','grey',4],[$seasons,'','']] Local $i = 1 Local $tStruct = DllStructCreate('uint') DllStructSetData($tStruct,1,2018) _GuiDebug('At line '&@ScriptLineNumber,'$cats,jack is,$cats[..][$i],$i,hex,structure{uint}', _ $aCats,$aCats[0][2],$aCats,$i,Hex(-$i),$tstruct) reports

         
    • careca
      By careca
      Hi, having an issue with an application i did, seems to crash randomly, and can take hours to do so.
      Simply says in the error msgbox:
      AutoIt Error
      Line 16392 (whatevermyapppath.exe)
      Error: The requested action with this object has failed.
       
      Recent changes to the script include this:
       
      ObjGet("winmgmts:\\localhost\root\CIMV2") $oSelect_active_network_cards = $objWMIService.ExecQuery('SELECT ProductName FROM Win32_NetworkAdapter WHERE NetConnectionStatus = 2 OR NetConnectionStatus = 9', "WQL") For $oSelect_active_network_card In $oSelect_active_network_cards $Adapter = $oSelect_active_network_card.ProductName Next Is the only thing i can see that can be related to an "object"
      This lines run only once at the top of the script.
      When i run the script itself and wait for a crash, it doesn't, or at least yet i didn't.
      What do you think this error could be?
      UPDATE: Runing the script eventually output this:
      "C:\script.au3" (894) : ==> The requested action with this object has failed.:
      $oNetwork_cards = $objWMIService.ExecQuery('SELECT BytesReceivedPerSec, BytesSentPerSec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface WHERE name LIKE "' & $Adapter & '"', "WQL")
      $oNetwork_cards = $objWMIService^ ERROR
    • gononono64
      By gononono64
      Hey there,
      I'm having some issues quick-sorting my 2d array imported from a database. Im trying to sort the array based on the name that would be returned in $array[$n][2]. The code i posted works for smaller arrays but for some reason when i try to sort my imported array (around 9000 indexes), I get "Recursion level has been exceeded". I understand that this is maybe due to lack of returns but i couldn't find an ideal spot to stick em and again it seems to work with smaller bits of code. Could it be that 9000 is too much?
      I would normally just trial and error it until i figured it out but due to the length of time to load and buffer my array it's become too time consuming. Really I'm just hoping there is a quick fix that someone with more experience happens to know.
      Thank you
       
      ;;---------------------------------------------This Works---------------------------------------------------- Local $a[7][2] = [ _ ["1", "asdfashks"], _ ["2", "SubStrlkghjing1"], _ ["3", "jdfghjsergh"], _ ["4", "nertynert"], _ ["5", "cvbncvjkrt"], _ ["6", "avbncvjkrt"], _ ["7", "oytuoyuop"]] Quicksort($a,1,0,6) _ArrayDisplay($a) ;;------------------------------------------This Does Not--------------------------------------------------------- Quicksort($aLargeData, 1, 0, Ubound($aLargeData) - 1) _ArrayDisplay($aLargeData) ;;----------------------------------------Quicksort Function------------------------------------------------------ Func Quicksort(ByRef $Array, $secondIndex, $First, $Last) Local $pivot, $i, $j, $temp If $First < $Last Then $pivot = $First $i = $First $j = $Last While ($i < $j) While (StringCompare($Array[$i][$secondIndex], $Array[$pivot][$secondIndex]) <= 0) And ($i < $Last) $i += 1 WEnd While (StringCompare($Array[$j][$secondIndex], $Array[$pivot][$secondIndex]) > 0) $j -= 1 WEnd If ($i < $j) Then _ArraySwap($Array, $i, $j) _ArraySwap($Array,$pivot,$j) Quicksort($Array, $secondIndex, $First,$j-1) Quicksort($Array, $secondIndex, $j+1,$Last) WEnd EndIf EndFunc  
×