Skip to content

Commit

Permalink
Merge pull request #14 from pm100/workspace
Browse files Browse the repository at this point in the history
reorg to separate db engine
  • Loading branch information
pm100 authored Feb 4, 2024
2 parents 4d437ba + e00d27c commit 0cc0787
Show file tree
Hide file tree
Showing 27 changed files with 7,554 additions and 244 deletions.
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ log = "0.4.20"
once_cell = "1.19.0"
rustyline = {version="13.0.0", features=["with-file-history"]}
shlex = "1.2.0"
simplelog = "0.12.1"

thiserror = "1.0.51"
dbgdata={path = "dbgdata"}
util={path="util"}

[build-dependencies]
built = {version = "0.7.1", features=["git2"]}
Expand All @@ -31,3 +33,6 @@ lto = true
[dependencies.rusqlite]
version = "0.30.0"
features = ["bundled"]

[workspace]
members=[ "dbgdata", "util"]
21 changes: 21 additions & 0 deletions dbgdata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "dbgdata"
version = "0.2.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.75"
bitflags = "2.4.1"
hex = "0.4.3"
log = "0.4.20"
once_cell = "1.19.0"

util = {path = "../util"}



[dependencies.rusqlite]
version = "0.30.0"
features = ["bundled"]
61 changes: 61 additions & 0 deletions dbgdata/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
MIT License

Copyright (c) 2023 Paul Moore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

====================================

This software depends on the cc65 projects sim65 emulator core https://github.com/cc65/cc65

Its license is reproduced here

/*****************************************************************************/
/* */
/* 6502.c */
/* */
/* CPU core for the 6502 */
/* */
/* */
/* */
/* (C) 2003-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: [email protected] */
/* */
/* Mar-2017, Christian Krueger, added support for 65SC02 */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
51 changes: 47 additions & 4 deletions src/db/debugdb.rs → dbgdata/src/debugdb.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use anyhow::{anyhow, bail, Result};
use rusqlite::Transaction;
use util::{say, verbose};

//pub const NO_PARAMS: = [];
use crate::db::util::Extract;
use crate::debugger::core::{HLSym, SegChunk, Segment, Symbol, SymbolType};
use crate::{say, verbose};
use crate::util::Extract;
use rusqlite::{
params,
types::{Null, Value as SqlValue},
Expand All @@ -17,6 +15,7 @@ use std::{
io::{BufRead, BufReader},
path::{Path, PathBuf},
};

#[derive(Debug)]
pub struct SourceInfo {
pub file_id: i64,
Expand All @@ -35,6 +34,49 @@ pub struct SourceFile {
pub loaded: Cell<bool>,
pub failed: bool,
}
pub struct HLSym {
pub name: String,
pub value: i64,
pub type_: String,
pub seg: u8,
pub scope: i64,
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum SymbolType {
Unknown,
Equate,
Label,
CSymbol,
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Symbol {
pub name: String,
pub value: u16,
pub module: String,
pub sym_type: SymbolType,
}
pub struct SegChunk {
pub offset: u16,
pub module: i32,
pub module_name: String,
pub size: u16,
}
pub struct Segment {
pub id: u8, // number in db
pub name: String, // name in db
pub start: u16, // start address
pub size: u16, // end address
pub seg_type: u8, // type in db
pub modules: Vec<SegChunk>,
}
pub enum SegmentType {
Code = 0,
ReadOnly = 1,
ReadWrite = 2,
Zp = 3,
// Bss = 4,
// OverWrite = 5,
}
pub struct DebugData {
pub conn: Connection,
pub(crate) file_table: HashMap<i64, SourceFile>,
Expand Down Expand Up @@ -166,6 +208,7 @@ impl DebugData {
}
v.push((name, val, m));
}

Ok(v)
}

Expand Down
4 changes: 4 additions & 0 deletions dbgdata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod debugdb;
pub mod parsedb;
pub mod setupdb;
pub mod util;
13 changes: 6 additions & 7 deletions src/db/parsedb.rs → dbgdata/src/parsedb.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use anyhow::{anyhow, bail, Result};
//use csv::StringRecord;

type StringRecord = Vec<String>;
//pub const NO_PARAMS: = [];
use crate::db::util::Extract;
use crate::debugdb::DebugData;

use crate::util::Extract;

use crate::debugdb::SegmentType;
use util::say;

use crate::say;
use crate::{db::debugdb::DebugData, debugger::core::SegmentType};
use rusqlite::{params, Transaction};
use std::collections::HashSet;
use std::{
Expand Down Expand Up @@ -326,7 +327,6 @@ impl DebugData {
}

fn dedup_symdef(&self) -> Result<()> {

// an equ in a header file will be in the symbol table
// multiple times, strip out the dups

Expand All @@ -351,7 +351,6 @@ impl DebugData {
Ok(())
}
fn merge_csymbols(&mut self, mut symcount: i64) -> Result<()> {

// insert static c symbols into symdef
let sql = "select * from csymbol";
let rows = self.query_db(params![], sql)?;
Expand Down
2 changes: 1 addition & 1 deletion src/db/setupdb.rs → dbgdata/src/setupdb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::db::debugdb::DebugData;
use crate::debugdb::DebugData;
use anyhow::Result;

impl DebugData {
Expand Down
File renamed without changes.
Binary file added samples/.db65.db
Binary file not shown.
43 changes: 43 additions & 0 deletions samples/.db65_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#V2
load heap
en -s -m
run
bt
g
bt
g
q
load heap
run
g
q
load segviol
run
en -s -m
run
g
q
load segviol
run
q
load segviol
en -s -m
run
q
load segviol
en -s -m
run
g
bt
dis =pc-10
dis =.pc-10
dis
bt
dis =$200
q
status
load heap
status
go
run
q
Binary file added samples/heap
Binary file not shown.
Loading

0 comments on commit 0cc0787

Please sign in to comment.