View Bug Activity | Format For Printing
The following script should pass: probe foobar ? , never { } with the foobar part silently skipped (since it's optional).
Created an attachment (id=3909) patch to suspend the error Simple example: $stap -p2 -e 'probe foobar ?, foobar1 !, never { }' WARNING: side-effect-free probe 'probe_1390': keyword at <input>:1:1 source: probe foobar ?, foobar1 !, never { } ^ # probes never /* <- foobar?,foobar1!,never */
If it's that simple, great! Could you commit please, with a test case?
See commit ed82b7c902d6a2e26452ec51c9cdb9665dbf9e97
Thanks for that. I see a slightly different variant of this that seems a bit harder to solve (at least, I didn't immediately see how it could be solved, maybe someone else does see an easy solution): $ stap -e 'probe process("/does/not/exist").function("main") ?, never { log ("process does exist"); }' semantic error: libdwfl failure (missing process /does/not/exist i686 debuginfo): No such file or directory while resolving probe point process("/does/not/exist").function("main")? This probably needs a similar change in setup_user(), but we don't have the probe location at that point, and setup_user() is called in a couple of different situations (not all of which can silently fail).
Created an attachment (id=3922) patch for user space target With the 2nd part patch, the example output: $stap -p2 -e 'probe process("/do/not/exist").function("main")?,process("/not/exist").function("main")!, begin { log("process does exist"); }' # functions log:unknown (msg:string) # probes begin /* <- process("/do/not/exist").function("main")?,process("/not/exist").function("main")!,begin */ $ stap -p2 -e 'probe process("./stap").function("no such")?, begin { log("process does exist"); }' # functions log:unknown (msg:string) # probes begin /* <- process("./stap").function("no such")?,begin */
Wenji, it seems to me that putting the try/catch one level higher -- perhaps into derive_probes() itself around the find_and_build() call -- would accomplish this for other probe types too.
Created an attachment (id=3923) Updated patch This patch will tolerate the failure for optional probe in derive_probe as Frank mentioned in comment #6. Seems all the probe types can be covered. $ stap -p2 -ue 'probe foo?, process("/do/not/exist").function("main") !, kernel.mark("no such mark") ?, kernel.trace("no trace") !, process.foo ?, kernel.statement("no statement") !, module("no mod").function("*") ?, begin {}' # probes begin /* <- foo?,process("/do/not/exist").function("main")!,kernel.mark("no such mark")?,kernel.trace("no trace")!,process.foo?,kernel.statement("no statement")!,module("no mod").function("*")?,begin */
Right, that last one looks almost 100% right; you can commit it. I'd follow up with a bit of cleanup that fixes the bug that loc->optional can get its old_loc_opt value forgotten in case of an exception. Plus I'd prefer to avoid replicating the find_and_build call and instead put the if(optional) check into a catch() block: try { ... } catch (...) { if(!optional) throw; ... }
done, thanks