Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cppdap
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
cppdap
Commits
1e5ec3e4
Commit
1e5ec3e4
authored
Jun 29, 2020
by
Ben Clayton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change dap::integer backing type to int64_t
`int` may be < 64 bit, and some dap protocols use a 64 bit integer. Chnage to `int64_t` to be consistent. Fixes: #45
parent
7b02b9f7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
hello_debugger.cpp
examples/hello_debugger.cpp
+10
-10
types.h
include/dap/types.h
+6
-4
session.cpp
src/session.cpp
+3
-2
No files found.
examples/hello_debugger.cpp
View file @
1e5ec3e4
...
@@ -50,7 +50,7 @@ You can set breakpoints, and single line step.
...
@@ -50,7 +50,7 @@ You can set breakpoints, and single line step.
You may also notice that the locals contains a single variable for the currently executing line number.)"
;
You may also notice that the locals contains a single variable for the currently executing line number.)"
;
// Total number of newlines in source.
// Total number of newlines in source.
constexpr
int
numSourceLines
=
7
;
constexpr
int
64_t
numSourceLines
=
7
;
// Debugger holds the dummy debugger state and fires events to the EventHandler
// Debugger holds the dummy debugger state and fires events to the EventHandler
// passed to the constructor.
// passed to the constructor.
...
@@ -68,7 +68,7 @@ class Debugger {
...
@@ -68,7 +68,7 @@ class Debugger {
void
pause
();
void
pause
();
// currentLine() returns the currently executing line number.
// currentLine() returns the currently executing line number.
int
currentLine
();
int
64_t
currentLine
();
// stepForward() instructs the debugger to step forward one line.
// stepForward() instructs the debugger to step forward one line.
void
stepForward
();
void
stepForward
();
...
@@ -77,21 +77,21 @@ class Debugger {
...
@@ -77,21 +77,21 @@ class Debugger {
void
clearBreakpoints
();
void
clearBreakpoints
();
// addBreakpoint() sets a new breakpoint on the given line.
// addBreakpoint() sets a new breakpoint on the given line.
void
addBreakpoint
(
int
line
);
void
addBreakpoint
(
int
64_t
line
);
private
:
private
:
EventHandler
onEvent
;
EventHandler
onEvent
;
std
::
mutex
mutex
;
std
::
mutex
mutex
;
int
line
=
1
;
int
64_t
line
=
1
;
std
::
unordered_set
<
int
>
breakpoints
;
std
::
unordered_set
<
int
64_t
>
breakpoints
;
};
};
Debugger
::
Debugger
(
const
EventHandler
&
onEvent
)
:
onEvent
(
onEvent
)
{}
Debugger
::
Debugger
(
const
EventHandler
&
onEvent
)
:
onEvent
(
onEvent
)
{}
void
Debugger
::
run
()
{
void
Debugger
::
run
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
for
(
int
i
=
0
;
i
<
numSourceLines
;
i
++
)
{
for
(
int
64_t
i
=
0
;
i
<
numSourceLines
;
i
++
)
{
auto
l
=
((
line
+
i
)
%
numSourceLines
)
+
1
;
int64_t
l
=
((
line
+
i
)
%
numSourceLines
)
+
1
;
if
(
breakpoints
.
count
(
l
))
{
if
(
breakpoints
.
count
(
l
))
{
line
=
l
;
line
=
l
;
lock
.
unlock
();
lock
.
unlock
();
...
@@ -105,7 +105,7 @@ void Debugger::pause() {
...
@@ -105,7 +105,7 @@ void Debugger::pause() {
onEvent
(
Event
::
Paused
);
onEvent
(
Event
::
Paused
);
}
}
int
Debugger
::
currentLine
()
{
int
64_t
Debugger
::
currentLine
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
return
line
;
return
line
;
}
}
...
@@ -122,7 +122,7 @@ void Debugger::clearBreakpoints() {
...
@@ -122,7 +122,7 @@ void Debugger::clearBreakpoints() {
this
->
breakpoints
.
clear
();
this
->
breakpoints
.
clear
();
}
}
void
Debugger
::
addBreakpoint
(
int
l
)
{
void
Debugger
::
addBreakpoint
(
int
64_t
l
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
this
->
breakpoints
.
emplace
(
l
);
this
->
breakpoints
.
emplace
(
l
);
}
}
...
@@ -156,7 +156,7 @@ void Event::fire() {
...
@@ -156,7 +156,7 @@ void Event::fire() {
}
// anonymous namespace
}
// anonymous namespace
// main() entry point to the DAP server.
// main() entry point to the DAP server.
int
main
(
int
,
char
*
[])
{
int
main
(
int
,
char
*
[])
{
#ifdef OS_WINDOWS
#ifdef OS_WINDOWS
// Change stdin & stdout from text mode to binary mode.
// Change stdin & stdout from text mode to binary mode.
// This ensures sequences of \r\n are not changed to \n.
// This ensures sequences of \r\n are not changed to \n.
...
...
include/dap/types.h
View file @
1e5ec3e4
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <stdint.h>
namespace
dap
{
namespace
dap
{
// string is a sequence of characters.
// string is a sequence of characters.
...
@@ -52,9 +54,9 @@ class boolean {
...
@@ -52,9 +54,9 @@ class boolean {
class
integer
{
class
integer
{
public
:
public
:
inline
integer
()
:
val
(
0
)
{}
inline
integer
()
:
val
(
0
)
{}
inline
integer
(
int
i
)
:
val
(
i
)
{}
inline
integer
(
int
64_t
i
)
:
val
(
i
)
{}
inline
operator
int
()
const
{
return
val
;
}
inline
operator
int
64_t
()
const
{
return
val
;
}
inline
integer
&
operator
=
(
int
i
)
{
inline
integer
&
operator
=
(
int
64_t
i
)
{
val
=
i
;
val
=
i
;
return
*
this
;
return
*
this
;
}
}
...
@@ -65,7 +67,7 @@ class integer {
...
@@ -65,7 +67,7 @@ class integer {
}
}
private
:
private
:
int
val
;
int
64_t
val
;
};
};
// number holds a 64-bit floating point number.
// number holds a 64-bit floating point number.
...
...
src/session.cpp
View file @
1e5ec3e4
...
@@ -167,7 +167,8 @@ class Impl : public dap::Session {
...
@@ -167,7 +167,8 @@ class Impl : public dap::Session {
}
}
}
}
std
::
pair
<
const
dap
::
TypeInfo
*
,
GenericResponseHandler
>
response
(
int
seq
)
{
std
::
pair
<
const
dap
::
TypeInfo
*
,
GenericResponseHandler
>
response
(
int64_t
seq
)
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
responseMutex
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
responseMutex
);
auto
responseIt
=
responseMap
.
find
(
seq
);
auto
responseIt
=
responseMap
.
find
(
seq
);
if
(
responseIt
==
responseMap
.
end
())
{
if
(
responseIt
==
responseMap
.
end
())
{
...
@@ -252,7 +253,7 @@ class Impl : public dap::Session {
...
@@ -252,7 +253,7 @@ class Impl : public dap::Session {
requestMap
;
requestMap
;
std
::
mutex
responseMutex
;
std
::
mutex
responseMutex
;
std
::
unordered_map
<
int
,
std
::
unordered_map
<
int
64_t
,
std
::
pair
<
const
dap
::
TypeInfo
*
,
GenericResponseHandler
>>
std
::
pair
<
const
dap
::
TypeInfo
*
,
GenericResponseHandler
>>
responseMap
;
responseMap
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment