Why does the typed argument (pointer to arc_buf_hdr_t) fail on the return probe? I wrote the following probes for the buf_hash_insert method: static arc_buf_hdr_t * buf_hash_insert(arc_buf_hdr_t *buf, kmutex_t **lockp); fbt:zfs:buf_hash_insert:entry /args[0]->b_datacnt > 1/ { printf("b_datacnt=%d", args[0]->b_datacnt); } fbt:zfs:buf_hash_insert:return /args[0]->b_datacnt > 1/ { } The entry probe works as expected. However, the return probe?s qualifier ?args[0]->b_datacnt > 1? causes an ?operator -> must be applied to a pointer? error message. So, I changed the return probe?s qualifier to use a cast instead of a typed argument as shown below: fbt:zfs:buf_hash_insert:return /((arc_buf_hdr_t*)arg0)->b_datacnt > 1/ { } The above probe loads without error, but I get an ?invalid alignment (0x28a) in predicate at DIF offset 24? error message when the probe is triggered. I?ve read the thread ?args[] typed to ''struct timeval'' leads to invalid alignment error? located at http://jp.opensolaris.org/jive/thread.jspa?messageID=47002 . I understand that some small structures are passed as multiple arguments instead of as a pointer. This is confusing. arc_buf_hdt_t is not really a small structure, and what does this do to the position of the probe''s subsequent arguments? Why does the typed argument work as expected for the entry probe and not the return probe? If I want to match entry and return probes, I need to use the same qualifier on both, but this seems to be impossible. Can anyone give me a suggestion on how to make this work? -- This message posted from opensolaris.org
On Wed, 27 Feb 2008, J Duff wrote:> Why does the typed argument (pointer to arc_buf_hdr_t) fail on the return probe? > > I wrote the following probes for the buf_hash_insert method: > > static arc_buf_hdr_t * > buf_hash_insert(arc_buf_hdr_t *buf, kmutex_t **lockp); > > fbt:zfs:buf_hash_insert:entry > /args[0]->b_datacnt > 1/ > { > printf("b_datacnt=%d", args[0]->b_datacnt); > } > > fbt:zfs:buf_hash_insert:return > /args[0]->b_datacnt > 1/ > { > }http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_Cheatsheets_Checklists For function entry probes, the arguments array will provide access to all function input arguments. For function return probes, the arguments array provides the return offset in args[0], and the return value of the function in args[1]. You don''t really want to be using args[0] here do you? -- Dave
Great thanks for the link to Cheatsheets. It''s quite helpful. If the return probe''s arg[0] is the return offset and its arg[1] is the return value, you are correct. I don''t want to use it. ...But, how do I qualify the return probe so that I end up with matching pairs of entries and returns? Duff -- This message posted from opensolaris.org
J Duff wrote:> Great thanks for the link to Cheatsheets. It''s quite helpful. > > how do I qualify the return probe so that I end up with matching pairs of entries and returns?use a self-> variable (thread-local) to hold something specific to the call, or, if the thread itself is specific enough, just a boolean. This is perhaps the most-used idiom in D. (I don''t have enough context from your message to know what your specific probe is, so I can''t advise you specifically.)