Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
redox-os
kernel
Commits
7d9a33c6
Verified
Commit
7d9a33c6
authored
3 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Add debugger (dumps all kernel state)
parent
f92fe900
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/debugger.rs
+82
-0
82 additions, 0 deletions
src/debugger.rs
src/lib.rs
+3
-0
3 additions, 0 deletions
src/lib.rs
with
85 additions
and
0 deletions
src/debugger.rs
0 → 100644
+
82
−
0
View file @
7d9a33c6
// Super unsafe due to page table switching and raw pointers!
pub
unsafe
fn
debugger
()
{
println!
(
"DEBUGGER START"
);
println!
();
let
mut
active_table
=
crate
::
paging
::
ActivePageTable
::
new
(
crate
::
paging
::
TableKind
::
User
);
for
(
id
,
context_lock
)
in
crate
::
context
::
contexts
()
.iter
()
{
let
context
=
context_lock
.read
();
println!
(
"{}: {}"
,
(
*
id
)
.into
(),
context
.name
.read
());
// Switch to context page table to ensure syscall debug and stack dump will work
let
new_table
=
crate
::
paging
::
InactivePageTable
::
from_address
(
context
.arch
.get_page_utable
());
let
old_table
=
active_table
.switch
(
new_table
);
println!
(
"status: {:?}"
,
context
.status
);
if
!
context
.status_reason
.is_empty
()
{
println!
(
"reason: {}"
,
context
.status_reason
);
}
if
let
Some
((
a
,
b
,
c
,
d
,
e
,
f
))
=
context
.syscall
{
println!
(
"syscall: {}"
,
crate
::
syscall
::
debug
::
format_call
(
a
,
b
,
c
,
d
,
e
,
f
));
}
if
!
context
.image
.is_empty
()
{
println!
(
"image:"
);
for
shared_memory
in
context
.image
.iter
()
{
shared_memory
.with
(|
memory
|
{
let
region
=
crate
::
context
::
memory
::
Region
::
new
(
memory
.start_address
(),
memory
.size
()
);
println!
(
" virt 0x{:016x}:0x{:016x} size 0x{:08x}"
,
region
.start_address
()
.data
(),
region
.final_address
()
.data
(),
region
.size
()
);
});
}
}
{
let
grants
=
context
.grants
.read
();
if
!
grants
.is_empty
()
{
println!
(
"grants:"
);
for
grant
in
grants
.iter
()
{
let
region
=
grant
.region
();
println!
(
" virt 0x{:016x}:0x{:016x} size 0x{:08x} {}"
,
region
.start_address
()
.data
(),
region
.final_address
()
.data
(),
region
.size
(),
if
grant
.is_owned
()
{
"owned"
}
else
{
"borrowed"
},
);
}
}
}
if
let
Some
(
regs
)
=
unsafe
{
crate
::
ptrace
::
regs_for
(
&
context
)
}
{
println!
(
"regs:"
);
regs
.dump
();
let
mut
rsp
=
regs
.iret.rsp
;
println!
(
"stack: {:>016x}"
,
rsp
);
//Maximum 64 qwords
for
i
in
0
..
64
{
if
active_table
.translate
(
crate
::
paging
::
VirtualAddress
::
new
(
rsp
))
.is_some
()
{
let
value
=
*
(
rsp
as
*
const
usize
);
println!
(
" {:>016x}: {:>016x}"
,
rsp
,
value
);
if
let
Some
(
next_rsp
)
=
rsp
.checked_add
(
core
::
mem
::
size_of
::
<
usize
>
())
{
rsp
=
next_rsp
;
}
else
{
println!
(
" {:>016x}: OVERFLOW"
,
rsp
);
break
;
}
}
else
{
println!
(
" {:>016x}: GUARD PAGE"
,
rsp
);
break
;
}
}
}
// Switch to original page table
active_table
.switch
(
old_table
);
println!
();
}
println!
(
"DEBUGGER END"
);
}
This diff is collapsed.
Click to expand it.
src/lib.rs
+
3
−
0
View file @
7d9a33c6
...
@@ -104,6 +104,9 @@ mod acpi;
...
@@ -104,6 +104,9 @@ mod acpi;
/// Context management
/// Context management
pub
mod
context
;
pub
mod
context
;
/// Debugger
pub
mod
debugger
;
/// Architecture-independent devices
/// Architecture-independent devices
pub
mod
devices
;
pub
mod
devices
;
...
...
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