Operating System - HP-UX
1752636 Members
5842 Online
108788 Solutions
New Discussion юеВ

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

 
SOLVED
Go to solution
Shaan_2
Occasional Advisor

" ttrace related stuff ": Printing syscall arguments using tts_scarg.

Hi,
ttstate_t structure will give the arguments list of the syscall which is being called by the process.
I am trying to print the arguments of open syscall, following statement is used to print :
[code]printf("\nOpen args : %s\n", (char *) stp->tts_scarg[0]/* first arg of open syscall */);
[/code]
following is the command to run my tracer :
[command]
./tracer make
[/command]

[output]

Open args :

Open args : /opt/graphics/OpenGL/lib/libogltls.sl

Open args : ding

Open args : /usr/lib/libdld.2

Open args : /usr/lib/libc.2

Open args :

Open args :

Open args : .

Open args : ..

Open args : ..

Open args : ..

Open args : ..

Open args : ERROR: mmap failed for dld
Memory fault(coredump)
[/output]

anybody has idea what is the problem here?
even when I go to debug mode and try to print the argument with the given address, its saying "error accessing memory address : bad address"

any help would be greatly appreciated.

~Shaan
9 REPLIES 9
Steven E. Protter
Exalted Contributor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

Shalom,

is SHLIB_PATH set properly before this run?

Does it include /usr/lib ?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dennis Handly
Acclaimed Contributor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

>I am trying to print the arguments of open syscall
>try to print the argument with the given address

You should also print out the hex address of the string (%p) so you check if you have a bogus address.
Shaan_2
Occasional Advisor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

Thanks a lot steven for quick reply .

here is the content of SHLIB_PATH
$ echo $SHLIB_PATH
/usr/lib

and run the tracer program but no luck :(
Hit with same problem ...
Any inputs on the same will help me a lot ..

Waiting for your reply
Shaan
Dennis Handly
Acclaimed Contributor
Solution

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

I would hope it is obvious, the addresses you get for syscall arguments are in the traced process' address space. You'll need to fetch MAXPATHLEN bytes for each to print them out.
Shaan_2
Occasional Advisor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

Hi Dennis,
Few of those are printing, and I am not able to access the memory for the one which I got core dump.
"Open args : ERROR: mmap failed for dld"
1) In the above statement, I expect the error message should come through "write" syscall not from "open".
2) After the above statement, we are getting core dump(Observe the error message: mmap failed for dld). I am suspecting something happening wrong with mmap, because of this we are trying to access bad address.
I am not sure, just a guess :)

~Shaan
Dennis Handly
Acclaimed Contributor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

>Few of those are printing

These are illusions, I would assume none are printing correctly. Use a real tool, tusc, to compare.
Shaan_2
Occasional Advisor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

Hi Dennis,
>>I would hope it is obvious, the addresses >>you get for syscall arguments are in the >>traced process' address space. You'll need >>to fetch MAXPATHLEN bytes for each to
>>print them out.

You are right, thanks for your reply!!! At the very first time I didn't realize this, and I thought I can access the content with the given address directly (we can't do this, because we cannot access kernel space directly). So we need to use ttrace again to get the content of the given address.
Finally its working fine!!!
Thanks a lot to everyone replied for this thread!!! :-)

~Shaan.
Dennis Handly
Acclaimed Contributor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

>we can't do this, because we cannot access kernel space directly

This isn't in kernel space, it is in the other process' space. You would need to to be in ring 0 to set the space/region register and the PID.
Shaan_2
Occasional Advisor

Re: " ttrace related stuff ": Printing syscall arguments using tts_scarg.

>> This isn't in kernel space, it is in the other process' space.

Yup, its in other process space.

~Shaan.