In order to debug sbcl internals, I tried tracing sbcl internal packages.
For example I tried
(trace "SB-IMPL")
This causes a control stack overflow. I tried changing the control stack size startup option while starting up SBCL, but no change.
Alternatively, I also tried to modify the function using: (only snippet)
(setf (symbol-function s)
#'(lambda (&rest args)
;do something
;invoke original function
;do something more))
under do-all-symbols only for symbols belonging to packages specified.
Still I get the overflow error. The above code shows binding stack exhausted error. Probably someone can explain how to control binding stack size?
Alternatively, if someone can point to how to change the internal SBCL function definitions while they are compiled could also be great? I could use that trick to recompile SBCL from source in that case.
I think the problem here is that you are tracing functions (probably SB-IMPL::FLUSH-OUTPUT-BUFFER in particular) that are used in tracing itself. Something (the REPL) calls FLUSH-OUTPUT-BUFFER, which is traced, so trace tries to output some stuff, which calls FLUSH-OUTPUT-BUFFER, which is traced, so trace tries to output some stuff, which calls FLUSH-OUTPUT-BUFFER, which is traced....
Depending on what you are trying to trace, you may be able to accomplish your task by tracing those functions specifically instead of all of SB-IMPL.
If you really have to trace something too low-level to use trace, you might want to compile with the SB-SHOW feature enabled (have a look in base-target-features.lisp-expr and src/code/show.lisp). This can print out a lot low-level trace information.