Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
e11ff79e
Commit
e11ff79e
authored
4 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[server] Logsource: also exports basename and dirname using prettified path.
parent
5e840bb7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/server/kernel_main.ml
+22
-8
22 additions, 8 deletions
src/plugins/server/kernel_main.ml
with
22 additions
and
8 deletions
src/plugins/server/kernel_main.ml
+
22
−
8
View file @
e11ff79e
...
@@ -82,23 +82,37 @@ module LogSource = Collection
...
@@ -82,23 +82,37 @@ module LogSource = Collection
(
struct
(
struct
type
t
=
Filepath
.
position
type
t
=
Filepath
.
position
let
syntax
=
Sy
.
publish
~
page
:
Data
.
page
~
name
:
"source"
let
synopsis
=
~
synopsis
:
(
Sy
.
record
[
"file"
,
Sy
.
string
;
"line"
,
Sy
.
int
])
Sy
.
record
[
"dir"
,
Sy
.
string
;
"base"
,
Sy
.
string
;
"file"
,
Sy
.
string
;
"line"
,
Sy
.
int
]
let
syntax
=
Sy
.
publish
~
page
:
Data
.
page
~
name
:
"source"
~
synopsis
~
descr
:
(
Md
.
plain
"Source file positions."
)
~
descr
:
(
Md
.
plain
"Source file positions."
)
~
details
:
Md
.([
Block
[
Text
(
plain
"The file path is normalized, \
~
details
:
Md
.([
Block
[
Text
(
plain
"The file path is normalized, \
and the line number starts at one."
)]])
and the line number starts at one."
)]])
()
()
let
to_json
p
=
`Assoc
[
let
to_json
p
=
let
path
=
Filepath
.(
Normalized
.
to_pretty_string
p
.
pos_path
)
in
`Assoc
[
"dir"
,
`String
(
Filename
.
dirname
path
)
;
"base"
,
`String
(
Filename
.
basename
path
)
;
"file"
,
`String
(
p
.
Filepath
.
pos_path
:>
string
)
;
"file"
,
`String
(
p
.
Filepath
.
pos_path
:>
string
)
;
"line"
,
`Int
p
.
Filepath
.
pos_lnum
;
"line"
,
`Int
p
.
Filepath
.
pos_lnum
;
]
]
let
of_json
=
function
let
of_json
js
=
|
`Assoc
[
"file"
,
`String
path
;
"line"
,
`Int
line
]
let
fail
()
=
failure_from_type_error
"Invalid source format"
js
in
|
`Assoc
[
"line"
,
`Int
line
;
"file"
,
`String
path
]
match
js
with
->
Log
.
source
~
file
:
(
Filepath
.
Normalized
.
of_string
path
)
~
line
|
`Assoc
assoc
->
|
js
->
failure_from_type_error
"Invalid source format"
js
begin
match
List
.
assoc
"file"
assoc
,
List
.
assoc
"line"
assoc
with
|
`String
path
,
`Int
line
->
Log
.
source
~
file
:
(
Filepath
.
Normalized
.
of_string
path
)
~
line
|
_
,
_
->
fail
()
|
exception
Not_found
->
fail
()
end
|
_
->
fail
()
end
)
end
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment