Skip to content

Commit 0cc0787

Browse files
authored
Merge pull request #14 from pm100/workspace
reorg to separate db engine
2 parents 4d437ba + e00d27c commit 0cc0787

27 files changed

+7554
-244
lines changed

Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ log = "0.4.20"
1717
once_cell = "1.19.0"
1818
rustyline = {version="13.0.0", features=["with-file-history"]}
1919
shlex = "1.2.0"
20-
simplelog = "0.12.1"
20+
2121
thiserror = "1.0.51"
22+
dbgdata={path = "dbgdata"}
23+
util={path="util"}
2224

2325
[build-dependencies]
2426
built = {version = "0.7.1", features=["git2"]}
@@ -31,3 +33,6 @@ lto = true
3133
[dependencies.rusqlite]
3234
version = "0.30.0"
3335
features = ["bundled"]
36+
37+
[workspace]
38+
members=[ "dbgdata", "util"]

dbgdata/Cargo.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "dbgdata"
3+
version = "0.2.3"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
anyhow = "1.0.75"
10+
bitflags = "2.4.1"
11+
hex = "0.4.3"
12+
log = "0.4.20"
13+
once_cell = "1.19.0"
14+
15+
util = {path = "../util"}
16+
17+
18+
19+
[dependencies.rusqlite]
20+
version = "0.30.0"
21+
features = ["bundled"]

dbgdata/LICENSE

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Paul Moore
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
====================================
24+
25+
This software depends on the cc65 projects sim65 emulator core https://github.com/cc65/cc65
26+
27+
Its license is reproduced here
28+
29+
/*****************************************************************************/
30+
/* */
31+
/* 6502.c */
32+
/* */
33+
/* CPU core for the 6502 */
34+
/* */
35+
/* */
36+
/* */
37+
/* (C) 2003-2012, Ullrich von Bassewitz */
38+
/* Roemerstrasse 52 */
39+
/* D-70794 Filderstadt */
40+
/* EMail: [email protected] */
41+
/* */
42+
/* Mar-2017, Christian Krueger, added support for 65SC02 */
43+
/* */
44+
/* This software is provided 'as-is', without any expressed or implied */
45+
/* warranty. In no event will the authors be held liable for any damages */
46+
/* arising from the use of this software. */
47+
/* */
48+
/* Permission is granted to anyone to use this software for any purpose, */
49+
/* including commercial applications, and to alter it and redistribute it */
50+
/* freely, subject to the following restrictions: */
51+
/* */
52+
/* 1. The origin of this software must not be misrepresented; you must not */
53+
/* claim that you wrote the original software. If you use this software */
54+
/* in a product, an acknowledgment in the product documentation would be */
55+
/* appreciated but is not required. */
56+
/* 2. Altered source versions must be plainly marked as such, and must not */
57+
/* be misrepresented as being the original software. */
58+
/* 3. This notice may not be removed or altered from any source */
59+
/* distribution. */
60+
/* */
61+
/*****************************************************************************/

src/db/debugdb.rs renamed to dbgdata/src/debugdb.rs

+47-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use anyhow::{anyhow, bail, Result};
22
use rusqlite::Transaction;
3+
use util::{say, verbose};
34

4-
//pub const NO_PARAMS: = [];
5-
use crate::db::util::Extract;
6-
use crate::debugger::core::{HLSym, SegChunk, Segment, Symbol, SymbolType};
7-
use crate::{say, verbose};
5+
use crate::util::Extract;
86
use rusqlite::{
97
params,
108
types::{Null, Value as SqlValue},
@@ -17,6 +15,7 @@ use std::{
1715
io::{BufRead, BufReader},
1816
path::{Path, PathBuf},
1917
};
18+
2019
#[derive(Debug)]
2120
pub struct SourceInfo {
2221
pub file_id: i64,
@@ -35,6 +34,49 @@ pub struct SourceFile {
3534
pub loaded: Cell<bool>,
3635
pub failed: bool,
3736
}
37+
pub struct HLSym {
38+
pub name: String,
39+
pub value: i64,
40+
pub type_: String,
41+
pub seg: u8,
42+
pub scope: i64,
43+
}
44+
#[derive(Debug, Clone, Eq, PartialEq)]
45+
pub enum SymbolType {
46+
Unknown,
47+
Equate,
48+
Label,
49+
CSymbol,
50+
}
51+
#[derive(Debug, Clone, Eq, PartialEq)]
52+
pub struct Symbol {
53+
pub name: String,
54+
pub value: u16,
55+
pub module: String,
56+
pub sym_type: SymbolType,
57+
}
58+
pub struct SegChunk {
59+
pub offset: u16,
60+
pub module: i32,
61+
pub module_name: String,
62+
pub size: u16,
63+
}
64+
pub struct Segment {
65+
pub id: u8, // number in db
66+
pub name: String, // name in db
67+
pub start: u16, // start address
68+
pub size: u16, // end address
69+
pub seg_type: u8, // type in db
70+
pub modules: Vec<SegChunk>,
71+
}
72+
pub enum SegmentType {
73+
Code = 0,
74+
ReadOnly = 1,
75+
ReadWrite = 2,
76+
Zp = 3,
77+
// Bss = 4,
78+
// OverWrite = 5,
79+
}
3880
pub struct DebugData {
3981
pub conn: Connection,
4082
pub(crate) file_table: HashMap<i64, SourceFile>,
@@ -166,6 +208,7 @@ impl DebugData {
166208
}
167209
v.push((name, val, m));
168210
}
211+
169212
Ok(v)
170213
}
171214

dbgdata/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod debugdb;
2+
pub mod parsedb;
3+
pub mod setupdb;
4+
pub mod util;

src/db/parsedb.rs renamed to dbgdata/src/parsedb.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use anyhow::{anyhow, bail, Result};
2-
//use csv::StringRecord;
32

43
type StringRecord = Vec<String>;
5-
//pub const NO_PARAMS: = [];
6-
use crate::db::util::Extract;
4+
use crate::debugdb::DebugData;
5+
6+
use crate::util::Extract;
7+
8+
use crate::debugdb::SegmentType;
9+
use util::say;
710

8-
use crate::say;
9-
use crate::{db::debugdb::DebugData, debugger::core::SegmentType};
1011
use rusqlite::{params, Transaction};
1112
use std::collections::HashSet;
1213
use std::{
@@ -326,7 +327,6 @@ impl DebugData {
326327
}
327328

328329
fn dedup_symdef(&self) -> Result<()> {
329-
330330
// an equ in a header file will be in the symbol table
331331
// multiple times, strip out the dups
332332

@@ -351,7 +351,6 @@ impl DebugData {
351351
Ok(())
352352
}
353353
fn merge_csymbols(&mut self, mut symcount: i64) -> Result<()> {
354-
355354
// insert static c symbols into symdef
356355
let sql = "select * from csymbol";
357356
let rows = self.query_db(params![], sql)?;

src/db/setupdb.rs renamed to dbgdata/src/setupdb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::db::debugdb::DebugData;
1+
use crate::debugdb::DebugData;
22
use anyhow::Result;
33

44
impl DebugData {
File renamed without changes.

samples/.db65.db

96 KB
Binary file not shown.

samples/.db65_history

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#V2
2+
load heap
3+
en -s -m
4+
run
5+
bt
6+
g
7+
bt
8+
g
9+
q
10+
load heap
11+
run
12+
g
13+
q
14+
load segviol
15+
run
16+
en -s -m
17+
run
18+
g
19+
q
20+
load segviol
21+
run
22+
q
23+
load segviol
24+
en -s -m
25+
run
26+
q
27+
load segviol
28+
en -s -m
29+
run
30+
g
31+
bt
32+
dis =pc-10
33+
dis =.pc-10
34+
dis
35+
bt
36+
dis =$200
37+
q
38+
status
39+
load heap
40+
status
41+
go
42+
run
43+
q

samples/heap

1.64 KB
Binary file not shown.

0 commit comments

Comments
 (0)