Page 4 of 13

Re: Autoloader for custom "Game" plug-ins

Posted: Fri Jun 25, 2010 2:09 pm
by manga00
tusko wrote:The script. I called it gdbtrick.sh

Configure and try to execute it using telnet. Let me know what happens...

Code: Select all

#!/bin/sh

### begin configure me

# gdb_binary: where your gdb binary resides
gdb_binary=/dtv/usb/sda1/gdb

# gdb_commands: this is a temporary file where gdb commands are stored
gdb_commands=/dtv/usb/sda1/gdbtrick.gdb

# gdb_delay: gdb will be scheduled to run after $gdb_delay seconds
#            this is for letting exeDSP to settle down at TV startup
gdb_delay=30

# libraries: absolute path of libraries to be loaded
#            there can be several separated by commas (no spaces!!)
#            this script requires paths WITHOUT spaces AND commas
libraries=/dtv/usb/sda1/samygoPVR/loader.so, # add more libraries here

### end configure me

libraries=$(echo $libraries | sed 's/\,/ /')

exeDSP_PID=$(ps aux | grep exeDSP | grep -v grep | sed 's/[ ]*\([0-9]*\).*/\1/')
temp='attach '$exeDSP_PID'\n'

i=0
for l in $libraries
do 
   temp=$temp'call dlopen("'$l'", 2)\n'
   i=$(( i + 1 ))
   temp=$temp'call dlsym($'$i', "Game_Main")\n'
   i=$(( i + 1 ))
   l_dirname=$(echo $l | sed 's/[^\/]*$//')
   temp=$temp'call $'$i'("'$l_dirname'", 0)\n'
   i=$(( i + 1 ))
done
temp=$temp'detach\n'

echo -e 'The following commands:\n---\n'$temp'---\nwill be executed by '$gdb_binary' in '$gdb_delay' secs!!\n'

echo -e $temp >$gdb_commands

{ sleep $gdb_delay; $gdb_binary -batch -x $gdb_commands; } &
HI tusko,
I have a prob with your script. I have no value for exeDSP_PID, when i execute the command`s by hand is all fine.
can you take a look of

Code: Select all

exeDSP_PID=$(ps aux | grep exeDSP | grep -v grep | sed 's/[ ]*\([0-9]*\).*/\1/')
temp='attach '$exeDSP_PID'\n'
thanks

Re: Autoloader for custom "Game" plug-ins

Posted: Fri Jun 25, 2010 4:07 pm
by arris69
manga00 wrote:...

Code: Select all

exeDSP_PID=$(ps aux | grep exeDSP | grep -v grep | sed 's/[ ]*\([0-9]*\).*/\1/')
temp='attach '$exeDSP_PID'\n'
thanks
may a

Code: Select all

exeDSP_PID=$(pidof exeDSP)
is a bit simpler
hope just 1 instance of exeDSP is running ;-)

Re: Autoloader for custom "Game" plug-ins

Posted: Sat Jun 26, 2010 9:47 am
by arris69
tusko wrote:arris69: damn, you are right :-P, thanks I edited the script. By the way, I would like to avoid the 'sed' command completely and using pidof is a step in the right direction. There is still more 'sed', though. For example, when assigning l_dirname. Unfortunately, the obvious solution (using dirname shell command) does not work in my TV.
....
may so?

Code: Select all

#!/bin/sh

### begin configure me

# gdb_binary: where your gdb binary resides
gdb_binary=/dtv/usb/sda1/gdb

# gdb_commands: this is a temporary file where gdb commands are stored
gdb_commands=/dtv/usb/sda1/gdbtrick.gdb

# gdb_delay: gdb will be scheduled to run after $gdb_delay seconds
#            this is for letting exeDSP to settle down at TV startup
gdb_delay=30

# libraries: absolute path of libraries to be loaded
#            there can be several, separated spaces!!
#            this script requires paths WITHOUT spaces
libraries="/mtd_tlib/GGame/channelinfo/loader.so /mtd_tlib/GGame/avrfix2/load.so" # add more libraries here

### end configure me

exeDSP_PID=$(pidof exeDSP)
temp='attach '$exeDSP_PID'\n'

i=0
for l in $libraries
do
        if [ -e "$l" ] ;then
                temp=$temp'call dlopen("'$l'", 2)\n'
                let i++
                temp=$temp'call dlsym($'$i', "Game_Main")\n'
                let i++
                temp=$temp'call $'$i'("'${l%/*}/'", 0)\n'
                let i++
        fi
done
temp=$temp'detach\n'

echo -e 'The following commands:\n---\n'$temp'---\nwill be executed by '$gdb_binary' in '$gdb_delay' secs!!\n'

echo -e $temp >$gdb_commands

{ sleep $gdb_delay; $gdb_binary -batch -x $gdb_commands; } &