An easy way to debug the julia code in base/

Hi, Julian expert people.

What is the easiest way to debug a modification to the source code in julia/base if I change the Julia code in base/string/?

Specifically, I would like to know how to easily debugging way the modifications if I change the source code written in Julia code in base/string/.

I want to avoid a rebuild if possible.

And I would be happy if I could debug code written in C without a full build as well.

If you have any good documentation or idea, please let me know.

My PC is very slow and the full build takes a long time.
I take a shower every time but it doesn’t get done in that time.

My environment is JuliaPro 1.4.2-1 on Mac and 1.4.2 with terminal command.

Best regards.

2 Likes

Use Revise for Base.

5 Likes

Dear Tamas_Papp,

Thank you very much for you reply.

Revise.jl is looks good for debagging.

I will try to understand and enjoy modification.

Thanks a lot.

4 Likes

Dear Tamas_Papp,

It worked perfectly.

  1. pkg> add Revise
  2. using Revise
  3. Copy target source code from GitHub to my working folder.
  4. modify
  5. includet(target.jl)
  6. set break point.
  7. debug run from test.jl for call.

The debugger worked perfectly.

According to the documents, ‘includet(’ is quick-and-dirty development way.
But this is enough for me. :star_struck:

Thank you for your kind post.

4 Likes

Personally, I find it easier to reason about changes entirely at the REPL. Just @eval Base begin ... end is a great way to interactively override small things and it makes the history much more tractable.

11 Likes

Dear mbauman,

Thank you for your advice.

I tried method of @eval.
I feel that This is a very easy way to make a prototype module for enhancement.

I will try to understand and utilize it more.

Thanks a lot.

2 Likes

Just for completeness, what I usually do is just Revise.track(Base), which automatically detects and applies all changes you made to Base and also lets you make changes during a running Julia session.

4 Likes

Great.
I tried this way. This is very powerful modify and trace technic.

thanks a lot.

One thing to be aware of when modifying Base is that not everything that works when modifying it after you have a fully working Julia will actually work when building Julia. That is because Julia is built incrementally in itself, ie bootstrapped, and not all functionality that will eventually be available is always available when your code is evaluated during that process. For example, there are files in base that are evaluated so early that integer arithmetic doesn’t yet work, so you can’t use a for loop to define a series of definitions concisely and instead have to simply spell out all the cases. To deal with this, a good approach is to get the change you’re implementing working in the REPL and once it works, try recompiling Julia and see what breaks—expecting that something very well might break. If something breaks it will be because it uses some functionality at compile time that doesn’t yet exist, which can be fixed by moving around the order of definitions. This can be quite tedious but isn’t fundamentally hard. You can move the text of the definitions to a later file or move the order of files in Base.jl.

11 Likes

Dear Stefankarpinsk,

Thank you for your kind advice.

I’m interested in the inner workings of Julia.

It’s much more fun than just reading the source code.

When I create a module in the future that could contribute to the community in some way, I’ll do a number of thorough tests.

Thanks a lot.

2 Likes

A post was split to a new topic: What makes Julia dynamic (easy) and as fast as C?

Can you present a specific exampl ? I cannot get how to implement it in details.