• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 ... 15 16 17 18 19 ... 115 Next »

Using the Profiler to find specific function calls
View New Posts | View Today's Posts

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
Using the Profiler to find specific function calls
06-20-2018, 06:37 AM (This post was last modified: 06-21-2018, 12:36 AM by One More Try.)
#1
One More Try Offline
Posting Freak
*****
Posts: 876
Threads: 22
Joined: Dec 2014
I realized you can difference two outputs from the profiler to find functions being called at a specific time. Sometimes this will lead to quickly finding the code you're looking for.  I'm curious if anyone else does this or something similar? Is there an easier way than using the profiler? Does anyone else want to use this technique?

Here's a short guide if you don't know how to difference outputs:

Guide: (Show Spoiler)
1. Start Dolphin WX, because profiler isn't in QT.

2. Choose a reference area in the game, where the code shouldn't be running, but is similar to what you want. (i.e. If you want to look for a menu/UI animation, try to be in the menu while the animation isn't happening for the baseline reference)

3. Select Profile -> Profile Blocks (menu item at the top), run for about 10 seconds or longer if you can, then choose Write to profile.txt

4. Copy all the text and paste it into a spreadsheet. (paste special, unformatted text, separated by TAB)
4b. You can delete all columns except the symbol names (column 2). This is the Reference column. Put it in Column B

5. Go back to the game, close the profile.txt and unpause the game.

6. With profile blocks still ON, try to make the desired code run (make the animation happen). Then immediately Write to profile.txt again.

7. Repeat step 4. This is the Target column. Put it in Column A.

----

At this point you have two columns of recordings of what code was running at each time, listed by symbol name. So now you just need to remove duplicates from the Target column.  There are many ways to do this, so if you know how - just do it your way. Otherwise here's the excel spreadsheet way. It's a little convoluted, but since we're already in a spreadsheet....

There will be duplicates inside each column individually that we need to deal with.

1a. Select Column A and Data -> Standard Filter. Choose "Not Empty" in the top right box. In options select "No Duplicates" "Copy results to" and "Keep filter" and click the bottom text box to select a place to save the output. You should be able to click A1 and have it autofill to something like: $Sheet1.$A$1  this will overwrite the A1 data with duplicates removed.
1b. Do sort -> Ascending on the column.
1c. Repeat for Column B and choose B1 at the end to overwrite.

2. Then we paste an already-made function into C1:

=IF(ISERROR(VLOOKUP(A1,B$1:B$10000,1,0)),A1,"")

Depending on version commas may need to be semicolons.
This means search for A in B1 to B10000 (larger than it needs to be to make sure we don't underestimate B's size, some versions can take B:B) and if not present then output A.  
NOTE: ? ~ and * will break this if present in the columns. Do a find - replace all for these characters and replace them with nothing/blank if needed.

2b. Double click the bottom right corner of C1 to autofill the code into the rest of Column C. Most boxes in C should be blank.

Then we copy C to text

3. Select column C and copy. Then select column D and paste special -> text only (or text and numbers). This copies the output rather than the function we used.

4. Finally we just need to cleanup the output. Repeat 1a and 1b on this new output column D. I hope you know how to spreadsheet or else that was probably a bit painful.

-----

Alternatively, if you know how to use something like notepad++, then use that to sort and remove duplicates from each column individually. Then copy/paste the columns together such that you get Target (Col A) on top of Reference (Col B). Then Find + Replace with Regex enabled -> Find:  (^.*$)\v(?=(.*\v)*\1$)  Replace: (nothing). Then you're done. The Unique functions that ran during Target will be on top. My regex could probably be improved a bit and not all text editors will accept that specific line.


/edit I remembered how to regex. No sorting or duplication removal required. Just paste the Target column, put QQQQ below it, then paste the Reference column below that. Such that:
Target Column
QQQQ
Reference Column

Then you can regex find: (?s)^([^\n\r]+)$[\n\r]*(.*QQQQ.*?^\1$)
Replace: \2
and it should delete all instances of duplicates in the Target column that are shared between the two columns, but it'll ignore duplicates inside an individual group.


I tested this in a few places, and it was able to quickly pull an animation timer function up.  I also tried it with jumping a character and not moving otherwise, but there was too much output - I probably should have ran around for the reference. It seems quite useful in controllable cases.
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode