Sign in to follow this  
Followers 0
MvGulik

Function recursion scanning (?)

6 posts in this topic

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



#2 ·  Posted (edited)

... 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

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

#4 ·  Posted (edited)

... 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

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

#6 ·  Posted (edited)

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  
Followers 0

  • 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 and slices of them, and even DLL structs. 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.
      #include cDebug.au3 at the top of your script.
      It is fully documented in cDebug.pdf   .  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.
      A teaser
      This script:
      #include "CDebug.au3" Local $aCats[2][3] = [['jack','black',3],['suki','grey',4]] 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
      1.0.0    First release to AutoIt forum
      1.1.0    Added _GuiDebug()
      1.2.0    _GetCtrlFontSize() determines font name and point size; internal functions renamed to _cDebug_*
      1.3.0    Added subtypes so now handles all Autoit subtypes; improved layout of results; fixed 2 bugs in Slices
      1.4.0    Added display only a limited number of elements; added __ChangeElementLimitForDebug and the Change element limit button; detects more user errors in Slices
      1.4.1    For binary variables with long values, shortened displayed value
      1.4.2    Fixed Copy Data button not disabling after copying to Clipboard
      1.4.3    Removed false detection of user error
      1.5.0    Added ability to display structs with a tag specified, and without
      1.5.1    Commented out call to _cDebug_Example(); Incorporated _StringSize() so no more #include "StringSize.au3"
      1.5.2    Added reporting struct, endstruct and align; fixed string value containing single quote mark
      1.5.3    Removed duplicate #include-once at line 1534
      1.6.0    Changed the default for value parameters; added info messages when comparing a user tag and a determined tag; improved logic for comparing tags
      1.6.1    Various small bug fixes; Note re detection now per main UDF call was per name-value pair; parent GUIs now lose focus properly
      1.6.2    Removed ! From _cDebug_Example()
      Acknowledgements
      Melba23, Kafu, ProgAndy, jchd
    • c.haslam
      By c.haslam
      The cDebug script 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 . 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 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.
      It is fully documented. During development of new features, the current version is used to debug the upcoming version, so there is much testing.
      Get the latest version at https://www.autoitscript.com/forum/files/file/454-cdebugau3/

       
         
    • 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  
    • aiter
      By aiter
      Anyone knows how to download the graphical autoitdebugger
      The download appears to have upped and died.
      Or an alternative?