-
Notifications
You must be signed in to change notification settings - Fork 89
Semaphores for ocaml probes #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,7 +559,7 @@ let find_or_add_semaphore name = | |
match String.Map.find_opt name !probe_semaphores with | ||
| Some label -> label | ||
| None -> | ||
let sym = Compilenv.make_symbol (Some ("semaphore_"^name)) in | ||
let sym = "caml_probes_semaphore_"^name in | ||
probe_semaphores := String.Map.add name sym !probe_semaphores; | ||
sym | ||
|
||
|
@@ -944,7 +944,11 @@ let emit_instr fallthrough i = | |
semaphores are of type unsigned short. | ||
[1] https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation | ||
*) | ||
I.mov (addressing (Ibased(semaphore_sym, 0)) WORD i 0) (res16 i 0); | ||
(* OCaml has it's own semaphore, in addition to system tap, | ||
to control ocaml probe handlers independently from stap probe handlers. | ||
It is placed immediately after stap semaphore, and is the same | ||
size - hence offset 2. *) | ||
I.mov (addressing (Ibased(semaphore_sym, 2)) WORD i 0) (res16 i 0); | ||
(* If the semaphore is 0, then the result is 0, otherwise 1. *) | ||
I.cmp (int 0) (res16 i 0); | ||
I.set (cond (Iunsigned Cne)) (res8 i 0); | ||
|
@@ -1421,7 +1425,7 @@ let emit_probe_notes0 () = | |
D.qword (const 0) | ||
end; | ||
D.qword (ConstLabel semaphore_label); | ||
D.bytes "ocaml\000"; | ||
D.bytes "ocaml.1\000"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name is a bit mysterious There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, suggestions for a better name are most welcome! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Users will see these strings if they inspect probe notes using "readelf -n" or gdb's "info probes". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems ok for now. |
||
D.bytes (probe_name ^ "\000"); | ||
D.bytes (args ^ "\000"); | ||
def_label d; | ||
|
@@ -1448,9 +1452,11 @@ let emit_probe_notes0 () = | |
end; | ||
D.align 2; | ||
String.Map.iter (fun _ label -> | ||
D.global label; | ||
D.weak label; | ||
D.hidden label; | ||
_label label; | ||
D.word (const 0); | ||
D.word (const 0); (* for systemtap probes *) | ||
D.word (const 0); (* for ocaml probes *) | ||
add_def_symbol label) | ||
!probe_semaphores | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this is offset 2 not 1. Is this value not in units of 8-byte words?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The units are bytes, and the size of the new semaphore is set to be the same as the size of stap semaphores, so the code for reading them remains unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, and the semaphores are 16-bit quantities. ok.