Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed naming confusion

  • Loading branch information...
commit 6fdd7485101fc0ec8c52c7032d17dda075cdb246 1 parent 29f7f4e
Alexander Bernauer authored
View
2  hgdbmi.cabal
@@ -48,7 +48,7 @@ library
Gdbmi.IO
Gdbmi.Commands
Gdbmi.Representation
- Gdbmi.Responses
+ Gdbmi.Semantics
hs-source-dirs: src
ghc-options: -Wall
View
8 src/Gdbmi/IO.hs
@@ -28,9 +28,9 @@ import System.IO (Handle, hSetBuffering, BufferMode(LineBuffering), hPutStr, hWa
import System.Posix.IO (fdToHandle, createPipe)
import System.Process (ProcessHandle, runProcess, waitForProcess)
-import qualified Gdbmi.Commands as C
+import qualified Gdbmi.Commands as C
import qualified Gdbmi.Representation as R
-import qualified Gdbmi.Responses as S
+import qualified Gdbmi.Semantics as S
data Context = Context { -- {{{1
-- gdb process {{{2
@@ -66,7 +66,7 @@ data Callback -- {{{1
= Callback {
cbStream :: [R.Stream] -> IO () -- ^ call-back for 'Gdbmi.Representation.Stream' events
, cbNotify :: [R.Notification] -> IO () -- ^ call-back for 'Gdbmi.Representation.Notification' events
- , cbStopped :: Maybe ([S.Stopped] -> IO ()) -- ^ optionally a special call-back for 'Gdbmi.Responses.Stopped' events
+ , cbStopped :: Maybe ([S.Stopped] -> IO ()) -- ^ optionally a special call-back for 'Gdbmi.Semantics.Stopped' events
}
-- | Configuration
@@ -187,7 +187,7 @@ callBack ctx output = forkIO go >> return ()
streams = R.output_stream output
notifications = R.output_notification output
(stops, others) = partition ((&&) <$> (R.Exec==) . R.notiClass <*> (R.ACStop==) . R.notiAsyncClass) notifications
- Just stops' = sequence $ map (S.response_stopped . R.notiResults) stops
+ Just stops' = sequence $ map (S.notification_stopped . R.notiResults) stops
in case stoppedCbMb of
Nothing -> do
when (not (null streams)) (streamsCb streams)
View
12 src/Gdbmi/Responses.hs → src/Gdbmi/Semantics.hs
@@ -1,9 +1,9 @@
--- | Data structures and conversion functions for GDB command responses.
+-- | Semantical data structures and conversion functions for GDB\/MI output.
--
-- While working with 'Gdbmi.Representation.Response' and 'Gdbmi.Representation.Notification' is always possible in general, handling the generic 'Gdbmi.Representation.Result' lists is cumbersome. This module provides convenient data types instead to facilitate pattern matching etc..
--
-- This module is incomplete, as we only implemented what we needed up to now.
-module Gdbmi.Responses
+module Gdbmi.Semantics
-- export {{{1
(
-- * Conversion Functions
@@ -13,7 +13,7 @@ module Gdbmi.Responses
response_exec_return,
response_stack_list_frames,
response_error,
- response_stopped,
+ notification_stopped,
-- * Types
-- | Please consult the GDB manual for details on the returned responses.
Breakpoint(..), BreakpointType, BreakpointDisp(..),
@@ -173,7 +173,7 @@ responseArg rs = do
<$> get rs Just "name"
<*> get rs Just "value"
--- responses {{{1
+-- functions {{{1
response_stack_list_frames :: [Result] -> Maybe Stack -- {{{2
-- | Convert the result list of a 'Gdbmi.Commands.stack_list_frames' command response.
response_stack_list_frames [item] = responseStack item
@@ -203,9 +203,9 @@ response_error [(Result variable value)] = do
asConst value
response_error _ = Nothing
-response_stopped :: [Result] -> Maybe Stopped -- {{{2
+notification_stopped :: [Result] -> Maybe Stopped -- {{{2
-- | Convert the result list of a 'Gdbmi.Representation.Notification' with 'Gdbmi.Representation.NotificationClass' 'Gdbmi.Representation.Exec' and 'Gdbmi.Representation.AsyncClass' 'Gdbmi.Representation.ACStop'.
-response_stopped items = responseStopped items
+notification_stopped items = responseStopped items
-- utils {{{1
get :: [Result] -> (String -> Maybe a) -> (String -> Maybe a) -- {{{2
View
64 tests/io.hs
@@ -1,4 +1,26 @@
{-# LANGUAGE QuasiQuotes #-}
+{-
+ - Test the IO interface of hgdbmi.
+ -
+ - Requirements:
+ - - gdb (see config)
+ - - gcc (see setup)
+ -
+ - Steps:
+ - - create temporary directory
+ - - write test program (example)
+ - - compile test program with debugging
+ - - start debugger
+ - - set breakpoint
+ - - run debugger
+ - - wait for stop event, evaluate variable and continue (10 times)
+ - - quit
+ - - dump log file
+ -
+ - Output:
+ - - stream and notification events (excluding stop events)
+ - - log file with GDB/MI communication
+-}
module Main (main) where
import Control.Concurrent (newEmptyMVar, putMVar, takeMVar, MVar)
@@ -13,12 +35,12 @@ import Text.Printf (printf)
import Paste (paste)
import qualified Gdbmi.IO as G
-import qualified Gdbmi.Commands as G
-import qualified Gdbmi.Responses as G
-import qualified Gdbmi.Representation as G
+import qualified Gdbmi.Commands as C
+import qualified Gdbmi.Semantics as S
+import qualified Gdbmi.Representation as R
config :: G.Config
-config = G.Config (words "schroot -c quantal -p -- gdb") (Just "gdb.log")
+config = G.Config ["gdb"] (Just "gdb.log")
example :: String
example = [paste|
@@ -37,7 +59,7 @@ int main() {
}
|]
-callback :: MVar [G.Stopped] -> G.Callback
+callback :: MVar [S.Stopped] -> G.Callback
callback mv = G.Callback print print (Just (putMVar mv))
setup :: IO ()
@@ -51,15 +73,15 @@ setup = do
error $ printf "failed to execute gcc: %s" (show ec')
ExitSuccess -> return ()
-command :: G.Context -> G.ResultClass -> G.Command -> IO [G.Result]
+command :: G.Context -> R.ResultClass -> R.Command -> IO [R.Result]
command ctx rc cmd = do
resp <- G.send_command ctx cmd
let msg = printf "command '%s' failed (%s): %s"
- (G.render_command cmd)
- (show (G.respClass resp))
- ((show . G.response_error . G.respResults) resp)
- when (G.respClass resp /= rc) (error msg)
- return (G.respResults resp)
+ (R.render_command cmd)
+ (show (R.respClass resp))
+ ((show . S.response_error . R.respResults) resp)
+ when (R.respClass resp /= rc) (error msg)
+ return (R.respResults resp)
assert :: (Eq a, Show a) => String -> a -> a -> IO ()
assert what x y = if (x == y)
@@ -72,19 +94,19 @@ test = do
mv <- newEmptyMVar
ctx <- G.setup config (callback mv)
let cmd = command ctx
- _ <- cmd G.RCDone $ G.cli_command "tty /dev/null"
- _ <- cmd G.RCDone $ G.file_exec_and_symbols (Just "example")
- let loc = G.file_function_location "example.c" "print"
- bp' <- cmd G.RCDone $ G.break_insert False False False False False Nothing Nothing Nothing loc
- let (Just bp) = G.response_break_insert bp'
- _ <- cmd G.RCRunning $ G.exec_run (Left True)
+ _ <- cmd R.RCDone $ C.cli_command "tty /dev/null"
+ _ <- cmd R.RCDone $ C.file_exec_and_symbols (Just "example")
+ let loc = C.file_function_location "example.c" "print"
+ bp' <- cmd R.RCDone $ C.break_insert False False False False False Nothing Nothing Nothing loc
+ let (Just bp) = S.response_break_insert bp'
+ _ <- cmd R.RCRunning $ C.exec_run (Left True)
forM_ [(0::Int)..10] (\counter -> do
[stopped] <- takeMVar mv
- assert "breakpoint number" ((G.bkptHitNumber . G.stoppedReason) stopped) (G.bkptNumber bp)
- value' <- cmd G.RCDone $ G.data_evaluate_expression "i"
- let (Just value) = G.response_data_evaluate_expression value'
+ assert "breakpoint number" ((S.bkptHitNumber . S.stoppedReason) stopped) (S.bkptNumber bp)
+ value' <- cmd R.RCDone $ C.data_evaluate_expression "i"
+ let (Just value) = S.response_data_evaluate_expression value'
assert "value of i" value (show counter)
- _ <- cmd G.RCRunning $ G.exec_continue False (Left True)
+ _ <- cmd R.RCRunning $ C.exec_continue False (Left True)
return ()
)
G.shutdown ctx
View
4 tests/pure.hs
@@ -3,7 +3,7 @@ module Main (main) where
-- imports {{{1
import Gdbmi.Representation
-import Gdbmi.Responses
+import Gdbmi.Semantics
import Test.Framework (Test, defaultMain, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit ((@=?), Assertion)
@@ -246,7 +246,7 @@ test_response_stopped = enumTestGroup "response_stopped" $ map runTest [
let
output = parse_output (tail str)
[notification] = output_notification output
- stp' = response_stopped (notiResults notification)
+ stp' = notification_stopped (notiResults notification)
in
show (Just stp) @=? show stp'
Please sign in to comment.
Something went wrong with that request. Please try again.