You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-15Lines changed: 18 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,24 @@ cd java-profiler
35
35
36
36
The resulting artifact will be in `ddprof-lib/build/libs/ddprof-<version>.jar`
37
37
38
+
#### Gritty details
39
+
To smoothen the absorption of the upstream changes, we are using parts of the upstream codebase in (mostly) vanilla form.
40
+
41
+
For this we have four new gradle tasks in `ddprof-lib/build.gradle`:
42
+
-`cloneAsyncProfiler` - clones the upstream repository into `ddprof-lib/build/async-profiler` using the commit lock specified in `gradle/ap-lock.properties`
43
+
-`copyUpstreamFiles` - copies the selected upstream source file into the `ddprof-lib/src/main/cpp-external` directory
44
+
-`patchStackFrame` and `patchStackWalker` - patches the upstream files if it is unavoidable to eg. pass the asan checks
45
+
46
+
Since the upstream code might not be 100% compatible with the current version of the project, we need to provide adapters.
47
+
The adapters are sharing the same file name as the upstream files but are suffixed with `_dd` (e.g. `arch_dd.h`).
48
+
49
+
In case we need to adapt a class from the upstream codebase, we put the adapter class into `ddprof` namespace to avoid
50
+
conflicts with the upstream code. This allows us to use the upstream code as-is while still providing the necessary modifications for our use case.
51
+
52
+
See [ddprof-lib/src/main/cpp/stackWalker_dd.h](ddprof-lib/src/main/cpp/stackWalker_dd.h) for an example of how we adapt the upstream code to fit our needs.
53
+
54
+
An example of this is the `ddprof-lib/src/main/cpp-external/stack_frame.cpp` file which is a modified version of the upstream `stack_frame.cpp` file.
For dd-trace-java you just need to set the `ddprof.jar` project property.
130
148
Eg. you can run the gradle build like this - ./gradlew clean -Pddprof.jar=file://<path-to-artifact.jar> :dd-java-agent:shadowJar` - which will result in a custom `dd-java-agent.jar` build containing your test version of Java profiler.
131
-
132
-
## Working with upstream
133
-
134
-
Although this project still shares the git history with the upstream the code structure is different. This makes it dificult to reliably
135
-
cherry-pick the upstream changes. To make this easier we have a script that will prepare the upstream repository
136
-
and add it as 'cherry' remote to this repository.
137
-
This way you can cherry-pick the changes from the upstream repository with (relative) ease.
138
-
139
-
```bash
140
-
./utils/init_cherrypick_repo.sh # you need to run this only once
141
-
142
-
./utils/cherry.sh <commit>
143
-
# ... resolve conflicts, if any
144
-
./utils/cherry.sh --continue # to commit the resolved conflicts
0 commit comments