How do I stop tracing a function in clisp? - lisp

I've been tracing a function example with this call
(trace example)
and now I wish to stop tracing it,
how can I do this?

In common lisp it's as easy as calling untrace:
(untrace example)

Use the untrace.

Related

AppleScript pass expression into function to be re-evaluated repeatedly? (or: AppleScript handler with callback?)

I think the correct description for what I'm trying to do is be able to pass an expression or function/handler into another handler as a parameter/argument. Some code to be evaluated inside the receiving handler. Similar to Javascript callbacks, I think.
For example, something like this:
on waitFor(theConditionExpression)
timeout_start(5) -- start a 5 second timer
repeat until (theConditionExpression or timeout_isExpired())
delay 0.1
end repeat
return theConditionExpression
end waitFor
theConditionExpression should be some expression or function that evaluates to a boolean result.
not really relevant to the question, but just FYI, timeout_start(…) and timeout_isExpired() are two simple handlers I've written that do exactly what they say. (…start() doesn't return anything, …isExpired() returns a boolean).
Of course, typically if I pass in some boolean expression, it will evaluate that expression once, at the time I pass it in. But I want it to evaluate it every time it's referenced in the code inside the handler.
Some languages (not sure about AS) have some kind of eval() function that you can pass it some code as a string and it will execute that string as code. Theoretically that could solve this, but: (a) I don't know if AS has anything like that, but even if it does, (b) it's not desired for various reasons (performance, injection risks, etc.)
So I'm thinking something more like eg. JavaScript's ability to pass in a function (named or anonymous) as function parameter/argument that can be re-evaluated every iteration in a loop, etc. (eg. like the compareFn argument in JS's Array.sort(compareFn)).
Can AS do anything like this, and if so how?
Thanks!
I'm going to suggest (pro forma) that an AppleScript application with an on idle handler is generally a better solution for wait conditions than a repeat/delay loop. It's more efficient for the system, and doesn't freeze up the script. But that would involve reconceptualizing your script, and I'm not certain it would work in this case, given the way you formed the problem.
There's an old but good site called AppleScript Power Handlers that shows a bunch of nifty-neato tricks for sophisticated use of AppleScript handlers: passing handlers as values or parameters; creating Script Objects within handlers; making closures and constructors. I'm pretty sure the answer to your request is in there. aLikely you'll want to set up a bunch of handlers that serve as condition expressions, then pass them as parameters to the evaluating handler. Or maybe you'll want to set up a script object containing the condition handlers and call it as needed?
At any rate, see what you can do with it, and ask more specific questions if you run into problems.

How do I make a dtrace probe only execute when a certain function is in the stack

OK, this is "fun." I'm trying to figure out a weird thread timeout in a program, and need to look at what is happening when pthread_cond_timedwait() returns on Solaris... But... Only when a certain wrapper function or functions are being called (call them foo_lock and foo_unlock)...
I don't think I can use this answer because the function I'm looking at is at least 2-3 hops up in the stack: dtrace execute action only when the function returns to a specific module
One of the weird behaviors is that I see the right parent in tracing entry, but not exit, when I use a return probe... This could be a buffering issue though. Have to dig...

Is it possible to tail call eBPF codes that use different modes?

Is it possible to tail call eBPF codes that use different modes?
For example, if I coded a code that printk("hello world") using kprobe,
would I be able to tail call a XDP code afterwards or vice versa?
I programmed something on eBPF that uses a socket buffer and seems like when I try to tail call another code that uses kprobe, it doesn't load the program.
I wanted to tail call a code that uses XDP_PASS after using a BPF.SOCKET_FILTER mode but seems like tail call isn't working.
I've been trying to figure this out but I can't find any documentations regarding tail calling codes that use different modes :P
Thanks in advance!
No, it is not.
Have a look at kernel commit 04fd61ab36ec, which introduced tail calls: the comment in the first piece of code (in internal kernel header bpf.h), defining the struct bpf_array, sets a owner_prog_type member, and explains the following in a comment:
/* 'ownership' of prog_array is claimed by the first program that
* is going to use this map or by the first program which FD is stored
* in the map to make sure that all callers and callees have the same
* prog_type and JITed flag
*/
So once the program type associated with a BPF program array, used for tail calls, has been defined, it is not possible to use it with other program types. Which makes sense, since different program types work with different context (packet data VS traced function context VS ...), can use different helpers, have return functions with different meanings, necessitate different checks from the verifier, ... So it's hard to see how jumping from one type to another would work. How could you start with processing a network packet, and all of a sudden jump to a piece of code that is supposed to trace some internals of the kernel? :)
Note that it is also impossible to mix JIT-ed and non-JIT-ed programs, as indicated by the owner_jited of the struct.

how to runtimely show call stack in system verilog?

currently i use this way, when run time error happens, vcs will print call stack. It is very low effecient. Is there a better way?
function void anyFunctionIWouldLikeToSeeCallStack();
uvm_object a;
// a == null
a.print();
endfunction;
Cadence incisive (ncsim) has a $stacktrace system task that you can call. I wouldn't be surprised if the other vendors have a similar thing.
in VCS, it's $stack()
but it's only about 8 levels of the stack, and I don't think that's configurable
This is the kind of thing a simulator usually provides while setting breakpoints. After reaching a certain breakpoint your simulation will stop and you'll be able to run a simulator specific command to print the call stack or you'll have the call stack shown in some GUI window.
You'll have to look up in the VCS documentation how this is done exactly.
in RivieraPro, the command is $callstack(). There are a few options you can pass to configure the output.
See the documentation:
R-PRO: User's Guide | SystemVerilog Simulation | SystemVerilog Non-standard Extensions | $callstack system function

Calling same function from other two function

I am want to know if there is any way to call a same function from other two functions.
Like, say ..fucntion1 calls the MainFunction and then after function1 has done using the main function, function2 should call the MainFunction.
I have learned that this can be achieved using NSOperation queues ? But that is for asynchronous execution, I do not want that.
Is there any other way to achieve this ?
Any help will be truly appreciated, Thank you for your time. :)
You can use dispatch_sync(). It's part of the GCD API.
Use below method, it may helps you
[self performSelectorInBackground:(SEL) withObject:(id)]
Thank you all for your help ..! I ended up using delegates to solve this issue, I inserted a delegate callback, which gives me a callback after the first function completes using the MainFucntion and after getting the callback i called that MainFucntion using the secondMethod.